]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
hal: add system reboot abstraction and route shell reboot through HAL
authorTulio A M Mendes <[email protected]>
Thu, 5 Feb 2026 20:47:02 +0000 (17:47 -0300)
committerTulio A M Mendes <[email protected]>
Thu, 5 Feb 2026 20:47:02 +0000 (17:47 -0300)
include/hal/system.h [new file with mode: 0644]
src/hal/arm/system.c [new file with mode: 0644]
src/hal/mips/system.c [new file with mode: 0644]
src/hal/riscv/system.c [new file with mode: 0644]
src/hal/x86/system.c [new file with mode: 0644]
src/kernel/shell.c

diff --git a/include/hal/system.h b/include/hal/system.h
new file mode 100644 (file)
index 0000000..18b1c4b
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef HAL_SYSTEM_H
+#define HAL_SYSTEM_H
+
+void hal_system_reboot(void);
+
+#endif
diff --git a/src/hal/arm/system.c b/src/hal/arm/system.c
new file mode 100644 (file)
index 0000000..abfdb09
--- /dev/null
@@ -0,0 +1,4 @@
+#include "hal/system.h"
+
+void hal_system_reboot(void) {
+}
diff --git a/src/hal/mips/system.c b/src/hal/mips/system.c
new file mode 100644 (file)
index 0000000..abfdb09
--- /dev/null
@@ -0,0 +1,4 @@
+#include "hal/system.h"
+
+void hal_system_reboot(void) {
+}
diff --git a/src/hal/riscv/system.c b/src/hal/riscv/system.c
new file mode 100644 (file)
index 0000000..abfdb09
--- /dev/null
@@ -0,0 +1,4 @@
+#include "hal/system.h"
+
+void hal_system_reboot(void) {
+}
diff --git a/src/hal/x86/system.c b/src/hal/x86/system.c
new file mode 100644 (file)
index 0000000..c6fe056
--- /dev/null
@@ -0,0 +1,15 @@
+#include "hal/system.h"
+
+#if defined(__i386__) || defined(__x86_64__)
+#include "io.h"
+#include <stdint.h>
+
+void hal_system_reboot(void) {
+    uint8_t good = 0x02;
+    while (good & 0x02) good = inb(0x64);
+    outb(0x64, 0xFE);
+}
+#else
+void hal_system_reboot(void) {
+}
+#endif
index acabec1aee53af89becc8c27d2eb086e6a3e89a2..c710020cebb6f08486df40ea3086d41f4b54258e 100644 (file)
@@ -8,6 +8,8 @@
 #include "fs.h"
 #include "heap.h"
 
+#include "hal/system.h"
+
 #define MAX_CMD_LEN 256
 static char cmd_buffer[MAX_CMD_LEN];
 static int cmd_index = 0;
@@ -80,9 +82,7 @@ void execute_command(char* cmd) {
         int a = 1; int b = 0; int c = a / b; (void)c;
     }
     else if (strcmp(cmd, "reboot") == 0) {
-        uint8_t good = 0x02;
-        while (good & 0x02) good = inb(0x64);
-        outb(0x64, 0xFE);
+        hal_system_reboot();
     }
     else if (strlen(cmd) > 0) {
         uart_print("Unknown command: ");