From: Tulio A M Mendes Date: Thu, 5 Feb 2026 20:47:02 +0000 (-0300) Subject: hal: add system reboot abstraction and route shell reboot through HAL X-Git-Url: https://projects.tadryanom.me/?a=commitdiff_plain;h=407f1db901bb59a6f7ad9b83e7551a43f5c67362;p=AdrOS.git hal: add system reboot abstraction and route shell reboot through HAL --- diff --git a/include/hal/system.h b/include/hal/system.h new file mode 100644 index 00000000..fbcdfcfb --- /dev/null +++ b/include/hal/system.h @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: BSD-3-Clause +/* + * Copyright (c) 2018, Tulio A M Mendes + * All rights reserved. + * See LICENSE for details. + * + * Source: https://github.com/tadryanom/AdrOS + */ + +#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 index 00000000..3738b713 --- /dev/null +++ b/src/hal/arm/system.c @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: BSD-3-Clause +/* + * Copyright (c) 2018, Tulio A M Mendes + * All rights reserved. + * See LICENSE for details. + * + * Source: https://github.com/tadryanom/AdrOS + */ + +#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 index 00000000..3738b713 --- /dev/null +++ b/src/hal/mips/system.c @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: BSD-3-Clause +/* + * Copyright (c) 2018, Tulio A M Mendes + * All rights reserved. + * See LICENSE for details. + * + * Source: https://github.com/tadryanom/AdrOS + */ + +#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 index 00000000..3738b713 --- /dev/null +++ b/src/hal/riscv/system.c @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: BSD-3-Clause +/* + * Copyright (c) 2018, Tulio A M Mendes + * All rights reserved. + * See LICENSE for details. + * + * Source: https://github.com/tadryanom/AdrOS + */ + +#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 index 00000000..1e255905 --- /dev/null +++ b/src/hal/x86/system.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: BSD-3-Clause +/* + * Copyright (c) 2018, Tulio A M Mendes + * All rights reserved. + * See LICENSE for details. + * + * Source: https://github.com/tadryanom/AdrOS + */ + +#include "hal/system.h" + +#if defined(__i386__) || defined(__x86_64__) +#include "io.h" +#include + +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 diff --git a/src/kernel/shell.c b/src/kernel/shell.c index 03b5c75f..61983a58 100644 --- a/src/kernel/shell.c +++ b/src/kernel/shell.c @@ -17,6 +17,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; @@ -89,9 +91,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: ");