[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 36/47] pc: acpi-build: drop template patching and memo
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [RFC 36/47] pc: acpi-build: drop template patching and memory hotplug objects dynamically |
Date: |
Fri, 19 Dec 2014 02:02:31 +0000 |
in addition it saves us ~330LOC and makes it one binary blob less
stored in QEMU source tree by removing need to keep and update
hw/i386/ssdt-mem.hex.generated file there.
Signed-off-by: Igor Mammedov <address@hidden>
---
hw/i386/Makefile.objs | 2 +-
hw/i386/acpi-build.c | 132 +++++++++----------------
hw/i386/ssdt-mem.dsl | 77 ---------------
hw/i386/ssdt-mem.hex.generated | 213 -----------------------------------------
4 files changed, 47 insertions(+), 377 deletions(-)
delete mode 100644 hw/i386/ssdt-mem.dsl
delete mode 100644 hw/i386/ssdt-mem.hex.generated
diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
index 92f2ee6..790a56c 100644
--- a/hw/i386/Makefile.objs
+++ b/hw/i386/Makefile.objs
@@ -10,7 +10,7 @@ obj-y += acpi-build.o
obj-y += bios-linker-loader.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/ssdt-mem.hex hw/i386/ssdt-tpm.hex
+ hw/i386/ssdt-tpm.hex
iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
; then echo "$(2)"; else echo "$(3)"; fi ;)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 7829ea5..241bb2a 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -279,48 +279,6 @@ build_header(GArray *linker, GArray *table_data,
table_data->data, h, len, &h->checksum);
}
-static GArray *build_alloc_method(const char *name, uint8_t arg_count)
-{
- GArray *method = build_alloc_array();
-
- build_append_namestring(method, "%s", name);
- build_append_byte(method, arg_count); /* MethodFlags: ArgCount */
-
- return method;
-}
-
-static void build_append_and_cleanup_method(GArray *device, GArray *method)
-{
- uint8_t op = 0x14; /* MethodOp */
-
- build_package(method, op);
-
- build_append_array(device, method);
- build_free_array(method);
-}
-
-static void build_append_notify_target_ifequal(GArray *method,
- GArray *target_name,
- uint32_t value, int size)
-{
- GArray *notify = build_alloc_array();
- uint8_t op = 0xA0; /* IfOp */
-
- build_append_byte(notify, 0x93); /* LEqualOp */
- build_append_byte(notify, 0x68); /* Arg0Op */
- build_append_value(notify, value, size);
- build_append_byte(notify, 0x86); /* NotifyOp */
- build_append_array(notify, target_name);
- build_append_byte(notify, 0x69); /* Arg1Op */
-
- /* Pack it up */
- build_package(notify, op);
-
- build_append_array(method, notify);
-
- build_free_array(notify);
-}
-
/* End here */
#define ACPI_PORT_SMI_CMD 0x00b2 /* TODO: this is APM_CNT_IOPORT */
@@ -512,38 +470,12 @@ build_madt(GArray *table_data, GArray *linker,
AcpiCpuInfo *cpu,
table_data->len - madt_start, 1);
}
-#include "hw/i386/ssdt-mem.hex"
-
-/* 0x5B 0x82 DeviceOp PkgLength NameString DimmID */
-#define ACPI_MEM_OFFSET_HEX (*ssdt_mem_name - *ssdt_mem_start + 2)
-#define ACPI_MEM_OFFSET_ID (*ssdt_mem_id - *ssdt_mem_start + 7)
-#define ACPI_MEM_SIZEOF (*ssdt_mem_end - *ssdt_mem_start)
-#define ACPI_MEM_AML (ssdm_mem_aml + *ssdt_mem_start)
-
#define ACPI_SSDT_SIGNATURE 0x54445353 /* SSDT */
#define ACPI_SSDT_HEADER_LENGTH 36
#include "hw/i386/ssdt-misc.hex"
#include "hw/i386/ssdt-tpm.hex"
-static void
-build_append_notify_method(GArray *device, const char *name,
- const char *format, int count)
-{
- int i;
- GArray *method = build_alloc_method(name, 2);
-
- for (i = 0; i < count; i++) {
- GArray *target = build_alloc_array();
- build_append_namestring(target, format, i);
- assert(i < 256); /* Fits in 1 byte */
- build_append_notify_target_ifequal(method, target, i, 1);
- build_free_array(target);
- }
-
- build_append_and_cleanup_method(device, method);
-}
-
/* Assign BSEL property to all buses. In the future, this can be changed
* to only assign to buses that support hotplug.
*/
@@ -895,27 +827,55 @@ build_ssdt(GArray *table_data, GArray *linker,
}
aml_append(&sb_scope, acpi_name_decl("CPON", pkg));
- if (nr_mem) {
- assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
- /* build memory devices */
- for (i = 0; i < nr_mem; i++) {
- char id[3];
- 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);
- memcpy(mem + ACPI_MEM_OFFSET_HEX, id, 2);
- memcpy(mem + ACPI_MEM_OFFSET_ID, id, 2);
- }
+ /* build memory devices */
+ assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
+
+ for (i = 0; i < nr_mem; i++) {
+ #define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
+ const char *s;
+
+ dev = acpi_device("MP%02X", i);
+ aml_append(&dev, acpi_name_decl("_UID", acpi_string("0x%02X", i)));
+ aml_append(&dev, acpi_name_decl("_HID", acpi_eisaid("PNP0C80")));
+
+ method = acpi_method("_CRS", 0);
+ s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);
+ aml_append(&method, acpi_return(acpi_call1(s, acpi_name("_UID"))));
+ aml_append(&dev, method);
+
+ method = acpi_method("_STA", 0);
+ s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);
+ aml_append(&method, acpi_return(acpi_call1(s, acpi_name("_UID"))));
+ aml_append(&dev, method);
+
+ method = acpi_method("_PXM", 0);
+ s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);
+ aml_append(&method, acpi_return(acpi_call1(s, acpi_name("_UID"))));
+ aml_append(&dev, method);
- /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
- * If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ...
- */
- build_append_notify_method(sb_scope.buf,
- stringify(MEMORY_SLOT_NOTIFY_METHOD),
- "MP%0.02X", nr_mem);
+ method = acpi_method("_OST", 3);
+ s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);
+ aml_append(&method, acpi_return(acpi_call4(
+ s, acpi_name("_UID"), acpi_arg0(), acpi_arg1(), acpi_arg2()
+ )));
+ aml_append(&dev, method);
+
+ aml_append(&sb_scope, dev);
}
+ /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
+ * If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ...
+ */
+ method = acpi_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2);
+ for (i = 0; i < nr_mem; i++) {
+ ifctx = acpi_if(acpi_equal(acpi_arg0(), acpi_int(i)));
+ aml_append(&ifctx,
+ acpi_notify(acpi_name("MP%.02X", i), acpi_arg1())
+ );
+ aml_append(&method, ifctx);
+ }
+ aml_append(&sb_scope, method);
+
{
Object *pci_host;
PCIBus *bus = NULL;
diff --git a/hw/i386/ssdt-mem.dsl b/hw/i386/ssdt-mem.dsl
deleted file mode 100644
index 22ff5dd..0000000
--- a/hw/i386/ssdt-mem.dsl
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Memory hotplug ACPI DSDT static objects definitions
- *
- * Copyright ProfitBricks GmbH 2012
- * Copyright (C) 2013-2014 Red Hat Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>
- */
-
-/* This file is the basis for the ssdt_mem[] variable in src/acpi.c.
- * It defines the contents of the memory device object. At
- * runtime, a dynamically generated SSDT will contain one copy of this
- * AML snippet for every possible memory device in the system. The
- * objects will be placed in the \_SB_ namespace.
- *
- * In addition to the aml code generated from this file, the
- * src/acpi.c file creates a MTFY method with an entry for each memdevice:
- * Method(MTFY, 2) {
- * If (LEqual(Arg0, 0x00)) { Notify(MP00, Arg1) }
- * If (LEqual(Arg0, 0x01)) { Notify(MP01, Arg1) }
- * ...
- * }
- */
-#include "hw/acpi/pc-hotplug.h"
-
-ACPI_EXTRACT_ALL_CODE ssdm_mem_aml
-
-DefinitionBlock ("ssdt-mem.aml", "SSDT", 0x02, "BXPC", "CSSDT", 0x1)
-{
-
- External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_CRS_METHOD, MethodObj)
- External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_STATUS_METHOD,
MethodObj)
- External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_OST_METHOD, MethodObj)
- External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_PROXIMITY_METHOD,
MethodObj)
-
- Scope(\_SB) {
-/* v------------------ DO NOT EDIT ------------------v */
- ACPI_EXTRACT_DEVICE_START ssdt_mem_start
- ACPI_EXTRACT_DEVICE_END ssdt_mem_end
- ACPI_EXTRACT_DEVICE_STRING ssdt_mem_name
- Device(MPAA) {
- ACPI_EXTRACT_NAME_STRING ssdt_mem_id
- Name(_UID, "0xAA")
-/* ^------------------ DO NOT EDIT ------------------^
- * Don't change the above without also updating the C code.
- */
- Name(_HID, EISAID("PNP0C80"))
-
- Method(_CRS, 0) {
-
Return(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_CRS_METHOD(_UID))
- }
-
- Method(_STA, 0) {
-
Return(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_STATUS_METHOD(_UID))
- }
-
- Method(_PXM, 0) {
-
Return(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_PROXIMITY_METHOD(_UID))
- }
-
- Method(_OST, 3) {
- \_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_OST_METHOD(_UID,
Arg0, Arg1, Arg2)
- }
- }
- }
-}
diff --git a/hw/i386/ssdt-mem.hex.generated b/hw/i386/ssdt-mem.hex.generated
deleted file mode 100644
index b3bfbbd..0000000
--- a/hw/i386/ssdt-mem.hex.generated
+++ /dev/null
@@ -1,213 +0,0 @@
-static unsigned char ssdt_mem_id[] = {
-0x35
-};
-static unsigned char ssdm_mem_aml[] = {
-0x53,
-0x53,
-0x44,
-0x54,
-0xc7,
-0x0,
-0x0,
-0x0,
-0x2,
-0x66,
-0x42,
-0x58,
-0x50,
-0x43,
-0x0,
-0x0,
-0x43,
-0x53,
-0x53,
-0x44,
-0x54,
-0x0,
-0x0,
-0x0,
-0x1,
-0x0,
-0x0,
-0x0,
-0x49,
-0x4e,
-0x54,
-0x4c,
-0x28,
-0x8,
-0x14,
-0x20,
-0x10,
-0x42,
-0xa,
-0x5c,
-0x5f,
-0x53,
-0x42,
-0x5f,
-0x5b,
-0x82,
-0x49,
-0x9,
-0x4d,
-0x50,
-0x41,
-0x41,
-0x8,
-0x5f,
-0x55,
-0x49,
-0x44,
-0xd,
-0x30,
-0x78,
-0x41,
-0x41,
-0x0,
-0x8,
-0x5f,
-0x48,
-0x49,
-0x44,
-0xc,
-0x41,
-0xd0,
-0xc,
-0x80,
-0x14,
-0x1e,
-0x5f,
-0x43,
-0x52,
-0x53,
-0x0,
-0xa4,
-0x5c,
-0x2f,
-0x4,
-0x5f,
-0x53,
-0x42,
-0x5f,
-0x50,
-0x43,
-0x49,
-0x30,
-0x4d,
-0x48,
-0x50,
-0x44,
-0x4d,
-0x43,
-0x52,
-0x53,
-0x5f,
-0x55,
-0x49,
-0x44,
-0x14,
-0x1e,
-0x5f,
-0x53,
-0x54,
-0x41,
-0x0,
-0xa4,
-0x5c,
-0x2f,
-0x4,
-0x5f,
-0x53,
-0x42,
-0x5f,
-0x50,
-0x43,
-0x49,
-0x30,
-0x4d,
-0x48,
-0x50,
-0x44,
-0x4d,
-0x52,
-0x53,
-0x54,
-0x5f,
-0x55,
-0x49,
-0x44,
-0x14,
-0x1e,
-0x5f,
-0x50,
-0x58,
-0x4d,
-0x0,
-0xa4,
-0x5c,
-0x2f,
-0x4,
-0x5f,
-0x53,
-0x42,
-0x5f,
-0x50,
-0x43,
-0x49,
-0x30,
-0x4d,
-0x48,
-0x50,
-0x44,
-0x4d,
-0x50,
-0x58,
-0x4d,
-0x5f,
-0x55,
-0x49,
-0x44,
-0x14,
-0x20,
-0x5f,
-0x4f,
-0x53,
-0x54,
-0x3,
-0x5c,
-0x2f,
-0x4,
-0x5f,
-0x53,
-0x42,
-0x5f,
-0x50,
-0x43,
-0x49,
-0x30,
-0x4d,
-0x48,
-0x50,
-0x44,
-0x4d,
-0x4f,
-0x53,
-0x54,
-0x5f,
-0x55,
-0x49,
-0x44,
-0x68,
-0x69,
-0x6a
-};
-static unsigned char ssdt_mem_start[] = {
-0x2c
-};
-static unsigned char ssdt_mem_end[] = {
-0xc7
-};
-static unsigned char ssdt_mem_name[] = {
-0x30
-};
--
1.8.3.1
- [Qemu-devel] [RFC 24/47] acpi: add acpi_operation_region() term, (continued)
- [Qemu-devel] [RFC 24/47] acpi: add acpi_operation_region() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 26/47] acpi: add acpi_local0() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 28/47] pc: acpi-build: generate pvpanic device description dynamically, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 23/47] acpi: include PkgLength size only when requested, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 30/47] acpi: add acpi_equal() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 29/47] acpi: add acpi_varpackage() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 33/47] pc: acpi-build: drop template patching and CPU hotplug objects dynamically, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 31/47] acpi: add acpi_processor() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 32/47] acpi: add acpi_eisaid() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 27/47] acpi: add acpi_string() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 36/47] pc: acpi-build: drop template patching and memory hotplug objects dynamically,
Igor Mammedov <=
- [Qemu-devel] [RFC 35/47] acpi: add acpi_reserved_field() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 34/47] pc: acpi-build: create CPU hotplug IO region dynamically, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 37/47] pc: acpi-build: create memory hotplug IO region dynamically, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 39/47] pc: pcihp: expose MMIO base and len as properties, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 41/47] pc: acpi-build: create PCI0._CRS dynamically, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 40/47] pc: acpi-build: reserve PCIHP MMIO resources, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 38/47] acpi: add acpi_word_bus_number(), acpi_word_io(), acpi_dword_memory(), acpi_qword_memory() terms, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 42/47] acpi: make tables linker-loader available to other targets, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 43/47] acpi: add acpi_def_block() term, Igor Mammedov, 2014/12/18
- [Qemu-devel] [RFC 45/47] pc: acpi-build: drop remaining ssdt_misc template and use acpi_def_block(), Igor Mammedov, 2014/12/18