@@ -11,7 +11,8 @@ use core::ops::{Deref, DerefMut};
1111use core:: ptr:: { self , NonNull } ;
1212use core:: sync:: atomic:: { AtomicPtr , Ordering } ;
1313use core:: { mem, slice} ;
14- use uefi:: { table, Char16 , Event , Handle , Result , Status , StatusExt } ;
14+ use uefi:: { table, Char16 , Event , Guid , Handle , Result , Status , StatusExt } ;
15+ use uefi_raw:: table:: boot:: InterfaceType ;
1516
1617#[ cfg( doc) ]
1718use {
@@ -299,6 +300,39 @@ pub fn disconnect_controller(
299300 . to_result_with_err ( |_| ( ) )
300301}
301302
303+ /// Installs a protocol interface on a device handle.
304+ ///
305+ /// When a protocol interface is installed, firmware will call all functions
306+ /// that have registered to wait for that interface to be installed.
307+ ///
308+ /// If `handle` is `None`, a new handle will be created and returned.
309+ ///
310+ /// # Safety
311+ ///
312+ /// The caller is responsible for ensuring that they pass a valid `Guid` for `protocol`.
313+ ///
314+ /// # Errors
315+ ///
316+ /// * [`Status::OUT_OF_RESOURCES`]: failed to allocate a new handle.
317+ /// * [`Status::INVALID_PARAMETER`]: this protocol is already installed on the handle.
318+ pub unsafe fn install_protocol_interface (
319+ handle : Option < Handle > ,
320+ protocol : & Guid ,
321+ interface : * const c_void ,
322+ ) -> Result < Handle > {
323+ let bt = boot_services_raw_panicking ( ) ;
324+ let bt = unsafe { bt. as_ref ( ) } ;
325+
326+ let mut handle = Handle :: opt_to_ptr ( handle) ;
327+ ( ( bt. install_protocol_interface ) (
328+ & mut handle,
329+ protocol,
330+ InterfaceType :: NATIVE_INTERFACE ,
331+ interface,
332+ ) )
333+ . to_result_with_val ( || Handle :: from_ptr ( handle) . unwrap ( ) )
334+ }
335+
302336/// Returns an array of handles that support the requested protocol in a
303337/// pool-allocated buffer.
304338///
0 commit comments