Skip to content

Commit

Permalink
uefi: Update panic handler to use the global system table
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasbishop committed Aug 25, 2024
1 parent 9518cd1 commit da0908d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions uefi/src/helpers/panic_handler.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use crate::println;
use crate::table::system_table_boot;
use crate::{boot, println};
use cfg_if::cfg_if;

#[panic_handler]
fn panic_handler(info: &core::panic::PanicInfo) -> ! {
println!("[PANIC]: {}", info);

// Give the user some time to read the message
if let Some(st) = system_table_boot() {
st.boot_services().stall(10_000_000);
if boot::are_boot_services_active() {
boot::stall(10_000_000);
} else {
let mut dummy = 0u64;
// FIXME: May need different counter values in debug & release builds
Expand All @@ -28,10 +27,10 @@ fn panic_handler(info: &core::panic::PanicInfo) -> ! {
qemu_exit_handle.exit_failure();
} else {
// If the system table is available, use UEFI's standard shutdown mechanism
if let Some(st) = system_table_boot() {
use crate::table::runtime::ResetType;
st.runtime_services()
.reset(ResetType::SHUTDOWN, crate::Status::ABORTED, None);
if let Some(st) = crate::table::system_table_raw() {
if !unsafe { st.as_ref().runtime_services }.is_null() {
crate::runtime::reset(crate::runtime::ResetType::SHUTDOWN, crate::Status::ABORTED, None);
}
}

// If we don't have any shutdown mechanism handy, the best we can do is loop
Expand Down

0 comments on commit da0908d

Please sign in to comment.