diff options
Diffstat (limited to 'x86_64/src/acpi.rs')
-rw-r--r-- | x86_64/src/acpi.rs | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/x86_64/src/acpi.rs b/x86_64/src/acpi.rs index 14b21a7..c1d92ee 100644 --- a/x86_64/src/acpi.rs +++ b/x86_64/src/acpi.rs @@ -5,6 +5,11 @@ use acpi_tables::{rsdp::RSDP, sdt::SDT}; use data_model::DataInit; use sys_util::{GuestAddress, GuestMemory}; +pub struct ACPIDevResource { + pub amls: Vec<u8>, + pub pm_iobase: u64, +} + #[repr(C)] #[derive(Clone, Copy, Default)] struct LocalAPIC { @@ -65,21 +70,7 @@ const MADT_ENABLED: u32 = 1; // XSDT const XSDT_REVISION: u8 = 1; -fn create_dsdt_table() -> SDT { - // The hex tables in this file are generated from the ASL below with: - // "iasl -tc <dsdt.asl>" - // Below is the tables represents by the pm_dsdt_data - // Name (_S1, Package (0x04) // _S1_: S1 System State - // { - // One, - // One, - // Zero, - // Zero - // }) - let pm_dsdt_data = [ - 0x08u8, 0x5F, 0x53, 0x31, 0x5f, 0x12, 0x06, 0x04, 0x01, 0x01, 0x00, 0x00, - ]; - +fn create_dsdt_table(amls: Vec<u8>) -> SDT { let mut dsdt = SDT::new( *b"DSDT", acpi_tables::HEADER_LEN, @@ -88,7 +79,10 @@ fn create_dsdt_table() -> SDT { *b"CROSVMDT", OEM_REVISION, ); - dsdt.append(pm_dsdt_data); + + if amls.len() != 0 { + dsdt.append_slice(amls.as_slice()); + } dsdt } @@ -102,13 +96,19 @@ fn create_dsdt_table() -> SDT { /// * `sci_irq` - Used to fill the FACP SCI_INTERRUPT field, which /// is going to be used by the ACPI drivers to register /// sci handler. -pub fn create_acpi_tables(guest_mem: &GuestMemory, num_cpus: u8, sci_irq: u32) -> GuestAddress { +/// * `acpi_dev_resource` - resouces needed by the ACPI devices for creating tables +pub fn create_acpi_tables( + guest_mem: &GuestMemory, + num_cpus: u8, + sci_irq: u32, + acpi_dev_resource: ACPIDevResource, +) -> GuestAddress { // RSDP is at the HI RSDP WINDOW let rsdp_offset = GuestAddress(super::ACPI_HI_RSDP_WINDOW_BASE); let mut tables: Vec<u64> = Vec::new(); // DSDT - let dsdt = create_dsdt_table(); + let dsdt = create_dsdt_table(acpi_dev_resource.amls); let dsdt_offset = rsdp_offset.checked_add(RSDP::len() as u64).unwrap(); guest_mem .write_at_addr(dsdt.as_slice(), dsdt_offset) @@ -134,14 +134,13 @@ pub fn create_acpi_tables(guest_mem: &GuestMemory, num_cpus: u8, sci_irq: u32) - // PM1A Event Block Address facp.write( FADT_FIELD_PM1A_EVENT_BLK_ADDR, - devices::acpi::ACPIPM_RESOURCE_BASE as u32, + acpi_dev_resource.pm_iobase as u32, ); // PM1A Control Block Address facp.write( FADT_FIELD_PM1A_CONTROL_BLK_ADDR, - devices::acpi::ACPIPM_RESOURCE_BASE as u32 - + devices::acpi::ACPIPM_RESOURCE_EVENTBLK_LEN as u32, + acpi_dev_resource.pm_iobase as u32 + devices::acpi::ACPIPM_RESOURCE_EVENTBLK_LEN as u32, ); // PM1 Event Block Length |