Trait IrqChip

Source
pub trait IrqChip: Send + Sync {
Show 21 methods // Required methods fn add_vcpu(&self, vcpu_id: usize, vcpu: Arc<dyn VcpuArch>) -> Result<()>; fn register_edge_irq_event( &self, irq: u32, irq_event: &IrqEdgeEvent, source: IrqEventSource, ) -> Result<Option<IrqEventIndex>>; fn unregister_edge_irq_event( &self, irq: u32, irq_event: &IrqEdgeEvent, ) -> Result<()>; fn register_level_irq_event( &self, irq: u32, irq_event: &IrqLevelEvent, source: IrqEventSource, ) -> Result<Option<IrqEventIndex>>; fn unregister_level_irq_event( &self, irq: u32, irq_event: &IrqLevelEvent, ) -> Result<()>; fn route_irq(&self, route: IrqRoute) -> Result<()>; fn set_irq_routes(&self, routes: &[IrqRoute]) -> Result<()>; fn irq_event_tokens( &self, ) -> Result<Vec<(IrqEventIndex, IrqEventSource, Event)>>; fn service_irq(&self, irq: u32, level: bool) -> Result<()>; fn service_irq_event(&self, event_index: IrqEventIndex) -> Result<()>; fn broadcast_eoi(&self, vector: u8) -> Result<()>; fn inject_interrupts(&self, vcpu: &dyn VcpuArch) -> Result<()>; fn halted(&self, vcpu_id: usize); fn wait_until_runnable(&self, vcpu: &dyn VcpuArch) -> Result<VcpuRunState>; fn kick_halted_vcpus(&self); fn get_mp_state(&self, vcpu_id: usize) -> Result<MPState>; fn set_mp_state(&self, vcpu_id: usize, state: &MPState) -> Result<()>; fn finalize_devices( self: Arc<Self>, resources: &mut SystemAllocator, io_bus: &Bus, mmio_bus: &Bus, ) -> Result<()>; fn process_delayed_irq_events(&self) -> Result<()>; fn irq_delayed_event_token(&self) -> Result<Option<Event>>; fn check_capability(&self, c: IrqChipCap) -> bool;
}
Expand description

Trait that abstracts interactions with interrupt controllers.

Each VM will have one IrqChip instance which is responsible for routing IRQ lines and registering IRQ events. Depending on the implementation, the IrqChip may interact with an underlying hypervisor API or emulate devices in userspace.

This trait is generic over a Vcpu type because some IrqChip implementations can support multiple hypervisors with a single implementation.

Required Methods§

Source

fn add_vcpu(&self, vcpu_id: usize, vcpu: Arc<dyn VcpuArch>) -> Result<()>

Add a vcpu to the irq chip.

Source

fn register_edge_irq_event( &self, irq: u32, irq_event: &IrqEdgeEvent, source: IrqEventSource, ) -> Result<Option<IrqEventIndex>>

Register an event with edge-trigger semantic that can trigger an interrupt for a particular GSI.

Source

fn unregister_edge_irq_event( &self, irq: u32, irq_event: &IrqEdgeEvent, ) -> Result<()>

Unregister an event with edge-trigger semantic for a particular GSI.

Source

fn register_level_irq_event( &self, irq: u32, irq_event: &IrqLevelEvent, source: IrqEventSource, ) -> Result<Option<IrqEventIndex>>

Register an event with level-trigger semantic that can trigger an interrupt for a particular GSI.

Source

fn unregister_level_irq_event( &self, irq: u32, irq_event: &IrqLevelEvent, ) -> Result<()>

Unregister an event with level-trigger semantic for a particular GSI.

Source

fn route_irq(&self, route: IrqRoute) -> Result<()>

Route an IRQ line to an interrupt controller, or to a particular MSI vector.

Source

fn set_irq_routes(&self, routes: &[IrqRoute]) -> Result<()>

Replace all irq routes with the supplied routes

Source

fn irq_event_tokens( &self, ) -> Result<Vec<(IrqEventIndex, IrqEventSource, Event)>>

Return a vector of all registered irq numbers and their associated events and event sources. These should be used by the main thread to wait for irq events.

Source

fn service_irq(&self, irq: u32, level: bool) -> Result<()>

Either assert or deassert an IRQ line. Sends to either an interrupt controller, or does a send_msi if the irq is associated with an MSI.

Source

fn service_irq_event(&self, event_index: IrqEventIndex) -> Result<()>

Service an IRQ event by asserting then deasserting an IRQ line. The associated Event that triggered the irq event will be read from. If the irq is associated with a resample Event, then the deassert will only happen after an EOI is broadcast for a vector associated with the irq line.

Source

fn broadcast_eoi(&self, vector: u8) -> Result<()>

Broadcast an end of interrupt.

Source

fn inject_interrupts(&self, vcpu: &dyn VcpuArch) -> Result<()>

Injects any pending interrupts for vcpu.

Source

fn halted(&self, vcpu_id: usize)

Notifies the irq chip that the specified VCPU has executed a halt instruction.

Source

fn wait_until_runnable(&self, vcpu: &dyn VcpuArch) -> Result<VcpuRunState>

Blocks until vcpu is in a runnable state or until interrupted by IrqChip::kick_halted_vcpus. Returns VcpuRunState::Runnable if vcpu is runnable, or VcpuRunState::Interrupted` if the wait was interrupted.

Source

fn kick_halted_vcpus(&self)

Makes unrunnable VCPUs return immediately from wait_until_runnable. For UserspaceIrqChip, every vcpu gets kicked so its current or next call to wait_until_runnable will immediately return false. After that one kick, subsequent wait_until_runnable calls go back to waiting for runnability normally.

Source

fn get_mp_state(&self, vcpu_id: usize) -> Result<MPState>

Get the current MP state of the specified VCPU.

Source

fn set_mp_state(&self, vcpu_id: usize, state: &MPState) -> Result<()>

Set the current MP state of the specified VCPU.

Source

fn finalize_devices( self: Arc<Self>, resources: &mut SystemAllocator, io_bus: &Bus, mmio_bus: &Bus, ) -> Result<()>

Finalize irqchip setup. Should be called once all devices have registered irq events and been added to the io_bus and mmio_bus.

Source

fn process_delayed_irq_events(&self) -> Result<()>

Process any irqs events that were delayed because of any locking issues.

Source

fn irq_delayed_event_token(&self) -> Result<Option<Event>>

Return an event which is meant to trigger process of any irqs events that were delayed by calling process_delayed_irq_events(). This should be used by the main thread to wait for delayed irq event kick. It is process_delayed_irq_events() responsibility to read the event as long as there is no more irqs to be serviced.

Source

fn check_capability(&self, c: IrqChipCap) -> bool

Checks if a particular IrqChipCap is available.

Implementors§

Source§

impl IrqChip for KvmKernelIrqChip

This IrqChip only works with Kvm so we only implement it for KvmVcpu.

Source§

impl IrqChip for KvmSplitIrqChip

This IrqChip only works with Kvm so we only implement it for KvmVcpu.

Source§

impl IrqChip for UserspaceIrqChip