Sync ACPICA with Intel's version 20160212.
[dragonfly.git] / sys / contrib / dev / acpica / source / common / dmtable.c
1 /******************************************************************************
2  *
3  * Module Name: dmtable - Support for ACPI tables that contain no AML code
4  *
5  *****************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2016, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43
44 #include "acpi.h"
45 #include "accommon.h"
46 #include "acdisasm.h"
47 #include "actables.h"
48 #include "aslcompiler.h"
49 #include "dtcompiler.h"
50
51 /* This module used for application-level code only */
52
53 #define _COMPONENT          ACPI_CA_DISASSEMBLER
54         ACPI_MODULE_NAME    ("dmtable")
55
56 const AH_TABLE *
57 AcpiAhGetTableInfo (
58     char                    *Signature);
59
60
61 /* Local Prototypes */
62
63 static void
64 AcpiDmCheckAscii (
65     UINT8                   *Target,
66     char                    *RepairedName,
67     UINT32                  Count);
68
69
70 /* Common format strings for commented values */
71
72 #define UINT8_FORMAT        "%2.2X [%s]\n"
73 #define UINT16_FORMAT       "%4.4X [%s]\n"
74 #define UINT32_FORMAT       "%8.8X [%s]\n"
75 #define STRING_FORMAT       "[%s]\n"
76
77 /* These tables map a subtable type to a description string */
78
79 static const char           *AcpiDmAsfSubnames[] =
80 {
81     "ASF Information",
82     "ASF Alerts",
83     "ASF Remote Control",
84     "ASF RMCP Boot Options",
85     "ASF Address",
86     "Unknown Subtable Type"         /* Reserved */
87 };
88
89 static const char           *AcpiDmDmarSubnames[] =
90 {
91     "Hardware Unit Definition",
92     "Reserved Memory Region",
93     "Root Port ATS Capability",
94     "Remapping Hardware Static Affinity",
95     "ACPI Namespace Device Declaration",
96     "Unknown Subtable Type"         /* Reserved */
97 };
98
99 static const char           *AcpiDmDmarScope[] =
100 {
101     "Reserved value",
102     "PCI Endpoint Device",
103     "PCI Bridge Device",
104     "IOAPIC Device",
105     "Message-capable HPET Device",
106     "Namespace Device",
107     "Unknown Scope Type"            /* Reserved */
108 };
109
110 static const char           *AcpiDmEinjActions[] =
111 {
112     "Begin Operation",
113     "Get Trigger Table",
114     "Set Error Type",
115     "Get Error Type",
116     "End Operation",
117     "Execute Operation",
118     "Check Busy Status",
119     "Get Command Status",
120     "Set Error Type With Address",
121     "Unknown Action"
122 };
123
124 static const char           *AcpiDmEinjInstructions[] =
125 {
126     "Read Register",
127     "Read Register Value",
128     "Write Register",
129     "Write Register Value",
130     "Noop",
131     "Flush Cacheline",
132     "Unknown Instruction"
133 };
134
135 static const char           *AcpiDmErstActions[] =
136 {
137     "Begin Write Operation",
138     "Begin Read Operation",
139     "Begin Clear Operation",
140     "End Operation",
141     "Set Record Offset",
142     "Execute Operation",
143     "Check Busy Status",
144     "Get Command Status",
145     "Get Record Identifier",
146     "Set Record Identifier",
147     "Get Record Count",
148     "Begin Dummy Write",
149     "Unused/Unknown Action",
150     "Get Error Address Range",
151     "Get Error Address Length",
152     "Get Error Attributes",
153     "Unknown Action"
154 };
155
156 static const char           *AcpiDmErstInstructions[] =
157 {
158     "Read Register",
159     "Read Register Value",
160     "Write Register",
161     "Write Register Value",
162     "Noop",
163     "Load Var1",
164     "Load Var2",
165     "Store Var1",
166     "Add",
167     "Subtract",
168     "Add Value",
169     "Subtract Value",
170     "Stall",
171     "Stall While True",
172     "Skip Next If True",
173     "GoTo",
174     "Set Source Address",
175     "Set Destination Address",
176     "Move Data",
177     "Unknown Instruction"
178 };
179
180 static const char           *AcpiDmGtdtSubnames[] =
181 {
182     "Generic Timer Block",
183     "Generic Watchdog Timer",
184     "Unknown Subtable Type"         /* Reserved */
185 };
186
187 static const char           *AcpiDmHestSubnames[] =
188 {
189     "IA-32 Machine Check Exception",
190     "IA-32 Corrected Machine Check",
191     "IA-32 Non-Maskable Interrupt",
192     "Unknown SubTable Type",        /* 3 - Reserved */
193     "Unknown SubTable Type",        /* 4 - Reserved */
194     "Unknown SubTable Type",        /* 5 - Reserved */
195     "PCI Express Root Port AER",
196     "PCI Express AER (AER Endpoint)",
197     "PCI Express/PCI-X Bridge AER",
198     "Generic Hardware Error Source",
199     "Generic Hardware Error Source V2",
200     "Unknown Subtable Type"         /* Reserved */
201 };
202
203 static const char           *AcpiDmHestNotifySubnames[] =
204 {
205     "Polled",
206     "External Interrupt",
207     "Local Interrupt",
208     "SCI",
209     "NMI",
210     "CMCI",                         /* ACPI 5.0 */
211     "MCE",                          /* ACPI 5.0 */
212     "Unknown Notify Type"           /* Reserved */
213 };
214
215 static const char           *AcpiDmMadtSubnames[] =
216 {
217     "Processor Local APIC",             /* ACPI_MADT_TYPE_LOCAL_APIC */
218     "I/O APIC",                         /* ACPI_MADT_TYPE_IO_APIC */
219     "Interrupt Source Override",        /* ACPI_MADT_TYPE_INTERRUPT_OVERRIDE */
220     "NMI Source",                       /* ACPI_MADT_TYPE_NMI_SOURCE */
221     "Local APIC NMI",                   /* ACPI_MADT_TYPE_LOCAL_APIC_NMI */
222     "Local APIC Address Override",      /* ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE */
223     "I/O SAPIC",                        /* ACPI_MADT_TYPE_IO_SAPIC */
224     "Local SAPIC",                      /* ACPI_MADT_TYPE_LOCAL_SAPIC */
225     "Platform Interrupt Sources",       /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */
226     "Processor Local x2APIC",           /* ACPI_MADT_TYPE_LOCAL_X2APIC */
227     "Local x2APIC NMI",                 /* ACPI_MADT_TYPE_LOCAL_X2APIC_NMI */
228     "Generic Interrupt Controller",     /* ACPI_MADT_GENERIC_INTERRUPT */
229     "Generic Interrupt Distributor",    /* ACPI_MADT_GENERIC_DISTRIBUTOR */
230     "Generic MSI Frame",                /* ACPI_MADT_GENERIC_MSI_FRAME */
231     "Generic Interrupt Redistributor",  /* ACPI_MADT_GENERIC_REDISTRIBUTOR */
232     "Generic Interrupt Translator",     /* ACPI_MADT_GENERIC_TRANSLATOR */
233     "Unknown Subtable Type"             /* Reserved */
234 };
235
236 static const char           *AcpiDmNfitSubnames[] =
237 {
238     "System Physical Address Range",    /* ACPI_NFIT_TYPE_SYSTEM_ADDRESS */
239     "Memory Range Map",                 /* ACPI_NFIT_TYPE_MEMORY_MAP */
240     "Interleave Info",                  /* ACPI_NFIT_TYPE_INTERLEAVE */
241     "SMBIOS Information",               /* ACPI_NFIT_TYPE_SMBIOS */
242     "NVDIMM Control Region",            /* ACPI_NFIT_TYPE_CONTROL_REGION */
243     "NVDIMM Block Data Window Region",  /* ACPI_NFIT_TYPE_DATA_REGION */
244     "Flush Hint Address",               /* ACPI_NFIT_TYPE_FLUSH_ADDRESS */
245     "Unknown Subtable Type"             /* Reserved */
246 };
247
248 static const char           *AcpiDmPcctSubnames[] =
249 {
250     "Generic Communications Subspace",  /* ACPI_PCCT_TYPE_GENERIC_SUBSPACE */
251     "HW-Reduced Comm Subspace",         /* ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE */
252     "Unknown Subtable Type"             /* Reserved */
253 };
254
255 static const char           *AcpiDmPmttSubnames[] =
256 {
257     "Socket",                       /* ACPI_PMTT_TYPE_SOCKET */
258     "Memory Controller",            /* ACPI_PMTT_TYPE_CONTROLLER */
259     "Physical Component (DIMM)",    /* ACPI_PMTT_TYPE_DIMM  */
260     "Unknown Subtable Type"         /* Reserved */
261 };
262
263 static const char           *AcpiDmSratSubnames[] =
264 {
265     "Processor Local APIC/SAPIC Affinity",
266     "Memory Affinity",
267     "Processor Local x2APIC Affinity",
268     "GICC Affinity",
269     "Unknown Subtable Type"         /* Reserved */
270 };
271
272 static const char           *AcpiDmIvrsSubnames[] =
273 {
274     "Hardware Definition Block",
275     "Memory Definition Block",
276     "Unknown Subtable Type"         /* Reserved */
277 };
278
279 static const char           *AcpiDmLpitSubnames[] =
280 {
281     "Native C-state Idle Structure",
282     "Unknown Subtable Type"         /* Reserved */
283 };
284
285 #define ACPI_FADT_PM_RESERVED       9
286
287 static const char           *AcpiDmFadtProfiles[] =
288 {
289     "Unspecified",
290     "Desktop",
291     "Mobile",
292     "Workstation",
293     "Enterprise Server",
294     "SOHO Server",
295     "Appliance PC",
296     "Performance Server",
297     "Tablet",
298     "Unknown Profile Type"
299 };
300
301 #define ACPI_GAS_WIDTH_RESERVED     5
302
303 static const char           *AcpiDmGasAccessWidth[] =
304 {
305     "Undefined/Legacy",
306     "Byte Access:8",
307     "Word Access:16",
308     "DWord Access:32",
309     "QWord Access:64",
310     "Unknown Width Encoding"
311 };
312
313
314 /*******************************************************************************
315  *
316  * ACPI Table Data, indexed by signature.
317  *
318  * Each entry contains: Signature, Table Info, Handler, DtHandler,
319  *  Template, Description
320  *
321  * Simple tables have only a TableInfo structure, complex tables have a
322  * handler. This table must be NULL terminated. RSDP and FACS are
323  * special-cased elsewhere.
324  *
325  * Note: Any tables added here should be duplicated within AcpiSupportedTables
326  * in the file common/ahtable.c
327  *
328  ******************************************************************************/
329
330 const ACPI_DMTABLE_DATA     AcpiDmTableData[] =
331 {
332     {ACPI_SIG_ASF,  NULL,                   AcpiDmDumpAsf,  DtCompileAsf,   TemplateAsf},
333     {ACPI_SIG_BERT, AcpiDmTableInfoBert,    NULL,           NULL,           TemplateBert},
334     {ACPI_SIG_BGRT, AcpiDmTableInfoBgrt,    NULL,           NULL,           TemplateBgrt},
335     {ACPI_SIG_BOOT, AcpiDmTableInfoBoot,    NULL,           NULL,           TemplateBoot},
336     {ACPI_SIG_CPEP, NULL,                   AcpiDmDumpCpep, DtCompileCpep,  TemplateCpep},
337     {ACPI_SIG_CSRT, NULL,                   AcpiDmDumpCsrt, DtCompileCsrt,  TemplateCsrt},
338     {ACPI_SIG_DBG2, AcpiDmTableInfoDbg2,    AcpiDmDumpDbg2, DtCompileDbg2,  TemplateDbg2},
339     {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp,    NULL,           NULL,           TemplateDbgp},
340     {ACPI_SIG_DMAR, NULL,                   AcpiDmDumpDmar, DtCompileDmar,  TemplateDmar},
341     {ACPI_SIG_DRTM, NULL,                   AcpiDmDumpDrtm, DtCompileDrtm,  TemplateDrtm},
342     {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt,    NULL,           NULL,           TemplateEcdt},
343     {ACPI_SIG_EINJ, NULL,                   AcpiDmDumpEinj, DtCompileEinj,  TemplateEinj},
344     {ACPI_SIG_ERST, NULL,                   AcpiDmDumpErst, DtCompileErst,  TemplateErst},
345     {ACPI_SIG_FADT, NULL,                   AcpiDmDumpFadt, DtCompileFadt,  TemplateFadt},
346     {ACPI_SIG_FPDT, NULL,                   AcpiDmDumpFpdt, DtCompileFpdt,  TemplateFpdt},
347     {ACPI_SIG_GTDT, NULL,                   AcpiDmDumpGtdt, DtCompileGtdt,  TemplateGtdt},
348     {ACPI_SIG_HEST, NULL,                   AcpiDmDumpHest, DtCompileHest,  TemplateHest},
349     {ACPI_SIG_HPET, AcpiDmTableInfoHpet,    NULL,           NULL,           TemplateHpet},
350     {ACPI_SIG_IORT, NULL,                   AcpiDmDumpIort, DtCompileIort,  TemplateIort},
351     {ACPI_SIG_IVRS, NULL,                   AcpiDmDumpIvrs, DtCompileIvrs,  TemplateIvrs},
352     {ACPI_SIG_LPIT, NULL,                   AcpiDmDumpLpit, DtCompileLpit,  TemplateLpit},
353     {ACPI_SIG_MADT, NULL,                   AcpiDmDumpMadt, DtCompileMadt,  TemplateMadt},
354     {ACPI_SIG_MCFG, NULL,                   AcpiDmDumpMcfg, DtCompileMcfg,  TemplateMcfg},
355     {ACPI_SIG_MCHI, AcpiDmTableInfoMchi,    NULL,           NULL,           TemplateMchi},
356     {ACPI_SIG_MPST, AcpiDmTableInfoMpst,    AcpiDmDumpMpst, DtCompileMpst,  TemplateMpst},
357     {ACPI_SIG_MSCT, NULL,                   AcpiDmDumpMsct, DtCompileMsct,  TemplateMsct},
358     {ACPI_SIG_MSDM, NULL,                   AcpiDmDumpSlic, DtCompileSlic,  TemplateMsdm},
359     {ACPI_SIG_MTMR, NULL,                   AcpiDmDumpMtmr, DtCompileMtmr,  TemplateMtmr},
360     {ACPI_SIG_NFIT, AcpiDmTableInfoNfit,    AcpiDmDumpNfit, DtCompileNfit,  TemplateNfit},
361     {ACPI_SIG_PCCT, AcpiDmTableInfoPcct,    AcpiDmDumpPcct, DtCompilePcct,  TemplatePcct},
362     {ACPI_SIG_PMTT, NULL,                   AcpiDmDumpPmtt, DtCompilePmtt,  TemplatePmtt},
363     {ACPI_SIG_RSDT, NULL,                   AcpiDmDumpRsdt, DtCompileRsdt,  TemplateRsdt},
364     {ACPI_SIG_S3PT, NULL,                   NULL,           NULL,           TemplateS3pt},
365     {ACPI_SIG_SBST, AcpiDmTableInfoSbst,    NULL,           NULL,           TemplateSbst},
366     {ACPI_SIG_SLIC, NULL,                   AcpiDmDumpSlic, DtCompileSlic,  TemplateSlic},
367     {ACPI_SIG_SLIT, NULL,                   AcpiDmDumpSlit, DtCompileSlit,  TemplateSlit},
368     {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr,    NULL,           NULL,           TemplateSpcr},
369     {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi,    NULL,           NULL,           TemplateSpmi},
370     {ACPI_SIG_SRAT, NULL,                   AcpiDmDumpSrat, DtCompileSrat,  TemplateSrat},
371     {ACPI_SIG_STAO, NULL,                   AcpiDmDumpStao, DtCompileStao,  TemplateStao},
372     {ACPI_SIG_TCPA, NULL,                   AcpiDmDumpTcpa, DtCompileTcpa,  TemplateTcpa},
373     {ACPI_SIG_TPM2, AcpiDmTableInfoTpm2,    NULL,           NULL,           TemplateTpm2},
374     {ACPI_SIG_UEFI, AcpiDmTableInfoUefi,    NULL,           DtCompileUefi,  TemplateUefi},
375     {ACPI_SIG_VRTC, AcpiDmTableInfoVrtc,    AcpiDmDumpVrtc, DtCompileVrtc,  TemplateVrtc},
376     {ACPI_SIG_WAET, AcpiDmTableInfoWaet,    NULL,           NULL,           TemplateWaet},
377     {ACPI_SIG_WDAT, NULL,                   AcpiDmDumpWdat, DtCompileWdat,  TemplateWdat},
378     {ACPI_SIG_WDDT, AcpiDmTableInfoWddt,    NULL,           NULL,           TemplateWddt},
379     {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt,    NULL,           NULL,           TemplateWdrt},
380     {ACPI_SIG_WPBT, NULL,                   AcpiDmDumpWpbt, DtCompileWpbt,  TemplateWpbt},
381     {ACPI_SIG_XENV, AcpiDmTableInfoXenv,    NULL,           NULL,           TemplateXenv},
382     {ACPI_SIG_XSDT, NULL,                   AcpiDmDumpXsdt, DtCompileXsdt,  TemplateXsdt},
383     {NULL,          NULL,                   NULL,           NULL,           NULL}
384 };
385
386
387 /*******************************************************************************
388  *
389  * FUNCTION:    AcpiDmGenerateChecksum
390  *
391  * PARAMETERS:  Table               - Pointer to table to be checksummed
392  *              Length              - Length of the table
393  *              OriginalChecksum    - Value of the checksum field
394  *
395  * RETURN:      8 bit checksum of buffer
396  *
397  * DESCRIPTION: Computes an 8 bit checksum of the table.
398  *
399  ******************************************************************************/
400
401 UINT8
402 AcpiDmGenerateChecksum (
403     void                    *Table,
404     UINT32                  Length,
405     UINT8                   OriginalChecksum)
406 {
407     UINT8                   Checksum;
408
409
410     /* Sum the entire table as-is */
411
412     Checksum = AcpiTbChecksum ((UINT8 *) Table, Length);
413
414     /* Subtract off the existing checksum value in the table */
415
416     Checksum = (UINT8) (Checksum - OriginalChecksum);
417
418     /* Compute the final checksum */
419
420     Checksum = (UINT8) (0 - Checksum);
421     return (Checksum);
422 }
423
424
425 /*******************************************************************************
426  *
427  * FUNCTION:    AcpiDmGetTableData
428  *
429  * PARAMETERS:  Signature           - ACPI signature (4 chars) to match
430  *
431  * RETURN:      Pointer to a valid ACPI_DMTABLE_DATA. Null if no match found.
432  *
433  * DESCRIPTION: Find a match in the global table of supported ACPI tables
434  *
435  ******************************************************************************/
436
437 const ACPI_DMTABLE_DATA *
438 AcpiDmGetTableData (
439     char                    *Signature)
440 {
441     const ACPI_DMTABLE_DATA *Info;
442
443
444     for (Info = AcpiDmTableData; Info->Signature; Info++)
445     {
446         if (ACPI_COMPARE_NAME (Signature, Info->Signature))
447         {
448             return (Info);
449         }
450     }
451
452     return (NULL);
453 }
454
455
456 /*******************************************************************************
457  *
458  * FUNCTION:    AcpiDmDumpDataTable
459  *
460  * PARAMETERS:  Table               - An ACPI table
461  *
462  * RETURN:      None.
463  *
464  * DESCRIPTION: Format the contents of an ACPI data table (any table other
465  *              than an SSDT or DSDT that does not contain executable AML code)
466  *
467  ******************************************************************************/
468
469 void
470 AcpiDmDumpDataTable (
471     ACPI_TABLE_HEADER       *Table)
472 {
473     ACPI_STATUS             Status;
474     const ACPI_DMTABLE_DATA *TableData;
475     UINT32                  Length;
476
477
478     /* Ignore tables that contain AML */
479
480     if (AcpiUtIsAmlTable (Table))
481     {
482         if (Gbl_VerboseTemplates)
483         {
484             /* Dump the raw table data */
485
486             Length = Table->Length;
487
488             AcpiOsPrintf ("\n/*\n%s: Length %d (0x%X)\n\n",
489                 ACPI_RAW_TABLE_DATA_HEADER, Length, Length);
490             AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table),
491                 Length, DB_BYTE_DISPLAY, 0);
492             AcpiOsPrintf (" */\n");
493         }
494         return;
495     }
496
497     /*
498      * Handle tables that don't use the common ACPI table header structure.
499      * Currently, these are the FACS, RSDP, and S3PT.
500      */
501     if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS))
502     {
503         Length = Table->Length;
504         Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFacs);
505         if (ACPI_FAILURE (Status))
506         {
507             return;
508         }
509     }
510     else if (ACPI_VALIDATE_RSDP_SIG (Table->Signature))
511     {
512         Length = AcpiDmDumpRsdp (Table);
513     }
514     else if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_S3PT))
515     {
516         Length = AcpiDmDumpS3pt (Table);
517     }
518     else
519     {
520         /*
521          * All other tables must use the common ACPI table header, dump it now
522          */
523         Length = Table->Length;
524         Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHeader);
525         if (ACPI_FAILURE (Status))
526         {
527             return;
528         }
529         AcpiOsPrintf ("\n");
530
531         /* Match signature and dispatch appropriately */
532
533         TableData = AcpiDmGetTableData (Table->Signature);
534         if (!TableData)
535         {
536             if (!strncmp (Table->Signature, "OEM", 3))
537             {
538                 AcpiOsPrintf ("\n**** OEM-defined ACPI table [%4.4s], unknown contents\n\n",
539                     Table->Signature);
540             }
541             else
542             {
543                 AcpiOsPrintf ("\n**** Unknown ACPI table signature [%4.4s]\n\n",
544                     Table->Signature);
545
546                 fprintf (stderr, "Unknown ACPI table signature [%4.4s], ",
547                     Table->Signature);
548
549                 if (!AcpiGbl_ForceAmlDisassembly)
550                 {
551                     fprintf (stderr, "decoding ACPI table header only\n");
552                 }
553                 else
554                 {
555                     fprintf (stderr, "assuming table contains valid AML code\n");
556                 }
557             }
558         }
559         else if (TableData->TableHandler)
560         {
561             /* Complex table, has a handler */
562
563             TableData->TableHandler (Table);
564         }
565         else if (TableData->TableInfo)
566         {
567             /* Simple table, just walk the info table */
568
569             Status = AcpiDmDumpTable (Length, 0, Table, 0, TableData->TableInfo);
570             if (ACPI_FAILURE (Status))
571             {
572                 return;
573             }
574         }
575     }
576
577     if (!Gbl_DoTemplates || Gbl_VerboseTemplates)
578     {
579         /* Dump the raw table data */
580
581         AcpiOsPrintf ("\n%s: Length %d (0x%X)\n\n",
582             ACPI_RAW_TABLE_DATA_HEADER, Length, Length);
583         AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table),
584             Length, DB_BYTE_DISPLAY, 0);
585     }
586 }
587
588
589 /*******************************************************************************
590  *
591  * FUNCTION:    AcpiDmLineHeader
592  *
593  * PARAMETERS:  Offset              - Current byte offset, from table start
594  *              ByteLength          - Length of the field in bytes, 0 for flags
595  *              Name                - Name of this field
596  *
597  * RETURN:      None
598  *
599  * DESCRIPTION: Utility routines for formatting output lines. Displays the
600  *              current table offset in hex and decimal, the field length,
601  *              and the field name.
602  *
603  ******************************************************************************/
604
605 void
606 AcpiDmLineHeader (
607     UINT32                  Offset,
608     UINT32                  ByteLength,
609     char                    *Name)
610 {
611
612     /* Allow a null name for fields that span multiple lines (large buffers) */
613
614     if (!Name)
615     {
616         Name = "";
617     }
618
619     if (Gbl_DoTemplates && !Gbl_VerboseTemplates) /* Terse template */
620     {
621         if (ByteLength)
622         {
623             AcpiOsPrintf ("[%.4d] %34s : ", ByteLength, Name);
624         }
625         else
626         {
627             if (*Name)
628             {
629                 AcpiOsPrintf ("%41s : ", Name);
630             }
631             else
632             {
633                 AcpiOsPrintf ("%41s   ", Name);
634             }
635         }
636     }
637     else /* Normal disassembler or verbose template */
638     {
639         if (ByteLength)
640         {
641             AcpiOsPrintf ("[%3.3Xh %4.4d% 4d] %28s : ",
642                 Offset, Offset, ByteLength, Name);
643         }
644         else
645         {
646             if (*Name)
647             {
648                 AcpiOsPrintf ("%44s : ", Name);
649             }
650             else
651             {
652                 AcpiOsPrintf ("%44s   ", Name);
653             }
654         }
655     }
656 }
657
658 void
659 AcpiDmLineHeader2 (
660     UINT32                  Offset,
661     UINT32                  ByteLength,
662     char                    *Name,
663     UINT32                  Value)
664 {
665
666     if (Gbl_DoTemplates && !Gbl_VerboseTemplates) /* Terse template */
667     {
668         if (ByteLength)
669         {
670             AcpiOsPrintf ("[%.4d] %30s %3d : ",
671                 ByteLength, Name, Value);
672         }
673         else
674         {
675             AcpiOsPrintf ("%36s % 3d : ",
676                 Name, Value);
677         }
678     }
679     else /* Normal disassembler or verbose template */
680     {
681         if (ByteLength)
682         {
683             AcpiOsPrintf ("[%3.3Xh %4.4d %3d] %24s %3d : ",
684                 Offset, Offset, ByteLength, Name, Value);
685         }
686         else
687         {
688             AcpiOsPrintf ("[%3.3Xh %4.4d   ] %24s %3d : ",
689                 Offset, Offset, Name, Value);
690         }
691     }
692 }
693
694
695 /*******************************************************************************
696  *
697  * FUNCTION:    AcpiDmDumpTable
698  *
699  * PARAMETERS:  TableLength         - Length of the entire ACPI table
700  *              TableOffset         - Starting offset within the table for this
701  *                                    sub-descriptor (0 if main table)
702  *              Table               - The ACPI table
703  *              SubtableLength      - Length of this sub-descriptor
704  *              Info                - Info table for this ACPI table
705  *
706  * RETURN:      Status
707  *
708  * DESCRIPTION: Display ACPI table contents by walking the Info table.
709  *
710  * Note: This function must remain in sync with DtGetFieldLength.
711  *
712  ******************************************************************************/
713
714 ACPI_STATUS
715 AcpiDmDumpTable (
716     UINT32                  TableLength,
717     UINT32                  TableOffset,
718     void                    *Table,
719     UINT32                  SubtableLength,
720     ACPI_DMTABLE_INFO       *Info)
721 {
722     UINT8                   *Target;
723     UINT32                  CurrentOffset;
724     UINT32                  ByteLength;
725     UINT8                   Temp8;
726     UINT16                  Temp16;
727     UINT32                  Temp32;
728     UINT64                  Value;
729     const AH_TABLE          *TableData;
730     const char              *Name;
731     BOOLEAN                 LastOutputBlankLine = FALSE;
732     ACPI_STATUS             Status;
733     char                    RepairedName[8];
734
735
736     if (!Info)
737     {
738         AcpiOsPrintf ("Display not implemented\n");
739         return (AE_NOT_IMPLEMENTED);
740     }
741
742     /* Walk entire Info table; Null name terminates */
743
744     for (; Info->Name; Info++)
745     {
746         /*
747          * Target points to the field within the ACPI Table. CurrentOffset is
748          * the offset of the field from the start of the main table.
749          */
750         Target = ACPI_ADD_PTR (UINT8, Table, Info->Offset);
751         CurrentOffset = TableOffset + Info->Offset;
752
753         /* Check for beyond subtable end or (worse) beyond EOT */
754
755         if (SubtableLength && (Info->Offset >= SubtableLength))
756         {
757             AcpiOsPrintf (
758                 "/**** ACPI subtable terminates early - "
759                 "may be older version (dump table) */\n");
760
761             /* Move on to next subtable */
762
763             return (AE_OK);
764         }
765
766         if (CurrentOffset >= TableLength)
767         {
768             AcpiOsPrintf (
769                 "/**** ACPI table terminates "
770                 "in the middle of a data structure! (dump table) */\n");
771             return (AE_BAD_DATA);
772         }
773
774         /* Generate the byte length for this field */
775
776         switch (Info->Opcode)
777         {
778         case ACPI_DMT_UINT8:
779         case ACPI_DMT_CHKSUM:
780         case ACPI_DMT_SPACEID:
781         case ACPI_DMT_ACCWIDTH:
782         case ACPI_DMT_IVRS:
783         case ACPI_DMT_GTDT:
784         case ACPI_DMT_MADT:
785         case ACPI_DMT_PCCT:
786         case ACPI_DMT_PMTT:
787         case ACPI_DMT_SRAT:
788         case ACPI_DMT_ASF:
789         case ACPI_DMT_HESTNTYP:
790         case ACPI_DMT_FADTPM:
791         case ACPI_DMT_EINJACT:
792         case ACPI_DMT_EINJINST:
793         case ACPI_DMT_ERSTACT:
794         case ACPI_DMT_ERSTINST:
795         case ACPI_DMT_DMAR_SCOPE:
796
797             ByteLength = 1;
798             break;
799
800         case ACPI_DMT_UINT16:
801         case ACPI_DMT_DMAR:
802         case ACPI_DMT_HEST:
803         case ACPI_DMT_NFIT:
804
805             ByteLength = 2;
806             break;
807
808         case ACPI_DMT_UINT24:
809
810             ByteLength = 3;
811             break;
812
813         case ACPI_DMT_UINT32:
814         case ACPI_DMT_NAME4:
815         case ACPI_DMT_SIG:
816         case ACPI_DMT_LPIT:
817
818             ByteLength = 4;
819             break;
820
821         case ACPI_DMT_UINT40:
822
823             ByteLength = 5;
824             break;
825
826         case ACPI_DMT_UINT48:
827         case ACPI_DMT_NAME6:
828
829             ByteLength = 6;
830             break;
831
832         case ACPI_DMT_UINT56:
833         case ACPI_DMT_BUF7:
834
835             ByteLength = 7;
836             break;
837
838         case ACPI_DMT_UINT64:
839         case ACPI_DMT_NAME8:
840
841             ByteLength = 8;
842             break;
843
844         case ACPI_DMT_BUF10:
845
846             ByteLength = 10;
847             break;
848
849         case ACPI_DMT_BUF16:
850         case ACPI_DMT_UUID:
851
852             ByteLength = 16;
853             break;
854
855         case ACPI_DMT_BUF128:
856
857             ByteLength = 128;
858             break;
859
860         case ACPI_DMT_UNICODE:
861         case ACPI_DMT_BUFFER:
862         case ACPI_DMT_RAW_BUFFER:
863
864             ByteLength = SubtableLength;
865             break;
866
867         case ACPI_DMT_STRING:
868
869             ByteLength = strlen (ACPI_CAST_PTR (char, Target)) + 1;
870             break;
871
872         case ACPI_DMT_GAS:
873
874             if (!LastOutputBlankLine)
875             {
876                 AcpiOsPrintf ("\n");
877                 LastOutputBlankLine = TRUE;
878             }
879
880             ByteLength = sizeof (ACPI_GENERIC_ADDRESS);
881             break;
882
883         case ACPI_DMT_HESTNTFY:
884
885             if (!LastOutputBlankLine)
886             {
887                 AcpiOsPrintf ("\n");
888                 LastOutputBlankLine = TRUE;
889             }
890
891             ByteLength = sizeof (ACPI_HEST_NOTIFY);
892             break;
893
894         case ACPI_DMT_IORTMEM:
895
896             if (!LastOutputBlankLine)
897             {
898                 LastOutputBlankLine = FALSE;
899             }
900
901             ByteLength = sizeof (ACPI_IORT_MEMORY_ACCESS);
902             break;
903
904         default:
905
906             ByteLength = 0;
907             break;
908         }
909
910         /* Check if we are beyond a subtable, or (worse) beyond EOT */
911
912         if (CurrentOffset + ByteLength > TableLength)
913         {
914             if (SubtableLength)
915             {
916                 AcpiOsPrintf (
917                     "/**** ACPI subtable terminates early - "
918                     "may be older version (dump table) */\n");
919
920                 /* Move on to next subtable */
921
922                 return (AE_OK);
923             }
924
925             AcpiOsPrintf (
926                 "/**** ACPI table terminates "
927                 "in the middle of a data structure! */\n");
928             return (AE_BAD_DATA);
929         }
930
931         if (Info->Opcode == ACPI_DMT_EXTRA_TEXT)
932         {
933             AcpiOsPrintf ("%s", Info->Name);
934             continue;
935         }
936
937         /* Start a new line and decode the opcode */
938
939         AcpiDmLineHeader (CurrentOffset, ByteLength, Info->Name);
940
941         switch (Info->Opcode)
942         {
943         /* Single-bit Flag fields. Note: Opcode is the bit position */
944
945         case ACPI_DMT_FLAG0:
946         case ACPI_DMT_FLAG1:
947         case ACPI_DMT_FLAG2:
948         case ACPI_DMT_FLAG3:
949         case ACPI_DMT_FLAG4:
950         case ACPI_DMT_FLAG5:
951         case ACPI_DMT_FLAG6:
952         case ACPI_DMT_FLAG7:
953
954             AcpiOsPrintf ("%1.1X\n", (*Target >> Info->Opcode) & 0x01);
955             break;
956
957         /* 2-bit Flag fields */
958
959         case ACPI_DMT_FLAGS0:
960
961             AcpiOsPrintf ("%1.1X\n", *Target & 0x03);
962             break;
963
964         case ACPI_DMT_FLAGS1:
965
966             AcpiOsPrintf ("%1.1X\n", (*Target >> 1) & 0x03);
967             break;
968
969         case ACPI_DMT_FLAGS2:
970
971             AcpiOsPrintf ("%1.1X\n", (*Target >> 2) & 0x03);
972             break;
973
974         case ACPI_DMT_FLAGS4:
975
976             AcpiOsPrintf ("%1.1X\n", (*Target >> 4) & 0x03);
977             break;
978
979         /* Integer Data Types */
980
981         case ACPI_DMT_UINT8:
982         case ACPI_DMT_UINT16:
983         case ACPI_DMT_UINT24:
984         case ACPI_DMT_UINT32:
985         case ACPI_DMT_UINT40:
986         case ACPI_DMT_UINT48:
987         case ACPI_DMT_UINT56:
988         case ACPI_DMT_UINT64:
989             /*
990              * Dump bytes - high byte first, low byte last.
991              * Note: All ACPI tables are little-endian.
992              */
993             Value = 0;
994             for (Temp8 = (UINT8) ByteLength; Temp8 > 0; Temp8--)
995             {
996                 AcpiOsPrintf ("%2.2X", Target[Temp8 - 1]);
997                 Value |= Target[Temp8 - 1];
998                 Value <<= 8;
999             }
1000
1001             if (!Value && (Info->Flags & DT_DESCRIBES_OPTIONAL))
1002             {
1003                 AcpiOsPrintf (" [Optional field not present]");
1004             }
1005
1006             AcpiOsPrintf ("\n");
1007             break;
1008
1009         case ACPI_DMT_BUF7:
1010         case ACPI_DMT_BUF10:
1011         case ACPI_DMT_BUF16:
1012         case ACPI_DMT_BUF128:
1013             /*
1014              * Buffer: Size depends on the opcode and was set above.
1015              * Each hex byte is separated with a space.
1016              * Multiple lines are separated by line continuation char.
1017              */
1018             for (Temp16 = 0; Temp16 < ByteLength; Temp16++)
1019             {
1020                 AcpiOsPrintf ("%2.2X", Target[Temp16]);
1021                 if ((UINT32) (Temp16 + 1) < ByteLength)
1022                 {
1023                     if ((Temp16 > 0) && (!((Temp16+1) % 16)))
1024                     {
1025                         AcpiOsPrintf (" \\\n"); /* Line continuation */
1026                         AcpiDmLineHeader (0, 0, NULL);
1027                     }
1028                     else
1029                     {
1030                         AcpiOsPrintf (" ");
1031                     }
1032                 }
1033             }
1034
1035             AcpiOsPrintf ("\n");
1036             break;
1037
1038         case ACPI_DMT_UUID:
1039
1040             /* Convert 16-byte UUID buffer to 36-byte formatted UUID string */
1041
1042             (void) AuConvertUuidToString ((char *) Target, MsgBuffer);
1043
1044             AcpiOsPrintf ("%s\n", MsgBuffer);
1045             break;
1046
1047         case ACPI_DMT_STRING:
1048
1049             AcpiOsPrintf ("\"%s\"\n", ACPI_CAST_PTR (char, Target));
1050             break;
1051
1052         /* Fixed length ASCII name fields */
1053
1054         case ACPI_DMT_SIG:
1055
1056             AcpiDmCheckAscii (Target, RepairedName, 4);
1057             AcpiOsPrintf ("\"%.4s\"    ", RepairedName);
1058
1059             TableData = AcpiAhGetTableInfo (ACPI_CAST_PTR (char, Target));
1060             if (TableData)
1061             {
1062                 AcpiOsPrintf (STRING_FORMAT, TableData->Description);
1063             }
1064             else
1065             {
1066                 AcpiOsPrintf ("\n");
1067             }
1068             break;
1069
1070         case ACPI_DMT_NAME4:
1071
1072             AcpiDmCheckAscii (Target, RepairedName, 4);
1073             AcpiOsPrintf ("\"%.4s\"\n", RepairedName);
1074             break;
1075
1076         case ACPI_DMT_NAME6:
1077
1078             AcpiDmCheckAscii (Target, RepairedName, 6);
1079             AcpiOsPrintf ("\"%.6s\"\n", RepairedName);
1080             break;
1081
1082         case ACPI_DMT_NAME8:
1083
1084             AcpiDmCheckAscii (Target, RepairedName, 8);
1085             AcpiOsPrintf ("\"%.8s\"\n", RepairedName);
1086             break;
1087
1088         /* Special Data Types */
1089
1090         case ACPI_DMT_CHKSUM:
1091
1092             /* Checksum, display and validate */
1093
1094             AcpiOsPrintf ("%2.2X", *Target);
1095             Temp8 = AcpiDmGenerateChecksum (Table,
1096                 ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length,
1097                 ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum);
1098
1099             if (Temp8 != ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum)
1100             {
1101                 AcpiOsPrintf (
1102                     "     /* Incorrect checksum, should be %2.2X */", Temp8);
1103             }
1104
1105             AcpiOsPrintf ("\n");
1106             break;
1107
1108         case ACPI_DMT_SPACEID:
1109
1110             /* Address Space ID */
1111
1112             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiUtGetRegionName (*Target));
1113             break;
1114
1115         case ACPI_DMT_ACCWIDTH:
1116
1117             /* Encoded Access Width */
1118
1119             Temp8 = *Target;
1120             if (Temp8 > ACPI_GAS_WIDTH_RESERVED)
1121             {
1122                 Temp8 = ACPI_GAS_WIDTH_RESERVED;
1123             }
1124
1125             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmGasAccessWidth[Temp8]);
1126             break;
1127
1128         case ACPI_DMT_GAS:
1129
1130             /* Generic Address Structure */
1131
1132             AcpiOsPrintf (STRING_FORMAT, "Generic Address Structure");
1133             Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1134                 sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas);
1135             if (ACPI_FAILURE (Status))
1136             {
1137                 return (Status);
1138             }
1139
1140             AcpiOsPrintf ("\n");
1141             LastOutputBlankLine = TRUE;
1142             break;
1143
1144         case ACPI_DMT_ASF:
1145
1146             /* ASF subtable types */
1147
1148             Temp16 = (UINT16) ((*Target) & 0x7F);  /* Top bit can be zero or one */
1149             if (Temp16 > ACPI_ASF_TYPE_RESERVED)
1150             {
1151                 Temp16 = ACPI_ASF_TYPE_RESERVED;
1152             }
1153
1154             AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmAsfSubnames[Temp16]);
1155             break;
1156
1157         case ACPI_DMT_DMAR:
1158
1159             /* DMAR subtable types */
1160
1161             Temp16 = ACPI_GET16 (Target);
1162             if (Temp16 > ACPI_DMAR_TYPE_RESERVED)
1163             {
1164                 Temp16 = ACPI_DMAR_TYPE_RESERVED;
1165             }
1166
1167             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1168                 AcpiDmDmarSubnames[Temp16]);
1169             break;
1170
1171         case ACPI_DMT_DMAR_SCOPE:
1172
1173             /* DMAR device scope types */
1174
1175             Temp8 = *Target;
1176             if (Temp8 > ACPI_DMAR_SCOPE_TYPE_RESERVED)
1177             {
1178                 Temp8 = ACPI_DMAR_SCOPE_TYPE_RESERVED;
1179             }
1180
1181             AcpiOsPrintf (UINT8_FORMAT, *Target,
1182                 AcpiDmDmarScope[Temp8]);
1183             break;
1184
1185         case ACPI_DMT_EINJACT:
1186
1187             /* EINJ Action types */
1188
1189             Temp8 = *Target;
1190             if (Temp8 > ACPI_EINJ_ACTION_RESERVED)
1191             {
1192                 Temp8 = ACPI_EINJ_ACTION_RESERVED;
1193             }
1194
1195             AcpiOsPrintf (UINT8_FORMAT, *Target,
1196                 AcpiDmEinjActions[Temp8]);
1197             break;
1198
1199         case ACPI_DMT_EINJINST:
1200
1201             /* EINJ Instruction types */
1202
1203             Temp8 = *Target;
1204             if (Temp8 > ACPI_EINJ_INSTRUCTION_RESERVED)
1205             {
1206                 Temp8 = ACPI_EINJ_INSTRUCTION_RESERVED;
1207             }
1208
1209             AcpiOsPrintf (UINT8_FORMAT, *Target,
1210                 AcpiDmEinjInstructions[Temp8]);
1211             break;
1212
1213         case ACPI_DMT_ERSTACT:
1214
1215             /* ERST Action types */
1216
1217             Temp8 = *Target;
1218             if (Temp8 > ACPI_ERST_ACTION_RESERVED)
1219             {
1220                 Temp8 = ACPI_ERST_ACTION_RESERVED;
1221             }
1222
1223             AcpiOsPrintf (UINT8_FORMAT, *Target,
1224                 AcpiDmErstActions[Temp8]);
1225             break;
1226
1227         case ACPI_DMT_ERSTINST:
1228
1229             /* ERST Instruction types */
1230
1231             Temp8 = *Target;
1232             if (Temp8 > ACPI_ERST_INSTRUCTION_RESERVED)
1233             {
1234                 Temp8 = ACPI_ERST_INSTRUCTION_RESERVED;
1235             }
1236
1237             AcpiOsPrintf (UINT8_FORMAT, *Target,
1238                 AcpiDmErstInstructions[Temp8]);
1239             break;
1240
1241         case ACPI_DMT_GTDT:
1242
1243             /* GTDT subtable types */
1244
1245             Temp8 = *Target;
1246             if (Temp8 > ACPI_GTDT_TYPE_RESERVED)
1247             {
1248                 Temp8 = ACPI_GTDT_TYPE_RESERVED;
1249             }
1250
1251             AcpiOsPrintf (UINT8_FORMAT, *Target,
1252                 AcpiDmGtdtSubnames[Temp8]);
1253             break;
1254
1255         case ACPI_DMT_HEST:
1256
1257             /* HEST subtable types */
1258
1259             Temp16 = ACPI_GET16 (Target);
1260             if (Temp16 > ACPI_HEST_TYPE_RESERVED)
1261             {
1262                 Temp16 = ACPI_HEST_TYPE_RESERVED;
1263             }
1264
1265             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1266                 AcpiDmHestSubnames[Temp16]);
1267             break;
1268
1269         case ACPI_DMT_HESTNTFY:
1270
1271             AcpiOsPrintf (STRING_FORMAT,
1272                 "Hardware Error Notification Structure");
1273
1274             Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1275                 sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify);
1276             if (ACPI_FAILURE (Status))
1277             {
1278                 return (Status);
1279             }
1280
1281             AcpiOsPrintf ("\n");
1282             LastOutputBlankLine = TRUE;
1283             break;
1284
1285         case ACPI_DMT_HESTNTYP:
1286
1287             /* HEST Notify types */
1288
1289             Temp8 = *Target;
1290             if (Temp8 > ACPI_HEST_NOTIFY_RESERVED)
1291             {
1292                 Temp8 = ACPI_HEST_NOTIFY_RESERVED;
1293             }
1294
1295             AcpiOsPrintf (UINT8_FORMAT, *Target,
1296                 AcpiDmHestNotifySubnames[Temp8]);
1297             break;
1298
1299         case ACPI_DMT_IORTMEM:
1300
1301             AcpiOsPrintf (STRING_FORMAT,
1302                 "IORT Memory Access Properties");
1303
1304             Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
1305                 sizeof (ACPI_IORT_MEMORY_ACCESS), AcpiDmTableInfoIortAcc);
1306             if (ACPI_FAILURE (Status))
1307             {
1308                 return (Status);
1309             }
1310
1311             LastOutputBlankLine = TRUE;
1312             break;
1313
1314         case ACPI_DMT_MADT:
1315
1316             /* MADT subtable types */
1317
1318             Temp8 = *Target;
1319             if (Temp8 > ACPI_MADT_TYPE_RESERVED)
1320             {
1321                 Temp8 = ACPI_MADT_TYPE_RESERVED;
1322             }
1323
1324             AcpiOsPrintf (UINT8_FORMAT, *Target,
1325                 AcpiDmMadtSubnames[Temp8]);
1326             break;
1327
1328         case ACPI_DMT_NFIT:
1329
1330             /* NFIT subtable types */
1331
1332             Temp16 = ACPI_GET16 (Target);
1333             if (Temp16 > ACPI_NFIT_TYPE_RESERVED)
1334             {
1335                 Temp16 = ACPI_NFIT_TYPE_RESERVED;
1336             }
1337
1338             AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
1339                 AcpiDmNfitSubnames[Temp16]);
1340             break;
1341
1342         case ACPI_DMT_PCCT:
1343
1344             /* PCCT subtable types */
1345
1346             Temp8 = *Target;
1347             if (Temp8 > ACPI_PCCT_TYPE_RESERVED)
1348             {
1349                 Temp8 = ACPI_PCCT_TYPE_RESERVED;
1350             }
1351
1352             AcpiOsPrintf (UINT8_FORMAT, *Target,
1353                 AcpiDmPcctSubnames[Temp8]);
1354             break;
1355
1356         case ACPI_DMT_PMTT:
1357
1358             /* PMTT subtable types */
1359
1360             Temp8 = *Target;
1361             if (Temp8 > ACPI_PMTT_TYPE_RESERVED)
1362             {
1363                 Temp8 = ACPI_PMTT_TYPE_RESERVED;
1364             }
1365
1366             AcpiOsPrintf (UINT8_FORMAT, *Target,
1367                 AcpiDmPmttSubnames[Temp8]);
1368             break;
1369
1370         case ACPI_DMT_UNICODE:
1371
1372             if (ByteLength == 0)
1373             {
1374                 AcpiOsPrintf ("/* Zero-length Data */\n");
1375                 break;
1376             }
1377
1378             AcpiDmDumpUnicode (Table, CurrentOffset, ByteLength);
1379             break;
1380
1381         case ACPI_DMT_RAW_BUFFER:
1382
1383             if (ByteLength == 0)
1384             {
1385                 AcpiOsPrintf ("/* Zero-length Data */\n");
1386                 break;
1387             }
1388
1389             AcpiDmDumpBuffer (Table, CurrentOffset, ByteLength,
1390                 CurrentOffset, NULL);
1391             break;
1392
1393         case ACPI_DMT_SRAT:
1394
1395             /* SRAT subtable types */
1396
1397             Temp8 = *Target;
1398             if (Temp8 > ACPI_SRAT_TYPE_RESERVED)
1399             {
1400                 Temp8 = ACPI_SRAT_TYPE_RESERVED;
1401             }
1402
1403             AcpiOsPrintf (UINT8_FORMAT, *Target,
1404                 AcpiDmSratSubnames[Temp8]);
1405             break;
1406
1407         case ACPI_DMT_FADTPM:
1408
1409             /* FADT Preferred PM Profile names */
1410
1411             Temp8 = *Target;
1412             if (Temp8 > ACPI_FADT_PM_RESERVED)
1413             {
1414                 Temp8 = ACPI_FADT_PM_RESERVED;
1415             }
1416
1417             AcpiOsPrintf (UINT8_FORMAT, *Target,
1418                 AcpiDmFadtProfiles[Temp8]);
1419             break;
1420
1421         case ACPI_DMT_IVRS:
1422
1423             /* IVRS subtable types */
1424
1425             Temp8 = *Target;
1426             switch (Temp8)
1427             {
1428             case ACPI_IVRS_TYPE_HARDWARE:
1429
1430                 Name = AcpiDmIvrsSubnames[0];
1431                 break;
1432
1433             case ACPI_IVRS_TYPE_MEMORY1:
1434             case ACPI_IVRS_TYPE_MEMORY2:
1435             case ACPI_IVRS_TYPE_MEMORY3:
1436
1437                 Name = AcpiDmIvrsSubnames[1];
1438                 break;
1439
1440             default:
1441
1442                 Name = AcpiDmIvrsSubnames[2];
1443                 break;
1444             }
1445
1446             AcpiOsPrintf (UINT8_FORMAT, *Target, Name);
1447             break;
1448
1449         case ACPI_DMT_LPIT:
1450
1451             /* LPIT subtable types */
1452
1453             Temp32 = ACPI_GET32 (Target);
1454             if (Temp32 > ACPI_LPIT_TYPE_RESERVED)
1455             {
1456                 Temp32 = ACPI_LPIT_TYPE_RESERVED;
1457             }
1458
1459             AcpiOsPrintf (UINT32_FORMAT, ACPI_GET32 (Target),
1460                 AcpiDmLpitSubnames[Temp32]);
1461             break;
1462
1463         case ACPI_DMT_EXIT:
1464
1465             return (AE_OK);
1466
1467         default:
1468
1469             ACPI_ERROR ((AE_INFO,
1470                 "**** Invalid table opcode [0x%X] ****\n", Info->Opcode));
1471             return (AE_SUPPORT);
1472         }
1473     }
1474
1475     if (TableOffset && !SubtableLength)
1476     {
1477         /*
1478          * If this table is not the main table, the subtable must have a
1479          * valid length
1480          */
1481         AcpiOsPrintf ("Invalid zero length subtable\n");
1482         return (AE_BAD_DATA);
1483     }
1484
1485     return (AE_OK);
1486 }
1487
1488
1489 /*******************************************************************************
1490  *
1491  * FUNCTION:    AcpiDmCheckAscii
1492  *
1493  * PARAMETERS:  Name                - Ascii string
1494  *              Count               - Number of characters to check
1495  *
1496  * RETURN:      None
1497  *
1498  * DESCRIPTION: Ensure that the requested number of characters are printable
1499  *              Ascii characters. Sets non-printable and null chars to <space>.
1500  *
1501  ******************************************************************************/
1502
1503 static void
1504 AcpiDmCheckAscii (
1505     UINT8                   *Name,
1506     char                    *RepairedName,
1507     UINT32                  Count)
1508 {
1509     UINT32                  i;
1510
1511
1512     for (i = 0; i < Count; i++)
1513     {
1514         RepairedName[i] = (char) Name[i];
1515
1516         if (!Name[i])
1517         {
1518             return;
1519         }
1520         if (!isprint (Name[i]))
1521         {
1522             RepairedName[i] = ' ';
1523         }
1524     }
1525 }