From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKlz9-0003Ks-Q5 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 1YKlz8-0000Qt-UI for qemu-devel@nongnu.org; Mon, 09 Feb 2015 05:54:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42377) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKlz8-0000Pw-O2 for qemu-devel@nongnu.org; Mon, 09 Feb 2015 05:54:34 -0500 From: Igor Mammedov Date: Mon, 9 Feb 2015 10:53:30 +0000 Message-Id: <1423479254-15342-9-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 08/52] pc: acpi-build: use aml_scope() for \_SB scope 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 prepares for incremental conversion of SSDT contents to AML API Signed-off-by: Igor Mammedov --- hw/i386/acpi-build.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index fcefa07..bdc343f 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -824,7 +824,7 @@ build_ssdt(Aml *table_data, uint32_t nr_mem = machine->ram_slots; unsigned acpi_cpus = guest_info->apic_id_limit; uint8_t *ssdt_ptr; - Aml *ssdt; + Aml *ssdt, *sb_scope; int i; /* The current AML generator can cover the APIC ID range [0..255], @@ -861,15 +861,11 @@ build_ssdt(Aml *table_data, ACPI_BUILD_SET_LE(ssdt_ptr, sizeof(ssdp_misc_aml), ssdt_mctrl_nr_slots[0], 32, nr_mem); + sb_scope = aml_scope("_SB"); { - GArray *sb_scope = build_alloc_array(); - uint8_t op = 0x10; /* ScopeOp */ - - build_append_namestring(sb_scope, "_SB"); - /* build Processor object for each processor */ for (i = 0; i < acpi_cpus; i++) { - uint8_t *proc = acpi_data_push(sb_scope, ACPI_PROC_SIZEOF); + uint8_t *proc = acpi_data_push(sb_scope->buf, ACPI_PROC_SIZEOF); memcpy(proc, ACPI_PROC_AML, ACPI_PROC_SIZEOF); proc[ACPI_PROC_OFFSET_CPUHEX] = acpi_get_hex(i >> 4); proc[ACPI_PROC_OFFSET_CPUHEX+1] = acpi_get_hex(i); @@ -881,11 +877,12 @@ build_ssdt(Aml *table_data, * Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...} */ /* Arg0 = Processor ID = APIC ID */ - build_append_notify_method(sb_scope, "NTFY", "CP%0.02X", acpi_cpus); + build_append_notify_method(sb_scope->buf, "NTFY", + "CP%0.02X", acpi_cpus); /* build "Name(CPON, Package() { One, One, ..., Zero, Zero, ... })" */ - build_append_byte(sb_scope, 0x08); /* NameOp */ - build_append_namestring(sb_scope, "CPON"); + build_append_byte(sb_scope->buf, 0x08); /* NameOp */ + build_append_namestring(sb_scope->buf, "CPON"); { GArray *package = build_alloc_array(); @@ -910,7 +907,7 @@ build_ssdt(Aml *table_data, } build_package(package, op); - build_append_array(sb_scope, package); + build_append_array(sb_scope->buf, package); build_free_array(package); } @@ -919,7 +916,7 @@ build_ssdt(Aml *table_data, /* build memory devices */ for (i = 0; i < nr_mem; i++) { char id[3]; - uint8_t *mem = acpi_data_push(sb_scope, ACPI_MEM_SIZEOF); + uint8_t *mem = acpi_data_push(sb_scope->buf, ACPI_MEM_SIZEOF); snprintf(id, sizeof(id), "%02X", i); memcpy(mem, ACPI_MEM_AML, ACPI_MEM_SIZEOF); @@ -930,7 +927,7 @@ build_ssdt(Aml *table_data, /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { * If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... */ - build_append_notify_method(sb_scope, + build_append_notify_method(sb_scope->buf, stringify(MEMORY_SLOT_NOTIFY_METHOD), "MP%0.02X", nr_mem); } @@ -947,13 +944,11 @@ build_ssdt(Aml *table_data, if (bus) { /* Scan all PCI buses. Generate tables to support hotplug. */ - build_append_pci_bus_devices(sb_scope, bus, + build_append_pci_bus_devices(sb_scope->buf, bus, pm->pcihp_bridge_en); } } - build_package(sb_scope, op); - build_append_array(ssdt->buf, sb_scope); - build_free_array(sb_scope); + aml_append(ssdt, sb_scope); } aml_append(table_data, ssdt); -- 1.8.3.1