File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
uefi-test-runner/src/boot Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ pub fn test(st: &SystemTable<Boot>) {
1717 info ! ( "Testing timer..." ) ;
1818 test_timer ( bt) ;
1919 info ! ( "Testing events..." ) ;
20+ test_check_event_freestanding ( ) ;
2021 test_event_callback ( bt) ;
2122 test_callback_with_ctx ( bt) ;
2223 info ! ( "Testing watchdog..." ) ;
@@ -35,6 +36,18 @@ fn test_tpl() {
3536 let _guard = unsafe { boot:: raise_tpl ( Tpl :: NOTIFY ) } ;
3637}
3738
39+ fn test_check_event_freestanding ( ) {
40+ extern "efiapi" fn callback ( _event : Event , _ctx : Option < NonNull < c_void > > ) {
41+ info ! ( "Callback triggered by check_event" ) ;
42+ }
43+
44+ let event =
45+ unsafe { boot:: create_event ( EventType :: NOTIFY_WAIT , Tpl :: CALLBACK , Some ( callback) , None ) }
46+ . unwrap ( ) ;
47+ let is_signaled = boot:: check_event ( event) . unwrap ( ) ;
48+ assert ! ( !is_signaled) ;
49+ }
50+
3851fn test_timer ( bt : & BootServices ) {
3952 let timer_event = unsafe { bt. create_event ( EventType :: TIMER , Tpl :: APPLICATION , None , None ) }
4053 . expect ( "Failed to create TIMER event" ) ;
Original file line number Diff line number Diff line change @@ -208,6 +208,31 @@ pub unsafe fn create_event(
208208 )
209209}
210210
211+ /// Checks to see if an event is signaled, without blocking execution to wait for it.
212+ ///
213+ /// Returns `Ok(true)` if the event is in the signaled state or `Ok(false)`
214+ /// if the event is not in the signaled state.
215+ ///
216+ /// # Errors
217+ ///
218+ /// Note: Instead of returning [`Status::NOT_READY`] as listed in the UEFI
219+ /// Specification, this function will return `Ok(false)`.
220+ ///
221+ /// * [`Status::INVALID_PARAMETER`]: `event` is of type [`NOTIFY_SIGNAL`].
222+ ///
223+ /// [`NOTIFY_SIGNAL`]: EventType::NOTIFY_SIGNAL
224+ pub fn check_event ( event : Event ) -> Result < bool > {
225+ let bt = boot_services_raw_panicking ( ) ;
226+ let bt = unsafe { bt. as_ref ( ) } ;
227+
228+ let status = unsafe { ( bt. check_event ) ( event. as_ptr ( ) ) } ;
229+ match status {
230+ Status :: SUCCESS => Ok ( true ) ,
231+ Status :: NOT_READY => Ok ( false ) ,
232+ _ => Err ( status. into ( ) ) ,
233+ }
234+ }
235+
211236/// Connect one or more drivers to a controller.
212237///
213238/// Usually one disconnects and then reconnects certain drivers
You can’t perform that action at this time.
0 commit comments