summaryrefslogtreecommitdiffhomepage
path: root/dev/Kernel/HALKit/ARM64/APM/APM.cc
blob: 51ac14f398176861cb8de5b41b592c362ad4ccf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* -------------------------------------------

	Copyright (C) 2024, Theater Quality Corp, all rights reserved.

------------------------------------------- */

#include <Mod/APM/APM.h>
#include <KernelKit/LPC.h>

using namespace Kernel;

/// @brief Send a APM command into it's own IO space.
/// @param base_dma the IO base port.
/// @param cmd the command.
/// @return status code.
EXTERN_C Int32 apm_send_io_command(UInt16 cmd, APMPowerCmd value)
{
	switch (cmd)
	{
	case kAPMPowerCommandReboot: {
		asm volatile(
			"ldr x0, =0x84000009\n"
			"hvc #0\n");

		return kErrorSuccess;
	}
	case kAPMPowerCommandShutdown: {
		asm volatile(
			"ldr x0, =0x84000008\n"
			"hvc #0\n");

		return kErrorSuccess;
	}
	default:
		return kErrorInvalidData;
	}
}