@@ -29,7 +29,7 @@ use crate::proto::device_path::LoadedImageDevicePath;
29
29
30
30
pub use uefi:: table:: boot:: {
31
31
AllocateType , EventNotifyFn , LoadImageSource , OpenProtocolAttributes , OpenProtocolParams ,
32
- SearchType , TimerTrigger ,
32
+ ProtocolSearchKey , SearchType , TimerTrigger ,
33
33
} ;
34
34
pub use uefi_raw:: table:: boot:: { EventType , MemoryAttribute , MemoryDescriptor , MemoryType , Tpl } ;
35
35
@@ -375,7 +375,7 @@ pub fn check_event(event: Event) -> Result<bool> {
375
375
376
376
/// Removes `event` from any event group to which it belongs and closes it.
377
377
///
378
- /// If `event` was registered with `register_protocol_notify`, then the
378
+ /// If `event` was registered with [ `register_protocol_notify`] , then the
379
379
/// corresponding registration will be removed. Calling this function within the
380
380
/// corresponding notify function is allowed.
381
381
///
@@ -616,6 +616,34 @@ pub unsafe fn uninstall_protocol_interface(
616
616
( bt. uninstall_protocol_interface ) ( handle. as_ptr ( ) , protocol, interface) . to_result ( )
617
617
}
618
618
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
+
619
647
/// Get the list of protocol interface [`Guids`][Guid] that are installed
620
648
/// on a [`Handle`].
621
649
///
0 commit comments