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