Skip to content

Commit c684367

Browse files
authored
Merge pull request #1304 from nicholasbishop/bishop-close-event
boot: Add freestanding close_event
2 parents fcfe676 + 9438077 commit c684367

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

uefi-test-runner/src/boot/misc.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ fn test_check_event_freestanding() {
4646
let event =
4747
unsafe { boot::create_event(EventType::NOTIFY_WAIT, Tpl::CALLBACK, Some(callback), None) }
4848
.unwrap();
49-
let is_signaled = boot::check_event(event).unwrap();
49+
50+
let event_clone = unsafe { event.unsafe_clone() };
51+
let is_signaled = boot::check_event(event_clone).unwrap();
5052
assert!(!is_signaled);
53+
54+
boot::close_event(event).unwrap();
5155
}
5256

5357
fn test_timer_freestanding() {
@@ -56,6 +60,8 @@ fn test_timer_freestanding() {
5660
let mut events = unsafe { [timer_event.unsafe_clone()] };
5761
boot::set_timer(&timer_event, TimerTrigger::Relative(5_0 /*00 ns */)).unwrap();
5862
assert_eq!(boot::wait_for_event(&mut events).unwrap(), 0);
63+
64+
boot::close_event(timer_event).unwrap();
5965
}
6066

6167
fn test_timer(bt: &BootServices) {

uefi/src/boot.rs

+17
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,23 @@ pub fn check_event(event: Event) -> Result<bool> {
234234
}
235235
}
236236

237+
/// Removes `event` from any event group to which it belongs and closes it.
238+
///
239+
/// If `event` was registered with `register_protocol_notify`, then the
240+
/// corresponding registration will be removed. Calling this function within the
241+
/// corresponding notify function is allowed.
242+
///
243+
/// # Errors
244+
///
245+
/// The specification does not list any errors, however implementations are
246+
/// allowed to return an error if needed.
247+
pub fn close_event(event: Event) -> Result {
248+
let bt = boot_services_raw_panicking();
249+
let bt = unsafe { bt.as_ref() };
250+
251+
unsafe { (bt.close_event)(event.as_ptr()) }.to_result()
252+
}
253+
237254
/// Sets the trigger for an event of type [`TIMER`].
238255
///
239256
/// # Errors

0 commit comments

Comments
 (0)