diff --git a/Kernel/Panic.cpp b/Kernel/Panic.cpp index 5e754b7c32..4c75c19eb9 100644 --- a/Kernel/Panic.cpp +++ b/Kernel/Panic.cpp @@ -7,19 +7,20 @@ #include #include #include +#include #include #include namespace Kernel { -[[noreturn]] static void __reset() +[[noreturn]] static void __shutdown() { - // FIXME: This works for i686/x86_64, but needs to be ported to any other arch when needed. - asm( - "lidt 0\n" - "movl $0, 0\n"); - - __builtin_unreachable(); + // Note: This will invoke QEMU Shutdown, but for other platforms (or emulators), + // this has no effect on the system, so we still need to halt afterwards. + // We also try the Bochs/Old QEMU shutdown method, if the first didn't work. + IO::out16(0x604, 0x2000); + IO::out16(0xb004, 0x2000); + Processor::halt(); } void __panic(const char* file, unsigned int line, const char* function) @@ -27,7 +28,7 @@ void __panic(const char* file, unsigned int line, const char* function) critical_dmesgln("at {}:{} in {}", file, line, function); dump_backtrace(); if (kernel_command_line().boot_mode() == BootMode::SelfTest) - __reset(); + __shutdown(); else Processor::halt(); }