File tree 2 files changed +38
-0
lines changed
uefi-test-runner/src/boot
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>) {
17
17
info ! ( "Testing timer..." ) ;
18
18
test_timer ( bt) ;
19
19
info ! ( "Testing events..." ) ;
20
+ test_check_event_freestanding ( ) ;
20
21
test_event_callback ( bt) ;
21
22
test_callback_with_ctx ( bt) ;
22
23
info ! ( "Testing watchdog..." ) ;
@@ -35,6 +36,18 @@ fn test_tpl() {
35
36
let _guard = unsafe { boot:: raise_tpl ( Tpl :: NOTIFY ) } ;
36
37
}
37
38
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
+
38
51
fn test_timer ( bt : & BootServices ) {
39
52
let timer_event = unsafe { bt. create_event ( EventType :: TIMER , Tpl :: APPLICATION , None , None ) }
40
53
. 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(
208
208
)
209
209
}
210
210
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
+
211
236
/// Connect one or more drivers to a controller.
212
237
///
213
238
/// Usually one disconnects and then reconnects certain drivers
You can’t perform that action at this time.
0 commit comments