panic! now properly kernel panics instead of aborting the current process

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

View File

@ -14,21 +14,18 @@ use core::panic::PanicInfo;
#[panic_handler]
fn panic(info: &PanicInfo<'_>) -> ! {
print!("Kernel panic in ");
if let Some(tasking) = TASKING.try_lock() {
if let Some(pid) = tasking.current_pid() {
print!("PID {}", pid);
} else {
print!("Kernel Init");
print!("kernel init");
}
} else {
print!("PID Unknown");
}
println!(" {info}");
println!(": {info}");
#[cfg(debug_assertions)]
print_backtrace();
if let Some(mut tasking) = TASKING.try_lock() {
tasking.exit();
} else {
exit_qemu();
}
exit_qemu();
}