Gracefully fail if QEMU does not exit

This commit is contained in:
pjht 2024-08-06 18:34:34 -05:00
parent fcf672a969
commit dcf82e0b32
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -1,6 +1,6 @@
use x86_64::instructions::port::Port; 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() -> ! { pub fn exit_qemu() -> ! {
PHYSICAL_MEMORY.lock().print_stats(); PHYSICAL_MEMORY.lock().print_stats();
@ -8,5 +8,9 @@ pub fn exit_qemu() -> ! {
unsafe { unsafe {
Port::new(0xf4).write(0u32); 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();
}
} }