mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-09 06:15:19 +00:00
vmm: device_manager: Store ACPI platform addresses for later use
These are ready for inclusion in the FACP table. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
686e6d5082
commit
2e8eb96ef6
@ -26,6 +26,7 @@ use crate::GuestMemoryMmap;
|
|||||||
use crate::GuestRegionMmap;
|
use crate::GuestRegionMmap;
|
||||||
use crate::PciDeviceInfo;
|
use crate::PciDeviceInfo;
|
||||||
use crate::{device_node, DEVICE_MANAGER_SNAPSHOT_ID};
|
use crate::{device_node, DEVICE_MANAGER_SNAPSHOT_ID};
|
||||||
|
use acpi_tables::sdt::GenericAddress;
|
||||||
use acpi_tables::{aml, aml::Aml};
|
use acpi_tables::{aml, aml::Aml};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use arch::layout;
|
use arch::layout;
|
||||||
@ -806,6 +807,14 @@ struct MetaVirtioDevice {
|
|||||||
dma_handler: Option<Arc<dyn ExternalDmaMapping>>,
|
dma_handler: Option<Arc<dyn ExternalDmaMapping>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
pub struct AcpiPlatformAddresses {
|
||||||
|
pub pm_timer_address: Option<GenericAddress>,
|
||||||
|
pub reset_reg_address: Option<GenericAddress>,
|
||||||
|
pub sleep_control_reg_address: Option<GenericAddress>,
|
||||||
|
pub sleep_status_reg_address: Option<GenericAddress>,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct DeviceManager {
|
pub struct DeviceManager {
|
||||||
// The underlying hypervisor
|
// The underlying hypervisor
|
||||||
hypervisor_type: HypervisorType,
|
hypervisor_type: HypervisorType,
|
||||||
@ -943,6 +952,9 @@ pub struct DeviceManager {
|
|||||||
|
|
||||||
// Pending activations
|
// Pending activations
|
||||||
pending_activations: Arc<Mutex<Vec<VirtioPciDeviceActivator>>>,
|
pending_activations: Arc<Mutex<Vec<VirtioPciDeviceActivator>>>,
|
||||||
|
|
||||||
|
// Addresses for ACPI platform devices e.g. ACPI PM timer, sleep/reset registers
|
||||||
|
acpi_platform_addresses: AcpiPlatformAddresses,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeviceManager {
|
impl DeviceManager {
|
||||||
@ -1087,6 +1099,7 @@ impl DeviceManager {
|
|||||||
boot_id_list,
|
boot_id_list,
|
||||||
timestamp,
|
timestamp,
|
||||||
pending_activations: Arc::new(Mutex::new(Vec::default())),
|
pending_activations: Arc::new(Mutex::new(Vec::default())),
|
||||||
|
acpi_platform_addresses: AcpiPlatformAddresses::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let device_manager = Arc::new(Mutex::new(device_manager));
|
let device_manager = Arc::new(Mutex::new(device_manager));
|
||||||
@ -1409,6 +1422,12 @@ impl DeviceManager {
|
|||||||
.io_bus
|
.io_bus
|
||||||
.insert(shutdown_device, 0x3c0, 0x4)
|
.insert(shutdown_device, 0x3c0, 0x4)
|
||||||
.map_err(DeviceManagerError::BusError)?;
|
.map_err(DeviceManagerError::BusError)?;
|
||||||
|
self.acpi_platform_addresses.sleep_control_reg_address =
|
||||||
|
Some(GenericAddress::io_port_address::<u8>(0x3c0));
|
||||||
|
self.acpi_platform_addresses.sleep_status_reg_address =
|
||||||
|
Some(GenericAddress::io_port_address::<u8>(0x3c0));
|
||||||
|
self.acpi_platform_addresses.reset_reg_address =
|
||||||
|
Some(GenericAddress::io_port_address::<u8>(0x3c0));
|
||||||
}
|
}
|
||||||
|
|
||||||
let ged_irq = self
|
let ged_irq = self
|
||||||
@ -1468,6 +1487,9 @@ impl DeviceManager {
|
|||||||
.io_bus
|
.io_bus
|
||||||
.insert(pm_timer_device, 0xb008, 0x4)
|
.insert(pm_timer_device, 0xb008, 0x4)
|
||||||
.map_err(DeviceManagerError::BusError)?;
|
.map_err(DeviceManagerError::BusError)?;
|
||||||
|
|
||||||
|
self.acpi_platform_addresses.pm_timer_address =
|
||||||
|
Some(GenericAddress::io_port_address::<u32>(0xb008));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Some(ged_device))
|
Ok(Some(ged_device))
|
||||||
@ -4122,6 +4144,10 @@ impl DeviceManager {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn acpi_platform_addresses(&self) -> &AcpiPlatformAddresses {
|
||||||
|
&self.acpi_platform_addresses
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn numa_node_id_from_memory_zone_id(numa_nodes: &NumaNodes, memory_zone_id: &str) -> Option<u32> {
|
fn numa_node_id_from_memory_zone_id(numa_nodes: &NumaNodes, memory_zone_id: &str) -> Option<u32> {
|
||||||
|
Loading…
Reference in New Issue
Block a user