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