Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion uefi-test-runner/src/boot/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ fn test_check_event_freestanding() {
let event =
unsafe { boot::create_event(EventType::NOTIFY_WAIT, Tpl::CALLBACK, Some(callback), None) }
.unwrap();
let is_signaled = boot::check_event(event).unwrap();

let event_clone = unsafe { event.unsafe_clone() };
let is_signaled = boot::check_event(event_clone).unwrap();
assert!(!is_signaled);

boot::close_event(event).unwrap();
}

fn test_timer_freestanding() {
Expand All @@ -56,6 +60,8 @@ fn test_timer_freestanding() {
let mut events = unsafe { [timer_event.unsafe_clone()] };
boot::set_timer(&timer_event, TimerTrigger::Relative(5_0 /*00 ns */)).unwrap();
assert_eq!(boot::wait_for_event(&mut events).unwrap(), 0);

boot::close_event(timer_event).unwrap();
}

fn test_timer(bt: &BootServices) {
Expand Down
17 changes: 17 additions & 0 deletions uefi/src/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,23 @@ pub fn check_event(event: Event) -> Result<bool> {
}
}

/// Removes `event` from any event group to which it belongs and closes it.
///
/// If `event` was registered with `register_protocol_notify`, then the
/// corresponding registration will be removed. Calling this function within the
/// corresponding notify function is allowed.
///
/// # Errors
///
/// The specification does not list any errors, however implementations are
/// allowed to return an error if needed.
pub fn close_event(event: Event) -> Result {
let bt = boot_services_raw_panicking();
let bt = unsafe { bt.as_ref() };

unsafe { (bt.close_event)(event.as_ptr()) }.to_result()
}

/// Sets the trigger for an event of type [`TIMER`].
///
/// # Errors
Expand Down