From dcf82e0b329a79beba3e961ff1033ed030d60604 Mon Sep 17 00:00:00 2001 From: pjht Date: Tue, 6 Aug 2024 18:34:34 -0500 Subject: [PATCH] Gracefully fail if QEMU does not exit --- src/qemu_exit.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/qemu_exit.rs b/src/qemu_exit.rs index 5ff08be..d804f70 100644 --- a/src/qemu_exit.rs +++ b/src/qemu_exit.rs @@ -1,6 +1,6 @@ use x86_64::instructions::port::Port; -use crate::{kernel_heap::HEAP, physical_memory::PHYSICAL_MEMORY}; +use crate::{kernel_heap::HEAP, physical_memory::PHYSICAL_MEMORY, println}; pub fn exit_qemu() -> ! { PHYSICAL_MEMORY.lock().print_stats(); @@ -8,5 +8,9 @@ pub fn exit_qemu() -> ! { unsafe { Port::new(0xf4).write(0u32); } - unreachable!(); + println!("Failed to quit QEMU! Disabling interupts and halting CPU!"); + x86_64::instructions::interrupts::disable(); + loop { + x86_64::instructions::hlt(); + } }