mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
devices: Refactor IOAPIC to cover other architectures
IOAPIC, a X86 specific interrupt controller, is referenced by device manager and CPU manager. To work with more architectures, a common type for all architectures is needed. This commit introduces trait InterruptController to provide architecture agnostic functions. Device manager and CPU manager can use it without caring what the underlying device is. Signed-off-by: Michael Zhao <michael.zhao@arm.com>
This commit is contained in:
committed by
Samuel Ortiz
parent
d588418053
commit
b32d3025f3
@@ -3,7 +3,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
||||
//
|
||||
|
||||
use devices::ioapic;
|
||||
use devices::interrupt_controller::InterruptController;
|
||||
use kvm_bindings::{kvm_irq_routing, kvm_irq_routing_entry, KVM_IRQ_ROUTING_MSI};
|
||||
use kvm_ioctls::VmFd;
|
||||
use std::collections::HashMap;
|
||||
@@ -281,12 +281,12 @@ impl InterruptSourceGroup for MsiInterruptGroup {
|
||||
}
|
||||
|
||||
pub struct LegacyUserspaceInterruptGroup {
|
||||
ioapic: Arc<Mutex<ioapic::Ioapic>>,
|
||||
ioapic: Arc<Mutex<dyn InterruptController>>,
|
||||
irq: u32,
|
||||
}
|
||||
|
||||
impl LegacyUserspaceInterruptGroup {
|
||||
fn new(ioapic: Arc<Mutex<ioapic::Ioapic>>, irq: u32) -> Self {
|
||||
fn new(ioapic: Arc<Mutex<dyn InterruptController>>, irq: u32) -> Self {
|
||||
LegacyUserspaceInterruptGroup { ioapic, irq }
|
||||
}
|
||||
}
|
||||
@@ -311,7 +311,7 @@ impl InterruptSourceGroup for LegacyUserspaceInterruptGroup {
|
||||
}
|
||||
|
||||
pub struct KvmLegacyUserspaceInterruptManager {
|
||||
ioapic: Arc<Mutex<ioapic::Ioapic>>,
|
||||
ioapic: Arc<Mutex<dyn InterruptController>>,
|
||||
}
|
||||
|
||||
pub struct KvmMsiInterruptManager {
|
||||
@@ -321,7 +321,7 @@ pub struct KvmMsiInterruptManager {
|
||||
}
|
||||
|
||||
impl KvmLegacyUserspaceInterruptManager {
|
||||
pub fn new(ioapic: Arc<Mutex<ioapic::Ioapic>>) -> Self {
|
||||
pub fn new(ioapic: Arc<Mutex<dyn InterruptController>>) -> Self {
|
||||
KvmLegacyUserspaceInterruptManager { ioapic }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user