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