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