pub trait IrqChip: Send {
Show 22 methods
// Required methods
fn add_vcpu(&mut self, vcpu_id: usize, vcpu: &dyn Vcpu) -> Result<()>;
fn register_edge_irq_event(
&mut self,
irq: u32,
irq_event: &IrqEdgeEvent,
source: IrqEventSource
) -> Result<Option<IrqEventIndex>>;
fn unregister_edge_irq_event(
&mut self,
irq: u32,
irq_event: &IrqEdgeEvent
) -> Result<()>;
fn register_level_irq_event(
&mut self,
irq: u32,
irq_event: &IrqLevelEvent,
source: IrqEventSource
) -> Result<Option<IrqEventIndex>>;
fn unregister_level_irq_event(
&mut self,
irq: u32,
irq_event: &IrqLevelEvent
) -> Result<()>;
fn route_irq(&mut self, route: IrqRoute) -> Result<()>;
fn set_irq_routes(&mut self, routes: &[IrqRoute]) -> Result<()>;
fn irq_event_tokens(
&self
) -> Result<Vec<(IrqEventIndex, IrqEventSource, Event)>>;
fn service_irq(&mut self, irq: u32, level: bool) -> Result<()>;
fn service_irq_event(&mut self, event_index: IrqEventIndex) -> Result<()>;
fn broadcast_eoi(&self, vector: u8) -> Result<()>;
fn inject_interrupts(&self, vcpu: &dyn Vcpu) -> Result<()>;
fn halted(&self, vcpu_id: usize);
fn wait_until_runnable(&self, vcpu: &dyn Vcpu) -> Result<VcpuRunState>;
fn kick_halted_vcpus(&self);
fn get_mp_state(&self, vcpu_id: usize) -> Result<MPState>;
fn set_mp_state(&mut self, vcpu_id: usize, state: &MPState) -> Result<()>;
fn try_clone(&self) -> Result<Self>
where Self: Sized;
fn finalize_devices(
&mut self,
resources: &mut SystemAllocator,
io_bus: &Bus,
mmio_bus: &Bus
) -> Result<()>;
fn process_delayed_irq_events(&mut 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§
sourcefn add_vcpu(&mut self, vcpu_id: usize, vcpu: &dyn Vcpu) -> Result<()>
fn add_vcpu(&mut self, vcpu_id: usize, vcpu: &dyn Vcpu) -> Result<()>
Add a vcpu to the irq chip.
sourcefn register_edge_irq_event(
&mut self,
irq: u32,
irq_event: &IrqEdgeEvent,
source: IrqEventSource
) -> Result<Option<IrqEventIndex>>
fn register_edge_irq_event( &mut 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.
sourcefn unregister_edge_irq_event(
&mut self,
irq: u32,
irq_event: &IrqEdgeEvent
) -> Result<()>
fn unregister_edge_irq_event( &mut self, irq: u32, irq_event: &IrqEdgeEvent ) -> Result<()>
Unregister an event with edge-trigger semantic for a particular GSI.
sourcefn register_level_irq_event(
&mut self,
irq: u32,
irq_event: &IrqLevelEvent,
source: IrqEventSource
) -> Result<Option<IrqEventIndex>>
fn register_level_irq_event( &mut 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.
sourcefn unregister_level_irq_event(
&mut self,
irq: u32,
irq_event: &IrqLevelEvent
) -> Result<()>
fn unregister_level_irq_event( &mut self, irq: u32, irq_event: &IrqLevelEvent ) -> Result<()>
Unregister an event with level-trigger semantic for a particular GSI.
sourcefn route_irq(&mut self, route: IrqRoute) -> Result<()>
fn route_irq(&mut self, route: IrqRoute) -> Result<()>
Route an IRQ line to an interrupt controller, or to a particular MSI vector.
sourcefn set_irq_routes(&mut self, routes: &[IrqRoute]) -> Result<()>
fn set_irq_routes(&mut self, routes: &[IrqRoute]) -> Result<()>
Replace all irq routes with the supplied routes
sourcefn irq_event_tokens(
&self
) -> Result<Vec<(IrqEventIndex, IrqEventSource, Event)>>
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.
sourcefn service_irq(&mut self, irq: u32, level: bool) -> Result<()>
fn service_irq(&mut 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.
sourcefn service_irq_event(&mut self, event_index: IrqEventIndex) -> Result<()>
fn service_irq_event(&mut 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.
sourcefn broadcast_eoi(&self, vector: u8) -> Result<()>
fn broadcast_eoi(&self, vector: u8) -> Result<()>
Broadcast an end of interrupt.
sourcefn inject_interrupts(&self, vcpu: &dyn Vcpu) -> Result<()>
fn inject_interrupts(&self, vcpu: &dyn Vcpu) -> Result<()>
Injects any pending interrupts for vcpu
.
sourcefn halted(&self, vcpu_id: usize)
fn halted(&self, vcpu_id: usize)
Notifies the irq chip that the specified VCPU has executed a halt instruction.
sourcefn wait_until_runnable(&self, vcpu: &dyn Vcpu) -> Result<VcpuRunState>
fn wait_until_runnable(&self, vcpu: &dyn Vcpu) -> 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.
sourcefn kick_halted_vcpus(&self)
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.
sourcefn get_mp_state(&self, vcpu_id: usize) -> Result<MPState>
fn get_mp_state(&self, vcpu_id: usize) -> Result<MPState>
Get the current MP state of the specified VCPU.
sourcefn set_mp_state(&mut self, vcpu_id: usize, state: &MPState) -> Result<()>
fn set_mp_state(&mut self, vcpu_id: usize, state: &MPState) -> Result<()>
Set the current MP state of the specified VCPU.
sourcefn try_clone(&self) -> Result<Self>where
Self: Sized,
fn try_clone(&self) -> Result<Self>where
Self: Sized,
Attempt to create a shallow clone of this IrqChip instance.
sourcefn finalize_devices(
&mut self,
resources: &mut SystemAllocator,
io_bus: &Bus,
mmio_bus: &Bus
) -> Result<()>
fn finalize_devices( &mut 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.
sourcefn process_delayed_irq_events(&mut self) -> Result<()>
fn process_delayed_irq_events(&mut self) -> Result<()>
Process any irqs events that were delayed because of any locking issues.
sourcefn irq_delayed_event_token(&self) -> Result<Option<Event>>
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.
sourcefn check_capability(&self, c: IrqChipCap) -> bool
fn check_capability(&self, c: IrqChipCap) -> bool
Checks if a particular IrqChipCap
is available.
Implementors§
impl IrqChip for KvmKernelIrqChip
This IrqChip only works with Kvm so we only implement it for KvmVcpu.
impl IrqChip for KvmSplitIrqChip
This IrqChip only works with Kvm so we only implement it for KvmVcpu.