Home | History | Annotate | Line # | Download | only in common
dmtable.c revision 1.1.1.16
      1 /******************************************************************************
      2  *
      3  * Module Name: dmtable - Support for ACPI tables that contain no AML code
      4  *
      5  *****************************************************************************/
      6 
      7 /*
      8  * Copyright (C) 2000 - 2019, Intel Corp.
      9  * All rights reserved.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions, and the following disclaimer,
     16  *    without modification.
     17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  *    including a substantially similar Disclaimer requirement for further
     21  *    binary redistribution.
     22  * 3. Neither the names of the above-listed copyright holders nor the names
     23  *    of any contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * Alternatively, this software may be distributed under the terms of the
     27  * GNU General Public License ("GPL") version 2 as published by the Free
     28  * Software Foundation.
     29  *
     30  * NO WARRANTY
     31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  * POSSIBILITY OF SUCH DAMAGES.
     42  */
     43 
     44 #include "acpi.h"
     45 #include "accommon.h"
     46 #include "acdisasm.h"
     47 #include "actables.h"
     48 #include "aslcompiler.h"
     49 
     50 /* This module used for application-level code only */
     51 
     52 #define _COMPONENT          ACPI_CA_DISASSEMBLER
     53         ACPI_MODULE_NAME    ("dmtable")
     54 
     55 const AH_TABLE *
     56 AcpiAhGetTableInfo (
     57     char                    *Signature);
     58 
     59 
     60 /* Common format strings for commented values */
     61 
     62 #define UINT8_FORMAT        "%2.2X [%s]\n"
     63 #define UINT16_FORMAT       "%4.4X [%s]\n"
     64 #define UINT32_FORMAT       "%8.8X [%s]\n"
     65 #define STRING_FORMAT       "[%s]\n"
     66 
     67 /* These tables map a subtable type to a description string */
     68 
     69 static const char           *AcpiDmAsfSubnames[] =
     70 {
     71     "ASF Information",
     72     "ASF Alerts",
     73     "ASF Remote Control",
     74     "ASF RMCP Boot Options",
     75     "ASF Address",
     76     "Unknown Subtable Type"         /* Reserved */
     77 };
     78 
     79 static const char           *AcpiDmDmarSubnames[] =
     80 {
     81     "Hardware Unit Definition",
     82     "Reserved Memory Region",
     83     "Root Port ATS Capability",
     84     "Remapping Hardware Static Affinity",
     85     "ACPI Namespace Device Declaration",
     86     "Unknown Subtable Type"         /* Reserved */
     87 };
     88 
     89 static const char           *AcpiDmDmarScope[] =
     90 {
     91     "Reserved value",
     92     "PCI Endpoint Device",
     93     "PCI Bridge Device",
     94     "IOAPIC Device",
     95     "Message-capable HPET Device",
     96     "Namespace Device",
     97     "Unknown Scope Type"            /* Reserved */
     98 };
     99 
    100 static const char           *AcpiDmEinjActions[] =
    101 {
    102     "Begin Operation",
    103     "Get Trigger Table",
    104     "Set Error Type",
    105     "Get Error Type",
    106     "End Operation",
    107     "Execute Operation",
    108     "Check Busy Status",
    109     "Get Command Status",
    110     "Set Error Type With Address",
    111     "Get Execute Timings",
    112     "Unknown Action"
    113 };
    114 
    115 static const char           *AcpiDmEinjInstructions[] =
    116 {
    117     "Read Register",
    118     "Read Register Value",
    119     "Write Register",
    120     "Write Register Value",
    121     "Noop",
    122     "Flush Cacheline",
    123     "Unknown Instruction"
    124 };
    125 
    126 static const char           *AcpiDmErstActions[] =
    127 {
    128     "Begin Write Operation",
    129     "Begin Read Operation",
    130     "Begin Clear Operation",
    131     "End Operation",
    132     "Set Record Offset",
    133     "Execute Operation",
    134     "Check Busy Status",
    135     "Get Command Status",
    136     "Get Record Identifier",
    137     "Set Record Identifier",
    138     "Get Record Count",
    139     "Begin Dummy Write",
    140     "Unused/Unknown Action",
    141     "Get Error Address Range",
    142     "Get Error Address Length",
    143     "Get Error Attributes",
    144     "Execute Timings",
    145     "Unknown Action"
    146 };
    147 
    148 static const char           *AcpiDmErstInstructions[] =
    149 {
    150     "Read Register",
    151     "Read Register Value",
    152     "Write Register",
    153     "Write Register Value",
    154     "Noop",
    155     "Load Var1",
    156     "Load Var2",
    157     "Store Var1",
    158     "Add",
    159     "Subtract",
    160     "Add Value",
    161     "Subtract Value",
    162     "Stall",
    163     "Stall While True",
    164     "Skip Next If True",
    165     "GoTo",
    166     "Set Source Address",
    167     "Set Destination Address",
    168     "Move Data",
    169     "Unknown Instruction"
    170 };
    171 
    172 static const char           *AcpiDmGtdtSubnames[] =
    173 {
    174     "Generic Timer Block",
    175     "Generic Watchdog Timer",
    176     "Unknown Subtable Type"         /* Reserved */
    177 };
    178 
    179 static const char           *AcpiDmHestSubnames[] =
    180 {
    181     "IA-32 Machine Check Exception",
    182     "IA-32 Corrected Machine Check",
    183     "IA-32 Non-Maskable Interrupt",
    184     "Unknown Subtable Type",        /* 3 - Reserved */
    185     "Unknown Subtable Type",        /* 4 - Reserved */
    186     "Unknown Subtable Type",        /* 5 - Reserved */
    187     "PCI Express Root Port AER",
    188     "PCI Express AER (AER Endpoint)",
    189     "PCI Express/PCI-X Bridge AER",
    190     "Generic Hardware Error Source",
    191     "Generic Hardware Error Source V2",
    192     "IA-32 Deferred Machine Check",
    193     "Unknown Subtable Type"         /* Reserved */
    194 };
    195 
    196 static const char           *AcpiDmHestNotifySubnames[] =
    197 {
    198     "Polled",
    199     "External Interrupt",
    200     "Local Interrupt",
    201     "SCI",
    202     "NMI",
    203     "CMCI",                         /* ACPI 5.0 */
    204     "MCE",                          /* ACPI 5.0 */
    205     "GPIO",                         /* ACPI 6.0 */
    206     "SEA",                          /* ACPI 6.1 */
    207     "SEI",                          /* ACPI 6.1 */
    208     "GSIV",                         /* ACPI 6.1 */
    209     "Software Delegated Exception", /* ACPI 6.2 */
    210     "Unknown Notify Type"           /* Reserved */
    211 };
    212 
    213 static const char           *AcpiDmHmatSubnames[] =
    214 {
    215     "Memory Proximity Domain Attributes",
    216     "System Locality Latency and Bandwidth Information",
    217     "Memory Side Cache Information",
    218     "Unknown Structure Type"         /* Reserved */
    219 };
    220 
    221 static const char           *AcpiDmMadtSubnames[] =
    222 {
    223     "Processor Local APIC",             /* ACPI_MADT_TYPE_LOCAL_APIC */
    224     "I/O APIC",                         /* ACPI_MADT_TYPE_IO_APIC */
    225     "Interrupt Source Override",        /* ACPI_MADT_TYPE_INTERRUPT_OVERRIDE */
    226     "NMI Source",                       /* ACPI_MADT_TYPE_NMI_SOURCE */
    227     "Local APIC NMI",                   /* ACPI_MADT_TYPE_LOCAL_APIC_NMI */
    228     "Local APIC Address Override",      /* ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE */
    229     "I/O SAPIC",                        /* ACPI_MADT_TYPE_IO_SAPIC */
    230     "Local SAPIC",                      /* ACPI_MADT_TYPE_LOCAL_SAPIC */
    231     "Platform Interrupt Sources",       /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */
    232     "Processor Local x2APIC",           /* ACPI_MADT_TYPE_LOCAL_X2APIC */
    233     "Local x2APIC NMI",                 /* ACPI_MADT_TYPE_LOCAL_X2APIC_NMI */
    234     "Generic Interrupt Controller",     /* ACPI_MADT_GENERIC_INTERRUPT */
    235     "Generic Interrupt Distributor",    /* ACPI_MADT_GENERIC_DISTRIBUTOR */
    236     "Generic MSI Frame",                /* ACPI_MADT_GENERIC_MSI_FRAME */
    237     "Generic Interrupt Redistributor",  /* ACPI_MADT_GENERIC_REDISTRIBUTOR */
    238     "Generic Interrupt Translator",     /* ACPI_MADT_GENERIC_TRANSLATOR */
    239     "Unknown Subtable Type"             /* Reserved */
    240 };
    241 
    242 static const char           *AcpiDmNfitSubnames[] =
    243 {
    244     "System Physical Address Range",    /* ACPI_NFIT_TYPE_SYSTEM_ADDRESS */
    245     "Memory Range Map",                 /* ACPI_NFIT_TYPE_MEMORY_MAP */
    246     "Interleave Info",                  /* ACPI_NFIT_TYPE_INTERLEAVE */
    247     "SMBIOS Information",               /* ACPI_NFIT_TYPE_SMBIOS */
    248     "NVDIMM Control Region",            /* ACPI_NFIT_TYPE_CONTROL_REGION */
    249     "NVDIMM Block Data Window Region",  /* ACPI_NFIT_TYPE_DATA_REGION */
    250     "Flush Hint Address",               /* ACPI_NFIT_TYPE_FLUSH_ADDRESS */
    251     "Platform Capabilities",            /* ACPI_NFIT_TYPE_CAPABILITIES */
    252     "Unknown Subtable Type"             /* Reserved */
    253 };
    254 
    255 static const char           *AcpiDmPcctSubnames[] =
    256 {
    257     "Generic Communications Subspace",  /* ACPI_PCCT_TYPE_GENERIC_SUBSPACE */
    258     "HW-Reduced Comm Subspace",         /* ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE */
    259     "HW-Reduced Comm Subspace Type2",   /* ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2 */
    260     "Extended PCC Master Subspace",     /* ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE */
    261     "Extended PCC Slave Subspace",      /* ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE */
    262     "Unknown Subtable Type"             /* Reserved */
    263 };
    264 
    265 static const char           *AcpiDmPmttSubnames[] =
    266 {
    267     "Socket",                       /* ACPI_PMTT_TYPE_SOCKET */
    268     "Memory Controller",            /* ACPI_PMTT_TYPE_CONTROLLER */
    269     "Physical Component (DIMM)",    /* ACPI_PMTT_TYPE_DIMM */
    270     "Unknown Subtable Type"         /* Reserved */
    271 };
    272 
    273 static const char           *AcpiDmPpttSubnames[] =
    274 {
    275     "Processor Hierarchy Node",     /* ACPI_PPTT_TYPE_PROCESSOR */
    276     "Cache Type",                   /* ACPI_PPTT_TYPE_CACHE */
    277     "ID",                           /* ACPI_PPTT_TYPE_ID */
    278     "Unknown Subtable Type"         /* Reserved */
    279 };
    280 
    281 static const char           *AcpiDmSdevSubnames[] =
    282 {
    283     "Namespace Device",             /* ACPI_SDEV_TYPE_NAMESPACE_DEVICE */
    284     "PCIe Endpoint Device",         /* ACPI_SDEV_TYPE_PCIE_ENDPOINT_DEVICE */
    285     "Unknown Subtable Type"         /* Reserved */
    286 };
    287 
    288 static const char           *AcpiDmSratSubnames[] =
    289 {
    290     "Processor Local APIC/SAPIC Affinity",
    291     "Memory Affinity",
    292     "Processor Local x2APIC Affinity",
    293     "GICC Affinity",
    294     "GIC ITS Affinity",             /* Acpi 6.2 */
    295     "Generic Initiator Affinity",   /* Acpi 6.3 */
    296     "Unknown Subtable Type"         /* Reserved */
    297 };
    298 
    299 static const char           *AcpiDmTpm2Subnames[] =
    300 {
    301     "Illegal Start Method value",
    302     "Reserved",
    303     "ACPI Start Method",
    304     "Reserved",
    305     "Reserved",
    306     "Reserved",
    307     "Memory Mapped I/O",
    308     "Command Response Buffer",
    309     "Command Response Buffer with ACPI Start Method",
    310     "Reserved",
    311     "Reserved",
    312     "Command Response Buffer with ARM SMC",
    313     "Unknown Subtable Type"         /* Reserved */
    314 };
    315 
    316 static const char           *AcpiDmIvrsSubnames[] =
    317 {
    318     "Hardware Definition Block",
    319     "Memory Definition Block",
    320     "Unknown Subtable Type"         /* Reserved */
    321 };
    322 
    323 static const char           *AcpiDmLpitSubnames[] =
    324 {
    325     "Native C-state Idle Structure",
    326     "Unknown Subtable Type"         /* Reserved */
    327 };
    328 
    329 #define ACPI_FADT_PM_RESERVED       9
    330 
    331 static const char           *AcpiDmFadtProfiles[] =
    332 {
    333     "Unspecified",
    334     "Desktop",
    335     "Mobile",
    336     "Workstation",
    337     "Enterprise Server",
    338     "SOHO Server",
    339     "Appliance PC",
    340     "Performance Server",
    341     "Tablet",
    342     "Unknown Profile Type"
    343 };
    344 
    345 #define ACPI_GAS_WIDTH_RESERVED     5
    346 
    347 static const char           *AcpiDmGasAccessWidth[] =
    348 {
    349     "Undefined/Legacy",
    350     "Byte Access:8",
    351     "Word Access:16",
    352     "DWord Access:32",
    353     "QWord Access:64",
    354     "Unknown Width Encoding"
    355 };
    356 
    357 
    358 /*******************************************************************************
    359  *
    360  * ACPI Table Data, indexed by signature.
    361  *
    362  * Each entry contains: Signature, Table Info, Handler, DtHandler,
    363  *  Template, Description
    364  *
    365  * Simple tables have only a TableInfo structure, complex tables have a
    366  * handler. This table must be NULL terminated. RSDP and FACS are
    367  * special-cased elsewhere.
    368  *
    369  * Note: Any tables added here should be duplicated within AcpiSupportedTables
    370  * in the file common/ahtable.c
    371  *
    372  ******************************************************************************/
    373 
    374 const ACPI_DMTABLE_DATA     AcpiDmTableData[] =
    375 {
    376     {ACPI_SIG_ASF,  NULL,                   AcpiDmDumpAsf,  DtCompileAsf,   TemplateAsf},
    377     {ACPI_SIG_BERT, AcpiDmTableInfoBert,    NULL,           NULL,           TemplateBert},
    378     {ACPI_SIG_BGRT, AcpiDmTableInfoBgrt,    NULL,           NULL,           TemplateBgrt},
    379     {ACPI_SIG_BOOT, AcpiDmTableInfoBoot,    NULL,           NULL,           TemplateBoot},
    380     {ACPI_SIG_CPEP, NULL,                   AcpiDmDumpCpep, DtCompileCpep,  TemplateCpep},
    381     {ACPI_SIG_CSRT, NULL,                   AcpiDmDumpCsrt, DtCompileCsrt,  TemplateCsrt},
    382     {ACPI_SIG_DBG2, AcpiDmTableInfoDbg2,    AcpiDmDumpDbg2, DtCompileDbg2,  TemplateDbg2},
    383     {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp,    NULL,           NULL,           TemplateDbgp},
    384     {ACPI_SIG_DMAR, NULL,                   AcpiDmDumpDmar, DtCompileDmar,  TemplateDmar},
    385     {ACPI_SIG_DRTM, NULL,                   AcpiDmDumpDrtm, DtCompileDrtm,  TemplateDrtm},
    386     {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt,    NULL,           NULL,           TemplateEcdt},
    387     {ACPI_SIG_EINJ, NULL,                   AcpiDmDumpEinj, DtCompileEinj,  TemplateEinj},
    388     {ACPI_SIG_ERST, NULL,                   AcpiDmDumpErst, DtCompileErst,  TemplateErst},
    389     {ACPI_SIG_FADT, NULL,                   AcpiDmDumpFadt, DtCompileFadt,  TemplateFadt},
    390     {ACPI_SIG_FPDT, NULL,                   AcpiDmDumpFpdt, DtCompileFpdt,  TemplateFpdt},
    391     {ACPI_SIG_GTDT, NULL,                   AcpiDmDumpGtdt, DtCompileGtdt,  TemplateGtdt},
    392     {ACPI_SIG_HEST, NULL,                   AcpiDmDumpHest, DtCompileHest,  TemplateHest},
    393     {ACPI_SIG_HMAT, NULL,                   AcpiDmDumpHmat, DtCompileHmat,  TemplateHmat},
    394     {ACPI_SIG_HPET, AcpiDmTableInfoHpet,    NULL,           NULL,           TemplateHpet},
    395     {ACPI_SIG_IORT, NULL,                   AcpiDmDumpIort, DtCompileIort,  TemplateIort},
    396     {ACPI_SIG_IVRS, NULL,                   AcpiDmDumpIvrs, DtCompileIvrs,  TemplateIvrs},
    397     {ACPI_SIG_LPIT, NULL,                   AcpiDmDumpLpit, DtCompileLpit,  TemplateLpit},
    398     {ACPI_SIG_MADT, NULL,                   AcpiDmDumpMadt, DtCompileMadt,  TemplateMadt},
    399     {ACPI_SIG_MCFG, NULL,                   AcpiDmDumpMcfg, DtCompileMcfg,  TemplateMcfg},
    400     {ACPI_SIG_MCHI, AcpiDmTableInfoMchi,    NULL,           NULL,           TemplateMchi},
    401     {ACPI_SIG_MPST, AcpiDmTableInfoMpst,    AcpiDmDumpMpst, DtCompileMpst,  TemplateMpst},
    402     {ACPI_SIG_MSCT, NULL,                   AcpiDmDumpMsct, DtCompileMsct,  TemplateMsct},
    403     {ACPI_SIG_MSDM, NULL,                   AcpiDmDumpSlic, DtCompileSlic,  TemplateMsdm},
    404     {ACPI_SIG_MTMR, NULL,                   AcpiDmDumpMtmr, DtCompileMtmr,  TemplateMtmr},
    405     {ACPI_SIG_NFIT, AcpiDmTableInfoNfit,    AcpiDmDumpNfit, DtCompileNfit,  TemplateNfit},
    406     {ACPI_SIG_PCCT, AcpiDmTableInfoPcct,    AcpiDmDumpPcct, DtCompilePcct,  TemplatePcct},
    407     {ACPI_SIG_PDTT, AcpiDmTableInfoPdtt,    AcpiDmDumpPdtt, DtCompilePdtt,  TemplatePdtt},
    408     {ACPI_SIG_PMTT, NULL,                   AcpiDmDumpPmtt, DtCompilePmtt,  TemplatePmtt},
    409     {ACPI_SIG_PPTT, NULL,                   AcpiDmDumpPptt, DtCompilePptt,  TemplatePptt},
    410     {ACPI_SIG_RASF, AcpiDmTableInfoRasf,    NULL,           NULL,           TemplateRasf},
    411     {ACPI_SIG_RSDT, NULL,                   AcpiDmDumpRsdt, DtCompileRsdt,  TemplateRsdt},
    412     {ACPI_SIG_S3PT, NULL,                   NULL,           NULL,           TemplateS3pt},
    413     {ACPI_SIG_SBST, AcpiDmTableInfoSbst,    NULL,           NULL,           TemplateSbst},
    414     {ACPI_SIG_SDEI, AcpiDmTableInfoSdei,    NULL,           NULL,           TemplateSdei},
    415     {ACPI_SIG_SDEV, AcpiDmTableInfoSdev,    AcpiDmDumpSdev, DtCompileSdev,  TemplateSdev},
    416     {ACPI_SIG_SLIC, NULL,                   AcpiDmDumpSlic, DtCompileSlic,  TemplateSlic},
    417     {ACPI_SIG_SLIT, NULL,                   AcpiDmDumpSlit, DtCompileSlit,  TemplateSlit},
    418     {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr,    NULL,           NULL,           TemplateSpcr},
    419     {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi,    NULL,           NULL,           TemplateSpmi},
    420     {ACPI_SIG_SRAT, NULL,                   AcpiDmDumpSrat, DtCompileSrat,  TemplateSrat},
    421     {ACPI_SIG_STAO, NULL,                   AcpiDmDumpStao, DtCompileStao,  TemplateStao},
    422     {ACPI_SIG_TCPA, NULL,                   AcpiDmDumpTcpa, DtCompileTcpa,  TemplateTcpa},
    423     {ACPI_SIG_TPM2, AcpiDmTableInfoTpm2,    AcpiDmDumpTpm2, DtCompileTpm2,  TemplateTpm2},
    424     {ACPI_SIG_UEFI, AcpiDmTableInfoUefi,    NULL,           DtCompileUefi,  TemplateUefi},
    425     {ACPI_SIG_VRTC, AcpiDmTableInfoVrtc,    AcpiDmDumpVrtc, DtCompileVrtc,  TemplateVrtc},
    426     {ACPI_SIG_WAET, AcpiDmTableInfoWaet,    NULL,           NULL,           TemplateWaet},
    427     {ACPI_SIG_WDAT, NULL,                   AcpiDmDumpWdat, DtCompileWdat,  TemplateWdat},
    428     {ACPI_SIG_WDDT, AcpiDmTableInfoWddt,    NULL,           NULL,           TemplateWddt},
    429     {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt,    NULL,           NULL,           TemplateWdrt},
    430     {ACPI_SIG_WPBT, NULL,                   AcpiDmDumpWpbt, DtCompileWpbt,  TemplateWpbt},
    431     {ACPI_SIG_WSMT, AcpiDmTableInfoWsmt,    NULL,           NULL,           TemplateWsmt},
    432     {ACPI_SIG_XENV, AcpiDmTableInfoXenv,    NULL,           NULL,           TemplateXenv},
    433     {ACPI_SIG_XSDT, NULL,                   AcpiDmDumpXsdt, DtCompileXsdt,  TemplateXsdt},
    434     {NULL,          NULL,                   NULL,           NULL,           NULL}
    435 };
    436 
    437 
    438 /*******************************************************************************
    439  *
    440  * FUNCTION:    AcpiDmGenerateChecksum
    441  *
    442  * PARAMETERS:  Table               - Pointer to table to be checksummed
    443  *              Length              - Length of the table
    444  *              OriginalChecksum    - Value of the checksum field
    445  *
    446  * RETURN:      8 bit checksum of buffer
    447  *
    448  * DESCRIPTION: Computes an 8 bit checksum of the table.
    449  *
    450  ******************************************************************************/
    451 
    452 UINT8
    453 AcpiDmGenerateChecksum (
    454     void                    *Table,
    455     UINT32                  Length,
    456     UINT8                   OriginalChecksum)
    457 {
    458     UINT8                   Checksum;
    459 
    460 
    461     /* Sum the entire table as-is */
    462 
    463     Checksum = AcpiTbChecksum ((UINT8 *) Table, Length);
    464 
    465     /* Subtract off the existing checksum value in the table */
    466 
    467     Checksum = (UINT8) (Checksum - OriginalChecksum);
    468 
    469     /* Compute the final checksum */
    470 
    471     Checksum = (UINT8) (0 - Checksum);
    472     return (Checksum);
    473 }
    474 
    475 
    476 /*******************************************************************************
    477  *
    478  * FUNCTION:    AcpiDmGetTableData
    479  *
    480  * PARAMETERS:  Signature           - ACPI signature (4 chars) to match
    481  *
    482  * RETURN:      Pointer to a valid ACPI_DMTABLE_DATA. Null if no match found.
    483  *
    484  * DESCRIPTION: Find a match in the global table of supported ACPI tables
    485  *
    486  ******************************************************************************/
    487 
    488 const ACPI_DMTABLE_DATA *
    489 AcpiDmGetTableData (
    490     char                    *Signature)
    491 {
    492     const ACPI_DMTABLE_DATA *Info;
    493 
    494 
    495     for (Info = AcpiDmTableData; Info->Signature; Info++)
    496     {
    497         if (ACPI_COMPARE_NAMESEG (Signature, Info->Signature))
    498         {
    499             return (Info);
    500         }
    501     }
    502 
    503     return (NULL);
    504 }
    505 
    506 
    507 /*******************************************************************************
    508  *
    509  * FUNCTION:    AcpiDmDumpDataTable
    510  *
    511  * PARAMETERS:  Table               - An ACPI table
    512  *
    513  * RETURN:      None.
    514  *
    515  * DESCRIPTION: Format the contents of an ACPI data table (any table other
    516  *              than an SSDT or DSDT that does not contain executable AML code)
    517  *
    518  ******************************************************************************/
    519 
    520 void
    521 AcpiDmDumpDataTable (
    522     ACPI_TABLE_HEADER       *Table)
    523 {
    524     ACPI_STATUS             Status;
    525     const ACPI_DMTABLE_DATA *TableData;
    526     UINT32                  Length;
    527 
    528 
    529     /* Ignore tables that contain AML */
    530 
    531     if (AcpiUtIsAmlTable (Table))
    532     {
    533         if (AslGbl_VerboseTemplates)
    534         {
    535             /* Dump the raw table data */
    536 
    537             Length = Table->Length;
    538 
    539             AcpiOsPrintf ("\n/*\n%s: Length %d (0x%X)\n\n",
    540                 ACPI_RAW_TABLE_DATA_HEADER, Length, Length);
    541             AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table),
    542                 Length, DB_BYTE_DISPLAY, 0);
    543             AcpiOsPrintf (" */\n");
    544         }
    545         return;
    546     }
    547 
    548     /*
    549      * Handle tables that don't use the common ACPI table header structure.
    550      * Currently, these are the FACS, RSDP, and S3PT.
    551      */
    552     if (ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_FACS))
    553     {
    554         Length = Table->Length;
    555         Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFacs);
    556         if (ACPI_FAILURE (Status))
    557         {
    558             return;
    559         }
    560     }
    561     else if (ACPI_VALIDATE_RSDP_SIG (Table->Signature))
    562     {
    563         Length = AcpiDmDumpRsdp (Table);
    564     }
    565     else if (ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_S3PT))
    566     {
    567         Length = AcpiDmDumpS3pt (Table);
    568     }
    569     else
    570     {
    571         /*
    572          * All other tables must use the common ACPI table header, dump it now
    573          */
    574         Length = Table->Length;
    575         Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHeader);
    576         if (ACPI_FAILURE (Status))
    577         {
    578             return;
    579         }
    580         AcpiOsPrintf ("\n");
    581 
    582         /* Match signature and dispatch appropriately */
    583 
    584         TableData = AcpiDmGetTableData (Table->Signature);
    585         if (!TableData)
    586         {
    587             if (!strncmp (Table->Signature, "OEM", 3))
    588             {
    589                 AcpiOsPrintf ("\n**** OEM-defined ACPI table [%4.4s], unknown contents\n\n",
    590                     Table->Signature);
    591             }
    592             else
    593             {
    594                 AcpiOsPrintf ("\n**** Unknown ACPI table signature [%4.4s]\n\n",
    595                     Table->Signature);
    596 
    597                 fprintf (stderr, "Unknown ACPI table signature [%4.4s], ",
    598                     Table->Signature);
    599 
    600                 if (!AcpiGbl_ForceAmlDisassembly)
    601                 {
    602                     fprintf (stderr, "decoding ACPI table header only\n");
    603                 }
    604                 else
    605                 {
    606                     fprintf (stderr, "assuming table contains valid AML code\n");
    607                 }
    608             }
    609         }
    610         else if (TableData->TableHandler)
    611         {
    612             /* Complex table, has a handler */
    613 
    614             TableData->TableHandler (Table);
    615         }
    616         else if (TableData->TableInfo)
    617         {
    618             /* Simple table, just walk the info table */
    619 
    620             Status = AcpiDmDumpTable (Length, 0, Table, 0, TableData->TableInfo);
    621             if (ACPI_FAILURE (Status))
    622             {
    623                 return;
    624             }
    625         }
    626     }
    627 
    628     if (!AslGbl_DoTemplates || AslGbl_VerboseTemplates)
    629     {
    630         /* Dump the raw table data */
    631 
    632         AcpiOsPrintf ("\n%s: Length %d (0x%X)\n\n",
    633             ACPI_RAW_TABLE_DATA_HEADER, Length, Length);
    634         AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table),
    635             Length, DB_BYTE_DISPLAY, 0);
    636     }
    637 }
    638 
    639 
    640 /*******************************************************************************
    641  *
    642  * FUNCTION:    AcpiDmLineHeader
    643  *
    644  * PARAMETERS:  Offset              - Current byte offset, from table start
    645  *              ByteLength          - Length of the field in bytes, 0 for flags
    646  *              Name                - Name of this field
    647  *
    648  * RETURN:      None
    649  *
    650  * DESCRIPTION: Utility routines for formatting output lines. Displays the
    651  *              current table offset in hex and decimal, the field length,
    652  *              and the field name.
    653  *
    654  ******************************************************************************/
    655 
    656 void
    657 AcpiDmLineHeader (
    658     UINT32                  Offset,
    659     UINT32                  ByteLength,
    660     char                    *Name)
    661 {
    662 
    663     /* Allow a null name for fields that span multiple lines (large buffers) */
    664 
    665     if (!Name)
    666     {
    667         Name = "";
    668     }
    669 
    670     if (AslGbl_DoTemplates && !AslGbl_VerboseTemplates) /* Terse template */
    671     {
    672         if (ByteLength)
    673         {
    674             AcpiOsPrintf ("[%.4d] %34s : ", ByteLength, Name);
    675         }
    676         else
    677         {
    678             if (*Name)
    679             {
    680                 AcpiOsPrintf ("%41s : ", Name);
    681             }
    682             else
    683             {
    684                 AcpiOsPrintf ("%41s   ", Name);
    685             }
    686         }
    687     }
    688     else /* Normal disassembler or verbose template */
    689     {
    690         if (ByteLength)
    691         {
    692             AcpiOsPrintf ("[%3.3Xh %4.4d% 4d] %28s : ",
    693                 Offset, Offset, ByteLength, Name);
    694         }
    695         else
    696         {
    697             if (*Name)
    698             {
    699                 AcpiOsPrintf ("%44s : ", Name);
    700             }
    701             else
    702             {
    703                 AcpiOsPrintf ("%44s   ", Name);
    704             }
    705         }
    706     }
    707 }
    708 
    709 void
    710 AcpiDmLineHeader2 (
    711     UINT32                  Offset,
    712     UINT32                  ByteLength,
    713     char                    *Name,
    714     UINT32                  Value)
    715 {
    716 
    717     if (AslGbl_DoTemplates && !AslGbl_VerboseTemplates) /* Terse template */
    718     {
    719         if (ByteLength)
    720         {
    721             AcpiOsPrintf ("[%.4d] %30s %3d : ",
    722                 ByteLength, Name, Value);
    723         }
    724         else
    725         {
    726             AcpiOsPrintf ("%36s % 3d : ",
    727                 Name, Value);
    728         }
    729     }
    730     else /* Normal disassembler or verbose template */
    731     {
    732         if (ByteLength)
    733         {
    734             AcpiOsPrintf ("[%3.3Xh %4.4d %3d] %24s %3d : ",
    735                 Offset, Offset, ByteLength, Name, Value);
    736         }
    737         else
    738         {
    739             AcpiOsPrintf ("[%3.3Xh %4.4d   ] %24s %3d : ",
    740                 Offset, Offset, Name, Value);
    741         }
    742     }
    743 }
    744 
    745 
    746 /*******************************************************************************
    747  *
    748  * FUNCTION:    AcpiDmDumpTable
    749  *
    750  * PARAMETERS:  TableLength         - Length of the entire ACPI table
    751  *              TableOffset         - Starting offset within the table for this
    752  *                                    sub-descriptor (0 if main table)
    753  *              Table               - The ACPI table
    754  *              SubtableLength      - Length of this sub-descriptor
    755  *              Info                - Info table for this ACPI table
    756  *
    757  * RETURN:      Status
    758  *
    759  * DESCRIPTION: Display ACPI table contents by walking the Info table.
    760  *
    761  * Note: This function must remain in sync with DtGetFieldLength.
    762  *
    763  ******************************************************************************/
    764 
    765 ACPI_STATUS
    766 AcpiDmDumpTable (
    767     UINT32                  TableLength,
    768     UINT32                  TableOffset,
    769     void                    *Table,
    770     UINT32                  SubtableLength,
    771     ACPI_DMTABLE_INFO       *Info)
    772 {
    773     UINT8                   *Target;
    774     UINT32                  CurrentOffset;
    775     UINT32                  ByteLength;
    776     UINT8                   Temp8;
    777     UINT16                  Temp16;
    778     UINT32                  Temp32;
    779     UINT64                  Value;
    780     const AH_TABLE          *TableData;
    781     const char              *Name;
    782     BOOLEAN                 LastOutputBlankLine = FALSE;
    783     ACPI_STATUS             Status;
    784     char                    RepairedName[8];
    785 
    786 
    787     if (!Info)
    788     {
    789         AcpiOsPrintf ("Display not implemented\n");
    790         return (AE_NOT_IMPLEMENTED);
    791     }
    792 
    793     /* Walk entire Info table; Null name terminates */
    794 
    795     for (; Info->Name; Info++)
    796     {
    797         /*
    798          * Target points to the field within the ACPI Table. CurrentOffset is
    799          * the offset of the field from the start of the main table.
    800          */
    801         Target = ACPI_ADD_PTR (UINT8, Table, Info->Offset);
    802         CurrentOffset = TableOffset + Info->Offset;
    803 
    804         /* Check for beyond subtable end or (worse) beyond EOT */
    805 
    806         if (SubtableLength && (Info->Offset >= SubtableLength))
    807         {
    808             AcpiOsPrintf (
    809                 "/**** ACPI subtable terminates early - "
    810                 "may be older version (dump table) */\n");
    811 
    812             /* Move on to next subtable */
    813 
    814             return (AE_OK);
    815         }
    816 
    817         if (CurrentOffset >= TableLength)
    818         {
    819             AcpiOsPrintf (
    820                 "/**** ACPI table terminates "
    821                 "in the middle of a data structure! (dump table) */\n");
    822             return (AE_BAD_DATA);
    823         }
    824 
    825         /* Generate the byte length for this field */
    826 
    827         switch (Info->Opcode)
    828         {
    829         case ACPI_DMT_UINT8:
    830         case ACPI_DMT_CHKSUM:
    831         case ACPI_DMT_SPACEID:
    832         case ACPI_DMT_ACCWIDTH:
    833         case ACPI_DMT_IVRS:
    834         case ACPI_DMT_GTDT:
    835         case ACPI_DMT_MADT:
    836         case ACPI_DMT_PCCT:
    837         case ACPI_DMT_PMTT:
    838         case ACPI_DMT_PPTT:
    839         case ACPI_DMT_SDEV:
    840         case ACPI_DMT_SRAT:
    841         case ACPI_DMT_ASF:
    842         case ACPI_DMT_HESTNTYP:
    843         case ACPI_DMT_FADTPM:
    844         case ACPI_DMT_EINJACT:
    845         case ACPI_DMT_EINJINST:
    846         case ACPI_DMT_ERSTACT:
    847         case ACPI_DMT_ERSTINST:
    848         case ACPI_DMT_DMAR_SCOPE:
    849 
    850             ByteLength = 1;
    851             break;
    852 
    853         case ACPI_DMT_UINT16:
    854         case ACPI_DMT_DMAR:
    855         case ACPI_DMT_HEST:
    856         case ACPI_DMT_HMAT:
    857         case ACPI_DMT_NFIT:
    858 
    859             ByteLength = 2;
    860             break;
    861 
    862         case ACPI_DMT_UINT24:
    863 
    864             ByteLength = 3;
    865             break;
    866 
    867         case ACPI_DMT_UINT32:
    868         case ACPI_DMT_NAME4:
    869         case ACPI_DMT_SIG:
    870         case ACPI_DMT_LPIT:
    871         case ACPI_DMT_TPM2:
    872 
    873             ByteLength = 4;
    874             break;
    875 
    876         case ACPI_DMT_UINT40:
    877 
    878             ByteLength = 5;
    879             break;
    880 
    881         case ACPI_DMT_UINT48:
    882         case ACPI_DMT_NAME6:
    883 
    884             ByteLength = 6;
    885             break;
    886 
    887         case ACPI_DMT_UINT56:
    888         case ACPI_DMT_BUF7:
    889 
    890             ByteLength = 7;
    891             break;
    892 
    893         case ACPI_DMT_UINT64:
    894         case ACPI_DMT_NAME8:
    895 
    896             ByteLength = 8;
    897             break;
    898 
    899         case ACPI_DMT_BUF10:
    900 
    901             ByteLength = 10;
    902             break;
    903 
    904         case ACPI_DMT_BUF12:
    905 
    906             ByteLength = 12;
    907             break;
    908 
    909         case ACPI_DMT_BUF16:
    910         case ACPI_DMT_UUID:
    911 
    912             ByteLength = 16;
    913             break;
    914 
    915         case ACPI_DMT_BUF128:
    916 
    917             ByteLength = 128;
    918             break;
    919 
    920         case ACPI_DMT_UNICODE:
    921         case ACPI_DMT_BUFFER:
    922         case ACPI_DMT_RAW_BUFFER:
    923 
    924             ByteLength = SubtableLength;
    925             break;
    926 
    927         case ACPI_DMT_STRING:
    928 
    929             ByteLength = strlen (ACPI_CAST_PTR (char, Target)) + 1;
    930             break;
    931 
    932         case ACPI_DMT_GAS:
    933 
    934             if (!LastOutputBlankLine)
    935             {
    936                 AcpiOsPrintf ("\n");
    937                 LastOutputBlankLine = TRUE;
    938             }
    939 
    940             ByteLength = sizeof (ACPI_GENERIC_ADDRESS);
    941             break;
    942 
    943         case ACPI_DMT_HESTNTFY:
    944 
    945             if (!LastOutputBlankLine)
    946             {
    947                 AcpiOsPrintf ("\n");
    948                 LastOutputBlankLine = TRUE;
    949             }
    950 
    951             ByteLength = sizeof (ACPI_HEST_NOTIFY);
    952             break;
    953 
    954         case ACPI_DMT_IORTMEM:
    955 
    956             if (!LastOutputBlankLine)
    957             {
    958                 LastOutputBlankLine = FALSE;
    959             }
    960 
    961             ByteLength = sizeof (ACPI_IORT_MEMORY_ACCESS);
    962             break;
    963 
    964         default:
    965 
    966             ByteLength = 0;
    967             break;
    968         }
    969 
    970         /* Check if we are beyond a subtable, or (worse) beyond EOT */
    971 
    972         if (CurrentOffset + ByteLength > TableLength)
    973         {
    974             if (SubtableLength)
    975             {
    976                 AcpiOsPrintf (
    977                     "/**** ACPI subtable terminates early - "
    978                     "may be older version (dump table) */\n");
    979 
    980                 /* Move on to next subtable */
    981 
    982                 return (AE_OK);
    983             }
    984 
    985             AcpiOsPrintf (
    986                 "/**** ACPI table terminates "
    987                 "in the middle of a data structure! */\n");
    988             return (AE_BAD_DATA);
    989         }
    990 
    991         if (Info->Opcode == ACPI_DMT_EXTRA_TEXT)
    992         {
    993             AcpiOsPrintf ("%s", Info->Name);
    994             continue;
    995         }
    996 
    997         /* Start a new line and decode the opcode */
    998 
    999         AcpiDmLineHeader (CurrentOffset, ByteLength, Info->Name);
   1000 
   1001         switch (Info->Opcode)
   1002         {
   1003         /* Single-bit Flag fields. Note: Opcode is the bit position */
   1004 
   1005         case ACPI_DMT_FLAG0:
   1006         case ACPI_DMT_FLAG1:
   1007         case ACPI_DMT_FLAG2:
   1008         case ACPI_DMT_FLAG3:
   1009         case ACPI_DMT_FLAG4:
   1010         case ACPI_DMT_FLAG5:
   1011         case ACPI_DMT_FLAG6:
   1012         case ACPI_DMT_FLAG7:
   1013 
   1014             AcpiOsPrintf ("%1.1X\n", (*Target >> Info->Opcode) & 0x01);
   1015             break;
   1016 
   1017         /* 2-bit Flag fields */
   1018 
   1019         case ACPI_DMT_FLAGS0:
   1020 
   1021             AcpiOsPrintf ("%1.1X\n", *Target & 0x03);
   1022             break;
   1023 
   1024         case ACPI_DMT_FLAGS1:
   1025 
   1026             AcpiOsPrintf ("%1.1X\n", (*Target >> 1) & 0x03);
   1027             break;
   1028 
   1029         case ACPI_DMT_FLAGS2:
   1030 
   1031             AcpiOsPrintf ("%1.1X\n", (*Target >> 2) & 0x03);
   1032             break;
   1033 
   1034         case ACPI_DMT_FLAGS4:
   1035 
   1036             AcpiOsPrintf ("%1.1X\n", (*Target >> 4) & 0x03);
   1037             break;
   1038 
   1039         case ACPI_DMT_FLAGS4_0:
   1040 
   1041             AcpiOsPrintf ("%1.1X\n", (*(UINT32 *)Target) & 0x0F);
   1042             break;
   1043 
   1044         case ACPI_DMT_FLAGS4_4:
   1045 
   1046             AcpiOsPrintf ("%1.1X\n", (*(UINT32 *)Target >> 4) & 0x0F);
   1047             break;
   1048 
   1049         case ACPI_DMT_FLAGS4_8:
   1050 
   1051             AcpiOsPrintf ("%1.1X\n", (*(UINT32 *)Target >> 8) & 0x0F);
   1052             break;
   1053 
   1054         case ACPI_DMT_FLAGS4_12:
   1055 
   1056             AcpiOsPrintf ("%1.1X\n", (*(UINT32 *)Target >> 12) & 0x0F);
   1057             break;
   1058 
   1059         case ACPI_DMT_FLAGS16_16:
   1060 
   1061             AcpiOsPrintf ("%4.4X\n", (*(UINT32 *)Target >> 16) & 0xFFFF);
   1062             break;
   1063 
   1064         /* Integer Data Types */
   1065 
   1066         case ACPI_DMT_UINT8:
   1067         case ACPI_DMT_UINT16:
   1068         case ACPI_DMT_UINT24:
   1069         case ACPI_DMT_UINT32:
   1070         case ACPI_DMT_UINT40:
   1071         case ACPI_DMT_UINT48:
   1072         case ACPI_DMT_UINT56:
   1073         case ACPI_DMT_UINT64:
   1074             /*
   1075              * Dump bytes - high byte first, low byte last.
   1076              * Note: All ACPI tables are little-endian.
   1077              */
   1078             Value = 0;
   1079             for (Temp8 = (UINT8) ByteLength; Temp8 > 0; Temp8--)
   1080             {
   1081                 AcpiOsPrintf ("%2.2X", Target[Temp8 - 1]);
   1082                 Value |= Target[Temp8 - 1];
   1083                 Value <<= 8;
   1084             }
   1085 
   1086             if (!Value && (Info->Flags & DT_DESCRIBES_OPTIONAL))
   1087             {
   1088                 AcpiOsPrintf (" [Optional field not present]");
   1089             }
   1090 
   1091             AcpiOsPrintf ("\n");
   1092             break;
   1093 
   1094         case ACPI_DMT_BUF7:
   1095         case ACPI_DMT_BUF10:
   1096         case ACPI_DMT_BUF12:
   1097         case ACPI_DMT_BUF16:
   1098         case ACPI_DMT_BUF128:
   1099             /*
   1100              * Buffer: Size depends on the opcode and was set above.
   1101              * Each hex byte is separated with a space.
   1102              * Multiple lines are separated by line continuation char.
   1103              */
   1104             for (Temp16 = 0; Temp16 < ByteLength; Temp16++)
   1105             {
   1106                 AcpiOsPrintf ("%2.2X", Target[Temp16]);
   1107                 if ((UINT32) (Temp16 + 1) < ByteLength)
   1108                 {
   1109                     if ((Temp16 > 0) && (!((Temp16+1) % 16)))
   1110                     {
   1111                         AcpiOsPrintf (" \\\n"); /* Line continuation */
   1112                         AcpiDmLineHeader (0, 0, NULL);
   1113                     }
   1114                     else
   1115                     {
   1116                         AcpiOsPrintf (" ");
   1117                     }
   1118                 }
   1119             }
   1120 
   1121             AcpiOsPrintf ("\n");
   1122             break;
   1123 
   1124         case ACPI_DMT_UUID:
   1125 
   1126             /* Convert 16-byte UUID buffer to 36-byte formatted UUID string */
   1127 
   1128             (void) AuConvertUuidToString ((char *) Target, AslGbl_MsgBuffer);
   1129 
   1130             AcpiOsPrintf ("%s\n", AslGbl_MsgBuffer);
   1131             break;
   1132 
   1133         case ACPI_DMT_STRING:
   1134 
   1135             AcpiOsPrintf ("\"%s\"\n", ACPI_CAST_PTR (char, Target));
   1136             break;
   1137 
   1138         /* Fixed length ASCII name fields */
   1139 
   1140         case ACPI_DMT_SIG:
   1141 
   1142             AcpiUtCheckAndRepairAscii (Target, RepairedName, 4);
   1143             AcpiOsPrintf ("\"%.4s\"    ", RepairedName);
   1144 
   1145             TableData = AcpiAhGetTableInfo (ACPI_CAST_PTR (char, Target));
   1146             if (TableData)
   1147             {
   1148                 AcpiOsPrintf (STRING_FORMAT, TableData->Description);
   1149             }
   1150             else
   1151             {
   1152                 AcpiOsPrintf ("\n");
   1153             }
   1154             break;
   1155 
   1156         case ACPI_DMT_NAME4:
   1157 
   1158             AcpiUtCheckAndRepairAscii (Target, RepairedName, 4);
   1159             AcpiOsPrintf ("\"%.4s\"\n", RepairedName);
   1160             break;
   1161 
   1162         case ACPI_DMT_NAME6:
   1163 
   1164             AcpiUtCheckAndRepairAscii (Target, RepairedName, 6);
   1165             AcpiOsPrintf ("\"%.6s\"\n", RepairedName);
   1166             break;
   1167 
   1168         case ACPI_DMT_NAME8:
   1169 
   1170             AcpiUtCheckAndRepairAscii (Target, RepairedName, 8);
   1171             AcpiOsPrintf ("\"%.8s\"\n", RepairedName);
   1172             break;
   1173 
   1174         /* Special Data Types */
   1175 
   1176         case ACPI_DMT_CHKSUM:
   1177 
   1178             /* Checksum, display and validate */
   1179 
   1180             AcpiOsPrintf ("%2.2X", *Target);
   1181             Temp8 = AcpiDmGenerateChecksum (Table,
   1182                 ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length,
   1183                 ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum);
   1184 
   1185             if (Temp8 != ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum)
   1186             {
   1187                 AcpiOsPrintf (
   1188                     "     /* Incorrect checksum, should be %2.2X */", Temp8);
   1189             }
   1190 
   1191             AcpiOsPrintf ("\n");
   1192             break;
   1193 
   1194         case ACPI_DMT_SPACEID:
   1195 
   1196             /* Address Space ID */
   1197 
   1198             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiUtGetRegionName (*Target));
   1199             break;
   1200 
   1201         case ACPI_DMT_ACCWIDTH:
   1202 
   1203             /* Encoded Access Width */
   1204 
   1205             Temp8 = *Target;
   1206             if (Temp8 > ACPI_GAS_WIDTH_RESERVED)
   1207             {
   1208                 Temp8 = ACPI_GAS_WIDTH_RESERVED;
   1209             }
   1210 
   1211             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmGasAccessWidth[Temp8]);
   1212             break;
   1213 
   1214         case ACPI_DMT_GAS:
   1215 
   1216             /* Generic Address Structure */
   1217 
   1218             AcpiOsPrintf (STRING_FORMAT, "Generic Address Structure");
   1219             Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
   1220                 sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas);
   1221             if (ACPI_FAILURE (Status))
   1222             {
   1223                 return (Status);
   1224             }
   1225 
   1226             AcpiOsPrintf ("\n");
   1227             LastOutputBlankLine = TRUE;
   1228             break;
   1229 
   1230         case ACPI_DMT_ASF:
   1231 
   1232             /* ASF subtable types */
   1233 
   1234             Temp16 = (UINT16) ((*Target) & 0x7F);  /* Top bit can be zero or one */
   1235             if (Temp16 > ACPI_ASF_TYPE_RESERVED)
   1236             {
   1237                 Temp16 = ACPI_ASF_TYPE_RESERVED;
   1238             }
   1239 
   1240             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmAsfSubnames[Temp16]);
   1241             break;
   1242 
   1243         case ACPI_DMT_DMAR:
   1244 
   1245             /* DMAR subtable types */
   1246 
   1247             Temp16 = ACPI_GET16 (Target);
   1248             if (Temp16 > ACPI_DMAR_TYPE_RESERVED)
   1249             {
   1250                 Temp16 = ACPI_DMAR_TYPE_RESERVED;
   1251             }
   1252 
   1253             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
   1254                 AcpiDmDmarSubnames[Temp16]);
   1255             break;
   1256 
   1257         case ACPI_DMT_DMAR_SCOPE:
   1258 
   1259             /* DMAR device scope types */
   1260 
   1261             Temp8 = *Target;
   1262             if (Temp8 > ACPI_DMAR_SCOPE_TYPE_RESERVED)
   1263             {
   1264                 Temp8 = ACPI_DMAR_SCOPE_TYPE_RESERVED;
   1265             }
   1266 
   1267             AcpiOsPrintf (UINT8_FORMAT, *Target,
   1268                 AcpiDmDmarScope[Temp8]);
   1269             break;
   1270 
   1271         case ACPI_DMT_EINJACT:
   1272 
   1273             /* EINJ Action types */
   1274 
   1275             Temp8 = *Target;
   1276             if (Temp8 > ACPI_EINJ_ACTION_RESERVED)
   1277             {
   1278                 Temp8 = ACPI_EINJ_ACTION_RESERVED;
   1279             }
   1280 
   1281             AcpiOsPrintf (UINT8_FORMAT, *Target,
   1282                 AcpiDmEinjActions[Temp8]);
   1283             break;
   1284 
   1285         case ACPI_DMT_EINJINST:
   1286 
   1287             /* EINJ Instruction types */
   1288 
   1289             Temp8 = *Target;
   1290             if (Temp8 > ACPI_EINJ_INSTRUCTION_RESERVED)
   1291             {
   1292                 Temp8 = ACPI_EINJ_INSTRUCTION_RESERVED;
   1293             }
   1294 
   1295             AcpiOsPrintf (UINT8_FORMAT, *Target,
   1296                 AcpiDmEinjInstructions[Temp8]);
   1297             break;
   1298 
   1299         case ACPI_DMT_ERSTACT:
   1300 
   1301             /* ERST Action types */
   1302 
   1303             Temp8 = *Target;
   1304             if (Temp8 > ACPI_ERST_ACTION_RESERVED)
   1305             {
   1306                 Temp8 = ACPI_ERST_ACTION_RESERVED;
   1307             }
   1308 
   1309             AcpiOsPrintf (UINT8_FORMAT, *Target,
   1310                 AcpiDmErstActions[Temp8]);
   1311             break;
   1312 
   1313         case ACPI_DMT_ERSTINST:
   1314 
   1315             /* ERST Instruction types */
   1316 
   1317             Temp8 = *Target;
   1318             if (Temp8 > ACPI_ERST_INSTRUCTION_RESERVED)
   1319             {
   1320                 Temp8 = ACPI_ERST_INSTRUCTION_RESERVED;
   1321             }
   1322 
   1323             AcpiOsPrintf (UINT8_FORMAT, *Target,
   1324                 AcpiDmErstInstructions[Temp8]);
   1325             break;
   1326 
   1327         case ACPI_DMT_GTDT:
   1328 
   1329             /* GTDT subtable types */
   1330 
   1331             Temp8 = *Target;
   1332             if (Temp8 > ACPI_GTDT_TYPE_RESERVED)
   1333             {
   1334                 Temp8 = ACPI_GTDT_TYPE_RESERVED;
   1335             }
   1336 
   1337             AcpiOsPrintf (UINT8_FORMAT, *Target,
   1338                 AcpiDmGtdtSubnames[Temp8]);
   1339             break;
   1340 
   1341         case ACPI_DMT_HEST:
   1342 
   1343             /* HEST subtable types */
   1344 
   1345             Temp16 = ACPI_GET16 (Target);
   1346             if (Temp16 > ACPI_HEST_TYPE_RESERVED)
   1347             {
   1348                 Temp16 = ACPI_HEST_TYPE_RESERVED;
   1349             }
   1350 
   1351             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
   1352                 AcpiDmHestSubnames[Temp16]);
   1353             break;
   1354 
   1355         case ACPI_DMT_HESTNTFY:
   1356 
   1357             AcpiOsPrintf (STRING_FORMAT,
   1358                 "Hardware Error Notification Structure");
   1359 
   1360             Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
   1361                 sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify);
   1362             if (ACPI_FAILURE (Status))
   1363             {
   1364                 return (Status);
   1365             }
   1366 
   1367             AcpiOsPrintf ("\n");
   1368             LastOutputBlankLine = TRUE;
   1369             break;
   1370 
   1371         case ACPI_DMT_HESTNTYP:
   1372 
   1373             /* HEST Notify types */
   1374 
   1375             Temp8 = *Target;
   1376             if (Temp8 > ACPI_HEST_NOTIFY_RESERVED)
   1377             {
   1378                 Temp8 = ACPI_HEST_NOTIFY_RESERVED;
   1379             }
   1380 
   1381             AcpiOsPrintf (UINT8_FORMAT, *Target,
   1382                 AcpiDmHestNotifySubnames[Temp8]);
   1383             break;
   1384 
   1385         case ACPI_DMT_HMAT:
   1386 
   1387             /* HMAT subtable types */
   1388 
   1389             Temp16 = *Target;
   1390             if (Temp16 > ACPI_HMAT_TYPE_RESERVED)
   1391             {
   1392                 Temp16 = ACPI_HMAT_TYPE_RESERVED;
   1393             }
   1394 
   1395             AcpiOsPrintf (UINT16_FORMAT, *Target,
   1396                 AcpiDmHmatSubnames[Temp16]);
   1397             break;
   1398 
   1399         case ACPI_DMT_IORTMEM:
   1400 
   1401             AcpiOsPrintf (STRING_FORMAT,
   1402                 "IORT Memory Access Properties");
   1403 
   1404             Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
   1405                 sizeof (ACPI_IORT_MEMORY_ACCESS), AcpiDmTableInfoIortAcc);
   1406             if (ACPI_FAILURE (Status))
   1407             {
   1408                 return (Status);
   1409             }
   1410 
   1411             LastOutputBlankLine = TRUE;
   1412             break;
   1413 
   1414         case ACPI_DMT_MADT:
   1415 
   1416             /* MADT subtable types */
   1417 
   1418             Temp8 = *Target;
   1419             if (Temp8 > ACPI_MADT_TYPE_RESERVED)
   1420             {
   1421                 Temp8 = ACPI_MADT_TYPE_RESERVED;
   1422             }
   1423 
   1424             AcpiOsPrintf (UINT8_FORMAT, *Target,
   1425                 AcpiDmMadtSubnames[Temp8]);
   1426             break;
   1427 
   1428         case ACPI_DMT_NFIT:
   1429 
   1430             /* NFIT subtable types */
   1431 
   1432             Temp16 = ACPI_GET16 (Target);
   1433             if (Temp16 > ACPI_NFIT_TYPE_RESERVED)
   1434             {
   1435                 Temp16 = ACPI_NFIT_TYPE_RESERVED;
   1436             }
   1437 
   1438             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
   1439                 AcpiDmNfitSubnames[Temp16]);
   1440             break;
   1441 
   1442         case ACPI_DMT_PCCT:
   1443 
   1444             /* PCCT subtable types */
   1445 
   1446             Temp8 = *Target;
   1447             if (Temp8 > ACPI_PCCT_TYPE_RESERVED)
   1448             {
   1449                 Temp8 = ACPI_PCCT_TYPE_RESERVED;
   1450             }
   1451 
   1452             AcpiOsPrintf (UINT8_FORMAT, *Target,
   1453                 AcpiDmPcctSubnames[Temp8]);
   1454             break;
   1455 
   1456         case ACPI_DMT_PMTT:
   1457 
   1458             /* PMTT subtable types */
   1459 
   1460             Temp8 = *Target;
   1461             if (Temp8 > ACPI_PMTT_TYPE_RESERVED)
   1462             {
   1463                 Temp8 = ACPI_PMTT_TYPE_RESERVED;
   1464             }
   1465 
   1466             AcpiOsPrintf (UINT8_FORMAT, *Target,
   1467                 AcpiDmPmttSubnames[Temp8]);
   1468             break;
   1469 
   1470         case ACPI_DMT_PPTT:
   1471 
   1472             /* PPTT subtable types */
   1473 
   1474             Temp8 = *Target;
   1475             if (Temp8 > ACPI_PPTT_TYPE_RESERVED)
   1476             {
   1477                 Temp8 = ACPI_PPTT_TYPE_RESERVED;
   1478             }
   1479 
   1480             AcpiOsPrintf (UINT8_FORMAT, *Target,
   1481                 AcpiDmPpttSubnames[Temp8]);
   1482             break;
   1483 
   1484         case ACPI_DMT_UNICODE:
   1485 
   1486             if (ByteLength == 0)
   1487             {
   1488                 AcpiOsPrintf ("/* Zero-length Data */\n");
   1489                 break;
   1490             }
   1491 
   1492             AcpiDmDumpUnicode (Table, CurrentOffset, ByteLength);
   1493             break;
   1494 
   1495         case ACPI_DMT_RAW_BUFFER:
   1496 
   1497             if (ByteLength == 0)
   1498             {
   1499                 AcpiOsPrintf ("/* Zero-length Data */\n");
   1500                 break;
   1501             }
   1502 
   1503             AcpiDmDumpBuffer (Table, CurrentOffset, ByteLength,
   1504                 CurrentOffset, NULL);
   1505             break;
   1506 
   1507         case ACPI_DMT_SDEV:
   1508 
   1509             /* SDEV subtable types */
   1510 
   1511             Temp8 = *Target;
   1512             if (Temp8 > ACPI_SDEV_TYPE_RESERVED)
   1513             {
   1514                 Temp8 = ACPI_SDEV_TYPE_RESERVED;
   1515             }
   1516 
   1517             AcpiOsPrintf (UINT8_FORMAT, *Target,
   1518                 AcpiDmSdevSubnames[Temp8]);
   1519             break;
   1520 
   1521         case ACPI_DMT_SRAT:
   1522 
   1523             /* SRAT subtable types */
   1524 
   1525             Temp8 = *Target;
   1526             if (Temp8 > ACPI_SRAT_TYPE_RESERVED)
   1527             {
   1528                 Temp8 = ACPI_SRAT_TYPE_RESERVED;
   1529             }
   1530 
   1531             AcpiOsPrintf (UINT8_FORMAT, *Target,
   1532                 AcpiDmSratSubnames[Temp8]);
   1533             break;
   1534 
   1535         case ACPI_DMT_TPM2:
   1536 
   1537             /* TPM2 Start Method types */
   1538 
   1539             Temp8 = *Target;
   1540             if (Temp8 > ACPI_TPM2_RESERVED)
   1541             {
   1542                 Temp8 = ACPI_TPM2_RESERVED;
   1543             }
   1544 
   1545             AcpiOsPrintf (UINT8_FORMAT, *Target,
   1546                 AcpiDmTpm2Subnames[Temp8]);
   1547             break;
   1548 
   1549 
   1550         case ACPI_DMT_FADTPM:
   1551 
   1552             /* FADT Preferred PM Profile names */
   1553 
   1554             Temp8 = *Target;
   1555             if (Temp8 > ACPI_FADT_PM_RESERVED)
   1556             {
   1557                 Temp8 = ACPI_FADT_PM_RESERVED;
   1558             }
   1559 
   1560             AcpiOsPrintf (UINT8_FORMAT, *Target,
   1561                 AcpiDmFadtProfiles[Temp8]);
   1562             break;
   1563 
   1564         case ACPI_DMT_IVRS:
   1565 
   1566             /* IVRS subtable types */
   1567 
   1568             Temp8 = *Target;
   1569             switch (Temp8)
   1570             {
   1571             case ACPI_IVRS_TYPE_HARDWARE:
   1572 
   1573                 Name = AcpiDmIvrsSubnames[0];
   1574                 break;
   1575 
   1576             case ACPI_IVRS_TYPE_MEMORY1:
   1577             case ACPI_IVRS_TYPE_MEMORY2:
   1578             case ACPI_IVRS_TYPE_MEMORY3:
   1579 
   1580                 Name = AcpiDmIvrsSubnames[1];
   1581                 break;
   1582 
   1583             default:
   1584 
   1585                 Name = AcpiDmIvrsSubnames[2];
   1586                 break;
   1587             }
   1588 
   1589             AcpiOsPrintf (UINT8_FORMAT, *Target, Name);
   1590             break;
   1591 
   1592         case ACPI_DMT_LPIT:
   1593 
   1594             /* LPIT subtable types */
   1595 
   1596             Temp32 = ACPI_GET32 (Target);
   1597             if (Temp32 > ACPI_LPIT_TYPE_RESERVED)
   1598             {
   1599                 Temp32 = ACPI_LPIT_TYPE_RESERVED;
   1600             }
   1601 
   1602             AcpiOsPrintf (UINT32_FORMAT, ACPI_GET32 (Target),
   1603                 AcpiDmLpitSubnames[Temp32]);
   1604             break;
   1605 
   1606         case ACPI_DMT_EXIT:
   1607 
   1608             return (AE_OK);
   1609 
   1610         default:
   1611 
   1612             ACPI_ERROR ((AE_INFO,
   1613                 "**** Invalid table opcode [0x%X] ****\n", Info->Opcode));
   1614             return (AE_SUPPORT);
   1615         }
   1616     }
   1617 
   1618     if (TableOffset && !SubtableLength)
   1619     {
   1620         /*
   1621          * If this table is not the main table, the subtable must have a
   1622          * valid length
   1623          */
   1624         AcpiOsPrintf ("Invalid zero length subtable\n");
   1625         return (AE_BAD_DATA);
   1626     }
   1627 
   1628     return (AE_OK);
   1629 }
   1630