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