Sync usage with man page.
[netbsd-mini2440.git] / sys / external / intel-public / acpica / dist / common / dmtable.c
blob9b0e1e50a3d163b33b870232a66250fa61328834
1 /******************************************************************************
3 * Module Name: dmtable - Support for ACPI tables that contain no AML code
5 *****************************************************************************/
7 /******************************************************************************
9 * 1. Copyright Notice
11 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
12 * All rights reserved.
14 * 2. License
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.
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
38 * conditions are met:
40 * 3. Conditions
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
64 * make.
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.
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
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
88 * PARTICULAR PURPOSE.
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.
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 *****************************************************************************/
116 #include "acpi.h"
117 #include "accommon.h"
118 #include "acdisasm.h"
119 #include "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 *
129 AcpiDmGetTableData (
130 char *Signature);
132 static void
133 AcpiDmCheckAscii (
134 UINT8 *Target,
135 char *RepairedName,
136 UINT32 Count);
138 UINT8
139 AcpiTbGenerateChecksum (
140 ACPI_TABLE_HEADER *Table);
143 /* These tables map a subtable type to a description string */
145 static const char *AcpiDmAsfSubnames[] =
147 "ASF Information",
148 "ASF Alerts",
149 "ASF Remote Control",
150 "ASF RMCP Boot Options",
151 "ASF Address",
152 "Unknown SubTable Type" /* Reserved */
155 static const char *AcpiDmDmarSubnames[] =
157 "Hardware Unit Definition",
158 "Reserved Memory Region",
159 "Root Port ATS Capability",
160 "Remapping Hardware Static Affinity",
161 "Unknown SubTable Type" /* Reserved */
164 static const char *AcpiDmHestSubnames[] =
166 "IA-32 Machine Check Exception",
167 "IA-32 Corrected Machine Check",
168 "IA-32 Non-Maskable Interrupt",
169 "Unknown SubTable Type", /* 3 - Reserved */
170 "Unknown SubTable Type", /* 4 - Reserved */
171 "Unknown SubTable Type", /* 5 - Reserved */
172 "PCI Express Root Port AER",
173 "PCI Express AER (AER Endpoint)",
174 "PCI Express/PCI-X Bridge AER",
175 "Generic Hardware Error Source",
176 "Unknown SubTable Type" /* Reserved */
179 static const char *AcpiDmHestNotifySubnames[] =
181 "Polled",
182 "External Interrupt",
183 "Local Interrupt",
184 "SCI",
185 "NMI",
186 "Unknown Notify Type" /* Reserved */
189 static const char *AcpiDmMadtSubnames[] =
191 "Processor Local APIC", /* ACPI_MADT_TYPE_LOCAL_APIC */
192 "I/O APIC", /* ACPI_MADT_TYPE_IO_APIC */
193 "Interrupt Source Override", /* ACPI_MADT_TYPE_INTERRUPT_OVERRIDE */
194 "NMI Source", /* ACPI_MADT_TYPE_NMI_SOURCE */
195 "Local APIC NMI", /* ACPI_MADT_TYPE_LOCAL_APIC_NMI */
196 "Local APIC Address Override", /* ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE */
197 "I/O SAPIC", /* ACPI_MADT_TYPE_IO_SAPIC */
198 "Local SAPIC", /* ACPI_MADT_TYPE_LOCAL_SAPIC */
199 "Platform Interrupt Sources", /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */
200 "Processor Local x2APIC", /* ACPI_MADT_TYPE_LOCAL_X2APIC */
201 "Local x2APIC NMI", /* ACPI_MADT_TYPE_LOCAL_X2APIC_NMI */
202 "Unknown SubTable Type" /* Reserved */
205 static const char *AcpiDmSratSubnames[] =
207 "Processor Local APIC/SAPIC Affinity",
208 "Memory Affinity",
209 "Processor Local x2APIC Affinity",
210 "Unknown SubTable Type" /* Reserved */
213 static const char *AcpiDmIvrsSubnames[] =
215 "Hardware Definition Block",
216 "Memory Definition Block",
217 "Unknown SubTable Type" /* Reserved */
222 #define ACPI_FADT_PM_RESERVED 8
224 static const char *AcpiDmFadtProfiles[] =
226 "Unspecified",
227 "Desktop",
228 "Mobile",
229 "Workstation",
230 "Enterprise Server",
231 "SOHO Server",
232 "Appliance PC",
233 "Performance Server",
234 "Unknown Profile Type"
237 /*******************************************************************************
239 * ACPI Table Data, indexed by signature.
241 * Each entry contains: Signature, Table Info, Handler, Description
243 * Simple tables have only a TableInfo structure, complex tables have a handler.
244 * This table must be NULL terminated. RSDP and FACS are special-cased
245 * elsewhere.
247 ******************************************************************************/
249 static ACPI_DMTABLE_DATA AcpiDmTableData[] =
251 {ACPI_SIG_ASF, NULL, AcpiDmDumpAsf, "Alert Standard Format table"},
252 {ACPI_SIG_BOOT, AcpiDmTableInfoBoot, NULL, "Simple Boot Flag Table"},
253 {ACPI_SIG_BERT, AcpiDmTableInfoBert, NULL, "Boot Error Record Table"},
254 {ACPI_SIG_CPEP, NULL, AcpiDmDumpCpep, "Corrected Platform Error Polling table"},
255 {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp, NULL, "Debug Port table"},
256 {ACPI_SIG_DMAR, NULL, AcpiDmDumpDmar, "DMA Remapping table"},
257 {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt, NULL, "Embedded Controller Boot Resources Table"},
258 {ACPI_SIG_EINJ, NULL, AcpiDmDumpEinj, "Error Injection table"},
259 {ACPI_SIG_ERST, NULL, AcpiDmDumpErst, "Error Record Serialization Table"},
260 {ACPI_SIG_FADT, NULL, AcpiDmDumpFadt, "Fixed ACPI Description Table"},
261 {ACPI_SIG_HEST, NULL, AcpiDmDumpHest, "Hardware Error Source Table"},
262 {ACPI_SIG_HPET, AcpiDmTableInfoHpet, NULL, "High Precision Event Timer table"},
263 {ACPI_SIG_IVRS, NULL, AcpiDmDumpIvrs, "I/O Virtualization Reporting Structure"},
264 {ACPI_SIG_MADT, NULL, AcpiDmDumpMadt, "Multiple APIC Description Table"},
265 {ACPI_SIG_MCFG, NULL, AcpiDmDumpMcfg, "Memory Mapped Configuration table"},
266 {ACPI_SIG_MSCT, NULL, AcpiDmDumpMsct, "Maximum System Characteristics Table"},
267 {ACPI_SIG_RSDT, NULL, AcpiDmDumpRsdt, "Root System Description Table"},
268 {ACPI_SIG_SBST, AcpiDmTableInfoSbst, NULL, "Smart Battery Specification Table"},
269 {ACPI_SIG_SLIC, AcpiDmTableInfoSlic, NULL, "Software Licensing Description Table"},
270 {ACPI_SIG_SLIT, NULL, AcpiDmDumpSlit, "System Locality Information Table"},
271 {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr, NULL, "Serial Port Console Redirection table"},
272 {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi, NULL, "Server Platform Management Interface table"},
273 {ACPI_SIG_SRAT, NULL, AcpiDmDumpSrat, "System Resource Affinity Table"},
274 {ACPI_SIG_TCPA, AcpiDmTableInfoTcpa, NULL, "Trusted Computing Platform Alliance table"},
275 {ACPI_SIG_UEFI, AcpiDmTableInfoUefi, NULL, "UEFI Boot Optimization Table"},
276 {ACPI_SIG_WAET, AcpiDmTableInfoWaet, NULL, "Windows ACPI Emulated Devices Table"},
277 {ACPI_SIG_WDAT, NULL, AcpiDmDumpWdat, "Watchdog Action Table"},
278 {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt, NULL, "Watchdog Resource Table"},
279 {ACPI_SIG_XSDT, NULL, AcpiDmDumpXsdt, "Extended System Description Table"},
280 {NULL, NULL, NULL, NULL}
284 /*******************************************************************************
286 * FUNCTION: AcpiTbGenerateChecksum
288 * PARAMETERS: Table - Pointer to a valid ACPI table (with a
289 * standard ACPI header)
291 * RETURN: 8 bit checksum of buffer
293 * DESCRIPTION: Computes an 8 bit checksum of the table.
295 ******************************************************************************/
297 UINT8
298 AcpiTbGenerateChecksum (
299 ACPI_TABLE_HEADER *Table)
301 UINT8 Checksum;
304 /* Sum the entire table as-is */
306 Checksum = AcpiTbChecksum ((UINT8 *) Table, Table->Length);
308 /* Subtract off the existing checksum value in the table */
310 Checksum = (UINT8) (Checksum - Table->Checksum);
312 /* Compute the final checksum */
314 Checksum = (UINT8) (0 - Checksum);
315 return (Checksum);
319 /*******************************************************************************
321 * FUNCTION: AcpiDmGetTableData
323 * PARAMETERS: Signature - ACPI signature (4 chars) to match
325 * RETURN: Pointer to a valid ACPI_DMTABLE_DATA. Null if no match found.
327 * DESCRIPTION: Find a match in the global table of supported ACPI tables
329 ******************************************************************************/
331 static ACPI_DMTABLE_DATA *
332 AcpiDmGetTableData (
333 char *Signature)
335 ACPI_DMTABLE_DATA *TableData;
338 for (TableData = AcpiDmTableData; TableData->Signature; TableData++)
340 if (ACPI_COMPARE_NAME (Signature, TableData->Signature))
342 return (TableData);
346 return (NULL);
350 /*******************************************************************************
352 * FUNCTION: AcpiDmDumpDataTable
354 * PARAMETERS: Table - An ACPI table
356 * RETURN: None.
358 * DESCRIPTION: Format the contents of an ACPI data table (any table other
359 * than an SSDT or DSDT that does not contain executable AML code)
361 ******************************************************************************/
363 void
364 AcpiDmDumpDataTable (
365 ACPI_TABLE_HEADER *Table)
367 ACPI_STATUS Status;
368 ACPI_DMTABLE_DATA *TableData;
369 UINT32 Length;
372 /* Ignore tables that contain AML */
374 if (AcpiUtIsAmlTable (Table))
376 return;
380 * Handle tables that don't use the common ACPI table header structure.
381 * Currently, these are the FACS and RSDP.
383 if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS))
385 Length = Table->Length;
386 AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFacs);
388 else if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_RSDP))
390 Length = AcpiDmDumpRsdp (Table);
392 else
395 * All other tables must use the common ACPI table header, dump it now
397 Length = Table->Length;
398 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHeader);
399 if (ACPI_FAILURE (Status))
401 return;
403 AcpiOsPrintf ("\n");
405 /* Match signature and dispatch appropriately */
407 TableData = AcpiDmGetTableData (Table->Signature);
408 if (!TableData)
410 if (!ACPI_STRNCMP (Table->Signature, "OEM", 3))
412 AcpiOsPrintf ("\n**** OEM-defined ACPI table [%4.4s], unknown contents\n\n",
413 Table->Signature);
415 else
417 AcpiOsPrintf ("\n**** Unknown ACPI table type [%4.4s]\n\n",
418 Table->Signature);
421 else if (TableData->TableHandler)
423 /* Complex table, has a handler */
425 TableData->TableHandler (Table);
427 else if (TableData->TableInfo)
429 /* Simple table, just walk the info table */
431 AcpiDmDumpTable (Length, 0, Table, 0, TableData->TableInfo);
435 /* Always dump the raw table data */
437 AcpiOsPrintf ("\nRaw Table Data\n\n");
438 AcpiUtDumpBuffer2 (ACPI_CAST_PTR (UINT8, Table), Length, DB_BYTE_DISPLAY);
442 /*******************************************************************************
444 * FUNCTION: AcpiDmLineHeader
446 * PARAMETERS: Offset - Current byte offset, from table start
447 * ByteLength - Length of the field in bytes, 0 for flags
448 * Name - Name of this field
449 * Value - Optional value, displayed on left of ':'
451 * RETURN: None
453 * DESCRIPTION: Utility routines for formatting output lines. Displays the
454 * current table offset in hex and decimal, the field length,
455 * and the field name.
457 ******************************************************************************/
459 void
460 AcpiDmLineHeader (
461 UINT32 Offset,
462 UINT32 ByteLength,
463 char *Name)
466 if (ByteLength)
468 AcpiOsPrintf ("[%3.3Xh %4.4d% 3d] %28s : ",
469 Offset, Offset, ByteLength, Name);
471 else
473 AcpiOsPrintf ("%43s : ",
474 Name);
478 void
479 AcpiDmLineHeader2 (
480 UINT32 Offset,
481 UINT32 ByteLength,
482 char *Name,
483 UINT32 Value)
486 if (ByteLength)
488 AcpiOsPrintf ("[%3.3Xh %4.4d% 3d] %24s % 3d : ",
489 Offset, Offset, ByteLength, Name, Value);
491 else
493 AcpiOsPrintf ("[%3.3Xh %4.4d ] %24s % 3d : ",
494 Offset, Offset, Name, Value);
499 /*******************************************************************************
501 * FUNCTION: AcpiDmDumpTable
503 * PARAMETERS: TableLength - Length of the entire ACPI table
504 * TableOffset - Starting offset within the table for this
505 * sub-descriptor (0 if main table)
506 * Table - The ACPI table
507 * SubtableLength - Length of this sub-descriptor
508 * Info - Info table for this ACPI table
510 * RETURN: None
512 * DESCRIPTION: Display ACPI table contents by walking the Info table.
514 ******************************************************************************/
516 ACPI_STATUS
517 AcpiDmDumpTable (
518 UINT32 TableLength,
519 UINT32 TableOffset,
520 void *Table,
521 UINT32 SubtableLength,
522 ACPI_DMTABLE_INFO *Info)
524 UINT8 *Target;
525 UINT32 CurrentOffset;
526 UINT32 ByteLength;
527 UINT8 Temp8;
528 UINT16 Temp16;
529 ACPI_DMTABLE_DATA *TableData;
530 const char *Name;
531 BOOLEAN LastOutputBlankLine = FALSE;
532 char RepairedName[8];
535 if (!Info)
537 AcpiOsPrintf ("Display not implemented\n");
538 return (AE_NOT_IMPLEMENTED);
541 /* Walk entire Info table; Null name terminates */
543 for (; Info->Name; Info++)
546 * Target points to the field within the ACPI Table. CurrentOffset is
547 * the offset of the field from the start of the main table.
549 Target = ACPI_ADD_PTR (UINT8, Table, Info->Offset);
550 CurrentOffset = TableOffset + Info->Offset;
552 /* Check for beyond EOT or beyond subtable end */
554 if ((CurrentOffset >= TableLength) ||
555 (SubtableLength && (Info->Offset >= SubtableLength)))
557 AcpiOsPrintf ("**** ACPI table terminates in the middle of a data structure!\n");
558 return (AE_BAD_DATA);
561 /* Generate the byte length for this field */
563 switch (Info->Opcode)
565 case ACPI_DMT_UINT8:
566 case ACPI_DMT_CHKSUM:
567 case ACPI_DMT_SPACEID:
568 case ACPI_DMT_IVRS:
569 case ACPI_DMT_MADT:
570 case ACPI_DMT_SRAT:
571 case ACPI_DMT_ASF:
572 case ACPI_DMT_HESTNTYP:
573 case ACPI_DMT_FADTPM:
574 ByteLength = 1;
575 break;
576 case ACPI_DMT_UINT16:
577 case ACPI_DMT_DMAR:
578 case ACPI_DMT_HEST:
579 ByteLength = 2;
580 break;
581 case ACPI_DMT_UINT24:
582 ByteLength = 3;
583 break;
584 case ACPI_DMT_UINT32:
585 case ACPI_DMT_NAME4:
586 case ACPI_DMT_SIG:
587 ByteLength = 4;
588 break;
589 case ACPI_DMT_NAME6:
590 ByteLength = 6;
591 break;
592 case ACPI_DMT_UINT56:
593 ByteLength = 7;
594 break;
595 case ACPI_DMT_UINT64:
596 case ACPI_DMT_NAME8:
597 ByteLength = 8;
598 break;
599 case ACPI_DMT_BUF16:
600 ByteLength = 16;
601 break;
602 case ACPI_DMT_STRING:
603 ByteLength = ACPI_STRLEN (ACPI_CAST_PTR (char, Target)) + 1;
604 break;
605 case ACPI_DMT_GAS:
606 if (!LastOutputBlankLine)
608 AcpiOsPrintf ("\n");
609 LastOutputBlankLine = TRUE;
611 ByteLength = sizeof (ACPI_GENERIC_ADDRESS);
612 break;
613 case ACPI_DMT_HESTNTFY:
614 if (!LastOutputBlankLine)
616 AcpiOsPrintf ("\n");
617 LastOutputBlankLine = TRUE;
619 ByteLength = sizeof (ACPI_HEST_NOTIFY);
620 break;
621 default:
622 ByteLength = 0;
623 break;
626 if (CurrentOffset + ByteLength > TableLength)
628 AcpiOsPrintf ("**** ACPI table terminates in the middle of a data structure!\n");
629 return (AE_BAD_DATA);
632 /* Start a new line and decode the opcode */
634 AcpiDmLineHeader (CurrentOffset, ByteLength, Info->Name);
636 switch (Info->Opcode)
638 /* Single-bit Flag fields. Note: Opcode is the bit position */
640 case ACPI_DMT_FLAG0:
641 case ACPI_DMT_FLAG1:
642 case ACPI_DMT_FLAG2:
643 case ACPI_DMT_FLAG3:
644 case ACPI_DMT_FLAG4:
645 case ACPI_DMT_FLAG5:
646 case ACPI_DMT_FLAG6:
647 case ACPI_DMT_FLAG7:
649 AcpiOsPrintf ("%1.1X\n", (*Target >> Info->Opcode) & 0x01);
650 break;
652 /* 2-bit Flag fields */
654 case ACPI_DMT_FLAGS0:
656 AcpiOsPrintf ("%1.1X\n", *Target & 0x03);
657 break;
659 case ACPI_DMT_FLAGS2:
661 AcpiOsPrintf ("%1.1X\n", (*Target >> 2) & 0x03);
662 break;
664 /* Standard Data Types */
666 case ACPI_DMT_UINT8:
668 AcpiOsPrintf ("%2.2X\n", *Target);
669 break;
671 case ACPI_DMT_UINT16:
673 AcpiOsPrintf ("%4.4X\n", ACPI_GET16 (Target));
674 break;
676 case ACPI_DMT_UINT24:
678 AcpiOsPrintf ("%2.2X%2.2X%2.2X\n",
679 *Target, *(Target + 1), *(Target + 2));
680 break;
682 case ACPI_DMT_UINT32:
684 AcpiOsPrintf ("%8.8X\n", ACPI_GET32 (Target));
685 break;
687 case ACPI_DMT_UINT56:
689 for (Temp8 = 0; Temp8 < 7; Temp8++)
691 AcpiOsPrintf ("%2.2X", Target[Temp8]);
693 AcpiOsPrintf ("\n");
694 break;
696 case ACPI_DMT_UINT64:
698 AcpiOsPrintf ("%8.8X%8.8X\n",
699 ACPI_FORMAT_UINT64 (ACPI_GET64 (Target)));
700 break;
702 case ACPI_DMT_BUF16:
704 /* Buffer of length 16 */
706 for (Temp8 = 0; Temp8 < 16; Temp8++)
708 AcpiOsPrintf ("%2.2X,", Target[Temp8]);
710 AcpiOsPrintf ("\n");
711 break;
713 case ACPI_DMT_STRING:
715 AcpiOsPrintf ("\"%s\"\n", ACPI_CAST_PTR (char, Target));
716 break;
718 /* Fixed length ASCII name fields */
720 case ACPI_DMT_SIG:
722 AcpiDmCheckAscii (Target, RepairedName, 4);
723 AcpiOsPrintf ("\"%.4s\" ", RepairedName);
724 TableData = AcpiDmGetTableData (ACPI_CAST_PTR (char, Target));
725 if (TableData)
727 AcpiOsPrintf ("/* %s */", TableData->Name);
729 AcpiOsPrintf ("\n");
730 break;
732 case ACPI_DMT_NAME4:
734 AcpiDmCheckAscii (Target, RepairedName, 4);
735 AcpiOsPrintf ("\"%.4s\"\n", RepairedName);
736 break;
738 case ACPI_DMT_NAME6:
740 AcpiDmCheckAscii (Target, RepairedName, 6);
741 AcpiOsPrintf ("\"%.6s\"\n", RepairedName);
742 break;
744 case ACPI_DMT_NAME8:
746 AcpiDmCheckAscii (Target, RepairedName, 8);
747 AcpiOsPrintf ("\"%.8s\"\n", RepairedName);
748 break;
750 /* Special Data Types */
752 case ACPI_DMT_CHKSUM:
754 /* Checksum, display and validate */
756 AcpiOsPrintf ("%2.2X", *Target);
757 Temp8 = AcpiTbGenerateChecksum (Table);
758 if (Temp8 != ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum)
760 AcpiOsPrintf (
761 " /* Incorrect checksum, should be %2.2X */", Temp8);
763 AcpiOsPrintf ("\n");
764 break;
766 case ACPI_DMT_SPACEID:
768 /* Address Space ID */
770 AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiUtGetRegionName (*Target));
771 break;
773 case ACPI_DMT_GAS:
775 /* Generic Address Structure */
777 AcpiOsPrintf ("<Generic Address Structure>\n");
778 AcpiDmDumpTable (TableLength, CurrentOffset, Target,
779 sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas);
780 AcpiOsPrintf ("\n");
781 LastOutputBlankLine = TRUE;
782 break;
784 case ACPI_DMT_ASF:
786 /* ASF subtable types */
788 Temp16 = (UINT16) ((*Target) & 0x7F); /* Top bit can be zero or one */
789 if (Temp16 > ACPI_ASF_TYPE_RESERVED)
791 Temp16 = ACPI_ASF_TYPE_RESERVED;
794 AcpiOsPrintf ("%2.2X <%s>\n", *Target, AcpiDmAsfSubnames[Temp16]);
795 break;
797 case ACPI_DMT_DMAR:
799 /* DMAR subtable types */
801 Temp16 = ACPI_GET16 (Target);
802 if (Temp16 > ACPI_DMAR_TYPE_RESERVED)
804 Temp16 = ACPI_DMAR_TYPE_RESERVED;
807 AcpiOsPrintf ("%4.4X <%s>\n", ACPI_GET16 (Target), AcpiDmDmarSubnames[Temp16]);
808 break;
810 case ACPI_DMT_HEST:
812 /* HEST subtable types */
814 Temp16 = ACPI_GET16 (Target);
815 if (Temp16 > ACPI_HEST_TYPE_RESERVED)
817 Temp16 = ACPI_HEST_TYPE_RESERVED;
820 AcpiOsPrintf ("%4.4X (%s)\n", ACPI_GET16 (Target), AcpiDmHestSubnames[Temp16]);
821 break;
823 case ACPI_DMT_HESTNTFY:
825 AcpiOsPrintf ("<Hardware Error Notification Structure>\n");
826 AcpiDmDumpTable (TableLength, CurrentOffset, Target,
827 sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify);
828 AcpiOsPrintf ("\n");
829 LastOutputBlankLine = TRUE;
830 break;
832 case ACPI_DMT_HESTNTYP:
834 /* HEST Notify types */
836 Temp8 = *Target;
837 if (Temp8 > ACPI_HEST_NOTIFY_RESERVED)
839 Temp8 = ACPI_HEST_NOTIFY_RESERVED;
842 AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiDmHestNotifySubnames[Temp8]);
843 break;
846 case ACPI_DMT_MADT:
848 /* MADT subtable types */
850 Temp8 = *Target;
851 if (Temp8 > ACPI_MADT_TYPE_RESERVED)
853 Temp8 = ACPI_MADT_TYPE_RESERVED;
856 AcpiOsPrintf ("%2.2X <%s>\n", *Target, AcpiDmMadtSubnames[Temp8]);
857 break;
859 case ACPI_DMT_SRAT:
861 /* SRAT subtable types */
863 Temp8 = *Target;
864 if (Temp8 > ACPI_SRAT_TYPE_RESERVED)
866 Temp8 = ACPI_SRAT_TYPE_RESERVED;
869 AcpiOsPrintf ("%2.2X <%s>\n", *Target, AcpiDmSratSubnames[Temp8]);
870 break;
872 case ACPI_DMT_FADTPM:
874 /* FADT Preferred PM Profile names */
876 Temp8 = *Target;
877 if (Temp8 > ACPI_FADT_PM_RESERVED)
879 Temp8 = ACPI_FADT_PM_RESERVED;
882 AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiDmFadtProfiles[Temp8]);
883 break;
885 case ACPI_DMT_IVRS:
887 /* IVRS subtable types */
889 Temp8 = *Target;
890 switch (Temp8)
892 case ACPI_IVRS_TYPE_HARDWARE:
893 Name = AcpiDmIvrsSubnames[0];
894 break;
896 case ACPI_IVRS_TYPE_MEMORY1:
897 case ACPI_IVRS_TYPE_MEMORY2:
898 case ACPI_IVRS_TYPE_MEMORY3:
899 Name = AcpiDmIvrsSubnames[1];
900 break;
902 default:
903 Name = AcpiDmIvrsSubnames[2];
904 break;
907 AcpiOsPrintf ("%2.2X <%s>\n", *Target, Name);
908 break;
910 case ACPI_DMT_EXIT:
911 return (AE_OK);
913 default:
914 ACPI_ERROR ((AE_INFO,
915 "**** Invalid table opcode [%X] ****\n", Info->Opcode));
916 return (AE_SUPPORT);
920 if (TableOffset && !SubtableLength)
922 /* If this table is not the main table, subtable must have valid length */
924 AcpiOsPrintf ("Invalid zero length subtable\n");
925 return (AE_BAD_DATA);
928 return (AE_OK);
932 /*******************************************************************************
934 * FUNCTION: AcpiDmCheckAscii
936 * PARAMETERS: Name - Ascii string
937 * Count - Number of characters to check
939 * RETURN: None
941 * DESCRIPTION: Ensure that the requested number of characters are printable
942 * Ascii characters. Sets non-printable and null chars to <space>.
944 ******************************************************************************/
946 static void
947 AcpiDmCheckAscii (
948 UINT8 *Name,
949 char *RepairedName,
950 UINT32 Count)
952 UINT32 i;
955 for (i = 0; i < Count; i++)
957 RepairedName[i] = Name[i];
959 if (!Name[i])
961 return;
963 if (!isprint (Name[i]))
965 RepairedName[i] = ' ';