OSDN Git Service

klibc基本機能実装. ACPICAの準備
[vaneos/DivergeMirror.git] / drivers / acpi / common / dmtable.c
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 - 2015, 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 "acpi.h"
117 #include "accommon.h"
118 #include "acdisasm.h"
119 #include "actables.h"
120 #include "aslcompiler.h"
121 #include "dtcompiler.h"
122
123 /* This module used for application-level code only */
124
125 #define _COMPONENT          ACPI_CA_DISASSEMBLER
126         ACPI_MODULE_NAME    ("dmtable")
127
128 const AH_TABLE *
129 AcpiAhGetTableInfo (
130     char                    *Signature);
131
132
133 /* Local Prototypes */
134
135 static void
136 AcpiDmCheckAscii (
137     UINT8                   *Target,
138     char                    *RepairedName,
139     UINT32                  Count);
140
141
142 /* Common format strings for commented values */
143
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"
148
149 /* These tables map a subtable type to a description string */
150
151 static const char           *AcpiDmAsfSubnames[] =
152 {
153     "ASF Information",
154     "ASF Alerts",
155     "ASF Remote Control",
156     "ASF RMCP Boot Options",
157     "ASF Address",
158     "Unknown Subtable Type"         /* Reserved */
159 };
160
161 static const char           *AcpiDmDmarSubnames[] =
162 {
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 */
169 };
170
171 static const char           *AcpiDmDmarScope[] =
172 {
173     "Reserved value",
174     "PCI Endpoint Device",
175     "PCI Bridge Device",
176     "IOAPIC Device",
177     "Message-capable HPET Device",
178     "Namespace Device",
179     "Unknown Scope Type"            /* Reserved */
180 };
181
182 static const char           *AcpiDmEinjActions[] =
183 {
184     "Begin Operation",
185     "Get Trigger Table",
186     "Set Error Type",
187     "Get Error Type",
188     "End Operation",
189     "Execute Operation",
190     "Check Busy Status",
191     "Get Command Status",
192     "Set Error Type With Address",
193     "Unknown Action"
194 };
195
196 static const char           *AcpiDmEinjInstructions[] =
197 {
198     "Read Register",
199     "Read Register Value",
200     "Write Register",
201     "Write Register Value",
202     "Noop",
203     "Flush Cacheline",
204     "Unknown Instruction"
205 };
206
207 static const char           *AcpiDmErstActions[] =
208 {
209     "Begin Write Operation",
210     "Begin Read Operation",
211     "Begin Clear Operation",
212     "End Operation",
213     "Set Record Offset",
214     "Execute Operation",
215     "Check Busy Status",
216     "Get Command Status",
217     "Get Record Identifier",
218     "Set Record Identifier",
219     "Get Record Count",
220     "Begin Dummy Write",
221     "Unused/Unknown Action",
222     "Get Error Address Range",
223     "Get Error Address Length",
224     "Get Error Attributes",
225     "Unknown Action"
226 };
227
228 static const char           *AcpiDmErstInstructions[] =
229 {
230     "Read Register",
231     "Read Register Value",
232     "Write Register",
233     "Write Register Value",
234     "Noop",
235     "Load Var1",
236     "Load Var2",
237     "Store Var1",
238     "Add",
239     "Subtract",
240     "Add Value",
241     "Subtract Value",
242     "Stall",
243     "Stall While True",
244     "Skip Next If True",
245     "GoTo",
246     "Set Source Address",
247     "Set Destination Address",
248     "Move Data",
249     "Unknown Instruction"
250 };
251
252 static const char           *AcpiDmGtdtSubnames[] =
253 {
254     "Generic Timer Block",
255     "Generic Watchdog Timer",
256     "Unknown Subtable Type"         /* Reserved */
257 };
258
259 static const char           *AcpiDmHestSubnames[] =
260 {
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 */
272 };
273
274 static const char           *AcpiDmHestNotifySubnames[] =
275 {
276     "Polled",
277     "External Interrupt",
278     "Local Interrupt",
279     "SCI",
280     "NMI",
281     "CMCI",                         /* ACPI 5.0 */
282     "MCE",                          /* ACPI 5.0 */
283     "Unknown Notify Type"           /* Reserved */
284 };
285
286 static const char           *AcpiDmMadtSubnames[] =
287 {
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 */
305 };
306
307 static const char           *AcpiDmNfitSubnames[] =
308 {
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 */
317 };
318
319 static const char           *AcpiDmPcctSubnames[] =
320 {
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 */
324 };
325
326 static const char           *AcpiDmPmttSubnames[] =
327 {
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 */
332 };
333
334 static const char           *AcpiDmSratSubnames[] =
335 {
336     "Processor Local APIC/SAPIC Affinity",
337     "Memory Affinity",
338     "Processor Local x2APIC Affinity",
339     "GICC Affinity",
340     "Unknown Subtable Type"         /* Reserved */
341 };
342
343 static const char           *AcpiDmIvrsSubnames[] =
344 {
345     "Hardware Definition Block",
346     "Memory Definition Block",
347     "Unknown Subtable Type"         /* Reserved */
348 };
349
350 static const char           *AcpiDmLpitSubnames[] =
351 {
352     "Native C-state Idle Structure",
353     "Unknown Subtable Type"         /* Reserved */
354 };
355
356 #define ACPI_FADT_PM_RESERVED       9
357
358 static const char           *AcpiDmFadtProfiles[] =
359 {
360     "Unspecified",
361     "Desktop",
362     "Mobile",
363     "Workstation",
364     "Enterprise Server",
365     "SOHO Server",
366     "Appliance PC",
367     "Performance Server",
368     "Tablet",
369     "Unknown Profile Type"
370 };
371
372 #define ACPI_GAS_WIDTH_RESERVED     5
373
374 static const char           *AcpiDmGasAccessWidth[] =
375 {
376     "Undefined/Legacy",
377     "Byte Access:8",
378     "Word Access:16",
379     "DWord Access:32",
380     "QWord Access:64",
381     "Unknown Width Encoding"
382 };
383
384
385 /*******************************************************************************
386  *
387  * ACPI Table Data, indexed by signature.
388  *
389  * Each entry contains: Signature, Table Info, Handler, DtHandler,
390  *  Template, Description
391  *
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.
395  *
396  * Note: Any tables added here should be duplicated within AcpiSupportedTables
397  * in the file common/ahtable.c
398  *
399  ******************************************************************************/
400
401 const ACPI_DMTABLE_DATA     AcpiDmTableData[] =
402 {
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}
455 };
456
457
458 /*******************************************************************************
459  *
460  * FUNCTION:    AcpiDmGenerateChecksum
461  *
462  * PARAMETERS:  Table               - Pointer to table to be checksummed
463  *              Length              - Length of the table
464  *              OriginalChecksum    - Value of the checksum field
465  *
466  * RETURN:      8 bit checksum of buffer
467  *
468  * DESCRIPTION: Computes an 8 bit checksum of the table.
469  *
470  ******************************************************************************/
471
472 UINT8
473 AcpiDmGenerateChecksum (
474     void                    *Table,
475     UINT32                  Length,
476     UINT8                   OriginalChecksum)
477 {
478     UINT8                   Checksum;
479
480
481     /* Sum the entire table as-is */
482
483     Checksum = AcpiTbChecksum ((UINT8 *) Table, Length);
484
485     /* Subtract off the existing checksum value in the table */
486
487     Checksum = (UINT8) (Checksum - OriginalChecksum);
488
489     /* Compute the final checksum */
490
491     Checksum = (UINT8) (0 - Checksum);
492     return (Checksum);
493 }
494
495
496 /*******************************************************************************
497  *
498  * FUNCTION:    AcpiDmGetTableData
499  *
500  * PARAMETERS:  Signature           - ACPI signature (4 chars) to match
501  *
502  * RETURN:      Pointer to a valid ACPI_DMTABLE_DATA. Null if no match found.
503  *
504  * DESCRIPTION: Find a match in the global table of supported ACPI tables
505  *
506  ******************************************************************************/
507
508 const ACPI_DMTABLE_DATA *
509 AcpiDmGetTableData (
510     char                    *Signature)
511 {
512     const ACPI_DMTABLE_DATA *Info;
513
514
515     for (Info = AcpiDmTableData; Info->Signature; Info++)
516     {
517         if (ACPI_COMPARE_NAME (Signature, Info->Signature))
518         {
519             return (Info);
520         }
521     }
522
523     return (NULL);
524 }
525
526
527 /*******************************************************************************
528  *
529  * FUNCTION:    AcpiDmDumpDataTable
530  *
531  * PARAMETERS:  Table               - An ACPI table
532  *
533  * RETURN:      None.
534  *
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)
537  *
538  ******************************************************************************/
539
540 void
541 AcpiDmDumpDataTable (
542     ACPI_TABLE_HEADER       *Table)
543 {
544     ACPI_STATUS             Status;
545     const ACPI_DMTABLE_DATA *TableData;
546     UINT32                  Length;
547
548
549     /* Ignore tables that contain AML */
550
551     if (AcpiUtIsAmlTable (Table))
552     {
553         if (Gbl_VerboseTemplates)
554         {
555             /* Dump the raw table data */
556
557             Length = Table->Length;
558
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");
564         }
565         return;
566     }
567
568     /*
569      * Handle tables that don't use the common ACPI table header structure.
570      * Currently, these are the FACS, RSDP, and S3PT.
571      */
572     if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS))
573     {
574         Length = Table->Length;
575         AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFacs);
576     }
577     else if (ACPI_VALIDATE_RSDP_SIG (Table->Signature))
578     {
579         Length = AcpiDmDumpRsdp (Table);
580     }
581     else if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_S3PT))
582     {
583         Length = AcpiDmDumpS3pt (Table);
584     }
585     else
586     {
587         /*
588          * All other tables must use the common ACPI table header, dump it now
589          */
590         Length = Table->Length;
591         Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHeader);
592         if (ACPI_FAILURE (Status))
593         {
594             return;
595         }
596         AcpiOsPrintf ("\n");
597
598         /* Match signature and dispatch appropriately */
599
600         TableData = AcpiDmGetTableData (Table->Signature);
601         if (!TableData)
602         {
603             if (!ACPI_STRNCMP (Table->Signature, "OEM", 3))
604             {
605                 AcpiOsPrintf ("\n**** OEM-defined ACPI table [%4.4s], unknown contents\n\n",
606                     Table->Signature);
607             }
608             else
609             {
610                 AcpiOsPrintf ("\n**** Unknown ACPI table signature [%4.4s]\n\n",
611                     Table->Signature);
612
613                 fprintf (stderr, "Unknown ACPI table signature [%4.4s], ",
614                     Table->Signature);
615
616                 if (!AcpiGbl_ForceAmlDisassembly)
617                 {
618                     fprintf (stderr, "decoding ACPI table header only\n");
619                 }
620                 else
621                 {
622                     fprintf (stderr, "assuming table contains valid AML code\n");
623                 }
624             }
625         }
626         else if (TableData->TableHandler)
627         {
628             /* Complex table, has a handler */
629
630             TableData->TableHandler (Table);
631         }
632         else if (TableData->TableInfo)
633         {
634             /* Simple table, just walk the info table */
635
636             AcpiDmDumpTable (Length, 0, Table, 0, TableData->TableInfo);
637         }
638     }
639
640     if (!Gbl_DoTemplates || Gbl_VerboseTemplates)
641     {
642         /* Dump the raw table data */
643
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);
648     }
649 }
650
651
652 /*******************************************************************************
653  *
654  * FUNCTION:    AcpiDmLineHeader
655  *
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
659  *
660  * RETURN:      None
661  *
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.
665  *
666  ******************************************************************************/
667
668 void
669 AcpiDmLineHeader (
670     UINT32                  Offset,
671     UINT32                  ByteLength,
672     char                    *Name)
673 {
674
675     /* Allow a null name for fields that span multiple lines (large buffers) */
676
677     if (!Name)
678     {
679         Name = "";
680     }
681
682     if (Gbl_DoTemplates && !Gbl_VerboseTemplates) /* Terse template */
683     {
684         if (ByteLength)
685         {
686             AcpiOsPrintf ("[%.4d] %34s : ", ByteLength, Name);
687         }
688         else
689         {
690             if (*Name)
691             {
692                 AcpiOsPrintf ("%41s : ", Name);
693             }
694             else
695             {
696                 AcpiOsPrintf ("%41s   ", Name);
697             }
698         }
699     }
700     else /* Normal disassembler or verbose template */
701     {
702         if (ByteLength)
703         {
704             AcpiOsPrintf ("[%3.3Xh %4.4d% 4d] %28s : ",
705                 Offset, Offset, ByteLength, Name);
706         }
707         else
708         {
709             if (*Name)
710             {
711                 AcpiOsPrintf ("%44s : ", Name);
712             }
713             else
714             {
715                 AcpiOsPrintf ("%44s   ", Name);
716             }
717         }
718     }
719 }
720
721 void
722 AcpiDmLineHeader2 (
723     UINT32                  Offset,
724     UINT32                  ByteLength,
725     char                    *Name,
726     UINT32                  Value)
727 {
728
729     if (Gbl_DoTemplates && !Gbl_VerboseTemplates) /* Terse template */
730     {
731         if (ByteLength)
732         {
733             AcpiOsPrintf ("[%.4d] %30s %3d : ",
734                 ByteLength, Name, Value);
735         }
736         else
737         {
738             AcpiOsPrintf ("%36s % 3d : ",
739                 Name, Value);
740         }
741     }
742     else /* Normal disassembler or verbose template */
743     {
744         if (ByteLength)
745         {
746             AcpiOsPrintf ("[%3.3Xh %4.4d %3d] %24s %3d : ",
747                 Offset, Offset, ByteLength, Name, Value);
748         }
749         else
750         {
751             AcpiOsPrintf ("[%3.3Xh %4.4d   ] %24s %3d : ",
752                 Offset, Offset, Name, Value);
753         }
754     }
755 }
756
757
758 /*******************************************************************************
759  *
760  * FUNCTION:    AcpiDmDumpTable
761  *
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
768  *
769  * RETURN:      None
770  *
771  * DESCRIPTION: Display ACPI table contents by walking the Info table.
772  *
773  * Note: This function must remain in sync with DtGetFieldLength.
774  *
775  ******************************************************************************/
776
777 ACPI_STATUS
778 AcpiDmDumpTable (
779     UINT32                  TableLength,
780     UINT32                  TableOffset,
781     void                    *Table,
782     UINT32                  SubtableLength,
783     ACPI_DMTABLE_INFO       *Info)
784 {
785     UINT8                   *Target;
786     UINT32                  CurrentOffset;
787     UINT32                  ByteLength;
788     UINT8                   Temp8;
789     UINT16                  Temp16;
790     UINT32                  Temp32;
791     UINT64                  Value;
792     const AH_TABLE          *TableData;
793     const char              *Name;
794     BOOLEAN                 LastOutputBlankLine = FALSE;
795     char                    RepairedName[8];
796
797
798     if (!Info)
799     {
800         AcpiOsPrintf ("Display not implemented\n");
801         return (AE_NOT_IMPLEMENTED);
802     }
803
804     /* Walk entire Info table; Null name terminates */
805
806     for (; Info->Name; Info++)
807     {
808         /*
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.
811          */
812         Target = ACPI_ADD_PTR (UINT8, Table, Info->Offset);
813         CurrentOffset = TableOffset + Info->Offset;
814
815         /* Check for beyond subtable end or (worse) beyond EOT */
816
817         if (SubtableLength && (Info->Offset >= SubtableLength))
818         {
819             AcpiOsPrintf (
820                 "/**** ACPI subtable terminates early - "
821                 "may be older version (dump table) */\n");
822
823             /* Move on to next subtable */
824
825             return (AE_OK);
826         }
827
828         if (CurrentOffset >= TableLength)
829         {
830             AcpiOsPrintf (
831                 "/**** ACPI table terminates "
832                 "in the middle of a data structure! (dump table) */\n");
833             return (AE_BAD_DATA);
834         }
835
836         /* Generate the byte length for this field */
837
838         switch (Info->Opcode)
839         {
840         case ACPI_DMT_UINT8:
841         case ACPI_DMT_CHKSUM:
842         case ACPI_DMT_SPACEID:
843         case ACPI_DMT_ACCWIDTH:
844         case ACPI_DMT_IVRS:
845         case ACPI_DMT_GTDT:
846         case ACPI_DMT_MADT:
847         case ACPI_DMT_PCCT:
848         case ACPI_DMT_PMTT:
849         case ACPI_DMT_SRAT:
850         case ACPI_DMT_ASF:
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:
858
859             ByteLength = 1;
860             break;
861
862         case ACPI_DMT_UINT16:
863         case ACPI_DMT_DMAR:
864         case ACPI_DMT_HEST:
865         case ACPI_DMT_NFIT:
866
867             ByteLength = 2;
868             break;
869
870         case ACPI_DMT_UINT24:
871
872             ByteLength = 3;
873             break;
874
875         case ACPI_DMT_UINT32:
876         case ACPI_DMT_NAME4:
877         case ACPI_DMT_SIG:
878         case ACPI_DMT_LPIT:
879
880             ByteLength = 4;
881             break;
882
883         case ACPI_DMT_UINT40:
884
885             ByteLength = 5;
886             break;
887
888         case ACPI_DMT_UINT48:
889         case ACPI_DMT_NAME6:
890
891             ByteLength = 6;
892             break;
893
894         case ACPI_DMT_UINT56:
895         case ACPI_DMT_BUF7:
896
897             ByteLength = 7;
898             break;
899
900         case ACPI_DMT_UINT64:
901         case ACPI_DMT_NAME8:
902
903             ByteLength = 8;
904             break;
905
906         case ACPI_DMT_BUF10:
907
908             ByteLength = 10;
909             break;
910
911         case ACPI_DMT_BUF16:
912         case ACPI_DMT_UUID:
913
914             ByteLength = 16;
915             break;
916
917         case ACPI_DMT_BUF128:
918
919             ByteLength = 128;
920             break;
921
922         case ACPI_DMT_UNICODE:
923         case ACPI_DMT_BUFFER:
924         case ACPI_DMT_RAW_BUFFER:
925
926             ByteLength = SubtableLength;
927             break;
928
929         case ACPI_DMT_STRING:
930
931             ByteLength = ACPI_STRLEN (ACPI_CAST_PTR (char, Target)) + 1;
932             break;
933
934         case ACPI_DMT_GAS:
935
936             if (!LastOutputBlankLine)
937             {
938                 AcpiOsPrintf ("\n");
939                 LastOutputBlankLine = TRUE;
940             }
941             ByteLength = sizeof (ACPI_GENERIC_ADDRESS);
942             break;
943
944         case ACPI_DMT_HESTNTFY:
945
946             if (!LastOutputBlankLine)
947             {
948                 AcpiOsPrintf ("\n");
949                 LastOutputBlankLine = TRUE;
950             }
951             ByteLength = sizeof (ACPI_HEST_NOTIFY);
952             break;
953
954         case ACPI_DMT_IORTMEM:
955
956             if (!LastOutputBlankLine)
957             {
958                 LastOutputBlankLine = FALSE;
959             }
960             ByteLength = sizeof (ACPI_IORT_MEMORY_ACCESS);
961             break;
962
963         default:
964
965             ByteLength = 0;
966             break;
967         }
968
969         /* Check if we are beyond a subtable, or (worse) beyond EOT */
970
971         if (CurrentOffset + ByteLength > TableLength)
972         {
973             if (SubtableLength)
974             {
975                 AcpiOsPrintf (
976                     "/**** ACPI subtable terminates early - "
977                     "may be older version (dump table) */\n");
978
979                 /* Move on to next subtable */
980
981                 return (AE_OK);
982             }
983
984             AcpiOsPrintf (
985                 "/**** ACPI table terminates "
986                 "in the middle of a data structure! */\n");
987             return (AE_BAD_DATA);
988         }
989
990         if (Info->Opcode == ACPI_DMT_EXTRA_TEXT)
991         {
992             AcpiOsPrintf ("%s", Info->Name);
993             continue;
994         }
995
996         /* Start a new line and decode the opcode */
997
998         AcpiDmLineHeader (CurrentOffset, ByteLength, Info->Name);
999
1000         switch (Info->Opcode)
1001         {
1002         /* Single-bit Flag fields. Note: Opcode is the bit position */
1003
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:
1012
1013             AcpiOsPrintf ("%1.1X\n", (*Target >> Info->Opcode) & 0x01);
1014             break;
1015
1016         /* 2-bit Flag fields */
1017
1018         case ACPI_DMT_FLAGS0:
1019
1020             AcpiOsPrintf ("%1.1X\n", *Target & 0x03);
1021             break;
1022
1023         case ACPI_DMT_FLAGS1:
1024
1025             AcpiOsPrintf ("%1.1X\n", (*Target >> 1) & 0x03);
1026             break;
1027
1028         case ACPI_DMT_FLAGS2:
1029
1030             AcpiOsPrintf ("%1.1X\n", (*Target >> 2) & 0x03);
1031             break;
1032
1033         case ACPI_DMT_FLAGS4:
1034
1035             AcpiOsPrintf ("%1.1X\n", (*Target >> 4) & 0x03);
1036             break;
1037
1038         /* Integer Data Types */
1039
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:
1048             /*
1049              * Dump bytes - high byte first, low byte last.
1050              * Note: All ACPI tables are little-endian.
1051              */
1052             Value = 0;
1053             for (Temp8 = (UINT8) ByteLength; Temp8 > 0; Temp8--)
1054             {
1055                 AcpiOsPrintf ("%2.2X", Target[Temp8 - 1]);
1056                 Value |= Target[Temp8 - 1];
1057                 Value <<= 8;
1058             }
1059
1060             if (!Value && (Info->Flags & DT_DESCRIBES_OPTIONAL))
1061             {
1062                 AcpiOsPrintf (" [Optional field not present]");
1063             }
1064
1065             AcpiOsPrintf ("\n");
1066             break;
1067
1068         case ACPI_DMT_BUF7:
1069         case ACPI_DMT_BUF10:
1070         case ACPI_DMT_BUF16:
1071         case ACPI_DMT_BUF128:
1072             /*
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.
1076              */
1077             for (Temp16 = 0; Temp16 < ByteLength; Temp16++)
1078             {
1079                 AcpiOsPrintf ("%2.2X", Target[Temp16]);
1080                 if ((UINT32) (Temp16 + 1) < ByteLength)
1081                 {
1082                     if ((Temp16 > 0) && (!((Temp16+1) % 16)))
1083                     {
1084                         AcpiOsPrintf (" \\\n"); /* Line continuation */
1085                         AcpiDmLineHeader (0, 0, NULL);
1086                     }
1087                     else
1088                     {
1089                         AcpiOsPrintf (" ");
1090                     }
1091                 }
1092             }
1093             AcpiOsPrintf ("\n");
1094             break;
1095
1096         case ACPI_DMT_UUID:
1097
1098             /* Convert 16-byte UUID buffer to 36-byte formatted UUID string */
1099
1100             (void) AuConvertUuidToString ((char *) Target, MsgBuffer);
1101
1102             AcpiOsPrintf ("%s\n", MsgBuffer);
1103             break;
1104
1105         case ACPI_DMT_STRING:
1106
1107             AcpiOsPrintf ("\"%s\"\n", ACPI_CAST_PTR (char, Target));
1108             break;
1109
1110         /* Fixed length ASCII name fields */
1111
1112         case ACPI_DMT_SIG:
1113
1114             AcpiDmCheckAscii (Target, RepairedName, 4);
1115             AcpiOsPrintf ("\"%.4s\"    ", RepairedName);
1116             TableData = AcpiAhGetTableInfo (ACPI_CAST_PTR (char, Target));
1117             if (TableData)
1118             {
1119                 AcpiOsPrintf (STRING_FORMAT, TableData->Description);
1120             }
1121             else
1122             {
1123                 AcpiOsPrintf ("\n");
1124             }
1125             break;
1126
1127         case ACPI_DMT_NAME4:
1128
1129             AcpiDmCheckAscii (Target, RepairedName, 4);
1130             AcpiOsPrintf ("\"%.4s\"\n", RepairedName);
1131             break;
1132
1133         case ACPI_DMT_NAME6:
1134
1135             AcpiDmCheckAscii (Target, RepairedName, 6);
1136             AcpiOsPrintf ("\"%.6s\"\n", RepairedName);
1137             break;
1138
1139         case ACPI_DMT_NAME8:
1140
1141             AcpiDmCheckAscii (Target, RepairedName, 8);
1142             AcpiOsPrintf ("\"%.8s\"\n", RepairedName);
1143             break;
1144
1145         /* Special Data Types */
1146
1147         case ACPI_DMT_CHKSUM:
1148
1149             /* Checksum, display and validate */
1150
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);
1155
1156             if (Temp8 != ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum)
1157             {
1158                 AcpiOsPrintf (
1159                     "     /* Incorrect checksum, should be %2.2X */", Temp8);
1160             }
1161             AcpiOsPrintf ("\n");
1162             break;
1163
1164         case ACPI_DMT_SPACEID:
1165
1166             /* Address Space ID */
1167
1168             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiUtGetRegionName (*Target));
1169             break;
1170
1171         case ACPI_DMT_ACCWIDTH:
1172
1173             /* Encoded Access Width */
1174
1175             Temp8 = *Target;
1176             if (Temp8 > ACPI_GAS_WIDTH_RESERVED)
1177             {
1178                 Temp8 = ACPI_GAS_WIDTH_RESERVED;
1179             }
1180
1181             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmGasAccessWidth[Temp8]);
1182             break;
1183
1184         case ACPI_DMT_GAS:
1185
1186             /* Generic Address Structure */
1187
1188             AcpiOsPrintf (STRING_FORMAT, "Generic Address Structure");
1189             AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1190                 sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas);
1191             AcpiOsPrintf ("\n");
1192             LastOutputBlankLine = TRUE;
1193             break;
1194
1195         case ACPI_DMT_ASF:
1196
1197             /* ASF subtable types */
1198
1199             Temp16 = (UINT16) ((*Target) & 0x7F);  /* Top bit can be zero or one */
1200             if (Temp16 > ACPI_ASF_TYPE_RESERVED)
1201             {
1202                 Temp16 = ACPI_ASF_TYPE_RESERVED;
1203             }
1204
1205             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmAsfSubnames[Temp16]);
1206             break;
1207
1208         case ACPI_DMT_DMAR:
1209
1210             /* DMAR subtable types */
1211
1212             Temp16 = ACPI_GET16 (Target);
1213             if (Temp16 > ACPI_DMAR_TYPE_RESERVED)
1214             {
1215                 Temp16 = ACPI_DMAR_TYPE_RESERVED;
1216             }
1217
1218             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1219                 AcpiDmDmarSubnames[Temp16]);
1220             break;
1221
1222         case ACPI_DMT_DMAR_SCOPE:
1223
1224             /* DMAR device scope types */
1225
1226             Temp8 = *Target;
1227             if (Temp8 > ACPI_DMAR_SCOPE_TYPE_RESERVED)
1228             {
1229                 Temp8 = ACPI_DMAR_SCOPE_TYPE_RESERVED;
1230             }
1231
1232             AcpiOsPrintf (UINT8_FORMAT, *Target,
1233                 AcpiDmDmarScope[Temp8]);
1234             break;
1235
1236         case ACPI_DMT_EINJACT:
1237
1238             /* EINJ Action types */
1239
1240             Temp8 = *Target;
1241             if (Temp8 > ACPI_EINJ_ACTION_RESERVED)
1242             {
1243                 Temp8 = ACPI_EINJ_ACTION_RESERVED;
1244             }
1245
1246             AcpiOsPrintf (UINT8_FORMAT, *Target,
1247                 AcpiDmEinjActions[Temp8]);
1248             break;
1249
1250         case ACPI_DMT_EINJINST:
1251
1252             /* EINJ Instruction types */
1253
1254             Temp8 = *Target;
1255             if (Temp8 > ACPI_EINJ_INSTRUCTION_RESERVED)
1256             {
1257                 Temp8 = ACPI_EINJ_INSTRUCTION_RESERVED;
1258             }
1259
1260             AcpiOsPrintf (UINT8_FORMAT, *Target,
1261                 AcpiDmEinjInstructions[Temp8]);
1262             break;
1263
1264         case ACPI_DMT_ERSTACT:
1265
1266             /* ERST Action types */
1267
1268             Temp8 = *Target;
1269             if (Temp8 > ACPI_ERST_ACTION_RESERVED)
1270             {
1271                 Temp8 = ACPI_ERST_ACTION_RESERVED;
1272             }
1273
1274             AcpiOsPrintf (UINT8_FORMAT, *Target,
1275                 AcpiDmErstActions[Temp8]);
1276             break;
1277
1278         case ACPI_DMT_ERSTINST:
1279
1280             /* ERST Instruction types */
1281
1282             Temp8 = *Target;
1283             if (Temp8 > ACPI_ERST_INSTRUCTION_RESERVED)
1284             {
1285                 Temp8 = ACPI_ERST_INSTRUCTION_RESERVED;
1286             }
1287
1288             AcpiOsPrintf (UINT8_FORMAT, *Target,
1289                 AcpiDmErstInstructions[Temp8]);
1290             break;
1291
1292         case ACPI_DMT_GTDT:
1293
1294             /* GTDT subtable types */
1295
1296             Temp8 = *Target;
1297             if (Temp8 > ACPI_GTDT_TYPE_RESERVED)
1298             {
1299                 Temp8 = ACPI_GTDT_TYPE_RESERVED;
1300             }
1301
1302             AcpiOsPrintf (UINT8_FORMAT, *Target,
1303                 AcpiDmGtdtSubnames[Temp8]);
1304             break;
1305
1306         case ACPI_DMT_HEST:
1307
1308             /* HEST subtable types */
1309
1310             Temp16 = ACPI_GET16 (Target);
1311             if (Temp16 > ACPI_HEST_TYPE_RESERVED)
1312             {
1313                 Temp16 = ACPI_HEST_TYPE_RESERVED;
1314             }
1315
1316             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1317                 AcpiDmHestSubnames[Temp16]);
1318             break;
1319
1320         case ACPI_DMT_HESTNTFY:
1321
1322             AcpiOsPrintf (STRING_FORMAT,
1323                 "Hardware Error Notification Structure");
1324
1325             AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1326                 sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify);
1327             AcpiOsPrintf ("\n");
1328             LastOutputBlankLine = TRUE;
1329             break;
1330
1331         case ACPI_DMT_HESTNTYP:
1332
1333             /* HEST Notify types */
1334
1335             Temp8 = *Target;
1336             if (Temp8 > ACPI_HEST_NOTIFY_RESERVED)
1337             {
1338                 Temp8 = ACPI_HEST_NOTIFY_RESERVED;
1339             }
1340
1341             AcpiOsPrintf (UINT8_FORMAT, *Target,
1342                 AcpiDmHestNotifySubnames[Temp8]);
1343             break;
1344
1345         case ACPI_DMT_IORTMEM:
1346
1347             AcpiOsPrintf (STRING_FORMAT,
1348                 "IORT Memory Access Properties");
1349
1350             AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1351                 sizeof (ACPI_IORT_MEMORY_ACCESS), AcpiDmTableInfoIortAcc);
1352             LastOutputBlankLine = TRUE;
1353             break;
1354
1355         case ACPI_DMT_MADT:
1356
1357             /* MADT subtable types */
1358
1359             Temp8 = *Target;
1360             if (Temp8 > ACPI_MADT_TYPE_RESERVED)
1361             {
1362                 Temp8 = ACPI_MADT_TYPE_RESERVED;
1363             }
1364
1365             AcpiOsPrintf (UINT8_FORMAT, *Target,
1366                 AcpiDmMadtSubnames[Temp8]);
1367             break;
1368
1369         case ACPI_DMT_NFIT:
1370
1371             /* NFIT subtable types */
1372
1373             Temp16 = ACPI_GET16 (Target);
1374             if (Temp16 > ACPI_NFIT_TYPE_RESERVED)
1375             {
1376                 Temp16 = ACPI_NFIT_TYPE_RESERVED;
1377             }
1378
1379             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1380                 AcpiDmNfitSubnames[Temp16]);
1381             break;
1382
1383         case ACPI_DMT_PCCT:
1384
1385             /* PCCT subtable types */
1386
1387             Temp8 = *Target;
1388             if (Temp8 > ACPI_PCCT_TYPE_RESERVED)
1389             {
1390                 Temp8 = ACPI_PCCT_TYPE_RESERVED;
1391             }
1392
1393             AcpiOsPrintf (UINT8_FORMAT, *Target,
1394                 AcpiDmPcctSubnames[Temp8]);
1395             break;
1396
1397         case ACPI_DMT_PMTT:
1398
1399             /* PMTT subtable types */
1400
1401             Temp8 = *Target;
1402             if (Temp8 > ACPI_PMTT_TYPE_RESERVED)
1403             {
1404                 Temp8 = ACPI_PMTT_TYPE_RESERVED;
1405             }
1406
1407             AcpiOsPrintf (UINT8_FORMAT, *Target,
1408                 AcpiDmPmttSubnames[Temp8]);
1409             break;
1410
1411         case ACPI_DMT_UNICODE:
1412
1413             if (ByteLength == 0)
1414             {
1415                 AcpiOsPrintf ("/* Zero-length Data */\n");
1416                 break;
1417             }
1418
1419             AcpiDmDumpUnicode (Table, CurrentOffset, ByteLength);
1420             break;
1421
1422         case ACPI_DMT_RAW_BUFFER:
1423
1424             if (ByteLength == 0)
1425             {
1426                 AcpiOsPrintf ("/* Zero-length Data */\n");
1427                 break;
1428             }
1429
1430             AcpiDmDumpBuffer (Table, CurrentOffset, ByteLength,
1431                 CurrentOffset, NULL);
1432             break;
1433
1434         case ACPI_DMT_SRAT:
1435
1436             /* SRAT subtable types */
1437
1438             Temp8 = *Target;
1439             if (Temp8 > ACPI_SRAT_TYPE_RESERVED)
1440             {
1441                 Temp8 = ACPI_SRAT_TYPE_RESERVED;
1442             }
1443
1444             AcpiOsPrintf (UINT8_FORMAT, *Target,
1445                 AcpiDmSratSubnames[Temp8]);
1446             break;
1447
1448         case ACPI_DMT_FADTPM:
1449
1450             /* FADT Preferred PM Profile names */
1451
1452             Temp8 = *Target;
1453             if (Temp8 > ACPI_FADT_PM_RESERVED)
1454             {
1455                 Temp8 = ACPI_FADT_PM_RESERVED;
1456             }
1457
1458             AcpiOsPrintf (UINT8_FORMAT, *Target,
1459                 AcpiDmFadtProfiles[Temp8]);
1460             break;
1461
1462         case ACPI_DMT_IVRS:
1463
1464             /* IVRS subtable types */
1465
1466             Temp8 = *Target;
1467             switch (Temp8)
1468             {
1469             case ACPI_IVRS_TYPE_HARDWARE:
1470
1471                 Name = AcpiDmIvrsSubnames[0];
1472                 break;
1473
1474             case ACPI_IVRS_TYPE_MEMORY1:
1475             case ACPI_IVRS_TYPE_MEMORY2:
1476             case ACPI_IVRS_TYPE_MEMORY3:
1477
1478                 Name = AcpiDmIvrsSubnames[1];
1479                 break;
1480
1481             default:
1482
1483                 Name = AcpiDmIvrsSubnames[2];
1484                 break;
1485             }
1486
1487             AcpiOsPrintf (UINT8_FORMAT, *Target, Name);
1488             break;
1489
1490         case ACPI_DMT_LPIT:
1491
1492             /* LPIT subtable types */
1493
1494             Temp32 = ACPI_GET32 (Target);
1495             if (Temp32 > ACPI_LPIT_TYPE_RESERVED)
1496             {
1497                 Temp32 = ACPI_LPIT_TYPE_RESERVED;
1498             }
1499
1500             AcpiOsPrintf (UINT32_FORMAT, ACPI_GET32 (Target),
1501                 AcpiDmLpitSubnames[Temp32]);
1502             break;
1503
1504         case ACPI_DMT_EXIT:
1505
1506             return (AE_OK);
1507
1508         default:
1509
1510             ACPI_ERROR ((AE_INFO,
1511                 "**** Invalid table opcode [0x%X] ****\n", Info->Opcode));
1512             return (AE_SUPPORT);
1513         }
1514     }
1515
1516     if (TableOffset && !SubtableLength)
1517     {
1518         /*
1519          * If this table is not the main table, the subtable must have a
1520          * valid length
1521          */
1522         AcpiOsPrintf ("Invalid zero length subtable\n");
1523         return (AE_BAD_DATA);
1524     }
1525
1526     return (AE_OK);
1527 }
1528
1529
1530 /*******************************************************************************
1531  *
1532  * FUNCTION:    AcpiDmCheckAscii
1533  *
1534  * PARAMETERS:  Name                - Ascii string
1535  *              Count               - Number of characters to check
1536  *
1537  * RETURN:      None
1538  *
1539  * DESCRIPTION: Ensure that the requested number of characters are printable
1540  *              Ascii characters. Sets non-printable and null chars to <space>.
1541  *
1542  ******************************************************************************/
1543
1544 static void
1545 AcpiDmCheckAscii (
1546     UINT8                   *Name,
1547     char                    *RepairedName,
1548     UINT32                  Count)
1549 {
1550     UINT32                  i;
1551
1552
1553     for (i = 0; i < Count; i++)
1554     {
1555         RepairedName[i] = (char) Name[i];
1556
1557         if (!Name[i])
1558         {
1559             return;
1560         }
1561         if (!isprint (Name[i]))
1562         {
1563             RepairedName[i] = ' ';
1564         }
1565     }
1566 }