[PATCHv3 4/4] acpi: automatically generated ssdt proc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Get rid of manually cut and pasted ssdt_proc,
use ssdt compiled by iasl and offsets extracted
by acpi_extract instead.

Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
---
 Makefile          |    2 +-
 src/acpi.c        |   33 +++++++++++++--------------------
 src/ssdt-proc.dsl |   19 +++++++------------
 3 files changed, 21 insertions(+), 33 deletions(-)

diff --git a/Makefile b/Makefile
index 541b080..fee68aa 100644
--- a/Makefile
+++ b/Makefile
@@ -200,7 +200,7 @@ src/%.hex: src/%.dsl ./tools/acpi_extract_preprocess.py ./tools/acpi_extract.py
 	$(Q)./tools/acpi_extract.py $(OUT)$*.lst > $(OUT)$*.off
 	$(Q)cat $(OUT)$*.hex $(OUT)$*.off > $@
 
-$(OUT)ccode32flat.o: src/acpi-dsdt.hex
+$(OUT)ccode32flat.o: src/acpi-dsdt.hex src/ssdt-proc.hex
 
 ####### Kconfig rules
 export HOSTCC             := $(CC)
diff --git a/src/acpi.c b/src/acpi.c
index f65f974..cf60257 100644
--- a/src/acpi.c
+++ b/src/acpi.c
@@ -398,23 +398,16 @@ encodeLen(u8 *ssdt_ptr, int length, int bytes)
     return ssdt_ptr + bytes;
 }
 
-// AML Processor() object.  See src/ssdt-proc.dsl for info.
-static unsigned char ssdt_proc[] = {
-    0x5b,0x83,0x42,0x05,0x43,0x50,0x41,0x41,
-    0xaa,0x10,0xb0,0x00,0x00,0x06,0x08,0x49,
-    0x44,0x5f,0x5f,0x0a,0xaa,0x08,0x5f,0x48,
-    0x49,0x44,0x0d,0x41,0x43,0x50,0x49,0x30,
-    0x30,0x30,0x37,0x00,0x14,0x0f,0x5f,0x4d,
-    0x41,0x54,0x00,0xa4,0x43,0x50,0x4d,0x41,
-    0x49,0x44,0x5f,0x5f,0x14,0x0f,0x5f,0x53,
-    0x54,0x41,0x00,0xa4,0x43,0x50,0x53,0x54,
-    0x49,0x44,0x5f,0x5f,0x14,0x0f,0x5f,0x45,
-    0x4a,0x30,0x01,0x43,0x50,0x45,0x4a,0x49,
-    0x44,0x5f,0x5f,0x68
-};
-#define SD_OFFSET_CPUHEX 6
-#define SD_OFFSET_CPUID1 8
-#define SD_OFFSET_CPUID2 20
+#define AmlCode static ssdp_proc_aml
+#include "ssdt-proc.hex"
+#undef AmlCode
+
+/* 0x5B 0x83 ProcessorOp PkgLength NameString ProcID */
+#define SD_OFFSET_CPUHEX (*ssdt_proc_name - *ssdt_proc_start + 2)
+#define SD_OFFSET_CPUID1 (*ssdt_proc_name - *ssdt_proc_start + 4)
+#define SD_OFFSET_CPUID2 (*ssdt_proc_id - *ssdt_proc_start)
+#define SD_SIZEOF (*ssdt_proc_end - *ssdt_proc_start)
+#define SD_PROC (ssdp_proc_aml + *ssdt_proc_start)
 
 #define SSDT_SIGNATURE 0x54445353 // SSDT
 static void*
@@ -423,7 +416,7 @@ build_ssdt(void)
     int acpi_cpus = MaxCountCPUs > 0xff ? 0xff : MaxCountCPUs;
     // length = ScopeOp + procs + NTYF method + CPON package
     int length = ((1+3+4)
-                  + (acpi_cpus * sizeof(ssdt_proc))
+                  + (acpi_cpus * SD_SIZEOF)
                   + (1+2+5+(12*acpi_cpus))
                   + (6+2+1+(1*acpi_cpus)));
     u8 *ssdt = malloc_high(sizeof(struct acpi_table_header) + length);
@@ -444,12 +437,12 @@ build_ssdt(void)
     // build Processor object for each processor
     int i;
     for (i=0; i<acpi_cpus; i++) {
-        memcpy(ssdt_ptr, ssdt_proc, sizeof(ssdt_proc));
+        memcpy(ssdt_ptr, SD_PROC, SD_SIZEOF);
         ssdt_ptr[SD_OFFSET_CPUHEX] = getHex(i >> 4);
         ssdt_ptr[SD_OFFSET_CPUHEX+1] = getHex(i);
         ssdt_ptr[SD_OFFSET_CPUID1] = i;
         ssdt_ptr[SD_OFFSET_CPUID2] = i;
-        ssdt_ptr += sizeof(ssdt_proc);
+        ssdt_ptr += SD_SIZEOF;
     }
 
     // build "Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...}"
diff --git a/src/ssdt-proc.dsl b/src/ssdt-proc.dsl
index 358afa8..a461636 100644
--- a/src/ssdt-proc.dsl
+++ b/src/ssdt-proc.dsl
@@ -1,16 +1,9 @@
-/* This file is the basis for the ssdt_proc[] variable in src/acpi.c.
+/* 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.
  *
- * To generate a new ssdt_proc[], run the commands:
- *   cpp -P src/ssdt-proc.dsl > out/ssdt-proc.dsl.i
- *   iasl -ta -p out/ssdt-proc out/ssdt-proc.dsl.i
- *   tail -c +37 < out/ssdt-proc.aml | hexdump -e '"    " 8/1 "0x%02x," "\n"'
- * and then cut-and-paste the output into the src/acpi.c ssdt_proc[]
- * array.
- *
  * 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) {
@@ -22,13 +15,15 @@
  *     Name(CPON, Package() { One, One, ..., Zero, Zero, ... })
  */
 DefinitionBlock ("ssdt-proc.aml", "SSDT", 0x01, "BXPC", "BXSSDT", 0x1)
-/*  v------------------ DO NOT EDIT ------------------v */
 {
+    ACPI_EXTRACT_PROCESSOR_START ssdt_proc_start
+    ACPI_EXTRACT_PROCESSOR_END ssdt_proc_end
+    ACPI_EXTRACT_PROCESSOR_STRING ssdt_proc_name
     Processor (CPAA, 0xAA, 0x0000b010, 0x06) {
+        ACPI_EXTRACT_NAME_BYTE_CONST ssdt_proc_id
         Name (ID, 0xAA)
-/*  ^------------------ DO NOT EDIT ------------------^
- *
- * The src/acpi.c code requires the above layout so that it can update
+/*
+ * 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.
-- 
1.7.5.53.gc233e
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux