From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKlzD-0003Qs-0I for qemu-devel@nongnu.org; Mon, 09 Feb 2015 05:54:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKlz6-0000MU-Nf for qemu-devel@nongnu.org; Mon, 09 Feb 2015 05:54:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46954) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKlz6-0000LX-Gg for qemu-devel@nongnu.org; Mon, 09 Feb 2015 05:54:32 -0500 From: Igor Mammedov Date: Mon, 9 Feb 2015 10:53:28 +0000 Message-Id: <1423479254-15342-7-git-send-email-imammedo@redhat.com> In-Reply-To: <1423479254-15342-1-git-send-email-imammedo@redhat.com> References: <1423479254-15342-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH v3 06/52] pc: acpi-build: use aml_def_block() for declaring SSDT table List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: drjones@redhat.com, marcel.a@redhat.com, claudio.fontana@huawei.com, mst@redhat.com, zhaoshenglong@huawei.com it replaces prebuilt SSDT table header template copying/patching with AML API Signed-off-by: Igor Mammedov --- hw/i386/acpi-build.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 553c86b..fcefa07 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -816,15 +816,15 @@ static void patch_pci_windows(PcPciInfo *pci, uint8_t *start, unsigned size) } static void -build_ssdt(GArray *table_data, GArray *linker, +build_ssdt(Aml *table_data, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc, PcPciInfo *pci, 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; uint8_t *ssdt_ptr; + Aml *ssdt; int i; /* The current AML generator can cover the APIC ID range [0..255], @@ -832,9 +832,17 @@ build_ssdt(GArray *table_data, GArray *linker, 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)); + /* Init SSDT Definition Block */ + ssdt = aml_def_block("SSDT", 1, ACPI_BUILD_APPNAME6, + ACPI_BUILD_APPNAME4, 1, + ACPI_BUILD_APPNAME4_HEX, 1); + + /* Copy misc variables and patch values in the S3_ / S4_ / S5_ packages */ + acpi_data_push(ssdt->buf, sizeof(ssdp_misc_aml) - sizeof(AcpiTableHeader)); + ssdt_ptr = (uint8_t *)ssdt->buf->data; + memcpy(ssdt_ptr + sizeof(AcpiTableHeader), + ssdp_misc_aml + sizeof(AcpiTableHeader), + sizeof(ssdp_misc_aml) - sizeof(AcpiTableHeader)); if (pm->s3_disabled) { ssdt_ptr[acpi_s3_name[0]] = 'X'; } @@ -944,13 +952,11 @@ build_ssdt(GArray *table_data, GArray *linker, } } build_package(sb_scope, op); - build_append_array(table_data, sb_scope); + build_append_array(ssdt->buf, sb_scope); build_free_array(sb_scope); } - build_header(linker, table_data, - (void *)(table_data->data + ssdt_start), - "SSDT", table_data->len - ssdt_start, 1); + aml_append(table_data, ssdt); } static void @@ -1352,7 +1358,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) ssdt = tables_blob->len; acpi_add_table(table_offsets, tables_blob); - build_ssdt(tables_blob, tables->linker, &cpu, &pm, &misc, &pci, + build_ssdt(tables->table_data, &cpu, &pm, &misc, &pci, guest_info); aml_len += tables_blob->len - ssdt; -- 1.8.3.1