Skip to content

Commit c77cf23

Browse files
committed
uefi-helpers: remove exit hook
No need for the complicated and error-prone approach using an event.
1 parent c3d0f8a commit c77cf23

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

uefi-services/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ pub use uefi::{print, println};
99

1010
#[deprecated = "WARNING: `uefi-services` is deprecated. Functionality was moved to `uefi::helpers::init`."]
1111
pub fn init(st: &mut SystemTable<Boot>) -> Result<Option<Event>> {
12-
uefi::helpers::init(st)
12+
uefi::helpers::init(st).map(|_| None)
1313
}

uefi/src/helpers/mod.rs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@
1313
//! epoch.
1414
1515
use crate::prelude::{Boot, SystemTable};
16-
use crate::Event;
1716
use crate::Result;
1817
use crate::StatusExt;
1918
use core::ffi::c_void;
2019
use core::ptr;
21-
use core::ptr::NonNull;
2220
use core::sync::atomic::{AtomicPtr, Ordering};
2321
#[doc(hidden)]
2422
pub use println::_print;
25-
use uefi_raw::table::boot::{EventType, Tpl};
2623
use uefi_raw::Status;
2724

2825
#[cfg(feature = "global_allocator")]
@@ -73,10 +70,10 @@ fn system_table() -> SystemTable<Boot> {
7370
///
7471
/// **PLEASE NOTE** that these helpers are meant for the pre exit boot service
7572
/// epoch.
76-
pub fn init(st: &mut SystemTable<Boot>) -> Result<Option<Event>> {
73+
pub fn init(st: &mut SystemTable<Boot>) -> Result<()> {
7774
if system_table_opt().is_some() {
7875
// Avoid double initialization.
79-
return Status::SUCCESS.to_result_with_val(|| None);
76+
return Status::SUCCESS.to_result_with_val(|| ());
8077
}
8178

8279
// Setup the system table singleton
@@ -89,23 +86,12 @@ pub fn init(st: &mut SystemTable<Boot>) -> Result<Option<Event>> {
8986
logger::init(st);
9087

9188
uefi::allocator::init(st);
92-
93-
// Schedule these tools to be disabled on exit from UEFI boot services
94-
let boot_services = st.boot_services();
95-
boot_services
96-
.create_event(
97-
EventType::SIGNAL_EXIT_BOOT_SERVICES,
98-
Tpl::NOTIFY,
99-
Some(exit_boot_services),
100-
None,
101-
)
102-
.map(Some)
10389
}
90+
91+
Ok(())
10492
}
10593

106-
/// Notify the utility library that boot services are not safe to call anymore
107-
/// As this is a callback, it must be `extern "efiapi"`.
108-
unsafe extern "efiapi" fn exit_boot_services(_e: Event, _ctx: Option<NonNull<c_void>>) {
94+
pub(crate) fn exit() {
10995
// DEBUG: The UEFI spec does not guarantee that this printout will work, as
11096
// the services used by logging might already have been shut down.
11197
// But it works on current OVMF, and can be used as a handy way to

uefi/src/table/system.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ impl SystemTable<Boot> {
230230
self,
231231
memory_type: MemoryType,
232232
) -> (SystemTable<Runtime>, MemoryMap<'static>) {
233+
crate::helpers::exit();
234+
233235
let boot_services = self.boot_services();
234236

235237
// Reboot the device.

0 commit comments

Comments
 (0)