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:
Michael Zhao
2020-05-25 16:27:08 +08:00
committed by Samuel Ortiz
parent d588418053
commit b32d3025f3
6 changed files with 202 additions and 147 deletions
+5 -5
View File
@@ -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 }
}
}