mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-02 01:45:21 +00:00
vmm: Calculate MMIO config address based on segment id
This means that each segment can have its own PCI MMIO config device without overlapping. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
b59f1d90dd
commit
b55f009b8a
@ -21,6 +21,9 @@ use std::sync::{Arc, Mutex};
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use vm_device::BusDevice;
|
use vm_device::BusDevice;
|
||||||
|
|
||||||
|
// One bus with potentially 256 devices (32 slots x 8 functions).
|
||||||
|
const PCI_MMIO_CONFIG_SIZE: u64 = 4096 * 256;
|
||||||
|
|
||||||
pub(crate) struct PciSegment {
|
pub(crate) struct PciSegment {
|
||||||
id: u16,
|
id: u16,
|
||||||
pub(crate) pci_bus: Arc<Mutex<PciBus>>,
|
pub(crate) pci_bus: Arc<Mutex<PciBus>>,
|
||||||
@ -48,6 +51,9 @@ impl PciSegment {
|
|||||||
start_of_device_area: u64,
|
start_of_device_area: u64,
|
||||||
end_of_device_area: u64,
|
end_of_device_area: u64,
|
||||||
) -> DeviceManagerResult<PciSegment> {
|
) -> DeviceManagerResult<PciSegment> {
|
||||||
|
// Default segment
|
||||||
|
let id = 0u16;
|
||||||
|
|
||||||
let pci_root = PciRoot::new(None);
|
let pci_root = PciRoot::new(None);
|
||||||
let pci_bus = Arc::new(Mutex::new(PciBus::new(
|
let pci_bus = Arc::new(Mutex::new(PciBus::new(
|
||||||
pci_root,
|
pci_root,
|
||||||
@ -55,12 +61,15 @@ impl PciSegment {
|
|||||||
)));
|
)));
|
||||||
|
|
||||||
let pci_config_mmio = Arc::new(Mutex::new(PciConfigMmio::new(Arc::clone(&pci_bus))));
|
let pci_config_mmio = Arc::new(Mutex::new(PciConfigMmio::new(Arc::clone(&pci_bus))));
|
||||||
|
|
||||||
|
let mmio_config_address = layout::PCI_MMCONFIG_START.0 + PCI_MMIO_CONFIG_SIZE * id as u64;
|
||||||
|
|
||||||
address_manager
|
address_manager
|
||||||
.mmio_bus
|
.mmio_bus
|
||||||
.insert(
|
.insert(
|
||||||
Arc::clone(&pci_config_mmio) as Arc<Mutex<dyn BusDevice>>,
|
Arc::clone(&pci_config_mmio) as Arc<Mutex<dyn BusDevice>>,
|
||||||
arch::layout::PCI_MMCONFIG_START.0,
|
mmio_config_address,
|
||||||
arch::layout::PCI_MMCONFIG_SIZE,
|
PCI_MMIO_CONFIG_SIZE,
|
||||||
)
|
)
|
||||||
.map_err(DeviceManagerError::BusError)?;
|
.map_err(DeviceManagerError::BusError)?;
|
||||||
|
|
||||||
@ -78,10 +87,10 @@ impl PciSegment {
|
|||||||
.map_err(DeviceManagerError::BusError)?;
|
.map_err(DeviceManagerError::BusError)?;
|
||||||
|
|
||||||
let mut segment = PciSegment {
|
let mut segment = PciSegment {
|
||||||
id: 0,
|
id,
|
||||||
pci_bus,
|
pci_bus,
|
||||||
pci_config_mmio,
|
pci_config_mmio,
|
||||||
mmio_config_address: arch::layout::PCI_MMCONFIG_START.0,
|
mmio_config_address,
|
||||||
pci_devices_up: 0,
|
pci_devices_up: 0,
|
||||||
pci_devices_down: 0,
|
pci_devices_down: 0,
|
||||||
pci_irq_slots: [0; 32],
|
pci_irq_slots: [0; 32],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user