git: 9a4bc5208fad - main - acpica: Import ACPICA 20221020

From: Jung-uk Kim <jkim_at_FreeBSD.org>
Date: Fri, 28 Oct 2022 02:05:22 UTC
The branch main has been updated by jkim:

URL: https://cgit.FreeBSD.org/src/commit/?id=9a4bc5208fad4d69360dbbe769e28a37419c4e21

commit 9a4bc5208fad4d69360dbbe769e28a37419c4e21
Author:     Jung-uk Kim <jkim@FreeBSD.org>
AuthorDate: 2022-10-27 21:34:40 +0000
Commit:     Jung-uk Kim <jkim@FreeBSD.org>
CommitDate: 2022-10-28 02:03:50 +0000

    acpica: Import ACPICA 20221020
    
    (cherry picked from commit a799bdd9d50e84cd6a36e8f1d2ac4301b2a6b374)
---
 sys/contrib/dev/acpica/common/acfileio.c           | 131 ++++++--
 sys/contrib/dev/acpica/common/adisasm.c            |   4 +-
 sys/contrib/dev/acpica/common/ahtable.c            |   2 +
 sys/contrib/dev/acpica/common/ahuuids.c            |   3 +
 sys/contrib/dev/acpica/common/dmtable.c            | 116 ++++---
 sys/contrib/dev/acpica/common/dmtables.c           |   2 +-
 sys/contrib/dev/acpica/common/dmtbdump.c           |   4 +-
 sys/contrib/dev/acpica/common/dmtbdump1.c          | 205 ++++++++++++-
 sys/contrib/dev/acpica/common/dmtbdump2.c          | 100 ++++--
 sys/contrib/dev/acpica/common/dmtbinfo1.c          | 110 +++++++
 sys/contrib/dev/acpica/common/dmtbinfo2.c          |  33 +-
 sys/contrib/dev/acpica/common/dmtbinfo3.c          |  17 ++
 sys/contrib/dev/acpica/compiler/aslcodegen.c       |  75 ++++-
 sys/contrib/dev/acpica/compiler/aslcompile.c       |  12 +-
 sys/contrib/dev/acpica/compiler/aslerror.c         |   1 -
 sys/contrib/dev/acpica/compiler/aslhelp.c          |   1 +
 sys/contrib/dev/acpica/compiler/asloptions.c       |  30 +-
 sys/contrib/dev/acpica/compiler/aslpredef.c        |   2 +-
 sys/contrib/dev/acpica/compiler/aslprune.c         |   8 +
 sys/contrib/dev/acpica/compiler/aslstartup.c       |   2 +-
 sys/contrib/dev/acpica/compiler/dtcompile.c        |  42 +++
 sys/contrib/dev/acpica/compiler/dtcompiler.h       |  10 +
 sys/contrib/dev/acpica/compiler/dtio.c             |   2 +-
 sys/contrib/dev/acpica/compiler/dttable1.c         | 128 +++++++-
 sys/contrib/dev/acpica/compiler/dttable2.c         | 169 +++++++++--
 sys/contrib/dev/acpica/compiler/dttemplate.h       |  63 +++-
 sys/contrib/dev/acpica/compiler/dtutils.c          |   3 +-
 .../dev/acpica/components/debugger/dbutils.c       | 192 ++++++++++++
 sys/contrib/dev/acpica/components/events/evevent.c |  11 +-
 .../dev/acpica/components/events/evregion.c        |   8 +
 .../dev/acpica/components/executer/exfield.c       |   6 +-
 .../dev/acpica/components/executer/exserial.c      |   6 +
 .../dev/acpica/components/hardware/hwsleep.c       |  10 +
 sys/contrib/dev/acpica/components/tables/tbdata.c  |   2 +-
 sys/contrib/dev/acpica/components/tables/tbfadt.c  |   2 +-
 sys/contrib/dev/acpica/components/tables/tbprint.c |  90 +-----
 sys/contrib/dev/acpica/components/tables/tbutils.c |   2 +-
 .../dev/acpica/components/tables/tbxfroot.c        |  32 +-
 .../dev/acpica/components/utilities/utcksum.c      | 335 +++++++++++++++++++++
 .../dev/acpica/components/utilities/utglobal.c     |   1 +
 .../dev/acpica/components/utilities/utstring.c     |  10 +-
 sys/contrib/dev/acpica/include/acconfig.h          |   2 +
 sys/contrib/dev/acpica/include/acdisasm.h          |  19 ++
 sys/contrib/dev/acpica/include/acglobal.h          |   1 +
 sys/contrib/dev/acpica/include/acpixf.h            |   2 +-
 sys/contrib/dev/acpica/include/actables.h          |  10 -
 sys/contrib/dev/acpica/include/actbinfo.h          |  10 +
 sys/contrib/dev/acpica/include/actbl1.h            | 179 ++++++++++-
 sys/contrib/dev/acpica/include/actbl2.h            | 163 +++++++++-
 sys/contrib/dev/acpica/include/actypes.h           |   9 +-
 sys/contrib/dev/acpica/include/acutils.h           |  25 ++
 sys/contrib/dev/acpica/include/acuuid.h            |   3 +-
 52 files changed, 2121 insertions(+), 284 deletions(-)

