From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y3lkO-0005WI-Sm for qemu-devel@nongnu.org; Wed, 24 Dec 2014 08:13:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y3lkF-0003Pt-5j for qemu-devel@nongnu.org; Wed, 24 Dec 2014 08:13:04 -0500 Received: from mail-wi0-x22a.google.com ([2a00:1450:400c:c05::22a]:53834) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y3lkE-0003Pp-R9 for qemu-devel@nongnu.org; Wed, 24 Dec 2014 08:12:55 -0500 Received: by mail-wi0-f170.google.com with SMTP id bs8so15667799wib.1 for ; Wed, 24 Dec 2014 05:12:54 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 24 Dec 2014 14:12:40 +0100 Message-Id: <1419426766-1593-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1419426766-1593-1-git-send-email-pbonzini@redhat.com> References: <1419426766-1593-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 1/4] pc: append ssdt-misc.dsl to the DSDT List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, dgilbert@redhat.com, mst@redhat.com This part of the ACPI tables can vary in size across machine types, but does not depend on the command-line. It is an SSDT just because it is the same for i440fx and Q35, and making it an SSDT made the code a bit simpler. However, it also complicates backwards compatibility, so merge it with the DSDT. Signed-off-by: Paolo Bonzini --- hw/i386/acpi-build.c | 54 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index a4d0c0c..c8088f1 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1061,26 +1061,17 @@ static void patch_pci_windows(PcPciInfo *pci, uint8_t *start, unsigned size) } } -static void -build_ssdt(GArray *table_data, GArray *linker, - AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc, - PcPciInfo *pci, PcGuestInfo *guest_info) +static size_t +append_ssdt_misc(GArray *table_data, AcpiPmInfo *pm, AcpiMiscInfo *misc, + PcPciInfo *pci) { MachineState *machine = MACHINE(qdev_get_machine()); uint32_t nr_mem = machine->ram_slots; - unsigned acpi_cpus = guest_info->apic_id_limit; - int ssdt_start = table_data->len; + size_t size = sizeof(ssdp_misc_aml) - sizeof(AcpiTableHeader); uint8_t *ssdt_ptr; - int i; - - /* The current AML generator can cover the APIC ID range [0..255], - * inclusive, for VCPU hotplug. */ - QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256); - g_assert(acpi_cpus <= ACPI_CPU_HOTPLUG_ID_LIMIT); /* Copy header and patch values in the S3_ / S4_ / S5_ packages */ - ssdt_ptr = acpi_data_push(table_data, sizeof(ssdp_misc_aml)); - memcpy(ssdt_ptr, ssdp_misc_aml, sizeof(ssdp_misc_aml)); + ssdt_ptr = g_memdup(ssdp_misc_aml, sizeof(ssdp_misc_aml)); if (pm->s3_disabled) { ssdt_ptr[acpi_s3_name[0]] = 'X'; } @@ -1099,6 +1090,29 @@ build_ssdt(GArray *table_data, GArray *linker, ACPI_BUILD_SET_LE(ssdt_ptr, sizeof(ssdp_misc_aml), ssdt_mctrl_nr_slots[0], 32, nr_mem); + memcpy(acpi_data_push(table_data, size), + ssdt_ptr + sizeof(AcpiTableHeader), size); + g_free(ssdt_ptr); + return size; +} + +static void +build_ssdt(GArray *table_data, GArray *linker, + AcpiCpuInfo *cpu, AcpiPmInfo *pm, PcGuestInfo *guest_info) +{ + MachineState *machine = MACHINE(qdev_get_machine()); + uint32_t nr_mem = machine->ram_slots; + unsigned acpi_cpus = guest_info->apic_id_limit; + int ssdt_start = table_data->len; + int i; + + acpi_data_push(table_data, sizeof(AcpiTableHeader)); + + /* The current AML generator can cover the APIC ID range [0..255], + * inclusive, for VCPU hotplug. */ + QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256); + g_assert(acpi_cpus <= ACPI_CPU_HOTPLUG_ID_LIMIT); + { GArray *sb_scope = build_alloc_array(); uint8_t op = 0x10; /* ScopeOp */ @@ -1423,18 +1437,21 @@ build_dmar_q35(GArray *table_data, GArray *linker) } static void -build_dsdt(GArray *table_data, GArray *linker, AcpiMiscInfo *misc) +build_dsdt(GArray *table_data, GArray *linker, AcpiPmInfo *pm, + AcpiMiscInfo *misc, PcPciInfo *pci) { AcpiTableHeader *dsdt; + size_t ssdt_misc_size; assert(misc->dsdt_code && misc->dsdt_size); dsdt = acpi_data_push(table_data, misc->dsdt_size); memcpy(dsdt, misc->dsdt_code, misc->dsdt_size); + ssdt_misc_size = append_ssdt_misc(table_data, pm, misc, pci); memset(dsdt, 0, sizeof *dsdt); build_header(linker, table_data, dsdt, "DSDT", - misc->dsdt_size, 1); + misc->dsdt_size + ssdt_misc_size, 1); } /* Build final rsdt table */ @@ -1591,7 +1608,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) /* DSDT is pointed to by FADT */ dsdt = tables->table_data->len; - build_dsdt(tables->table_data, tables->linker, &misc); + build_dsdt(tables->table_data, tables->linker, &pm, &misc, &pci); /* Count the size of the DSDT and SSDT, we will need it for legacy * sizing of ACPI tables. @@ -1604,8 +1621,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) ssdt = tables->table_data->len; acpi_add_table(table_offsets, tables->table_data); - build_ssdt(tables->table_data, tables->linker, &cpu, &pm, &misc, &pci, - guest_info); + build_ssdt(tables->table_data, tables->linker, &cpu, &pm, guest_info); aml_len += tables->table_data->len - ssdt; acpi_add_table(table_offsets, tables->table_data); -- 1.8.3.1