macro_rules! use_sbi_timer {
    (unsafe impl PortTimer for $Traits:ty) => { ... };
}
Expand description

Attach the implementation of PortTimer based on the RISC-V Supervisor Binary Interface Timer Extension (EID #0x54494D45 “TIME”) and time[h] CSR to a given kernel trait type. This macro also implements Timer on the kernel trait type. Requires SbiTimerOptions.

You should do the following:

  • Implement SbiTimerOptions on the kernel trait type $Traits.
  • Call $Traits::configure_timer() in your configuration function. See the following example.
r3_port_riscv::use_sbi_timer!(unsafe impl PortTimer for SystemTraits);

impl r3_port_riscv::SbiTimerOptions for SystemTraits {
    const FREQUENCY: u64 = 1_000_000;
}

const fn configure_app(b: &mut r3_kernel::Cfg<SystemTraits>) -> Objects {
    SystemTraits::configure_timer(b);
    /* ... */
}

Safety

  • SbiTimerOptions must be configured correctly.