From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJ6Q-0003GS-JU for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEJ6I-0003bj-A8 for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47803) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJ6I-0003b7-3a for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:14 -0500 From: Igor Mammedov Date: Thu, 22 Jan 2015 14:50:03 +0000 Message-Id: <1421938231-25698-20-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 19/47] pc: acpi-build: generate _S[345] packages dynamically 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 Replaces template patching with packages composed using ASL API. Note on behavior change: If S3 or S4 is disabled, respective packages won't be created and put into SSDT. Which saves us some space in SSDT and doesn't confuse guest OS with mangled package names as it was done originally. Signed-off-by: Igor Mammedov --- hw/i386/acpi-build.c | 39 ++++++++++++++++++++++++++++++--------- hw/i386/ssdt-misc.dsl | 33 --------------------------------- 2 files changed, 30 insertions(+), 42 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 9088faa..4e5858a 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -760,6 +760,7 @@ build_ssdt(GArray *table_data, GArray *linker, int ssdt_start = table_data->len; AcpiAml table_aml = { .buf = table_data }; uint8_t *ssdt_ptr; + AcpiAml pkg, scope; int i; /* The current AML generator can cover the APIC ID range [0..255], @@ -767,17 +768,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 header and patch values in the S3_ / S4_ / S5_ packages */ + /* Copy header and ssdt template and patch values */ ssdt_ptr = acpi_data_push(table_data, sizeof(ssdp_misc_aml)); memcpy(ssdt_ptr, ssdp_misc_aml, sizeof(ssdp_misc_aml)); - if (pm->s3_disabled) { - ssdt_ptr[acpi_s3_name[0]] = 'X'; - } - if (pm->s4_disabled) { - ssdt_ptr[acpi_s4_name[0]] = 'X'; - } else { - ssdt_ptr[acpi_s4_pkg[0] + 1] = pm->s4_val; - } patch_pci_windows(pci, ssdt_ptr, sizeof(ssdp_misc_aml)); @@ -787,6 +780,34 @@ 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); + /* create S3_ / S4_ / S5_ packages if necessary */ + scope = acpi_scope("\\"); + if (!pm->s3_disabled) { + pkg = acpi_package(4); + aml_append(&pkg, acpi_int(1)); /* PM1a_CNT.SLP_TYP */ + aml_append(&pkg, acpi_int(0)); /* PM1b_CNT.SLP_TYP not impl. */ + aml_append(&pkg, acpi_int(0)); /* reserved */ + aml_append(&pkg, acpi_int(0)); /* reserved */ + aml_append(&scope, acpi_name_decl("_S3", pkg)); + } + + if (!pm->s4_disabled) { + pkg = acpi_package(4); + aml_append(&pkg, acpi_int(pm->s4_val)); /* PM1a_CNT.SLP_TYP */ + aml_append(&pkg, acpi_int(0)); /* PM1b_CNT.SLP_TYP not impl. */ + aml_append(&pkg, acpi_int(0)); /* reserved */ + aml_append(&pkg, acpi_int(0)); /* reserved */ + aml_append(&scope, acpi_name_decl("_S4", pkg)); + } + + pkg = acpi_package(4); + aml_append(&pkg, acpi_int(0)); /* PM1a_CNT.SLP_TYP */ + aml_append(&pkg, acpi_int(0)); /* PM1b_CNT.SLP_TYP not impl. */ + 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); + { AcpiAml sb_scope = acpi_scope("_SB"); diff --git a/hw/i386/ssdt-misc.dsl b/hw/i386/ssdt-misc.dsl index 96382a6..26b9241 100644 --- a/hw/i386/ssdt-misc.dsl +++ b/hw/i386/ssdt-misc.dsl @@ -41,39 +41,6 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) } -/**************************************************************** - * Suspend - ****************************************************************/ - - Scope(\) { - /* - * S3 (suspend-to-ram), S4 (suspend-to-disk) and S5 (power-off) type codes: - * must match piix4 emulation. - */ - - ACPI_EXTRACT_NAME_STRING acpi_s3_name - Name(_S3, Package(0x04) { - One, /* PM1a_CNT.SLP_TYP */ - Zero, /* PM1b_CNT.SLP_TYP, QEMU doesn't provide it */ - Zero, /* reserved */ - Zero /* reserved */ - }) - ACPI_EXTRACT_NAME_STRING acpi_s4_name - ACPI_EXTRACT_PKG_START acpi_s4_pkg - Name(_S4, Package(0x04) { - 0x2, /* PM1a_CNT.SLP_TYP */ - Zero, /* PM1b_CNT.SLP_TYP, QEMU doesn't provide it */ - Zero, /* reserved */ - Zero /* reserved */ - }) - Name(_S5, Package(0x04) { - Zero, /* PM1a_CNT.SLP_TYP */ - Zero, /* PM1b_CNT.SLP_TYP */ - Zero, /* reserved */ - Zero /* reserved */ - }) - } - External(\_SB.PCI0, DeviceObj) External(\_SB.PCI0.ISA, DeviceObj) -- 1.8.3.1