88c41d
commit b980be9b7fd364f62f62655e458325581a4f239c
88c41d
Author: Ben Widawsky <ben@bwidawsk.net>
88c41d
Date:   Thu Feb 25 14:11:46 2021 -0800
88c41d
88c41d
    CXL 2.0: CEDT: Add table and subtable dumping
88c41d
    
88c41d
    Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
88c41d
88c41d
diff --git a/source/common/dmtable.c b/source/common/dmtable.c
88c41d
index 137b5b9..f483a78 100644
88c41d
--- a/source/common/dmtable.c
88c41d
+++ b/source/common/dmtable.c
88c41d
@@ -376,7 +376,7 @@ const ACPI_DMTABLE_DATA     AcpiDmTableData[] =
88c41d
     {ACPI_SIG_BERT, AcpiDmTableInfoBert,    NULL,           NULL,           TemplateBert},
88c41d
     {ACPI_SIG_BGRT, AcpiDmTableInfoBgrt,    NULL,           NULL,           TemplateBgrt},
88c41d
     {ACPI_SIG_BOOT, AcpiDmTableInfoBoot,    NULL,           NULL,           TemplateBoot},
88c41d
-    {ACPI_SIG_CEDT, NULL,                   NULL,           NULL,           NULL},
88c41d
+    {ACPI_SIG_CEDT, NULL,                   AcpiDmDumpCedt, NULL,           NULL},
88c41d
     {ACPI_SIG_CPEP, NULL,                   AcpiDmDumpCpep, DtCompileCpep,  TemplateCpep},
88c41d
     {ACPI_SIG_CSRT, NULL,                   AcpiDmDumpCsrt, DtCompileCsrt,  TemplateCsrt},
88c41d
     {ACPI_SIG_DBG2, AcpiDmTableInfoDbg2,    AcpiDmDumpDbg2, DtCompileDbg2,  TemplateDbg2},
88c41d
diff --git a/source/common/dmtbdump1.c b/source/common/dmtbdump1.c
88c41d
index 0103a6c..19a810f 100644
88c41d
--- a/source/common/dmtbdump1.c
88c41d
+++ b/source/common/dmtbdump1.c
88c41d
@@ -221,6 +221,82 @@ AcpiDmDumpAsf (
88c41d
     }
88c41d
 }
88c41d
 
88c41d
+/*******************************************************************************
88c41d
+ *
88c41d
+ * FUNCTION:    AcpiDmDumpCedt
88c41d
+ *
88c41d
+ * PARAMETERS:  Table               - A CEDT table
88c41d
+ *
88c41d
+ * RETURN:      None
88c41d
+ *
88c41d
+ * DESCRIPTION: Format the contents of a CEDT. This table type consists
88c41d
+ *              of an open-ended number of subtables.
88c41d
+ *
88c41d
+ ******************************************************************************/
88c41d
+
88c41d
+void
88c41d
+AcpiDmDumpCedt (
88c41d
+    ACPI_TABLE_HEADER       *Table)
88c41d
+{
88c41d
+    ACPI_STATUS             Status;
88c41d
+    ACPI_CEDT_HEADER        *Subtable;
88c41d
+    UINT32                  Length = Table->Length;
88c41d
+    UINT32                  Offset = sizeof (ACPI_TABLE_CEDT);
88c41d
+    ACPI_DMTABLE_INFO       *InfoTable;
88c41d
+
88c41d
+
88c41d
+    /* There is no main table (other than the standard ACPI header) */
88c41d
+
88c41d
+    Subtable = ACPI_ADD_PTR (ACPI_CEDT_HEADER, Table, Offset);
88c41d
+    while (Offset < Table->Length)
88c41d
+    {
88c41d
+        /* Common subtable header */
88c41d
+
88c41d
+        AcpiOsPrintf ("\n");
88c41d
+        Status = AcpiDmDumpTable (Length, Offset, Subtable,
88c41d
+            Subtable->Length, AcpiDmTableInfoCedtHdr);
88c41d
+        if (ACPI_FAILURE (Status))
88c41d
+        {
88c41d
+            return;
88c41d
+        }
88c41d
+
88c41d
+        switch (Subtable->Type)
88c41d
+        {
88c41d
+        case ACPI_CEDT_TYPE_CHBS:
88c41d
+
88c41d
+            InfoTable = AcpiDmTableInfoCedt0;
88c41d
+            break;
88c41d
+
88c41d
+        default:
88c41d
+
88c41d
+            AcpiOsPrintf ("\n**** Unknown CEDT subtable type 0x%X\n\n",
88c41d
+                Subtable->Type);
88c41d
+
88c41d
+            /* Attempt to continue */
88c41d
+
88c41d
+            if (!Subtable->Length)
88c41d
+            {
88c41d
+                AcpiOsPrintf ("Invalid zero length subtable\n");
88c41d
+                return;
88c41d
+            }
88c41d
+            goto NextSubtable;
88c41d
+        }
88c41d
+
88c41d
+        Status = AcpiDmDumpTable (Length, Offset, Subtable,
88c41d
+            Subtable->Length, InfoTable);
88c41d
+        if (ACPI_FAILURE (Status))
88c41d
+        {
88c41d
+            return;
88c41d
+        }
88c41d
+
88c41d
+NextSubtable:
88c41d
+        /* Point to next subtable */
88c41d
+
88c41d
+        Offset += Subtable->Length;
88c41d
+        Subtable = ACPI_ADD_PTR (ACPI_CEDT_HEADER, Subtable,
88c41d
+            Subtable->Length);
88c41d
+    }
88c41d
+}
88c41d
 
88c41d
 /*******************************************************************************
88c41d
  *
88c41d
diff --git a/source/include/acdisasm.h b/source/include/acdisasm.h
88c41d
index 5e94ee3..d7f348f 100644
88c41d
--- a/source/include/acdisasm.h
88c41d
+++ b/source/include/acdisasm.h
88c41d
@@ -533,6 +533,10 @@ void
88c41d
 AcpiDmDumpAsf (
88c41d
     ACPI_TABLE_HEADER       *Table);
88c41d
 
88c41d
+void
88c41d
+AcpiDmDumpCedt (
88c41d
+    ACPI_TABLE_HEADER       *Table);
88c41d
+
88c41d
 void
88c41d
 AcpiDmDumpCpep (
88c41d
     ACPI_TABLE_HEADER       *Table);