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