diff --git a/sys/contrib/dev/acpica/common/acfileio.c b/sys/contrib/dev/acpica/common/acfileio.c
index ca1e9199f3e3..819e7ceaa7e6 100644
--- a/sys/contrib/dev/acpica/common/acfileio.c
+++ b/sys/contrib/dev/acpica/common/acfileio.c
@@ -387,16 +387,36 @@ AcGetOneTableFromFile (
     ACPI_TABLE_HEADER       TableHeader;
     ACPI_TABLE_HEADER       *Table;
     INT32                   Count;
-    long                    TableOffset;
-
+    UINT32                  TableLength;
+    UINT32                  HeaderLength;
+    long                    TableOffset = 0;
 
     *ReturnTable = NULL;
 
     /* Get the table header to examine signature and length */
+    /*
+     * Special handling for the CDAT table (both the Length field
+     * and the Checksum field are not in the standard positions).
+     * (The table header is non-standard).
+     */
+    if (AcpiGbl_CDAT)
+    {
+        HeaderLength = sizeof (ACPI_TABLE_CDAT);
+    }
+    else
+    {
+        HeaderLength = sizeof (ACPI_TABLE_HEADER);
+    }
+
+    Status = AcValidateTableHeader (File, TableOffset);
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
 
     TableOffset = ftell (File);
-    Count = fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), File);
-    if (Count != sizeof (ACPI_TABLE_HEADER))
+    Count = fread (&TableHeader, 1, HeaderLength, File);
+    if (Count != (INT32) HeaderLength)
     {
         return (AE_CTRL_TERMINATE);
     }
