dmtable.c revision 193529
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 - 2009, 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#include <contrib/dev/acpica/include/acpi.h>
117#include <contrib/dev/acpica/include/accommon.h>
118#include <contrib/dev/acpica/include/acdisasm.h>
119#include <contrib/dev/acpica/include/actables.h>
120
121/* This module used for application-level code only */
122
123#define _COMPONENT          ACPI_CA_DISASSEMBLER
124        ACPI_MODULE_NAME    ("dmtable")
125
126/* Local Prototypes */
127
128static ACPI_DMTABLE_DATA *
129AcpiDmGetTableData (
130    char                    *Signature);
131
132static void
133AcpiDmCheckAscii (
134    UINT8                   *Target,
135    UINT32                  Count);
136
137UINT8
138AcpiTbGenerateChecksum (
139    ACPI_TABLE_HEADER       *Table);
140
141
142/* These tables map a subtable type to a description string */
143
144static const char           *AcpiDmAsfSubnames[] =
145{
146    "ASF Information",
147    "ASF Alerts",
148    "ASF Remote Control",
149    "ASF RMCP Boot Options",
150    "ASF Address",
151    "Unknown SubTable Type"         /* Reserved */
152};
153
154static const char           *AcpiDmDmarSubnames[] =
155{
156    "Hardware Unit Definition",
157    "Reserved Memory Region",
158    "Root Port ATS Capability",
159    "Unknown SubTable Type"         /* Reserved */
160};
161
162static const char           *AcpiDmHestSubnames[] =
163{
164    "XPF Machine Check Exception",
165    "XPF Corrected Machine Check",
166    "NOT USED???",
167    "XPF Non-Maskable Interrupt",
168    "IPF Corrected Machine Check",
169    "IPF Corrected Platform Error",
170    "PCI Express Root Port AER",
171    "PCI Express AER (AER Endpoint)",
172    "PCI Express/PCI-X Bridge AER",
173    "Generic Hardware Error Source",
174    "Unknown SubTable Type"         /* Reserved */
175};
176
177static const char           *AcpiDmHestNotifySubnames[] =
178{
179    "Polled",
180    "External Interrupt",
181    "Local Interrupt",
182    "SCI",
183    "NMI",
184    "Unknown Notify Type"           /* Reserved */
185};
186
187static const char           *AcpiDmMadtSubnames[] =
188{
189    "Processor Local APIC",         /* ACPI_MADT_TYPE_LOCAL_APIC */
190    "I/O APIC",                     /* ACPI_MADT_TYPE_IO_APIC */
191    "Interrupt Source Override",    /* ACPI_MADT_TYPE_INTERRUPT_OVERRIDE */
192    "NMI Source",                   /* ACPI_MADT_TYPE_NMI_SOURCE */
193    "Local APIC NMI",               /* ACPI_MADT_TYPE_LOCAL_APIC_NMI */
194    "Local APIC Address Override",  /* ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE */
195    "I/O SAPIC",                    /* ACPI_MADT_TYPE_IO_SAPIC */
196    "Local SAPIC",                  /* ACPI_MADT_TYPE_LOCAL_SAPIC */
197    "Platform Interrupt Sources",   /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */
198    "Processor Local x2APIC",       /* ACPI_MADT_TYPE_LOCAL_X2APIC */
199    "Local x2APIC NMI",             /* ACPI_MADT_TYPE_LOCAL_X2APIC_NMI */
200    "Unknown SubTable Type"         /* Reserved */
201};
202
203static const char           *AcpiDmSratSubnames[] =
204{
205    "Processor Local APIC/SAPIC Affinity",
206    "Memory Affinity",
207    "Processor Local x2APIC Affinity",
208    "Unknown SubTable Type"         /* Reserved */
209};
210
211
212#define ACPI_FADT_PM_RESERVED       8
213
214static const char           *AcpiDmFadtProfiles[] =
215{
216    "Unspecified",
217    "Desktop",
218    "Mobile",
219    "Workstation",
220    "Enterprise Server",
221    "SOHO Server",
222    "Appliance PC",
223    "Performance Server",
224    "Unknown Profile Type"
225};
226
227
228/*******************************************************************************
229 *
230 * ACPI Table Data, indexed by signature.
231 *
232 * Simple tables have only a TableInfo structure, complex tables have a handler.
233 * This table must be NULL terminated. RSDP and FACS are special-cased
234 * elsewhere.
235 *
236 ******************************************************************************/
237
238static ACPI_DMTABLE_DATA    AcpiDmTableData[] =
239{
240    {ACPI_SIG_ASF,  NULL,                   AcpiDmDumpAsf,  "Alert Standard Format table"},
241    {ACPI_SIG_BOOT, AcpiDmTableInfoBoot,    NULL,           "Simple Boot Flag Table"},
242    {ACPI_SIG_BERT, AcpiDmTableInfoBert,    NULL,           "Boot Error Record Table"},
243    {ACPI_SIG_CPEP, NULL,                   AcpiDmDumpCpep, "Corrected Platform Error Polling table"},
244    {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp,    NULL,           "Debug Port table"},
245    {ACPI_SIG_DMAR, NULL,                   AcpiDmDumpDmar, "DMA Remapping table"},
246    {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt,    NULL,           "Embedded Controller Boot Resources Table"},
247    {ACPI_SIG_EINJ, NULL,                   AcpiDmDumpEinj, "Error Injection table"},
248    {ACPI_SIG_ERST, NULL,                   AcpiDmDumpErst, "Error Record Serialization Table"},
249    {ACPI_SIG_FADT, NULL,                   AcpiDmDumpFadt, "Fixed ACPI Description Table"},
250    {ACPI_SIG_HEST, NULL,                   AcpiDmDumpHest, "Hardware Error Source Table"},
251    {ACPI_SIG_HPET, AcpiDmTableInfoHpet,    NULL,           "High Precision Event Timer table"},
252    {ACPI_SIG_MADT, NULL,                   AcpiDmDumpMadt, "Multiple APIC Description Table"},
253    {ACPI_SIG_MCFG, NULL,                   AcpiDmDumpMcfg, "Memory Mapped Configuration table"},
254    {ACPI_SIG_RSDT, NULL,                   AcpiDmDumpRsdt, "Root System Description Table"},
255    {ACPI_SIG_SBST, AcpiDmTableInfoSbst,    NULL,           "Smart Battery Specification Table"},
256    {ACPI_SIG_SLIC, AcpiDmTableInfoSlic,    NULL,           "Software Licensing Description Table"},
257    {ACPI_SIG_SLIT, NULL,                   AcpiDmDumpSlit, "System Locality Information Table"},
258    {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr,    NULL,           "Serial Port Console Redirection table"},
259    {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi,    NULL,           "Server Platform Management Interface table"},
260    {ACPI_SIG_SRAT, NULL,                   AcpiDmDumpSrat, "System Resource Affinity Table"},
261    {ACPI_SIG_TCPA, AcpiDmTableInfoTcpa,    NULL,           "Trusted Computing Platform Alliance table"},
262    {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt,    NULL,           "Watchdog Resource Table"},
263    {ACPI_SIG_XSDT, NULL,                   AcpiDmDumpXsdt, "Extended System Description Table"},
264    {NULL,          NULL,                   NULL,           NULL}
265};
266
267
268/*******************************************************************************
269 *
270 * FUNCTION:    AcpiTbGenerateChecksum
271 *
272 * PARAMETERS:  Table               - Pointer to a valid ACPI table (with a
273 *                                    standard ACPI header)
274 *
275 * RETURN:      8 bit checksum of buffer
276 *
277 * DESCRIPTION: Computes an 8 bit checksum of the table.
278 *
279 ******************************************************************************/
280
281UINT8
282AcpiTbGenerateChecksum (
283    ACPI_TABLE_HEADER       *Table)
284{
285    UINT8                   Checksum;
286
287
288    /* Sum the entire table as-is */
289
290    Checksum = AcpiTbChecksum ((UINT8 *) Table, Table->Length);
291
292    /* Subtract off the existing checksum value in the table */
293
294    Checksum = (UINT8) (Checksum - Table->Checksum);
295
296    /* Compute the final checksum */
297
298    Checksum = (UINT8) (0 - Checksum);
299    return (Checksum);
300}
301
302
303/*******************************************************************************
304 *
305 * FUNCTION:    AcpiDmGetTableData
306 *
307 * PARAMETERS:  Signature           - ACPI signature (4 chars) to match
308 *
309 * RETURN:      Pointer to a valid ACPI_DMTABLE_DATA. Null if no match found.
310 *
311 * DESCRIPTION: Find a match in the global table of supported ACPI tables
312 *
313 ******************************************************************************/
314
315static ACPI_DMTABLE_DATA *
316AcpiDmGetTableData (
317    char                    *Signature)
318{
319    ACPI_DMTABLE_DATA       *TableData;
320
321
322    for (TableData = AcpiDmTableData; TableData->Signature; TableData++)
323    {
324        if (ACPI_COMPARE_NAME (Signature, TableData->Signature))
325        {
326            return (TableData);
327        }
328    }
329
330    return (NULL);
331}
332
333
334/*******************************************************************************
335 *
336 * FUNCTION:    AcpiDmDumpDataTable
337 *
338 * PARAMETERS:  Table               - An ACPI table
339 *
340 * RETURN:      None.
341 *
342 * DESCRIPTION: Format the contents of an ACPI data table (any table other
343 *              than an SSDT or DSDT that does not contain executable AML code)
344 *
345 ******************************************************************************/
346
347void
348AcpiDmDumpDataTable (
349    ACPI_TABLE_HEADER       *Table)
350{
351    ACPI_STATUS             Status;
352    ACPI_DMTABLE_DATA       *TableData;
353    UINT32                  Length;
354
355
356    /* Ignore tables that contain AML */
357
358    if (AcpiUtIsAmlTable (Table))
359    {
360        return;
361    }
362
363    /*
364     * Handle tables that don't use the common ACPI table header structure.
365     * Currently, these are the FACS and RSDP.
366     */
367    if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS))
368    {
369        Length = Table->Length;
370        AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFacs);
371    }
372    else if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_RSDP))
373    {
374        Length = AcpiDmDumpRsdp (Table);
375    }
376    else
377    {
378        /*
379         * All other tables must use the common ACPI table header, dump it now
380         */
381        Length = Table->Length;
382        Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHeader);
383        if (ACPI_FAILURE (Status))
384        {
385            return;
386        }
387        AcpiOsPrintf ("\n");
388
389        /* Match signature and dispatch appropriately */
390
391        TableData = AcpiDmGetTableData (Table->Signature);
392        if (!TableData)
393        {
394            if (!ACPI_STRNCMP (Table->Signature, "OEM", 3))
395            {
396                AcpiOsPrintf ("\n**** OEM-defined ACPI table [%4.4s], unknown contents\n\n",
397                    Table->Signature);
398            }
399            else
400            {
401                AcpiOsPrintf ("\n**** Unknown ACPI table type [%4.4s]\n\n",
402                    Table->Signature);
403            }
404        }
405        else if (TableData->TableHandler)
406        {
407            /* Complex table, has a handler */
408
409            TableData->TableHandler (Table);
410        }
411        else if (TableData->TableInfo)
412        {
413            /* Simple table, just walk the info table */
414
415            AcpiDmDumpTable (Length, 0, Table, 0, TableData->TableInfo);
416        }
417    }
418
419    /* Always dump the raw table data */
420
421    AcpiOsPrintf ("\nRaw Table Data\n\n");
422    AcpiUtDumpBuffer2 (ACPI_CAST_PTR (UINT8, Table), Length, DB_BYTE_DISPLAY);
423}
424
425
426/*******************************************************************************
427 *
428 * FUNCTION:    AcpiDmLineHeader
429 *
430 * PARAMETERS:  Offset              - Current byte offset, from table start
431 *              ByteLength          - Length of the field in bytes, 0 for flags
432 *              Name                - Name of this field
433 *              Value               - Optional value, displayed on left of ':'
434 *
435 * RETURN:      None
436 *
437 * DESCRIPTION: Utility routines for formatting output lines. Displays the
438 *              current table offset in hex and decimal, the field length,
439 *              and the field name.
440 *
441 ******************************************************************************/
442
443void
444AcpiDmLineHeader (
445    UINT32                  Offset,
446    UINT32                  ByteLength,
447    char                    *Name)
448{
449
450    if (ByteLength)
451    {
452        AcpiOsPrintf ("[%3.3Xh %4.4d% 3d] %28s : ",
453            Offset, Offset, ByteLength, Name);
454    }
455    else
456    {
457        AcpiOsPrintf ("%43s : ",
458            Name);
459    }
460}
461
462void
463AcpiDmLineHeader2 (
464    UINT32                  Offset,
465    UINT32                  ByteLength,
466    char                    *Name,
467    UINT32                  Value)
468{
469
470    if (ByteLength)
471    {
472        AcpiOsPrintf ("[%3.3Xh %4.4d% 3d] %24s % 3d : ",
473            Offset, Offset, ByteLength, Name, Value);
474    }
475    else
476    {
477        AcpiOsPrintf ("[%3.3Xh %4.4d   ] %24s % 3d : ",
478            Offset, Offset, Name, Value);
479    }
480}
481
482
483/*******************************************************************************
484 *
485 * FUNCTION:    AcpiDmDumpTable
486 *
487 * PARAMETERS:  TableLength         - Length of the entire ACPI table
488 *              TableOffset         - Starting offset within the table for this
489 *                                    sub-descriptor (0 if main table)
490 *              Table               - The ACPI table
491 *              SubtableLength      - Length of this sub-descriptor
492 *              Info                - Info table for this ACPI table
493 *
494 * RETURN:      None
495 *
496 * DESCRIPTION: Display ACPI table contents by walking the Info table.
497 *
498 ******************************************************************************/
499
500ACPI_STATUS
501AcpiDmDumpTable (
502    UINT32                  TableLength,
503    UINT32                  TableOffset,
504    void                    *Table,
505    UINT32                  SubtableLength,
506    ACPI_DMTABLE_INFO       *Info)
507{
508    UINT8                   *Target;
509    UINT32                  CurrentOffset;
510    UINT32                  ByteLength;
511    UINT8                   Temp8;
512    UINT16                  Temp16;
513    ACPI_DMTABLE_DATA       *TableData;
514    BOOLEAN                 LastOutputBlankLine = FALSE;
515
516
517    if (!Info)
518    {
519        AcpiOsPrintf ("Display not implemented\n");
520        return (AE_NOT_IMPLEMENTED);
521    }
522
523    /* Walk entire Info table; Null name terminates */
524
525    for (; Info->Name; Info++)
526    {
527        /*
528         * Target points to the field within the ACPI Table. CurrentOffset is
529         * the offset of the field from the start of the main table.
530         */
531        Target = ACPI_ADD_PTR (UINT8, Table, Info->Offset);
532        CurrentOffset = TableOffset + Info->Offset;
533
534        /* Check for beyond EOT or beyond subtable end */
535
536        if ((CurrentOffset >= TableLength) ||
537            (SubtableLength && (Info->Offset >= SubtableLength)))
538        {
539            AcpiOsPrintf ("**** ACPI table terminates in the middle of a data structure!\n");
540            return (AE_BAD_DATA);
541        }
542
543        /* Generate the byte length for this field */
544
545        switch (Info->Opcode)
546        {
547        case ACPI_DMT_UINT8:
548        case ACPI_DMT_CHKSUM:
549        case ACPI_DMT_SPACEID:
550        case ACPI_DMT_MADT:
551        case ACPI_DMT_SRAT:
552        case ACPI_DMT_ASF:
553        case ACPI_DMT_HESTNTYP:
554        case ACPI_DMT_FADTPM:
555            ByteLength = 1;
556            break;
557        case ACPI_DMT_UINT16:
558        case ACPI_DMT_DMAR:
559        case ACPI_DMT_HEST:
560            ByteLength = 2;
561            break;
562        case ACPI_DMT_UINT24:
563            ByteLength = 3;
564            break;
565        case ACPI_DMT_UINT32:
566        case ACPI_DMT_NAME4:
567        case ACPI_DMT_SIG:
568            ByteLength = 4;
569            break;
570        case ACPI_DMT_NAME6:
571            ByteLength = 6;
572            break;
573        case ACPI_DMT_UINT56:
574            ByteLength = 7;
575            break;
576        case ACPI_DMT_UINT64:
577        case ACPI_DMT_NAME8:
578            ByteLength = 8;
579            break;
580        case ACPI_DMT_STRING:
581            ByteLength = ACPI_STRLEN (ACPI_CAST_PTR (char, Target)) + 1;
582            break;
583        case ACPI_DMT_GAS:
584            if (!LastOutputBlankLine)
585            {
586                AcpiOsPrintf ("\n");
587                LastOutputBlankLine = TRUE;
588            }
589            ByteLength = sizeof (ACPI_GENERIC_ADDRESS);
590            break;
591        case ACPI_DMT_HESTNTFY:
592            if (!LastOutputBlankLine)
593            {
594                AcpiOsPrintf ("\n");
595                LastOutputBlankLine = TRUE;
596            }
597            ByteLength = sizeof (ACPI_HEST_NOTIFY);
598            break;
599        default:
600            ByteLength = 0;
601            break;
602        }
603
604        if (CurrentOffset + ByteLength > TableLength)
605        {
606            AcpiOsPrintf ("**** ACPI table terminates in the middle of a data structure!\n");
607            return (AE_BAD_DATA);
608        }
609
610        /* Start a new line and decode the opcode */
611
612        AcpiDmLineHeader (CurrentOffset, ByteLength, Info->Name);
613
614        switch (Info->Opcode)
615        {
616        /* Single-bit Flag fields. Note: Opcode is the bit position */
617
618        case ACPI_DMT_FLAG0:
619        case ACPI_DMT_FLAG1:
620        case ACPI_DMT_FLAG2:
621        case ACPI_DMT_FLAG3:
622        case ACPI_DMT_FLAG4:
623        case ACPI_DMT_FLAG5:
624        case ACPI_DMT_FLAG6:
625        case ACPI_DMT_FLAG7:
626
627            AcpiOsPrintf ("%1.1X\n", (*Target >> Info->Opcode) & 0x01);
628            break;
629
630        /* 2-bit Flag fields */
631
632        case ACPI_DMT_FLAGS0:
633
634            AcpiOsPrintf ("%1.1X\n", *Target & 0x03);
635            break;
636
637        case ACPI_DMT_FLAGS2:
638
639            AcpiOsPrintf ("%1.1X\n", (*Target >> 2) & 0x03);
640            break;
641
642        /* Standard Data Types */
643
644        case ACPI_DMT_UINT8:
645
646            AcpiOsPrintf ("%2.2X\n", *Target);
647            break;
648
649        case ACPI_DMT_UINT16:
650
651            AcpiOsPrintf ("%4.4X\n", ACPI_GET16 (Target));
652            break;
653
654        case ACPI_DMT_UINT24:
655
656            AcpiOsPrintf ("%2.2X%2.2X%2.2X\n",
657                *Target, *(Target + 1), *(Target + 2));
658            break;
659
660        case ACPI_DMT_UINT32:
661
662            AcpiOsPrintf ("%8.8X\n", ACPI_GET32 (Target));
663            break;
664
665        case ACPI_DMT_UINT56:
666
667            for (Temp8 = 0; Temp8 < 7; Temp8++)
668            {
669                AcpiOsPrintf ("%2.2X", Target[Temp8]);
670            }
671            AcpiOsPrintf ("\n");
672            break;
673
674        case ACPI_DMT_UINT64:
675
676            AcpiOsPrintf ("%8.8X%8.8X\n",
677                ACPI_FORMAT_UINT64 (ACPI_GET64 (Target)));
678            break;
679
680        case ACPI_DMT_STRING:
681
682            AcpiOsPrintf ("%s\n", ACPI_CAST_PTR (char, Target));
683            break;
684
685        /* Fixed length ASCII name fields */
686
687        case ACPI_DMT_SIG:
688
689            AcpiDmCheckAscii (Target, 4);
690            AcpiOsPrintf ("\"%4.4s\"    ", Target);
691            TableData = AcpiDmGetTableData (ACPI_CAST_PTR (char, Target));
692            if (TableData)
693            {
694                AcpiOsPrintf ("/* %s */", TableData->Name);
695            }
696            AcpiOsPrintf ("\n");
697            break;
698
699        case ACPI_DMT_NAME4:
700
701            AcpiDmCheckAscii (Target, 4);
702            AcpiOsPrintf ("\"%4.4s\"\n", Target);
703            break;
704
705        case ACPI_DMT_NAME6:
706
707            AcpiDmCheckAscii (Target, 6);
708            AcpiOsPrintf ("\"%6.6s\"\n", Target);
709            break;
710
711        case ACPI_DMT_NAME8:
712
713            AcpiDmCheckAscii (Target, 8);
714            AcpiOsPrintf ("\"%8.8s\"\n", Target);
715            break;
716
717        /* Special Data Types */
718
719        case ACPI_DMT_CHKSUM:
720
721            /* Checksum, display and validate */
722
723            AcpiOsPrintf ("%2.2X", *Target);
724            Temp8 = AcpiTbGenerateChecksum (Table);
725            if (Temp8 != ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum)
726            {
727                AcpiOsPrintf (
728                    "     /* Incorrect checksum, should be %2.2X */", Temp8);
729            }
730            AcpiOsPrintf ("\n");
731            break;
732
733        case ACPI_DMT_SPACEID:
734
735            /* Address Space ID */
736
737            AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiUtGetRegionName (*Target));
738            break;
739
740        case ACPI_DMT_GAS:
741
742            /* Generic Address Structure */
743
744            AcpiOsPrintf ("<Generic Address Structure>\n");
745            AcpiDmDumpTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length,
746                CurrentOffset, Target, sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas);
747            AcpiOsPrintf ("\n");
748            LastOutputBlankLine = TRUE;
749            break;
750
751        case ACPI_DMT_ASF:
752
753            /* ASF subtable types */
754
755            Temp16 = (UINT16) ((*Target) & 0x7F);  /* Top bit can be zero or one */
756            if (Temp16 > ACPI_ASF_TYPE_RESERVED)
757            {
758                Temp16 = ACPI_ASF_TYPE_RESERVED;
759            }
760
761            AcpiOsPrintf ("%2.2X <%s>\n", *Target, AcpiDmAsfSubnames[Temp16]);
762            break;
763
764        case ACPI_DMT_DMAR:
765
766            /* DMAR subtable types */
767
768            Temp16 = ACPI_GET16 (Target);
769            if (Temp16 > ACPI_DMAR_TYPE_RESERVED)
770            {
771                Temp16 = ACPI_DMAR_TYPE_RESERVED;
772            }
773
774            AcpiOsPrintf ("%4.4X <%s>\n", ACPI_GET16 (Target), AcpiDmDmarSubnames[Temp16]);
775            break;
776
777        case ACPI_DMT_HEST:
778
779            /* HEST subtable types */
780
781            Temp16 = ACPI_GET16 (Target);
782            if (Temp16 > ACPI_HEST_TYPE_RESERVED)
783            {
784                Temp16 = ACPI_HEST_TYPE_RESERVED;
785            }
786
787            AcpiOsPrintf ("%4.4X (%s)\n", ACPI_GET16 (Target), AcpiDmHestSubnames[Temp16]);
788            break;
789
790        case ACPI_DMT_HESTNTFY:
791
792            AcpiOsPrintf ("<Hardware Error Notification Structure>\n");
793            AcpiDmDumpTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length,
794                CurrentOffset, Target, sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify);
795            AcpiOsPrintf ("\n");
796            LastOutputBlankLine = TRUE;
797            break;
798
799        case ACPI_DMT_HESTNTYP:
800
801            /* HEST Notify types */
802
803            Temp8 = *Target;
804            if (Temp8 > ACPI_HEST_NOTIFY_RESERVED)
805            {
806                Temp8 = ACPI_HEST_NOTIFY_RESERVED;
807            }
808
809            AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiDmHestNotifySubnames[Temp8]);
810            break;
811
812
813        case ACPI_DMT_MADT:
814
815            /* MADT subtable types */
816
817            Temp8 = *Target;
818            if (Temp8 > ACPI_MADT_TYPE_RESERVED)
819            {
820                Temp8 = ACPI_MADT_TYPE_RESERVED;
821            }
822
823            AcpiOsPrintf ("%2.2X <%s>\n", *Target, AcpiDmMadtSubnames[Temp8]);
824            break;
825
826        case ACPI_DMT_SRAT:
827
828            /* SRAT subtable types */
829
830            Temp8 = *Target;
831            if (Temp8 > ACPI_SRAT_TYPE_RESERVED)
832            {
833                Temp8 = ACPI_SRAT_TYPE_RESERVED;
834            }
835
836            AcpiOsPrintf ("%2.2X <%s>\n", *Target, AcpiDmSratSubnames[Temp8]);
837            break;
838
839        case ACPI_DMT_FADTPM:
840
841            /* FADT Preferred PM Profile names */
842
843            Temp8 = *Target;
844            if (Temp8 > ACPI_FADT_PM_RESERVED)
845            {
846                Temp8 = ACPI_FADT_PM_RESERVED;
847            }
848
849            AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiDmFadtProfiles[Temp8]);
850            break;
851
852        case ACPI_DMT_EXIT:
853            return (AE_OK);
854
855        default:
856            ACPI_ERROR ((AE_INFO,
857                "**** Invalid table opcode [%X] ****\n", Info->Opcode));
858            return (AE_SUPPORT);
859        }
860    }
861
862    if (TableOffset && !SubtableLength)
863    {
864        /* If this table is not the main table, subtable must have valid length */
865
866        AcpiOsPrintf ("Invalid zero length subtable\n");
867        return (AE_BAD_DATA);
868    }
869
870    return (AE_OK);
871}
872
873
874/*******************************************************************************
875 *
876 * FUNCTION:    AcpiDmCheckAscii
877 *
878 * PARAMETERS:  Name                - Ascii string
879 *              Count               - Number of characters to check
880 *
881 * RETURN:      None
882 *
883 * DESCRIPTION: Ensure that the requested number of characters are printable
884 *              Ascii characters. Sets non-printable and null chars to <space>.
885 *
886 ******************************************************************************/
887
888static void
889AcpiDmCheckAscii (
890    UINT8                   *Name,
891    UINT32                  Count)
892{
893    UINT32                  i;
894
895
896    for (i = 0; i < Count; i++)
897    {
898        if (!Name[i] || !isprint (Name[i]))
899        {
900            Name[i] = ' ';
901        }
902    }
903}
904