pub struct Plic<const TOTAL_INTS: usize = 51> { /* private fields */ }
Expand description
The PLIC instance generic parameter indicates the total number of interrupt sources implemented on the specific chip.
51 is a default for backwards compatibility with the SiFive based platforms implemented without the generic parameter.
Implementations§
Source§impl<const TOTAL_INTS: usize> Plic<TOTAL_INTS>
impl<const TOTAL_INTS: usize> Plic<TOTAL_INTS>
pub const fn new(base: StaticRef<PlicRegisters>) -> Self
Sourcepub fn clear_all_pending(&self)
pub fn clear_all_pending(&self)
Clear all pending interrupts. The [PLIC specification
] section 7:
A successful claim will also atomically clear the corresponding pending bit on the interrupt source.. Note that this function will only clear the enabled interrupt sources, as only those can be claimed. [
PLIC specification
]: https://github.com/riscv/riscv-plic-spec/blob/master/riscv-plic.adoc
Sourcepub fn enable_specific_interrupts(&self, interrupts: &[u32])
pub fn enable_specific_interrupts(&self, interrupts: &[u32])
Enable a list of interrupt IDs. The IDs must be in the range 1..TOTAL_INTS.
pub fn disable_specific_interrupts(&self, interrupts: &[u32])
Sourcepub fn enable_all(&self)
pub fn enable_all(&self)
Enable all interrupts.
Sourcepub fn disable_all(&self)
pub fn disable_all(&self)
Disable all interrupts.
Sourcepub fn next_pending(&self) -> Option<u32>
pub fn next_pending(&self) -> Option<u32>
Get the index (0-256) of the lowest number pending interrupt, or None
if
none is pending. RISC-V PLIC has a “claim” register which makes it easy
to grab the highest priority pending interrupt.
Sourcepub unsafe fn save_interrupt(&self, index: u32)
pub unsafe fn save_interrupt(&self, index: u32)
Save the current interrupt to be handled later
This will save the interrupt at index internally to be handled later.
Interrupts must be disabled before this is called.
Saved interrupts can be retrieved by calling get_saved_interrupts()
.
Saved interrupts are cleared when 'complete()
is called.
Sourcepub fn get_saved_interrupts(&self) -> Option<u32>
pub fn get_saved_interrupts(&self) -> Option<u32>
The next_pending()
function will only return enabled interrupts.
This function will return a pending interrupt that has been disabled by
save_interrupt()
.
Sourcepub unsafe fn complete(&self, index: u32)
pub unsafe fn complete(&self, index: u32)
Signal that an interrupt is finished being handled. In Tock, this should be called from the normal main loop (not the interrupt handler). Interrupts must be disabled before this is called.
Sourcepub fn suppress_all(&self)
pub fn suppress_all(&self)
This is a generic implementation. There may be board specific versions as
some platforms have added more bits to the mtvec
register.