Skip to content

Commit 575078a

Browse files
committed
Add RuntimeServices::update_capsule
This allows passing capsules[1] to firmware. Firmware updates cannot be explicitly tested as it is not supported by OVMF. [1]:https://uefi.org/specs/UEFI/2.9_A/08_Services_Runtime_Services.html#update-capsule
1 parent 4710689 commit 575078a

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

uefi/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# uefi - [Unreleased]
22

3+
## Added
4+
- Added `RuntimeServices::update_capsule`.
5+
36
## Removed
47
- Removed the `panic-on-logger-errors` feature of the `uefi` crate. Logger
58
errors are now silently ignored.

uefi/src/table/runtime.rs

+19
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ use core::fmt::{self, Debug, Display, Formatter};
77
use core::mem::MaybeUninit;
88
use core::ptr;
99

10+
pub use uefi_raw::capsule::{CapsuleBlockDescriptor, CapsuleHeader};
1011
pub use uefi_raw::table::runtime::{
1112
ResetType, TimeCapabilities, VariableAttributes, VariableVendor,
1213
};
1314
pub use uefi_raw::time::Daylight;
15+
pub use uefi_raw::PhysicalAddress;
1416

1517
#[cfg(feature = "alloc")]
1618
use {
@@ -290,6 +292,23 @@ impl RuntimeServices {
290292
) -> Status {
291293
(self.0.set_virtual_address_map)(map_size, desc_size, desc_version, virtual_map)
292294
}
295+
296+
/// Passes capsules to the firmware. Capsules are most commonly used to update the firmware
297+
/// or for by the operating system to have information persist across a system reset.
298+
pub fn update_capsule(
299+
&self,
300+
capsule_header_array: &[&CapsuleHeader],
301+
capsule_block_descriptors: &[CapsuleBlockDescriptor],
302+
) -> Result {
303+
unsafe {
304+
(self.0.update_capsule)(
305+
capsule_header_array.as_ptr().cast(),
306+
capsule_header_array.len(),
307+
capsule_block_descriptors.as_ptr() as PhysicalAddress,
308+
)
309+
.to_result()
310+
}
311+
}
293312
}
294313

295314
impl super::Table for RuntimeServices {

0 commit comments

Comments
 (0)