mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-23 16:31:16 +00:00
devices: gic: Introduce VgicConfig and Gic::create_default_config()
VgicConfig structure will be used for initializing the Vgic. Gic::create_default_config will be used everywhere we currently compute redist/msi registers. Signed-off-by: Nuno Das Neves <nudasnev@microsoft.com>
This commit is contained in:
parent
3a19573c69
commit
a832033531
@ -6,14 +6,17 @@ use super::interrupt_controller::{Error, InterruptController};
|
|||||||
extern crate arch;
|
extern crate arch;
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use arch::layout;
|
use arch::layout;
|
||||||
use hypervisor::{arch::aarch64::gic::Vgic, CpuState};
|
use hypervisor::{
|
||||||
|
arch::aarch64::gic::{Vgic, VgicConfig},
|
||||||
|
CpuState,
|
||||||
|
};
|
||||||
use std::result;
|
use std::result;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use vm_device::interrupt::{
|
use vm_device::interrupt::{
|
||||||
InterruptIndex, InterruptManager, InterruptSourceConfig, InterruptSourceGroup,
|
InterruptIndex, InterruptManager, InterruptSourceConfig, InterruptSourceGroup,
|
||||||
LegacyIrqSourceConfig, MsiIrqGroupConfig,
|
LegacyIrqSourceConfig, MsiIrqGroupConfig,
|
||||||
};
|
};
|
||||||
use vm_memory::Address;
|
use vm_memory::address::Address;
|
||||||
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
|
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
|
||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
|
|
||||||
@ -52,6 +55,22 @@ impl Gic {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Default config implied by arch::layout
|
||||||
|
pub fn create_default_config(vcpu_count: u64) -> VgicConfig {
|
||||||
|
let redists_size = layout::GIC_V3_REDIST_SIZE * vcpu_count;
|
||||||
|
let redists_addr = layout::GIC_V3_DIST_START.raw_value() - redists_size;
|
||||||
|
VgicConfig {
|
||||||
|
vcpu_count,
|
||||||
|
dist_addr: layout::GIC_V3_DIST_START.raw_value(),
|
||||||
|
dist_size: layout::GIC_V3_DIST_SIZE,
|
||||||
|
redists_addr,
|
||||||
|
redists_size,
|
||||||
|
msi_addr: redists_addr - layout::GIC_V3_ITS_SIZE,
|
||||||
|
msi_size: layout::GIC_V3_ITS_SIZE,
|
||||||
|
nr_irqs: layout::IRQ_NUM,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn create_vgic(
|
pub fn create_vgic(
|
||||||
&mut self,
|
&mut self,
|
||||||
vm: &Arc<dyn hypervisor::Vm>,
|
vm: &Arc<dyn hypervisor::Vm>,
|
||||||
|
@ -16,6 +16,18 @@ pub enum Error {
|
|||||||
}
|
}
|
||||||
pub type Result<T> = result::Result<T, Error>;
|
pub type Result<T> = result::Result<T, Error>;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct VgicConfig {
|
||||||
|
pub vcpu_count: u64,
|
||||||
|
pub dist_addr: u64,
|
||||||
|
pub dist_size: u64,
|
||||||
|
pub redists_addr: u64,
|
||||||
|
pub redists_size: u64,
|
||||||
|
pub msi_addr: u64,
|
||||||
|
pub msi_size: u64,
|
||||||
|
pub nr_irqs: u32,
|
||||||
|
}
|
||||||
|
|
||||||
/// Hypervisor agnostic interface for a virtualized GIC
|
/// Hypervisor agnostic interface for a virtualized GIC
|
||||||
pub trait Vgic: Send + Sync {
|
pub trait Vgic: Send + Sync {
|
||||||
/// Returns the fdt compatibility property of the device
|
/// Returns the fdt compatibility property of the device
|
||||||
|
Loading…
Reference in New Issue
Block a user