Struct InterruptManager

Source
pub struct InterruptManager {
    controllers: InterruptControllers,
    external_handlers: Mutex<HashMap<InterruptId, ExternalInterruptHandler>>,
    interrupt_devices: Mutex<HashMap<InterruptId, Arc<dyn InterruptCapableDevice>>>,
}
Expand description

Unified interrupt manager

This manages both local and external interrupts in a single structure.

Fields§

§controllers: InterruptControllers§external_handlers: Mutex<HashMap<InterruptId, ExternalInterruptHandler>>§interrupt_devices: Mutex<HashMap<InterruptId, Arc<dyn InterruptCapableDevice>>>

Implementations§

Source§

impl InterruptManager

Source

pub fn new() -> Self

Create a new interrupt manager

Source

pub fn global() -> &'static Mutex<InterruptManager>

Get a reference to the global interrupt manager

Source

pub fn get_manager() -> MutexGuard<'static, InterruptManager>

Get a mutable reference to the global interrupt manager (convenience method)

This method locks the global manager and returns a guard. Use this when you need to perform multiple operations atomically.

Source

pub fn with_manager<F, R>(f: F) -> R
where F: FnOnce(&mut InterruptManager) -> R,

Execute a closure with mutable access to the global interrupt manager

This is a convenience method that automatically handles locking and unlocking.

Source

pub fn init(&mut self)

Source

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

Handle an external interrupt

Source

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

Claim and handle the next pending external interrupt

Source

pub fn enable_local_interrupt( &mut self, cpu_id: CpuId, interrupt_type: LocalInterruptType, ) -> InterruptResult<()>

Enable a local interrupt type for a CPU

Source

pub fn disable_local_interrupt( &mut self, cpu_id: CpuId, interrupt_type: LocalInterruptType, ) -> InterruptResult<()>

Disable a local interrupt type for a CPU

Source

pub fn send_software_interrupt( &mut self, target_cpu: CpuId, ) -> InterruptResult<()>

Send a software interrupt to a specific CPU

Source

pub fn set_timer(&mut self, cpu_id: CpuId, time: u64) -> InterruptResult<()>

Set timer interrupt for a specific CPU

Source

pub fn register_local_controller( &mut self, controller: Box<dyn LocalInterruptController>, cpu_ids: &[CpuId], ) -> InterruptResult<usize>

Register a local interrupt controller (e.g., CLINT) for specific CPUs

Source

pub fn register_local_controller_for_range( &mut self, controller: Box<dyn LocalInterruptController>, cpu_range: Range<CpuId>, ) -> InterruptResult<usize>

Register a local interrupt controller for a CPU range

Source

pub fn register_local_controller_for_cpu( &mut self, controller: Box<dyn LocalInterruptController>, cpu_id: CpuId, ) -> InterruptResult<usize>

Register a local interrupt controller for a single CPU

Source

pub fn register_external_controller( &mut self, controller: Box<dyn ExternalInterruptController>, ) -> InterruptResult<()>

Register an external interrupt controller (e.g., PLIC)

Source

pub fn register_external_handler( &mut self, interrupt_id: InterruptId, handler: ExternalInterruptHandler, ) -> InterruptResult<()>

Register a handler for a specific external interrupt

Source

pub fn register_interrupt_device( &mut self, interrupt_id: InterruptId, device: Arc<dyn InterruptCapableDevice>, ) -> InterruptResult<()>

Register a device-based handler for a specific external interrupt

Source

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

Complete an external interrupt

Source

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

Enable an external interrupt for a specific CPU

Source

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

Disable an external interrupt for a specific CPU

Source

pub fn has_local_controller(&self) -> bool

Check if local interrupt controller is registered

Source

pub fn has_external_controller(&self) -> bool

Check if external interrupt controller is registered

Auto Trait Implementations§

§

impl !Freeze for InterruptManager

§

impl !RefUnwindSafe for InterruptManager

§

impl Send for InterruptManager

§

impl Sync for InterruptManager

§

impl Unpin for InterruptManager

§

impl !UnwindSafe for InterruptManager

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.