From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJ70-0004ES-38 for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:52:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEJ6t-0003td-W4 for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41538) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJ6t-0003tG-Pf for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:51 -0500 From: Igor Mammedov Date: Thu, 22 Jan 2015 14:50:28 +0000 Message-Id: <1421938231-25698-45-git-send-email-imammedo@redhat.com> In-Reply-To: <1421938231-25698-1-git-send-email-imammedo@redhat.com> References: <1421938231-25698-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH v2 44/47] pc: acpi-build: drop remaining ssdt_misc template and use acpi_def_block() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, drjones@redhat.com, marcel.a@redhat.com, claudio.fontana@huawei.com, mst@redhat.com It completes dynamic SSDT generation and makes it independed of IASL binary blobs. It also hides from user all pointer arithmetic when building SSDT which makes resulting code a bit cleaner and concentrating only on composing ASL construct /i.e. a task build_ssdt() should be doing/. Also it makes one binary blob less stored in QEMU source tree by removing need to keep and update hw/i386/ssdt-misc.hex.generated file here in total saving us ~430LOC. Signed-off-by: Igor Mammedov --- hw/i386/Makefile.objs | 2 +- hw/i386/acpi-build.c | 32 ++-- hw/i386/ssdt-misc.dsl | 21 --- hw/i386/ssdt-misc.hex.generated | 399 ---------------------------------------- 4 files changed, 12 insertions(+), 442 deletions(-) delete mode 100644 hw/i386/ssdt-misc.dsl delete mode 100644 hw/i386/ssdt-misc.hex.generated diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs index 6c8705d..dc8c38a 100644 --- a/hw/i386/Makefile.objs +++ b/hw/i386/Makefile.objs @@ -8,7 +8,7 @@ obj-$(CONFIG_XEN) += ../xenpv/ xen/ obj-y += kvmvapic.o obj-y += acpi-build.o hw/i386/acpi-build.o: hw/i386/acpi-build.c hw/i386/acpi-dsdt.hex \ - hw/i386/ssdt-misc.hex hw/i386/q35-acpi-dsdt.hex \ + hw/i386/q35-acpi-dsdt.hex \ hw/i386/ssdt-tpm.hex iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 5821528..5831450 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -268,7 +268,6 @@ static void acpi_get_pci_info(PcPciInfo *info) #define ACPI_BUILD_APPNAME "Bochs" #define ACPI_BUILD_APPNAME6 "BOCHS " -#define ACPI_BUILD_APPNAME4 "BXPC" #define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp" #define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log" @@ -465,10 +464,6 @@ build_madt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, table_data->len - madt_start, 1); } -#define ACPI_SSDT_SIGNATURE 0x54445353 /* SSDT */ -#define ACPI_SSDT_HEADER_LENGTH 36 - -#include "hw/i386/ssdt-misc.hex" #include "hw/i386/ssdt-tpm.hex" /* Assign BSEL property to all buses. In the future, this can be changed @@ -647,17 +642,14 @@ static void build_append_pci_bus_devices(AcpiAml *parent_scope, PCIBus *bus, } static void -build_ssdt(GArray *table_data, GArray *linker, +build_ssdt(AcpiAml *table_aml, GArray *linker, 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; - AcpiAml table_aml = { .buf = table_data }; - uint8_t *ssdt_ptr; - AcpiAml pkg, scope, dev, method, crs, field, ifctx; + AcpiAml pkg, scope, dev, method, crs, field, ifctx, ssdt; int i; /* The current AML generator can cover the APIC ID range [0..255], @@ -665,9 +657,9 @@ 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 SSDT header */ - 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 = + acpi_def_block("SSDT", 1, ACPI_BUILD_APPNAME6, ACPI_BUILD_APPNAME4, 1); scope = acpi_scope("\\_SB.PCI0"); /* build PCI0._CRS */ @@ -719,7 +711,7 @@ build_ssdt(GArray *table_data, GArray *linker, aml_append(&dev, acpi_name_decl("_CRS", crs)); aml_append(&scope, dev); } - aml_append(&table_aml, scope); + aml_append(&ssdt, scope); /* create S3_ / S4_ / S5_ packages if necessary */ scope = acpi_scope("\\"); @@ -747,7 +739,7 @@ build_ssdt(GArray *table_data, GArray *linker, aml_append(&pkg, acpi_int(0)); /* reserved */ aml_append(&pkg, acpi_int(0)); /* reserved */ aml_append(&scope, acpi_name_decl("_S5", pkg)); - aml_append(&table_aml, scope); + aml_append(&ssdt, scope); if (misc->pvpanic_port) { scope = acpi_scope("\\_SB.PCI0.ISA"); @@ -777,7 +769,7 @@ build_ssdt(GArray *table_data, GArray *linker, aml_append(&dev, method); aml_append(&scope, dev); - aml_append(&table_aml, scope); + aml_append(&ssdt, scope); } { @@ -972,12 +964,10 @@ build_ssdt(GArray *table_data, GArray *linker, aml_append(&sb_scope, scope); } } - aml_append(&table_aml, sb_scope); + aml_append(&ssdt, sb_scope); } - build_header(linker, table_data, - (void *)(table_data->data + ssdt_start), - "SSDT", table_data->len - ssdt_start, 1); + aml_append(table_aml, ssdt); } static void @@ -1379,7 +1369,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) ssdt = tables->table_data.buf->len; acpi_add_table(table_offsets, tables->table_data.buf); - build_ssdt(tables->table_data.buf, tables->linker, &cpu, &pm, &misc, &pci, + build_ssdt(&tables->table_data, tables->linker, &cpu, &pm, &misc, &pci, guest_info); aml_len += tables->table_data.buf->len - ssdt; diff --git a/hw/i386/ssdt-misc.dsl b/hw/i386/ssdt-misc.dsl deleted file mode 100644 index 8d61f21..0000000 --- a/hw/i386/ssdt-misc.dsl +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - */ -#include "hw/acpi/pc-hotplug.h" - -ACPI_EXTRACT_ALL_CODE ssdp_misc_aml - -DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) -{ -} diff --git a/hw/i386/ssdt-misc.hex.generated b/hw/i386/ssdt-misc.hex.generated deleted file mode 100644 index cbcf61d..0000000 --- a/hw/i386/ssdt-misc.hex.generated +++ /dev/null @@ -1,399 +0,0 @@ -static unsigned char acpi_pci64_length[] = { -0x6f -}; -static unsigned char acpi_s4_pkg[] = { -0x99 -}; -static unsigned char ssdt_mctrl_nr_slots[] = { -0x7d -}; -static unsigned char acpi_s3_name[] = { -0x86 -}; -static unsigned char acpi_pci32_start[] = { -0x2f -}; -static unsigned char acpi_pci64_valid[] = { -0x43 -}; -static unsigned char ssdp_misc_aml[] = { -0x53, -0x53, -0x44, -0x54, -0x6c, -0x1, -0x0, -0x0, -0x1, -0x3, -0x42, -0x58, -0x50, -0x43, -0x0, -0x0, -0x42, -0x58, -0x53, -0x53, -0x44, -0x54, -0x53, -0x55, -0x1, -0x0, -0x0, -0x0, -0x49, -0x4e, -0x54, -0x4c, -0x28, -0x8, -0x14, -0x20, -0x10, -0x4c, -0x5, -0x5c, -0x0, -0x8, -0x50, -0x30, -0x53, -0x5f, -0xc, -0x78, -0x56, -0x34, -0x12, -0x8, -0x50, -0x30, -0x45, -0x5f, -0xc, -0x78, -0x56, -0x34, -0x12, -0x8, -0x50, -0x31, -0x56, -0x5f, -0xa, -0x12, -0x8, -0x50, -0x31, -0x53, -0x5f, -0x11, -0xb, -0xa, -0x8, -0x0, -0x0, -0x0, -0x0, -0x0, -0x0, -0x0, -0x0, -0x8, -0x50, -0x31, -0x45, -0x5f, -0x11, -0xb, -0xa, -0x8, -0x0, -0x0, -0x0, -0x0, -0x0, -0x0, -0x0, -0x0, -0x8, -0x50, -0x31, -0x4c, -0x5f, -0x11, -0xb, -0xa, -0x8, -0x0, -0x0, -0x0, -0x0, -0x0, -0x0, -0x0, -0x0, -0x8, -0x4d, -0x44, -0x4e, -0x52, -0xc, -0x78, -0x56, -0x34, -0x12, -0x10, -0x29, -0x5c, -0x0, -0x8, -0x5f, -0x53, -0x33, -0x5f, -0x12, -0x6, -0x4, -0x1, -0x1, -0x0, -0x0, -0x8, -0x5f, -0x53, -0x34, -0x5f, -0x12, -0x8, -0x4, -0xa, -0x2, -0xa, -0x2, -0x0, -0x0, -0x8, -0x5f, -0x53, -0x35, -0x5f, -0x12, -0x6, -0x4, -0x0, -0x0, -0x0, -0x0, -0x10, -0x40, -0xc, -0x5c, -0x2f, -0x3, -0x5f, -0x53, -0x42, -0x5f, -0x50, -0x43, -0x49, -0x30, -0x49, -0x53, -0x41, -0x5f, -0x5b, -0x82, -0x4d, -0xa, -0x50, -0x45, -0x56, -0x54, -0x8, -0x5f, -0x48, -0x49, -0x44, -0xd, -0x51, -0x45, -0x4d, -0x55, -0x30, -0x30, -0x30, -0x31, -0x0, -0x8, -0x50, -0x45, -0x53, -0x54, -0xb, -0xff, -0xff, -0x5b, -0x80, -0x50, -0x45, -0x4f, -0x52, -0x1, -0x50, -0x45, -0x53, -0x54, -0x1, -0x5b, -0x81, -0xb, -0x50, -0x45, -0x4f, -0x52, -0x1, -0x50, -0x45, -0x50, -0x54, -0x8, -0x14, -0x18, -0x5f, -0x53, -0x54, -0x41, -0x0, -0x70, -0x50, -0x45, -0x53, -0x54, -0x60, -0xa0, -0x6, -0x93, -0x60, -0x0, -0xa4, -0x0, -0xa1, -0x4, -0xa4, -0xa, -0xf, -0x14, -0xe, -0x52, -0x44, -0x50, -0x54, -0x0, -0x70, -0x50, -0x45, -0x50, -0x54, -0x60, -0xa4, -0x60, -0x14, -0xc, -0x57, -0x52, -0x50, -0x54, -0x1, -0x70, -0x68, -0x50, -0x45, -0x50, -0x54, -0x8, -0x5f, -0x43, -0x52, -0x53, -0x11, -0xd, -0xa, -0xa, -0x47, -0x1, -0x0, -0x0, -0x0, -0x0, -0x1, -0x1, -0x79, -0x0, -0x8b, -0x5f, -0x43, -0x52, -0x53, -0xa, -0x2, -0x49, -0x4f, -0x4d, -0x4e, -0x8b, -0x5f, -0x43, -0x52, -0x53, -0xa, -0x4, -0x49, -0x4f, -0x4d, -0x58, -0x14, -0x18, -0x5f, -0x49, -0x4e, -0x49, -0x0, -0x70, -0x50, -0x45, -0x53, -0x54, -0x49, -0x4f, -0x4d, -0x4e, -0x70, -0x50, -0x45, -0x53, -0x54, -0x49, -0x4f, -0x4d, -0x58 -}; -static unsigned char ssdt_isa_pest[] = { -0xda -}; -static unsigned char acpi_s4_name[] = { -0x92 -}; -static unsigned char acpi_pci64_start[] = { -0x4d -}; -static unsigned char acpi_pci64_end[] = { -0x5e -}; -static unsigned char acpi_pci32_end[] = { -0x39 -}; -- 1.8.3.1