blob: c4d0154b9f990195addc04615881566852bbf6e3 (
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
|
/* ========================================
Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
======================================== */
#include <KernelKit/KPC.h>
#include <modules/APM/APM.h>
using namespace Kernel;
/// @brief Send APM command to its 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) {
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;
}
}
|