xref: /illumos-gate/usr/src/cmd/acpi/common/dmtable.c (revision 66582b606a8194f7f3ba5b3a3a6dca5b0d346361)
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 - 2018, 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 "acpi.h"
153 #include "accommon.h"
154 #include "acdisasm.h"
155 #include "actables.h"
156 #include "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 Subystem Address Range",
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     "Unknown Subtable Type"         /* Reserved */
404 };
405 
406 static const char           *AcpiDmTpm2Subnames[] =
407 {
408     "Illegal Start Method value",
409     "Reserved",
410     "ACPI Start Method",
411     "Reserved",
412     "Reserved",
413     "Reserved",
414     "Memory Mapped I/O",
415     "Command Response Buffer",
416     "Command Response Buffer with ACPI Start Method",
417     "Reserved",
418     "Reserved",
419     "Command Response Buffer with ARM SMC",
420     "Unknown Subtable Type"         /* Reserved */
421 };
422 
423 static const char           *AcpiDmIvrsSubnames[] =
424 {
425     "Hardware Definition Block",
426     "Memory Definition Block",
427     "Unknown Subtable Type"         /* Reserved */
428 };
429 
430 static const char           *AcpiDmLpitSubnames[] =
431 {
432     "Native C-state Idle Structure",
433     "Unknown Subtable Type"         /* Reserved */
434 };
435 
436 #define ACPI_FADT_PM_RESERVED       9
437 
438 static const char           *AcpiDmFadtProfiles[] =
439 {
440     "Unspecified",
441     "Desktop",
442     "Mobile",
443     "Workstation",
444     "Enterprise Server",
445     "SOHO Server",
446     "Appliance PC",
447     "Performance Server",
448     "Tablet",
449     "Unknown Profile Type"
450 };
451 
452 #define ACPI_GAS_WIDTH_RESERVED     5
453 
454 static const char           *AcpiDmGasAccessWidth[] =
455 {
456     "Undefined/Legacy",
457     "Byte Access:8",
458     "Word Access:16",
459     "DWord Access:32",
460     "QWord Access:64",
461     "Unknown Width Encoding"
462 };
463 
464 
465 /*******************************************************************************
466  *
467  * ACPI Table Data, indexed by signature.
468  *
469  * Each entry contains: Signature, Table Info, Handler, DtHandler,
470  *  Template, Description
471  *
472  * Simple tables have only a TableInfo structure, complex tables have a
473  * handler. This table must be NULL terminated. RSDP and FACS are
474  * special-cased elsewhere.
475  *
476  * Note: Any tables added here should be duplicated within AcpiSupportedTables
477  * in the file common/ahtable.c
478  *
479  ******************************************************************************/
480 
481 const ACPI_DMTABLE_DATA     AcpiDmTableData[] =
482 {
483     {ACPI_SIG_ASF,  NULL,                   AcpiDmDumpAsf,  DtCompileAsf,   TemplateAsf},
484     {ACPI_SIG_BERT, AcpiDmTableInfoBert,    NULL,           NULL,           TemplateBert},
485     {ACPI_SIG_BGRT, AcpiDmTableInfoBgrt,    NULL,           NULL,           TemplateBgrt},
486     {ACPI_SIG_BOOT, AcpiDmTableInfoBoot,    NULL,           NULL,           TemplateBoot},
487     {ACPI_SIG_CPEP, NULL,                   AcpiDmDumpCpep, DtCompileCpep,  TemplateCpep},
488     {ACPI_SIG_CSRT, NULL,                   AcpiDmDumpCsrt, DtCompileCsrt,  TemplateCsrt},
489     {ACPI_SIG_DBG2, AcpiDmTableInfoDbg2,    AcpiDmDumpDbg2, DtCompileDbg2,  TemplateDbg2},
490     {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp,    NULL,           NULL,           TemplateDbgp},
491     {ACPI_SIG_DMAR, NULL,                   AcpiDmDumpDmar, DtCompileDmar,  TemplateDmar},
492     {ACPI_SIG_DRTM, NULL,                   AcpiDmDumpDrtm, DtCompileDrtm,  TemplateDrtm},
493     {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt,    NULL,           NULL,           TemplateEcdt},
494     {ACPI_SIG_EINJ, NULL,                   AcpiDmDumpEinj, DtCompileEinj,  TemplateEinj},
495     {ACPI_SIG_ERST, NULL,                   AcpiDmDumpErst, DtCompileErst,  TemplateErst},
496     {ACPI_SIG_FADT, NULL,                   AcpiDmDumpFadt, DtCompileFadt,  TemplateFadt},
497     {ACPI_SIG_FPDT, NULL,                   AcpiDmDumpFpdt, DtCompileFpdt,  TemplateFpdt},
498     {ACPI_SIG_GTDT, NULL,                   AcpiDmDumpGtdt, DtCompileGtdt,  TemplateGtdt},
499     {ACPI_SIG_HEST, NULL,                   AcpiDmDumpHest, DtCompileHest,  TemplateHest},
500     {ACPI_SIG_HMAT, NULL,                   AcpiDmDumpHmat, DtCompileHmat,  TemplateHmat},
501     {ACPI_SIG_HPET, AcpiDmTableInfoHpet,    NULL,           NULL,           TemplateHpet},
502     {ACPI_SIG_IORT, NULL,                   AcpiDmDumpIort, DtCompileIort,  TemplateIort},
503     {ACPI_SIG_IVRS, NULL,                   AcpiDmDumpIvrs, DtCompileIvrs,  TemplateIvrs},
504     {ACPI_SIG_LPIT, NULL,                   AcpiDmDumpLpit, DtCompileLpit,  TemplateLpit},
505     {ACPI_SIG_MADT, NULL,                   AcpiDmDumpMadt, DtCompileMadt,  TemplateMadt},
506     {ACPI_SIG_MCFG, NULL,                   AcpiDmDumpMcfg, DtCompileMcfg,  TemplateMcfg},
507     {ACPI_SIG_MCHI, AcpiDmTableInfoMchi,    NULL,           NULL,           TemplateMchi},
508     {ACPI_SIG_MPST, AcpiDmTableInfoMpst,    AcpiDmDumpMpst, DtCompileMpst,  TemplateMpst},
509     {ACPI_SIG_MSCT, NULL,                   AcpiDmDumpMsct, DtCompileMsct,  TemplateMsct},
510     {ACPI_SIG_MSDM, NULL,                   AcpiDmDumpSlic, DtCompileSlic,  TemplateMsdm},
511     {ACPI_SIG_MTMR, NULL,                   AcpiDmDumpMtmr, DtCompileMtmr,  TemplateMtmr},
512     {ACPI_SIG_NFIT, AcpiDmTableInfoNfit,    AcpiDmDumpNfit, DtCompileNfit,  TemplateNfit},
513     {ACPI_SIG_PCCT, AcpiDmTableInfoPcct,    AcpiDmDumpPcct, DtCompilePcct,  TemplatePcct},
514     {ACPI_SIG_PDTT, AcpiDmTableInfoPdtt,    AcpiDmDumpPdtt, DtCompilePdtt,  TemplatePdtt},
515     {ACPI_SIG_PMTT, NULL,                   AcpiDmDumpPmtt, DtCompilePmtt,  TemplatePmtt},
516     {ACPI_SIG_PPTT, NULL,                   AcpiDmDumpPptt, DtCompilePptt,  TemplatePptt},
517     {ACPI_SIG_RASF, AcpiDmTableInfoRasf,    NULL,           NULL,           TemplateRasf},
518     {ACPI_SIG_RSDT, NULL,                   AcpiDmDumpRsdt, DtCompileRsdt,  TemplateRsdt},
519     {ACPI_SIG_S3PT, NULL,                   NULL,           NULL,           TemplateS3pt},
520     {ACPI_SIG_SBST, AcpiDmTableInfoSbst,    NULL,           NULL,           TemplateSbst},
521     {ACPI_SIG_SDEI, AcpiDmTableInfoSdei,    NULL,           NULL,           TemplateSdei},
522     {ACPI_SIG_SDEV, AcpiDmTableInfoSdev,    AcpiDmDumpSdev, DtCompileSdev,  TemplateSdev},
523     {ACPI_SIG_SLIC, NULL,                   AcpiDmDumpSlic, DtCompileSlic,  TemplateSlic},
524     {ACPI_SIG_SLIT, NULL,                   AcpiDmDumpSlit, DtCompileSlit,  TemplateSlit},
525     {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr,    NULL,           NULL,           TemplateSpcr},
526     {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi,    NULL,           NULL,           TemplateSpmi},
527     {ACPI_SIG_SRAT, NULL,                   AcpiDmDumpSrat, DtCompileSrat,  TemplateSrat},
528     {ACPI_SIG_STAO, NULL,                   AcpiDmDumpStao, DtCompileStao,  TemplateStao},
529     {ACPI_SIG_TCPA, NULL,                   AcpiDmDumpTcpa, DtCompileTcpa,  TemplateTcpa},
530     {ACPI_SIG_TPM2, AcpiDmTableInfoTpm2,    AcpiDmDumpTpm2, DtCompileTpm2,  TemplateTpm2},
531     {ACPI_SIG_UEFI, AcpiDmTableInfoUefi,    NULL,           DtCompileUefi,  TemplateUefi},
532     {ACPI_SIG_VRTC, AcpiDmTableInfoVrtc,    AcpiDmDumpVrtc, DtCompileVrtc,  TemplateVrtc},
533     {ACPI_SIG_WAET, AcpiDmTableInfoWaet,    NULL,           NULL,           TemplateWaet},
534     {ACPI_SIG_WDAT, NULL,                   AcpiDmDumpWdat, DtCompileWdat,  TemplateWdat},
535     {ACPI_SIG_WDDT, AcpiDmTableInfoWddt,    NULL,           NULL,           TemplateWddt},
536     {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt,    NULL,           NULL,           TemplateWdrt},
537     {ACPI_SIG_WPBT, NULL,                   AcpiDmDumpWpbt, DtCompileWpbt,  TemplateWpbt},
538     {ACPI_SIG_WSMT, AcpiDmTableInfoWsmt,    NULL,           NULL,           TemplateWsmt},
539     {ACPI_SIG_XENV, AcpiDmTableInfoXenv,    NULL,           NULL,           TemplateXenv},
540     {ACPI_SIG_XSDT, NULL,                   AcpiDmDumpXsdt, DtCompileXsdt,  TemplateXsdt},
541     {NULL,          NULL,                   NULL,           NULL,           NULL}
542 };
543 
544 
545 /*******************************************************************************
546  *
547  * FUNCTION:    AcpiDmGenerateChecksum
548  *
549  * PARAMETERS:  Table               - Pointer to table to be checksummed
550  *              Length              - Length of the table
551  *              OriginalChecksum    - Value of the checksum field
552  *
553  * RETURN:      8 bit checksum of buffer
554  *
555  * DESCRIPTION: Computes an 8 bit checksum of the table.
556  *
557  ******************************************************************************/
558 
559 UINT8
560 AcpiDmGenerateChecksum (
561     void                    *Table,
562     UINT32                  Length,
563     UINT8                   OriginalChecksum)
564 {
565     UINT8                   Checksum;
566 
567 
568     /* Sum the entire table as-is */
569 
570     Checksum = AcpiTbChecksum ((UINT8 *) Table, Length);
571 
572     /* Subtract off the existing checksum value in the table */
573 
574     Checksum = (UINT8) (Checksum - OriginalChecksum);
575 
576     /* Compute the final checksum */
577 
578     Checksum = (UINT8) (0 - Checksum);
579     return (Checksum);
580 }
581 
582 
583 /*******************************************************************************
584  *
585  * FUNCTION:    AcpiDmGetTableData
586  *
587  * PARAMETERS:  Signature           - ACPI signature (4 chars) to match
588  *
589  * RETURN:      Pointer to a valid ACPI_DMTABLE_DATA. Null if no match found.
590  *
591  * DESCRIPTION: Find a match in the global table of supported ACPI tables
592  *
593  ******************************************************************************/
594 
595 const ACPI_DMTABLE_DATA *
596 AcpiDmGetTableData (
597     char                    *Signature)
598 {
599     const ACPI_DMTABLE_DATA *Info;
600 
601 
602     for (Info = AcpiDmTableData; Info->Signature; Info++)
603     {
604         if (ACPI_COMPARE_NAME (Signature, Info->Signature))
605         {
606             return (Info);
607         }
608     }
609 
610     return (NULL);
611 }
612 
613 
614 /*******************************************************************************
615  *
616  * FUNCTION:    AcpiDmDumpDataTable
617  *
618  * PARAMETERS:  Table               - An ACPI table
619  *
620  * RETURN:      None.
621  *
622  * DESCRIPTION: Format the contents of an ACPI data table (any table other
623  *              than an SSDT or DSDT that does not contain executable AML code)
624  *
625  ******************************************************************************/
626 
627 void
628 AcpiDmDumpDataTable (
629     ACPI_TABLE_HEADER       *Table)
630 {
631     ACPI_STATUS             Status;
632     const ACPI_DMTABLE_DATA *TableData;
633     UINT32                  Length;
634 
635 
636     /* Ignore tables that contain AML */
637 
638     if (AcpiUtIsAmlTable (Table))
639     {
640         if (Gbl_VerboseTemplates)
641         {
642             /* Dump the raw table data */
643 
644             Length = Table->Length;
645 
646             AcpiOsPrintf ("\n/*\n%s: Length %d (0x%X)\n\n",
647                 ACPI_RAW_TABLE_DATA_HEADER, Length, Length);
648             AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table),
649                 Length, DB_BYTE_DISPLAY, 0);
650             AcpiOsPrintf (" */\n");
651         }
652         return;
653     }
654 
655     /*
656      * Handle tables that don't use the common ACPI table header structure.
657      * Currently, these are the FACS, RSDP, and S3PT.
658      */
659     if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS))
660     {
661         Length = Table->Length;
662         Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFacs);
663         if (ACPI_FAILURE (Status))
664         {
665             return;
666         }
667     }
668     else if (ACPI_VALIDATE_RSDP_SIG (Table->Signature))
669     {
670         Length = AcpiDmDumpRsdp (Table);
671     }
672     else if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_S3PT))
673     {
674         Length = AcpiDmDumpS3pt (Table);
675     }
676     else
677     {
678         /*
679          * All other tables must use the common ACPI table header, dump it now
680          */
681         Length = Table->Length;
682         Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHeader);
683         if (ACPI_FAILURE (Status))
684         {
685             return;
686         }
687         AcpiOsPrintf ("\n");
688 
689         /* Match signature and dispatch appropriately */
690 
691         TableData = AcpiDmGetTableData (Table->Signature);
692         if (!TableData)
693         {
694             if (!strncmp (Table->Signature, "OEM", 3))
695             {
696                 AcpiOsPrintf ("\n**** OEM-defined ACPI table [%4.4s], unknown contents\n\n",
697                     Table->Signature);
698             }
699             else
700             {
701                 AcpiOsPrintf ("\n**** Unknown ACPI table signature [%4.4s]\n\n",
702                     Table->Signature);
703 
704                 fprintf (stderr, "Unknown ACPI table signature [%4.4s], ",
705                     Table->Signature);
706 
707                 if (!AcpiGbl_ForceAmlDisassembly)
708                 {
709                     fprintf (stderr, "decoding ACPI table header only\n");
710                 }
711                 else
712                 {
713                     fprintf (stderr, "assuming table contains valid AML code\n");
714                 }
715             }
716         }
717         else if (TableData->TableHandler)
718         {
719             /* Complex table, has a handler */
720 
721             TableData->TableHandler (Table);
722         }
723         else if (TableData->TableInfo)
724         {
725             /* Simple table, just walk the info table */
726 
727             Status = AcpiDmDumpTable (Length, 0, Table, 0, TableData->TableInfo);
728             if (ACPI_FAILURE (Status))
729             {
730                 return;
731             }
732         }
733     }
734 
735     if (!Gbl_DoTemplates || Gbl_VerboseTemplates)
736     {
737         /* Dump the raw table data */
738 
739         AcpiOsPrintf ("\n%s: Length %d (0x%X)\n\n",
740             ACPI_RAW_TABLE_DATA_HEADER, Length, Length);
741         AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table),
742             Length, DB_BYTE_DISPLAY, 0);
743     }
744 }
745 
746 
747 /*******************************************************************************
748  *
749  * FUNCTION:    AcpiDmLineHeader
750  *
751  * PARAMETERS:  Offset              - Current byte offset, from table start
752  *              ByteLength          - Length of the field in bytes, 0 for flags
753  *              Name                - Name of this field
754  *
755  * RETURN:      None
756  *
757  * DESCRIPTION: Utility routines for formatting output lines. Displays the
758  *              current table offset in hex and decimal, the field length,
759  *              and the field name.
760  *
761  ******************************************************************************/
762 
763 void
764 AcpiDmLineHeader (
765     UINT32                  Offset,
766     UINT32                  ByteLength,
767     char                    *Name)
768 {
769 
770     /* Allow a null name for fields that span multiple lines (large buffers) */
771 
772     if (!Name)
773     {
774         Name = "";
775     }
776 
777     if (Gbl_DoTemplates && !Gbl_VerboseTemplates) /* Terse template */
778     {
779         if (ByteLength)
780         {
781             AcpiOsPrintf ("[%.4d] %34s : ", ByteLength, Name);
782         }
783         else
784         {
785             if (*Name)
786             {
787                 AcpiOsPrintf ("%41s : ", Name);
788             }
789             else
790             {
791                 AcpiOsPrintf ("%41s   ", Name);
792             }
793         }
794     }
795     else /* Normal disassembler or verbose template */
796     {
797         if (ByteLength)
798         {
799             AcpiOsPrintf ("[%3.3Xh %4.4d% 4d] %28s : ",
800                 Offset, Offset, ByteLength, Name);
801         }
802         else
803         {
804             if (*Name)
805             {
806                 AcpiOsPrintf ("%44s : ", Name);
807             }
808             else
809             {
810                 AcpiOsPrintf ("%44s   ", Name);
811             }
812         }
813     }
814 }
815 
816 void
817 AcpiDmLineHeader2 (
818     UINT32                  Offset,
819     UINT32                  ByteLength,
820     char                    *Name,
821     UINT32                  Value)
822 {
823 
824     if (Gbl_DoTemplates && !Gbl_VerboseTemplates) /* Terse template */
825     {
826         if (ByteLength)
827         {
828             AcpiOsPrintf ("[%.4d] %30s %3d : ",
829                 ByteLength, Name, Value);
830         }
831         else
832         {
833             AcpiOsPrintf ("%36s % 3d : ",
834                 Name, Value);
835         }
836     }
837     else /* Normal disassembler or verbose template */
838     {
839         if (ByteLength)
840         {
841             AcpiOsPrintf ("[%3.3Xh %4.4d %3d] %24s %3d : ",
842                 Offset, Offset, ByteLength, Name, Value);
843         }
844         else
845         {
846             AcpiOsPrintf ("[%3.3Xh %4.4d   ] %24s %3d : ",
847                 Offset, Offset, Name, Value);
848         }
849     }
850 }
851 
852 
853 /*******************************************************************************
854  *
855  * FUNCTION:    AcpiDmDumpTable
856  *
857  * PARAMETERS:  TableLength         - Length of the entire ACPI table
858  *              TableOffset         - Starting offset within the table for this
859  *                                    sub-descriptor (0 if main table)
860  *              Table               - The ACPI table
861  *              SubtableLength      - Length of this sub-descriptor
862  *              Info                - Info table for this ACPI table
863  *
864  * RETURN:      Status
865  *
866  * DESCRIPTION: Display ACPI table contents by walking the Info table.
867  *
868  * Note: This function must remain in sync with DtGetFieldLength.
869  *
870  ******************************************************************************/
871 
872 ACPI_STATUS
873 AcpiDmDumpTable (
874     UINT32                  TableLength,
875     UINT32                  TableOffset,
876     void                    *Table,
877     UINT32                  SubtableLength,
878     ACPI_DMTABLE_INFO       *Info)
879 {
880     UINT8                   *Target;
881     UINT32                  CurrentOffset;
882     UINT32                  ByteLength;
883     UINT8                   Temp8;
884     UINT16                  Temp16;
885     UINT32                  Temp32;
886     UINT64                  Value;
887     const AH_TABLE          *TableData;
888     const char              *Name;
889     BOOLEAN                 LastOutputBlankLine = FALSE;
890     ACPI_STATUS             Status;
891     char                    RepairedName[8];
892 
893 
894     if (!Info)
895     {
896         AcpiOsPrintf ("Display not implemented\n");
897         return (AE_NOT_IMPLEMENTED);
898     }
899 
900     /* Walk entire Info table; Null name terminates */
901 
902     for (; Info->Name; Info++)
903     {
904         /*
905          * Target points to the field within the ACPI Table. CurrentOffset is
906          * the offset of the field from the start of the main table.
907          */
908         Target = ACPI_ADD_PTR (UINT8, Table, Info->Offset);
909         CurrentOffset = TableOffset + Info->Offset;
910 
911         /* Check for beyond subtable end or (worse) beyond EOT */
912 
913         if (SubtableLength && (Info->Offset >= SubtableLength))
914         {
915             AcpiOsPrintf (
916                 "/**** ACPI subtable terminates early - "
917                 "may be older version (dump table) */\n");
918 
919             /* Move on to next subtable */
920 
921             return (AE_OK);
922         }
923 
924         if (CurrentOffset >= TableLength)
925         {
926             AcpiOsPrintf (
927                 "/**** ACPI table terminates "
928                 "in the middle of a data structure! (dump table) */\n");
929             return (AE_BAD_DATA);
930         }
931 
932         /* Generate the byte length for this field */
933 
934         switch (Info->Opcode)
935         {
936         case ACPI_DMT_UINT8:
937         case ACPI_DMT_CHKSUM:
938         case ACPI_DMT_SPACEID:
939         case ACPI_DMT_ACCWIDTH:
940         case ACPI_DMT_IVRS:
941         case ACPI_DMT_GTDT:
942         case ACPI_DMT_MADT:
943         case ACPI_DMT_PCCT:
944         case ACPI_DMT_PMTT:
945         case ACPI_DMT_PPTT:
946         case ACPI_DMT_SDEV:
947         case ACPI_DMT_SRAT:
948         case ACPI_DMT_ASF:
949         case ACPI_DMT_HESTNTYP:
950         case ACPI_DMT_FADTPM:
951         case ACPI_DMT_EINJACT:
952         case ACPI_DMT_EINJINST:
953         case ACPI_DMT_ERSTACT:
954         case ACPI_DMT_ERSTINST:
955         case ACPI_DMT_DMAR_SCOPE:
956 
957             ByteLength = 1;
958             break;
959 
960         case ACPI_DMT_UINT16:
961         case ACPI_DMT_DMAR:
962         case ACPI_DMT_HEST:
963         case ACPI_DMT_HMAT:
964         case ACPI_DMT_NFIT:
965 
966             ByteLength = 2;
967             break;
968 
969         case ACPI_DMT_UINT24:
970 
971             ByteLength = 3;
972             break;
973 
974         case ACPI_DMT_UINT32:
975         case ACPI_DMT_NAME4:
976         case ACPI_DMT_SIG:
977         case ACPI_DMT_LPIT:
978         case ACPI_DMT_TPM2:
979 
980             ByteLength = 4;
981             break;
982 
983         case ACPI_DMT_UINT40:
984 
985             ByteLength = 5;
986             break;
987 
988         case ACPI_DMT_UINT48:
989         case ACPI_DMT_NAME6:
990 
991             ByteLength = 6;
992             break;
993 
994         case ACPI_DMT_UINT56:
995         case ACPI_DMT_BUF7:
996 
997             ByteLength = 7;
998             break;
999 
1000         case ACPI_DMT_UINT64:
1001         case ACPI_DMT_NAME8:
1002 
1003             ByteLength = 8;
1004             break;
1005 
1006         case ACPI_DMT_BUF10:
1007 
1008             ByteLength = 10;
1009             break;
1010 
1011         case ACPI_DMT_BUF12:
1012 
1013             ByteLength = 12;
1014             break;
1015 
1016         case ACPI_DMT_BUF16:
1017         case ACPI_DMT_UUID:
1018 
1019             ByteLength = 16;
1020             break;
1021 
1022         case ACPI_DMT_BUF128:
1023 
1024             ByteLength = 128;
1025             break;
1026 
1027         case ACPI_DMT_UNICODE:
1028         case ACPI_DMT_BUFFER:
1029         case ACPI_DMT_RAW_BUFFER:
1030 
1031             ByteLength = SubtableLength;
1032             break;
1033 
1034         case ACPI_DMT_STRING:
1035 
1036             ByteLength = strlen (ACPI_CAST_PTR (char, Target)) + 1;
1037             break;
1038 
1039         case ACPI_DMT_GAS:
1040 
1041             if (!LastOutputBlankLine)
1042             {
1043                 AcpiOsPrintf ("\n");
1044                 LastOutputBlankLine = TRUE;
1045             }
1046 
1047             ByteLength = sizeof (ACPI_GENERIC_ADDRESS);
1048             break;
1049 
1050         case ACPI_DMT_HESTNTFY:
1051 
1052             if (!LastOutputBlankLine)
1053             {
1054                 AcpiOsPrintf ("\n");
1055                 LastOutputBlankLine = TRUE;
1056             }
1057 
1058             ByteLength = sizeof (ACPI_HEST_NOTIFY);
1059             break;
1060 
1061         case ACPI_DMT_IORTMEM:
1062 
1063             if (!LastOutputBlankLine)
1064             {
1065                 LastOutputBlankLine = FALSE;
1066             }
1067 
1068             ByteLength = sizeof (ACPI_IORT_MEMORY_ACCESS);
1069             break;
1070 
1071         default:
1072 
1073             ByteLength = 0;
1074             break;
1075         }
1076 
1077         /* Check if we are beyond a subtable, or (worse) beyond EOT */
1078 
1079         if (CurrentOffset + ByteLength > TableLength)
1080         {
1081             if (SubtableLength)
1082             {
1083                 AcpiOsPrintf (
1084                     "/**** ACPI subtable terminates early - "
1085                     "may be older version (dump table) */\n");
1086 
1087                 /* Move on to next subtable */
1088 
1089                 return (AE_OK);
1090             }
1091 
1092             AcpiOsPrintf (
1093                 "/**** ACPI table terminates "
1094                 "in the middle of a data structure! */\n");
1095             return (AE_BAD_DATA);
1096         }
1097 
1098         if (Info->Opcode == ACPI_DMT_EXTRA_TEXT)
1099         {
1100             AcpiOsPrintf ("%s", Info->Name);
1101             continue;
1102         }
1103 
1104         /* Start a new line and decode the opcode */
1105 
1106         AcpiDmLineHeader (CurrentOffset, ByteLength, Info->Name);
1107 
1108         switch (Info->Opcode)
1109         {
1110         /* Single-bit Flag fields. Note: Opcode is the bit position */
1111 
1112         case ACPI_DMT_FLAG0:
1113         case ACPI_DMT_FLAG1:
1114         case ACPI_DMT_FLAG2:
1115         case ACPI_DMT_FLAG3:
1116         case ACPI_DMT_FLAG4:
1117         case ACPI_DMT_FLAG5:
1118         case ACPI_DMT_FLAG6:
1119         case ACPI_DMT_FLAG7:
1120 
1121             AcpiOsPrintf ("%1.1X\n", (*Target >> Info->Opcode) & 0x01);
1122             break;
1123 
1124         /* 2-bit Flag fields */
1125 
1126         case ACPI_DMT_FLAGS0:
1127 
1128             AcpiOsPrintf ("%1.1X\n", *Target & 0x03);
1129             break;
1130 
1131         case ACPI_DMT_FLAGS1:
1132 
1133             AcpiOsPrintf ("%1.1X\n", (*Target >> 1) & 0x03);
1134             break;
1135 
1136         case ACPI_DMT_FLAGS2:
1137 
1138             AcpiOsPrintf ("%1.1X\n", (*Target >> 2) & 0x03);
1139             break;
1140 
1141         case ACPI_DMT_FLAGS4:
1142 
1143             AcpiOsPrintf ("%1.1X\n", (*Target >> 4) & 0x03);
1144             break;
1145 
1146         case ACPI_DMT_FLAGS4_0:
1147 
1148             AcpiOsPrintf ("%1.1X\n", (*(UINT32 *)Target) & 0x0F);
1149             break;
1150 
1151         case ACPI_DMT_FLAGS4_4:
1152 
1153             AcpiOsPrintf ("%1.1X\n", (*(UINT32 *)Target >> 4) & 0x0F);
1154             break;
1155 
1156         case ACPI_DMT_FLAGS4_8:
1157 
1158             AcpiOsPrintf ("%1.1X\n", (*(UINT32 *)Target >> 8) & 0x0F);
1159             break;
1160 
1161         case ACPI_DMT_FLAGS4_12:
1162 
1163             AcpiOsPrintf ("%1.1X\n", (*(UINT32 *)Target >> 12) & 0x0F);
1164             break;
1165 
1166         case ACPI_DMT_FLAGS16_16:
1167 
1168             AcpiOsPrintf ("%4.4X\n", (*(UINT32 *)Target >> 16) & 0xFFFF);
1169             break;
1170 
1171         /* Integer Data Types */
1172 
1173         case ACPI_DMT_UINT8:
1174         case ACPI_DMT_UINT16:
1175         case ACPI_DMT_UINT24:
1176         case ACPI_DMT_UINT32:
1177         case ACPI_DMT_UINT40:
1178         case ACPI_DMT_UINT48:
1179         case ACPI_DMT_UINT56:
1180         case ACPI_DMT_UINT64:
1181             /*
1182              * Dump bytes - high byte first, low byte last.
1183              * Note: All ACPI tables are little-endian.
1184              */
1185             Value = 0;
1186             for (Temp8 = (UINT8) ByteLength; Temp8 > 0; Temp8--)
1187             {
1188                 AcpiOsPrintf ("%2.2X", Target[Temp8 - 1]);
1189                 Value |= Target[Temp8 - 1];
1190                 Value <<= 8;
1191             }
1192 
1193             if (!Value && (Info->Flags & DT_DESCRIBES_OPTIONAL))
1194             {
1195                 AcpiOsPrintf (" [Optional field not present]");
1196             }
1197 
1198             AcpiOsPrintf ("\n");
1199             break;
1200 
1201         case ACPI_DMT_BUF7:
1202         case ACPI_DMT_BUF10:
1203         case ACPI_DMT_BUF12:
1204         case ACPI_DMT_BUF16:
1205         case ACPI_DMT_BUF128:
1206             /*
1207              * Buffer: Size depends on the opcode and was set above.
1208              * Each hex byte is separated with a space.
1209              * Multiple lines are separated by line continuation char.
1210              */
1211             for (Temp16 = 0; Temp16 < ByteLength; Temp16++)
1212             {
1213                 AcpiOsPrintf ("%2.2X", Target[Temp16]);
1214                 if ((UINT32) (Temp16 + 1) < ByteLength)
1215                 {
1216                     if ((Temp16 > 0) && (!((Temp16+1) % 16)))
1217                     {
1218                         AcpiOsPrintf (" \\\n"); /* Line continuation */
1219                         AcpiDmLineHeader (0, 0, NULL);
1220                     }
1221                     else
1222                     {
1223                         AcpiOsPrintf (" ");
1224                     }
1225                 }
1226             }
1227 
1228             AcpiOsPrintf ("\n");
1229             break;
1230 
1231         case ACPI_DMT_UUID:
1232 
1233             /* Convert 16-byte UUID buffer to 36-byte formatted UUID string */
1234 
1235             (void) AuConvertUuidToString ((char *) Target, MsgBuffer);
1236 
1237             AcpiOsPrintf ("%s\n", MsgBuffer);
1238             break;
1239 
1240         case ACPI_DMT_STRING:
1241 
1242             AcpiOsPrintf ("\"%s\"\n", ACPI_CAST_PTR (char, Target));
1243             break;
1244 
1245         /* Fixed length ASCII name fields */
1246 
1247         case ACPI_DMT_SIG:
1248 
1249             AcpiUtCheckAndRepairAscii (Target, RepairedName, 4);
1250             AcpiOsPrintf ("\"%.4s\"    ", RepairedName);
1251 
1252             TableData = AcpiAhGetTableInfo (ACPI_CAST_PTR (char, Target));
1253             if (TableData)
1254             {
1255                 AcpiOsPrintf (STRING_FORMAT, TableData->Description);
1256             }
1257             else
1258             {
1259                 AcpiOsPrintf ("\n");
1260             }
1261             break;
1262 
1263         case ACPI_DMT_NAME4:
1264 
1265             AcpiUtCheckAndRepairAscii (Target, RepairedName, 4);
1266             AcpiOsPrintf ("\"%.4s\"\n", RepairedName);
1267             break;
1268 
1269         case ACPI_DMT_NAME6:
1270 
1271             AcpiUtCheckAndRepairAscii (Target, RepairedName, 6);
1272             AcpiOsPrintf ("\"%.6s\"\n", RepairedName);
1273             break;
1274 
1275         case ACPI_DMT_NAME8:
1276 
1277             AcpiUtCheckAndRepairAscii (Target, RepairedName, 8);
1278             AcpiOsPrintf ("\"%.8s\"\n", RepairedName);
1279             break;
1280 
1281         /* Special Data Types */
1282 
1283         case ACPI_DMT_CHKSUM:
1284 
1285             /* Checksum, display and validate */
1286 
1287             AcpiOsPrintf ("%2.2X", *Target);
1288             Temp8 = AcpiDmGenerateChecksum (Table,
1289                 ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length,
1290                 ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum);
1291 
1292             if (Temp8 != ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum)
1293             {
1294                 AcpiOsPrintf (
1295                     "     /* Incorrect checksum, should be %2.2X */", Temp8);
1296             }
1297 
1298             AcpiOsPrintf ("\n");
1299             break;
1300 
1301         case ACPI_DMT_SPACEID:
1302 
1303             /* Address Space ID */
1304 
1305             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiUtGetRegionName (*Target));
1306             break;
1307 
1308         case ACPI_DMT_ACCWIDTH:
1309 
1310             /* Encoded Access Width */
1311 
1312             Temp8 = *Target;
1313             if (Temp8 > ACPI_GAS_WIDTH_RESERVED)
1314             {
1315                 Temp8 = ACPI_GAS_WIDTH_RESERVED;
1316             }
1317 
1318             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmGasAccessWidth[Temp8]);
1319             break;
1320 
1321         case ACPI_DMT_GAS:
1322 
1323             /* Generic Address Structure */
1324 
1325             AcpiOsPrintf (STRING_FORMAT, "Generic Address Structure");
1326             Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1327                 sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas);
1328             if (ACPI_FAILURE (Status))
1329             {
1330                 return (Status);
1331             }
1332 
1333             AcpiOsPrintf ("\n");
1334             LastOutputBlankLine = TRUE;
1335             break;
1336 
1337         case ACPI_DMT_ASF:
1338 
1339             /* ASF subtable types */
1340 
1341             Temp16 = (UINT16) ((*Target) & 0x7F);  /* Top bit can be zero or one */
1342             if (Temp16 > ACPI_ASF_TYPE_RESERVED)
1343             {
1344                 Temp16 = ACPI_ASF_TYPE_RESERVED;
1345             }
1346 
1347             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmAsfSubnames[Temp16]);
1348             break;
1349 
1350         case ACPI_DMT_DMAR:
1351 
1352             /* DMAR subtable types */
1353 
1354             Temp16 = ACPI_GET16 (Target);
1355             if (Temp16 > ACPI_DMAR_TYPE_RESERVED)
1356             {
1357                 Temp16 = ACPI_DMAR_TYPE_RESERVED;
1358             }
1359 
1360             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1361                 AcpiDmDmarSubnames[Temp16]);
1362             break;
1363 
1364         case ACPI_DMT_DMAR_SCOPE:
1365 
1366             /* DMAR device scope types */
1367 
1368             Temp8 = *Target;
1369             if (Temp8 > ACPI_DMAR_SCOPE_TYPE_RESERVED)
1370             {
1371                 Temp8 = ACPI_DMAR_SCOPE_TYPE_RESERVED;
1372             }
1373 
1374             AcpiOsPrintf (UINT8_FORMAT, *Target,
1375                 AcpiDmDmarScope[Temp8]);
1376             break;
1377 
1378         case ACPI_DMT_EINJACT:
1379 
1380             /* EINJ Action types */
1381 
1382             Temp8 = *Target;
1383             if (Temp8 > ACPI_EINJ_ACTION_RESERVED)
1384             {
1385                 Temp8 = ACPI_EINJ_ACTION_RESERVED;
1386             }
1387 
1388             AcpiOsPrintf (UINT8_FORMAT, *Target,
1389                 AcpiDmEinjActions[Temp8]);
1390             break;
1391 
1392         case ACPI_DMT_EINJINST:
1393 
1394             /* EINJ Instruction types */
1395 
1396             Temp8 = *Target;
1397             if (Temp8 > ACPI_EINJ_INSTRUCTION_RESERVED)
1398             {
1399                 Temp8 = ACPI_EINJ_INSTRUCTION_RESERVED;
1400             }
1401 
1402             AcpiOsPrintf (UINT8_FORMAT, *Target,
1403                 AcpiDmEinjInstructions[Temp8]);
1404             break;
1405 
1406         case ACPI_DMT_ERSTACT:
1407 
1408             /* ERST Action types */
1409 
1410             Temp8 = *Target;
1411             if (Temp8 > ACPI_ERST_ACTION_RESERVED)
1412             {
1413                 Temp8 = ACPI_ERST_ACTION_RESERVED;
1414             }
1415 
1416             AcpiOsPrintf (UINT8_FORMAT, *Target,
1417                 AcpiDmErstActions[Temp8]);
1418             break;
1419 
1420         case ACPI_DMT_ERSTINST:
1421 
1422             /* ERST Instruction types */
1423 
1424             Temp8 = *Target;
1425             if (Temp8 > ACPI_ERST_INSTRUCTION_RESERVED)
1426             {
1427                 Temp8 = ACPI_ERST_INSTRUCTION_RESERVED;
1428             }
1429 
1430             AcpiOsPrintf (UINT8_FORMAT, *Target,
1431                 AcpiDmErstInstructions[Temp8]);
1432             break;
1433 
1434         case ACPI_DMT_GTDT:
1435 
1436             /* GTDT subtable types */
1437 
1438             Temp8 = *Target;
1439             if (Temp8 > ACPI_GTDT_TYPE_RESERVED)
1440             {
1441                 Temp8 = ACPI_GTDT_TYPE_RESERVED;
1442             }
1443 
1444             AcpiOsPrintf (UINT8_FORMAT, *Target,
1445                 AcpiDmGtdtSubnames[Temp8]);
1446             break;
1447 
1448         case ACPI_DMT_HEST:
1449 
1450             /* HEST subtable types */
1451 
1452             Temp16 = ACPI_GET16 (Target);
1453             if (Temp16 > ACPI_HEST_TYPE_RESERVED)
1454             {
1455                 Temp16 = ACPI_HEST_TYPE_RESERVED;
1456             }
1457 
1458             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1459                 AcpiDmHestSubnames[Temp16]);
1460             break;
1461 
1462         case ACPI_DMT_HESTNTFY:
1463 
1464             AcpiOsPrintf (STRING_FORMAT,
1465                 "Hardware Error Notification Structure");
1466 
1467             Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1468                 sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify);
1469             if (ACPI_FAILURE (Status))
1470             {
1471                 return (Status);
1472             }
1473 
1474             AcpiOsPrintf ("\n");
1475             LastOutputBlankLine = TRUE;
1476             break;
1477 
1478         case ACPI_DMT_HESTNTYP:
1479 
1480             /* HEST Notify types */
1481 
1482             Temp8 = *Target;
1483             if (Temp8 > ACPI_HEST_NOTIFY_RESERVED)
1484             {
1485                 Temp8 = ACPI_HEST_NOTIFY_RESERVED;
1486             }
1487 
1488             AcpiOsPrintf (UINT8_FORMAT, *Target,
1489                 AcpiDmHestNotifySubnames[Temp8]);
1490             break;
1491 
1492         case ACPI_DMT_HMAT:
1493 
1494             /* HMAT subtable types */
1495 
1496             Temp16 = *Target;
1497             if (Temp16 > ACPI_HMAT_TYPE_RESERVED)
1498             {
1499                 Temp16 = ACPI_HMAT_TYPE_RESERVED;
1500             }
1501 
1502             AcpiOsPrintf (UINT16_FORMAT, *Target,
1503                 AcpiDmHmatSubnames[Temp16]);
1504             break;
1505 
1506         case ACPI_DMT_IORTMEM:
1507 
1508             AcpiOsPrintf (STRING_FORMAT,
1509                 "IORT Memory Access Properties");
1510 
1511             Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1512                 sizeof (ACPI_IORT_MEMORY_ACCESS), AcpiDmTableInfoIortAcc);
1513             if (ACPI_FAILURE (Status))
1514             {
1515                 return (Status);
1516             }
1517 
1518             LastOutputBlankLine = TRUE;
1519             break;
1520 
1521         case ACPI_DMT_MADT:
1522 
1523             /* MADT subtable types */
1524 
1525             Temp8 = *Target;
1526             if (Temp8 > ACPI_MADT_TYPE_RESERVED)
1527             {
1528                 Temp8 = ACPI_MADT_TYPE_RESERVED;
1529             }
1530 
1531             AcpiOsPrintf (UINT8_FORMAT, *Target,
1532                 AcpiDmMadtSubnames[Temp8]);
1533             break;
1534 
1535         case ACPI_DMT_NFIT:
1536 
1537             /* NFIT subtable types */
1538 
1539             Temp16 = ACPI_GET16 (Target);
1540             if (Temp16 > ACPI_NFIT_TYPE_RESERVED)
1541             {
1542                 Temp16 = ACPI_NFIT_TYPE_RESERVED;
1543             }
1544 
1545             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1546                 AcpiDmNfitSubnames[Temp16]);
1547             break;
1548 
1549         case ACPI_DMT_PCCT:
1550 
1551             /* PCCT subtable types */
1552 
1553             Temp8 = *Target;
1554             if (Temp8 > ACPI_PCCT_TYPE_RESERVED)
1555             {
1556                 Temp8 = ACPI_PCCT_TYPE_RESERVED;
1557             }
1558 
1559             AcpiOsPrintf (UINT8_FORMAT, *Target,
1560                 AcpiDmPcctSubnames[Temp8]);
1561             break;
1562 
1563         case ACPI_DMT_PMTT:
1564 
1565             /* PMTT subtable types */
1566 
1567             Temp8 = *Target;
1568             if (Temp8 > ACPI_PMTT_TYPE_RESERVED)
1569             {
1570                 Temp8 = ACPI_PMTT_TYPE_RESERVED;
1571             }
1572 
1573             AcpiOsPrintf (UINT8_FORMAT, *Target,
1574                 AcpiDmPmttSubnames[Temp8]);
1575             break;
1576 
1577         case ACPI_DMT_PPTT:
1578 
1579             /* PPTT subtable types */
1580 
1581             Temp8 = *Target;
1582             if (Temp8 > ACPI_PPTT_TYPE_RESERVED)
1583             {
1584                 Temp8 = ACPI_PPTT_TYPE_RESERVED;
1585             }
1586 
1587             AcpiOsPrintf (UINT8_FORMAT, *Target,
1588                 AcpiDmPpttSubnames[Temp8]);
1589             break;
1590 
1591         case ACPI_DMT_UNICODE:
1592 
1593             if (ByteLength == 0)
1594             {
1595                 AcpiOsPrintf ("/* Zero-length Data */\n");
1596                 break;
1597             }
1598 
1599             AcpiDmDumpUnicode (Table, CurrentOffset, ByteLength);
1600             break;
1601 
1602         case ACPI_DMT_RAW_BUFFER:
1603 
1604             if (ByteLength == 0)
1605             {
1606                 AcpiOsPrintf ("/* Zero-length Data */\n");
1607                 break;
1608             }
1609 
1610             AcpiDmDumpBuffer (Table, CurrentOffset, ByteLength,
1611                 CurrentOffset, NULL);
1612             break;
1613 
1614         case ACPI_DMT_SDEV:
1615 
1616             /* SDEV subtable types */
1617 
1618             Temp8 = *Target;
1619             if (Temp8 > ACPI_SDEV_TYPE_RESERVED)
1620             {
1621                 Temp8 = ACPI_SDEV_TYPE_RESERVED;
1622             }
1623 
1624             AcpiOsPrintf (UINT8_FORMAT, *Target,
1625                 AcpiDmSdevSubnames[Temp8]);
1626             break;
1627 
1628         case ACPI_DMT_SRAT:
1629 
1630             /* SRAT subtable types */
1631 
1632             Temp8 = *Target;
1633             if (Temp8 > ACPI_SRAT_TYPE_RESERVED)
1634             {
1635                 Temp8 = ACPI_SRAT_TYPE_RESERVED;
1636             }
1637 
1638             AcpiOsPrintf (UINT8_FORMAT, *Target,
1639                 AcpiDmSratSubnames[Temp8]);
1640             break;
1641 
1642         case ACPI_DMT_TPM2:
1643 
1644             /* TPM2 Start Method types */
1645 
1646             Temp8 = *Target;
1647             if (Temp8 > ACPI_TPM2_RESERVED)
1648             {
1649                 Temp8 = ACPI_TPM2_RESERVED;
1650             }
1651 
1652             AcpiOsPrintf (UINT8_FORMAT, *Target,
1653                 AcpiDmTpm2Subnames[Temp8]);
1654             break;
1655 
1656 
1657         case ACPI_DMT_FADTPM:
1658 
1659             /* FADT Preferred PM Profile names */
1660 
1661             Temp8 = *Target;
1662             if (Temp8 > ACPI_FADT_PM_RESERVED)
1663             {
1664                 Temp8 = ACPI_FADT_PM_RESERVED;
1665             }
1666 
1667             AcpiOsPrintf (UINT8_FORMAT, *Target,
1668                 AcpiDmFadtProfiles[Temp8]);
1669             break;
1670 
1671         case ACPI_DMT_IVRS:
1672 
1673             /* IVRS subtable types */
1674 
1675             Temp8 = *Target;
1676             switch (Temp8)
1677             {
1678             case ACPI_IVRS_TYPE_HARDWARE:
1679 
1680                 Name = AcpiDmIvrsSubnames[0];
1681                 break;
1682 
1683             case ACPI_IVRS_TYPE_MEMORY1:
1684             case ACPI_IVRS_TYPE_MEMORY2:
1685             case ACPI_IVRS_TYPE_MEMORY3:
1686 
1687                 Name = AcpiDmIvrsSubnames[1];
1688                 break;
1689 
1690             default:
1691 
1692                 Name = AcpiDmIvrsSubnames[2];
1693                 break;
1694             }
1695 
1696             AcpiOsPrintf (UINT8_FORMAT, *Target, Name);
1697             break;
1698 
1699         case ACPI_DMT_LPIT:
1700 
1701             /* LPIT subtable types */
1702 
1703             Temp32 = ACPI_GET32 (Target);
1704             if (Temp32 > ACPI_LPIT_TYPE_RESERVED)
1705             {
1706                 Temp32 = ACPI_LPIT_TYPE_RESERVED;
1707             }
1708 
1709             AcpiOsPrintf (UINT32_FORMAT, ACPI_GET32 (Target),
1710                 AcpiDmLpitSubnames[Temp32]);
1711             break;
1712 
1713         case ACPI_DMT_EXIT:
1714 
1715             return (AE_OK);
1716 
1717         default:
1718 
1719             ACPI_ERROR ((AE_INFO,
1720                 "**** Invalid table opcode [0x%X] ****\n", Info->Opcode));
1721             return (AE_SUPPORT);
1722         }
1723     }
1724 
1725     if (TableOffset && !SubtableLength)
1726     {
1727         /*
1728          * If this table is not the main table, the subtable must have a
1729          * valid length
1730          */
1731         AcpiOsPrintf ("Invalid zero length subtable\n");
1732         return (AE_BAD_DATA);
1733     }
1734 
1735     return (AE_OK);
1736 }
1737