Macro r3_port_riscv::use_plic
source · macro_rules! use_plic { (unsafe impl InterruptController for $Traits:ty) => { ... }; }
Expand description
Implement InterruptController
and Plic
on the given kernel trait
type using the Platform-Level Interrupt Controller (PLIC) on the target.
Requires PlicOptions
and InterruptControllerToPort
.
This macro adds a method const fn configure_plic(b: &mut Cfg<C>)
to the
kernel trait type. It should be called by your application’s configuration
function. See the following example:
ⓘ
r3_port_riscv::use_plic!(unsafe impl InterruptController for SystemTraits);
impl r3_port_riscv::PlicOptions for SystemTraits {
// SiFive E
const MAX_PRIORITY: InterruptPriority = 7;
const MAX_NUM: InterruptNum = 127;
const PLIC_BASE: usize = 0x0c00_0000;
}
const fn configure_app(b: &mut r3_kernel::Cfg<SystemTraits>) -> Objects {
SystemTraits::configure_plic(b);
/* ... */
}
Safety
- The target must really include a PLIC.
PlicOptions
should be configured correctly and the memory-mapped registers should be accessible.