Skip to content

Commit fd6a001

Browse files
authored
Merge pull request #1323 from rust-osdev/bishop-as-raw
uefi: Add table::system_table_raw
2 parents 8791ec3 + fc3764c commit fd6a001

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

uefi/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ details of a significant change to the API in this release.
1010
boot services using the global system table.
1111
- `uefi::runtime` is a new module that provides freestanding functions for
1212
runtime services using the global system table.
13+
- `uefi::table::system_table_raw` is a new function to retrieve a raw pointer to
14+
the global system table.
1315
- Add standard derives for `ConfigTableEntry`.
1416
- `PcrEvent`/`PcrEventInputs` impl `Align`, `Eq`, and `PartialEq`.
1517
- Added `PcrEvent::new_in_box` and `PcrEventInputs::new_in_box`.

uefi/src/table/mod.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ use core::sync::atomic::{AtomicPtr, Ordering};
1818
static SYSTEM_TABLE: AtomicPtr<uefi_raw::table::system::SystemTable> =
1919
AtomicPtr::new(ptr::null_mut());
2020

21+
/// Get the raw system table pointer.
22+
///
23+
/// If called before `set_system_table` has been called, this will return `None`.
24+
pub fn system_table_raw() -> Option<NonNull<uefi_raw::table::system::SystemTable>> {
25+
let ptr = SYSTEM_TABLE.load(Ordering::Acquire);
26+
NonNull::new(ptr)
27+
}
28+
2129
/// Get the raw system table pointer. This may only be called after
2230
/// `set_system_table` has been used to set the global pointer.
2331
///
@@ -26,8 +34,7 @@ static SYSTEM_TABLE: AtomicPtr<uefi_raw::table::system::SystemTable> =
2634
/// Panics if the global system table pointer is null.
2735
#[track_caller]
2836
pub(crate) fn system_table_raw_panicking() -> NonNull<uefi_raw::table::system::SystemTable> {
29-
let ptr = SYSTEM_TABLE.load(Ordering::Acquire);
30-
NonNull::new(ptr).expect("global system table pointer is not set")
37+
system_table_raw().expect("global system table pointer is not set")
3138
}
3239

3340
/// Update the global system table pointer.

0 commit comments

Comments
 (0)