[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 72/96] pc: acpi-build: generate _S[345] packages dyna
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 72/96] pc: acpi-build: generate _S[345] packages dynamically |
Date: |
Wed, 18 Feb 2015 22:50:56 +0100 |
From: Igor Mammedov <address@hidden>
Replaces template patching with packages composed
using AML 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 <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/i386/acpi-build.c | 40 ++++++++++++++++++++++++++++++----------
hw/i386/ssdt-misc.dsl | 33 ---------------------------------
2 files changed, 30 insertions(+), 43 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index bf34415..4536fba 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -924,7 +924,7 @@ build_ssdt(GArray *table_data, GArray *linker,
uint32_t nr_mem = machine->ram_slots;
unsigned acpi_cpus = guest_info->apic_id_limit;
uint8_t *ssdt_ptr;
- Aml *ssdt, *sb_scope;
+ Aml *ssdt, *sb_scope, *scope, *pkg;
int i;
ssdt = init_aml_allocator();
@@ -936,15 +936,6 @@ build_ssdt(GArray *table_data, GArray *linker,
/* Copy header and patch values in the S3_ / S4_ / S5_ packages */
ssdt_ptr = acpi_data_push(ssdt->buf, 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] = ssdt_ptr[acpi_s4_pkg[0] + 3] =
- pm->s4_val;
- }
patch_pci_windows(pci, ssdt_ptr, sizeof(ssdp_misc_aml));
@@ -954,6 +945,35 @@ 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 = aml_scope("\\");
+ if (!pm->s3_disabled) {
+ pkg = aml_package(4);
+ aml_append(pkg, aml_int(1)); /* PM1a_CNT.SLP_TYP */
+ aml_append(pkg, aml_int(1)); /* PM1b_CNT.SLP_TYP, FIXME: not impl. */
+ aml_append(pkg, aml_int(0)); /* reserved */
+ aml_append(pkg, aml_int(0)); /* reserved */
+ aml_append(scope, aml_name_decl("_S3", pkg));
+ }
+
+ if (!pm->s4_disabled) {
+ pkg = aml_package(4);
+ aml_append(pkg, aml_int(pm->s4_val)); /* PM1a_CNT.SLP_TYP */
+ /* PM1b_CNT.SLP_TYP, FIXME: not impl. */
+ aml_append(pkg, aml_int(pm->s4_val));
+ aml_append(pkg, aml_int(0)); /* reserved */
+ aml_append(pkg, aml_int(0)); /* reserved */
+ aml_append(scope, aml_name_decl("_S4", pkg));
+ }
+
+ pkg = aml_package(4);
+ aml_append(pkg, aml_int(0)); /* PM1a_CNT.SLP_TYP */
+ aml_append(pkg, aml_int(0)); /* PM1b_CNT.SLP_TYP not impl. */
+ aml_append(pkg, aml_int(0)); /* reserved */
+ aml_append(pkg, aml_int(0)); /* reserved */
+ aml_append(scope, aml_name_decl("_S5", pkg));
+ aml_append(ssdt, scope);
+
sb_scope = aml_scope("_SB");
{
/* build Processor object for each processor */
diff --git a/hw/i386/ssdt-misc.dsl b/hw/i386/ssdt-misc.dsl
index 1e3baae..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 */
- One, /* PM1b_CNT.SLP_TYP */
- 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 */
- 0x2, /* PM1b_CNT.SLP_TYP */
- 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)
--
MST
- [Qemu-devel] [PULL 62/96] acpi: add aml_if() term, (continued)
- [Qemu-devel] [PULL 62/96] acpi: add aml_if() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 63/96] acpi: add aml_name() & aml_name_decl() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 64/96] acpi: add aml_int() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 65/96] acpi: add aml_return() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 66/96] acpi: add aml_arg() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 67/96] acpi: add aml_store() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 68/96] acpi: add aml_and() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 69/96] acpi: add aml_notify() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 70/96] acpi: add aml_call1(), aml_call2(), aml_call3(), aml_call4() helpers, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 71/96] acpi: add aml_package() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 72/96] pc: acpi-build: generate _S[345] packages dynamically,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 73/96] acpi: add aml_buffer() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 74/96] acpi: add aml_resource_template() helper, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 75/96] acpi: add aml_io() helper, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 76/96] acpi: include PkgLength size only when requested, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 77/96] acpi: add aml_operation_region() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 78/96] acpi: add aml_field() & aml_named_field() terms, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 80/96] acpi: add aml_string() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 79/96] acpi: add aml_local() term, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 81/96] pc: acpi-build: generate pvpanic device description dynamically, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 82/96] acpi: add aml_varpackage() term, Michael S. Tsirkin, 2015/02/18