Skip to content

uefi: Add table::system_table_raw #1323

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 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions uefi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ details of a significant change to the API in this release.
boot services using the global system table.
- `uefi::runtime` is a new module that provides freestanding functions for
runtime services using the global system table.
- `uefi::table::system_table_raw` is a new function to retrieve a raw pointer to
the global system table.
- Add standard derives for `ConfigTableEntry`.
- `PcrEvent`/`PcrEventInputs` impl `Align`, `Eq`, and `PartialEq`.
- Added `PcrEvent::new_in_box` and `PcrEventInputs::new_in_box`.
Expand Down
11 changes: 9 additions & 2 deletions uefi/src/table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ use core::sync::atomic::{AtomicPtr, Ordering};
static SYSTEM_TABLE: AtomicPtr<uefi_raw::table::system::SystemTable> =
AtomicPtr::new(ptr::null_mut());

/// Get the raw system table pointer.
///
/// If called before `set_system_table` has been called, this will return `None`.
pub fn system_table_raw() -> Option<NonNull<uefi_raw::table::system::SystemTable>> {
let ptr = SYSTEM_TABLE.load(Ordering::Acquire);
NonNull::new(ptr)
}

/// Get the raw system table pointer. This may only be called after
/// `set_system_table` has been used to set the global pointer.
///
Expand All @@ -26,8 +34,7 @@ static SYSTEM_TABLE: AtomicPtr<uefi_raw::table::system::SystemTable> =
/// Panics if the global system table pointer is null.
#[track_caller]
pub(crate) fn system_table_raw_panicking() -> NonNull<uefi_raw::table::system::SystemTable> {
let ptr = SYSTEM_TABLE.load(Ordering::Acquire);
NonNull::new(ptr).expect("global system table pointer is not set")
system_table_raw().expect("global system table pointer is not set")
}

/// Update the global system table pointer.
Expand Down