summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/HALKit/ARM64/APM/APM+IO.cc
blob: fc53e4e09c111ddea8dd01c9d7bdb696ae3bf043 (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-2025, Amlal El Mahrouss, all rights reserved.

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

#include <modules/APM/APM.h>
#include <KernelKit/KPC.h>

using namespace Kernel;

/// @brief Send APM command to it's 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, =0x84000004\n"
			"svc #0\n");

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

		return kErrorSuccess;
	}
	default:
		return kErrorInvalidData;
	}
}