@@ -405,12 +425,6 @@ AcGetOneTableFromFile (
     {
         /* Validate the table signature/header (limited ASCII chars) */
 
-        Status = AcValidateTableHeader (File, TableOffset);
-        if (ACPI_FAILURE (Status))
-        {
-            return (Status);
-        }
-
         /*
          * Table must be an AML table (DSDT/SSDT).
          * Used for iASL -e option only.
@@ -425,9 +439,22 @@ AcGetOneTableFromFile (
         }
     }
 
+    /*
+     * Special handling for the CDAT table (both the Length field
+     * and the Checksum field are not in the standard positions).
+     */
+    if (AcpiGbl_CDAT)
+    {
+        TableLength = ACPI_CAST_PTR (ACPI_TABLE_CDAT, &TableHeader)->Length;
+    }
+    else
+    {
+        TableLength = TableHeader.Length;
+    }
+
     /* Allocate a buffer for the entire table */
 
-    Table = AcpiOsAllocate ((ACPI_SIZE) TableHeader.Length);
+    Table = AcpiOsAllocate ((ACPI_SIZE) TableLength);
     if (!Table)
     {
         return (AE_NO_MEMORY);
@@ -436,22 +463,31 @@ AcGetOneTableFromFile (
     /* Read the entire ACPI table, including header */
 
     fseek (File, TableOffset, SEEK_SET);
-
-    Count = fread (Table, 1, TableHeader.Length, File);
+    Count = fread (Table, 1, TableLength, File);
 
     /*
      * Checks for data table headers happen later in the execution. Only verify
      * for Aml tables at this point in the code.
      */
-    if (GetOnlyAmlTables && Count != (INT32) TableHeader.Length)
+    if (GetOnlyAmlTables && Count != (INT32) TableLength)
     {
         Status = AE_ERROR;
         goto ErrorExit;
     }
 
-    /* Validate the checksum (just issue a warning) */
+    /*
+     * Validate the checksum (just issue a warning if incorrect).
+     * Note: CDAT is special cased here because the table does
+     * not have the checksum field in the standard position.
+     */
+    if (AcpiGbl_CDAT)
+    {
+        Status = AcpiUtVerifyCdatChecksum ((ACPI_TABLE_CDAT *) Table, TableLength);
+    } else
+    {
+        Status = AcpiUtVerifyChecksum (Table, TableLength);
+    }
 
-    Status = AcpiTbVerifyChecksum (Table, TableHeader.Length);
     if (ACPI_FAILURE (Status))
     {
         Status = AcCheckTextModeCorruption (Table);
@@ -540,6 +576,8 @@ AcValidateTableHeader (
     long                    TableOffset)
 {
     ACPI_TABLE_HEADER       TableHeader;
+    ACPI_TABLE_CDAT         *CdatTableHeader = ACPI_CAST_PTR (ACPI_TABLE_CDAT, &TableHeader);
+    UINT32                  HeaderLength;
     ACPI_SIZE               Actual;
     long                    OriginalOffset;
     UINT32                  FileSize;
@@ -548,6 +586,16 @@ AcValidateTableHeader (
 
     ACPI_FUNCTION_TRACE (AcValidateTableHeader);
 
+    /* Determine the type of table header */
+
+    if (AcpiGbl_CDAT)
+    {
+        HeaderLength = sizeof (ACPI_TABLE_CDAT);
+    }
+    else
+    {
+        HeaderLength = sizeof (ACPI_TABLE_HEADER);
+    }
 
     /* Read a potential table header */
 
@@ -556,41 +604,76 @@ AcValidateTableHeader (
     {
         fprintf (stderr, "SEEK error\n");
     }
-    Actual = fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), File);
+    Actual = fread (&TableHeader, 1, HeaderLength, File);
     if (fseek (File, OriginalOffset, SEEK_SET))
     {
         fprintf (stderr, "SEEK error\n");
     }
 
-    if (Actual < sizeof (ACPI_TABLE_HEADER))
+    if (Actual < HeaderLength)
     {
         fprintf (stderr,
             "Could not read entire table header: Actual %u, Requested %u\n",
-            (UINT32) Actual, (UINT32) sizeof (ACPI_TABLE_HEADER));
+            (UINT32) Actual, HeaderLength);
         return (AE_ERROR);
     }
 
     /* Validate the signature (limited ASCII chars) */
 
-    if (!AcpiUtValidNameseg (TableHeader.Signature))
+    if (!AcpiGbl_CDAT && !AcpiUtValidNameseg (TableHeader.Signature))
     {
+        /*
+         * The "-ds cdat" option was not used, and the signature is not valid.
+         *
+         * For CDAT we are assuming that there should be at least one non-ASCII
+         * byte in the (normally) 4-character Signature field (at least the
+         * high-order byte should be zero). Otherwise, this is OK.
+         */
+        fprintf (stderr,
+            "\nTable appears to be a CDAT table, which has no signature.\n"
+            "If this is in fact a CDAT table, use the -ds option on the\n"
+            "command line to specify the table type (signature):\n"
+            "\"iasl -d -ds CDAT <file>\" or \"iasl -ds CDAT -T CDAT\"\n\n");
+
         return (AE_BAD_SIGNATURE);
     }
 
     /* Validate table length against bytes remaining in the file */
 
     FileSize = CmGetFileSize (File);
-    if (TableHeader.Length > (UINT32) (FileSize - TableOffset))
+    if (!AcpiGbl_CDAT)
+    {
+        /* Standard ACPI table header */
+
+        if (TableHeader.Length > (UINT32) (FileSize - TableOffset))
+        {
+            fprintf (stderr, "Table [%4.4s] is too long for file - "
+                "needs: 0x%.2X, remaining in file: 0x%.2X\n",
+                TableHeader.Signature, TableHeader.Length,
+                (UINT32) (FileSize - TableOffset));
+            return (AE_BAD_HEADER);
+        }
+    }
+    else if (CdatTableHeader->Length > (UINT32) (FileSize - TableOffset))
     {
-        fprintf (stderr, "Table [%4.4s] is too long for file - "
+        /* Special header for CDAT table */
+
+        fprintf (stderr, "Table [CDAT] is too long for file - "
             "needs: 0x%.2X, remaining in file: 0x%.2X\n",
-            TableHeader.Signature, TableHeader.Length,
+            CdatTableHeader->Length,
             (UINT32) (FileSize - TableOffset));
         return (AE_BAD_HEADER);
     }
 
+    /* For CDAT table, there are no ASCII fields in the header, we are done */
+
+    if (AcpiGbl_CDAT)
+    {
+        return (AE_OK);
+    }
+
     /*
-     * These fields must be ASCII: OemId, OemTableId, AslCompilerId.
+     * These standard fields must be ASCII: OemId, OemTableId, AslCompilerId.
      * We allow a NULL terminator in OemId and OemTableId.
      */
     for (i = 0; i < ACPI_NAMESEG_SIZE; i++)
diff --git a/sys/contrib/dev/acpica/common/adisasm.c b/sys/contrib/dev/acpica/common/adisasm.c
index c45b609d4f3f..7aac349458d9 100644
--- a/sys/contrib/dev/acpica/common/adisasm.c
+++ b/sys/contrib/dev/acpica/common/adisasm.c
@@ -476,13 +476,13 @@ AdDisassembleOneTable (
         /* This is a "Data Table" (non-AML table) */
 
         AcpiOsPrintf (" * ACPI Data Table [%4.4s]\n *\n",
-            Table->Signature);
+            AcpiGbl_CDAT ? (char *) AcpiGbl_CDAT : Table->Signature);
         AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength]  "
             "FieldName : FieldValue (in hex)\n */\n\n");
 
         AcpiDmDumpDataTable (Table);
         fprintf (stderr, "Acpi Data Table [%4.4s] decoded\n",
-            Table->Signature);
+            AcpiGbl_CDAT ? (char *) AcpiGbl_CDAT : Table->Signature);
 
         if (File)
         {
diff --git a/sys/contrib/dev/acpica/common/ahtable.c b/sys/contrib/dev/acpica/common/ahtable.c
index 227fee2b5132..b925be84ec6b 100644
--- a/sys/contrib/dev/acpica/common/ahtable.c
+++ b/sys/contrib/dev/acpica/common/ahtable.c
@@ -206,6 +206,8 @@ const AH_TABLE      AcpiGbl_SupportedTables[] =
     {ACPI_SIG_BERT, "Boot Error Record Table"},
     {ACPI_SIG_BGRT, "Boot Graphics Resource Table"},
     {ACPI_SIG_BOOT, "Simple Boot Flag Table"},
+    {ACPI_SIG_CCEL, "CC-Event Log Table"},
+    {ACPI_SIG_CDAT, "Coherent Device Attribute Table"},
     {ACPI_SIG_CEDT, "CXL Early Discovery Table"},
     {ACPI_SIG_CPEP, "Corrected Platform Error Polling Table"},
     {ACPI_SIG_CSRT, "Core System Resource Table"},
diff --git a/sys/contrib/dev/acpica/common/ahuuids.c b/sys/contrib/dev/acpica/common/ahuuids.c
index 7378a8555bb0..5e92903e0ecb 100644
--- a/sys/contrib/dev/acpica/common/ahuuids.c
+++ b/sys/contrib/dev/acpica/common/ahuuids.c
@@ -209,6 +209,9 @@ const AH_UUID  Gbl_AcpiUuids[] =
     {"Hierarchical Data Extension", UUID_HIERARCHICAL_DATA_EXTENSION},
     {"ARM Coresight Graph",         UUID_CORESIGHT_GRAPH},
     {"USB4 Capabilities",           UUID_USB4_CAPABILITIES},
+    {"First Function ID for _DSM",  UUID_1ST_FUNCTION_ID},
+    {"Second Function ID for _DSM", UUID_2ND_FUNCTION_ID},
+
     {NULL, NULL}
 };
 
diff --git a/sys/contrib/dev/acpica/common/dmtable.c b/sys/contrib/dev/acpica/common/dmtable.c
index 78c75ab803f8..c5582530d497 100644
--- a/sys/contrib/dev/acpica/common/dmtable.c
+++ b/sys/contrib/dev/acpica/common/dmtable.c
@@ -234,6 +234,17 @@ static const char           *AcpiDmAsfSubnames[] =
     "Unknown Subtable Type"         /* Reserved */
 };
 
+static const char           *AcpiDmCdatSubnames[] =
+{
+    "Device Scoped Memory Affinity Structure (DSMAS)",
+    "Device scoped Latency and Bandwidth Information Structure (DSLBIS)",
+    "Device Scoped Memory Side Cache Information Structure (DSMSCIS)",
+    "Device Scoped Initiator Structure (DSIS)",
+    "Device Scoped EFI Memory Type Structure (DSEMTS)",
+    "Switch Scoped Latency and Bandwidth Information Structure (SSLBIS)",
+    "Unknown Subtable Type"         /* Reserved */
+};
+
 static const char           *AcpiDmCedtSubnames[] =
 {
     "CXL Host Bridge Structure",
@@ -403,6 +414,13 @@ static const char           *AcpiDmMadtSubnames[] =
     "Generic Interrupt Redistributor",  /* ACPI_MADT_GENERIC_REDISTRIBUTOR */
     "Generic Interrupt Translator",     /* ACPI_MADT_GENERIC_TRANSLATOR */
     "Mutiprocessor Wakeup",             /* ACPI_MADT_TYPE_MULTIPROC_WAKEUP */
+    "CPU Core Interrupt Controller",    /* ACPI_MADT_TYPE_CORE_PIC */
+    "Legacy I/O Interrupt Controller",  /* ACPI_MADT_TYPE_LIO_PIC */
+    "HT Interrupt Controller",          /* ACPI_MADT_TYPE_HT_PIC */
+    "Extend I/O Interrupt Controller",  /* ACPI_MADT_TYPE_EIO_PIC */
+    "MSI Interrupt Controller",         /* ACPI_MADT_TYPE_MSI_PIC */
+    "Bridge I/O Interrupt Controller",  /* ACPI_MADT_TYPE_BIO_PIC */
+    "LPC Interrupt Controller",         /* ACPI_MADT_TYPE_LPC_PIC */
     "Unknown Subtable Type",            /* Reserved */
     "Types 80-FF are used for OEM data" /* Reserved for OEM data */
 };
@@ -658,6 +676,8 @@ const ACPI_DMTABLE_DATA     AcpiDmTableData[] =
     {ACPI_SIG_BERT, AcpiDmTableInfoBert,    NULL,           NULL,           TemplateBert},
     {ACPI_SIG_BGRT, AcpiDmTableInfoBgrt,    NULL,           NULL,           TemplateBgrt},
     {ACPI_SIG_BOOT, AcpiDmTableInfoBoot,    NULL,           NULL,           TemplateBoot},
+    {ACPI_SIG_CCEL, AcpiDmTableInfoCcel,    NULL,           NULL,           TemplateCcel},
+    {ACPI_SIG_CDAT, NULL,                   AcpiDmDumpCdat, NULL,           TemplateCdat},
     {ACPI_SIG_CEDT, NULL,                   AcpiDmDumpCedt, DtCompileCedt,  TemplateCedt},
     {ACPI_SIG_CPEP, NULL,                   AcpiDmDumpCpep, DtCompileCpep,  TemplateCpep},
     {ACPI_SIG_CSRT, NULL,                   AcpiDmDumpCsrt, DtCompileCsrt,  TemplateCsrt},
@@ -722,44 +742,6 @@ const ACPI_DMTABLE_DATA     AcpiDmTableData[] =
 };
 
 
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmGenerateChecksum
- *
- * PARAMETERS:  Table               - Pointer to table to be checksummed
- *              Length              - Length of the table
- *              OriginalChecksum    - Value of the checksum field
- *
- * RETURN:      8 bit checksum of buffer
- *
- * DESCRIPTION: Computes an 8 bit checksum of the table.
- *
- ******************************************************************************/
-
-UINT8
-AcpiDmGenerateChecksum (
-    void                    *Table,
-    UINT32                  Length,
-    UINT8                   OriginalChecksum)
-{
-    UINT8                   Checksum;
-
-
-    /* Sum the entire table as-is */
-
-    Checksum = AcpiTbChecksum ((UINT8 *) Table, Length);
-
-    /* Subtract off the existing checksum value in the table */
-
-    Checksum = (UINT8) (Checksum - OriginalChecksum);
-
-    /* Compute the final checksum */
-
-    Checksum = (UINT8) (0 - Checksum);
-    return (Checksum);
-}
-
-
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDmGetTableData
@@ -834,7 +816,7 @@ AcpiDmDumpDataTable (
 
     /*
      * Handle tables that don't use the common ACPI table header structure.
-     * Currently, these are the FACS, RSDP, and S3PT.
+     * Currently, these are the FACS, RSDP, S3PT and CDAT.
      */
     if (ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_FACS))
     {
@@ -854,6 +836,28 @@ AcpiDmDumpDataTable (
     {
         Length = AcpiDmDumpS3pt (Table);
     }
+    else if (!AcpiUtValidNameseg (Table->Signature))
+    {
+        /*
+         * For CDAT we are assuming that there should be at least one non-ASCII
+         * byte in the (normally) 4-character Signature field (at least the
+         * high-order byte should be zero).
+         */
+        if (AcpiGbl_CDAT)
+        {
+            /*
+             * Invalid signature and <-ds CDAT> was specified on the command line.
+             * Therefore, we have a CDAT table.
+             */
+            AcpiDmDumpCdat (Table);
+        }
+        else
+        {
+            fprintf (stderr, "Table has an invalid signature\n");
+        }
+
+        return;
+    }
     else
     {
         /*
@@ -977,7 +981,7 @@ AcpiDmLineHeader (
     {
         if (ByteLength)
         {
-            AcpiOsPrintf ("[%3.3Xh %4.4d% 4d] %28s : ",
+            AcpiOsPrintf ("[%3.3Xh %4.4u %3.3Xh] %27s : ",
                 Offset, Offset, ByteLength, Name);
         }
         else
@@ -1019,12 +1023,12 @@ AcpiDmLineHeader2 (
     {
         if (ByteLength)
         {
-            AcpiOsPrintf ("[%3.3Xh %4.4d %3d] %24s %3d : ",
+            AcpiOsPrintf ("[%3.3Xh %4.4u %3.3Xh] %24s %3d : ",
                 Offset, Offset, ByteLength, Name, Value);
         }
         else
         {
-            AcpiOsPrintf ("[%3.3Xh %4.4d   ] %24s %3d : ",
+            AcpiOsPrintf ("[%3.3Xh %4.4u   ] %24s %3d : ",
                 Offset, Offset, Name, Value);
         }
     }
@@ -1106,7 +1110,8 @@ AcpiDmDumpTable (
         {
             AcpiOsPrintf (
                 "/**** ACPI table terminates "
-                "in the middle of a data structure! (dump table) */\n");
+                "in the middle of a data structure! (dump table) \n"
+                "CurrentOffset: %X, TableLength: %X ***/", CurrentOffset, TableLength);
             return (AE_BAD_DATA);
         }
 
@@ -1140,6 +1145,7 @@ AcpiDmDumpTable (
         case ACPI_DMT_AEST_XFACE:
         case ACPI_DMT_AEST_XRUPT:
         case ACPI_DMT_ASF:
+        case ACPI_DMT_CDAT:
         case ACPI_DMT_HESTNTYP:
         case ACPI_DMT_FADTPM:
         case ACPI_DMT_EINJACT:
@@ -1522,7 +1528,7 @@ AcpiDmDumpTable (
             /* Checksum, display and validate */
 
             AcpiOsPrintf ("%2.2X", *Target);
-            Temp8 = AcpiDmGenerateChecksum (Table,
+            Temp8 = AcpiUtGenerateChecksum (Table,
                 ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length,
                 ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum);
 
@@ -1668,6 +1674,20 @@ AcpiDmDumpTable (
             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmAsfSubnames[Temp16]);
             break;
 
+        case ACPI_DMT_CDAT:
+
+            /* CDAT subtable types */
+
+            Temp8 = *Target;
+            if (Temp8 > ACPI_CDAT_TYPE_RESERVED)
+            {
+                Temp8 = ACPI_CDAT_TYPE_RESERVED;
+            }
+
+            AcpiOsPrintf (UINT8_FORMAT, *Target,
+                AcpiDmCdatSubnames[Temp8]);
+            break;
+
         case ACPI_DMT_CEDT:
 
             /* CEDT subtable types */
@@ -2017,15 +2037,15 @@ AcpiDmDumpTable (
 
         case ACPI_DMT_PHAT:
 
-            /* PMTT subtable types */
+            /* PHAT subtable types */
 
-            Temp16 = *Target;
+            Temp16 = ACPI_GET16 (Target);
             if (Temp16 > ACPI_PHAT_TYPE_RESERVED)
             {
                 Temp16 = ACPI_PHAT_TYPE_RESERVED;
             }
 
-            AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16(Target),
+            AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
                 AcpiDmPhatSubnames[Temp16]);
             break;
 
@@ -2069,7 +2089,7 @@ AcpiDmDumpTable (
                 break;
             }
 
-            AcpiDmDumpUnicode (Table, CurrentOffset, ByteLength);
+            AcpiDmDumpUnicode (Table, 0, ByteLength);
             break;
 
         case ACPI_DMT_RAW_BUFFER:
diff --git a/sys/contrib/dev/acpica/common/dmtables.c b/sys/contrib/dev/acpica/common/dmtables.c
index 13ecdf40909e..72af05952701 100644
--- a/sys/contrib/dev/acpica/common/dmtables.c
+++ b/sys/contrib/dev/acpica/common/dmtables.c
@@ -296,7 +296,7 @@ AdCreateTableHeader (
 
     AcpiOsPrintf ("\n *     Checksum         0x%2.2X",        Table->Checksum);
 
-    Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Table->Length);
+    Checksum = AcpiUtChecksum (ACPI_CAST_PTR (UINT8, Table), Table->Length);
     if (Checksum)
     {
         AcpiOsPrintf (" **** Incorrect checksum, should be 0x%2.2X",
diff --git a/sys/contrib/dev/acpica/common/dmtbdump.c b/sys/contrib/dev/acpica/common/dmtbdump.c
index b87c276cc625..e4bb62eaab6e 100644
--- a/sys/contrib/dev/acpica/common/dmtbdump.c
+++ b/sys/contrib/dev/acpica/common/dmtbdump.c
@@ -384,7 +384,7 @@ AcpiDmDumpRsdp (
 
     /* Validate the first checksum */
 
-    Checksum = AcpiDmGenerateChecksum (Rsdp, sizeof (ACPI_RSDP_COMMON),
+    Checksum = AcpiUtGenerateChecksum (Rsdp, sizeof (ACPI_RSDP_COMMON),
         Rsdp->Checksum);
     if (Checksum != Rsdp->Checksum)
     {
@@ -405,7 +405,7 @@ AcpiDmDumpRsdp (
 
         /* Validate the extended checksum over entire RSDP */
 
-        Checksum = AcpiDmGenerateChecksum (Rsdp, sizeof (ACPI_TABLE_RSDP),
+        Checksum = AcpiUtGenerateChecksum (Rsdp, sizeof (ACPI_TABLE_RSDP),
             Rsdp->ExtendedChecksum);
         if (Checksum != Rsdp->ExtendedChecksum)
         {
diff --git a/sys/contrib/dev/acpica/common/dmtbdump1.c b/sys/contrib/dev/acpica/common/dmtbdump1.c
index c21d641d25a0..1c40e5f6def8 100644
--- a/sys/contrib/dev/acpica/common/dmtbdump1.c
+++ b/sys/contrib/dev/acpica/common/dmtbdump1.c
@@ -153,6 +153,7 @@
 #include <contrib/dev/acpica/include/accommon.h>
 #include <contrib/dev/acpica/include/acdisasm.h>
 #include <contrib/dev/acpica/include/actables.h>
+#include <contrib/dev/acpica/compiler/aslcompiler.h>
 
 /* This module used for application-level code only */
 
@@ -608,6 +609,192 @@ AcpiDmDumpAsf (
     }
 }
 
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmDumpCdat
+ *
+ * PARAMETERS:  InTable             - A CDAT table
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Format the contents of a CDAT. This table type consists
+ *              of an open-ended number of subtables.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDumpCdat (
+    ACPI_TABLE_HEADER       *InTable)
+{
+    ACPI_TABLE_CDAT         *Table = ACPI_CAST_PTR (ACPI_TABLE_CDAT, InTable);
+    ACPI_STATUS             Status;
+    ACPI_CDAT_HEADER        *Subtable;
+    ACPI_TABLE_CDAT         *CdatTable = ACPI_CAST_PTR (ACPI_TABLE_CDAT, Table);
+    ACPI_DMTABLE_INFO       *InfoTable;
+    UINT32                  Length = CdatTable->Length;
+    UINT32                  Offset = sizeof (ACPI_TABLE_CDAT);
+    UINT32                  SubtableLength;
+    UINT32                  SubtableType;
+    INT32                   EntriesLength;
+
+
+    /* Main table */
+
+    Status = AcpiDmDumpTable (Offset, 0, CdatTable, 0,
+        AcpiDmTableInfoCdatTableHdr);
+    if (ACPI_FAILURE (Status))
+    {
+        return;
+    }
+
+    Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, sizeof (ACPI_TABLE_CDAT));
+    while (Offset < Table->Length)
+    {
+        /* Dump the common subtable header */
+
+        DbgPrint (ASL_DEBUG_OUTPUT, "0) HeaderOffset: %X\n", Offset);
+        AcpiOsPrintf ("\n");
+        Status = AcpiDmDumpTable (Length, Offset, Subtable,
+            sizeof (ACPI_CDAT_HEADER), AcpiDmTableInfoCdatHeader);
+        if (ACPI_FAILURE (Status))
+        {
+            return;
+        }
+
+        /* Point past the common subtable header, decode the subtable type */
+
+        Offset += sizeof (ACPI_CDAT_HEADER);
+        SubtableType = Subtable->Type;
+
+        switch (Subtable->Type)
+        {
+        case ACPI_CDAT_TYPE_DSMAS:
+            Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
+            SubtableLength = sizeof (ACPI_CDAT_DSMAS);
+
+            InfoTable = AcpiDmTableInfoCdat0;
+            break;
+
+        case ACPI_CDAT_TYPE_DSLBIS:
+            Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
+            SubtableLength = sizeof (ACPI_CDAT_DSLBIS);
+            DbgPrint (ASL_DEBUG_OUTPUT, "1) Offset: %X\n", Offset);
+
+            InfoTable = AcpiDmTableInfoCdat1;
+            break;
+
+        case ACPI_CDAT_TYPE_DSMSCIS:
+            Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
+            SubtableLength = sizeof (ACPI_CDAT_DSMSCIS);
+
+            InfoTable = AcpiDmTableInfoCdat2;
+            break;
+
+        case ACPI_CDAT_TYPE_DSIS:
+            DbgPrint (ASL_DEBUG_OUTPUT, "2) Offset: %X ", Offset);
+            SubtableLength = sizeof (ACPI_CDAT_DSIS);
+            DbgPrint (ASL_DEBUG_OUTPUT, "1) input pointer: %p\n", Table);
+            Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
+            DbgPrint (ASL_DEBUG_OUTPUT, "1) output pointers: %p, %p, Offset: %X\n",
+                Table, Subtable, Offset);
+            DbgPrint (ASL_DEBUG_OUTPUT, "3) Offset: %X\n", Offset);
+
+            InfoTable = AcpiDmTableInfoCdat3;
+            break;
+
+        case ACPI_CDAT_TYPE_DSEMTS:
+            Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
+            SubtableLength = sizeof (ACPI_CDAT_DSEMTS);
+
+            InfoTable = AcpiDmTableInfoCdat4;
+            break;
+
+        case ACPI_CDAT_TYPE_SSLBIS:
+            SubtableLength = Subtable->Length;
+
+            InfoTable = AcpiDmTableInfoCdat5;
+            Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
+            break;
+
+        default:
+            fprintf (stderr, "ERROR: Unknown SubtableType: %X\n", Subtable->Type);
+            return;
+        }
+
+        DbgPrint (ASL_DEBUG_OUTPUT, "SubtableType: %X, Length: %X Actual "
+            "Length: %X Offset: %X tableptr: %p\n", SubtableType,
+            Subtable->Length, SubtableLength, Offset, Table);
+
+        /*
+         * Do the subtable-specific fields
+         */
+        Status = AcpiDmDumpTable (Length, Offset, Subtable, Offset, InfoTable);
+        if (ACPI_FAILURE (Status))
+        {
+            return;
+        }
+
+        DbgPrint (ASL_DEBUG_OUTPUT, "Subtable Type: %X, Offset: %X, SubtableLength: %X\n",
+            SubtableType, Offset, SubtableLength);
+
+        /* Additional sub-subtables, dependent on the main subtable type */
+
+        switch (SubtableType)
+        {
+        case ACPI_CDAT_TYPE_SSLBIS:
+            Offset += sizeof (ACPI_CDAT_SSLBIS);
+            Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table,
+                Offset);
+
+            DbgPrint (ASL_DEBUG_OUTPUT, "Case SSLBIS, Offset: %X, SubtableLength: %X "
+                "Subtable->Length %X\n", Offset, SubtableLength, Subtable->Length);
+
+            /* Generate the total length of all the SSLBE entries */
+
+            EntriesLength = SubtableLength - sizeof (ACPI_CDAT_HEADER) -
+                sizeof (ACPI_CDAT_SSLBIS);
+            DbgPrint (ASL_DEBUG_OUTPUT, "EntriesLength: %X, Offset: %X, Table->Length: %X\n",
+                EntriesLength, Offset, Table->Length);
+
+            /* Do each of the SSLBE Entries */
+
+            while ((EntriesLength > 0) && (Offset < Table->Length))
+            {
+                AcpiOsPrintf ("\n");
+
+                Status = AcpiDmDumpTable (Length, Offset, Subtable, Offset,
+                    AcpiDmTableInfoCdatEntries);
+                if (ACPI_FAILURE (Status))
+                {
+                    return;
+                }
+
+                EntriesLength -= sizeof (ACPI_CDAT_SSLBE);
+                Offset += sizeof (ACPI_CDAT_SSLBE);
+                Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
+            }
+
+            SubtableLength = 0;
+            break;
+
+        default:
+            break;
+        }
+
+        DbgPrint (ASL_DEBUG_OUTPUT, "Offset: %X, Subtable Length: %X\n",
+            Offset, SubtableLength);
+
+        /* Point to next subtable */
+
+        Offset += SubtableLength;
+        Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
+    }
+
+    return;
+}
+
+
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDmDumpCedt
@@ -651,12 +838,14 @@ AcpiDmDumpCedt (
         case ACPI_CEDT_TYPE_CHBS:
             Status = AcpiDmDumpTable (Length, Offset, Subtable,
                 Subtable->Length, AcpiDmTableInfoCedt0);
-            if (ACPI_FAILURE (Status)) {
+            if (ACPI_FAILURE (Status))
+            {
                 return;
             }
             break;
 
-        case ACPI_CEDT_TYPE_CFMWS: {
+        case ACPI_CEDT_TYPE_CFMWS:
+        {
             ACPI_CEDT_CFMWS *ptr = (ACPI_CEDT_CFMWS *) Subtable;
             unsigned int i, max = 0x01 << (ptr->InterleaveWays);
 
@@ -664,18 +853,22 @@ AcpiDmDumpCedt (
 
             Status = AcpiDmDumpTable (Length, Offset, Subtable,
                 Subtable->Length, AcpiDmTableInfoCedt1);
-            if (ACPI_FAILURE (Status)) {
+            if (ACPI_FAILURE (Status))
+            {
                 return;
             }
 
             /* Now, print out any interleave targets beyond the first. */
 
-            for (i = 1; i < max; i++) {
-                unsigned int loc_offset = Offset + (i * 4) + ACPI_OFFSET(ACPI_CEDT_CFMWS, InterleaveTargets);
+            for (i = 1; i < max; i++)
+            {
+                unsigned int loc_offset = Offset + (i * 4) + ACPI_OFFSET (ACPI_CEDT_CFMWS, InterleaveTargets);
                 unsigned int *trg = &(ptr->InterleaveTargets[i]);
+
                 Status = AcpiDmDumpTable (Length, loc_offset, trg,
                         Subtable->Length, AcpiDmTableInfoCedt1_te);
-                if (ACPI_FAILURE (Status)) {
+                if (ACPI_FAILURE (Status))
+                {
                     return;
                 }
             }
diff --git a/sys/contrib/dev/acpica/common/dmtbdump2.c b/sys/contrib/dev/acpica/common/dmtbdump2.c
index 8371b8748977..aff5453efdda 100644
--- a/sys/contrib/dev/acpica/common/dmtbdump2.c
+++ b/sys/contrib/dev/acpica/common/dmtbdump2.c
@@ -149,6 +149,7 @@
  *
  *****************************************************************************/
 
+#include <wchar.h>
 #include <contrib/dev/acpica/include/acpi.h>
 #include <contrib/dev/acpica/include/accommon.h>
 #include <contrib/dev/acpica/include/acdisasm.h>
@@ -2104,9 +2105,12 @@ AcpiDmDumpPhat (
     UINT32                  RecordCount;
     UINT32                  Length = Table->Length;
     UINT32                  Offset = sizeof (ACPI_TABLE_PHAT);
+    UINT32                  OriginalOffset;
     UINT32                  SubtableLength;
     UINT32                  PathLength;
     UINT32                  VendorLength;
+    UINT16                  RecordType;
+    const wchar_t           *WideString;
 
 
     Subtable = ACPI_ADD_PTR (ACPI_PHAT_HEADER, Table, sizeof (ACPI_TABLE_PHAT));
@@ -2116,58 +2120,93 @@ AcpiDmDumpPhat (
         /* Common subtable header */
 
         AcpiOsPrintf ("\n");
-        Status = AcpiDmDumpTable (Length, 0, Subtable,
+        Status = AcpiDmDumpTable (Length, Offset, Subtable,
             sizeof (ACPI_PHAT_HEADER), AcpiDmTableInfoPhatHdr);
         if (ACPI_FAILURE (Status))
         {
             return;
         }
 
+        DbgPrint (ASL_DEBUG_OUTPUT, "\n/* %u, Subtable->Type %X */\n",
+            __LINE__, Subtable->Type);
+
         switch (Subtable->Type)
         {
         case ACPI_PHAT_TYPE_FW_VERSION_DATA:
 
             InfoTable = AcpiDmTableInfoPhat0;
-            SubtableLength = sizeof (ACPI_PHAT_VERSION_DATA);
+            SubtableLength = Offset += sizeof (ACPI_PHAT_VERSION_DATA);
             break;
 
         case ACPI_PHAT_TYPE_FW_HEALTH_DATA:
 
             InfoTable = AcpiDmTableInfoPhat1;
-            SubtableLength = sizeof (ACPI_PHAT_HEALTH_DATA);
+            SubtableLength = Offset += sizeof (ACPI_PHAT_TYPE_FW_HEALTH_DATA);
             break;
 
         default:
 
-            AcpiOsPrintf ("\n**** Unknown PHAT subtable type 0x%X\n\n",
+            DbgPrint (ASL_DEBUG_OUTPUT, "\n**** Unknown PHAT subtable type 0x%X\n\n",
                 Subtable->Type);
 
             return;
         }
 
-        Status = AcpiDmDumpTable (Length, 0, Subtable,
+        Status = AcpiDmDumpTable (Length, SubtableLength, Subtable,
             SubtableLength, InfoTable);
         if (ACPI_FAILURE (Status))
         {
             return;
         }
 
+        OriginalOffset = Offset;
         switch (Subtable->Type)
         {
         case ACPI_PHAT_TYPE_FW_VERSION_DATA:
 
             VersionData = ACPI_CAST_PTR (ACPI_PHAT_VERSION_DATA, Subtable);
             RecordCount = VersionData->ElementCount;
-            while (RecordCount)
+            RecordType = *ACPI_CAST_PTR (UINT8, Subtable);
+
+            /*
+             * Skip past a zero-valued block (not part of the ACPI PHAT specification).
+             * First, check for a zero length record and a zero element count
+             */
+            if (!VersionData->Header.Length && !VersionData->ElementCount)
             {
-                Status = AcpiDmDumpTable (Length, Offset,
-                    ACPI_ADD_PTR (ACPI_PHAT_HEADER, Subtable, sizeof (ACPI_PHAT_VERSION_DATA)),
+                while (RecordType == 0)
+                {
+                    Subtable = ACPI_ADD_PTR (ACPI_PHAT_HEADER, Table, Offset);
+                    RecordType = *ACPI_CAST_PTR (UINT8, Subtable);
+                    RecordCount = VersionData->ElementCount;
+                    Offset += 1;
+                }
+
+                Offset -= 1;
+                AcpiOsPrintf ("\n/* Warning: Block of zeros found above starting at Offset %X Length %X */\n"
+                    "/* (not compliant to PHAT specification -- ignoring block) */\n",
+                    OriginalOffset - 12, Offset - OriginalOffset + 12);
+            }
+
+            DbgPrint (ASL_DEBUG_OUTPUT, "/* %u, RecordCount: %X, Offset %X, SubtableLength %X */\n",
+                __LINE__, RecordCount, Offset, SubtableLength);
+
+            /* Emit each of the version elements */
+
+            while (RecordCount && VersionData->Header.Length)
+            {
+                AcpiOsPrintf ("\n/* Version Element #%Xh Offset %Xh */\n\n",
+                    VersionData->ElementCount - RecordCount + 1, Offset);
+
+                Subtable = ACPI_ADD_PTR (ACPI_PHAT_HEADER, Table, Offset);
+                Status = AcpiDmDumpTable (Length, Offset, Subtable,
                     sizeof (ACPI_PHAT_VERSION_ELEMENT), AcpiDmTableInfoPhat0a);
                 if (ACPI_FAILURE (Status))
                 {
                     return;
                 }
 
+                Offset += sizeof (ACPI_PHAT_VERSION_ELEMENT);
                 RecordCount--;
             }
 
@@ -2175,24 +2214,48 @@ AcpiDmDumpPhat (
 
         case ACPI_PHAT_TYPE_FW_HEALTH_DATA:
*** 2851 LINES SKIPPED ***