Skip to content

Commit d684b13

Browse files
boot: Add freestanding set_timer
1 parent c7668ee commit d684b13

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

uefi/src/boot.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use {
2121

2222
pub use uefi::table::boot::{
2323
AllocateType, EventNotifyFn, LoadImageSource, OpenProtocolAttributes, OpenProtocolParams,
24-
SearchType,
24+
SearchType, TimerTrigger,
2525
};
2626
pub use uefi_raw::table::boot::{EventType, MemoryType, Tpl};
2727

@@ -233,6 +233,25 @@ pub fn check_event(event: Event) -> Result<bool> {
233233
}
234234
}
235235

236+
/// Sets the trigger for an event of type [`TIMER`].
237+
///
238+
/// # Errors
239+
///
240+
/// * [`Status::INVALID_PARAMETER`]: `event` is not valid.
241+
///
242+
/// [`TIMER`]: EventType::TIMER
243+
pub fn set_timer(event: &Event, trigger_time: TimerTrigger) -> Result {
244+
let bt = boot_services_raw_panicking();
245+
let bt = unsafe { bt.as_ref() };
246+
247+
let (ty, time) = match trigger_time {
248+
TimerTrigger::Cancel => (0, 0),
249+
TimerTrigger::Periodic(hundreds_ns) => (1, hundreds_ns),
250+
TimerTrigger::Relative(hundreds_ns) => (2, hundreds_ns),
251+
};
252+
unsafe { (bt.set_timer)(event.as_ptr(), ty, time) }.to_result()
253+
}
254+
236255
/// Connect one or more drivers to a controller.
237256
///
238257
/// Usually one disconnects and then reconnects certain drivers

0 commit comments

Comments
 (0)