xref: /freebsd/sys/contrib/dev/acpica/common/dmtable.c (revision 7697e6c4df7188ee3a2aa66f73c572c27479bdf2)
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 - 2026, 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 UINT8_FORMAT_NO_NEWLINE "%2.2X [%s]"
172 #define UINT16_FORMAT           "%4.4X [%s]\n"
173 #define UINT32_FORMAT           "%8.8X [%s]\n"
174 #define STRING_FORMAT           "[%s]\n"
175 
176 /* These tables map a subtable type to a description string */
177 
178 static const char           *AcpiDmAestResourceNames[] =
179 {
180     "Cache Resource",
181     "TLB Resource",
182     "Generic Resource",
183     "Unknown Resource Type"         /* Reserved */
184 };
185 
186 static const char           *AcpiDmAestSubnames[] =
187 {
188     "Processor Error Node",
189     "Memory Error Node",
190     "SMMU Error Node",
191     "Vendor-defined Error Node",
192     "GIC Error Node",
193     "PCIE Error Node",
194     "PROXY Error Node",
195     "Unknown Subtable Type"         /* Reserved */
196 };
197 
198 static const char           *AcpiDmAestCacheNames[] =
199 {
200     "Data Cache",
201     "Instruction Cache",
202     "Unified Cache",
203     "Unknown Cache Type"            /* Reserved */
204 };
205 
206 static const char           *AcpiDmAestGicNames[] =
207 {
208     "GIC CPU",
209     "GIC Distributor",
210     "GIC Redistributor",
211     "GIC ITS",
212     "Unknown GIC Interface Type"    /* Reserved */
213 };
214 
215 static const char           *AcpiDmAestXfaceNames[] =
216 {
217     "System Register Interface",
218     "Memory Mapped Interface",
219     "Single Record Memory Mapped Interface",
220     "Unknown Interface Type"        /* Reserved */
221 };
222 
223 static const char           *AcpiDmAestXruptNames[] =
224 {
225     "Fault Handling Interrupt",
226     "Error Recovery Interrupt",
227     "Unknown Interrupt Type"        /* Reserved */
228 };
229 
230 static const char           *AcpiDmAsfSubnames[] =
231 {
232     "ASF Information",
233     "ASF Alerts",
234     "ASF Remote Control",
235     "ASF RMCP Boot Options",
236     "ASF Address",
237     "Unknown Subtable Type"         /* Reserved */
238 };
239 
240 static const char           *AcpiDmAsptSubnames[] =
241 {
242     "ASPT Global Registers",
243     "ASPT SEV Mailbox Registers",
244     "ASPT ACPI Mailbox Registers",
245     "Unknown Subtable Type"         /* Reserved */
246 };
247 
248 static const char           *AcpiDmCdatSubnames[] =
249 {
250     "Device Scoped Memory Affinity Structure (DSMAS)",
251     "Device scoped Latency and Bandwidth Information Structure (DSLBIS)",
252     "Device Scoped Memory Side Cache Information Structure (DSMSCIS)",
253     "Device Scoped Initiator Structure (DSIS)",
254     "Device Scoped EFI Memory Type Structure (DSEMTS)",
255     "Switch Scoped Latency and Bandwidth Information Structure (SSLBIS)",
256     "Unknown Subtable Type"         /* Reserved */
257 };
258 
259 static const char           *AcpiDmCedtSubnames[] =
260 {
261     "CXL Host Bridge Structure",
262     "CXL Fixed Memory Window Structure",
263     "CXL XOR Interleave Math Structure",
264     "Unknown Subtable Type"         /* Reserved */
265 };
266 
267 static const char           *AcpiDmDmarSubnames[] =
268 {
269     "Hardware Unit Definition",
270     "Reserved Memory Region",
271     "Root Port ATS Capability",
272     "Remapping Hardware Static Affinity",
273     "ACPI Namespace Device Declaration",
274     "SoC Integrated Address Translation Cache",
275     "SoC Integrated Device Property",
276     "Unknown Subtable Type"         /* Reserved */
277 };
278 
279 static const char           *AcpiDmDmarScope[] =
280 {
281     "Reserved value",
282     "PCI Endpoint Device",
283     "PCI Bridge Device",
284     "IOAPIC Device",
285     "Message-capable HPET Device",
286     "Namespace Device",
287     "Unknown Scope Type"            /* Reserved */
288 };
289 
290 static const char           *AcpiDmEinjActions[] =
291 {
292     "Begin Operation",
293     "Get Trigger Table",
294     "Set Error Type",
295     "Get Error Type",
296     "End Operation",
297     "Execute Operation",
298     "Check Busy Status",
299     "Get Command Status",
300     "Set Error Type With Address",
301     "Get Execute Timings",
302     "Unassigned",
303     "Unassigned",
304     "Unassigned",
305     "Unassigned",
306     "Unassigned",
307     "Unassigned",
308     "EinjV2 Set Error Type(deprecated)",
309     "EinjV2 Get Error Type",
310     "Unknown Action"
311 };
312 
313 static const char           *AcpiDmEinjInstructions[] =
314 {
315     "Read Register",
316     "Read Register Value",
317     "Write Register",
318     "Write Register Value",
319     "Noop",
320     "Flush Cacheline",
321     "Unknown Instruction"
322 };
323 
324 static const char           *AcpiDmErdtSubnames[] =
325 {
326     "RMDD",
327     "CACD",
328     "DACD",
329     "CMRC",
330     "MMRC",
331     "MARC",
332     "CARC",
333     "CMRD",
334     "IBRD",
335     "IBAD",
336     "CARD",
337     "RESERVED"
338 };
339 
340 static const char           *AcpiDmErstActions[] =
341 {
342     "Begin Write Operation",
343     "Begin Read Operation",
344     "Begin Clear Operation",
345     "End Operation",
346     "Set Record Offset",
347     "Execute Operation",
348     "Check Busy Status",
349     "Get Command Status",
350     "Get Record Identifier",
351     "Set Record Identifier",
352     "Get Record Count",
353     "Begin Dummy Write",
354     "Unused/Unknown Action",
355     "Get Error Address Range",
356     "Get Error Address Length",
357     "Get Error Attributes",
358     "Execute Timings",
359     "Unknown Action"
360 };
361 
362 static const char           *AcpiDmErstInstructions[] =
363 {
364     "Read Register",
365     "Read Register Value",
366     "Write Register",
367     "Write Register Value",
368     "Noop",
369     "Load Var1",
370     "Load Var2",
371     "Store Var1",
372     "Add",
373     "Subtract",
374     "Add Value",
375     "Subtract Value",
376     "Stall",
377     "Stall While True",
378     "Skip Next If True",
379     "GoTo",
380     "Set Source Address",
381     "Set Destination Address",
382     "Move Data",
383     "Unknown Instruction"
384 };
385 
386 static const char           *AcpiDmGtdtSubnames[] =
387 {
388     "Generic Timer Block",
389     "Generic Watchdog Timer",
390     "Unknown Subtable Type"         /* Reserved */
391 };
392 
393 static const char           *AcpiDmHestSubnames[] =
394 {
395     "IA-32 Machine Check Exception",
396     "IA-32 Corrected Machine Check",
397     "IA-32 Non-Maskable Interrupt",
398     "Unknown Subtable Type",        /* 3 - Reserved */
399     "Unknown Subtable Type",        /* 4 - Reserved */
400     "Unknown Subtable Type",        /* 5 - Reserved */
401     "PCI Express Root Port AER",
402     "PCI Express AER (AER Endpoint)",
403     "PCI Express/PCI-X Bridge AER",
404     "Generic Hardware Error Source",
405     "Generic Hardware Error Source V2",
406     "IA-32 Deferred Machine Check",
407     "Unknown Subtable Type"         /* Reserved */
408 };
409 
410 static const char           *AcpiDmHestNotifySubnames[] =
411 {
412     "Polled",
413     "External Interrupt",
414     "Local Interrupt",
415     "SCI",
416     "NMI",
417     "CMCI",                         /* ACPI 5.0 */
418     "MCE",                          /* ACPI 5.0 */
419     "GPIO",                         /* ACPI 6.0 */
420     "SEA",                          /* ACPI 6.1 */
421     "SEI",                          /* ACPI 6.1 */
422     "GSIV",                         /* ACPI 6.1 */
423     "Software Delegated Exception", /* ACPI 6.2 */
424     "Unknown Notify Type"           /* Reserved */
425 };
426 
427 static const char           *AcpiDmHmatSubnames[] =
428 {
429     "Memory Proximity Domain Attributes",
430     "System Locality Latency and Bandwidth Information",
431     "Memory Side Cache Information",
432     "Unknown Structure Type"         /* Reserved */
433 };
434 
435 static const char           *AcpiDmMadtSubnames[] =
436 {
437     "Processor Local APIC",                   /* ACPI_MADT_TYPE_LOCAL_APIC */
438     "I/O APIC",                               /* ACPI_MADT_TYPE_IO_APIC */
439     "Interrupt Source Override",              /* ACPI_MADT_TYPE_INTERRUPT_OVERRIDE */
440     "NMI Source",                             /* ACPI_MADT_TYPE_NMI_SOURCE */
441     "Local APIC NMI",                         /* ACPI_MADT_TYPE_LOCAL_APIC_NMI */
442     "Local APIC Address Override",            /* ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE */
443     "I/O SAPIC",                              /* ACPI_MADT_TYPE_IO_SAPIC */
444     "Local SAPIC",                            /* ACPI_MADT_TYPE_LOCAL_SAPIC */
445     "Platform Interrupt Sources",             /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */
446     "Processor Local x2APIC",                 /* ACPI_MADT_TYPE_LOCAL_X2APIC */
447     "Local x2APIC NMI",                       /* ACPI_MADT_TYPE_LOCAL_X2APIC_NMI */
448     "Generic Interrupt Controller",           /* ACPI_MADT_GENERIC_INTERRUPT */
449     "Generic Interrupt Distributor",          /* ACPI_MADT_GENERIC_DISTRIBUTOR */
450     "Generic MSI Frame",                      /* ACPI_MADT_GENERIC_MSI_FRAME */
451     "Generic Interrupt Redistributor",        /* ACPI_MADT_GENERIC_REDISTRIBUTOR */
452     "Generic Interrupt Translator",           /* ACPI_MADT_GENERIC_TRANSLATOR */
453     "Mutiprocessor Wakeup",                   /* ACPI_MADT_TYPE_MULTIPROC_WAKEUP */
454     "CPU Core Interrupt Controller",          /* ACPI_MADT_TYPE_CORE_PIC */
455     "Legacy I/O Interrupt Controller",        /* ACPI_MADT_TYPE_LIO_PIC */
456     "HT Interrupt Controller",                /* ACPI_MADT_TYPE_HT_PIC */
457     "Extend I/O Interrupt Controller",        /* ACPI_MADT_TYPE_EIO_PIC */
458     "MSI Interrupt Controller",               /* ACPI_MADT_TYPE_MSI_PIC */
459     "Bridge I/O Interrupt Controller",        /* ACPI_MADT_TYPE_BIO_PIC */
460     "LPC Interrupt Controller",               /* ACPI_MADT_TYPE_LPC_PIC */
461     "RISC-V Interrupt Controller",            /* ACPI_MADT_TYPE_RINTC */
462     "RISC-V Incoming MSI Controller",         /* ACPI_MADT_TYPE_IMSIC */
463     "RISC-V APLIC Controller",                /* ACPI_MADT_TYPE_APLIC */
464     "RISC-V PLIC Controller",                 /* ACPI_MADT_TYPE_PLIC */
465     "Generic Interrupt v5 Router",            /* ACPI_MADT_TYPE_GICV5_IRS */
466     "Generic Interrupt v5 Translator Config", /* ACPI_MADT_TYPE_GICV5_ITS */
467     "Generic Interrupt v5 Translator Entry",  /* ACPI_MADT_TYPE_GICV5_ITS_TRANSLATE */
468     "Unknown Subtable Type",                  /* Reserved */
469     "Types 80-FF are used for OEM data"       /* Reserved for OEM data */
470 };
471 
472 static const char           *AcpiDmMpamSubnames[] =
473 {
474     "Processor cache",      /* ACPI_MPAM_LOCATION_TYPE_PROCESSOR_CACHE */
475     "Memory",               /* ACPI_MPAM_LOCATION_TYPE_MEMORY */
476     "SMMU",                 /* ACPI_MPAM_LOCATION_TYPE_SMMU */
477     "Memory-side cache",    /* ACPI_MPAM_LOCATION_TYPE_MEMORY_CACHE */
478     "ACPI device",          /* ACPI_MPAM_LOCATION_TYPE_ACPI_DEVICE */
479     "Interconnect",         /* ACPI_MPAM_LOCATION_TYPE_INTERCONNECT */
480     "Unknown"               /* ACPI_MPAM_LOCATION_TYPE_UNKNOWN */
481 };
482 
483 static const char           *AcpiDmNfitSubnames[] =
484 {
485     "System Physical Address Range",    /* ACPI_NFIT_TYPE_SYSTEM_ADDRESS */
486     "Memory Range Map",                 /* ACPI_NFIT_TYPE_MEMORY_MAP */
487     "Interleave Info",                  /* ACPI_NFIT_TYPE_INTERLEAVE */
488     "SMBIOS Information",               /* ACPI_NFIT_TYPE_SMBIOS */
489     "NVDIMM Control Region",            /* ACPI_NFIT_TYPE_CONTROL_REGION */
490     "NVDIMM Block Data Window Region",  /* ACPI_NFIT_TYPE_DATA_REGION */
491     "Flush Hint Address",               /* ACPI_NFIT_TYPE_FLUSH_ADDRESS */
492     "Platform Capabilities",            /* ACPI_NFIT_TYPE_CAPABILITIES */
493     "Unknown Subtable Type"             /* Reserved */
494 };
495 
496 static const char           *AcpiDmPcctSubnames[] =
497 {
498     "Generic Communications Subspace",  /* ACPI_PCCT_TYPE_GENERIC_SUBSPACE */
499     "HW-Reduced Comm Subspace",         /* ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE */
500     "HW-Reduced Comm Subspace Type2",   /* ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2 */
501     "Extended PCC Master Subspace",     /* ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE */
502     "Extended PCC Slave Subspace",      /* ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE */
503     "HW Registers based Comm Subspace", /* ACPI_PCCT_TYPE_HW_REG_COMM_SUBSPACE */
504     "Unknown Subtable Type"             /* Reserved */
505 };
506 
507 static const char           *AcpiDmPhatSubnames[] =
508 {
509     "Firmware Version Data",        /* ACPI_PHAT_TYPE_FW_VERSION_DATA */
510     "Firmware Health Data",         /* ACPI_PHAT_TYPE_FW_HEALTH_DATA */
511     "Unknown Subtable Type"         /* Reserved */
512 };
513 
514 static const char           *AcpiDmPmttSubnames[] =
515 {
516     "Socket",                       /* ACPI_PMTT_TYPE_SOCKET */
517     "Memory Controller",            /* ACPI_PMTT_TYPE_CONTROLLER */
518     "Physical Component (DIMM)",    /* ACPI_PMTT_TYPE_DIMM */
519     "Unknown Subtable Type",        /* Reserved */
520     "Vendor Specific"               /* ACPI_PMTT_TYPE_VENDOR */
521 };
522 
523 static const char           *AcpiDmPpttSubnames[] =
524 {
525     "Processor Hierarchy Node",     /* ACPI_PPTT_TYPE_PROCESSOR */
526     "Cache Type",                   /* ACPI_PPTT_TYPE_CACHE */
527     "ID",                           /* ACPI_PPTT_TYPE_ID */
528     "Unknown Subtable Type"         /* Reserved */
529 };
530 
531 static const char           *AcpiDmRgrtSubnames[] =
532 {
533     "Unknown/Reserved Image Type",  /* ACPI_RGRT_TYPE_RESERVED0 */
534     "Type PNG"                      /* ACPI_RGRT_IMAGE_TYPE_PNG */
535 };
536 
537 static const char           *AcpiDmSdevSubnames[] =
538 {
539     "Namespace Device",             /* ACPI_SDEV_TYPE_NAMESPACE_DEVICE */
540     "PCIe Endpoint Device",         /* ACPI_SDEV_TYPE_PCIE_ENDPOINT_DEVICE */
541     "Unknown Subtable Type"         /* Reserved */
542 };
543 
544 static const char           *AcpiDmSratSubnames[] =
545 {
546     "Processor Local APIC/SAPIC Affinity",
547     "Memory Affinity",
548     "Processor Local x2APIC Affinity",
549     "GICC Affinity",
550     "GIC ITS Affinity",             /* Acpi 6.2 */
551     "Generic Initiator Affinity",   /* Acpi 6.3 */
552     "Generic Port Affinity",        /* Acpi 6.4 */
553     "RINTC Affinity",               /* Acpi 6.6 */
554     "Unknown Subtable Type"         /* Reserved */
555 };
556 
557 static const char           *AcpiDmTpm2Subnames[] =
558 {
559     "Illegal Start Method value",
560     "Reserved",
561     "ACPI Start Method",
562     "Reserved",
563     "Reserved",
564     "Reserved",
565     "Memory Mapped I/O",
566     "Command Response Buffer",
567     "Command Response Buffer with ACPI Start Method",
568     "Reserved",
569     "Reserved",
570     "Command Response Buffer with ARM SMC",
571     "FIFO over I2C",
572     "Command Response Buffer with AMD Mailbox",
573     "Reserved",
574     "Command Response Buffer with ARM Framework-A",
575     "Unknown Subtable Type"         /* Reserved */
576 };
577 
578 static const char           *AcpiDmIovtSubnames[] =
579 {
580     "IOMMUv1",
581     "Unknown Subtable Type"         /* Reserved */
582 };
583 
584 static const char           *AcpiDmIovtdevSubnames[] =
585 {
586     "A single PCI device",
587     "Start of range",
588     "End of range",
589     "Unknown Subtable Type"         /* Reserved */
590 };
591 
592 static const char           *AcpiDmIvrsSubnames[] =
593 {
594     "Hardware Definition Block (IVHD)",
595     "Hardware Definition Block - Mixed Format (IVHD)",
596     "Memory Definition Block (IVMD)",
597     "Unknown/Reserved Subtable Type"            /* Reserved */
598 };
599 
600 static const char           *AcpiDmIvrsDevEntryNames[] =
601 {
602     "Unknown/Reserved Device Entry Type",       /* 0- Reserved */
603     "Device Entry: Select All Devices",         /* 1 */
604     "Device Entry: Select One Device",          /* 2 */
605     "Device Entry: Start of Range",             /* 3 */
606     "Device Entry: End of Range",               /* 4 */
607     "Device Entry: Alias Select",               /* 66 */
608     "Device Entry: Alias Start of Range",       /* 67 */
609     "Unknown/Reserved Device Entry Type",       /* 68- Reserved */
610     "Unknown/Reserved Device Entry Type",       /* 69- Reserved */
611     "Device Entry: Extended Select",            /* 70 */
612     "Device Entry: Extended Start of Range",    /* 71 */
613     "Device Entry: Special Device",             /* 72 */
614     "Device Entry: ACPI HID Named Device",      /* 240 */
615     "Unknown/Reserved Device Entry Type"        /* Reserved */
616 };
617 
618 static const char           *AcpiDmLpitSubnames[] =
619 {
620     "Native C-state Idle Structure",
621     "Unknown Subtable Type"         /* Reserved */
622 };
623 
624 static const char           *AcpiDmViotSubnames[] =
625 {
626     "Unknown Subtable Type",        /* 0 -Reserved */
627     "PCI Range",
628     "MMIO Endpoint",
629     "VirtIO-PCI IOMMU",
630     "VirtIO-MMIO IOMMU",
631     "Unknown Subtable Type"         /* Reserved */
632 };
633 
634 #define ACPI_FADT_PM_RESERVED       9
635 
636 static const char           *AcpiDmFadtProfiles[] =
637 {
638     "Unspecified",
639     "Desktop",
640     "Mobile",
641     "Workstation",
642     "Enterprise Server",
643     "SOHO Server",
644     "Appliance PC",
645     "Performance Server",
646     "Tablet",
647     "Unknown Profile Type"
648 };
649 
650 #define ACPI_GAS_WIDTH_RESERVED     5
651 
652 static const char           *AcpiDmGasAccessWidth[] =
653 {
654     "Undefined/Legacy",
655     "Byte Access:8",
656     "Word Access:16",
657     "DWord Access:32",
658     "QWord Access:64",
659     "Unknown Width Encoding"
660 };
661 
662 static const char           *AcpiDmRhctSubnames[] =
663 {
664     "RISC-V ISA string structure",  /* ACPI_RHCT_ISA_STRING */
665     "RISC-V CMO node structure",    /* ACPI_RHCT_CMO_NODE */
666     "RISC-V MMU node structure",    /* ACPI_RHCT_MMU_NODE */
667     "RISC-V Hart Info structure",   /* ACPI_RHCT_HART_INFO */
668 };
669 
670 
671 /*******************************************************************************
672  *
673  * ACPI Table Data, indexed by signature.
674  *
675  * Each entry contains: Signature, Table Info, Handler, DtHandler,
676  *  Template, Description
677  *
678  * Simple tables have only a TableInfo structure, complex tables have a
679  * handler. This table must be NULL terminated. RSDP and FACS are
680  * special-cased elsewhere.
681  *
682  * Note: Any tables added here should be duplicated within
683  * AcpiGbl_SupportedTables in the file common/ahtable.c
684  *
685  ******************************************************************************/
686 
687 const ACPI_DMTABLE_DATA     AcpiDmTableData[] =
688 {
689     {ACPI_SIG_AEST, NULL,                   AcpiDmDumpAest, DtCompileAest,  TemplateAest},
690     {ACPI_SIG_AGDI, AcpiDmTableInfoAgdi,    NULL,           NULL,           TemplateAgdi},
691     {ACPI_SIG_APMT, NULL,                   AcpiDmDumpApmt, DtCompileApmt,  TemplateApmt},
692     {ACPI_SIG_ASF,  NULL,                   AcpiDmDumpAsf,  DtCompileAsf,   TemplateAsf},
693     {ACPI_SIG_ASPT, NULL,                   AcpiDmDumpAspt, DtCompileAspt,  TemplateAspt},
694     {ACPI_SIG_BDAT, AcpiDmTableInfoBdat,    NULL,           NULL,           TemplateBdat},
695     {ACPI_SIG_BERT, AcpiDmTableInfoBert,    NULL,           NULL,           TemplateBert},
696     {ACPI_SIG_BGRT, AcpiDmTableInfoBgrt,    NULL,           NULL,           TemplateBgrt},
697     {ACPI_SIG_BOOT, AcpiDmTableInfoBoot,    NULL,           NULL,           TemplateBoot},
698     {ACPI_SIG_CCEL, AcpiDmTableInfoCcel,    NULL,           NULL,           TemplateCcel},
699     {ACPI_SIG_CDAT, NULL,                   AcpiDmDumpCdat, NULL,           TemplateCdat},
700     {ACPI_SIG_CEDT, NULL,                   AcpiDmDumpCedt, DtCompileCedt,  TemplateCedt},
701     {ACPI_SIG_CPEP, NULL,                   AcpiDmDumpCpep, DtCompileCpep,  TemplateCpep},
702     {ACPI_SIG_CSRT, NULL,                   AcpiDmDumpCsrt, DtCompileCsrt,  TemplateCsrt},
703     {ACPI_SIG_DBG2, AcpiDmTableInfoDbg2,    AcpiDmDumpDbg2, DtCompileDbg2,  TemplateDbg2},
704     {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp,    NULL,           NULL,           TemplateDbgp},
705     {ACPI_SIG_DMAR, NULL,                   AcpiDmDumpDmar, DtCompileDmar,  TemplateDmar},
706     {ACPI_SIG_DRTM, NULL,                   AcpiDmDumpDrtm, DtCompileDrtm,  TemplateDrtm},
707     {ACPI_SIG_DTPR, NULL,                   AcpiDmDumpDtpr, DtCompileDtpr,  TemplateDtpr},
708     {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt,    NULL,           NULL,           TemplateEcdt},
709     {ACPI_SIG_EINJ, NULL,                   AcpiDmDumpEinj, DtCompileEinj,  TemplateEinj},
710     {ACPI_SIG_ERDT, NULL,                   AcpiDmDumpErdt, DtCompileErdt,  TemplateErdt},
711     {ACPI_SIG_ERST, NULL,                   AcpiDmDumpErst, DtCompileErst,  TemplateErst},
712     {ACPI_SIG_FADT, NULL,                   AcpiDmDumpFadt, DtCompileFadt,  TemplateFadt},
713     {ACPI_SIG_FPDT, NULL,                   AcpiDmDumpFpdt, DtCompileFpdt,  TemplateFpdt},
714     {ACPI_SIG_GTDT, NULL,                   AcpiDmDumpGtdt, DtCompileGtdt,  TemplateGtdt},
715     {ACPI_SIG_HEST, NULL,                   AcpiDmDumpHest, DtCompileHest,  TemplateHest},
716     {ACPI_SIG_HMAT, NULL,                   AcpiDmDumpHmat, DtCompileHmat,  TemplateHmat},
717     {ACPI_SIG_HPET, AcpiDmTableInfoHpet,    NULL,           NULL,           TemplateHpet},
718     {ACPI_SIG_IORT, NULL,                   AcpiDmDumpIort, DtCompileIort,  TemplateIort},
719     {ACPI_SIG_IOVT, AcpiDmTableInfoIovt,    AcpiDmDumpIovt, DtCompileIovt,  TemplateIovt},
720     {ACPI_SIG_IVRS, NULL,                   AcpiDmDumpIvrs, DtCompileIvrs,  TemplateIvrs},
721     {ACPI_SIG_LPIT, NULL,                   AcpiDmDumpLpit, DtCompileLpit,  TemplateLpit},
722     {ACPI_SIG_MADT, NULL,                   AcpiDmDumpMadt, DtCompileMadt,  TemplateMadt},
723     {ACPI_SIG_MCFG, NULL,                   AcpiDmDumpMcfg, DtCompileMcfg,  TemplateMcfg},
724     {ACPI_SIG_MCHI, AcpiDmTableInfoMchi,    NULL,           NULL,           TemplateMchi},
725     {ACPI_SIG_MPAM, NULL,                   AcpiDmDumpMpam, DtCompileMpam,  TemplateMpam},
726     {ACPI_SIG_MPST, AcpiDmTableInfoMpst,    AcpiDmDumpMpst, DtCompileMpst,  TemplateMpst},
727     {ACPI_SIG_MRRM, NULL,                   AcpiDmDumpMrrm, DtCompileMrrm,  TemplateMrrm},
728     {ACPI_SIG_MSCT, NULL,                   AcpiDmDumpMsct, DtCompileMsct,  TemplateMsct},
729     {ACPI_SIG_MSDM, NULL,                   AcpiDmDumpSlic, DtCompileSlic,  TemplateMsdm},
730     {ACPI_SIG_NFIT, AcpiDmTableInfoNfit,    AcpiDmDumpNfit, DtCompileNfit,  TemplateNfit},
731     {ACPI_SIG_NHLT, NULL,                   NULL,           NULL,           NULL},
732     {ACPI_SIG_PCCT, AcpiDmTableInfoPcct,    AcpiDmDumpPcct, DtCompilePcct,  TemplatePcct},
733     {ACPI_SIG_PDTT, AcpiDmTableInfoPdtt,    AcpiDmDumpPdtt, DtCompilePdtt,  TemplatePdtt},
734     {ACPI_SIG_PHAT, NULL,                   AcpiDmDumpPhat, DtCompilePhat,  TemplatePhat},
735     {ACPI_SIG_PMTT, NULL,                   AcpiDmDumpPmtt, DtCompilePmtt,  TemplatePmtt},
736     {ACPI_SIG_PPTT, NULL,                   AcpiDmDumpPptt, DtCompilePptt,  TemplatePptt},
737     {ACPI_SIG_PRMT, NULL,                   AcpiDmDumpPrmt, DtCompilePrmt,  TemplatePrmt},
738     {ACPI_SIG_RASF, AcpiDmTableInfoRasf,    NULL,           NULL,           TemplateRasf},
739     {ACPI_SIG_RAS2, AcpiDmTableInfoRas2,    AcpiDmDumpRas2, DtCompileRas2,  TemplateRas2},
740     {ACPI_SIG_RGRT, NULL,                   AcpiDmDumpRgrt, DtCompileRgrt,  TemplateRgrt},
741     {ACPI_SIG_RHCT, NULL,                   AcpiDmDumpRhct, DtCompileRhct,  TemplateRhct},
742     {ACPI_SIG_RIMT, NULL,                   AcpiDmDumpRimt, DtCompileRimt,  TemplateRimt},
743     {ACPI_SIG_RSDT, NULL,                   AcpiDmDumpRsdt, DtCompileRsdt,  TemplateRsdt},
744     {ACPI_SIG_S3PT, NULL,                   NULL,           NULL,           TemplateS3pt},
745     {ACPI_SIG_SBST, AcpiDmTableInfoSbst,    NULL,           NULL,           TemplateSbst},
746     {ACPI_SIG_SDEI, AcpiDmTableInfoSdei,    NULL,           NULL,           TemplateSdei},
747     {ACPI_SIG_SDEV, AcpiDmTableInfoSdev,    AcpiDmDumpSdev, DtCompileSdev,  TemplateSdev},
748     {ACPI_SIG_SLIC, NULL,                   AcpiDmDumpSlic, DtCompileSlic,  TemplateSlic},
749     {ACPI_SIG_SLIT, NULL,                   AcpiDmDumpSlit, DtCompileSlit,  TemplateSlit},
750     {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr,    NULL,           NULL,           TemplateSpcr},
751     {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi,    NULL,           NULL,           TemplateSpmi},
752     {ACPI_SIG_SRAT, NULL,                   AcpiDmDumpSrat, DtCompileSrat,  TemplateSrat},
753     {ACPI_SIG_STAO, NULL,                   AcpiDmDumpStao, DtCompileStao,  TemplateStao},
754     {ACPI_SIG_SVKL, AcpiDmTableInfoSvkl,    AcpiDmDumpSvkl, DtCompileSvkl,  TemplateSvkl},
755     {ACPI_SIG_SWFT, AcpiDmTableInfoSwft,    AcpiDmDumpSwft, DtCompileSwft,  TemplateSwft},
756     {ACPI_SIG_TCPA, NULL,                   AcpiDmDumpTcpa, DtCompileTcpa,  TemplateTcpa},
757     {ACPI_SIG_TDEL, AcpiDmTableInfoTdel,    NULL,           NULL,           TemplateTdel},
758     {ACPI_SIG_TPM2, AcpiDmTableInfoTpm2,    AcpiDmDumpTpm2, DtCompileTpm2,  TemplateTpm2},
759     {ACPI_SIG_UEFI, AcpiDmTableInfoUefi,    NULL,           DtCompileUefi,  TemplateUefi},
760     {ACPI_SIG_VIOT, AcpiDmTableInfoViot,    AcpiDmDumpViot, DtCompileViot,  TemplateViot},
761     {ACPI_SIG_WAET, AcpiDmTableInfoWaet,    NULL,           NULL,           TemplateWaet},
762     {ACPI_SIG_WDAT, NULL,                   AcpiDmDumpWdat, DtCompileWdat,  TemplateWdat},
763     {ACPI_SIG_WDDT, AcpiDmTableInfoWddt,    NULL,           NULL,           TemplateWddt},
764     {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt,    NULL,           NULL,           TemplateWdrt},
765     {ACPI_SIG_WPBT, NULL,                   AcpiDmDumpWpbt, DtCompileWpbt,  TemplateWpbt},
766     {ACPI_SIG_WSMT, AcpiDmTableInfoWsmt,    NULL,           NULL,           TemplateWsmt},
767     {ACPI_SIG_XENV, AcpiDmTableInfoXenv,    NULL,           NULL,           TemplateXenv},
768     {ACPI_SIG_XSDT, NULL,                   AcpiDmDumpXsdt, DtCompileXsdt,  TemplateXsdt},
769     {NULL,          NULL,                   NULL,           NULL,           NULL}
770 };
771 
772 
773 /*******************************************************************************
774  *
775  * FUNCTION:    AcpiDmGetTableData
776  *
777  * PARAMETERS:  Signature           - ACPI signature (4 chars) to match
778  *
779  * RETURN:      Pointer to a valid ACPI_DMTABLE_DATA. Null if no match found.
780  *
781  * DESCRIPTION: Find a match in the global table of supported ACPI tables
782  *
783  ******************************************************************************/
784 
785 const ACPI_DMTABLE_DATA *
AcpiDmGetTableData(char * Signature)786 AcpiDmGetTableData (
787     char                    *Signature)
788 {
789     const ACPI_DMTABLE_DATA *Info;
790 
791 
792     for (Info = AcpiDmTableData; Info->Signature; Info++)
793     {
794         if (ACPI_COMPARE_NAMESEG (Signature, Info->Signature))
795         {
796             return (Info);
797         }
798     }
799 
800     return (NULL);
801 }
802 
803 
804 /*******************************************************************************
805  *
806  * FUNCTION:    AcpiDmDumpDataTable
807  *
808  * PARAMETERS:  Table               - An ACPI table
809  *
810  * RETURN:      None.
811  *
812  * DESCRIPTION: Format the contents of an ACPI data table (any table other
813  *              than an SSDT or DSDT that does not contain executable AML code)
814  *
815  ******************************************************************************/
816 
817 void
AcpiDmDumpDataTable(ACPI_TABLE_HEADER * Table)818 AcpiDmDumpDataTable (
819     ACPI_TABLE_HEADER       *Table)
820 {
821     ACPI_STATUS             Status;
822     const ACPI_DMTABLE_DATA *TableData;
823     UINT32                  Length;
824 
825 
826     /* Ignore tables that contain AML */
827 
828     if (AcpiUtIsAmlTable (Table))
829     {
830         if (AslGbl_VerboseTemplates)
831         {
832             /* Dump the raw table data */
833 
834             Length = Table->Length;
835 
836             AcpiOsPrintf ("\n/*\n%s: Length %d (0x%X)\n\n",
837                 ACPI_RAW_TABLE_DATA_HEADER, Length, Length);
838             AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table),
839                 Length, DB_BYTE_DISPLAY, 0);
840             AcpiOsPrintf (" */\n");
841         }
842         return;
843     }
844 
845     /*
846      * Handle tables that don't use the common ACPI table header structure.
847      * Currently, these are the FACS, RSDP, S3PT and CDAT.
848      */
849     if (ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_FACS))
850     {
851         Length = Table->Length;
852         Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFacs);
853         if (ACPI_FAILURE (Status))
854         {
855             return;
856         }
857     }
858     else if (ACPI_VALIDATE_RSDP_SIG (ACPI_CAST_PTR (ACPI_TABLE_RSDP,
859         Table)->Signature))
860     {
861         Length = AcpiDmDumpRsdp (Table);
862     }
863     else if (ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_S3PT))
864     {
865         Length = AcpiDmDumpS3pt (Table);
866     }
867     else if (!AcpiUtValidNameseg (Table->Signature))
868     {
869         /*
870          * For CDAT we are assuming that there should be at least one non-ASCII
871          * byte in the (normally) 4-character Signature field (at least the
872          * high-order byte should be zero).
873          */
874         if (AcpiGbl_CDAT)
875         {
876             /*
877              * Invalid signature and <-ds CDAT> was specified on the command line.
878              * Therefore, we have a CDAT table.
879              */
880             AcpiDmDumpCdat (Table);
881         }
882         else
883         {
884             fprintf (stderr, "Table has an invalid signature\n");
885         }
886 
887         return;
888     }
889     else
890     {
891         /*
892          * All other tables must use the common ACPI table header, dump it now
893          */
894         Length = Table->Length;
895         Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHeader);
896         if (ACPI_FAILURE (Status))
897         {
898             return;
899         }
900         AcpiOsPrintf ("\n");
901 
902         /* Match signature and dispatch appropriately */
903 
904         TableData = AcpiDmGetTableData (Table->Signature);
905         if (!TableData)
906         {
907             if (!strncmp (Table->Signature, "OEM", 3))
908             {
909                 AcpiOsPrintf ("\n**** OEM-defined ACPI table [%4.4s], unknown contents\n\n",
910                     Table->Signature);
911             }
912             else
913             {
914                 AcpiOsPrintf ("\n**** Unknown ACPI table signature [%4.4s]\n\n",
915                     Table->Signature);
916 
917                 fprintf (stderr, "Unknown ACPI table signature [%4.4s], ",
918                     Table->Signature);
919 
920                 if (!AcpiGbl_ForceAmlDisassembly)
921                 {
922                     fprintf (stderr, "decoding ACPI table header only\n");
923                 }
924                 else
925                 {
926                     fprintf (stderr, "assuming table contains valid AML code\n");
927                 }
928             }
929         }
930         else if (TableData->TableHandler)
931         {
932             /* Complex table, has a handler */
933 
934             TableData->TableHandler (Table);
935         }
936         else if (TableData->TableInfo)
937         {
938             /* Simple table, just walk the info table */
939 
940             Status = AcpiDmDumpTable (Length, 0, Table, 0, TableData->TableInfo);
941             if (ACPI_FAILURE (Status))
942             {
943                 return;
944             }
945         }
946     }
947 
948     if (!AslGbl_DoTemplates || AslGbl_VerboseTemplates)
949     {
950         /* Dump the raw table data */
951 
952         AcpiOsPrintf ("\n%s: Length %d (0x%X)\n\n",
953             ACPI_RAW_TABLE_DATA_HEADER, Length, Length);
954         AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table),
955             Length, DB_BYTE_DISPLAY, 0);
956     }
957 }
958 
959 
960 /*******************************************************************************
961  *
962  * FUNCTION:    AcpiDmLineHeader
963  *
964  * PARAMETERS:  Offset              - Current byte offset, from table start
965  *              ByteLength          - Length of the field in bytes, 0 for flags
966  *              Name                - Name of this field
967  *
968  * RETURN:      None
969  *
970  * DESCRIPTION: Utility routines for formatting output lines. Displays the
971  *              current table offset in hex and decimal, the field length,
972  *              and the field name.
973  *
974  ******************************************************************************/
975 
976 void
AcpiDmLineHeader(UINT32 Offset,UINT32 ByteLength,char * Name)977 AcpiDmLineHeader (
978     UINT32                  Offset,
979     UINT32                  ByteLength,
980     char                    *Name)
981 {
982 
983     /* Allow a null name for fields that span multiple lines (large buffers) */
984 
985     if (!Name)
986     {
987         Name = "";
988     }
989 
990     if (AslGbl_DoTemplates && !AslGbl_VerboseTemplates) /* Terse template */
991     {
992         if (ByteLength)
993         {
994             AcpiOsPrintf ("[%.4d] %34s : ", ByteLength, Name);
995         }
996         else
997         {
998             if (*Name)
999             {
1000                 AcpiOsPrintf ("%41s : ", Name);
1001             }
1002             else
1003             {
1004                 AcpiOsPrintf ("%41s   ", Name);
1005             }
1006         }
1007     }
1008     else /* Normal disassembler or verbose template */
1009     {
1010         if (ByteLength)
1011         {
1012             AcpiOsPrintf ("[%3.3Xh %4.4u %3.3Xh] %27s : ",
1013                 Offset, Offset, ByteLength, Name);
1014         }
1015         else
1016         {
1017             if (*Name)
1018             {
1019                 AcpiOsPrintf ("%44s : ", Name);
1020             }
1021             else
1022             {
1023                 AcpiOsPrintf ("%44s   ", Name);
1024             }
1025         }
1026     }
1027 }
1028 
1029 void
AcpiDmLineHeader2(UINT32 Offset,UINT32 ByteLength,char * Name,UINT32 Value)1030 AcpiDmLineHeader2 (
1031     UINT32                  Offset,
1032     UINT32                  ByteLength,
1033     char                    *Name,
1034     UINT32                  Value)
1035 {
1036 
1037     if (AslGbl_DoTemplates && !AslGbl_VerboseTemplates) /* Terse template */
1038     {
1039         if (ByteLength)
1040         {
1041             AcpiOsPrintf ("[%.4d] %30s %3d : ",
1042                 ByteLength, Name, Value);
1043         }
1044         else
1045         {
1046             AcpiOsPrintf ("%36s % 3d : ",
1047                 Name, Value);
1048         }
1049     }
1050     else /* Normal disassembler or verbose template */
1051     {
1052         if (ByteLength)
1053         {
1054             AcpiOsPrintf ("[%3.3Xh %4.4u %3.3Xh] %24s %3d : ",
1055                 Offset, Offset, ByteLength, Name, Value);
1056         }
1057         else
1058         {
1059             AcpiOsPrintf ("[%3.3Xh %4.4u   ] %24s %3d : ",
1060                 Offset, Offset, Name, Value);
1061         }
1062     }
1063 }
1064 
1065 
1066 /*******************************************************************************
1067  *
1068  * FUNCTION:    AcpiDmDumpTable
1069  *
1070  * PARAMETERS:  TableLength         - Length of the entire ACPI table
1071  *              TableOffset         - Starting offset within the table for this
1072  *                                    sub-descriptor (0 if main table)
1073  *              Table               - The ACPI table
1074  *              SubtableLength      - Length of this sub-descriptor
1075  *              Info                - Info table for this ACPI table
1076  *
1077  * RETURN:      Status
1078  *
1079  * DESCRIPTION: Display ACPI table contents by walking the Info table.
1080  *
1081  * Note: This function must remain in sync with DtGetFieldLength.
1082  *
1083  ******************************************************************************/
1084 
1085 ACPI_STATUS
AcpiDmDumpTable(UINT32 TableLength,UINT32 TableOffset,void * Table,UINT32 SubtableLength,ACPI_DMTABLE_INFO * Info)1086 AcpiDmDumpTable (
1087     UINT32                  TableLength,
1088     UINT32                  TableOffset,
1089     void                    *Table,
1090     UINT32                  SubtableLength,
1091     ACPI_DMTABLE_INFO       *Info)
1092 {
1093     UINT8                   *Target;
1094     UINT32                  CurrentOffset;
1095     UINT32                  ByteLength;
1096     UINT8                   Temp8;
1097     UINT16                  Temp16;
1098     UINT32                  Temp32;
1099     UINT64                  Value;
1100     const AH_TABLE          *TableData;
1101     const char              *Name;
1102     BOOLEAN                 LastOutputBlankLine = FALSE;
1103     ACPI_STATUS             Status;
1104     char                    RepairedName[8];
1105 
1106 
1107     if (!Info)
1108     {
1109         AcpiOsPrintf ("Display not implemented\n");
1110         return (AE_NOT_IMPLEMENTED);
1111     }
1112 
1113     /* Walk entire Info table; Null name terminates */
1114 
1115     for (; Info->Name; Info++)
1116     {
1117         /*
1118          * Target points to the field within the ACPI Table. CurrentOffset is
1119          * the offset of the field from the start of the main table.
1120          */
1121         Target = ACPI_ADD_PTR (UINT8, Table, Info->Offset);
1122         CurrentOffset = TableOffset + Info->Offset;
1123 
1124         /* Check for beyond subtable end or (worse) beyond EOT */
1125 
1126         if (SubtableLength && (Info->Offset > SubtableLength))
1127         {
1128             AcpiOsPrintf (
1129                 "/**** ACPI subtable terminates early (Len %u) - "
1130                 "may be older version (dump table) */\n", SubtableLength);
1131 
1132             /* Move on to next subtable */
1133 
1134             return (AE_OK);
1135         }
1136 
1137         if (CurrentOffset >= TableLength)
1138         {
1139             AcpiOsPrintf (
1140                 "/**** ACPI table terminates "
1141                 "in the middle of a data structure! (dump table)\n"
1142                 "CurrentOffset: %X, TableLength: %X ***/", CurrentOffset, TableLength);
1143             return (AE_BAD_DATA);
1144         }
1145 
1146         /* Generate the byte length for this field */
1147 
1148         switch (Info->Opcode)
1149         {
1150         case ACPI_DMT_UINT8:
1151         case ACPI_DMT_CHKSUM:
1152         case ACPI_DMT_SPACEID:
1153         case ACPI_DMT_ACCWIDTH:
1154         case ACPI_DMT_CEDT:
1155         case ACPI_DMT_IVRS:
1156         case ACPI_DMT_IVRS_DE:
1157         case ACPI_DMT_GTDT:
1158         case ACPI_DMT_MADT:
1159         case ACPI_DMT_MPAM_LOCATOR:
1160         case ACPI_DMT_PCCT:
1161         case ACPI_DMT_PMTT:
1162         case ACPI_DMT_PPTT:
1163         case ACPI_DMT_RGRT:
1164         case ACPI_DMT_SDEV:
1165         case ACPI_DMT_SRAT:
1166         case ACPI_DMT_AEST:
1167         case ACPI_DMT_AEST_RES:
1168         case ACPI_DMT_AEST_XFACE:
1169         case ACPI_DMT_AEST_XRUPT:
1170         case ACPI_DMT_ASF:
1171         case ACPI_DMT_CDAT:
1172         case ACPI_DMT_HESTNTYP:
1173         case ACPI_DMT_FADTPM:
1174         case ACPI_DMT_EINJACT:
1175         case ACPI_DMT_EINJINST:
1176         case ACPI_DMT_ERSTACT:
1177         case ACPI_DMT_ERSTINST:
1178         case ACPI_DMT_DMAR_SCOPE:
1179         case ACPI_DMT_IOVTDEV:
1180         case ACPI_DMT_VIOT:
1181 
1182             ByteLength = 1;
1183             break;
1184 
1185         case ACPI_DMT_ASPT:
1186         case ACPI_DMT_UINT16:
1187         case ACPI_DMT_DMAR:
1188         case ACPI_DMT_ERDT:
1189         case ACPI_DMT_HEST:
1190         case ACPI_DMT_HMAT:
1191         case ACPI_DMT_IOVT:
1192         case ACPI_DMT_NFIT:
1193         case ACPI_DMT_PHAT:
1194         case ACPI_DMT_RHCT:
1195 
1196             ByteLength = 2;
1197             break;
1198 
1199         case ACPI_DMT_UINT24:
1200 
1201             ByteLength = 3;
1202             break;
1203 
1204         case ACPI_DMT_UINT32:
1205         case ACPI_DMT_AEST_CACHE:
1206         case ACPI_DMT_AEST_GIC:
1207         case ACPI_DMT_NAME4:
1208         case ACPI_DMT_SIG:
1209         case ACPI_DMT_LPIT:
1210         case ACPI_DMT_TPM2:
1211 
1212             ByteLength = 4;
1213             break;
1214 
1215         case ACPI_DMT_UINT40:
1216 
1217             ByteLength = 5;
1218             break;
1219 
1220         case ACPI_DMT_UINT48:
1221         case ACPI_DMT_NAME6:
1222 
1223             ByteLength = 6;
1224             break;
1225 
1226         case ACPI_DMT_UINT56:
1227         case ACPI_DMT_BUF7:
1228 
1229             ByteLength = 7;
1230             break;
1231 
1232         case ACPI_DMT_UINT64:
1233         case ACPI_DMT_NAME8:
1234 
1235             ByteLength = 8;
1236             break;
1237 
1238         case ACPI_DMT_BUF10:
1239 
1240             ByteLength = 10;
1241             break;
1242 
1243         case ACPI_DMT_BUF11:
1244 
1245             ByteLength = 11;
1246             break;
1247 
1248         case ACPI_DMT_BUF12:
1249 
1250             ByteLength = 12;
1251             break;
1252 
1253         case ACPI_DMT_BUF16:
1254         case ACPI_DMT_UUID:
1255 
1256             ByteLength = 16;
1257             break;
1258 
1259         case ACPI_DMT_BUF18:
1260 
1261             ByteLength = 18;
1262             break;
1263 
1264         case ACPI_DMT_BUF24:
1265 
1266             ByteLength = 24;
1267             break;
1268 
1269         case ACPI_DMT_BUF26:
1270 
1271             ByteLength = 26;
1272             break;
1273 
1274         case ACPI_DMT_BUF32:
1275 
1276             ByteLength = 32;
1277             break;
1278 
1279         case ACPI_DMT_BUF112:
1280 
1281             ByteLength = 112;
1282             break;
1283 
1284         case ACPI_DMT_BUF128:
1285 
1286             ByteLength = 128;
1287             break;
1288 
1289         case ACPI_DMT_WPBT_UNICODE:
1290 
1291             ByteLength = SubtableLength;
1292             CurrentOffset = sizeof (ACPI_TABLE_WPBT);
1293             break;
1294 
1295         case ACPI_DMT_UNICODE:
1296         case ACPI_DMT_BUFFER:
1297         case ACPI_DMT_RAW_BUFFER:
1298 
1299             ByteLength = SubtableLength;
1300             break;
1301 
1302         case ACPI_DMT_PMTT_VENDOR:
1303             /*
1304              * Calculate the length of the vendor data for the PMTT table:
1305              * Length = (Current Subtable ptr + Subtable length) -
1306              *          Start of the vendor data (Target)
1307              */
1308             ByteLength = ((ACPI_CAST_PTR (char, Table) +
1309                             (ACPI_CAST_PTR (ACPI_PMTT_HEADER, Table)->Length)) -
1310                             ACPI_CAST_PTR (char, Target));
1311             break;
1312 
1313         case ACPI_DMT_STRING:
1314 
1315             ByteLength = strlen (ACPI_CAST_PTR (char, Target)) + 1;
1316             break;
1317 
1318         case ACPI_DMT_IVRS_UNTERMINATED_STRING:
1319 
1320             ByteLength = ((ACPI_CAST_PTR (ACPI_IVRS_DEVICE_HID, Target) -1)->UidLength);
1321             break;
1322 
1323         case ACPI_DMT_GAS:
1324 
1325             if (!LastOutputBlankLine)
1326             {
1327                 AcpiOsPrintf ("\n");
1328                 LastOutputBlankLine = TRUE;
1329             }
1330 
1331             ByteLength = sizeof (ACPI_GENERIC_ADDRESS);
1332             break;
1333 
1334         case ACPI_DMT_HESTNTFY:
1335 
1336             if (!LastOutputBlankLine)
1337             {
1338                 AcpiOsPrintf ("\n");
1339                 LastOutputBlankLine = TRUE;
1340             }
1341 
1342             ByteLength = sizeof (ACPI_HEST_NOTIFY);
1343             break;
1344 
1345         case ACPI_DMT_IORTMEM:
1346 
1347             if (!LastOutputBlankLine)
1348             {
1349                 LastOutputBlankLine = FALSE;
1350             }
1351 
1352             ByteLength = sizeof (ACPI_IORT_MEMORY_ACCESS);
1353             break;
1354 
1355         default:
1356 
1357             ByteLength = 0;
1358             break;
1359         }
1360 
1361         /* Check if we are beyond a subtable, or (worse) beyond EOT */
1362 
1363         if (CurrentOffset + ByteLength > TableLength)
1364         {
1365             if (SubtableLength)
1366             {
1367                 AcpiOsPrintf (
1368                     "/**** ACPI subtable terminates early - "
1369                     "may be older version (dump table) */\n");
1370 
1371                 /* Move on to next subtable */
1372 
1373                 return (AE_OK);
1374             }
1375 
1376             AcpiOsPrintf (
1377                 "/**** ACPI table terminates "
1378                 "in the middle of a data structure! */\n");
1379             return (AE_BAD_DATA);
1380         }
1381 
1382         if (Info->Opcode == ACPI_DMT_EXTRA_TEXT)
1383         {
1384             AcpiOsPrintf ("%s", Info->Name);
1385             continue;
1386         }
1387 
1388         /* Start a new line and decode the opcode */
1389 
1390         AcpiDmLineHeader (CurrentOffset, ByteLength, Info->Name);
1391 
1392         switch (Info->Opcode)
1393         {
1394         /* Single-bit Flag fields. Note: Opcode is the bit position */
1395 
1396         case ACPI_DMT_FLAG0:
1397         case ACPI_DMT_FLAG1:
1398         case ACPI_DMT_FLAG2:
1399         case ACPI_DMT_FLAG3:
1400         case ACPI_DMT_FLAG4:
1401         case ACPI_DMT_FLAG5:
1402         case ACPI_DMT_FLAG6:
1403         case ACPI_DMT_FLAG7:
1404 
1405             AcpiOsPrintf ("%1.1X\n", (*Target >> Info->Opcode) & 0x01);
1406             break;
1407 
1408         /* 2-bit Flag fields */
1409 
1410         case ACPI_DMT_FLAGS0:
1411 
1412             AcpiOsPrintf ("%1.1X\n", *Target & 0x03);
1413             break;
1414 
1415         case ACPI_DMT_FLAGS1:
1416 
1417             AcpiOsPrintf ("%1.1X\n", (*Target >> 1) & 0x03);
1418             break;
1419 
1420         case ACPI_DMT_FLAGS2:
1421 
1422             AcpiOsPrintf ("%1.1X\n", (*Target >> 2) & 0x03);
1423             break;
1424 
1425         case ACPI_DMT_FLAGS8_2:
1426 
1427             AcpiOsPrintf ("%2.2X\n", (*Target >> 2) & 0xFF);
1428             break;
1429 
1430         case ACPI_DMT_FLAGS4:
1431 
1432             AcpiOsPrintf ("%1.1X\n", (*Target >> 4) & 0x03);
1433             break;
1434 
1435         case ACPI_DMT_FLAGS4_0:
1436 
1437             AcpiOsPrintf ("%1.1X\n", (*(UINT32 *)Target) & 0x0F);
1438             break;
1439 
1440         case ACPI_DMT_FLAGS4_4:
1441 
1442             AcpiOsPrintf ("%1.1X\n", (*(UINT32 *)Target >> 4) & 0x0F);
1443             break;
1444 
1445         case ACPI_DMT_FLAGS4_8:
1446 
1447             AcpiOsPrintf ("%1.1X\n", (*(UINT32 *)Target >> 8) & 0x0F);
1448             break;
1449 
1450         case ACPI_DMT_FLAGS4_12:
1451 
1452             AcpiOsPrintf ("%1.1X\n", (*(UINT32 *)Target >> 12) & 0x0F);
1453             break;
1454 
1455         case ACPI_DMT_FLAGS16_16:
1456 
1457             AcpiOsPrintf ("%4.4X\n", (*(UINT32 *)Target >> 16) & 0xFFFF);
1458             break;
1459 
1460         /* Integer Data Types */
1461 
1462         case ACPI_DMT_UINT8:
1463         case ACPI_DMT_UINT16:
1464         case ACPI_DMT_UINT24:
1465         case ACPI_DMT_UINT32:
1466         case ACPI_DMT_UINT40:
1467         case ACPI_DMT_UINT48:
1468         case ACPI_DMT_UINT56:
1469         case ACPI_DMT_UINT64:
1470             /*
1471              * Dump bytes - high byte first, low byte last.
1472              * Note: All ACPI tables are little-endian.
1473              */
1474             Value = 0;
1475             for (Temp8 = (UINT8) ByteLength; Temp8 > 0; Temp8--)
1476             {
1477                 AcpiOsPrintf ("%2.2X", Target[Temp8 - 1]);
1478                 Value |= Target[Temp8 - 1];
1479                 Value <<= 8;
1480             }
1481 
1482             if (!Value && (Info->Flags & DT_DESCRIBES_OPTIONAL))
1483             {
1484                 AcpiOsPrintf (" [Optional field not present]");
1485             }
1486 
1487             AcpiOsPrintf ("\n");
1488             break;
1489 
1490         case ACPI_DMT_BUF7:
1491         case ACPI_DMT_BUF10:
1492         case ACPI_DMT_BUF11:
1493         case ACPI_DMT_BUF12:
1494         case ACPI_DMT_BUF16:
1495         case ACPI_DMT_BUF18:
1496         case ACPI_DMT_BUF24:
1497         case ACPI_DMT_BUF26:
1498         case ACPI_DMT_BUF32:
1499         case ACPI_DMT_BUF112:
1500         case ACPI_DMT_BUF128:
1501             /*
1502              * Buffer: Size depends on the opcode and was set above.
1503              * Each hex byte is separated with a space.
1504              * Multiple lines are separated by line continuation char.
1505              */
1506             for (Temp16 = 0; Temp16 < ByteLength; Temp16++)
1507             {
1508                 AcpiOsPrintf ("%2.2X", Target[Temp16]);
1509                 if ((UINT32) (Temp16 + 1) < ByteLength)
1510                 {
1511                     if ((Temp16 > 0) && (!((Temp16+1) % 16)))
1512                     {
1513                         AcpiOsPrintf (" \\\n"); /* Line continuation */
1514                         AcpiDmLineHeader (0, 0, NULL);
1515                     }
1516                     else
1517                     {
1518                         AcpiOsPrintf (" ");
1519                     }
1520                 }
1521             }
1522 
1523             AcpiOsPrintf ("\n");
1524             break;
1525 
1526         case ACPI_DMT_UUID:
1527 
1528             /* Convert 16-byte UUID buffer to 36-byte formatted UUID string */
1529 
1530             (void) AcpiUtConvertUuidToString ((char *) Target, AslGbl_MsgBuffer);
1531 
1532             AcpiOsPrintf ("%s\n", AslGbl_MsgBuffer);
1533             break;
1534 
1535         case ACPI_DMT_STRING:
1536 
1537             AcpiOsPrintf ("\"%s\"\n", ACPI_CAST_PTR (char, Target));
1538             break;
1539 
1540         case ACPI_DMT_IVRS_UNTERMINATED_STRING:
1541 
1542             AcpiOsPrintf ("\"%.*s\"\n", ByteLength, ACPI_CAST_PTR (char, Target));
1543             break;
1544 
1545         /* Fixed length ASCII name fields */
1546 
1547         case ACPI_DMT_SIG:
1548 
1549             AcpiUtCheckAndRepairAscii (Target, RepairedName, 4);
1550             AcpiOsPrintf ("\"%.4s\"    ", RepairedName);
1551 
1552             TableData = AcpiAhGetTableInfo (ACPI_CAST_PTR (char, Target));
1553             if (TableData)
1554             {
1555                 AcpiOsPrintf (STRING_FORMAT, TableData->Description);
1556             }
1557             else
1558             {
1559                 AcpiOsPrintf ("\n");
1560             }
1561             break;
1562 
1563         case ACPI_DMT_NAME4:
1564 
1565             AcpiUtCheckAndRepairAscii (Target, RepairedName, 4);
1566             AcpiOsPrintf ("\"%.4s\"\n", RepairedName);
1567             break;
1568 
1569         case ACPI_DMT_NAME6:
1570 
1571             AcpiUtCheckAndRepairAscii (Target, RepairedName, 6);
1572             AcpiOsPrintf ("\"%.6s\"\n", RepairedName);
1573             break;
1574 
1575         case ACPI_DMT_NAME8:
1576 
1577             AcpiUtCheckAndRepairAscii (Target, RepairedName, 8);
1578             AcpiOsPrintf ("\"%.8s\"\n", RepairedName);
1579             break;
1580 
1581         /* Special Data Types */
1582 
1583         case ACPI_DMT_CHKSUM:
1584 
1585             /* Checksum, display and validate */
1586 
1587             AcpiOsPrintf ("%2.2X", *Target);
1588             Temp8 = AcpiUtGenerateChecksum (Table,
1589                 ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length,
1590                 ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum);
1591 
1592             if (Temp8 != ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum)
1593             {
1594                 AcpiOsPrintf (
1595                     "     /* Incorrect checksum, should be %2.2X */", Temp8);
1596             }
1597 
1598             AcpiOsPrintf ("\n");
1599             break;
1600 
1601         case ACPI_DMT_SPACEID:
1602 
1603             /* Address Space ID */
1604 
1605             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiUtGetRegionName (*Target));
1606             break;
1607 
1608         case ACPI_DMT_ACCWIDTH:
1609 
1610             /* Encoded Access Width */
1611 
1612             Temp8 = *Target;
1613             if (Temp8 > ACPI_GAS_WIDTH_RESERVED)
1614             {
1615                 Temp8 = ACPI_GAS_WIDTH_RESERVED;
1616             }
1617 
1618             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmGasAccessWidth[Temp8]);
1619             break;
1620 
1621         case ACPI_DMT_GAS:
1622 
1623             /* Generic Address Structure */
1624 
1625             AcpiOsPrintf (STRING_FORMAT, "Generic Address Structure");
1626             Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1627                 sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas);
1628             if (ACPI_FAILURE (Status))
1629             {
1630                 return (Status);
1631             }
1632 
1633             AcpiOsPrintf ("\n");
1634             LastOutputBlankLine = TRUE;
1635             break;
1636 
1637         case ACPI_DMT_AEST:
1638 
1639             /* AEST subtable types */
1640 
1641             Temp8 = *Target;
1642             if (Temp8 > ACPI_AEST_NODE_TYPE_RESERVED)
1643             {
1644                 Temp8 = ACPI_AEST_NODE_TYPE_RESERVED;
1645             }
1646 
1647             AcpiOsPrintf (UINT8_FORMAT, *Target,
1648                 AcpiDmAestSubnames[Temp8]);
1649             break;
1650 
1651         case ACPI_DMT_AEST_CACHE:
1652 
1653             /* AEST cache resource subtable */
1654 
1655             Temp32 = *Target;
1656             if (Temp32 > ACPI_AEST_CACHE_RESERVED)
1657             {
1658                 Temp32 = ACPI_AEST_CACHE_RESERVED;
1659             }
1660 
1661             AcpiOsPrintf (UINT32_FORMAT, *Target,
1662                 AcpiDmAestCacheNames[Temp32]);
1663             break;
1664 
1665         case ACPI_DMT_AEST_GIC:
1666 
1667             /* AEST GIC error subtable */
1668 
1669             Temp32 = *Target;
1670             if (Temp32 > ACPI_AEST_GIC_RESERVED)
1671             {
1672                 Temp32 = ACPI_AEST_GIC_RESERVED;
1673             }
1674 
1675             AcpiOsPrintf (UINT32_FORMAT, *Target,
1676                 AcpiDmAestGicNames[Temp32]);
1677             break;
1678 
1679         case ACPI_DMT_AEST_RES:
1680 
1681             /* AEST resource type subtable */
1682 
1683             Temp8 = *Target;
1684             if (Temp8 > ACPI_AEST_RESOURCE_RESERVED)
1685             {
1686                 Temp8 = ACPI_AEST_RESOURCE_RESERVED;
1687             }
1688 
1689             AcpiOsPrintf (UINT8_FORMAT, *Target,
1690                 AcpiDmAestResourceNames[Temp8]);
1691             break;
1692 
1693         case ACPI_DMT_AEST_XFACE:
1694 
1695             /* AEST interface structure types */
1696 
1697             Temp8 = *Target;
1698             if (Temp8 > ACPI_AEST_XFACE_RESERVED)
1699             {
1700                 Temp8 = ACPI_AEST_XFACE_RESERVED;
1701             }
1702 
1703             AcpiOsPrintf (UINT8_FORMAT, *Target,
1704                 AcpiDmAestXfaceNames[Temp8]);
1705             break;
1706 
1707         case ACPI_DMT_AEST_XRUPT:
1708 
1709             /* AEST interrupt structure types */
1710 
1711             Temp8 = *Target;
1712             if (Temp8 > ACPI_AEST_XRUPT_RESERVED)
1713             {
1714                 Temp8 = ACPI_AEST_XRUPT_RESERVED;
1715             }
1716 
1717             AcpiOsPrintf (UINT8_FORMAT, *Target,
1718                 AcpiDmAestXruptNames[Temp8]);
1719             break;
1720 
1721         case ACPI_DMT_ASPT:
1722             /* ASPT subtable types */
1723             Temp16 = ACPI_GET16(Target);
1724             if (Temp16 > ACPI_ASPT_TYPE_UNKNOWN)
1725             {
1726                 Temp16 = ACPI_ASPT_TYPE_UNKNOWN;
1727             }
1728 
1729             AcpiOsPrintf(UINT16_FORMAT, Temp16, AcpiDmAsptSubnames[Temp16]);
1730             break;
1731 
1732         case ACPI_DMT_ASF:
1733 
1734             /* ASF subtable types */
1735 
1736             Temp16 = (UINT16) ((*Target) & 0x7F);  /* Top bit can be zero or one */
1737             if (Temp16 > ACPI_ASF_TYPE_RESERVED)
1738             {
1739                 Temp16 = ACPI_ASF_TYPE_RESERVED;
1740             }
1741 
1742             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmAsfSubnames[Temp16]);
1743             break;
1744 
1745         case ACPI_DMT_CDAT:
1746 
1747             /* CDAT subtable types */
1748 
1749             Temp8 = *Target;
1750             if (Temp8 > ACPI_CDAT_TYPE_RESERVED)
1751             {
1752                 Temp8 = ACPI_CDAT_TYPE_RESERVED;
1753             }
1754 
1755             AcpiOsPrintf (UINT8_FORMAT, *Target,
1756                 AcpiDmCdatSubnames[Temp8]);
1757             break;
1758 
1759         case ACPI_DMT_CEDT:
1760 
1761             /* CEDT subtable types */
1762 
1763             Temp8 = *Target;
1764             if (Temp8 > ACPI_CEDT_TYPE_RESERVED)
1765             {
1766                 Temp8 = ACPI_CEDT_TYPE_RESERVED;
1767             }
1768 
1769             AcpiOsPrintf (UINT8_FORMAT, *Target,
1770                 AcpiDmCedtSubnames[Temp8]);
1771             break;
1772 
1773         case ACPI_DMT_DMAR:
1774 
1775             /* DMAR subtable types */
1776 
1777             Temp16 = ACPI_GET16 (Target);
1778             if (Temp16 > ACPI_DMAR_TYPE_RESERVED)
1779             {
1780                 Temp16 = ACPI_DMAR_TYPE_RESERVED;
1781             }
1782 
1783             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1784                 AcpiDmDmarSubnames[Temp16]);
1785             break;
1786 
1787         case ACPI_DMT_DMAR_SCOPE:
1788 
1789             /* DMAR device scope types */
1790 
1791             Temp8 = *Target;
1792             if (Temp8 > ACPI_DMAR_SCOPE_TYPE_RESERVED)
1793             {
1794                 Temp8 = ACPI_DMAR_SCOPE_TYPE_RESERVED;
1795             }
1796 
1797             AcpiOsPrintf (UINT8_FORMAT, *Target,
1798                 AcpiDmDmarScope[Temp8]);
1799             break;
1800 
1801         case ACPI_DMT_EINJACT:
1802 
1803             /* EINJ Action types */
1804 
1805             Temp8 = *Target;
1806             if (Temp8 > ACPI_EINJ_ACTION_RESERVED)
1807             {
1808                 Temp8 = ACPI_EINJ_ACTION_RESERVED;
1809             }
1810 
1811             AcpiOsPrintf (UINT8_FORMAT, *Target,
1812                 AcpiDmEinjActions[Temp8]);
1813             break;
1814 
1815         case ACPI_DMT_EINJINST:
1816 
1817             /* EINJ Instruction types */
1818 
1819             Temp8 = *Target;
1820             if (Temp8 > ACPI_EINJ_INSTRUCTION_RESERVED)
1821             {
1822                 Temp8 = ACPI_EINJ_INSTRUCTION_RESERVED;
1823             }
1824 
1825             AcpiOsPrintf (UINT8_FORMAT, *Target,
1826                 AcpiDmEinjInstructions[Temp8]);
1827             break;
1828 
1829         case ACPI_DMT_ERSTACT:
1830 
1831             /* ERST Action types */
1832 
1833             Temp8 = *Target;
1834             if (Temp8 > ACPI_ERST_ACTION_RESERVED)
1835             {
1836                 Temp8 = ACPI_ERST_ACTION_RESERVED;
1837             }
1838 
1839             AcpiOsPrintf (UINT8_FORMAT, *Target,
1840                 AcpiDmErstActions[Temp8]);
1841             break;
1842 
1843         case ACPI_DMT_ERDT:
1844 
1845             /* ERDT subtable types */
1846 
1847             Temp16 = *Target;
1848             if (Temp16 > ACPI_ERDT_TYPE_RESERVED)
1849             {
1850                 Temp16 = ACPI_ERDT_TYPE_RESERVED;
1851             }
1852 
1853             AcpiOsPrintf (UINT8_FORMAT, *Target,
1854                 AcpiDmErdtSubnames[Temp16]);
1855             break;
1856 
1857         case ACPI_DMT_ERSTINST:
1858 
1859             /* ERST Instruction types */
1860 
1861             Temp8 = *Target;
1862             if (Temp8 > ACPI_ERST_INSTRUCTION_RESERVED)
1863             {
1864                 Temp8 = ACPI_ERST_INSTRUCTION_RESERVED;
1865             }
1866 
1867             AcpiOsPrintf (UINT8_FORMAT, *Target,
1868                 AcpiDmErstInstructions[Temp8]);
1869             break;
1870 
1871         case ACPI_DMT_GTDT:
1872 
1873             /* GTDT subtable types */
1874 
1875             Temp8 = *Target;
1876             if (Temp8 > ACPI_GTDT_TYPE_RESERVED)
1877             {
1878                 Temp8 = ACPI_GTDT_TYPE_RESERVED;
1879             }
1880 
1881             AcpiOsPrintf (UINT8_FORMAT, *Target,
1882                 AcpiDmGtdtSubnames[Temp8]);
1883             break;
1884 
1885         case ACPI_DMT_HEST:
1886 
1887             /* HEST subtable types */
1888 
1889             Temp16 = ACPI_GET16 (Target);
1890             if (Temp16 > ACPI_HEST_TYPE_RESERVED)
1891             {
1892                 Temp16 = ACPI_HEST_TYPE_RESERVED;
1893             }
1894 
1895             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1896                 AcpiDmHestSubnames[Temp16]);
1897             break;
1898 
1899         case ACPI_DMT_HESTNTFY:
1900 
1901             AcpiOsPrintf (STRING_FORMAT,
1902                 "Hardware Error Notification Structure");
1903 
1904             Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1905                 sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify);
1906             if (ACPI_FAILURE (Status))
1907             {
1908                 return (Status);
1909             }
1910 
1911             AcpiOsPrintf ("\n");
1912             LastOutputBlankLine = TRUE;
1913             break;
1914 
1915         case ACPI_DMT_HESTNTYP:
1916 
1917             /* HEST Notify types */
1918 
1919             Temp8 = *Target;
1920             if (Temp8 > ACPI_HEST_NOTIFY_RESERVED)
1921             {
1922                 Temp8 = ACPI_HEST_NOTIFY_RESERVED;
1923             }
1924 
1925             AcpiOsPrintf (UINT8_FORMAT, *Target,
1926                 AcpiDmHestNotifySubnames[Temp8]);
1927             break;
1928 
1929         case ACPI_DMT_HMAT:
1930 
1931             /* HMAT subtable types */
1932 
1933             Temp16 = *Target;
1934             if (Temp16 > ACPI_HMAT_TYPE_RESERVED)
1935             {
1936                 Temp16 = ACPI_HMAT_TYPE_RESERVED;
1937             }
1938 
1939             AcpiOsPrintf (UINT16_FORMAT, *Target,
1940                 AcpiDmHmatSubnames[Temp16]);
1941             break;
1942 
1943         case ACPI_DMT_IORTMEM:
1944 
1945             AcpiOsPrintf (STRING_FORMAT,
1946                 "IORT Memory Access Properties");
1947 
1948             Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1949                 sizeof (ACPI_IORT_MEMORY_ACCESS), AcpiDmTableInfoIortAcc);
1950             if (ACPI_FAILURE (Status))
1951             {
1952                 return (Status);
1953             }
1954 
1955             LastOutputBlankLine = TRUE;
1956             break;
1957 
1958         case ACPI_DMT_MADT:
1959 
1960             /* MADT subtable types */
1961 
1962             Temp8 = *Target;
1963             if ((Temp8 >= ACPI_MADT_TYPE_RESERVED) && (Temp8 < ACPI_MADT_TYPE_OEM_RESERVED))
1964             {
1965                 Temp8 = ACPI_MADT_TYPE_RESERVED;
1966             }
1967             else if (Temp8 >= ACPI_MADT_TYPE_OEM_RESERVED)
1968             {
1969                 Temp8 = ACPI_MADT_TYPE_RESERVED + 1;
1970             }
1971             AcpiOsPrintf (UINT8_FORMAT, *Target,
1972                 AcpiDmMadtSubnames[Temp8]);
1973             break;
1974 
1975         case ACPI_DMT_MPAM_LOCATOR:
1976 
1977             /* MPAM subtable locator types */
1978 
1979             Temp8 = *Target;
1980             if (Temp8 > ACPI_MPAM_LOCATION_TYPE_INTERCONNECT)
1981             {
1982                 Temp8 = ACPI_MPAM_LOCATION_TYPE_INTERCONNECT + 1;
1983             }
1984 
1985             AcpiOsPrintf (UINT8_FORMAT, *Target,
1986                 AcpiDmMpamSubnames[Temp8]);
1987             break;
1988 
1989         case ACPI_DMT_NFIT:
1990 
1991             /* NFIT subtable types */
1992 
1993             Temp16 = ACPI_GET16 (Target);
1994             if (Temp16 > ACPI_NFIT_TYPE_RESERVED)
1995             {
1996                 Temp16 = ACPI_NFIT_TYPE_RESERVED;
1997             }
1998 
1999             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
2000                 AcpiDmNfitSubnames[Temp16]);
2001             break;
2002 
2003         case ACPI_DMT_PCCT:
2004 
2005             /* PCCT subtable types */
2006 
2007             Temp8 = *Target;
2008             if (Temp8 > ACPI_PCCT_TYPE_RESERVED)
2009             {
2010                 Temp8 = ACPI_PCCT_TYPE_RESERVED;
2011             }
2012 
2013             AcpiOsPrintf (UINT8_FORMAT, *Target,
2014                 AcpiDmPcctSubnames[Temp8]);
2015             break;
2016 
2017         case ACPI_DMT_PHAT:
2018 
2019             /* PHAT subtable types */
2020 
2021             Temp16 = ACPI_GET16 (Target);
2022             if (Temp16 > ACPI_PHAT_TYPE_RESERVED)
2023             {
2024                 Temp16 = ACPI_PHAT_TYPE_RESERVED;
2025             }
2026 
2027             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
2028                 AcpiDmPhatSubnames[Temp16]);
2029             break;
2030 
2031         case ACPI_DMT_PMTT:
2032 
2033             /* PMTT subtable types */
2034 
2035             Temp8 = *Target;
2036             if (Temp8 == ACPI_PMTT_TYPE_VENDOR)
2037             {
2038                 Temp8 = ACPI_PMTT_TYPE_RESERVED + 1;
2039             }
2040             else if (Temp8 > ACPI_PMTT_TYPE_RESERVED)
2041             {
2042                 Temp8 = ACPI_PMTT_TYPE_RESERVED;
2043             }
2044             AcpiOsPrintf (UINT8_FORMAT, *Target,
2045                 AcpiDmPmttSubnames[Temp8]);
2046             break;
2047 
2048         case ACPI_DMT_PPTT:
2049 
2050             /* PPTT subtable types */
2051 
2052             Temp8 = *Target;
2053             if (Temp8 > ACPI_PPTT_TYPE_RESERVED)
2054             {
2055                 Temp8 = ACPI_PPTT_TYPE_RESERVED;
2056             }
2057 
2058             AcpiOsPrintf (UINT8_FORMAT, *Target,
2059                 AcpiDmPpttSubnames[Temp8]);
2060             break;
2061 
2062         case ACPI_DMT_UNICODE:
2063         case ACPI_DMT_WPBT_UNICODE:
2064 
2065             if (ByteLength == 0)
2066             {
2067                 AcpiOsPrintf ("/* Zero-length Data */\n");
2068                 break;
2069             }
2070 
2071             AcpiDmDumpUnicode (Table, 0, ByteLength);
2072             break;
2073 
2074         case ACPI_DMT_RAW_BUFFER:
2075         case ACPI_DMT_BUFFER:
2076         case ACPI_DMT_PMTT_VENDOR:
2077 
2078             if (ByteLength == 0)
2079             {
2080                 AcpiOsPrintf ("/* Zero-length Data */\n");
2081                 break;
2082             }
2083 
2084             AcpiDmDumpBuffer (Target, 0, ByteLength, CurrentOffset, NULL);
2085             break;
2086 
2087         case ACPI_DMT_RGRT:
2088 
2089             /* RGRT subtable types */
2090 
2091             Temp8 = *Target;
2092             if (Temp8 >= ACPI_RGRT_TYPE_RESERVED)
2093             {
2094                 Temp8 = ACPI_RGRT_TYPE_RESERVED0;
2095             }
2096 
2097             AcpiOsPrintf (UINT8_FORMAT, *Target,
2098                 AcpiDmRgrtSubnames[Temp8]);
2099             break;
2100 
2101         case ACPI_DMT_RHCT:
2102 
2103             /* RHCT subtable types */
2104 
2105             Temp16 = ACPI_GET16 (Target);
2106             if (Temp16 == ACPI_RHCT_NODE_TYPE_HART_INFO)
2107             {
2108                 Temp16 = ACPI_RHCT_NODE_TYPE_RESERVED;
2109             }
2110 
2111             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
2112                 AcpiDmRhctSubnames[Temp16]);
2113             break;
2114 
2115         case ACPI_DMT_SDEV:
2116 
2117             /* SDEV subtable types */
2118 
2119             Temp8 = *Target;
2120             if (Temp8 > ACPI_SDEV_TYPE_RESERVED)
2121             {
2122                 Temp8 = ACPI_SDEV_TYPE_RESERVED;
2123             }
2124 
2125             AcpiOsPrintf (UINT8_FORMAT, *Target,
2126                 AcpiDmSdevSubnames[Temp8]);
2127             break;
2128 
2129         case ACPI_DMT_SRAT:
2130 
2131             /* SRAT subtable types */
2132 
2133             Temp8 = *Target;
2134             if (Temp8 > ACPI_SRAT_TYPE_RESERVED)
2135             {
2136                 Temp8 = ACPI_SRAT_TYPE_RESERVED;
2137             }
2138 
2139             AcpiOsPrintf (UINT8_FORMAT, *Target,
2140                 AcpiDmSratSubnames[Temp8]);
2141             break;
2142 
2143         case ACPI_DMT_TPM2:
2144 
2145             /* TPM2 Start Method types */
2146 
2147             Temp8 = *Target;
2148             if (Temp8 > ACPI_TPM2_RESERVED)
2149             {
2150                 Temp8 = ACPI_TPM2_RESERVED;
2151             }
2152 
2153             AcpiOsPrintf (UINT8_FORMAT, *Target,
2154                 AcpiDmTpm2Subnames[Temp8]);
2155             break;
2156 
2157 
2158         case ACPI_DMT_FADTPM:
2159 
2160             /* FADT Preferred PM Profile names */
2161 
2162             Temp8 = *Target;
2163             if (Temp8 > ACPI_FADT_PM_RESERVED)
2164             {
2165                 Temp8 = ACPI_FADT_PM_RESERVED;
2166             }
2167 
2168             AcpiOsPrintf (UINT8_FORMAT, *Target,
2169                 AcpiDmFadtProfiles[Temp8]);
2170             break;
2171 
2172         case ACPI_DMT_IOVT:
2173 
2174             /* IOVT subtable types */
2175 
2176             Temp16 = ACPI_GET16(Target);
2177             if (Temp16 > ACPI_IOVT_IOMMU_RESERVED)
2178             {
2179                 Temp16 = ACPI_IOVT_IOMMU_RESERVED;
2180             }
2181 
2182             AcpiOsPrintf(UINT16_FORMAT, Temp16, AcpiDmIovtSubnames[Temp16]);
2183             break;
2184 
2185         case ACPI_DMT_IOVTDEV:
2186 
2187             /* IOVT subtable types */
2188 
2189             Temp8 = *Target;
2190             if (Temp8 > ACPI_IOVT_DEVICE_ENTRY_RESERVED)
2191             {
2192                 Temp8 = ACPI_IOVT_DEVICE_ENTRY_RESERVED;
2193             }
2194 
2195             AcpiOsPrintf (UINT8_FORMAT, *Target,
2196                 AcpiDmIovtdevSubnames[Temp8]);
2197             break;
2198 
2199         case ACPI_DMT_IVRS:
2200 
2201             /* IVRS subtable types */
2202 
2203             Temp8 = *Target;
2204             switch (Temp8)
2205             {
2206             case ACPI_IVRS_TYPE_HARDWARE1:
2207             case ACPI_IVRS_TYPE_HARDWARE2:
2208 
2209                 Name = AcpiDmIvrsSubnames[0];
2210                 break;
2211 
2212             case ACPI_IVRS_TYPE_HARDWARE3:
2213 
2214                 Name = AcpiDmIvrsSubnames[1];
2215                 break;
2216 
2217             case ACPI_IVRS_TYPE_MEMORY1:
2218             case ACPI_IVRS_TYPE_MEMORY2:
2219             case ACPI_IVRS_TYPE_MEMORY3:
2220 
2221                 Name = AcpiDmIvrsSubnames[2];
2222                 break;
2223 
2224             default:
2225 
2226                 Name = AcpiDmIvrsSubnames[3];
2227                 break;
2228             }
2229 
2230             AcpiOsPrintf (UINT8_FORMAT, *Target, Name);
2231             break;
2232 
2233         case ACPI_DMT_IVRS_DE:
2234 
2235             /* IVRS device entry types */
2236 
2237             Temp8 = *Target;
2238             switch (Temp8)
2239             {
2240             case ACPI_IVRS_TYPE_ALL:
2241             case ACPI_IVRS_TYPE_SELECT:
2242             case ACPI_IVRS_TYPE_START:
2243             case ACPI_IVRS_TYPE_END:
2244 
2245                 Name = AcpiDmIvrsDevEntryNames[Temp8];
2246                 break;
2247 
2248             case ACPI_IVRS_TYPE_ALIAS_SELECT:
2249             case ACPI_IVRS_TYPE_ALIAS_START:
2250             case ACPI_IVRS_TYPE_EXT_SELECT:
2251             case ACPI_IVRS_TYPE_EXT_START:
2252             case ACPI_IVRS_TYPE_SPECIAL:
2253 
2254                 Name = AcpiDmIvrsDevEntryNames[Temp8 - 61];
2255                 break;
2256 
2257             case ACPI_IVRS_TYPE_HID:
2258 
2259                 Name = AcpiDmIvrsDevEntryNames[Temp8 - 228];
2260                 break;
2261 
2262             default:
2263                 Name = AcpiDmIvrsDevEntryNames[0];  /* Unknown/Reserved */
2264                 break;
2265             }
2266 
2267             AcpiOsPrintf (UINT8_FORMAT, *Target, Name);
2268             break;
2269 
2270         case ACPI_DMT_LPIT:
2271 
2272             /* LPIT subtable types */
2273 
2274             Temp32 = ACPI_GET32 (Target);
2275             if (Temp32 > ACPI_LPIT_TYPE_RESERVED)
2276             {
2277                 Temp32 = ACPI_LPIT_TYPE_RESERVED;
2278             }
2279 
2280             AcpiOsPrintf (UINT32_FORMAT, ACPI_GET32 (Target),
2281                 AcpiDmLpitSubnames[Temp32]);
2282             break;
2283 
2284         case ACPI_DMT_VIOT:
2285 
2286             /* VIOT subtable types */
2287 
2288             Temp8 = *Target;
2289             if (Temp8 > ACPI_VIOT_RESERVED)
2290             {
2291                 Temp8 = ACPI_VIOT_RESERVED;
2292             }
2293 
2294             AcpiOsPrintf (UINT8_FORMAT, *Target,
2295                 AcpiDmViotSubnames[Temp8]);
2296             break;
2297 
2298         case ACPI_DMT_EXIT:
2299 
2300             return (AE_OK);
2301 
2302         default:
2303 
2304             ACPI_ERROR ((AE_INFO,
2305                 "**** Invalid table opcode [0x%X] ****\n", Info->Opcode));
2306             return (AE_SUPPORT);
2307         }
2308     }
2309 
2310     if (TableOffset && !SubtableLength)
2311     {
2312         /*
2313          * If this table is not the main table, the subtable must have a
2314          * valid length
2315          */
2316         AcpiOsPrintf ("Invalid zero length subtable\n");
2317         return (AE_BAD_DATA);
2318     }
2319 
2320     return (AE_OK);
2321 }
2322