Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
uefi: Add table::system_table_raw_panicking
This is `pub(crate)`, not part of the public API currently.
  • Loading branch information
nicholasbishop committed Jul 15, 2024
commit 5cfc5f0dd44e38511acab5fc8881336e6e6fd55d
14 changes: 13 additions & 1 deletion uefi/src/table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,25 @@ pub use header::Header;
pub use system::{Boot, Runtime, SystemTable};
pub use uefi_raw::table::Revision;

use core::ptr;
use core::ptr::{self, NonNull};
use core::sync::atomic::{AtomicPtr, Ordering};

/// Global system table pointer. This is only modified by [`set_system_table`].
static SYSTEM_TABLE: AtomicPtr<uefi_raw::table::system::SystemTable> =
AtomicPtr::new(ptr::null_mut());

/// Get the raw system table pointer. This may only be called after
/// `set_system_table` has been used to set the global pointer.
///
/// # Panics
///
/// 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")
}

/// Update the global system table pointer.
///
/// This is called automatically in the `main` entry point as part of
Expand Down