88c41d
commit d9798f5275bb20ab88ac854ba04e6e3bdb22cf6d
88c41d
Author: Lawrence Hileman <larry.hileman@xconn-tech.com>
88c41d
Date:   Mon Jan 17 15:24:34 2022 -0800
88c41d
88c41d
    Fix Compile issue with CEDT and add template
88c41d
88c41d
diff --git a/source/compiler/dttable1.c b/source/compiler/dttable1.c
88c41d
index 79550ab..6eea2a4 100644
88c41d
--- a/source/compiler/dttable1.c
88c41d
+++ b/source/compiler/dttable1.c
88c41d
@@ -262,6 +262,7 @@ DtCompileCedt (
88c41d
 
88c41d
     while (*PFieldList)
88c41d
     {
88c41d
+        int InsertFlag = 1;             // if CFMWS and has more than one target, then set to zero later
88c41d
         SubtableStart = *PFieldList;
88c41d
 
88c41d
         /* CEDT Header */
88c41d
@@ -283,24 +284,68 @@ DtCompileCedt (
88c41d
         {
88c41d
         case ACPI_CEDT_TYPE_CHBS:
88c41d
             Status = DtCompileTable (PFieldList, AcpiDmTableInfoCedt0, &Subtable);
88c41d
+            if (ACPI_FAILURE (Status))
88c41d
+            {
88c41d
+                return (Status);
88c41d
+            }
88c41d
             break;
88c41d
-        case ACPI_CEDT_TYPE_CFMWS:
88c41d
+        case ACPI_CEDT_TYPE_CFMWS: {
88c41d
+            unsigned char *dump;
88c41d
+            unsigned int idx, offset, max = 0;
88c41d
+
88c41d
+            // Compile table with first "Interleave target"
88c41d
             Status = DtCompileTable (PFieldList, AcpiDmTableInfoCedt1, &Subtable);
88c41d
+            if (ACPI_FAILURE (Status))
88c41d
+            {
88c41d
+                return (Status);
88c41d
+            }
88c41d
+
88c41d
+            // Look in buffer for the number of targets
88c41d
+            offset = (unsigned int) ACPI_OFFSET (ACPI_CEDT_CFMWS, InterleaveWays);
88c41d
+            dump = (unsigned char *) Subtable->Buffer - 4;     // place at beginning of cedt1
88c41d
+            max = 0x01 << dump[offset]; // 2^max, so 0=1, 1=2, 2=4, 3=8.  8 is MAX
88c41d
+            if (max > 8)    max=1;      // Error in encoding Interleaving Ways.
88c41d
+            if (max == 1)               // if only one target, then break here.
88c41d
+                break;                  // break if only one target.
88c41d
+
88c41d
+            // We need to add more interleave targets, so write the current Subtable.
88c41d
+            ParentTable = DtPeekSubtable ();
88c41d
+            DtInsertSubtable (ParentTable, Subtable);   // Insert AcpiDmTableInfoCedt1 table so we can put in
88c41d
+            DtPushSubtable (Subtable);                  // the targets > the first.
88c41d
+
88c41d
+            // Now, find out all interleave targets beyond the first.
88c41d
+            for (idx = 1; idx < max; idx++) {
88c41d
+                ParentTable = DtPeekSubtable ();
88c41d
+
88c41d
+                if (*PFieldList)
88c41d
+                {
88c41d
+                    Status = DtCompileTable (PFieldList, AcpiDmTableInfoCedt1_te, &Subtable);
88c41d
+                    if (ACPI_FAILURE (Status))
88c41d
+                    {
88c41d
+                        return (Status);
88c41d
+                    }
88c41d
+                    if (Subtable)
88c41d
+                    {
88c41d
+                        DtInsertSubtable (ParentTable, Subtable);       // got a target, so insert table.
88c41d
+                        InsertFlag = 0;
88c41d
+                    }
88c41d
+                }
88c41d
+            }
88c41d
+
88c41d
+            DtPopSubtable ();
88c41d
+            ParentTable = DtPeekSubtable ();
88c41d
             break;
88c41d
+        }
88c41d
 
88c41d
         default:
88c41d
             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "CEDT");
88c41d
             return (AE_ERROR);
88c41d
         }
88c41d
 
88c41d
-        /* CEDT Subtable */
88c41d
-        if (ACPI_FAILURE (Status))
88c41d
-        {
88c41d
-            return (Status);
88c41d
-        }
88c41d
-
88c41d
         ParentTable = DtPeekSubtable ();
88c41d
-        DtInsertSubtable (ParentTable, Subtable);
88c41d
+        if (InsertFlag == 1) {
88c41d
+                DtInsertSubtable (ParentTable, Subtable);
88c41d
+        }
88c41d
         DtPopSubtable ();
88c41d
     }
88c41d
 
88c41d
diff --git a/source/compiler/dttemplate.h b/source/compiler/dttemplate.h
88c41d
index 82f352a..ceddb93 100644
88c41d
--- a/source/compiler/dttemplate.h
88c41d
+++ b/source/compiler/dttemplate.h
88c41d
@@ -98,23 +98,58 @@ const unsigned char TemplateBoot[] =
88c41d
 
88c41d
 const unsigned char TemplateCedt[] =
88c41d
 {
88c41d
-    0x43,0x45,0x44,0x54,0x84,0x00,0x00,0x00,  /* 00000000    "CEDT...." */
88c41d
-    0x01,0x8B,0x49,0x4E,0x54,0x45,0x4C,0x20,  /* 00000008    "..INTEL " */
88c41d
-    0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45,  /* 00000010    "TEMPLATE" */
88c41d
-    0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
88c41d
-    0x05,0x01,0x21,0x20,0x00,0x00,0x20,0x00,  /* 00000020    "..! .. ." */
88c41d
-    0x33,0x33,0xCD,0xAB,0x01,0x00,0x00,0x00,  /* 00000028    "33......" */
88c41d
-    0x00,0x00,0x00,0x00,0x00,0x21,0x43,0xD5,  /* 00000030    ".....!C." */
88c41d
-    0x00,0x00,0x00,0x00,0x45,0x23,0x01,0x00,  /* 00000038    "....E#.." */
88c41d
+    0x43,0x45,0x44,0x54,0x9c,0x01,0x00,0x00,  /* 00000000    "CEDT...." */
88c41d
+    0x01,0x87,0x49,0x4e,0x54,0x45,0x4c,0x20,  /* 00000008    "..INTEL " */
88c41d
+    0x54,0x45,0x4d,0x50,0x4c,0x41,0x54,0x45,  /* 00000010    "TEMPLATE" */
88c41d
+    0x00,0x00,0x00,0x00,0x49,0x4e,0x54,0x4c,  /* 00000018    "....INTL" */
88c41d
+    0x17,0x12,0x21,0x20,0x00,0x00,0x20,0x00,  /* 00000020    "..! .. ." */
88c41d
+    0x00,0x5e,0xba,0x00,0x00,0x00,0x00,0x00,  /* 00000028    ".^......" */
88c41d
+    0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,  /* 00000030    "........" */
88c41d
+    0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,  /* 00000038    "..... .." */
88c41d
     0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,  /* 00000040    "...... ." */
88c41d
-    0x44,0x44,0xCD,0xAB,0x01,0x00,0x00,0x00,  /* 00000048    "DD......" */
88c41d
-    0x00,0x00,0x00,0x00,0x00,0x21,0x43,0xA5,  /* 00000050    ".....!C." */
88c41d
-    0x00,0x00,0x00,0x00,0x45,0x23,0xB1,0x00,  /* 00000058    "....E#.." */
88c41d
+    0x01,0x5e,0xba,0x00,0x00,0x00,0x00,0x00,  /* 00000048    ".^......" */
88c41d
+    0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,  /* 00000050    "..... .." */
88c41d
+    0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,  /* 00000058    "..... .." */
88c41d
     0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,  /* 00000060    "...... ." */
88c41d
-    0x55,0x55,0xCD,0xAB,0x01,0x00,0x00,0x00,  /* 00000068    "UU......" */
88c41d
-    0x00,0x00,0x00,0x00,0x00,0x21,0x43,0xB5,  /* 00000070    ".....!C." */
88c41d
-    0x00,0x00,0x00,0x00,0x45,0x23,0xB1,0x00,  /* 00000078    "....E#.." */
88c41d
-    0x00,0x00,0x00,0x00                       /* 00000080    "...."     */
88c41d
+    0x02,0x5e,0xba,0x00,0x00,0x00,0x00,0x00,  /* 00000068    ".^......" */
88c41d
+    0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,  /* 00000070    ".....0.." */
88c41d
+    0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,  /* 00000078    "..... .." */
88c41d
+    0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,  /* 00000080    "...... ." */
88c41d
+    0x03,0x5e,0xba,0x00,0x00,0x00,0x00,0x00,  /* 00000088    ".^......" */
88c41d
+    0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,  /* 00000090    ".....@.." */
88c41d
+    0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,  /* 00000098    "..... .." */
88c41d
+    0x00,0x00,0x00,0x00,0x01,0x00,0x28,0x00,  /* 000000a0    "......(." */
88c41d
+    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000a8    "........" */
88c41d
+    0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000b0    "........" */
88c41d
+    0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000b8    "........" */
88c41d
+    0x03,0x00,0x00,0x00,0x06,0x00,0x01,0x00,  /* 000000c0    "........" */
88c41d
+    0x00,0x5e,0xba,0x00,0x01,0x00,0x28,0x00,  /* 000000c8    ".^....(." */
88c41d
+    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000d0    "........" */
88c41d
+    0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000d8    "........" */
88c41d
+    0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000e0    "........" */
88c41d
+    0x03,0x00,0x00,0x00,0x06,0x00,0x01,0x00,  /* 000000e8    "........" */
88c41d
+    0x01,0x5e,0xba,0x00,0x01,0x00,0x28,0x00,  /* 000000f0    ".^....(." */
88c41d
+    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000f8    "........" */
88c41d
+    0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000100    "........" */
88c41d
+    0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000108    "........" */
88c41d
+    0x03,0x00,0x00,0x00,0x06,0x00,0x01,0x00,  /* 00000110    "........" */
88c41d
+    0x02,0x5e,0xba,0x00,0x01,0x00,0x28,0x00,  /* 00000118    ".^....(." */
88c41d
+    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000120    "........" */
88c41d
+    0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000128    "........" */
88c41d
+    0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000130    "........" */
88c41d
+    0x03,0x00,0x00,0x00,0x06,0x00,0x01,0x00,  /* 00000138    "........" */
88c41d
+    0x03,0x5e,0xba,0x00,0x01,0x00,0x2c,0x00,  /* 00000140    ".^....,." */
88c41d
+    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000148    "........" */
88c41d
+    0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000150    "........" */
88c41d
+    0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x00,  /* 00000158    "........" */
88c41d
+    0x03,0x00,0x00,0x00,0x06,0x00,0x01,0x00,  /* 00000160    "........" */
88c41d
+    0x00,0x5e,0xba,0x00,0x01,0x5e,0xba,0x00,  /* 00000160    ".^...^.." */
88c41d
+    0x01,0x00,0x2c,0x00,0x00,0x00,0x00,0x00,  /* 00000170    "..,....." */
88c41d
+    0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,  /* 00000178    "........" */
88c41d
+    0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,  /* 00000180    "........" */
88c41d
+    0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,  /* 00000188    "........" */
88c41d
+    0x0a,0x00,0x01,0x00,0x02,0x5e,0xba,0x00,  /* 00000190    ".....^.." */
88c41d
+    0x03,0x5e,0xba,0x00                       /* 00000198    ".^.."     */
88c41d
 };
88c41d
 
88c41d
 const unsigned char TemplateCpep[] =