Skip to content

Commit 1841270

Browse files
boot: Add freestanding reinstall_protocol_interface
1 parent 1ce728f commit 1841270

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

uefi/src/boot.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,35 @@ pub unsafe fn install_protocol_interface(
333333
.to_result_with_val(|| Handle::from_ptr(handle).unwrap())
334334
}
335335

336+
/// Reinstalls a protocol interface on a device handle. `old_interface` is replaced with `new_interface`.
337+
/// These interfaces may be the same, in which case the registered protocol notifications occur for the handle
338+
/// without replacing the interface.
339+
///
340+
/// As with `install_protocol_interface`, any process that has registered to wait for the installation of
341+
/// the interface is notified.
342+
///
343+
/// # Safety
344+
///
345+
/// The caller is responsible for ensuring that there are no references to the `old_interface` that is being
346+
/// removed.
347+
///
348+
/// # Errors
349+
///
350+
/// * [`Status::NOT_FOUND`]: the old interface was not found on the handle.
351+
/// * [`Status::ACCESS_DENIED`]: the old interface is still in use and cannot be uninstalled.
352+
pub unsafe fn reinstall_protocol_interface(
353+
handle: Handle,
354+
protocol: &Guid,
355+
old_interface: *const c_void,
356+
new_interface: *const c_void,
357+
) -> Result<()> {
358+
let bt = boot_services_raw_panicking();
359+
let bt = unsafe { bt.as_ref() };
360+
361+
(bt.reinstall_protocol_interface)(handle.as_ptr(), protocol, old_interface, new_interface)
362+
.to_result()
363+
}
364+
336365
/// Returns an array of handles that support the requested protocol in a
337366
/// pool-allocated buffer.
338367
///

0 commit comments

Comments
 (0)