Skip to content

Commit 8d0085c

Browse files
authored
Merge pull request #1359 from nicholasbishop/bishop-update-panic-handler
uefi: Update panic handler to use the global system table
2 parents 790ead3 + da0908d commit 8d0085c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

uefi/src/helpers/panic_handler.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
use crate::println;
2-
use crate::table::system_table_boot;
1+
use crate::{boot, println};
32
use cfg_if::cfg_if;
43

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

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

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

0 commit comments

Comments
 (0)