@@ -29,7 +29,7 @@ use crate::proto::device_path::LoadedImageDevicePath;
2929
3030pub use uefi:: table:: boot:: {
3131 AllocateType , EventNotifyFn , LoadImageSource , OpenProtocolAttributes , OpenProtocolParams ,
32- SearchType , TimerTrigger ,
32+ ProtocolSearchKey , SearchType , TimerTrigger ,
3333} ;
3434pub use uefi_raw:: table:: boot:: { EventType , MemoryAttribute , MemoryDescriptor , MemoryType , Tpl } ;
3535
@@ -375,7 +375,7 @@ pub fn check_event(event: Event) -> Result<bool> {
375375
376376/// Removes `event` from any event group to which it belongs and closes it.
377377///
378- /// If `event` was registered with `register_protocol_notify`, then the
378+ /// If `event` was registered with [ `register_protocol_notify`] , then the
379379/// corresponding registration will be removed. Calling this function within the
380380/// corresponding notify function is allowed.
381381///
@@ -616,6 +616,34 @@ pub unsafe fn uninstall_protocol_interface(
616616 ( bt. uninstall_protocol_interface ) ( handle. as_ptr ( ) , protocol, interface) . to_result ( )
617617}
618618
619+ /// Registers `event` to be signaled whenever a protocol interface is registered for
620+ /// `protocol` by [`install_protocol_interface`] or [`reinstall_protocol_interface`].
621+ ///
622+ /// If successful, a [`SearchType::ByRegisterNotify`] is returned. This can be
623+ /// used with [`locate_handle`] or [`locate_handle_buffer`] to identify the
624+ /// newly (re)installed handles that support `protocol`.
625+ ///
626+ /// Events can be unregistered from protocol interface notification by calling [`close_event`].
627+ ///
628+ /// # Errors
629+ ///
630+ /// * [`Status::OUT_OF_RESOURCES`]: the event could not be allocated.
631+ pub fn register_protocol_notify (
632+ protocol : & ' static Guid ,
633+ event : & Event ,
634+ ) -> Result < SearchType < ' static > > {
635+ let bt = boot_services_raw_panicking ( ) ;
636+ let bt = unsafe { bt. as_ref ( ) } ;
637+
638+ let mut key = ptr:: null ( ) ;
639+ unsafe { ( bt. register_protocol_notify ) ( protocol, event. as_ptr ( ) , & mut key) } . to_result_with_val (
640+ || {
641+ // OK to unwrap: key is non-null for Status::SUCCESS.
642+ SearchType :: ByRegisterNotify ( ProtocolSearchKey ( NonNull :: new ( key. cast_mut ( ) ) . unwrap ( ) ) )
643+ } ,
644+ )
645+ }
646+
619647/// Get the list of protocol interface [`Guids`][Guid] that are installed
620648/// on a [`Handle`].
621649///
0 commit comments