timer.rs 722 B

123456789101112131415161718
  1. /// Timer programmer support
  2. pub trait Timer: Send + Sync {
  3. /// Programs the clock for next event after `stime_value` time.
  4. ///
  5. /// `stime_value` is in absolute time. This function must clear the pending timer interrupt bit as well.
  6. ///
  7. /// If the supervisor wishes to clear the timer interrupt without scheduling the next timer event,
  8. /// it can either request a timer interrupt infinitely far into the future (i.e., (uint64_t)-1),
  9. /// or it can instead mask the timer interrupt by clearing `sie.STIE` CSR bit.
  10. fn set_timer(&self, stime_value: u64);
  11. }
  12. impl<T: Timer> Timer for &T {
  13. #[inline]
  14. fn set_timer(&self, stime_value: u64) {
  15. T::set_timer(self, stime_value)
  16. }
  17. }