File tree 3 files changed +61
-0
lines changed
uefi-test-runner/src/boot
3 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ pub fn test() {
17
17
info ! ( "Testing events..." ) ;
18
18
test_check_event ( ) ;
19
19
test_callback_with_ctx ( ) ;
20
+ test_signal_event ( ) ;
20
21
info ! ( "Testing watchdog..." ) ;
21
22
test_watchdog ( ) ;
22
23
info ! ( "Testing protocol handler services..." ) ;
@@ -92,6 +93,38 @@ fn test_callback_with_ctx() {
92
93
assert_eq ! ( data, 456 ) ;
93
94
}
94
95
96
+ fn test_signal_event ( ) {
97
+ let mut data = 123u32 ;
98
+
99
+ extern "efiapi" fn callback ( _event : Event , ctx : Option < NonNull < c_void > > ) {
100
+ info ! ( "Inside the signal event callback" ) ;
101
+ // Safety: this callback is run within the parent function's
102
+ // scope, so the context pointer is still valid.
103
+ unsafe {
104
+ let ctx = ctx. unwrap ( ) . as_ptr ( ) . cast :: < u32 > ( ) ;
105
+ * ctx = 456 ;
106
+ }
107
+ }
108
+
109
+ let ctx: * mut u32 = & mut data;
110
+ let ctx = NonNull :: new ( ctx. cast :: < c_void > ( ) ) . unwrap ( ) ;
111
+
112
+ let event = unsafe {
113
+ boot:: create_event (
114
+ EventType :: NOTIFY_SIGNAL ,
115
+ Tpl :: CALLBACK ,
116
+ Some ( callback) ,
117
+ Some ( ctx) ,
118
+ )
119
+ . expect ( "Failed to create event with context" )
120
+ } ;
121
+
122
+ boot:: signal_event ( & event) . expect ( "Failed to signal event" ) ;
123
+
124
+ // Check that `data` was updated inside the event callback.
125
+ assert_eq ! ( data, 456 ) ;
126
+ }
127
+
95
128
fn test_watchdog ( ) {
96
129
// There's no way to check the watchdog timer value, so just test setting it.
97
130
Original file line number Diff line number Diff line change 1
1
# uefi - [ Unreleased]
2
2
3
+ ## Added
4
+ - Added ` boot::signal_event ` .
5
+
3
6
## Changed
4
7
- ** Breaking:** Removed ` BootPolicyError ` as ` BootPolicy ` construction is no
5
8
longer fallible. ` BootPolicy ` now tightly integrates the new ` Boolean ` type
Original file line number Diff line number Diff line change @@ -467,6 +467,31 @@ pub fn check_event(event: Event) -> Result<bool> {
467
467
}
468
468
}
469
469
470
+ /// Places the supplied `event` in the signaled state. If `event` is already in
471
+ /// the signaled state, the function returns successfully. If `event` is of type
472
+ /// [`NOTIFY_SIGNAL`], the event's notification function is scheduled to be
473
+ /// invoked at the event's notification task priority level.
474
+ ///
475
+ /// This function may be invoked from any task priority level.
476
+ ///
477
+ /// If `event` is part of an event group, then all of the events in the event
478
+ /// group are also signaled and their notification functions are scheduled.
479
+ ///
480
+ /// When signaling an event group, it is possible to create an event in the
481
+ /// group, signal it and then close the event to remove it from the group.
482
+ ///
483
+ /// # Errors
484
+ ///
485
+ /// The specification does not list any errors.
486
+ ///
487
+ /// [`NOTIFY_SIGNAL`]: EventType::NOTIFY_SIGNAL
488
+ pub fn signal_event ( event : & Event ) -> Result {
489
+ let bt = boot_services_raw_panicking ( ) ;
490
+ let bt = unsafe { bt. as_ref ( ) } ;
491
+
492
+ unsafe { ( bt. signal_event ) ( event. as_ptr ( ) ) } . to_result ( )
493
+ }
494
+
470
495
/// Removes `event` from any event group to which it belongs and closes it.
471
496
///
472
497
/// If `event` was registered with [`register_protocol_notify`], then the
You can’t perform that action at this time.
0 commit comments