Skip to content

Commit af7ae1d

Browse files
Merge pull request #1166 from andre-braga/query2
Add RuntimeServices::query_capsule_capabilities
2 parents 3a82f0c + bdbc80f commit af7ae1d

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

uefi-raw/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

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

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

uefi-raw/src/table/runtime.rs

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ pub struct RuntimeServices {
8080
}
8181

8282
newtype_enum! {
83+
#[derive(Default)]
8384
/// The type of system reset.
8485
pub enum ResetType: u32 => {
8586
/// System-wide reset.

uefi/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Added
44
- Added `RuntimeServices::update_capsule`.
5+
- Added `RuntimeServices::query_capsule_capabilities`.
56

67
## Removed
78
- Removed the `panic-on-logger-errors` feature of the `uefi` crate. Logger

uefi/src/table/runtime.rs

+32
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,25 @@ impl RuntimeServices {
308308
.to_result()
309309
}
310310
}
311+
312+
/// Tests whether a capsule or capsules can be updated via [`RuntimeServices::update_capsule`].
313+
///
314+
/// See [`CapsuleInfo`] for details of the information returned.
315+
pub fn query_capsule_capabilities(
316+
&self,
317+
capsule_header_array: &[&CapsuleHeader],
318+
) -> Result<CapsuleInfo> {
319+
let mut info = CapsuleInfo::default();
320+
unsafe {
321+
(self.0.query_capsule_capabilities)(
322+
capsule_header_array.as_ptr().cast(),
323+
capsule_header_array.len(),
324+
&mut info.maximum_capsule_size,
325+
&mut info.reset_type,
326+
)
327+
.to_result_with_val(|| info)
328+
}
329+
}
311330
}
312331

313332
impl super::Table for RuntimeServices {
@@ -551,3 +570,16 @@ pub struct VariableStorageInfo {
551570
/// Maximum size of an individual variable of the specified type.
552571
pub maximum_variable_size: u64,
553572
}
573+
574+
/// Information about UEFI variable storage space returned by
575+
/// [`RuntimeServices::query_capsule_capabilities`].
576+
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
577+
pub struct CapsuleInfo {
578+
/// The maximum size in bytes that [`RuntimeServices::update_capsule`]
579+
/// can support as input. Note that the size of an update capsule is composed of
580+
/// all [`CapsuleHeader`]s and [CapsuleBlockDescriptor]s.
581+
pub maximum_capsule_size: u64,
582+
583+
/// The type of reset required for the capsule update.
584+
pub reset_type: ResetType,
585+
}

0 commit comments

Comments
 (0)