Skip to content

Commit 98bcffb

Browse files
boot: Add freestanding uninstall_protocol_interface
1 parent 1841270 commit 98bcffb

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

uefi/src/boot.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,32 @@ pub unsafe fn reinstall_protocol_interface(
362362
.to_result()
363363
}
364364

365+
/// Removes a protocol interface from a device handle.
366+
///
367+
/// # Safety
368+
///
369+
/// The caller is responsible for ensuring that there are no references to a protocol interface
370+
/// that has been removed. Some protocols may not be able to be removed as there is no information
371+
/// available regarding the references. This includes Console I/O, Block I/O, Disk I/o, and handles
372+
/// to device protocols.
373+
///
374+
/// The caller is responsible for ensuring that they pass a valid `Guid` for `protocol`.
375+
///
376+
/// # Errors
377+
///
378+
/// * [`Status::NOT_FOUND`]: the interface was not found on the handle.
379+
/// * [`Status::ACCESS_DENIED`]: the interface is still in use and cannot be uninstalled.
380+
pub unsafe fn uninstall_protocol_interface(
381+
handle: Handle,
382+
protocol: &Guid,
383+
interface: *const c_void,
384+
) -> Result<()> {
385+
let bt = boot_services_raw_panicking();
386+
let bt = unsafe { bt.as_ref() };
387+
388+
(bt.uninstall_protocol_interface)(handle.as_ptr(), protocol, interface).to_result()
389+
}
390+
365391
/// Returns an array of handles that support the requested protocol in a
366392
/// pool-allocated buffer.
367393
///

0 commit comments

Comments
 (0)