mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-01 17:35:19 +00:00
vmm: Remove GIC entity set/get from DeviceManager
Moved the set/get functions from vmm::DeviceManager to devices::Gic. Signed-off-by: Michael Zhao <michael.zhao@arm.com>
This commit is contained in:
parent
195eba188a
commit
7932cd22ca
@ -4,8 +4,9 @@
|
||||
|
||||
use super::interrupt_controller::{Error, InterruptController};
|
||||
extern crate arch;
|
||||
use arch::aarch64::gic::GicDevice;
|
||||
use std::result;
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use vm_device::interrupt::{
|
||||
InterruptIndex, InterruptManager, InterruptSourceConfig, InterruptSourceGroup,
|
||||
LegacyIrqSourceConfig, MsiIrqGroupConfig,
|
||||
@ -26,6 +27,7 @@ pub const IRQ_LEGACY_COUNT: usize = 32;
|
||||
// 2. Move this file and ioapic.rs to arch/, as they are architecture specific.
|
||||
pub struct Gic {
|
||||
interrupt_source_group: Arc<Box<dyn InterruptSourceGroup>>,
|
||||
gic_device: Option<Arc<Mutex<Box<dyn GicDevice>>>>,
|
||||
}
|
||||
|
||||
impl Gic {
|
||||
@ -42,8 +44,17 @@ impl Gic {
|
||||
|
||||
Ok(Gic {
|
||||
interrupt_source_group,
|
||||
gic_device: None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_gic_device(&mut self, gic_device: Arc<Mutex<Box<dyn GicDevice>>>) {
|
||||
self.gic_device = Some(gic_device);
|
||||
}
|
||||
|
||||
pub fn get_gic_device(&self) -> Option<&Arc<Mutex<Box<dyn GicDevice>>>> {
|
||||
self.gic_device.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl InterruptController for Gic {
|
||||
|
@ -1261,6 +1261,11 @@ impl DeviceManager {
|
||||
Ok(interrupt_controller)
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
pub fn get_interrupt_controller(&mut self) -> Option<&Arc<Mutex<gic::Gic>>> {
|
||||
self.interrupt_controller.as_ref()
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
pub fn set_gic_device_entity(&mut self, device_entity: Arc<Mutex<Box<dyn GicDevice>>>) {
|
||||
self.gic_device_entity = Some(device_entity);
|
||||
|
@ -1044,7 +1044,11 @@ impl Vm {
|
||||
self.device_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.set_gic_device_entity(Arc::new(Mutex::new(gic_device)));
|
||||
.get_interrupt_controller()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.set_gic_device(Arc::new(Mutex::new(gic_device)));
|
||||
|
||||
self.device_manager
|
||||
.lock()
|
||||
@ -1865,7 +1869,11 @@ impl Vm {
|
||||
self.device_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get_gic_device_entity()
|
||||
.get_interrupt_controller()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get_gic_device()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap()
|
||||
@ -1898,7 +1906,11 @@ impl Vm {
|
||||
self.device_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.set_gic_device_entity(Arc::new(Mutex::new(gic_device)));
|
||||
.get_interrupt_controller()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.set_gic_device(Arc::new(Mutex::new(gic_device)));
|
||||
|
||||
// Here we prepare the GICR_TYPER registers from the restored vCPU states.
|
||||
self.device_manager
|
||||
@ -1911,7 +1923,11 @@ impl Vm {
|
||||
self.device_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get_gic_device_entity()
|
||||
.get_interrupt_controller()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get_gic_device()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap()
|
||||
|
Loading…
x
Reference in New Issue
Block a user