sbi_rt/time.rs
1//! Chapter 6. Timer Extension (EID #0x54494D45 "TIME")
2
3use sbi_spec::{
4 binary::SbiRet,
5 time::{EID_TIME, SET_TIMER},
6};
7
8/// Programs the clock for the next event after an absolute time.
9///
10/// Parameter `stime_value` is in absolute time.
11/// This function must clear the pending timer-interrupt bit as well.
12///
13/// If the supervisor wishes to clear the timer interrupt without scheduling the next timer event,
14/// it can either request a timer interrupt infinitely far into the future (i.e., `u64::MAX`),
15/// or it can instead mask the timer interrupt by clearing `sie.STIE` CSR bit.
16///
17/// This function is defined in RISC-V SBI Specification chapter 6.1.
18#[inline]
19#[doc(alias = "sbi_set_timer")]
20pub fn set_timer(stime_value: u64) -> SbiRet {
21 match () {
22 #[cfg(target_pointer_width = "32")]
23 () => crate::binary::sbi_call_2(
24 EID_TIME,
25 SET_TIMER,
26 stime_value as _,
27 (stime_value >> 32) as _,
28 ),
29 #[cfg(target_pointer_width = "64")]
30 () => crate::binary::sbi_call_1(EID_TIME, SET_TIMER, stime_value as _),
31 }
32}