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