Skip to content

uefi: Update panic handler to use the global system table #1359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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