summaryrefslogtreecommitdiffhomepage
path: root/src/kernel/HALKit/ARM64/APM
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/HALKit/ARM64/APM')
-rw-r--r--src/kernel/HALKit/ARM64/APM/APM+IO.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/kernel/HALKit/ARM64/APM/APM+IO.cc b/src/kernel/HALKit/ARM64/APM/APM+IO.cc
new file mode 100644
index 00000000..c4d0154b
--- /dev/null
+++ b/src/kernel/HALKit/ARM64/APM/APM+IO.cc
@@ -0,0 +1,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;
+ }
+}