@@ -79,17 +79,18 @@ struct BootServicesInternal {
79
79
notify_tpl : Tpl ,
80
80
notify_func : Option < EventNotifyFn > ,
81
81
notify_ctx : Option < NonNull < c_void > > ,
82
- out_event : * mut Option < Event > ,
82
+ out_event : * mut uefi_raw :: Event ,
83
83
) -> Status ,
84
- set_timer : unsafe extern "efiapi" fn ( event : Event , ty : u32 , trigger_time : u64 ) -> Status ,
84
+ set_timer :
85
+ unsafe extern "efiapi" fn ( event : uefi_raw:: Event , ty : u32 , trigger_time : u64 ) -> Status ,
85
86
wait_for_event : unsafe extern "efiapi" fn (
86
87
number_of_events : usize ,
87
- events : * mut Event ,
88
+ events : * mut uefi_raw :: Event ,
88
89
out_index : * mut usize ,
89
90
) -> Status ,
90
- signal_event : unsafe extern "efiapi" fn ( event : Event ) -> Status ,
91
- close_event : unsafe extern "efiapi" fn ( event : Event ) -> Status ,
92
- check_event : unsafe extern "efiapi" fn ( event : Event ) -> Status ,
91
+ signal_event : unsafe extern "efiapi" fn ( event : uefi_raw :: Event ) -> Status ,
92
+ close_event : unsafe extern "efiapi" fn ( event : uefi_raw :: Event ) -> Status ,
93
+ check_event : unsafe extern "efiapi" fn ( event : uefi_raw :: Event ) -> Status ,
93
94
94
95
// Protocol handlers
95
96
install_protocol_interface : unsafe extern "efiapi" fn (
@@ -118,7 +119,7 @@ struct BootServicesInternal {
118
119
_reserved : usize ,
119
120
register_protocol_notify : unsafe extern "efiapi" fn (
120
121
protocol : & Guid ,
121
- event : Event ,
122
+ event : uefi_raw :: Event ,
122
123
registration : * mut Option < ProtocolSearchKey > ,
123
124
) -> Status ,
124
125
locate_handle : unsafe extern "efiapi" fn (
@@ -235,7 +236,7 @@ struct BootServicesInternal {
235
236
notify_fn : Option < EventNotifyFn > ,
236
237
notify_ctx : Option < NonNull < c_void > > ,
237
238
event_group : Option < NonNull < Guid > > ,
238
- out_event : * mut Option < Event > ,
239
+ out_event : * mut uefi_raw :: Event ,
239
240
) -> Status ,
240
241
}
241
242
@@ -528,13 +529,13 @@ impl BootServices {
528
529
notify_fn : Option < EventNotifyFn > ,
529
530
notify_ctx : Option < NonNull < c_void > > ,
530
531
) -> Result < Event > {
531
- let mut event = None ;
532
+ let mut event = ptr :: null_mut ( ) ;
532
533
533
534
// Now we're ready to call UEFI
534
535
( self . 0 . create_event ) ( event_ty, notify_tpl, notify_fn, notify_ctx, & mut event)
535
536
. to_result_with_val (
536
537
// OK to unwrap: event is non-null for Status::SUCCESS.
537
- || event. unwrap ( ) ,
538
+ || Event :: from_ptr ( event) . unwrap ( ) ,
538
539
)
539
540
}
540
541
@@ -589,7 +590,7 @@ impl BootServices {
589
590
return Err ( Status :: UNSUPPORTED . into ( ) ) ;
590
591
}
591
592
592
- let mut event = None ;
593
+ let mut event = ptr :: null_mut ( ) ;
593
594
594
595
( self . 0 . create_event_ex ) (
595
596
event_type,
@@ -601,7 +602,7 @@ impl BootServices {
601
602
)
602
603
. to_result_with_val (
603
604
// OK to unwrap: event is non-null for Status::SUCCESS.
604
- || event. unwrap ( ) ,
605
+ || Event :: from_ptr ( event) . unwrap ( ) ,
605
606
)
606
607
}
607
608
@@ -618,7 +619,7 @@ impl BootServices {
618
619
TimerTrigger :: Periodic ( hundreds_ns) => ( 1 , hundreds_ns) ,
619
620
TimerTrigger :: Relative ( hundreds_ns) => ( 2 , hundreds_ns) ,
620
621
} ;
621
- unsafe { ( self . 0 . set_timer ) ( event. unsafe_clone ( ) , ty, time) } . to_result ( )
622
+ unsafe { ( self . 0 . set_timer ) ( event. as_ptr ( ) , ty, time) } . to_result ( )
622
623
}
623
624
624
625
/// Stops execution until an event is signaled.
@@ -656,7 +657,9 @@ impl BootServices {
656
657
/// * [`uefi::Status::INVALID_PARAMETER`]
657
658
/// * [`uefi::Status::UNSUPPORTED`]
658
659
pub fn wait_for_event ( & self , events : & mut [ Event ] ) -> Result < usize , Option < usize > > {
659
- let ( number_of_events, events) = ( events. len ( ) , events. as_mut_ptr ( ) ) ;
660
+ let number_of_events = events. len ( ) ;
661
+ let events: * mut uefi_raw:: Event = events. as_mut_ptr ( ) . cast ( ) ;
662
+
660
663
let mut index = 0 ;
661
664
unsafe { ( self . 0 . wait_for_event ) ( number_of_events, events, & mut index) } . to_result_with (
662
665
|| index,
@@ -691,7 +694,7 @@ impl BootServices {
691
694
pub fn signal_event ( & self , event : & Event ) -> Result {
692
695
// Safety: cloning this event should be safe, as we're directly passing it to firmware
693
696
// and not keeping the clone around.
694
- unsafe { ( self . 0 . signal_event ) ( event. unsafe_clone ( ) ) . to_result ( ) }
697
+ unsafe { ( self . 0 . signal_event ) ( event. as_ptr ( ) ) . to_result ( ) }
695
698
}
696
699
697
700
/// Removes `event` from any event group to which it belongs and closes it. If `event` was
@@ -708,7 +711,7 @@ impl BootServices {
708
711
///
709
712
/// * [`uefi::Status::INVALID_PARAMETER`]
710
713
pub fn close_event ( & self , event : Event ) -> Result {
711
- unsafe { ( self . 0 . close_event ) ( event) . to_result ( ) }
714
+ unsafe { ( self . 0 . close_event ) ( event. as_ptr ( ) ) . to_result ( ) }
712
715
}
713
716
714
717
/// Checks to see if an event is signaled, without blocking execution to wait for it.
@@ -725,7 +728,7 @@ impl BootServices {
725
728
///
726
729
/// * [`uefi::Status::INVALID_PARAMETER`]
727
730
pub fn check_event ( & self , event : Event ) -> Result < bool > {
728
- let status = unsafe { ( self . 0 . check_event ) ( event) } ;
731
+ let status = unsafe { ( self . 0 . check_event ) ( event. as_ptr ( ) ) } ;
729
732
match status {
730
733
Status :: SUCCESS => Ok ( true ) ,
731
734
Status :: NOT_READY => Ok ( false ) ,
@@ -848,7 +851,7 @@ impl BootServices {
848
851
) -> Result < ( Event , SearchType ) > {
849
852
let mut key = None ;
850
853
// Safety: we clone `event` a couple times, but there will be only one left once we return.
851
- unsafe { ( self . 0 . register_protocol_notify ) ( protocol, event. unsafe_clone ( ) , & mut key) }
854
+ unsafe { ( self . 0 . register_protocol_notify ) ( protocol, event. as_ptr ( ) , & mut key) }
852
855
// Safety: as long as this call is successful, `key` will be valid.
853
856
. to_result_with_val ( || unsafe {
854
857
(
0 commit comments