Skip to content

Add RuntimeServices::query_capsule_capabilities #1166

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 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
1 change: 1 addition & 0 deletions uefi-raw/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Changed
- `maximum_capsule_size` of `query_capsule_capabilities` now takes a *mut u64 instead of a *mut usize.
- `ResetType` now derives the `Default` trait.

# uefi-raw - 0.5.2 (2024-04-19)

Expand Down
1 change: 1 addition & 0 deletions uefi-raw/src/table/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pub struct RuntimeServices {
}

newtype_enum! {
#[derive(Default)]
/// The type of system reset.
pub enum ResetType: u32 => {
/// System-wide reset.
Expand Down
1 change: 1 addition & 0 deletions uefi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Added
- Added `RuntimeServices::update_capsule`.
- Added `RuntimeServices::query_capsule_capabilities`.

## Removed
- Removed the `panic-on-logger-errors` feature of the `uefi` crate. Logger
Expand Down
32 changes: 32 additions & 0 deletions uefi/src/table/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,25 @@ impl RuntimeServices {
.to_result()
}
}

/// Tests whether a capsule or capsules can be updated via [`RuntimeServices::update_capsule`].
///
/// See [`CapsuleInfo`] for details of the information returned.
pub fn query_capsule_capabilities(
&self,
capsule_header_array: &[&CapsuleHeader],
) -> Result<CapsuleInfo> {
let mut info = CapsuleInfo::default();
unsafe {
(self.0.query_capsule_capabilities)(
capsule_header_array.as_ptr().cast(),
capsule_header_array.len(),
&mut info.maximum_capsule_size,
&mut info.reset_type,
)
.to_result_with_val(|| info)
}
}
}

impl super::Table for RuntimeServices {
Expand Down Expand Up @@ -551,3 +570,16 @@ pub struct VariableStorageInfo {
/// Maximum size of an individual variable of the specified type.
pub maximum_variable_size: u64,
}

/// Information about UEFI variable storage space returned by
/// [`RuntimeServices::query_capsule_capabilities`].
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct CapsuleInfo {
/// The maximum size in bytes that [`RuntimeServices::update_capsule`]
/// can support as input. Note that the size of an update capsule is composed of
/// all [`CapsuleHeader`]s and [CapsuleBlockDescriptor]s.
pub maximum_capsule_size: u64,

/// The type of reset required for the capsule update.
pub reset_type: ResetType,
}