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
impl InterruptManager
Sourcepub fn global() -> &'static Mutex<InterruptManager>
pub fn global() -> &'static Mutex<InterruptManager>
Get a reference to the global interrupt manager
Sourcepub fn get_manager() -> MutexGuard<'static, InterruptManager>
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.
Sourcepub fn with_manager<F, R>(f: F) -> Rwhere
F: FnOnce(&mut InterruptManager) -> R,
pub fn with_manager<F, R>(f: F) -> Rwhere
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.
pub fn init(&mut self)
Sourcepub fn handle_external_interrupt(
&mut self,
interrupt_id: InterruptId,
cpu_id: CpuId,
) -> InterruptResult<()>
pub fn handle_external_interrupt( &mut self, interrupt_id: InterruptId, cpu_id: CpuId, ) -> InterruptResult<()>
Handle an external interrupt
Sourcepub fn claim_and_handle_external_interrupt(
&mut self,
cpu_id: CpuId,
) -> InterruptResult<Option<InterruptId>>
pub fn claim_and_handle_external_interrupt( &mut self, cpu_id: CpuId, ) -> InterruptResult<Option<InterruptId>>
Claim and handle the next pending external interrupt
Sourcepub fn enable_local_interrupt(
&mut self,
cpu_id: CpuId,
interrupt_type: LocalInterruptType,
) -> InterruptResult<()>
pub fn enable_local_interrupt( &mut self, cpu_id: CpuId, interrupt_type: LocalInterruptType, ) -> InterruptResult<()>
Enable a local interrupt type for a CPU
Sourcepub fn disable_local_interrupt(
&mut self,
cpu_id: CpuId,
interrupt_type: LocalInterruptType,
) -> InterruptResult<()>
pub fn disable_local_interrupt( &mut self, cpu_id: CpuId, interrupt_type: LocalInterruptType, ) -> InterruptResult<()>
Disable a local interrupt type for a CPU
Sourcepub fn send_software_interrupt(
&mut self,
target_cpu: CpuId,
) -> InterruptResult<()>
pub fn send_software_interrupt( &mut self, target_cpu: CpuId, ) -> InterruptResult<()>
Send a software interrupt to a specific CPU
Sourcepub fn set_timer(&mut self, cpu_id: CpuId, time: u64) -> InterruptResult<()>
pub fn set_timer(&mut self, cpu_id: CpuId, time: u64) -> InterruptResult<()>
Set timer interrupt for a specific CPU
Sourcepub fn register_local_controller(
&mut self,
controller: Box<dyn LocalInterruptController>,
cpu_ids: &[CpuId],
) -> InterruptResult<usize>
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
Sourcepub fn register_local_controller_for_range(
&mut self,
controller: Box<dyn LocalInterruptController>,
cpu_range: Range<CpuId>,
) -> InterruptResult<usize>
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
Sourcepub fn register_local_controller_for_cpu(
&mut self,
controller: Box<dyn LocalInterruptController>,
cpu_id: CpuId,
) -> InterruptResult<usize>
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
Sourcepub fn register_external_controller(
&mut self,
controller: Box<dyn ExternalInterruptController>,
) -> InterruptResult<()>
pub fn register_external_controller( &mut self, controller: Box<dyn ExternalInterruptController>, ) -> InterruptResult<()>
Register an external interrupt controller (e.g., PLIC)
Sourcepub fn register_external_handler(
&mut self,
interrupt_id: InterruptId,
handler: ExternalInterruptHandler,
) -> InterruptResult<()>
pub fn register_external_handler( &mut self, interrupt_id: InterruptId, handler: ExternalInterruptHandler, ) -> InterruptResult<()>
Register a handler for a specific external interrupt
Sourcepub fn register_interrupt_device(
&mut self,
interrupt_id: InterruptId,
device: Arc<dyn InterruptCapableDevice>,
) -> InterruptResult<()>
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
Sourcepub fn complete_external_interrupt(
&mut self,
cpu_id: CpuId,
interrupt_id: InterruptId,
) -> InterruptResult<()>
pub fn complete_external_interrupt( &mut self, cpu_id: CpuId, interrupt_id: InterruptId, ) -> InterruptResult<()>
Complete an external interrupt
Sourcepub fn enable_external_interrupt(
&mut self,
interrupt_id: InterruptId,
cpu_id: CpuId,
) -> InterruptResult<()>
pub fn enable_external_interrupt( &mut self, interrupt_id: InterruptId, cpu_id: CpuId, ) -> InterruptResult<()>
Enable an external interrupt for a specific CPU
Sourcepub fn disable_external_interrupt(
&mut self,
interrupt_id: InterruptId,
cpu_id: CpuId,
) -> InterruptResult<()>
pub fn disable_external_interrupt( &mut self, interrupt_id: InterruptId, cpu_id: CpuId, ) -> InterruptResult<()>
Disable an external interrupt for a specific CPU
Sourcepub fn has_local_controller(&self) -> bool
pub fn has_local_controller(&self) -> bool
Check if local interrupt controller is registered
Sourcepub fn has_external_controller(&self) -> bool
pub fn has_external_controller(&self) -> bool
Check if external interrupt controller is registered