Skip to content

Commit 83bc8fc

Browse files
relicensing: Rewrite PR "Added BootServices::set_timer()"
This covers these commits: 2a89253
1 parent 55d62ed commit 83bc8fc

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

uefi/src/boot.rs

+24-14
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use core::ops::{Deref, DerefMut};
4242
use core::ptr::{self, NonNull};
4343
use core::sync::atomic::{AtomicPtr, Ordering};
4444
use core::{mem, slice};
45-
use uefi_raw::table::boot::InterfaceType;
45+
use uefi_raw::table::boot::{InterfaceType, TimerDelay};
4646
#[cfg(feature = "alloc")]
4747
use {alloc::vec::Vec, uefi::ResultExt};
4848

@@ -472,9 +472,9 @@ pub fn set_timer(event: &Event, trigger_time: TimerTrigger) -> Result {
472472
let bt = unsafe { bt.as_ref() };
473473

474474
let (ty, time) = match trigger_time {
475-
TimerTrigger::Cancel => (0, 0),
476-
TimerTrigger::Periodic(hundreds_ns) => (1, hundreds_ns),
477-
TimerTrigger::Relative(hundreds_ns) => (2, hundreds_ns),
475+
TimerTrigger::Cancel => (TimerDelay::CANCEL, 0),
476+
TimerTrigger::Periodic(period) => (TimerDelay::PERIODIC, period),
477+
TimerTrigger::Relative(delay) => (TimerDelay::RELATIVE, delay),
478478
};
479479
unsafe { (bt.set_timer)(event.as_ptr(), ty, time) }.to_result()
480480
}
@@ -1688,19 +1688,29 @@ impl SearchType<'_> {
16881688
/// Event notification callback type.
16891689
pub type EventNotifyFn = unsafe extern "efiapi" fn(event: Event, context: Option<NonNull<c_void>>);
16901690

1691-
/// Timer events manipulation.
1691+
/// Trigger type for events of type [`TIMER`].
1692+
///
1693+
/// See [`set_timer`].
1694+
///
1695+
/// [`TIMER`]: EventType::TIMER
16921696
#[derive(Debug)]
16931697
pub enum TimerTrigger {
1694-
/// Cancel event's timer
1698+
/// Remove the event's timer setting.
16951699
Cancel,
1696-
/// The event is to be signaled periodically.
1697-
/// Parameter is the period in 100ns units.
1698-
/// Delay of 0 will be signalled on every timer tick.
1699-
Periodic(u64),
1700-
/// The event is to be signaled once in 100ns units.
1701-
/// Parameter is the delay in 100ns units.
1702-
/// Delay of 0 will be signalled on next timer tick.
1703-
Relative(u64),
1700+
1701+
/// Trigger the event periodically.
1702+
Periodic(
1703+
/// Duration between event signaling in units of 100ns. If set to zero,
1704+
/// the event will be signaled on every timer tick.
1705+
u64,
1706+
),
1707+
1708+
/// Trigger the event one time.
1709+
Relative(
1710+
/// Duration to wait before signaling the event in units of 100ns. If
1711+
/// set to zero, the event will be signaled on the next timer tick.
1712+
u64,
1713+
),
17041714
}
17051715

17061716
/// Opaque pointer returned by [`register_protocol_notify`] to be used

0 commit comments

Comments
 (0)