Struct Plic

Source
pub struct Plic {
    base_addr: usize,
    max_interrupts: InterruptId,
    max_cpus: CpuId,
}
Expand description

RISC-V PLIC Implementation

Fields§

§base_addr: usize

Base address of the PLIC

§max_interrupts: InterruptId

Maximum number of interrupts this PLIC supports

§max_cpus: CpuId

Maximum number of CPUs this PLIC supports

Implementations§

Source§

impl Plic

Source

pub fn new( base_addr: usize, max_interrupts: InterruptId, max_cpus: CpuId, ) -> Self

Create a new PLIC instance

§Arguments
  • base_addr - Physical base address of the PLIC
  • max_interrupts - Maximum interrupt ID supported (1-based)
  • max_cpus - Maximum number of CPUs supported
Source

fn context_id_for_cpu(&self, cpu_id: CpuId) -> usize

Convert CPU ID to PLIC context ID for Supervisor mode. Hart 0 S-Mode -> Context 1, Hart 1 S-Mode -> Context 3, etc.

Source

fn priority_addr(&self, interrupt_id: InterruptId) -> usize

Get the address of a priority register for an interrupt

Source

fn pending_addr(&self, interrupt_id: InterruptId) -> usize

Get the address of a pending register for an interrupt

Source

fn enable_addr(&self, cpu_id: CpuId, interrupt_id: InterruptId) -> usize

Get the address of an enable register for a CPU and interrupt

Source

fn threshold_addr(&self, cpu_id: CpuId) -> usize

Get the address of a threshold register for a CPU

Source

fn claim_addr(&self, cpu_id: CpuId) -> usize

Get the address of a claim register for a CPU

Source

fn validate_interrupt_id( &self, interrupt_id: InterruptId, ) -> InterruptResult<()>

Validate interrupt ID

Source

fn validate_cpu_id(&self, cpu_id: CpuId) -> InterruptResult<()>

Validate CPU ID

Trait Implementations§

Source§

impl ExternalInterruptController for Plic

Source§

fn init(&mut self) -> InterruptResult<()>

Initialize the PLIC

Source§

fn enable_interrupt( &mut self, interrupt_id: InterruptId, cpu_id: CpuId, ) -> InterruptResult<()>

Enable a specific interrupt for a CPU

Source§

fn disable_interrupt( &mut self, interrupt_id: InterruptId, cpu_id: CpuId, ) -> InterruptResult<()>

Disable a specific interrupt for a CPU

Source§

fn set_priority( &mut self, interrupt_id: InterruptId, priority: Priority, ) -> InterruptResult<()>

Set priority for a specific interrupt

Source§

fn get_priority(&self, interrupt_id: InterruptId) -> InterruptResult<Priority>

Get priority for a specific interrupt

Source§

fn set_threshold( &mut self, cpu_id: CpuId, threshold: Priority, ) -> InterruptResult<()>

Set priority threshold for a CPU

Source§

fn get_threshold(&self, cpu_id: CpuId) -> InterruptResult<Priority>

Get priority threshold for a CPU

Source§

fn claim_interrupt( &mut self, cpu_id: CpuId, ) -> InterruptResult<Option<InterruptId>>

Claim an interrupt (acknowledge and get the interrupt ID)

Source§

fn complete_interrupt( &mut self, cpu_id: CpuId, interrupt_id: InterruptId, ) -> InterruptResult<()>

Complete an interrupt (signal that handling is finished)

Source§

fn is_pending(&self, interrupt_id: InterruptId) -> bool

Check if a specific interrupt is pending

Source§

fn max_interrupts(&self) -> InterruptId

Get the maximum number of interrupts supported

Source§

fn max_cpus(&self) -> CpuId

Get the number of CPUs supported

Source§

impl Send for Plic

Source§

impl Sync for Plic

Auto Trait Implementations§

§

impl Freeze for Plic

§

impl RefUnwindSafe for Plic

§

impl Unpin for Plic

§

impl UnwindSafe for Plic

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.