From c93496895afaf8388cd08fe461e57fa1b3c5d557 Mon Sep 17 00:00:00 2001 From: Tulio A M Mendes Date: Fri, 6 Feb 2026 08:42:43 -0300 Subject: [PATCH] shell: make panic command deterministic (ud2 on x86) --- src/kernel/shell.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/kernel/shell.c b/src/kernel/shell.c index c710020..f00050b 100644 --- a/src/kernel/shell.c +++ b/src/kernel/shell.c @@ -9,6 +9,7 @@ #include "heap.h" #include "hal/system.h" +#include "hal/cpu.h" #define MAX_CMD_LEN 256 static char cmd_buffer[MAX_CMD_LEN]; @@ -79,7 +80,14 @@ void execute_command(char* cmd) { uart_print(" Total RAM: [TODO] MB\n"); } else if (strcmp(cmd, "panic") == 0) { - int a = 1; int b = 0; int c = a / b; (void)c; +#if defined(__i386__) || defined(__x86_64__) + __asm__ volatile("cli"); + __asm__ volatile("ud2"); +#else + for(;;) { + hal_cpu_idle(); + } +#endif } else if (strcmp(cmd, "reboot") == 0) { hal_system_reboot(); -- 2.43.0