Skip to content

Add Tpl to uefi-raw and use it from uefi #790

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
May 4, 2023
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
26 changes: 26 additions & 0 deletions uefi-raw/src/table/boot.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//! UEFI services available during boot.

newtype_enum! {
/// Task priority level.
///
/// Although the UEFI specification repeatedly states that only the variants
/// specified below should be used in application-provided input, as the other
/// are reserved for internal firmware use, it might still happen that the
/// firmware accidentally discloses one of these internal TPLs to us.
///
/// Since feeding an unexpected variant to a Rust enum is UB, this means that
/// this C enum must be interfaced via the newtype pattern.
pub enum Tpl: usize => {
/// Normal task execution level.
APPLICATION = 4,
/// Async interrupt-style callbacks run at this TPL.
CALLBACK = 8,
/// Notifications are masked at this level.
///
/// This is used in critical sections of code.
NOTIFY = 16,
/// Highest priority level.
///
/// Even processor interrupts are disable at this level.
HIGH_LEVEL = 31,
}}
2 changes: 2 additions & 0 deletions uefi-raw/src/table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

mod revision;

pub mod boot;

pub use revision::Revision;
27 changes: 2 additions & 25 deletions uefi/src/table/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ use {
::alloc::vec::Vec,
};

pub use uefi_raw::table::boot::Tpl;

// TODO: this similar to `SyncUnsafeCell`. Once that is stabilized we
// can use it instead.
struct GlobalImageHandle {
Expand Down Expand Up @@ -1673,31 +1675,6 @@ pub enum LoadImageSource<'a> {
},
}

newtype_enum! {
/// Task priority level.
///
/// Although the UEFI specification repeatedly states that only the variants
/// specified below should be used in application-provided input, as the other
/// are reserved for internal firmware use, it might still happen that the
/// firmware accidentally discloses one of these internal TPLs to us.
///
/// Since feeding an unexpected variant to a Rust enum is UB, this means that
/// this C enum must be interfaced via the newtype pattern.
pub enum Tpl: usize => {
/// Normal task execution level.
APPLICATION = 4,
/// Async interrupt-style callbacks run at this TPL.
CALLBACK = 8,
/// Notifications are masked at this level.
///
/// This is used in critical sections of code.
NOTIFY = 16,
/// Highest priority level.
///
/// Even processor interrupts are disable at this level.
HIGH_LEVEL = 31,
}}

/// RAII guard for task priority level changes
///
/// Will automatically restore the former task priority level when dropped.
Expand Down