1 /******************************************************************************
3 * Module Name: dmtable - Support for ACPI tables that contain no AML code
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp.
13 * All rights reserved.
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
73 * 3.4. Intel retains all right, title, and interest in and to the Original
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************/
117 #include <contrib/dev/acpica/acpi.h>
118 #include <contrib/dev/acpica/acdisasm.h>
119 #include <contrib/dev/acpica/actables.h>
121 /* This module used for application-level code only */
123 #define _COMPONENT ACPI_CA_DISASSEMBLER
124 ACPI_MODULE_NAME ("dmtable")
126 /* Local Prototypes */
128 static ACPI_DMTABLE_DATA *
138 /* These tables map a subtable type to a description string */
140 static const char *AcpiDmDmarSubnames[] =
142 "Hardware Unit Definition",
143 "Reserved Memory Region",
144 "Unknown SubTable Type" /* Reserved */
147 static const char *AcpiDmMadtSubnames[] =
149 "Processor Local APIC", /* ACPI_MADT_TYPE_LOCAL_APIC */
150 "I/O APIC", /* ACPI_MADT_TYPE_IO_APIC */
151 "Interrupt Source Override", /* ACPI_MADT_TYPE_INTERRUPT_OVERRIDE */
152 "NMI Source", /* ACPI_MADT_TYPE_NMI_SOURCE */
153 "Local APIC NMI", /* ACPI_MADT_TYPE_LOCAL_APIC_NMI */
154 "Local APIC Address Override", /* ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE */
155 "I/O SAPIC", /* ACPI_MADT_TYPE_IO_SAPIC */
156 "Local SAPIC", /* ACPI_MADT_TYPE_LOCAL_SAPIC */
157 "Platform Interrupt Sources", /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */
158 "Unknown SubTable Type" /* Reserved */
161 static const char *AcpiDmSratSubnames[] =
163 "Processor Local APIC/SAPIC Affinity",
165 "Unknown SubTable Type" /* Reserved */
169 /*******************************************************************************
171 * ACPI Table Data, indexed by signature.
173 * Simple tables have only a TableInfo structure, complex tables have a handler.
174 * This table must be NULL terminated. RSDP and FACS are special-cased
177 ******************************************************************************/
179 static ACPI_DMTABLE_DATA AcpiDmTableData[] =
181 {ACPI_SIG_ASF, NULL, AcpiDmDumpAsf, "Alert Standard Format table"},
182 {ACPI_SIG_BOOT, AcpiDmTableInfoBoot, NULL, "Simple Boot Flag Table"},
183 {ACPI_SIG_CPEP, NULL, AcpiDmDumpCpep, "Corrected Platform Error Polling table"},
184 {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp, NULL, "Debug Port table"},
185 {ACPI_SIG_DMAR, NULL, AcpiDmDumpDmar, "DMA Remapping table"},
186 {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt, NULL, "Embedded Controller Boot Resources Table"},
187 {ACPI_SIG_FADT, NULL, AcpiDmDumpFadt, "Fixed ACPI Description Table"},
188 {ACPI_SIG_HPET, AcpiDmTableInfoHpet, NULL, "High Precision Event Timer table"},
189 {ACPI_SIG_MADT, NULL, AcpiDmDumpMadt, "Multiple APIC Description Table"},
190 {ACPI_SIG_MCFG, NULL, AcpiDmDumpMcfg, "Memory Mapped Configuration table"},
191 {ACPI_SIG_RSDT, NULL, AcpiDmDumpRsdt, "Root System Description Table"},
192 {ACPI_SIG_SBST, AcpiDmTableInfoSbst, NULL, "Smart Battery Specification Table"},
193 {ACPI_SIG_SLIT, NULL, AcpiDmDumpSlit, "System Locality Information Table"},
194 {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr, NULL, "Serial Port Console Redirection table"},
195 {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi, NULL, "Server Platform Management Interface table"},
196 {ACPI_SIG_SRAT, NULL, AcpiDmDumpSrat, "System Resource Affinity Table"},
197 {ACPI_SIG_TCPA, AcpiDmTableInfoTcpa, NULL, "Trusted Computing Platform Alliance table"},
198 {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt, NULL, "Watchdog Resource Table"},
199 {ACPI_SIG_XSDT, NULL, AcpiDmDumpXsdt, "Extended System Description Table"},
200 {NULL, NULL, NULL, NULL}
204 /*******************************************************************************
206 * FUNCTION: AcpiTbGenerateChecksum
208 * PARAMETERS: Table - Pointer to a valid ACPI table (with a
209 * standard ACPI header)
211 * RETURN: 8 bit checksum of buffer
213 * DESCRIPTION: Computes an 8 bit checksum of the table.
215 ******************************************************************************/
218 AcpiTbGenerateChecksum (
219 ACPI_TABLE_HEADER *Table)
224 /* Sum the entire table as-is */
226 Checksum = AcpiTbChecksum ((UINT8 *) Table, Table->Length);
228 /* Subtract off the existing checksum value in the table */
230 Checksum = (UINT8) (Checksum - Table->Checksum);
232 /* Compute the final checksum */
234 Checksum = (UINT8) (0 - Checksum);
239 /*******************************************************************************
241 * FUNCTION: AcpiDmGetTableData
243 * PARAMETERS: Signature - ACPI signature (4 chars) to match
245 * RETURN: Pointer to a valid ACPI_DMTABLE_DATA. Null if no match found.
247 * DESCRIPTION: Find a match in the global table of supported ACPI tables
249 ******************************************************************************/
251 static ACPI_DMTABLE_DATA *
255 ACPI_DMTABLE_DATA *TableData;
258 for (TableData = AcpiDmTableData; TableData->Signature; TableData++)
260 if (ACPI_COMPARE_NAME (Signature, TableData->Signature))
270 /*******************************************************************************
272 * FUNCTION: AcpiDmDumpDataTable
274 * PARAMETERS: Table - An ACPI table
278 * DESCRIPTION: Format the contents of an ACPI data table (any table other
279 * than an SSDT or DSDT that does not contain executable AML code)
281 ******************************************************************************/
284 AcpiDmDumpDataTable (
285 ACPI_TABLE_HEADER *Table)
287 ACPI_DMTABLE_DATA *TableData;
291 /* Ignore tables that contain AML */
293 if (AcpiUtIsAmlTable (Table))
299 * Handle tables that don't use the common ACPI table header structure.
300 * Currently, these are the FACS and RSDP.
302 if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS))
304 Length = Table->Length;
305 AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFacs);
307 else if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_RSDP))
309 Length = AcpiDmDumpRsdp (Table);
314 * All other tables must use the common ACPI table header, dump it now
316 Length = Table->Length;
317 AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHeader);
320 /* Match signature and dispatch appropriately */
322 TableData = AcpiDmGetTableData (Table->Signature);
325 if (!ACPI_STRNCMP (Table->Signature, "OEM", 3))
327 AcpiOsPrintf ("\n**** OEM-defined ACPI table [%4.4s], unknown contents\n\n",
332 AcpiOsPrintf ("\n**** Unknown ACPI table type [%4.4s]\n\n",
336 else if (TableData->TableHandler)
338 /* Complex table, has a handler */
340 TableData->TableHandler (Table);
342 else if (TableData->TableInfo)
344 /* Simple table, just walk the info table */
346 AcpiDmDumpTable (Length, 0, Table, 0, TableData->TableInfo);
350 /* Always dump the raw table data */
352 AcpiOsPrintf ("\nRaw Table Data\n\n");
353 AcpiUtDumpBuffer2 (ACPI_CAST_PTR (UINT8, Table), Length, DB_BYTE_DISPLAY);
357 /*******************************************************************************
359 * FUNCTION: AcpiDmLineHeader
361 * PARAMETERS: Offset - Current byte offset, from table start
362 * ByteLength - Length of the field in bytes, 0 for flags
363 * Name - Name of this field
364 * Value - Optional value, displayed on left of ':'
368 * DESCRIPTION: Utility routines for formatting output lines. Displays the
369 * current table offset in hex and decimal, the field length,
370 * and the field name.
372 ******************************************************************************/
383 AcpiOsPrintf ("[%3.3Xh %3.3d% 3d] %28s : ",
384 Offset, Offset, ByteLength, Name);
388 AcpiOsPrintf ("%42s : ",
403 AcpiOsPrintf ("[%3.3Xh %3.3d% 3d] %24s % 3d : ",
404 Offset, Offset, ByteLength, Name, Value);
408 AcpiOsPrintf ("[%3.3Xh %3.3d ] %24s % 3d : ",
409 Offset, Offset, Name, Value);
414 /*******************************************************************************
416 * FUNCTION: AcpiDmDumpTable
418 * PARAMETERS: TableLength - Length of the entire ACPI table
419 * TableOffset - Starting offset within the table for this
420 * sub-descriptor (0 if main table)
421 * Table - The ACPI table
422 * SubtableLength - Lenghth of this sub-descriptor
423 * Info - Info table for this ACPI table
427 * DESCRIPTION: Display ACPI table contents by walking the Info table.
429 ******************************************************************************/
436 UINT32 SubtableLength,
437 ACPI_DMTABLE_INFO *Info)
440 UINT32 CurrentOffset;
444 ACPI_DMTABLE_DATA *TableData;
449 AcpiOsPrintf ("Display not implemented\n");
453 /* Walk entire Info table; Null name terminates */
455 for (; Info->Name; Info++)
458 * Target points to the field within the ACPI Table. CurrentOffset is
459 * the offset of the field from the start of the main table.
461 Target = ACPI_ADD_PTR (UINT8, Table, Info->Offset);
462 CurrentOffset = TableOffset + Info->Offset;
464 /* Check for beyond EOT or beyond subtable end */
466 if ((CurrentOffset >= TableLength) ||
467 (SubtableLength && (Info->Offset >= SubtableLength)))
472 /* Generate the byte length for this field */
474 switch (Info->Opcode)
477 case ACPI_DMT_CHKSUM:
478 case ACPI_DMT_SPACEID:
483 case ACPI_DMT_UINT16:
487 case ACPI_DMT_UINT24:
490 case ACPI_DMT_UINT32:
498 case ACPI_DMT_UINT56:
501 case ACPI_DMT_UINT64:
505 case ACPI_DMT_STRING:
506 ByteLength = ACPI_STRLEN (ACPI_CAST_PTR (char, Target)) + 1;
510 ByteLength = sizeof (ACPI_GENERIC_ADDRESS);
517 /* Start a new line and decode the opcode */
519 AcpiDmLineHeader (CurrentOffset, ByteLength, Info->Name);
521 switch (Info->Opcode)
523 /* Single-bit Flag fields. Note: Opcode is the bit position */
534 AcpiOsPrintf ("%1.1X\n", (*Target >> Info->Opcode) & 0x01);
537 /* 2-bit Flag fields */
539 case ACPI_DMT_FLAGS0:
541 AcpiOsPrintf ("%1.1X\n", *Target & 0x03);
544 case ACPI_DMT_FLAGS2:
546 AcpiOsPrintf ("%1.1X\n", (*Target >> 2) & 0x03);
549 /* Standard Data Types */
553 AcpiOsPrintf ("%2.2X\n", *Target);
556 case ACPI_DMT_UINT16:
558 AcpiOsPrintf ("%4.4X\n", ACPI_GET16 (Target));
561 case ACPI_DMT_UINT24:
563 AcpiOsPrintf ("%2.2X%2.2X%2.2X\n",
564 *Target, *(Target + 1), *(Target + 2));
567 case ACPI_DMT_UINT32:
569 AcpiOsPrintf ("%8.8X\n", ACPI_GET32 (Target));
572 case ACPI_DMT_UINT56:
574 AcpiOsPrintf ("%6.6X%8.8X\n",
575 ACPI_HIDWORD (ACPI_GET64 (Target)) & 0x00FFFFFF,
576 ACPI_LODWORD (ACPI_GET64 (Target)));
579 case ACPI_DMT_UINT64:
581 AcpiOsPrintf ("%8.8X%8.8X\n",
582 ACPI_FORMAT_UINT64 (ACPI_GET64 (Target)));
585 case ACPI_DMT_STRING:
587 AcpiOsPrintf ("%s\n", ACPI_CAST_PTR (char, Target));
590 /* Fixed length ASCII name fields */
594 AcpiDmCheckAscii (Target, 4);
595 AcpiOsPrintf ("\"%4.4s\" ", Target);
596 TableData = AcpiDmGetTableData (ACPI_CAST_PTR (char, Target));
599 AcpiOsPrintf ("/* %s */", TableData->Name);
606 AcpiDmCheckAscii (Target, 4);
607 AcpiOsPrintf ("\"%4.4s\"\n", Target);
612 AcpiDmCheckAscii (Target, 6);
613 AcpiOsPrintf ("\"%6.6s\"\n", Target);
618 AcpiDmCheckAscii (Target, 8);
619 AcpiOsPrintf ("\"%8.8s\"\n", Target);
622 /* Special Data Types */
624 case ACPI_DMT_CHKSUM:
626 /* Checksum, display and validate */
628 AcpiOsPrintf ("%2.2X", *Target);
629 Temp8 = AcpiTbGenerateChecksum (Table);
630 if (Temp8 != ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum)
633 " /* Incorrect checksum, should be %2.2X */", Temp8);
638 case ACPI_DMT_SPACEID:
640 /* Address Space ID */
642 AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiUtGetRegionName (*Target));
647 /* Generic Address Structure */
649 AcpiOsPrintf ("<Generic Address Structure>\n");
650 AcpiDmDumpTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length,
651 CurrentOffset, Target, 0, AcpiDmTableInfoGas);
656 /* DMAR subtable types */
659 if (Temp16 > ACPI_DMAR_TYPE_RESERVED)
661 Temp16 = ACPI_DMAR_TYPE_RESERVED;
664 AcpiOsPrintf ("%4.4X <%s>\n", *Target, AcpiDmDmarSubnames[Temp16]);
669 /* MADT subtable types */
672 if (Temp8 > ACPI_MADT_TYPE_RESERVED)
674 Temp8 = ACPI_MADT_TYPE_RESERVED;
677 AcpiOsPrintf ("%2.2X <%s>\n", *Target, AcpiDmMadtSubnames[Temp8]);
682 /* SRAT subtable types */
685 if (Temp8 > ACPI_SRAT_TYPE_RESERVED)
687 Temp8 = ACPI_SRAT_TYPE_RESERVED;
690 AcpiOsPrintf ("%2.2X <%s>\n", *Target, AcpiDmSratSubnames[Temp8]);
697 ACPI_ERROR ((AE_INFO,
698 "**** Invalid table opcode [%X] ****\n", Info->Opcode));
705 /*******************************************************************************
707 * FUNCTION: AcpiDmCheckAscii
709 * PARAMETERS: Name - Ascii string
710 * Count - Number of characters to check
714 * DESCRIPTION: Ensure that the requested number of characters are printable
715 * Ascii characters. Sets non-printable and null chars to <space>.
717 ******************************************************************************/
727 for (i = 0; i < Count; i++)
729 if (!Name[i] || !isprint (Name[i]))