xref: /src/sys/contrib/dev/acpica/common/dmtable.c (revision 1efb6541c67792702db075015d48615168ba3783)
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 - 2025, 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     "Unknown Subtable Type"         /* Reserved */
572 };
573 
574 static const char           *AcpiDmIovtSubnames[] =
575 {
576     "IOMMUv1",
577     "Unknown Subtable Type"         /* Reserved */
578 };
579 
580 static const char           *AcpiDmIovtdevSubnames[] =
581 {
582     "A single PCI device",
583     "Start of range",
584     "End of range",
585     "Unknown Subtable Type"         /* Reserved */
586 };
587 
588 static const char           *AcpiDmIvrsSubnames[] =
589 {
590     "Hardware Definition Block (IVHD)",
591     "Hardware Definition Block - Mixed Format (IVHD)",
592     "Memory Definition Block (IVMD)",
593     "Unknown/Reserved Subtable Type"            /* Reserved */
594 };
595 
596 static const char           *AcpiDmIvrsDevEntryNames[] =
597 {
598     "Unknown/Reserved Device Entry Type",       /* 0- Reserved */
599     "Device Entry: Select All Devices",         /* 1 */
600     "Device Entry: Select One Device",          /* 2 */
601     "Device Entry: Start of Range",             /* 3 */
602     "Device Entry: End of Range",               /* 4 */
603     "Device Entry: Alias Select",               /* 66 */
604     "Device Entry: Alias Start of Range",       /* 67 */
605     "Unknown/Reserved Device Entry Type",       /* 68- Reserved */
606     "Unknown/Reserved Device Entry Type",       /* 69- Reserved */
607     "Device Entry: Extended Select",            /* 70 */
608     "Device Entry: Extended Start of Range",    /* 71 */
609     "Device Entry: Special Device",             /* 72 */
610     "Device Entry: ACPI HID Named Device",      /* 240 */
611     "Unknown/Reserved Device Entry Type"        /* Reserved */
612 };
613 
614 static const char           *AcpiDmLpitSubnames[] =
615 {
616     "Native C-state Idle Structure",
617     "Unknown Subtable Type"         /* Reserved */
618 };
619 
620 static const char           *AcpiDmViotSubnames[] =
621 {
622     "Unknown Subtable Type",        /* 0 -Reserved */
623     "PCI Range",
624     "MMIO Endpoint",
625     "VirtIO-PCI IOMMU",
626     "VirtIO-MMIO IOMMU",
627     "Unknown Subtable Type"         /* Reserved */
628 };
629 
630 #define ACPI_FADT_PM_RESERVED       9
631 
632 static const char           *AcpiDmFadtProfiles[] =
633 {
634     "Unspecified",
635     "Desktop",
636     "Mobile",
637     "Workstation",
638     "Enterprise Server",
639     "SOHO Server",
640     "Appliance PC",
641     "Performance Server",
642     "Tablet",
643     "Unknown Profile Type"
644 };
645 
646 #define ACPI_GAS_WIDTH_RESERVED     5
647 
648 static const char           *AcpiDmGasAccessWidth[] =
649 {
650     "Undefined/Legacy",
651     "Byte Access:8",
652     "Word Access:16",
653     "DWord Access:32",
654     "QWord Access:64",
655     "Unknown Width Encoding"
656 };
657 
658 static const char           *AcpiDmRhctSubnames[] =
659 {
660     "RISC-V ISA string structure",  /* ACPI_RHCT_ISA_STRING */
661     "RISC-V CMO node structure",    /* ACPI_RHCT_CMO_NODE */
662     "RISC-V MMU node structure",    /* ACPI_RHCT_MMU_NODE */
663     "RISC-V Hart Info structure",   /* ACPI_RHCT_HART_INFO */
664 };
665 
666 
667 /*******************************************************************************
668  *
669  * ACPI Table Data, indexed by signature.
670  *
671  * Each entry contains: Signature, Table Info, Handler, DtHandler,
672  *  Template, Description
673  *
674  * Simple tables have only a TableInfo structure, complex tables have a
675  * handler. This table must be NULL terminated. RSDP and FACS are
676  * special-cased elsewhere.
677  *
678  * Note: Any tables added here should be duplicated within
679  * AcpiGbl_SupportedTables in the file common/ahtable.c
680  *
681  ******************************************************************************/
682 
683 const ACPI_DMTABLE_DATA     AcpiDmTableData[] =
684 {
685     {ACPI_SIG_AEST, NULL,                   AcpiDmDumpAest, DtCompileAest,  TemplateAest},
686     {ACPI_SIG_AGDI, AcpiDmTableInfoAgdi,    NULL,           NULL,           TemplateAgdi},
687     {ACPI_SIG_APMT, NULL,                   AcpiDmDumpApmt, DtCompileApmt,  TemplateApmt},
688     {ACPI_SIG_ASF,  NULL,                   AcpiDmDumpAsf,  DtCompileAsf,   TemplateAsf},
689     {ACPI_SIG_ASPT, NULL,                   AcpiDmDumpAspt, DtCompileAspt,  TemplateAspt},
690     {ACPI_SIG_BDAT, AcpiDmTableInfoBdat,    NULL,           NULL,           TemplateBdat},
691     {ACPI_SIG_BERT, AcpiDmTableInfoBert,    NULL,           NULL,           TemplateBert},
692     {ACPI_SIG_BGRT, AcpiDmTableInfoBgrt,    NULL,           NULL,           TemplateBgrt},
693     {ACPI_SIG_BOOT, AcpiDmTableInfoBoot,    NULL,           NULL,           TemplateBoot},
694     {ACPI_SIG_CCEL, AcpiDmTableInfoCcel,    NULL,           NULL,           TemplateCcel},
695     {ACPI_SIG_CDAT, NULL,                   AcpiDmDumpCdat, NULL,           TemplateCdat},
696     {ACPI_SIG_CEDT, NULL,                   AcpiDmDumpCedt, DtCompileCedt,  TemplateCedt},
697     {ACPI_SIG_CPEP, NULL,                   AcpiDmDumpCpep, DtCompileCpep,  TemplateCpep},
698     {ACPI_SIG_CSRT, NULL,                   AcpiDmDumpCsrt, DtCompileCsrt,  TemplateCsrt},
699     {ACPI_SIG_DBG2, AcpiDmTableInfoDbg2,    AcpiDmDumpDbg2, DtCompileDbg2,  TemplateDbg2},
700     {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp,    NULL,           NULL,           TemplateDbgp},
701     {ACPI_SIG_DMAR, NULL,                   AcpiDmDumpDmar, DtCompileDmar,  TemplateDmar},
702     {ACPI_SIG_DRTM, NULL,                   AcpiDmDumpDrtm, DtCompileDrtm,  TemplateDrtm},
703     {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt,    NULL,           NULL,           TemplateEcdt},
704     {ACPI_SIG_EINJ, NULL,                   AcpiDmDumpEinj, DtCompileEinj,  TemplateEinj},
705     {ACPI_SIG_ERDT, NULL,                   AcpiDmDumpErdt, DtCompileErdt,  TemplateErdt},
706     {ACPI_SIG_ERST, NULL,                   AcpiDmDumpErst, DtCompileErst,  TemplateErst},
707     {ACPI_SIG_FADT, NULL,                   AcpiDmDumpFadt, DtCompileFadt,  TemplateFadt},
708     {ACPI_SIG_FPDT, NULL,                   AcpiDmDumpFpdt, DtCompileFpdt,  TemplateFpdt},
709     {ACPI_SIG_GTDT, NULL,                   AcpiDmDumpGtdt, DtCompileGtdt,  TemplateGtdt},
710     {ACPI_SIG_HEST, NULL,                   AcpiDmDumpHest, DtCompileHest,  TemplateHest},
711     {ACPI_SIG_HMAT, NULL,                   AcpiDmDumpHmat, DtCompileHmat,  TemplateHmat},
712     {ACPI_SIG_HPET, AcpiDmTableInfoHpet,    NULL,           NULL,           TemplateHpet},
713     {ACPI_SIG_IORT, NULL,                   AcpiDmDumpIort, DtCompileIort,  TemplateIort},
714     {ACPI_SIG_IOVT, AcpiDmTableInfoIovt,    AcpiDmDumpIovt, DtCompileIovt,  TemplateIovt},
715     {ACPI_SIG_IVRS, NULL,                   AcpiDmDumpIvrs, DtCompileIvrs,  TemplateIvrs},
716     {ACPI_SIG_LPIT, NULL,                   AcpiDmDumpLpit, DtCompileLpit,  TemplateLpit},
717     {ACPI_SIG_MADT, NULL,                   AcpiDmDumpMadt, DtCompileMadt,  TemplateMadt},
718     {ACPI_SIG_MCFG, NULL,                   AcpiDmDumpMcfg, DtCompileMcfg,  TemplateMcfg},
719     {ACPI_SIG_MCHI, AcpiDmTableInfoMchi,    NULL,           NULL,           TemplateMchi},
720     {ACPI_SIG_MPAM, NULL,                   AcpiDmDumpMpam, DtCompileMpam,  TemplateMpam},
721     {ACPI_SIG_MPST, AcpiDmTableInfoMpst,    AcpiDmDumpMpst, DtCompileMpst,  TemplateMpst},
722     {ACPI_SIG_MRRM, NULL,                   AcpiDmDumpMrrm, DtCompileMrrm,  TemplateMrrm},
723     {ACPI_SIG_MSCT, NULL,                   AcpiDmDumpMsct, DtCompileMsct,  TemplateMsct},
724     {ACPI_SIG_MSDM, NULL,                   AcpiDmDumpSlic, DtCompileSlic,  TemplateMsdm},
725     {ACPI_SIG_NFIT, AcpiDmTableInfoNfit,    AcpiDmDumpNfit, DtCompileNfit,  TemplateNfit},
726     {ACPI_SIG_NHLT, NULL,                   NULL,           NULL,           NULL},
727     {ACPI_SIG_PCCT, AcpiDmTableInfoPcct,    AcpiDmDumpPcct, DtCompilePcct,  TemplatePcct},
728     {ACPI_SIG_PDTT, AcpiDmTableInfoPdtt,    AcpiDmDumpPdtt, DtCompilePdtt,  TemplatePdtt},
729     {ACPI_SIG_PHAT, NULL,                   AcpiDmDumpPhat, DtCompilePhat,  TemplatePhat},
730     {ACPI_SIG_PMTT, NULL,                   AcpiDmDumpPmtt, DtCompilePmtt,  TemplatePmtt},
731     {ACPI_SIG_PPTT, NULL,                   AcpiDmDumpPptt, DtCompilePptt,  TemplatePptt},
732     {ACPI_SIG_PRMT, NULL,                   AcpiDmDumpPrmt, DtCompilePrmt,  TemplatePrmt},
733     {ACPI_SIG_RASF, AcpiDmTableInfoRasf,    NULL,           NULL,           TemplateRasf},
734     {ACPI_SIG_RAS2, AcpiDmTableInfoRas2,    AcpiDmDumpRas2, DtCompileRas2,  TemplateRas2},
735     {ACPI_SIG_RGRT, NULL,                   AcpiDmDumpRgrt, DtCompileRgrt,  TemplateRgrt},
736     {ACPI_SIG_RHCT, NULL,                   AcpiDmDumpRhct, DtCompileRhct,  TemplateRhct},
737     {ACPI_SIG_RIMT, NULL,                   AcpiDmDumpRimt, DtCompileRimt,  TemplateRimt},
738     {ACPI_SIG_RSDT, NULL,                   AcpiDmDumpRsdt, DtCompileRsdt,  TemplateRsdt},
739     {ACPI_SIG_S3PT, NULL,                   NULL,           NULL,           TemplateS3pt},
740     {ACPI_SIG_SBST, AcpiDmTableInfoSbst,    NULL,           NULL,           TemplateSbst},
741     {ACPI_SIG_SDEI, AcpiDmTableInfoSdei,    NULL,           NULL,           TemplateSdei},
742     {ACPI_SIG_SDEV, AcpiDmTableInfoSdev,    AcpiDmDumpSdev, DtCompileSdev,  TemplateSdev},
743     {ACPI_SIG_SLIC, NULL,                   AcpiDmDumpSlic, DtCompileSlic,  TemplateSlic},
744     {ACPI_SIG_SLIT, NULL,                   AcpiDmDumpSlit, DtCompileSlit,  TemplateSlit},
745     {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr,    NULL,           NULL,           TemplateSpcr},
746     {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi,    NULL,           NULL,           TemplateSpmi},
747     {ACPI_SIG_SRAT, NULL,                   AcpiDmDumpSrat, DtCompileSrat,  TemplateSrat},
748     {ACPI_SIG_STAO, NULL,                   AcpiDmDumpStao, DtCompileStao,  TemplateStao},
749     {ACPI_SIG_SVKL, AcpiDmTableInfoSvkl,    AcpiDmDumpSvkl, DtCompileSvkl,  TemplateSvkl},
750     {ACPI_SIG_SWFT, AcpiDmTableInfoSwft,    AcpiDmDumpSwft, DtCompileSwft,  TemplateSwft},
751     {ACPI_SIG_TCPA, NULL,                   AcpiDmDumpTcpa, DtCompileTcpa,  TemplateTcpa},
752     {ACPI_SIG_TDEL, AcpiDmTableInfoTdel,    NULL,           NULL,           TemplateTdel},
753     {ACPI_SIG_TPM2, AcpiDmTableInfoTpm2,    AcpiDmDumpTpm2, DtCompileTpm2,  TemplateTpm2},
754     {ACPI_SIG_UEFI, AcpiDmTableInfoUefi,    NULL,           DtCompileUefi,  TemplateUefi},
755     {ACPI_SIG_VIOT, AcpiDmTableInfoViot,    AcpiDmDumpViot, DtCompileViot,  TemplateViot},
756     {ACPI_SIG_WAET, AcpiDmTableInfoWaet,    NULL,           NULL,           TemplateWaet},
757     {ACPI_SIG_WDAT, NULL,                   AcpiDmDumpWdat, DtCompileWdat,  TemplateWdat},
758     {ACPI_SIG_WDDT, AcpiDmTableInfoWddt,    NULL,           NULL,           TemplateWddt},
759     {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt,    NULL,           NULL,           TemplateWdrt},
760     {ACPI_SIG_WPBT, NULL,                   AcpiDmDumpWpbt, DtCompileWpbt,  TemplateWpbt},
761     {ACPI_SIG_WSMT, AcpiDmTableInfoWsmt,    NULL,           NULL,           TemplateWsmt},
762     {ACPI_SIG_XENV, AcpiDmTableInfoXenv,    NULL,           NULL,           TemplateXenv},
763     {ACPI_SIG_XSDT, NULL,                   AcpiDmDumpXsdt, DtCompileXsdt,  TemplateXsdt},
764     {NULL,          NULL,                   NULL,           NULL,           NULL}
765 };
766 
767 
768 /*******************************************************************************
769  *
770  * FUNCTION:    AcpiDmGetTableData
771  *
772  * PARAMETERS:  Signature           - ACPI signature (4 chars) to match
773  *
774  * RETURN:      Pointer to a valid ACPI_DMTABLE_DATA. Null if no match found.
775  *
776  * DESCRIPTION: Find a match in the global table of supported ACPI tables
777  *
778  ******************************************************************************/
779 
780 const ACPI_DMTABLE_DATA *
AcpiDmGetTableData(char * Signature)781 AcpiDmGetTableData (
782     char                    *Signature)
783 {
784     const ACPI_DMTABLE_DATA *Info;
785 
786 
787     for (Info = AcpiDmTableData; Info->Signature; Info++)
788     {
789         if (ACPI_COMPARE_NAMESEG (Signature, Info->Signature))
790         {
791             return (Info);
792         }
793     }
794 
795     return (NULL);
796 }
797 
798 
799 /*******************************************************************************
800  *
801  * FUNCTION:    AcpiDmDumpDataTable
802  *
803  * PARAMETERS:  Table               - An ACPI table
804  *
805  * RETURN:      None.
806  *
807  * DESCRIPTION: Format the contents of an ACPI data table (any table other
808  *              than an SSDT or DSDT that does not contain executable AML code)
809  *
810  ******************************************************************************/
811 
812 void
AcpiDmDumpDataTable(ACPI_TABLE_HEADER * Table)813 AcpiDmDumpDataTable (
814     ACPI_TABLE_HEADER       *Table)
815 {
816     ACPI_STATUS             Status;
817     const ACPI_DMTABLE_DATA *TableData;
818     UINT32                  Length;
819 
820 
821     /* Ignore tables that contain AML */
822 
823     if (AcpiUtIsAmlTable (Table))
824     {
825         if (AslGbl_VerboseTemplates)
826         {
827             /* Dump the raw table data */
828 
829             Length = Table->Length;
830 
831             AcpiOsPrintf ("\n/*\n%s: Length %d (0x%X)\n\n",
832                 ACPI_RAW_TABLE_DATA_HEADER, Length, Length);
833             AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table),
834                 Length, DB_BYTE_DISPLAY, 0);
835             AcpiOsPrintf (" */\n");
836         }
837         return;
838     }
839 
840     /*
841      * Handle tables that don't use the common ACPI table header structure.
842      * Currently, these are the FACS, RSDP, S3PT and CDAT.
843      */
844     if (ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_FACS))
845     {
846         Length = Table->Length;
847         Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFacs);
848         if (ACPI_FAILURE (Status))
849         {
850             return;
851         }
852     }
853     else if (ACPI_VALIDATE_RSDP_SIG (ACPI_CAST_PTR (ACPI_TABLE_RSDP,
854         Table)->Signature))
855     {
856         Length = AcpiDmDumpRsdp (Table);
857     }
858     else if (ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_S3PT))
859     {
860         Length = AcpiDmDumpS3pt (Table);
861     }
862     else if (!AcpiUtValidNameseg (Table->Signature))
863     {
864         /*
865          * For CDAT we are assuming that there should be at least one non-ASCII
866          * byte in the (normally) 4-character Signature field (at least the
867          * high-order byte should be zero).
868          */
869         if (AcpiGbl_CDAT)
870         {
871             /*
872              * Invalid signature and <-ds CDAT> was specified on the command line.
873              * Therefore, we have a CDAT table.
874              */
875             AcpiDmDumpCdat (Table);
876         }
877         else
878         {
879             fprintf (stderr, "Table has an invalid signature\n");
880         }
881 
882         return;
883     }
884     else
885     {
886         /*
887          * All other tables must use the common ACPI table header, dump it now
888          */
889         Length = Table->Length;
890         Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHeader);
891         if (ACPI_FAILURE (Status))
892         {
893             return;
894         }
895         AcpiOsPrintf ("\n");
896 
897         /* Match signature and dispatch appropriately */
898 
899         TableData = AcpiDmGetTableData (Table->Signature);
900         if (!TableData)
901         {
902             if (!strncmp (Table->Signature, "OEM", 3))
903             {
904                 AcpiOsPrintf ("\n**** OEM-defined ACPI table [%4.4s], unknown contents\n\n",
905                     Table->Signature);
906             }
907             else
908             {
909                 AcpiOsPrintf ("\n**** Unknown ACPI table signature [%4.4s]\n\n",
910                     Table->Signature);
911 
912                 fprintf (stderr, "Unknown ACPI table signature [%4.4s], ",
913                     Table->Signature);
914 
915                 if (!AcpiGbl_ForceAmlDisassembly)
916                 {
917                     fprintf (stderr, "decoding ACPI table header only\n");
918                 }
919                 else
920                 {
921                     fprintf (stderr, "assuming table contains valid AML code\n");
922                 }
923             }
924         }
925         else if (TableData->TableHandler)
926         {
927             /* Complex table, has a handler */
928 
929             TableData->TableHandler (Table);
930         }
931         else if (TableData->TableInfo)
932         {
933             /* Simple table, just walk the info table */
934 
935             Status = AcpiDmDumpTable (Length, 0, Table, 0, TableData->TableInfo);
936             if (ACPI_FAILURE (Status))
937             {
938                 return;
939             }
940         }
941     }
942 
943     if (!AslGbl_DoTemplates || AslGbl_VerboseTemplates)
944     {
945         /* Dump the raw table data */
946 
947         AcpiOsPrintf ("\n%s: Length %d (0x%X)\n\n",
948             ACPI_RAW_TABLE_DATA_HEADER, Length, Length);
949         AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table),
950             Length, DB_BYTE_DISPLAY, 0);
951     }
952 }
953 
954 
955 /*******************************************************************************
956  *
957  * FUNCTION:    AcpiDmLineHeader
958  *
959  * PARAMETERS:  Offset              - Current byte offset, from table start
960  *              ByteLength          - Length of the field in bytes, 0 for flags
961  *              Name                - Name of this field
962  *
963  * RETURN:      None
964  *
965  * DESCRIPTION: Utility routines for formatting output lines. Displays the
966  *              current table offset in hex and decimal, the field length,
967  *              and the field name.
968  *
969  ******************************************************************************/
970 
971 void
AcpiDmLineHeader(UINT32 Offset,UINT32 ByteLength,char * Name)972 AcpiDmLineHeader (
973     UINT32                  Offset,
974     UINT32                  ByteLength,
975     char                    *Name)
976 {
977 
978     /* Allow a null name for fields that span multiple lines (large buffers) */
979 
980     if (!Name)
981     {
982         Name = "";
983     }
984 
985     if (AslGbl_DoTemplates && !AslGbl_VerboseTemplates) /* Terse template */
986     {
987         if (ByteLength)
988         {
989             AcpiOsPrintf ("[%.4d] %34s : ", ByteLength, Name);
990         }
991         else
992         {
993             if (*Name)
994             {
995                 AcpiOsPrintf ("%41s : ", Name);
996             }
997             else
998             {
999                 AcpiOsPrintf ("%41s   ", Name);
1000             }
1001         }
1002     }
1003     else /* Normal disassembler or verbose template */
1004     {
1005         if (ByteLength)
1006         {
1007             AcpiOsPrintf ("[%3.3Xh %4.4u %3.3Xh] %27s : ",
1008                 Offset, Offset, ByteLength, Name);
1009         }
1010         else
1011         {
1012             if (*Name)
1013             {
1014                 AcpiOsPrintf ("%44s : ", Name);
1015             }
1016             else
1017             {
1018                 AcpiOsPrintf ("%44s   ", Name);
1019             }
1020         }
1021     }
1022 }
1023 
1024 void
AcpiDmLineHeader2(UINT32 Offset,UINT32 ByteLength,char * Name,UINT32 Value)1025 AcpiDmLineHeader2 (
1026     UINT32                  Offset,
1027     UINT32                  ByteLength,
1028     char                    *Name,
1029     UINT32                  Value)
1030 {
1031 
1032     if (AslGbl_DoTemplates && !AslGbl_VerboseTemplates) /* Terse template */
1033     {
1034         if (ByteLength)
1035         {
1036             AcpiOsPrintf ("[%.4d] %30s %3d : ",
1037                 ByteLength, Name, Value);
1038         }
1039         else
1040         {
1041             AcpiOsPrintf ("%36s % 3d : ",
1042                 Name, Value);
1043         }
1044     }
1045     else /* Normal disassembler or verbose template */
1046     {
1047         if (ByteLength)
1048         {
1049             AcpiOsPrintf ("[%3.3Xh %4.4u %3.3Xh] %24s %3d : ",
1050                 Offset, Offset, ByteLength, Name, Value);
1051         }
1052         else
1053         {
1054             AcpiOsPrintf ("[%3.3Xh %4.4u   ] %24s %3d : ",
1055                 Offset, Offset, Name, Value);
1056         }
1057     }
1058 }
1059 
1060 
1061 /*******************************************************************************
1062  *
1063  * FUNCTION:    AcpiDmDumpTable
1064  *
1065  * PARAMETERS:  TableLength         - Length of the entire ACPI table
1066  *              TableOffset         - Starting offset within the table for this
1067  *                                    sub-descriptor (0 if main table)
1068  *              Table               - The ACPI table
1069  *              SubtableLength      - Length of this sub-descriptor
1070  *              Info                - Info table for this ACPI table
1071  *
1072  * RETURN:      Status
1073  *
1074  * DESCRIPTION: Display ACPI table contents by walking the Info table.
1075  *
1076  * Note: This function must remain in sync with DtGetFieldLength.
1077  *
1078  ******************************************************************************/
1079 
1080 ACPI_STATUS
AcpiDmDumpTable(UINT32 TableLength,UINT32 TableOffset,void * Table,UINT32 SubtableLength,ACPI_DMTABLE_INFO * Info)1081 AcpiDmDumpTable (
1082     UINT32                  TableLength,
1083     UINT32                  TableOffset,
1084     void                    *Table,
1085     UINT32                  SubtableLength,
1086     ACPI_DMTABLE_INFO       *Info)
1087 {
1088     UINT8                   *Target;
1089     UINT32                  CurrentOffset;
1090     UINT32                  ByteLength;
1091     UINT8                   Temp8;
1092     UINT16                  Temp16;
1093     UINT32                  Temp32;
1094     UINT64                  Value;
1095     const AH_TABLE          *TableData;
1096     const char              *Name;
1097     BOOLEAN                 LastOutputBlankLine = FALSE;
1098     ACPI_STATUS             Status;
1099     char                    RepairedName[8];
1100 
1101 
1102     if (!Info)
1103     {
1104         AcpiOsPrintf ("Display not implemented\n");
1105         return (AE_NOT_IMPLEMENTED);
1106     }
1107 
1108     /* Walk entire Info table; Null name terminates */
1109 
1110     for (; Info->Name; Info++)
1111     {
1112         /*
1113          * Target points to the field within the ACPI Table. CurrentOffset is
1114          * the offset of the field from the start of the main table.
1115          */
1116         Target = ACPI_ADD_PTR (UINT8, Table, Info->Offset);
1117         CurrentOffset = TableOffset + Info->Offset;
1118 
1119         /* Check for beyond subtable end or (worse) beyond EOT */
1120 
1121         if (SubtableLength && (Info->Offset > SubtableLength))
1122         {
1123             AcpiOsPrintf (
1124                 "/**** ACPI subtable terminates early (Len %u) - "
1125                 "may be older version (dump table) */\n", SubtableLength);
1126 
1127             /* Move on to next subtable */
1128 
1129             return (AE_OK);
1130         }
1131 
1132         if (CurrentOffset >= TableLength)
1133         {
1134             AcpiOsPrintf (
1135                 "/**** ACPI table terminates "
1136                 "in the middle of a data structure! (dump table)\n"
1137                 "CurrentOffset: %X, TableLength: %X ***/", CurrentOffset, TableLength);
1138             return (AE_BAD_DATA);
1139         }
1140 
1141         /* Generate the byte length for this field */
1142 
1143         switch (Info->Opcode)
1144         {
1145         case ACPI_DMT_UINT8:
1146         case ACPI_DMT_CHKSUM:
1147         case ACPI_DMT_SPACEID:
1148         case ACPI_DMT_ACCWIDTH:
1149         case ACPI_DMT_CEDT:
1150         case ACPI_DMT_IVRS:
1151         case ACPI_DMT_IVRS_DE:
1152         case ACPI_DMT_GTDT:
1153         case ACPI_DMT_MADT:
1154         case ACPI_DMT_MPAM_LOCATOR:
1155         case ACPI_DMT_PCCT:
1156         case ACPI_DMT_PMTT:
1157         case ACPI_DMT_PPTT:
1158         case ACPI_DMT_RGRT:
1159         case ACPI_DMT_SDEV:
1160         case ACPI_DMT_SRAT:
1161         case ACPI_DMT_AEST:
1162         case ACPI_DMT_AEST_RES:
1163         case ACPI_DMT_AEST_XFACE:
1164         case ACPI_DMT_AEST_XRUPT:
1165         case ACPI_DMT_ASF:
1166         case ACPI_DMT_CDAT:
1167         case ACPI_DMT_HESTNTYP:
1168         case ACPI_DMT_FADTPM:
1169         case ACPI_DMT_EINJACT:
1170         case ACPI_DMT_EINJINST:
1171         case ACPI_DMT_ERSTACT:
1172         case ACPI_DMT_ERSTINST:
1173         case ACPI_DMT_DMAR_SCOPE:
1174         case ACPI_DMT_IOVTDEV:
1175         case ACPI_DMT_VIOT:
1176 
1177             ByteLength = 1;
1178             break;
1179 
1180         case ACPI_DMT_ASPT:
1181         case ACPI_DMT_UINT16:
1182         case ACPI_DMT_DMAR:
1183         case ACPI_DMT_ERDT:
1184         case ACPI_DMT_HEST:
1185         case ACPI_DMT_HMAT:
1186         case ACPI_DMT_IOVT:
1187         case ACPI_DMT_NFIT:
1188         case ACPI_DMT_PHAT:
1189         case ACPI_DMT_RHCT:
1190 
1191             ByteLength = 2;
1192             break;
1193 
1194         case ACPI_DMT_UINT24:
1195 
1196             ByteLength = 3;
1197             break;
1198 
1199         case ACPI_DMT_UINT32:
1200         case ACPI_DMT_AEST_CACHE:
1201         case ACPI_DMT_AEST_GIC:
1202         case ACPI_DMT_NAME4:
1203         case ACPI_DMT_SIG:
1204         case ACPI_DMT_LPIT:
1205         case ACPI_DMT_TPM2:
1206 
1207             ByteLength = 4;
1208             break;
1209 
1210         case ACPI_DMT_UINT40:
1211 
1212             ByteLength = 5;
1213             break;
1214 
1215         case ACPI_DMT_UINT48:
1216         case ACPI_DMT_NAME6:
1217 
1218             ByteLength = 6;
1219             break;
1220 
1221         case ACPI_DMT_UINT56:
1222         case ACPI_DMT_BUF7:
1223 
1224             ByteLength = 7;
1225             break;
1226 
1227         case ACPI_DMT_UINT64:
1228         case ACPI_DMT_NAME8:
1229 
1230             ByteLength = 8;
1231             break;
1232 
1233         case ACPI_DMT_BUF10:
1234 
1235             ByteLength = 10;
1236             break;
1237 
1238         case ACPI_DMT_BUF11:
1239 
1240             ByteLength = 11;
1241             break;
1242 
1243         case ACPI_DMT_BUF12:
1244 
1245             ByteLength = 12;
1246             break;
1247 
1248         case ACPI_DMT_BUF16:
1249         case ACPI_DMT_UUID:
1250 
1251             ByteLength = 16;
1252             break;
1253 
1254         case ACPI_DMT_BUF18:
1255 
1256             ByteLength = 18;
1257             break;
1258 
1259         case ACPI_DMT_BUF24:
1260 
1261             ByteLength = 24;
1262             break;
1263 
1264         case ACPI_DMT_BUF26:
1265 
1266             ByteLength = 26;
1267             break;
1268 
1269         case ACPI_DMT_BUF32:
1270 
1271             ByteLength = 32;
1272             break;
1273 
1274         case ACPI_DMT_BUF112:
1275 
1276             ByteLength = 112;
1277             break;
1278 
1279         case ACPI_DMT_BUF128:
1280 
1281             ByteLength = 128;
1282             break;
1283 
1284         case ACPI_DMT_WPBT_UNICODE:
1285 
1286             ByteLength = SubtableLength;
1287             CurrentOffset = sizeof (ACPI_TABLE_WPBT);
1288             break;
1289 
1290         case ACPI_DMT_UNICODE:
1291         case ACPI_DMT_BUFFER:
1292         case ACPI_DMT_RAW_BUFFER:
1293 
1294             ByteLength = SubtableLength;
1295             break;
1296 
1297         case ACPI_DMT_PMTT_VENDOR:
1298             /*
1299              * Calculate the length of the vendor data for the PMTT table:
1300              * Length = (Current Subtable ptr + Subtable length) -
1301              *          Start of the vendor data (Target)
1302              */
1303             ByteLength = ((ACPI_CAST_PTR (char, Table) +
1304                             (ACPI_CAST_PTR (ACPI_PMTT_HEADER, Table)->Length)) -
1305                             ACPI_CAST_PTR (char, Target));
1306             break;
1307 
1308         case ACPI_DMT_STRING:
1309 
1310             ByteLength = strlen (ACPI_CAST_PTR (char, Target)) + 1;
1311             break;
1312 
1313         case ACPI_DMT_IVRS_UNTERMINATED_STRING:
1314 
1315             ByteLength = ((ACPI_CAST_PTR (ACPI_IVRS_DEVICE_HID, Target) -1)->UidLength);
1316             break;
1317 
1318         case ACPI_DMT_GAS:
1319 
1320             if (!LastOutputBlankLine)
1321             {
1322                 AcpiOsPrintf ("\n");
1323                 LastOutputBlankLine = TRUE;
1324             }
1325 
1326             ByteLength = sizeof (ACPI_GENERIC_ADDRESS);
1327             break;
1328 
1329         case ACPI_DMT_HESTNTFY:
1330 
1331             if (!LastOutputBlankLine)
1332             {
1333                 AcpiOsPrintf ("\n");
1334                 LastOutputBlankLine = TRUE;
1335             }
1336 
1337             ByteLength = sizeof (ACPI_HEST_NOTIFY);
1338             break;
1339 
1340         case ACPI_DMT_IORTMEM:
1341 
1342             if (!LastOutputBlankLine)
1343             {
1344                 LastOutputBlankLine = FALSE;
1345             }
1346 
1347             ByteLength = sizeof (ACPI_IORT_MEMORY_ACCESS);
1348             break;
1349 
1350         default:
1351 
1352             ByteLength = 0;
1353             break;
1354         }
1355 
1356         /* Check if we are beyond a subtable, or (worse) beyond EOT */
1357 
1358         if (CurrentOffset + ByteLength > TableLength)
1359         {
1360             if (SubtableLength)
1361             {
1362                 AcpiOsPrintf (
1363                     "/**** ACPI subtable terminates early - "
1364                     "may be older version (dump table) */\n");
1365 
1366                 /* Move on to next subtable */
1367 
1368                 return (AE_OK);
1369             }
1370 
1371             AcpiOsPrintf (
1372                 "/**** ACPI table terminates "
1373                 "in the middle of a data structure! */\n");
1374             return (AE_BAD_DATA);
1375         }
1376 
1377         if (Info->Opcode == ACPI_DMT_EXTRA_TEXT)
1378         {
1379             AcpiOsPrintf ("%s", Info->Name);
1380             continue;
1381         }
1382 
1383         /* Start a new line and decode the opcode */
1384 
1385         AcpiDmLineHeader (CurrentOffset, ByteLength, Info->Name);
1386 
1387         switch (Info->Opcode)
1388         {
1389         /* Single-bit Flag fields. Note: Opcode is the bit position */
1390 
1391         case ACPI_DMT_FLAG0:
1392         case ACPI_DMT_FLAG1:
1393         case ACPI_DMT_FLAG2:
1394         case ACPI_DMT_FLAG3:
1395         case ACPI_DMT_FLAG4:
1396         case ACPI_DMT_FLAG5:
1397         case ACPI_DMT_FLAG6:
1398         case ACPI_DMT_FLAG7:
1399 
1400             AcpiOsPrintf ("%1.1X\n", (*Target >> Info->Opcode) & 0x01);
1401             break;
1402 
1403         /* 2-bit Flag fields */
1404 
1405         case ACPI_DMT_FLAGS0:
1406 
1407             AcpiOsPrintf ("%1.1X\n", *Target & 0x03);
1408             break;
1409 
1410         case ACPI_DMT_FLAGS1:
1411 
1412             AcpiOsPrintf ("%1.1X\n", (*Target >> 1) & 0x03);
1413             break;
1414 
1415         case ACPI_DMT_FLAGS2:
1416 
1417             AcpiOsPrintf ("%1.1X\n", (*Target >> 2) & 0x03);
1418             break;
1419 
1420         case ACPI_DMT_FLAGS8_2:
1421 
1422             AcpiOsPrintf ("%2.2X\n", (*Target >> 2) & 0xFF);
1423             break;
1424 
1425         case ACPI_DMT_FLAGS4:
1426 
1427             AcpiOsPrintf ("%1.1X\n", (*Target >> 4) & 0x03);
1428             break;
1429 
1430         case ACPI_DMT_FLAGS4_0:
1431 
1432             AcpiOsPrintf ("%1.1X\n", (*(UINT32 *)Target) & 0x0F);
1433             break;
1434 
1435         case ACPI_DMT_FLAGS4_4:
1436 
1437             AcpiOsPrintf ("%1.1X\n", (*(UINT32 *)Target >> 4) & 0x0F);
1438             break;
1439 
1440         case ACPI_DMT_FLAGS4_8:
1441 
1442             AcpiOsPrintf ("%1.1X\n", (*(UINT32 *)Target >> 8) & 0x0F);
1443             break;
1444 
1445         case ACPI_DMT_FLAGS4_12:
1446 
1447             AcpiOsPrintf ("%1.1X\n", (*(UINT32 *)Target >> 12) & 0x0F);
1448             break;
1449 
1450         case ACPI_DMT_FLAGS16_16:
1451 
1452             AcpiOsPrintf ("%4.4X\n", (*(UINT32 *)Target >> 16) & 0xFFFF);
1453             break;
1454 
1455         /* Integer Data Types */
1456 
1457         case ACPI_DMT_UINT8:
1458         case ACPI_DMT_UINT16:
1459         case ACPI_DMT_UINT24:
1460         case ACPI_DMT_UINT32:
1461         case ACPI_DMT_UINT40:
1462         case ACPI_DMT_UINT48:
1463         case ACPI_DMT_UINT56:
1464         case ACPI_DMT_UINT64:
1465             /*
1466              * Dump bytes - high byte first, low byte last.
1467              * Note: All ACPI tables are little-endian.
1468              */
1469             Value = 0;
1470             for (Temp8 = (UINT8) ByteLength; Temp8 > 0; Temp8--)
1471             {
1472                 AcpiOsPrintf ("%2.2X", Target[Temp8 - 1]);
1473                 Value |= Target[Temp8 - 1];
1474                 Value <<= 8;
1475             }
1476 
1477             if (!Value && (Info->Flags & DT_DESCRIBES_OPTIONAL))
1478             {
1479                 AcpiOsPrintf (" [Optional field not present]");
1480             }
1481 
1482             AcpiOsPrintf ("\n");
1483             break;
1484 
1485         case ACPI_DMT_BUF7:
1486         case ACPI_DMT_BUF10:
1487         case ACPI_DMT_BUF11:
1488         case ACPI_DMT_BUF12:
1489         case ACPI_DMT_BUF16:
1490         case ACPI_DMT_BUF18:
1491         case ACPI_DMT_BUF24:
1492         case ACPI_DMT_BUF26:
1493         case ACPI_DMT_BUF32:
1494         case ACPI_DMT_BUF112:
1495         case ACPI_DMT_BUF128:
1496             /*
1497              * Buffer: Size depends on the opcode and was set above.
1498              * Each hex byte is separated with a space.
1499              * Multiple lines are separated by line continuation char.
1500              */
1501             for (Temp16 = 0; Temp16 < ByteLength; Temp16++)
1502             {
1503                 AcpiOsPrintf ("%2.2X", Target[Temp16]);
1504                 if ((UINT32) (Temp16 + 1) < ByteLength)
1505                 {
1506                     if ((Temp16 > 0) && (!((Temp16+1) % 16)))
1507                     {
1508                         AcpiOsPrintf (" \\\n"); /* Line continuation */
1509                         AcpiDmLineHeader (0, 0, NULL);
1510                     }
1511                     else
1512                     {
1513                         AcpiOsPrintf (" ");
1514                     }
1515                 }
1516             }
1517 
1518             AcpiOsPrintf ("\n");
1519             break;
1520 
1521         case ACPI_DMT_UUID:
1522 
1523             /* Convert 16-byte UUID buffer to 36-byte formatted UUID string */
1524 
1525             (void) AcpiUtConvertUuidToString ((char *) Target, AslGbl_MsgBuffer);
1526 
1527             AcpiOsPrintf ("%s\n", AslGbl_MsgBuffer);
1528             break;
1529 
1530         case ACPI_DMT_STRING:
1531 
1532             AcpiOsPrintf ("\"%s\"\n", ACPI_CAST_PTR (char, Target));
1533             break;
1534 
1535         case ACPI_DMT_IVRS_UNTERMINATED_STRING:
1536 
1537             AcpiOsPrintf ("\"%.*s\"\n", ByteLength, ACPI_CAST_PTR (char, Target));
1538             break;
1539 
1540         /* Fixed length ASCII name fields */
1541 
1542         case ACPI_DMT_SIG:
1543 
1544             AcpiUtCheckAndRepairAscii (Target, RepairedName, 4);
1545             AcpiOsPrintf ("\"%.4s\"    ", RepairedName);
1546 
1547             TableData = AcpiAhGetTableInfo (ACPI_CAST_PTR (char, Target));
1548             if (TableData)
1549             {
1550                 AcpiOsPrintf (STRING_FORMAT, TableData->Description);
1551             }
1552             else
1553             {
1554                 AcpiOsPrintf ("\n");
1555             }
1556             break;
1557 
1558         case ACPI_DMT_NAME4:
1559 
1560             AcpiUtCheckAndRepairAscii (Target, RepairedName, 4);
1561             AcpiOsPrintf ("\"%.4s\"\n", RepairedName);
1562             break;
1563 
1564         case ACPI_DMT_NAME6:
1565 
1566             AcpiUtCheckAndRepairAscii (Target, RepairedName, 6);
1567             AcpiOsPrintf ("\"%.6s\"\n", RepairedName);
1568             break;
1569 
1570         case ACPI_DMT_NAME8:
1571 
1572             AcpiUtCheckAndRepairAscii (Target, RepairedName, 8);
1573             AcpiOsPrintf ("\"%.8s\"\n", RepairedName);
1574             break;
1575 
1576         /* Special Data Types */
1577 
1578         case ACPI_DMT_CHKSUM:
1579 
1580             /* Checksum, display and validate */
1581 
1582             AcpiOsPrintf ("%2.2X", *Target);
1583             Temp8 = AcpiUtGenerateChecksum (Table,
1584                 ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length,
1585                 ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum);
1586 
1587             if (Temp8 != ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum)
1588             {
1589                 AcpiOsPrintf (
1590                     "     /* Incorrect checksum, should be %2.2X */", Temp8);
1591             }
1592 
1593             AcpiOsPrintf ("\n");
1594             break;
1595 
1596         case ACPI_DMT_SPACEID:
1597 
1598             /* Address Space ID */
1599 
1600             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiUtGetRegionName (*Target));
1601             break;
1602 
1603         case ACPI_DMT_ACCWIDTH:
1604 
1605             /* Encoded Access Width */
1606 
1607             Temp8 = *Target;
1608             if (Temp8 > ACPI_GAS_WIDTH_RESERVED)
1609             {
1610                 Temp8 = ACPI_GAS_WIDTH_RESERVED;
1611             }
1612 
1613             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmGasAccessWidth[Temp8]);
1614             break;
1615 
1616         case ACPI_DMT_GAS:
1617 
1618             /* Generic Address Structure */
1619 
1620             AcpiOsPrintf (STRING_FORMAT, "Generic Address Structure");
1621             Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1622                 sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas);
1623             if (ACPI_FAILURE (Status))
1624             {
1625                 return (Status);
1626             }
1627 
1628             AcpiOsPrintf ("\n");
1629             LastOutputBlankLine = TRUE;
1630             break;
1631 
1632         case ACPI_DMT_AEST:
1633 
1634             /* AEST subtable types */
1635 
1636             Temp8 = *Target;
1637             if (Temp8 > ACPI_AEST_NODE_TYPE_RESERVED)
1638             {
1639                 Temp8 = ACPI_AEST_NODE_TYPE_RESERVED;
1640             }
1641 
1642             AcpiOsPrintf (UINT8_FORMAT, *Target,
1643                 AcpiDmAestSubnames[Temp8]);
1644             break;
1645 
1646         case ACPI_DMT_AEST_CACHE:
1647 
1648             /* AEST cache resource subtable */
1649 
1650             Temp32 = *Target;
1651             if (Temp32 > ACPI_AEST_CACHE_RESERVED)
1652             {
1653                 Temp32 = ACPI_AEST_CACHE_RESERVED;
1654             }
1655 
1656             AcpiOsPrintf (UINT32_FORMAT, *Target,
1657                 AcpiDmAestCacheNames[Temp32]);
1658             break;
1659 
1660         case ACPI_DMT_AEST_GIC:
1661 
1662             /* AEST GIC error subtable */
1663 
1664             Temp32 = *Target;
1665             if (Temp32 > ACPI_AEST_GIC_RESERVED)
1666             {
1667                 Temp32 = ACPI_AEST_GIC_RESERVED;
1668             }
1669 
1670             AcpiOsPrintf (UINT32_FORMAT, *Target,
1671                 AcpiDmAestGicNames[Temp32]);
1672             break;
1673 
1674         case ACPI_DMT_AEST_RES:
1675 
1676             /* AEST resource type subtable */
1677 
1678             Temp8 = *Target;
1679             if (Temp8 > ACPI_AEST_RESOURCE_RESERVED)
1680             {
1681                 Temp8 = ACPI_AEST_RESOURCE_RESERVED;
1682             }
1683 
1684             AcpiOsPrintf (UINT8_FORMAT, *Target,
1685                 AcpiDmAestResourceNames[Temp8]);
1686             break;
1687 
1688         case ACPI_DMT_AEST_XFACE:
1689 
1690             /* AEST interface structure types */
1691 
1692             Temp8 = *Target;
1693             if (Temp8 > ACPI_AEST_XFACE_RESERVED)
1694             {
1695                 Temp8 = ACPI_AEST_XFACE_RESERVED;
1696             }
1697 
1698             AcpiOsPrintf (UINT8_FORMAT, *Target,
1699                 AcpiDmAestXfaceNames[Temp8]);
1700             break;
1701 
1702         case ACPI_DMT_AEST_XRUPT:
1703 
1704             /* AEST interrupt structure types */
1705 
1706             Temp8 = *Target;
1707             if (Temp8 > ACPI_AEST_XRUPT_RESERVED)
1708             {
1709                 Temp8 = ACPI_AEST_XRUPT_RESERVED;
1710             }
1711 
1712             AcpiOsPrintf (UINT8_FORMAT, *Target,
1713                 AcpiDmAestXruptNames[Temp8]);
1714             break;
1715 
1716         case ACPI_DMT_ASPT:
1717             /* ASPT subtable types */
1718             Temp16 = ACPI_GET16(Target);
1719             if (Temp16 > ACPI_ASPT_TYPE_UNKNOWN)
1720             {
1721                 Temp16 = ACPI_ASPT_TYPE_UNKNOWN;
1722             }
1723 
1724             AcpiOsPrintf(UINT16_FORMAT, Temp16, AcpiDmAsptSubnames[Temp16]);
1725             break;
1726 
1727         case ACPI_DMT_ASF:
1728 
1729             /* ASF subtable types */
1730 
1731             Temp16 = (UINT16) ((*Target) & 0x7F);  /* Top bit can be zero or one */
1732             if (Temp16 > ACPI_ASF_TYPE_RESERVED)
1733             {
1734                 Temp16 = ACPI_ASF_TYPE_RESERVED;
1735             }
1736 
1737             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmAsfSubnames[Temp16]);
1738             break;
1739 
1740         case ACPI_DMT_CDAT:
1741 
1742             /* CDAT subtable types */
1743 
1744             Temp8 = *Target;
1745             if (Temp8 > ACPI_CDAT_TYPE_RESERVED)
1746             {
1747                 Temp8 = ACPI_CDAT_TYPE_RESERVED;
1748             }
1749 
1750             AcpiOsPrintf (UINT8_FORMAT, *Target,
1751                 AcpiDmCdatSubnames[Temp8]);
1752             break;
1753 
1754         case ACPI_DMT_CEDT:
1755 
1756             /* CEDT subtable types */
1757 
1758             Temp8 = *Target;
1759             if (Temp8 > ACPI_CEDT_TYPE_RESERVED)
1760             {
1761                 Temp8 = ACPI_CEDT_TYPE_RESERVED;
1762             }
1763 
1764             AcpiOsPrintf (UINT8_FORMAT, *Target,
1765                 AcpiDmCedtSubnames[Temp8]);
1766             break;
1767 
1768         case ACPI_DMT_DMAR:
1769 
1770             /* DMAR subtable types */
1771 
1772             Temp16 = ACPI_GET16 (Target);
1773             if (Temp16 > ACPI_DMAR_TYPE_RESERVED)
1774             {
1775                 Temp16 = ACPI_DMAR_TYPE_RESERVED;
1776             }
1777 
1778             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1779                 AcpiDmDmarSubnames[Temp16]);
1780             break;
1781 
1782         case ACPI_DMT_DMAR_SCOPE:
1783 
1784             /* DMAR device scope types */
1785 
1786             Temp8 = *Target;
1787             if (Temp8 > ACPI_DMAR_SCOPE_TYPE_RESERVED)
1788             {
1789                 Temp8 = ACPI_DMAR_SCOPE_TYPE_RESERVED;
1790             }
1791 
1792             AcpiOsPrintf (UINT8_FORMAT, *Target,
1793                 AcpiDmDmarScope[Temp8]);
1794             break;
1795 
1796         case ACPI_DMT_EINJACT:
1797 
1798             /* EINJ Action types */
1799 
1800             Temp8 = *Target;
1801             if (Temp8 > ACPI_EINJ_ACTION_RESERVED)
1802             {
1803                 Temp8 = ACPI_EINJ_ACTION_RESERVED;
1804             }
1805 
1806             AcpiOsPrintf (UINT8_FORMAT, *Target,
1807                 AcpiDmEinjActions[Temp8]);
1808             break;
1809 
1810         case ACPI_DMT_EINJINST:
1811 
1812             /* EINJ Instruction types */
1813 
1814             Temp8 = *Target;
1815             if (Temp8 > ACPI_EINJ_INSTRUCTION_RESERVED)
1816             {
1817                 Temp8 = ACPI_EINJ_INSTRUCTION_RESERVED;
1818             }
1819 
1820             AcpiOsPrintf (UINT8_FORMAT, *Target,
1821                 AcpiDmEinjInstructions[Temp8]);
1822             break;
1823 
1824         case ACPI_DMT_ERSTACT:
1825 
1826             /* ERST Action types */
1827 
1828             Temp8 = *Target;
1829             if (Temp8 > ACPI_ERST_ACTION_RESERVED)
1830             {
1831                 Temp8 = ACPI_ERST_ACTION_RESERVED;
1832             }
1833 
1834             AcpiOsPrintf (UINT8_FORMAT, *Target,
1835                 AcpiDmErstActions[Temp8]);
1836             break;
1837 
1838         case ACPI_DMT_ERDT:
1839 
1840             /* ERDT subtable types */
1841 
1842             Temp16 = *Target;
1843             if (Temp16 > ACPI_ERDT_TYPE_RESERVED)
1844             {
1845                 Temp16 = ACPI_ERDT_TYPE_RESERVED;
1846             }
1847 
1848             AcpiOsPrintf (UINT8_FORMAT, *Target,
1849                 AcpiDmErdtSubnames[Temp16]);
1850             break;
1851 
1852         case ACPI_DMT_ERSTINST:
1853 
1854             /* ERST Instruction types */
1855 
1856             Temp8 = *Target;
1857             if (Temp8 > ACPI_ERST_INSTRUCTION_RESERVED)
1858             {
1859                 Temp8 = ACPI_ERST_INSTRUCTION_RESERVED;
1860             }
1861 
1862             AcpiOsPrintf (UINT8_FORMAT, *Target,
1863                 AcpiDmErstInstructions[Temp8]);
1864             break;
1865 
1866         case ACPI_DMT_GTDT:
1867 
1868             /* GTDT subtable types */
1869 
1870             Temp8 = *Target;
1871             if (Temp8 > ACPI_GTDT_TYPE_RESERVED)
1872             {
1873                 Temp8 = ACPI_GTDT_TYPE_RESERVED;
1874             }
1875 
1876             AcpiOsPrintf (UINT8_FORMAT, *Target,
1877                 AcpiDmGtdtSubnames[Temp8]);
1878             break;
1879 
1880         case ACPI_DMT_HEST:
1881 
1882             /* HEST subtable types */
1883 
1884             Temp16 = ACPI_GET16 (Target);
1885             if (Temp16 > ACPI_HEST_TYPE_RESERVED)
1886             {
1887                 Temp16 = ACPI_HEST_TYPE_RESERVED;
1888             }
1889 
1890             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1891                 AcpiDmHestSubnames[Temp16]);
1892             break;
1893 
1894         case ACPI_DMT_HESTNTFY:
1895 
1896             AcpiOsPrintf (STRING_FORMAT,
1897                 "Hardware Error Notification Structure");
1898 
1899             Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1900                 sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify);
1901             if (ACPI_FAILURE (Status))
1902             {
1903                 return (Status);
1904             }
1905 
1906             AcpiOsPrintf ("\n");
1907             LastOutputBlankLine = TRUE;
1908             break;
1909 
1910         case ACPI_DMT_HESTNTYP:
1911 
1912             /* HEST Notify types */
1913 
1914             Temp8 = *Target;
1915             if (Temp8 > ACPI_HEST_NOTIFY_RESERVED)
1916             {
1917                 Temp8 = ACPI_HEST_NOTIFY_RESERVED;
1918             }
1919 
1920             AcpiOsPrintf (UINT8_FORMAT, *Target,
1921                 AcpiDmHestNotifySubnames[Temp8]);
1922             break;
1923 
1924         case ACPI_DMT_HMAT:
1925 
1926             /* HMAT subtable types */
1927 
1928             Temp16 = *Target;
1929             if (Temp16 > ACPI_HMAT_TYPE_RESERVED)
1930             {
1931                 Temp16 = ACPI_HMAT_TYPE_RESERVED;
1932             }
1933 
1934             AcpiOsPrintf (UINT16_FORMAT, *Target,
1935                 AcpiDmHmatSubnames[Temp16]);
1936             break;
1937 
1938         case ACPI_DMT_IORTMEM:
1939 
1940             AcpiOsPrintf (STRING_FORMAT,
1941                 "IORT Memory Access Properties");
1942 
1943             Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1944                 sizeof (ACPI_IORT_MEMORY_ACCESS), AcpiDmTableInfoIortAcc);
1945             if (ACPI_FAILURE (Status))
1946             {
1947                 return (Status);
1948             }
1949 
1950             LastOutputBlankLine = TRUE;
1951             break;
1952 
1953         case ACPI_DMT_MADT:
1954 
1955             /* MADT subtable types */
1956 
1957             Temp8 = *Target;
1958             if ((Temp8 >= ACPI_MADT_TYPE_RESERVED) && (Temp8 < ACPI_MADT_TYPE_OEM_RESERVED))
1959             {
1960                 Temp8 = ACPI_MADT_TYPE_RESERVED;
1961             }
1962             else if (Temp8 >= ACPI_MADT_TYPE_OEM_RESERVED)
1963             {
1964                 Temp8 = ACPI_MADT_TYPE_RESERVED + 1;
1965             }
1966             AcpiOsPrintf (UINT8_FORMAT, *Target,
1967                 AcpiDmMadtSubnames[Temp8]);
1968             break;
1969 
1970         case ACPI_DMT_MPAM_LOCATOR:
1971 
1972             /* MPAM subtable locator types */
1973 
1974             Temp8 = *Target;
1975             if (Temp8 > ACPI_MPAM_LOCATION_TYPE_INTERCONNECT)
1976             {
1977                 Temp8 = ACPI_MPAM_LOCATION_TYPE_INTERCONNECT + 1;
1978             }
1979 
1980             AcpiOsPrintf (UINT8_FORMAT, *Target,
1981                 AcpiDmMpamSubnames[Temp8]);
1982             break;
1983 
1984         case ACPI_DMT_NFIT:
1985 
1986             /* NFIT subtable types */
1987 
1988             Temp16 = ACPI_GET16 (Target);
1989             if (Temp16 > ACPI_NFIT_TYPE_RESERVED)
1990             {
1991                 Temp16 = ACPI_NFIT_TYPE_RESERVED;
1992             }
1993 
1994             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1995                 AcpiDmNfitSubnames[Temp16]);
1996             break;
1997 
1998         case ACPI_DMT_PCCT:
1999 
2000             /* PCCT subtable types */
2001 
2002             Temp8 = *Target;
2003             if (Temp8 > ACPI_PCCT_TYPE_RESERVED)
2004             {
2005                 Temp8 = ACPI_PCCT_TYPE_RESERVED;
2006             }
2007 
2008             AcpiOsPrintf (UINT8_FORMAT, *Target,
2009                 AcpiDmPcctSubnames[Temp8]);
2010             break;
2011 
2012         case ACPI_DMT_PHAT:
2013 
2014             /* PHAT subtable types */
2015 
2016             Temp16 = ACPI_GET16 (Target);
2017             if (Temp16 > ACPI_PHAT_TYPE_RESERVED)
2018             {
2019                 Temp16 = ACPI_PHAT_TYPE_RESERVED;
2020             }
2021 
2022             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
2023                 AcpiDmPhatSubnames[Temp16]);
2024             break;
2025 
2026         case ACPI_DMT_PMTT:
2027 
2028             /* PMTT subtable types */
2029 
2030             Temp8 = *Target;
2031             if (Temp8 == ACPI_PMTT_TYPE_VENDOR)
2032             {
2033                 Temp8 = ACPI_PMTT_TYPE_RESERVED + 1;
2034             }
2035             else if (Temp8 > ACPI_PMTT_TYPE_RESERVED)
2036             {
2037                 Temp8 = ACPI_PMTT_TYPE_RESERVED;
2038             }
2039             AcpiOsPrintf (UINT8_FORMAT, *Target,
2040                 AcpiDmPmttSubnames[Temp8]);
2041             break;
2042 
2043         case ACPI_DMT_PPTT:
2044 
2045             /* PPTT subtable types */
2046 
2047             Temp8 = *Target;
2048             if (Temp8 > ACPI_PPTT_TYPE_RESERVED)
2049             {
2050                 Temp8 = ACPI_PPTT_TYPE_RESERVED;
2051             }
2052 
2053             AcpiOsPrintf (UINT8_FORMAT, *Target,
2054                 AcpiDmPpttSubnames[Temp8]);
2055             break;
2056 
2057         case ACPI_DMT_UNICODE:
2058         case ACPI_DMT_WPBT_UNICODE:
2059 
2060             if (ByteLength == 0)
2061             {
2062                 AcpiOsPrintf ("/* Zero-length Data */\n");
2063                 break;
2064             }
2065 
2066             AcpiDmDumpUnicode (Table, 0, ByteLength);
2067             break;
2068 
2069         case ACPI_DMT_RAW_BUFFER:
2070         case ACPI_DMT_BUFFER:
2071         case ACPI_DMT_PMTT_VENDOR:
2072 
2073             if (ByteLength == 0)
2074             {
2075                 AcpiOsPrintf ("/* Zero-length Data */\n");
2076                 break;
2077             }
2078 
2079             AcpiDmDumpBuffer (Target, 0, ByteLength, CurrentOffset, NULL);
2080             break;
2081 
2082         case ACPI_DMT_RGRT:
2083 
2084             /* RGRT subtable types */
2085 
2086             Temp8 = *Target;
2087             if (Temp8 >= ACPI_RGRT_TYPE_RESERVED)
2088             {
2089                 Temp8 = ACPI_RGRT_TYPE_RESERVED0;
2090             }
2091 
2092             AcpiOsPrintf (UINT8_FORMAT, *Target,
2093                 AcpiDmRgrtSubnames[Temp8]);
2094             break;
2095 
2096         case ACPI_DMT_RHCT:
2097 
2098             /* RHCT subtable types */
2099 
2100             Temp16 = ACPI_GET16 (Target);
2101             if (Temp16 == ACPI_RHCT_NODE_TYPE_HART_INFO)
2102             {
2103                 Temp16 = ACPI_RHCT_NODE_TYPE_RESERVED;
2104             }
2105 
2106             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
2107                 AcpiDmRhctSubnames[Temp16]);
2108             break;
2109 
2110         case ACPI_DMT_SDEV:
2111 
2112             /* SDEV subtable types */
2113 
2114             Temp8 = *Target;
2115             if (Temp8 > ACPI_SDEV_TYPE_RESERVED)
2116             {
2117                 Temp8 = ACPI_SDEV_TYPE_RESERVED;
2118             }
2119 
2120             AcpiOsPrintf (UINT8_FORMAT, *Target,
2121                 AcpiDmSdevSubnames[Temp8]);
2122             break;
2123 
2124         case ACPI_DMT_SRAT:
2125 
2126             /* SRAT subtable types */
2127 
2128             Temp8 = *Target;
2129             if (Temp8 > ACPI_SRAT_TYPE_RESERVED)
2130             {
2131                 Temp8 = ACPI_SRAT_TYPE_RESERVED;
2132             }
2133 
2134             AcpiOsPrintf (UINT8_FORMAT, *Target,
2135                 AcpiDmSratSubnames[Temp8]);
2136             break;
2137 
2138         case ACPI_DMT_TPM2:
2139 
2140             /* TPM2 Start Method types */
2141 
2142             Temp8 = *Target;
2143             if (Temp8 > ACPI_TPM2_RESERVED)
2144             {
2145                 Temp8 = ACPI_TPM2_RESERVED;
2146             }
2147 
2148             AcpiOsPrintf (UINT8_FORMAT, *Target,
2149                 AcpiDmTpm2Subnames[Temp8]);
2150             break;
2151 
2152 
2153         case ACPI_DMT_FADTPM:
2154 
2155             /* FADT Preferred PM Profile names */
2156 
2157             Temp8 = *Target;
2158             if (Temp8 > ACPI_FADT_PM_RESERVED)
2159             {
2160                 Temp8 = ACPI_FADT_PM_RESERVED;
2161             }
2162 
2163             AcpiOsPrintf (UINT8_FORMAT, *Target,
2164                 AcpiDmFadtProfiles[Temp8]);
2165             break;
2166 
2167         case ACPI_DMT_IOVT:
2168 
2169             /* IOVT subtable types */
2170 
2171             Temp16 = ACPI_GET16(Target);
2172             if (Temp16 > ACPI_IOVT_IOMMU_RESERVED)
2173             {
2174                 Temp16 = ACPI_IOVT_IOMMU_RESERVED;
2175             }
2176 
2177             AcpiOsPrintf(UINT16_FORMAT, Temp16, AcpiDmIovtSubnames[Temp16]);
2178             break;
2179 
2180         case ACPI_DMT_IOVTDEV:
2181 
2182             /* IOVT subtable types */
2183 
2184             Temp8 = *Target;
2185             if (Temp8 > ACPI_IOVT_DEVICE_ENTRY_RESERVED)
2186             {
2187                 Temp8 = ACPI_IOVT_DEVICE_ENTRY_RESERVED;
2188             }
2189 
2190             AcpiOsPrintf (UINT8_FORMAT, *Target,
2191                 AcpiDmIovtdevSubnames[Temp8]);
2192             break;
2193 
2194         case ACPI_DMT_IVRS:
2195 
2196             /* IVRS subtable types */
2197 
2198             Temp8 = *Target;
2199             switch (Temp8)
2200             {
2201             case ACPI_IVRS_TYPE_HARDWARE1:
2202             case ACPI_IVRS_TYPE_HARDWARE2:
2203 
2204                 Name = AcpiDmIvrsSubnames[0];
2205                 break;
2206 
2207             case ACPI_IVRS_TYPE_HARDWARE3:
2208 
2209                 Name = AcpiDmIvrsSubnames[1];
2210                 break;
2211 
2212             case ACPI_IVRS_TYPE_MEMORY1:
2213             case ACPI_IVRS_TYPE_MEMORY2:
2214             case ACPI_IVRS_TYPE_MEMORY3:
2215 
2216                 Name = AcpiDmIvrsSubnames[2];
2217                 break;
2218 
2219             default:
2220 
2221                 Name = AcpiDmIvrsSubnames[3];
2222                 break;
2223             }
2224 
2225             AcpiOsPrintf (UINT8_FORMAT, *Target, Name);
2226             break;
2227 
2228         case ACPI_DMT_IVRS_DE:
2229 
2230             /* IVRS device entry types */
2231 
2232             Temp8 = *Target;
2233             switch (Temp8)
2234             {
2235             case ACPI_IVRS_TYPE_ALL:
2236             case ACPI_IVRS_TYPE_SELECT:
2237             case ACPI_IVRS_TYPE_START:
2238             case ACPI_IVRS_TYPE_END:
2239 
2240                 Name = AcpiDmIvrsDevEntryNames[Temp8];
2241                 break;
2242 
2243             case ACPI_IVRS_TYPE_ALIAS_SELECT:
2244             case ACPI_IVRS_TYPE_ALIAS_START:
2245             case ACPI_IVRS_TYPE_EXT_SELECT:
2246             case ACPI_IVRS_TYPE_EXT_START:
2247             case ACPI_IVRS_TYPE_SPECIAL:
2248 
2249                 Name = AcpiDmIvrsDevEntryNames[Temp8 - 61];
2250                 break;
2251 
2252             case ACPI_IVRS_TYPE_HID:
2253 
2254                 Name = AcpiDmIvrsDevEntryNames[Temp8 - 228];
2255                 break;
2256 
2257             default:
2258                 Name = AcpiDmIvrsDevEntryNames[0];  /* Unknown/Reserved */
2259                 break;
2260             }
2261 
2262             AcpiOsPrintf (UINT8_FORMAT, *Target, Name);
2263             break;
2264 
2265         case ACPI_DMT_LPIT:
2266 
2267             /* LPIT subtable types */
2268 
2269             Temp32 = ACPI_GET32 (Target);
2270             if (Temp32 > ACPI_LPIT_TYPE_RESERVED)
2271             {
2272                 Temp32 = ACPI_LPIT_TYPE_RESERVED;
2273             }
2274 
2275             AcpiOsPrintf (UINT32_FORMAT, ACPI_GET32 (Target),
2276                 AcpiDmLpitSubnames[Temp32]);
2277             break;
2278 
2279         case ACPI_DMT_VIOT:
2280 
2281             /* VIOT subtable types */
2282 
2283             Temp8 = *Target;
2284             if (Temp8 > ACPI_VIOT_RESERVED)
2285             {
2286                 Temp8 = ACPI_VIOT_RESERVED;
2287             }
2288 
2289             AcpiOsPrintf (UINT8_FORMAT, *Target,
2290                 AcpiDmViotSubnames[Temp8]);
2291             break;
2292 
2293         case ACPI_DMT_EXIT:
2294 
2295             return (AE_OK);
2296 
2297         default:
2298 
2299             ACPI_ERROR ((AE_INFO,
2300                 "**** Invalid table opcode [0x%X] ****\n", Info->Opcode));
2301             return (AE_SUPPORT);
2302         }
2303     }
2304 
2305     if (TableOffset && !SubtableLength)
2306     {
2307         /*
2308          * If this table is not the main table, the subtable must have a
2309          * valid length
2310          */
2311         AcpiOsPrintf ("Invalid zero length subtable\n");
2312         return (AE_BAD_DATA);
2313     }
2314 
2315     return (AE_OK);
2316 }
2317