From 2e8eb96ef69e6fe6108522bfb369b27ec620e4d9 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Mon, 25 Jul 2022 13:36:31 +0100 Subject: [PATCH] vmm: device_manager: Store ACPI platform addresses for later use These are ready for inclusion in the FACP table. Signed-off-by: Rob Bradford --- vmm/src/device_manager.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 09f9a2231..83fe9e84c 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -26,6 +26,7 @@ use crate::GuestMemoryMmap; use crate::GuestRegionMmap; use crate::PciDeviceInfo; use crate::{device_node, DEVICE_MANAGER_SNAPSHOT_ID}; +use acpi_tables::sdt::GenericAddress; use acpi_tables::{aml, aml::Aml}; use anyhow::anyhow; use arch::layout; @@ -806,6 +807,14 @@ struct MetaVirtioDevice { dma_handler: Option>, } +#[derive(Default)] +pub struct AcpiPlatformAddresses { + pub pm_timer_address: Option, + pub reset_reg_address: Option, + pub sleep_control_reg_address: Option, + pub sleep_status_reg_address: Option, +} + pub struct DeviceManager { // The underlying hypervisor hypervisor_type: HypervisorType, @@ -943,6 +952,9 @@ pub struct DeviceManager { // Pending activations pending_activations: Arc>>, + + // Addresses for ACPI platform devices e.g. ACPI PM timer, sleep/reset registers + acpi_platform_addresses: AcpiPlatformAddresses, } impl DeviceManager { @@ -1087,6 +1099,7 @@ impl DeviceManager { boot_id_list, timestamp, pending_activations: Arc::new(Mutex::new(Vec::default())), + acpi_platform_addresses: AcpiPlatformAddresses::default(), }; let device_manager = Arc::new(Mutex::new(device_manager)); @@ -1409,6 +1422,12 @@ impl DeviceManager { .io_bus .insert(shutdown_device, 0x3c0, 0x4) .map_err(DeviceManagerError::BusError)?; + self.acpi_platform_addresses.sleep_control_reg_address = + Some(GenericAddress::io_port_address::(0x3c0)); + self.acpi_platform_addresses.sleep_status_reg_address = + Some(GenericAddress::io_port_address::(0x3c0)); + self.acpi_platform_addresses.reset_reg_address = + Some(GenericAddress::io_port_address::(0x3c0)); } let ged_irq = self @@ -1468,6 +1487,9 @@ impl DeviceManager { .io_bus .insert(pm_timer_device, 0xb008, 0x4) .map_err(DeviceManagerError::BusError)?; + + self.acpi_platform_addresses.pm_timer_address = + Some(GenericAddress::io_port_address::(0xb008)); } Ok(Some(ged_device)) @@ -4122,6 +4144,10 @@ impl DeviceManager { 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 {