1 /******************************************************************************
3 * Module Name: dmtable - Support for ACPI tables that contain no AML code
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2015, Intel Corp.
12 * All rights reserved.
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
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
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;
37 * The above copyright and patent license is granted only if the following
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.
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
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
72 * 3.4. Intel retains all right, title, and interest in and to the Original
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.
80 * 4. Disclaimer and Export Compliance
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
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
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.
114 *****************************************************************************/
117 #include "accommon.h"
118 #include "acdisasm.h"
119 #include "actables.h"
120 #include "aslcompiler.h"
121 #include "dtcompiler.h"
123 /* This module used for application-level code only */
125 #define _COMPONENT ACPI_CA_DISASSEMBLER
126 ACPI_MODULE_NAME ("dmtable")
133 /* Local Prototypes */
142 /* Common format strings for commented values */
144 #define UINT8_FORMAT "%2.2X [%s]\n"
145 #define UINT16_FORMAT "%4.4X [%s]\n"
146 #define UINT32_FORMAT "%8.8X [%s]\n"
147 #define STRING_FORMAT "[%s]\n"
149 /* These tables map a subtable type to a description string */
151 static const char *AcpiDmAsfSubnames[] =
155 "ASF Remote Control",
156 "ASF RMCP Boot Options",
158 "Unknown Subtable Type" /* Reserved */
161 static const char *AcpiDmDmarSubnames[] =
163 "Hardware Unit Definition",
164 "Reserved Memory Region",
165 "Root Port ATS Capability",
166 "Remapping Hardware Static Affinity",
167 "ACPI Namespace Device Declaration",
168 "Unknown Subtable Type" /* Reserved */
171 static const char *AcpiDmDmarScope[] =
174 "PCI Endpoint Device",
177 "Message-capable HPET Device",
179 "Unknown Scope Type" /* Reserved */
182 static const char *AcpiDmEinjActions[] =
191 "Get Command Status",
192 "Set Error Type With Address",
196 static const char *AcpiDmEinjInstructions[] =
199 "Read Register Value",
201 "Write Register Value",
204 "Unknown Instruction"
207 static const char *AcpiDmErstActions[] =
209 "Begin Write Operation",
210 "Begin Read Operation",
211 "Begin Clear Operation",
216 "Get Command Status",
217 "Get Record Identifier",
218 "Set Record Identifier",
221 "Unused/Unknown Action",
222 "Get Error Address Range",
223 "Get Error Address Length",
224 "Get Error Attributes",
228 static const char *AcpiDmErstInstructions[] =
231 "Read Register Value",
233 "Write Register Value",
246 "Set Source Address",
247 "Set Destination Address",
249 "Unknown Instruction"
252 static const char *AcpiDmGtdtSubnames[] =
254 "Generic Timer Block",
255 "Generic Watchdog Timer",
256 "Unknown Subtable Type" /* Reserved */
259 static const char *AcpiDmHestSubnames[] =
261 "IA-32 Machine Check Exception",
262 "IA-32 Corrected Machine Check",
263 "IA-32 Non-Maskable Interrupt",
264 "Unknown SubTable Type", /* 3 - Reserved */
265 "Unknown SubTable Type", /* 4 - Reserved */
266 "Unknown SubTable Type", /* 5 - Reserved */
267 "PCI Express Root Port AER",
268 "PCI Express AER (AER Endpoint)",
269 "PCI Express/PCI-X Bridge AER",
270 "Generic Hardware Error Source",
271 "Unknown Subtable Type" /* Reserved */
274 static const char *AcpiDmHestNotifySubnames[] =
277 "External Interrupt",
281 "CMCI", /* ACPI 5.0 */
282 "MCE", /* ACPI 5.0 */
283 "Unknown Notify Type" /* Reserved */
286 static const char *AcpiDmMadtSubnames[] =
288 "Processor Local APIC", /* ACPI_MADT_TYPE_LOCAL_APIC */
289 "I/O APIC", /* ACPI_MADT_TYPE_IO_APIC */
290 "Interrupt Source Override", /* ACPI_MADT_TYPE_INTERRUPT_OVERRIDE */
291 "NMI Source", /* ACPI_MADT_TYPE_NMI_SOURCE */
292 "Local APIC NMI", /* ACPI_MADT_TYPE_LOCAL_APIC_NMI */
293 "Local APIC Address Override", /* ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE */
294 "I/O SAPIC", /* ACPI_MADT_TYPE_IO_SAPIC */
295 "Local SAPIC", /* ACPI_MADT_TYPE_LOCAL_SAPIC */
296 "Platform Interrupt Sources", /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */
297 "Processor Local x2APIC", /* ACPI_MADT_TYPE_LOCAL_X2APIC */
298 "Local x2APIC NMI", /* ACPI_MADT_TYPE_LOCAL_X2APIC_NMI */
299 "Generic Interrupt Controller", /* ACPI_MADT_GENERIC_INTERRUPT */
300 "Generic Interrupt Distributor", /* ACPI_MADT_GENERIC_DISTRIBUTOR */
301 "Generic MSI Frame", /* ACPI_MADT_GENERIC_MSI_FRAME */
302 "Generic Interrupt Redistributor", /* ACPI_MADT_GENERIC_REDISTRIBUTOR */
303 "Generic Interrupt Translator", /* ACPI_MADT_GENERIC_TRANSLATOR */
304 "Unknown Subtable Type" /* Reserved */
307 static const char *AcpiDmNfitSubnames[] =
309 "System Physical Address Range", /* ACPI_NFIT_TYPE_SYSTEM_ADDRESS */
310 "Memory Range Map", /* ACPI_NFIT_TYPE_MEMORY_MAP */
311 "Interleave Info", /* ACPI_NFIT_TYPE_INTERLEAVE */
312 "SMBIOS Information", /* ACPI_NFIT_TYPE_SMBIOS */
313 "NVDIMM Control Region", /* ACPI_NFIT_TYPE_CONTROL_REGION */
314 "NVDIMM Block Data Window Region", /* ACPI_NFIT_TYPE_DATA_REGION */
315 "Flush Hint Address", /* ACPI_NFIT_TYPE_FLUSH_ADDRESS */
316 "Unknown Subtable Type" /* Reserved */
319 static const char *AcpiDmPcctSubnames[] =
321 "Generic Communications Subspace", /* ACPI_PCCT_TYPE_GENERIC_SUBSPACE */
322 "HW-Reduced Comm Subspace", /* ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE */
323 "Unknown Subtable Type" /* Reserved */
326 static const char *AcpiDmPmttSubnames[] =
328 "Socket", /* ACPI_PMTT_TYPE_SOCKET */
329 "Memory Controller", /* ACPI_PMTT_TYPE_CONTROLLER */
330 "Physical Component (DIMM)", /* ACPI_PMTT_TYPE_DIMM */
331 "Unknown Subtable Type" /* Reserved */
334 static const char *AcpiDmSratSubnames[] =
336 "Processor Local APIC/SAPIC Affinity",
338 "Processor Local x2APIC Affinity",
340 "Unknown Subtable Type" /* Reserved */
343 static const char *AcpiDmIvrsSubnames[] =
345 "Hardware Definition Block",
346 "Memory Definition Block",
347 "Unknown Subtable Type" /* Reserved */
350 static const char *AcpiDmLpitSubnames[] =
352 "Native C-state Idle Structure",
353 "Unknown Subtable Type" /* Reserved */
356 #define ACPI_FADT_PM_RESERVED 9
358 static const char *AcpiDmFadtProfiles[] =
367 "Performance Server",
369 "Unknown Profile Type"
372 #define ACPI_GAS_WIDTH_RESERVED 5
374 static const char *AcpiDmGasAccessWidth[] =
381 "Unknown Width Encoding"
385 /*******************************************************************************
387 * ACPI Table Data, indexed by signature.
389 * Each entry contains: Signature, Table Info, Handler, DtHandler,
390 * Template, Description
392 * Simple tables have only a TableInfo structure, complex tables have a
393 * handler. This table must be NULL terminated. RSDP and FACS are
394 * special-cased elsewhere.
396 * Note: Any tables added here should be duplicated within AcpiSupportedTables
397 * in the file common/ahtable.c
399 ******************************************************************************/
401 const ACPI_DMTABLE_DATA AcpiDmTableData[] =
403 {ACPI_SIG_ASF, NULL, AcpiDmDumpAsf, DtCompileAsf, TemplateAsf},
404 {ACPI_SIG_BERT, AcpiDmTableInfoBert, NULL, NULL, TemplateBert},
405 {ACPI_SIG_BGRT, AcpiDmTableInfoBgrt, NULL, NULL, TemplateBgrt},
406 {ACPI_SIG_BOOT, AcpiDmTableInfoBoot, NULL, NULL, TemplateBoot},
407 {ACPI_SIG_CPEP, NULL, AcpiDmDumpCpep, DtCompileCpep, TemplateCpep},
408 {ACPI_SIG_CSRT, NULL, AcpiDmDumpCsrt, DtCompileCsrt, TemplateCsrt},
409 {ACPI_SIG_DBG2, AcpiDmTableInfoDbg2, AcpiDmDumpDbg2, DtCompileDbg2, TemplateDbg2},
410 {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp, NULL, NULL, TemplateDbgp},
411 {ACPI_SIG_DMAR, NULL, AcpiDmDumpDmar, DtCompileDmar, TemplateDmar},
412 {ACPI_SIG_DRTM, NULL, AcpiDmDumpDrtm, DtCompileDrtm, TemplateDrtm},
413 {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt, NULL, NULL, TemplateEcdt},
414 {ACPI_SIG_EINJ, NULL, AcpiDmDumpEinj, DtCompileEinj, TemplateEinj},
415 {ACPI_SIG_ERST, NULL, AcpiDmDumpErst, DtCompileErst, TemplateErst},
416 {ACPI_SIG_FADT, NULL, AcpiDmDumpFadt, DtCompileFadt, TemplateFadt},
417 {ACPI_SIG_FPDT, NULL, AcpiDmDumpFpdt, DtCompileFpdt, TemplateFpdt},
418 {ACPI_SIG_GTDT, NULL, AcpiDmDumpGtdt, DtCompileGtdt, TemplateGtdt},
419 {ACPI_SIG_HEST, NULL, AcpiDmDumpHest, DtCompileHest, TemplateHest},
420 {ACPI_SIG_HPET, AcpiDmTableInfoHpet, NULL, NULL, TemplateHpet},
421 {ACPI_SIG_IORT, NULL, AcpiDmDumpIort, DtCompileIort, TemplateIort},
422 {ACPI_SIG_IVRS, NULL, AcpiDmDumpIvrs, DtCompileIvrs, TemplateIvrs},
423 {ACPI_SIG_LPIT, NULL, AcpiDmDumpLpit, DtCompileLpit, TemplateLpit},
424 {ACPI_SIG_MADT, NULL, AcpiDmDumpMadt, DtCompileMadt, TemplateMadt},
425 {ACPI_SIG_MCFG, NULL, AcpiDmDumpMcfg, DtCompileMcfg, TemplateMcfg},
426 {ACPI_SIG_MCHI, AcpiDmTableInfoMchi, NULL, NULL, TemplateMchi},
427 {ACPI_SIG_MPST, AcpiDmTableInfoMpst, AcpiDmDumpMpst, DtCompileMpst, TemplateMpst},
428 {ACPI_SIG_MSCT, NULL, AcpiDmDumpMsct, DtCompileMsct, TemplateMsct},
429 {ACPI_SIG_MSDM, NULL, AcpiDmDumpSlic, DtCompileSlic, TemplateMsdm},
430 {ACPI_SIG_MTMR, NULL, AcpiDmDumpMtmr, DtCompileMtmr, TemplateMtmr},
431 {ACPI_SIG_NFIT, AcpiDmTableInfoNfit, AcpiDmDumpNfit, DtCompileNfit, TemplateNfit},
432 {ACPI_SIG_PCCT, AcpiDmTableInfoPcct, AcpiDmDumpPcct, DtCompilePcct, TemplatePcct},
433 {ACPI_SIG_PMTT, NULL, AcpiDmDumpPmtt, DtCompilePmtt, TemplatePmtt},
434 {ACPI_SIG_RSDT, NULL, AcpiDmDumpRsdt, DtCompileRsdt, TemplateRsdt},
435 {ACPI_SIG_S3PT, NULL, NULL, NULL, TemplateS3pt},
436 {ACPI_SIG_SBST, AcpiDmTableInfoSbst, NULL, NULL, TemplateSbst},
437 {ACPI_SIG_SLIC, NULL, AcpiDmDumpSlic, DtCompileSlic, TemplateSlic},
438 {ACPI_SIG_SLIT, NULL, AcpiDmDumpSlit, DtCompileSlit, TemplateSlit},
439 {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr, NULL, NULL, TemplateSpcr},
440 {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi, NULL, NULL, TemplateSpmi},
441 {ACPI_SIG_SRAT, NULL, AcpiDmDumpSrat, DtCompileSrat, TemplateSrat},
442 {ACPI_SIG_STAO, NULL, AcpiDmDumpStao, DtCompileStao, TemplateStao},
443 {ACPI_SIG_TCPA, AcpiDmTableInfoTcpa, NULL, NULL, TemplateTcpa},
444 {ACPI_SIG_TPM2, AcpiDmTableInfoTpm2, NULL, NULL, TemplateTpm2},
445 {ACPI_SIG_UEFI, AcpiDmTableInfoUefi, NULL, DtCompileUefi, TemplateUefi},
446 {ACPI_SIG_VRTC, AcpiDmTableInfoVrtc, AcpiDmDumpVrtc, DtCompileVrtc, TemplateVrtc},
447 {ACPI_SIG_WAET, AcpiDmTableInfoWaet, NULL, NULL, TemplateWaet},
448 {ACPI_SIG_WDAT, NULL, AcpiDmDumpWdat, DtCompileWdat, TemplateWdat},
449 {ACPI_SIG_WDDT, AcpiDmTableInfoWddt, NULL, NULL, TemplateWddt},
450 {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt, NULL, NULL, TemplateWdrt},
451 {ACPI_SIG_WPBT, NULL, AcpiDmDumpWpbt, DtCompileWpbt, TemplateWpbt},
452 {ACPI_SIG_XENV, AcpiDmTableInfoXenv, NULL, NULL, TemplateXenv},
453 {ACPI_SIG_XSDT, NULL, AcpiDmDumpXsdt, DtCompileXsdt, TemplateXsdt},
454 {NULL, NULL, NULL, NULL, NULL}
458 /*******************************************************************************
460 * FUNCTION: AcpiDmGenerateChecksum
462 * PARAMETERS: Table - Pointer to table to be checksummed
463 * Length - Length of the table
464 * OriginalChecksum - Value of the checksum field
466 * RETURN: 8 bit checksum of buffer
468 * DESCRIPTION: Computes an 8 bit checksum of the table.
470 ******************************************************************************/
473 AcpiDmGenerateChecksum (
476 UINT8 OriginalChecksum)
481 /* Sum the entire table as-is */
483 Checksum = AcpiTbChecksum ((UINT8 *) Table, Length);
485 /* Subtract off the existing checksum value in the table */
487 Checksum = (UINT8) (Checksum - OriginalChecksum);
489 /* Compute the final checksum */
491 Checksum = (UINT8) (0 - Checksum);
496 /*******************************************************************************
498 * FUNCTION: AcpiDmGetTableData
500 * PARAMETERS: Signature - ACPI signature (4 chars) to match
502 * RETURN: Pointer to a valid ACPI_DMTABLE_DATA. Null if no match found.
504 * DESCRIPTION: Find a match in the global table of supported ACPI tables
506 ******************************************************************************/
508 const ACPI_DMTABLE_DATA *
512 const ACPI_DMTABLE_DATA *Info;
515 for (Info = AcpiDmTableData; Info->Signature; Info++)
517 if (ACPI_COMPARE_NAME (Signature, Info->Signature))
527 /*******************************************************************************
529 * FUNCTION: AcpiDmDumpDataTable
531 * PARAMETERS: Table - An ACPI table
535 * DESCRIPTION: Format the contents of an ACPI data table (any table other
536 * than an SSDT or DSDT that does not contain executable AML code)
538 ******************************************************************************/
541 AcpiDmDumpDataTable (
542 ACPI_TABLE_HEADER *Table)
545 const ACPI_DMTABLE_DATA *TableData;
549 /* Ignore tables that contain AML */
551 if (AcpiUtIsAmlTable (Table))
553 if (Gbl_VerboseTemplates)
555 /* Dump the raw table data */
557 Length = Table->Length;
559 AcpiOsPrintf ("\n/*\n%s: Length %d (0x%X)\n\n",
560 ACPI_RAW_TABLE_DATA_HEADER, Length, Length);
561 AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table),
562 Length, DB_BYTE_DISPLAY, 0);
563 AcpiOsPrintf (" */\n");
569 * Handle tables that don't use the common ACPI table header structure.
570 * Currently, these are the FACS, RSDP, and S3PT.
572 if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS))
574 Length = Table->Length;
575 AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFacs);
577 else if (ACPI_VALIDATE_RSDP_SIG (Table->Signature))
579 Length = AcpiDmDumpRsdp (Table);
581 else if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_S3PT))
583 Length = AcpiDmDumpS3pt (Table);
588 * All other tables must use the common ACPI table header, dump it now
590 Length = Table->Length;
591 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHeader);
592 if (ACPI_FAILURE (Status))
598 /* Match signature and dispatch appropriately */
600 TableData = AcpiDmGetTableData (Table->Signature);
603 if (!ACPI_STRNCMP (Table->Signature, "OEM", 3))
605 AcpiOsPrintf ("\n**** OEM-defined ACPI table [%4.4s], unknown contents\n\n",
610 AcpiOsPrintf ("\n**** Unknown ACPI table signature [%4.4s]\n\n",
613 fprintf (stderr, "Unknown ACPI table signature [%4.4s], ",
616 if (!AcpiGbl_ForceAmlDisassembly)
618 fprintf (stderr, "decoding ACPI table header only\n");
622 fprintf (stderr, "assuming table contains valid AML code\n");
626 else if (TableData->TableHandler)
628 /* Complex table, has a handler */
630 TableData->TableHandler (Table);
632 else if (TableData->TableInfo)
634 /* Simple table, just walk the info table */
636 AcpiDmDumpTable (Length, 0, Table, 0, TableData->TableInfo);
640 if (!Gbl_DoTemplates || Gbl_VerboseTemplates)
642 /* Dump the raw table data */
644 AcpiOsPrintf ("\n%s: Length %d (0x%X)\n\n",
645 ACPI_RAW_TABLE_DATA_HEADER, Length, Length);
646 AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table),
647 Length, DB_BYTE_DISPLAY, 0);
652 /*******************************************************************************
654 * FUNCTION: AcpiDmLineHeader
656 * PARAMETERS: Offset - Current byte offset, from table start
657 * ByteLength - Length of the field in bytes, 0 for flags
658 * Name - Name of this field
662 * DESCRIPTION: Utility routines for formatting output lines. Displays the
663 * current table offset in hex and decimal, the field length,
664 * and the field name.
666 ******************************************************************************/
675 /* Allow a null name for fields that span multiple lines (large buffers) */
682 if (Gbl_DoTemplates && !Gbl_VerboseTemplates) /* Terse template */
686 AcpiOsPrintf ("[%.4d] %34s : ", ByteLength, Name);
692 AcpiOsPrintf ("%41s : ", Name);
696 AcpiOsPrintf ("%41s ", Name);
700 else /* Normal disassembler or verbose template */
704 AcpiOsPrintf ("[%3.3Xh %4.4d% 4d] %28s : ",
705 Offset, Offset, ByteLength, Name);
711 AcpiOsPrintf ("%44s : ", Name);
715 AcpiOsPrintf ("%44s ", Name);
729 if (Gbl_DoTemplates && !Gbl_VerboseTemplates) /* Terse template */
733 AcpiOsPrintf ("[%.4d] %30s %3d : ",
734 ByteLength, Name, Value);
738 AcpiOsPrintf ("%36s % 3d : ",
742 else /* Normal disassembler or verbose template */
746 AcpiOsPrintf ("[%3.3Xh %4.4d %3d] %24s %3d : ",
747 Offset, Offset, ByteLength, Name, Value);
751 AcpiOsPrintf ("[%3.3Xh %4.4d ] %24s %3d : ",
752 Offset, Offset, Name, Value);
758 /*******************************************************************************
760 * FUNCTION: AcpiDmDumpTable
762 * PARAMETERS: TableLength - Length of the entire ACPI table
763 * TableOffset - Starting offset within the table for this
764 * sub-descriptor (0 if main table)
765 * Table - The ACPI table
766 * SubtableLength - Length of this sub-descriptor
767 * Info - Info table for this ACPI table
771 * DESCRIPTION: Display ACPI table contents by walking the Info table.
773 * Note: This function must remain in sync with DtGetFieldLength.
775 ******************************************************************************/
782 UINT32 SubtableLength,
783 ACPI_DMTABLE_INFO *Info)
786 UINT32 CurrentOffset;
792 const AH_TABLE *TableData;
794 BOOLEAN LastOutputBlankLine = FALSE;
795 char RepairedName[8];
800 AcpiOsPrintf ("Display not implemented\n");
801 return (AE_NOT_IMPLEMENTED);
804 /* Walk entire Info table; Null name terminates */
806 for (; Info->Name; Info++)
809 * Target points to the field within the ACPI Table. CurrentOffset is
810 * the offset of the field from the start of the main table.
812 Target = ACPI_ADD_PTR (UINT8, Table, Info->Offset);
813 CurrentOffset = TableOffset + Info->Offset;
815 /* Check for beyond subtable end or (worse) beyond EOT */
817 if (SubtableLength && (Info->Offset >= SubtableLength))
820 "/**** ACPI subtable terminates early - "
821 "may be older version (dump table) */\n");
823 /* Move on to next subtable */
828 if (CurrentOffset >= TableLength)
831 "/**** ACPI table terminates "
832 "in the middle of a data structure! (dump table) */\n");
833 return (AE_BAD_DATA);
836 /* Generate the byte length for this field */
838 switch (Info->Opcode)
841 case ACPI_DMT_CHKSUM:
842 case ACPI_DMT_SPACEID:
843 case ACPI_DMT_ACCWIDTH:
851 case ACPI_DMT_HESTNTYP:
852 case ACPI_DMT_FADTPM:
853 case ACPI_DMT_EINJACT:
854 case ACPI_DMT_EINJINST:
855 case ACPI_DMT_ERSTACT:
856 case ACPI_DMT_ERSTINST:
857 case ACPI_DMT_DMAR_SCOPE:
862 case ACPI_DMT_UINT16:
870 case ACPI_DMT_UINT24:
875 case ACPI_DMT_UINT32:
883 case ACPI_DMT_UINT40:
888 case ACPI_DMT_UINT48:
894 case ACPI_DMT_UINT56:
900 case ACPI_DMT_UINT64:
917 case ACPI_DMT_BUF128:
922 case ACPI_DMT_UNICODE:
923 case ACPI_DMT_BUFFER:
924 case ACPI_DMT_RAW_BUFFER:
926 ByteLength = SubtableLength;
929 case ACPI_DMT_STRING:
931 ByteLength = ACPI_STRLEN (ACPI_CAST_PTR (char, Target)) + 1;
936 if (!LastOutputBlankLine)
939 LastOutputBlankLine = TRUE;
941 ByteLength = sizeof (ACPI_GENERIC_ADDRESS);
944 case ACPI_DMT_HESTNTFY:
946 if (!LastOutputBlankLine)
949 LastOutputBlankLine = TRUE;
951 ByteLength = sizeof (ACPI_HEST_NOTIFY);
954 case ACPI_DMT_IORTMEM:
956 if (!LastOutputBlankLine)
958 LastOutputBlankLine = FALSE;
960 ByteLength = sizeof (ACPI_IORT_MEMORY_ACCESS);
969 /* Check if we are beyond a subtable, or (worse) beyond EOT */
971 if (CurrentOffset + ByteLength > TableLength)
976 "/**** ACPI subtable terminates early - "
977 "may be older version (dump table) */\n");
979 /* Move on to next subtable */
985 "/**** ACPI table terminates "
986 "in the middle of a data structure! */\n");
987 return (AE_BAD_DATA);
990 if (Info->Opcode == ACPI_DMT_EXTRA_TEXT)
992 AcpiOsPrintf ("%s", Info->Name);
996 /* Start a new line and decode the opcode */
998 AcpiDmLineHeader (CurrentOffset, ByteLength, Info->Name);
1000 switch (Info->Opcode)
1002 /* Single-bit Flag fields. Note: Opcode is the bit position */
1004 case ACPI_DMT_FLAG0:
1005 case ACPI_DMT_FLAG1:
1006 case ACPI_DMT_FLAG2:
1007 case ACPI_DMT_FLAG3:
1008 case ACPI_DMT_FLAG4:
1009 case ACPI_DMT_FLAG5:
1010 case ACPI_DMT_FLAG6:
1011 case ACPI_DMT_FLAG7:
1013 AcpiOsPrintf ("%1.1X\n", (*Target >> Info->Opcode) & 0x01);
1016 /* 2-bit Flag fields */
1018 case ACPI_DMT_FLAGS0:
1020 AcpiOsPrintf ("%1.1X\n", *Target & 0x03);
1023 case ACPI_DMT_FLAGS1:
1025 AcpiOsPrintf ("%1.1X\n", (*Target >> 1) & 0x03);
1028 case ACPI_DMT_FLAGS2:
1030 AcpiOsPrintf ("%1.1X\n", (*Target >> 2) & 0x03);
1033 case ACPI_DMT_FLAGS4:
1035 AcpiOsPrintf ("%1.1X\n", (*Target >> 4) & 0x03);
1038 /* Integer Data Types */
1040 case ACPI_DMT_UINT8:
1041 case ACPI_DMT_UINT16:
1042 case ACPI_DMT_UINT24:
1043 case ACPI_DMT_UINT32:
1044 case ACPI_DMT_UINT40:
1045 case ACPI_DMT_UINT48:
1046 case ACPI_DMT_UINT56:
1047 case ACPI_DMT_UINT64:
1049 * Dump bytes - high byte first, low byte last.
1050 * Note: All ACPI tables are little-endian.
1053 for (Temp8 = (UINT8) ByteLength; Temp8 > 0; Temp8--)
1055 AcpiOsPrintf ("%2.2X", Target[Temp8 - 1]);
1056 Value |= Target[Temp8 - 1];
1060 if (!Value && (Info->Flags & DT_DESCRIBES_OPTIONAL))
1062 AcpiOsPrintf (" [Optional field not present]");
1065 AcpiOsPrintf ("\n");
1069 case ACPI_DMT_BUF10:
1070 case ACPI_DMT_BUF16:
1071 case ACPI_DMT_BUF128:
1073 * Buffer: Size depends on the opcode and was set above.
1074 * Each hex byte is separated with a space.
1075 * Multiple lines are separated by line continuation char.
1077 for (Temp16 = 0; Temp16 < ByteLength; Temp16++)
1079 AcpiOsPrintf ("%2.2X", Target[Temp16]);
1080 if ((UINT32) (Temp16 + 1) < ByteLength)
1082 if ((Temp16 > 0) && (!((Temp16+1) % 16)))
1084 AcpiOsPrintf (" \\\n"); /* Line continuation */
1085 AcpiDmLineHeader (0, 0, NULL);
1093 AcpiOsPrintf ("\n");
1098 /* Convert 16-byte UUID buffer to 36-byte formatted UUID string */
1100 (void) AuConvertUuidToString ((char *) Target, MsgBuffer);
1102 AcpiOsPrintf ("%s\n", MsgBuffer);
1105 case ACPI_DMT_STRING:
1107 AcpiOsPrintf ("\"%s\"\n", ACPI_CAST_PTR (char, Target));
1110 /* Fixed length ASCII name fields */
1114 AcpiDmCheckAscii (Target, RepairedName, 4);
1115 AcpiOsPrintf ("\"%.4s\" ", RepairedName);
1116 TableData = AcpiAhGetTableInfo (ACPI_CAST_PTR (char, Target));
1119 AcpiOsPrintf (STRING_FORMAT, TableData->Description);
1123 AcpiOsPrintf ("\n");
1127 case ACPI_DMT_NAME4:
1129 AcpiDmCheckAscii (Target, RepairedName, 4);
1130 AcpiOsPrintf ("\"%.4s\"\n", RepairedName);
1133 case ACPI_DMT_NAME6:
1135 AcpiDmCheckAscii (Target, RepairedName, 6);
1136 AcpiOsPrintf ("\"%.6s\"\n", RepairedName);
1139 case ACPI_DMT_NAME8:
1141 AcpiDmCheckAscii (Target, RepairedName, 8);
1142 AcpiOsPrintf ("\"%.8s\"\n", RepairedName);
1145 /* Special Data Types */
1147 case ACPI_DMT_CHKSUM:
1149 /* Checksum, display and validate */
1151 AcpiOsPrintf ("%2.2X", *Target);
1152 Temp8 = AcpiDmGenerateChecksum (Table,
1153 ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length,
1154 ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum);
1156 if (Temp8 != ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum)
1159 " /* Incorrect checksum, should be %2.2X */", Temp8);
1161 AcpiOsPrintf ("\n");
1164 case ACPI_DMT_SPACEID:
1166 /* Address Space ID */
1168 AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiUtGetRegionName (*Target));
1171 case ACPI_DMT_ACCWIDTH:
1173 /* Encoded Access Width */
1176 if (Temp8 > ACPI_GAS_WIDTH_RESERVED)
1178 Temp8 = ACPI_GAS_WIDTH_RESERVED;
1181 AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmGasAccessWidth[Temp8]);
1186 /* Generic Address Structure */
1188 AcpiOsPrintf (STRING_FORMAT, "Generic Address Structure");
1189 AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1190 sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas);
1191 AcpiOsPrintf ("\n");
1192 LastOutputBlankLine = TRUE;
1197 /* ASF subtable types */
1199 Temp16 = (UINT16) ((*Target) & 0x7F); /* Top bit can be zero or one */
1200 if (Temp16 > ACPI_ASF_TYPE_RESERVED)
1202 Temp16 = ACPI_ASF_TYPE_RESERVED;
1205 AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmAsfSubnames[Temp16]);
1210 /* DMAR subtable types */
1212 Temp16 = ACPI_GET16 (Target);
1213 if (Temp16 > ACPI_DMAR_TYPE_RESERVED)
1215 Temp16 = ACPI_DMAR_TYPE_RESERVED;
1218 AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1219 AcpiDmDmarSubnames[Temp16]);
1222 case ACPI_DMT_DMAR_SCOPE:
1224 /* DMAR device scope types */
1227 if (Temp8 > ACPI_DMAR_SCOPE_TYPE_RESERVED)
1229 Temp8 = ACPI_DMAR_SCOPE_TYPE_RESERVED;
1232 AcpiOsPrintf (UINT8_FORMAT, *Target,
1233 AcpiDmDmarScope[Temp8]);
1236 case ACPI_DMT_EINJACT:
1238 /* EINJ Action types */
1241 if (Temp8 > ACPI_EINJ_ACTION_RESERVED)
1243 Temp8 = ACPI_EINJ_ACTION_RESERVED;
1246 AcpiOsPrintf (UINT8_FORMAT, *Target,
1247 AcpiDmEinjActions[Temp8]);
1250 case ACPI_DMT_EINJINST:
1252 /* EINJ Instruction types */
1255 if (Temp8 > ACPI_EINJ_INSTRUCTION_RESERVED)
1257 Temp8 = ACPI_EINJ_INSTRUCTION_RESERVED;
1260 AcpiOsPrintf (UINT8_FORMAT, *Target,
1261 AcpiDmEinjInstructions[Temp8]);
1264 case ACPI_DMT_ERSTACT:
1266 /* ERST Action types */
1269 if (Temp8 > ACPI_ERST_ACTION_RESERVED)
1271 Temp8 = ACPI_ERST_ACTION_RESERVED;
1274 AcpiOsPrintf (UINT8_FORMAT, *Target,
1275 AcpiDmErstActions[Temp8]);
1278 case ACPI_DMT_ERSTINST:
1280 /* ERST Instruction types */
1283 if (Temp8 > ACPI_ERST_INSTRUCTION_RESERVED)
1285 Temp8 = ACPI_ERST_INSTRUCTION_RESERVED;
1288 AcpiOsPrintf (UINT8_FORMAT, *Target,
1289 AcpiDmErstInstructions[Temp8]);
1294 /* GTDT subtable types */
1297 if (Temp8 > ACPI_GTDT_TYPE_RESERVED)
1299 Temp8 = ACPI_GTDT_TYPE_RESERVED;
1302 AcpiOsPrintf (UINT8_FORMAT, *Target,
1303 AcpiDmGtdtSubnames[Temp8]);
1308 /* HEST subtable types */
1310 Temp16 = ACPI_GET16 (Target);
1311 if (Temp16 > ACPI_HEST_TYPE_RESERVED)
1313 Temp16 = ACPI_HEST_TYPE_RESERVED;
1316 AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1317 AcpiDmHestSubnames[Temp16]);
1320 case ACPI_DMT_HESTNTFY:
1322 AcpiOsPrintf (STRING_FORMAT,
1323 "Hardware Error Notification Structure");
1325 AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1326 sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify);
1327 AcpiOsPrintf ("\n");
1328 LastOutputBlankLine = TRUE;
1331 case ACPI_DMT_HESTNTYP:
1333 /* HEST Notify types */
1336 if (Temp8 > ACPI_HEST_NOTIFY_RESERVED)
1338 Temp8 = ACPI_HEST_NOTIFY_RESERVED;
1341 AcpiOsPrintf (UINT8_FORMAT, *Target,
1342 AcpiDmHestNotifySubnames[Temp8]);
1345 case ACPI_DMT_IORTMEM:
1347 AcpiOsPrintf (STRING_FORMAT,
1348 "IORT Memory Access Properties");
1350 AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1351 sizeof (ACPI_IORT_MEMORY_ACCESS), AcpiDmTableInfoIortAcc);
1352 LastOutputBlankLine = TRUE;
1357 /* MADT subtable types */
1360 if (Temp8 > ACPI_MADT_TYPE_RESERVED)
1362 Temp8 = ACPI_MADT_TYPE_RESERVED;
1365 AcpiOsPrintf (UINT8_FORMAT, *Target,
1366 AcpiDmMadtSubnames[Temp8]);
1371 /* NFIT subtable types */
1373 Temp16 = ACPI_GET16 (Target);
1374 if (Temp16 > ACPI_NFIT_TYPE_RESERVED)
1376 Temp16 = ACPI_NFIT_TYPE_RESERVED;
1379 AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1380 AcpiDmNfitSubnames[Temp16]);
1385 /* PCCT subtable types */
1388 if (Temp8 > ACPI_PCCT_TYPE_RESERVED)
1390 Temp8 = ACPI_PCCT_TYPE_RESERVED;
1393 AcpiOsPrintf (UINT8_FORMAT, *Target,
1394 AcpiDmPcctSubnames[Temp8]);
1399 /* PMTT subtable types */
1402 if (Temp8 > ACPI_PMTT_TYPE_RESERVED)
1404 Temp8 = ACPI_PMTT_TYPE_RESERVED;
1407 AcpiOsPrintf (UINT8_FORMAT, *Target,
1408 AcpiDmPmttSubnames[Temp8]);
1411 case ACPI_DMT_UNICODE:
1413 if (ByteLength == 0)
1415 AcpiOsPrintf ("/* Zero-length Data */\n");
1419 AcpiDmDumpUnicode (Table, CurrentOffset, ByteLength);
1422 case ACPI_DMT_RAW_BUFFER:
1424 if (ByteLength == 0)
1426 AcpiOsPrintf ("/* Zero-length Data */\n");
1430 AcpiDmDumpBuffer (Table, CurrentOffset, ByteLength,
1431 CurrentOffset, NULL);
1436 /* SRAT subtable types */
1439 if (Temp8 > ACPI_SRAT_TYPE_RESERVED)
1441 Temp8 = ACPI_SRAT_TYPE_RESERVED;
1444 AcpiOsPrintf (UINT8_FORMAT, *Target,
1445 AcpiDmSratSubnames[Temp8]);
1448 case ACPI_DMT_FADTPM:
1450 /* FADT Preferred PM Profile names */
1453 if (Temp8 > ACPI_FADT_PM_RESERVED)
1455 Temp8 = ACPI_FADT_PM_RESERVED;
1458 AcpiOsPrintf (UINT8_FORMAT, *Target,
1459 AcpiDmFadtProfiles[Temp8]);
1464 /* IVRS subtable types */
1469 case ACPI_IVRS_TYPE_HARDWARE:
1471 Name = AcpiDmIvrsSubnames[0];
1474 case ACPI_IVRS_TYPE_MEMORY1:
1475 case ACPI_IVRS_TYPE_MEMORY2:
1476 case ACPI_IVRS_TYPE_MEMORY3:
1478 Name = AcpiDmIvrsSubnames[1];
1483 Name = AcpiDmIvrsSubnames[2];
1487 AcpiOsPrintf (UINT8_FORMAT, *Target, Name);
1492 /* LPIT subtable types */
1494 Temp32 = ACPI_GET32 (Target);
1495 if (Temp32 > ACPI_LPIT_TYPE_RESERVED)
1497 Temp32 = ACPI_LPIT_TYPE_RESERVED;
1500 AcpiOsPrintf (UINT32_FORMAT, ACPI_GET32 (Target),
1501 AcpiDmLpitSubnames[Temp32]);
1510 ACPI_ERROR ((AE_INFO,
1511 "**** Invalid table opcode [0x%X] ****\n", Info->Opcode));
1512 return (AE_SUPPORT);
1516 if (TableOffset && !SubtableLength)
1519 * If this table is not the main table, the subtable must have a
1522 AcpiOsPrintf ("Invalid zero length subtable\n");
1523 return (AE_BAD_DATA);
1530 /*******************************************************************************
1532 * FUNCTION: AcpiDmCheckAscii
1534 * PARAMETERS: Name - Ascii string
1535 * Count - Number of characters to check
1539 * DESCRIPTION: Ensure that the requested number of characters are printable
1540 * Ascii characters. Sets non-printable and null chars to <space>.
1542 ******************************************************************************/
1553 for (i = 0; i < Count; i++)
1555 RepairedName[i] = (char) Name[i];
1561 if (!isprint (Name[i]))
1563 RepairedName[i] = ' ';