@@ -9,7 +9,7 @@ obj-y += kvmvapic.o
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-proc.hex hw/i386/ssdt-misc.hex hw/i386/q35-acpi-dsdt.hex \
+ hw/i386/ssdt-misc.hex hw/i386/q35-acpi-dsdt.hex \
hw/i386/ssdt-mem.hex hw/i386/ssdt-tpm.hex
iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
@@ -507,22 +507,6 @@ build_madt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu,
table_data->len - madt_start, 1);
}
-/* Encode a hex value */
-static inline char acpi_get_hex(uint32_t val)
-{
- val &= 0x0f;
- return (val <= 9) ? ('0' + val) : ('A' + val - 10);
-}
-
-#include "hw/i386/ssdt-proc.hex"
-
-/* 0x5B 0x83 ProcessorOp PkgLength NameString ProcID */
-#define ACPI_PROC_OFFSET_CPUHEX (*ssdt_proc_name - *ssdt_proc_start + 2)
-#define ACPI_PROC_OFFSET_CPUID1 (*ssdt_proc_name - *ssdt_proc_start + 4)
-#define ACPI_PROC_OFFSET_CPUID2 (*ssdt_proc_id - *ssdt_proc_start)
-#define ACPI_PROC_SIZEOF (*ssdt_proc_end - *ssdt_proc_start)
-#define ACPI_PROC_AML (ssdp_proc_aml + *ssdt_proc_start)
-
#include "hw/i386/ssdt-mem.hex"
/* 0x5B 0x82 DeviceOp PkgLength NameString DimmID */
@@ -754,7 +738,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, dev, method, crs, field;
+ AcpiAml pkg, scope, dev, method, crs, field, ifctx;
int i;
/* The current AML generator can cover the APIC ID range [0..255],
@@ -835,50 +819,54 @@ build_ssdt(GArray *table_data, GArray *linker,
/* build Processor object for each processor */
for (i = 0; i < acpi_cpus; i++) {
- 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);
- proc[ACPI_PROC_OFFSET_CPUID1] = i;
- proc[ACPI_PROC_OFFSET_CPUID2] = i;
+ dev = acpi_processor(i, 0, 0, "CP%.02X", i);
+
+ method = acpi_method("_MAT", 0);
+ aml_append(&method, acpi_return(acpi_call1("CPMA", acpi_int(i))));
+ aml_append(&dev, method);
+
+ method = acpi_method("_STA", 0);
+ aml_append(&method, acpi_return(acpi_call1("CPST", acpi_int(i))));
+ aml_append(&dev, method);
+
+ method = acpi_method("_EJ0", 1);
+ aml_append(&method,
+ acpi_return(acpi_call2("CPEJ", acpi_int(i), acpi_arg0()))
+ );
+ aml_append(&dev, method);
+
+ aml_append(&sb_scope, dev);
}
/* build this code:
* Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...}
*/
/* Arg0 = Processor ID = APIC ID */
- 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.buf, 0x08); /* NameOp */
- build_append_namestring(sb_scope.buf, "CPON");
-
- {
- GArray *package = build_alloc_array();
- uint8_t op;
-
- /*
- * Note: The ability to create variable-sized packages was first introduced in ACPI 2.0. ACPI 1.0 only
- * allowed fixed-size packages with up to 255 elements.
- * Windows guests up to win2k8 fail when VarPackageOp is used.
- */
- if (acpi_cpus <= 255) {
- op = 0x12; /* PackageOp */
- build_append_byte(package, acpi_cpus); /* NumElements */
- } else {
- op = 0x13; /* VarPackageOp */
- build_append_int(package, acpi_cpus); /* VarNumElements */
- }
-
- for (i = 0; i < acpi_cpus; i++) {
- uint8_t b = test_bit(i, cpu->found_cpus) ? 0x01 : 0x00;
- build_append_byte(package, b);
- }
+ method = acpi_method("NTFY", 2);
+ for (i = 0; i < acpi_cpus; i++) {
+ ifctx = acpi_if(acpi_equal(acpi_arg0(), acpi_int(i)));
+ aml_append(&ifctx,
+ acpi_notify(acpi_name("CP%.02X", i), acpi_arg1())
+ );
+ aml_append(&method, ifctx);
+ }
+ aml_append(&sb_scope, method);
+
+ /* build "Name(CPON, Package() { One, One, ..., Zero, Zero, ... })"
+ *
+ * Note: The ability to create variable-sized packages was first
+ * ntroduced in ACPI 2.0. ACPI 1.0 only allowed fixed-size packages
+ * ith up to 255 elements. Windows guests up to win2k8 fail when
+ * VarPackageOp is used.
+ */
+ pkg = acpi_cpus <= 255 ? acpi_package(acpi_cpus) :
+ acpi_varpackage(acpi_cpus);
- build_package(package, op);
- build_append_array(sb_scope.buf, package);
- build_free_array(package);
+ for (i = 0; i < acpi_cpus; i++) {
+ uint8_t b = test_bit(i, cpu->found_cpus) ? 0x01 : 0x00;
+ aml_append(&pkg, acpi_int(b));
}
+ aml_append(&sb_scope, acpi_name_decl("CPON", pkg));
if (nr_mem) {
assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
deleted file mode 100644
@@ -1,63 +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 <http://www.gnu.org/licenses/>.
- */
-
-/* This file is the basis for the ssdt table generated in src/acpi.c.
- * It defines the contents of the per-cpu Processor() object. At
- * runtime, a dynamically generated SSDT will contain one copy of this
- * AML snippet for every possible cpu 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 NTFY method with an entry for each cpu:
- * Method(NTFY, 2) {
- * If (LEqual(Arg0, 0x00)) { Notify(CP00, Arg1) }
- * If (LEqual(Arg0, 0x01)) { Notify(CP01, Arg1) }
- * ...
- * }
- * and a CPON array with the list of active and inactive cpus:
- * Name(CPON, Package() { One, One, ..., Zero, Zero, ... })
- */
-
-ACPI_EXTRACT_ALL_CODE ssdp_proc_aml
-
-DefinitionBlock ("ssdt-proc.aml", "SSDT", 0x01, "BXPC", "BXSSDT", 0x1)
-{
- ACPI_EXTRACT_PROCESSOR_START ssdt_proc_start
- ACPI_EXTRACT_PROCESSOR_END ssdt_proc_end
- ACPI_EXTRACT_PROCESSOR_STRING ssdt_proc_name
- Processor(CPAA, 0xAA, 0x00000000, 0x0) {
- ACPI_EXTRACT_NAME_BYTE_CONST ssdt_proc_id
- Name(ID, 0xAA)
-/*
- * The src/acpi.c code requires the above ACP_EXTRACT tags so that it can update
- * CPAA and 0xAA with the appropriate CPU id (see
- * SD_OFFSET_CPUHEX/CPUID1/CPUID2). Don't change the above without
- * also updating the C code.
- */
- Name(_HID, "ACPI0007")
- External(CPMA, MethodObj)
- External(CPST, MethodObj)
- External(CPEJ, MethodObj)
- Method(_MAT, 0) {
- Return (CPMA(ID))
- }
- Method(_STA, 0) {
- Return (CPST(ID))
- }
- Method(_EJ0, 1, NotSerialized) {
- CPEJ(ID, Arg0)
- }
- }
-}
deleted file mode 100644
@@ -1,134 +0,0 @@
-static unsigned char ssdt_proc_name[] = {
-0x28
-};
-static unsigned char ssdp_proc_aml[] = {
-0x53,
-0x53,
-0x44,
-0x54,
-0x78,
-0x0,
-0x0,
-0x0,
-0x1,
-0x7d,
-0x42,
-0x58,
-0x50,
-0x43,
-0x0,
-0x0,
-0x42,
-0x58,
-0x53,
-0x53,
-0x44,
-0x54,
-0x0,
-0x0,
-0x1,
-0x0,
-0x0,
-0x0,
-0x49,
-0x4e,
-0x54,
-0x4c,
-0x15,
-0x11,
-0x13,
-0x20,
-0x5b,
-0x83,
-0x42,
-0x5,
-0x43,
-0x50,
-0x41,
-0x41,
-0xaa,
-0x0,
-0x0,
-0x0,
-0x0,
-0x0,
-0x8,
-0x49,
-0x44,
-0x5f,
-0x5f,
-0xa,
-0xaa,
-0x8,
-0x5f,
-0x48,
-0x49,
-0x44,
-0xd,
-0x41,
-0x43,
-0x50,
-0x49,
-0x30,
-0x30,
-0x30,
-0x37,
-0x0,
-0x14,
-0xf,
-0x5f,
-0x4d,
-0x41,
-0x54,
-0x0,
-0xa4,
-0x43,
-0x50,
-0x4d,
-0x41,
-0x49,
-0x44,
-0x5f,
-0x5f,
-0x14,
-0xf,
-0x5f,
-0x53,
-0x54,
-0x41,
-0x0,
-0xa4,
-0x43,
-0x50,
-0x53,
-0x54,
-0x49,
-0x44,
-0x5f,
-0x5f,
-0x14,
-0xf,
-0x5f,
-0x45,
-0x4a,
-0x30,
-0x1,
-0x43,
-0x50,
-0x45,
-0x4a,
-0x49,
-0x44,
-0x5f,
-0x5f,
-0x68
-};
-static unsigned char ssdt_proc_id[] = {
-0x38
-};
-static unsigned char ssdt_proc_end[] = {
-0x78
-};
-static unsigned char ssdt_proc_start[] = {
-0x24
-};
in addition it saves us ~400LOC and makes it one binary blob less stored in QEMU source tree by removing need to keep and update hw/i386/ssdt-proc.hex.generated file there. Signed-off-by: Igor Mammedov <imammedo@redhat.com> --- hw/i386/Makefile.objs | 2 +- hw/i386/acpi-build.c | 94 ++++++++++++---------------- hw/i386/ssdt-proc.dsl | 63 ------------------- hw/i386/ssdt-proc.hex.generated | 134 ---------------------------------------- 4 files changed, 42 insertions(+), 251 deletions(-) delete mode 100644 hw/i386/ssdt-proc.dsl delete mode 100644 hw/i386/ssdt-proc.hex.generated