microsoft/openvmm
Publicmirrored fromhttps://github.com/microsoft/openvmmAvailable
guest_test_uefi/src/uefi/rt.rs
28lines · modecode
| 1 | // Copyright (C) Microsoft Corporation. All rights reserved. |
| 2 | |
| 3 | //! Runtime support for the UEFI application environment. |
| 4 | |
| 5 | #[cfg(target_os = "uefi")] |
| 6 | #[panic_handler] |
| 7 | fn panic_handler(panic: &core::panic::PanicInfo<'_>) -> ! { |
| 8 | use uefi::println; |
| 9 | |
| 10 | println!("{}", panic); |
| 11 | |
| 12 | // If the system table is available, use UEFI's standard shutdown mechanism |
| 13 | if uefi::table::system_table_raw().is_none() { |
| 14 | use uefi::table::runtime::ResetType; |
| 15 | uefi::runtime::reset(ResetType::SHUTDOWN, uefi::Status::ABORTED, None); |
| 16 | } |
| 17 | |
| 18 | println!("Could not shut down... falling back to invoking an undefined instruction"); |
| 19 | |
| 20 | // SAFETY: the undefined instruction trap handler in `guest_test_uefi` will not return |
| 21 | unsafe { |
| 22 | #[cfg(target_arch = "x86_64")] |
| 23 | core::arch::asm!("ud2"); |
| 24 | #[cfg(target_arch = "aarch64")] |
| 25 | core::arch::asm!("brk #0"); |
| 26 | core::hint::unreachable_unchecked(); |
| 27 | } |
| 28 | } |
| 29 | |