xref: /freebsd/sys/contrib/dev/acpica/common/dmtbdump1.c (revision 058ac3e8063366dafa634d9107642e12b038bf09)
1 /******************************************************************************
2  *
3  * Module Name: dmtbdump1 - Dump ACPI data 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 - 2022, 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  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
122  * 1. Redistributions of source code must retain the above copyright
123  *    notice, this list of conditions, and the following disclaimer,
124  *    without modification.
125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126  *    substantially similar to the "NO WARRANTY" disclaimer below
127  *    ("Disclaimer") and any redistribution must be conditioned upon
128  *    including a substantially similar Disclaimer requirement for further
129  *    binary redistribution.
130  * 3. Neither the names of the above-listed copyright holders nor the names
131  *    of any contributors may be used to endorse or promote products derived
132  *    from this software without specific prior written permission.
133  *
134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145  *
146  * Alternatively, you may choose to be licensed under the terms of the
147  * GNU General Public License ("GPL") version 2 as published by the Free
148  * Software Foundation.
149  *
150  *****************************************************************************/
151 
152 #include <contrib/dev/acpica/include/acpi.h>
153 #include <contrib/dev/acpica/include/accommon.h>
154 #include <contrib/dev/acpica/include/acdisasm.h>
155 #include <contrib/dev/acpica/include/actables.h>
156 #include <contrib/dev/acpica/compiler/aslcompiler.h>
157 
158 /* This module used for application-level code only */
159 
160 #define _COMPONENT          ACPI_CA_DISASSEMBLER
161         ACPI_MODULE_NAME    ("dmtbdump1")
162 
163 
164 /*******************************************************************************
165  *
166  * FUNCTION:    AcpiDmDumpAest
167  *
168  * PARAMETERS:  Table               - A AEST table
169  *
170  * RETURN:      None
171  *
172  * DESCRIPTION: Format the contents of a AEST table
173  *
174  * NOTE: Assumes the following table structure:
175  *      For all AEST Error Nodes:
176  *          1) An AEST Error Node, followed immediately by:
177  *          2) Any node-specific data
178  *          3) An Interface Structure (one)
179  *          4) A list (array) of Interrupt Structures
180  *
181  * AEST - ARM Error Source table. Conforms to:
182  * ACPI for the Armv8 RAS Extensions 1.1 Platform Design Document Sep 2020
183  *
184  ******************************************************************************/
185 
186 void
187 AcpiDmDumpAest (
188     ACPI_TABLE_HEADER       *Table)
189 {
190     ACPI_STATUS             Status;
191     UINT32                  Offset = sizeof (ACPI_TABLE_HEADER);
192     ACPI_AEST_HEADER        *Subtable;
193     ACPI_AEST_HEADER        *NodeHeader;
194     ACPI_AEST_PROCESSOR     *ProcessorSubtable;
195     ACPI_DMTABLE_INFO       *InfoTable;
196     ACPI_SIZE               Length;
197     UINT8                   Type;
198 
199 
200     /* Very small, generic main table. AEST consists of mostly subtables */
201 
202     while (Offset < Table->Length)
203     {
204         NodeHeader = ACPI_ADD_PTR (ACPI_AEST_HEADER, Table, Offset);
205 
206         /* Dump the common error node (subtable) header */
207 
208         Status = AcpiDmDumpTable (Table->Length, Offset, NodeHeader,
209             NodeHeader->Length, AcpiDmTableInfoAestHdr);
210         if (ACPI_FAILURE (Status))
211         {
212             return;
213         }
214 
215         Type = NodeHeader->Type;
216 
217         /* Setup the node-specific subtable based on the header Type field */
218 
219         switch (Type)
220         {
221         case ACPI_AEST_PROCESSOR_ERROR_NODE:
222             InfoTable = AcpiDmTableInfoAestProcError;
223             Length = sizeof (ACPI_AEST_PROCESSOR);
224             break;
225 
226         case ACPI_AEST_MEMORY_ERROR_NODE:
227             InfoTable = AcpiDmTableInfoAestMemError;
228             Length = sizeof (ACPI_AEST_MEMORY);
229             break;
230 
231         case ACPI_AEST_SMMU_ERROR_NODE:
232             InfoTable = AcpiDmTableInfoAestSmmuError;
233             Length = sizeof (ACPI_AEST_SMMU);
234             break;
235 
236         case ACPI_AEST_VENDOR_ERROR_NODE:
237             InfoTable = AcpiDmTableInfoAestVendorError;
238             Length = sizeof (ACPI_AEST_VENDOR);
239             break;
240 
241         case ACPI_AEST_GIC_ERROR_NODE:
242             InfoTable = AcpiDmTableInfoAestGicError;
243             Length = sizeof (ACPI_AEST_GIC);
244             break;
245 
246         /* Error case below */
247         default:
248 
249             AcpiOsPrintf ("\n**** Unknown AEST Error Subtable type 0x%X\n",
250                 Type);
251             return;
252         }
253 
254         /* Point past the common header (to the node-specific data) */
255 
256         Offset += sizeof (ACPI_AEST_HEADER);
257         Subtable = ACPI_ADD_PTR (ACPI_AEST_HEADER, Table, Offset);
258         AcpiOsPrintf ("\n");
259 
260         /* Dump the node-specific subtable */
261 
262         Status = AcpiDmDumpTable (Table->Length, Offset, Subtable, Length,
263             InfoTable);
264         if (ACPI_FAILURE (Status))
265         {
266             return;
267         }
268         AcpiOsPrintf ("\n");
269 
270         if (Type == ACPI_AEST_PROCESSOR_ERROR_NODE)
271         {
272             /*
273              * Special handling for PROCESSOR_ERROR_NODE subtables
274              * (to handle the Resource Substructure via the ResourceType
275              * field).
276              */
277 
278             /* Point past the node-specific data */
279 
280             Offset += Length;
281             ProcessorSubtable = ACPI_CAST_PTR (ACPI_AEST_PROCESSOR, Subtable);
282 
283             switch (ProcessorSubtable->ResourceType)
284             {
285             /* Setup the Resource Substructure subtable */
286 
287             case ACPI_AEST_CACHE_RESOURCE:
288                 InfoTable = AcpiDmTableInfoAestCacheRsrc;
289                 Length = sizeof (ACPI_AEST_PROCESSOR_CACHE);
290                 break;
291 
292             case ACPI_AEST_TLB_RESOURCE:
293                 InfoTable = AcpiDmTableInfoAestTlbRsrc;
294                 Length = sizeof (ACPI_AEST_PROCESSOR_TLB);
295                 break;
296 
297             case ACPI_AEST_GENERIC_RESOURCE:
298                 InfoTable = AcpiDmTableInfoAestGenRsrc;
299                 Length = sizeof (ACPI_AEST_PROCESSOR_GENERIC);
300                 break;
301 
302             /* Error case below */
303             default:
304                 AcpiOsPrintf ("\n**** Unknown AEST Processor Resource type 0x%X\n",
305                     ProcessorSubtable->ResourceType);
306                 return;
307             }
308 
309             ProcessorSubtable = ACPI_ADD_PTR (ACPI_AEST_PROCESSOR, Table,
310                 Offset);
311 
312             /* Dump the resource substructure subtable */
313 
314             Status = AcpiDmDumpTable (Table->Length, Offset, ProcessorSubtable,
315                 Length, InfoTable);
316             if (ACPI_FAILURE (Status))
317             {
318                 return;
319             }
320 
321             AcpiOsPrintf ("\n");
322         }
323 
324         /* Point past the resource substructure or the node-specific data */
325 
326         Offset += Length;
327 
328         /* Dump the interface structure, required to be present */
329 
330         Subtable = ACPI_ADD_PTR (ACPI_AEST_HEADER, Table, Offset);
331         if (Subtable->Type >= ACPI_AEST_XFACE_RESERVED)
332         {
333             AcpiOsPrintf ("\n**** Unknown AEST Node Interface type 0x%X\n",
334                 Subtable->Type);
335             return;
336         }
337 
338         Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
339             sizeof (ACPI_AEST_NODE_INTERFACE), AcpiDmTableInfoAestXface);
340         if (ACPI_FAILURE (Status))
341         {
342             return;
343         }
344 
345         /* Point past the interface structure */
346 
347         AcpiOsPrintf ("\n");
348         Offset += sizeof (ACPI_AEST_NODE_INTERFACE);
349 
350         /* Dump the entire interrupt structure array, if present */
351 
352         if (NodeHeader->NodeInterruptOffset)
353         {
354             Length = NodeHeader->NodeInterruptCount;
355             Subtable = ACPI_ADD_PTR (ACPI_AEST_HEADER, Table, Offset);
356 
357             while (Length)
358             {
359                 /* Dump the interrupt structure */
360 
361                 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
362                     sizeof (ACPI_AEST_NODE_INTERRUPT),
363                     AcpiDmTableInfoAestXrupt);
364                 if (ACPI_FAILURE (Status))
365                 {
366                     return;
367                 }
368 
369                 /* Point to the next interrupt structure */
370 
371                 Offset += sizeof (ACPI_AEST_NODE_INTERRUPT);
372                 Subtable = ACPI_ADD_PTR (ACPI_AEST_HEADER, Table, Offset);
373                 Length--;
374                 AcpiOsPrintf ("\n");
375             }
376         }
377     }
378 }
379 
380 /*******************************************************************************
381  *
382  * FUNCTION:    AcpiDmDumpApmt
383  *
384  * PARAMETERS:  Table               - A APMT table
385  *
386  * RETURN:      None
387  *
388  * DESCRIPTION: Format the contents of a APMT. This table type consists
389  *              of an open-ended number of subtables.
390  *
391  *
392  * APMT - ARM Performance Monitoring Unit table. Conforms to:
393  * ARM Performance Monitoring Unit Architecture 1.0 Platform Design Document
394  * ARM DEN0117 v1.0 November 25, 2021
395  *
396  ******************************************************************************/
397 
398 void
399 AcpiDmDumpApmt (
400     ACPI_TABLE_HEADER       *Table)
401 {
402     ACPI_STATUS              Status;
403     ACPI_APMT_NODE           *Subtable;
404     UINT32                   Length = Table->Length;
405     UINT32                   Offset = sizeof (ACPI_TABLE_APMT);
406     UINT32                   NodeNum = 0;
407 
408     /* There is no main table (other than the standard ACPI header) */
409 
410     /* Subtables */
411 
412     Subtable = ACPI_ADD_PTR (ACPI_APMT_NODE, Table, Offset);
413     while (Offset < Table->Length)
414     {
415         AcpiOsPrintf ("\n");
416 
417         if (Subtable->Type >= ACPI_APMT_NODE_TYPE_COUNT)
418         {
419             AcpiOsPrintf ("\n**** Unknown APMT subtable type 0x%X\n",
420                 Subtable->Type);
421             return;
422         }
423 
424         AcpiOsPrintf ("/* APMT Node-%u */\n", NodeNum++);
425 
426         Status = AcpiDmDumpTable (Length, Offset, Subtable,
427             Subtable->Length, AcpiDmTableInfoApmtNode);
428         if (ACPI_FAILURE (Status))
429         {
430             return;
431         }
432 
433         /* Point to next subtable */
434 
435         Offset += Subtable->Length;
436         Subtable = ACPI_ADD_PTR (ACPI_APMT_NODE, Subtable,
437             Subtable->Length);
438         AcpiOsPrintf ("\n");
439     }
440 }
441 
442 
443 /*******************************************************************************
444  *
445  * FUNCTION:    AcpiDmDumpAsf
446  *
447  * PARAMETERS:  Table               - A ASF table
448  *
449  * RETURN:      None
450  *
451  * DESCRIPTION: Format the contents of a ASF table
452  *
453  ******************************************************************************/
454 
455 void
456 AcpiDmDumpAsf (
457     ACPI_TABLE_HEADER       *Table)
458 {
459     ACPI_STATUS             Status;
460     UINT32                  Offset = sizeof (ACPI_TABLE_HEADER);
461     ACPI_ASF_INFO           *Subtable;
462     ACPI_DMTABLE_INFO       *InfoTable;
463     ACPI_DMTABLE_INFO       *DataInfoTable = NULL;
464     UINT8                   *DataTable = NULL;
465     UINT32                  DataCount = 0;
466     UINT32                  DataLength = 0;
467     UINT32                  DataOffset = 0;
468     UINT32                  i;
469     UINT8                   Type;
470 
471 
472     /* No main table, only subtables */
473 
474     Subtable = ACPI_ADD_PTR (ACPI_ASF_INFO, Table, Offset);
475     while (Offset < Table->Length)
476     {
477         /* Common subtable header */
478 
479         Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
480             Subtable->Header.Length, AcpiDmTableInfoAsfHdr);
481         if (ACPI_FAILURE (Status))
482         {
483             return;
484         }
485 
486         /* The actual type is the lower 7 bits of Type */
487 
488         Type = (UINT8) (Subtable->Header.Type & 0x7F);
489 
490         switch (Type)
491         {
492         case ACPI_ASF_TYPE_INFO:
493 
494             InfoTable = AcpiDmTableInfoAsf0;
495             break;
496 
497         case ACPI_ASF_TYPE_ALERT:
498 
499             InfoTable = AcpiDmTableInfoAsf1;
500             DataInfoTable = AcpiDmTableInfoAsf1a;
501             DataTable = ACPI_ADD_PTR (UINT8, Subtable, sizeof (ACPI_ASF_ALERT));
502             DataCount = ACPI_CAST_PTR (ACPI_ASF_ALERT, Subtable)->Alerts;
503             DataLength = ACPI_CAST_PTR (ACPI_ASF_ALERT, Subtable)->DataLength;
504             DataOffset = Offset + sizeof (ACPI_ASF_ALERT);
505             break;
506 
507         case ACPI_ASF_TYPE_CONTROL:
508 
509             InfoTable = AcpiDmTableInfoAsf2;
510             DataInfoTable = AcpiDmTableInfoAsf2a;
511             DataTable = ACPI_ADD_PTR (UINT8, Subtable, sizeof (ACPI_ASF_REMOTE));
512             DataCount = ACPI_CAST_PTR (ACPI_ASF_REMOTE, Subtable)->Controls;
513             DataLength = ACPI_CAST_PTR (ACPI_ASF_REMOTE, Subtable)->DataLength;
514             DataOffset = Offset + sizeof (ACPI_ASF_REMOTE);
515             break;
516 
517         case ACPI_ASF_TYPE_BOOT:
518 
519             InfoTable = AcpiDmTableInfoAsf3;
520             break;
521 
522         case ACPI_ASF_TYPE_ADDRESS:
523 
524             InfoTable = AcpiDmTableInfoAsf4;
525             DataTable = ACPI_ADD_PTR (UINT8, Subtable, sizeof (ACPI_ASF_ADDRESS));
526             DataLength = ACPI_CAST_PTR (ACPI_ASF_ADDRESS, Subtable)->Devices;
527             DataOffset = Offset + sizeof (ACPI_ASF_ADDRESS);
528             break;
529 
530         default:
531 
532             AcpiOsPrintf ("\n**** Unknown ASF subtable type 0x%X\n",
533                 Subtable->Header.Type);
534             return;
535         }
536 
537         Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
538             Subtable->Header.Length, InfoTable);
539         if (ACPI_FAILURE (Status))
540         {
541             return;
542         }
543 
544         /* Dump variable-length extra data */
545 
546         switch (Type)
547         {
548         case ACPI_ASF_TYPE_ALERT:
549         case ACPI_ASF_TYPE_CONTROL:
550 
551             for (i = 0; i < DataCount; i++)
552             {
553                 AcpiOsPrintf ("\n");
554                 Status = AcpiDmDumpTable (Table->Length, DataOffset,
555                     DataTable, DataLength, DataInfoTable);
556                 if (ACPI_FAILURE (Status))
557                 {
558                     return;
559                 }
560 
561                 DataTable = ACPI_ADD_PTR (UINT8, DataTable, DataLength);
562                 DataOffset += DataLength;
563             }
564             break;
565 
566         case ACPI_ASF_TYPE_ADDRESS:
567 
568             for (i = 0; i < DataLength; i++)
569             {
570                 if (!(i % 16))
571                 {
572                     AcpiDmLineHeader (DataOffset, 1, "Addresses");
573                 }
574 
575                 AcpiOsPrintf ("%2.2X ", *DataTable);
576                 DataTable++;
577                 DataOffset++;
578 
579                 if (DataOffset > Table->Length)
580                 {
581                     AcpiOsPrintf (
582                         "**** ACPI table terminates in the middle of a "
583                         "data structure! (ASF! table)\n");
584                     return;
585                 }
586             }
587 
588             AcpiOsPrintf ("\n");
589             break;
590 
591         default:
592 
593             break;
594         }
595 
596         AcpiOsPrintf ("\n");
597 
598         /* Point to next subtable */
599 
600         if (!Subtable->Header.Length)
601         {
602             AcpiOsPrintf ("Invalid zero subtable header length\n");
603             return;
604         }
605 
606         Offset += Subtable->Header.Length;
607         Subtable = ACPI_ADD_PTR (ACPI_ASF_INFO, Subtable,
608             Subtable->Header.Length);
609     }
610 }
611 
612 
613 /*******************************************************************************
614  *
615  * FUNCTION:    AcpiDmDumpCdat
616  *
617  * PARAMETERS:  InTable             - A CDAT table
618  *
619  * RETURN:      None
620  *
621  * DESCRIPTION: Format the contents of a CDAT. This table type consists
622  *              of an open-ended number of subtables.
623  *
624  ******************************************************************************/
625 
626 void
627 AcpiDmDumpCdat (
628     ACPI_TABLE_HEADER       *InTable)
629 {
630     ACPI_TABLE_CDAT         *Table = ACPI_CAST_PTR (ACPI_TABLE_CDAT, InTable);
631     ACPI_STATUS             Status;
632     ACPI_CDAT_HEADER        *Subtable;
633     ACPI_TABLE_CDAT         *CdatTable = ACPI_CAST_PTR (ACPI_TABLE_CDAT, Table);
634     ACPI_DMTABLE_INFO       *InfoTable;
635     UINT32                  Length = CdatTable->Length;
636     UINT32                  Offset = sizeof (ACPI_TABLE_CDAT);
637     UINT32                  SubtableLength;
638     UINT32                  SubtableType;
639     INT32                   EntriesLength;
640 
641 
642     /* Main table */
643 
644     Status = AcpiDmDumpTable (Offset, 0, CdatTable, 0,
645         AcpiDmTableInfoCdatTableHdr);
646     if (ACPI_FAILURE (Status))
647     {
648         return;
649     }
650 
651     Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, sizeof (ACPI_TABLE_CDAT));
652     while (Offset < Table->Length)
653     {
654         /* Dump the common subtable header */
655 
656         DbgPrint (ASL_DEBUG_OUTPUT, "0) HeaderOffset: %X\n", Offset);
657         AcpiOsPrintf ("\n");
658         Status = AcpiDmDumpTable (Length, Offset, Subtable,
659             sizeof (ACPI_CDAT_HEADER), AcpiDmTableInfoCdatHeader);
660         if (ACPI_FAILURE (Status))
661         {
662             return;
663         }
664 
665         /* Point past the common subtable header, decode the subtable type */
666 
667         Offset += sizeof (ACPI_CDAT_HEADER);
668         SubtableType = Subtable->Type;
669 
670         switch (Subtable->Type)
671         {
672         case ACPI_CDAT_TYPE_DSMAS:
673             Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
674             SubtableLength = sizeof (ACPI_CDAT_DSMAS);
675 
676             InfoTable = AcpiDmTableInfoCdat0;
677             break;
678 
679         case ACPI_CDAT_TYPE_DSLBIS:
680             Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
681             SubtableLength = sizeof (ACPI_CDAT_DSLBIS);
682             DbgPrint (ASL_DEBUG_OUTPUT, "1) Offset: %X\n", Offset);
683 
684             InfoTable = AcpiDmTableInfoCdat1;
685             break;
686 
687         case ACPI_CDAT_TYPE_DSMSCIS:
688             Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
689             SubtableLength = sizeof (ACPI_CDAT_DSMSCIS);
690 
691             InfoTable = AcpiDmTableInfoCdat2;
692             break;
693 
694         case ACPI_CDAT_TYPE_DSIS:
695             DbgPrint (ASL_DEBUG_OUTPUT, "2) Offset: %X ", Offset);
696             SubtableLength = sizeof (ACPI_CDAT_DSIS);
697             DbgPrint (ASL_DEBUG_OUTPUT, "1) input pointer: %p\n", Table);
698             Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
699             DbgPrint (ASL_DEBUG_OUTPUT, "1) output pointers: %p, %p, Offset: %X\n",
700                 Table, Subtable, Offset);
701             DbgPrint (ASL_DEBUG_OUTPUT, "3) Offset: %X\n", Offset);
702 
703             InfoTable = AcpiDmTableInfoCdat3;
704             break;
705 
706         case ACPI_CDAT_TYPE_DSEMTS:
707             Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
708             SubtableLength = sizeof (ACPI_CDAT_DSEMTS);
709 
710             InfoTable = AcpiDmTableInfoCdat4;
711             break;
712 
713         case ACPI_CDAT_TYPE_SSLBIS:
714             SubtableLength = Subtable->Length;
715 
716             InfoTable = AcpiDmTableInfoCdat5;
717             Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
718             break;
719 
720         default:
721             fprintf (stderr, "ERROR: Unknown SubtableType: %X\n", Subtable->Type);
722             return;
723         }
724 
725         DbgPrint (ASL_DEBUG_OUTPUT, "SubtableType: %X, Length: %X Actual "
726             "Length: %X Offset: %X tableptr: %p\n", SubtableType,
727             Subtable->Length, SubtableLength, Offset, Table);
728 
729         /*
730          * Do the subtable-specific fields
731          */
732         Status = AcpiDmDumpTable (Length, Offset, Subtable, Offset, InfoTable);
733         if (ACPI_FAILURE (Status))
734         {
735             return;
736         }
737 
738         DbgPrint (ASL_DEBUG_OUTPUT, "Subtable Type: %X, Offset: %X, SubtableLength: %X\n",
739             SubtableType, Offset, SubtableLength);
740 
741         /* Additional sub-subtables, dependent on the main subtable type */
742 
743         switch (SubtableType)
744         {
745         case ACPI_CDAT_TYPE_SSLBIS:
746             Offset += sizeof (ACPI_CDAT_SSLBIS);
747             Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table,
748                 Offset);
749 
750             DbgPrint (ASL_DEBUG_OUTPUT, "Case SSLBIS, Offset: %X, SubtableLength: %X "
751                 "Subtable->Length %X\n", Offset, SubtableLength, Subtable->Length);
752 
753             /* Generate the total length of all the SSLBE entries */
754 
755             EntriesLength = SubtableLength - sizeof (ACPI_CDAT_HEADER) -
756                 sizeof (ACPI_CDAT_SSLBIS);
757             DbgPrint (ASL_DEBUG_OUTPUT, "EntriesLength: %X, Offset: %X, Table->Length: %X\n",
758                 EntriesLength, Offset, Table->Length);
759 
760             /* Do each of the SSLBE Entries */
761 
762             while ((EntriesLength > 0) && (Offset < Table->Length))
763             {
764                 AcpiOsPrintf ("\n");
765 
766                 Status = AcpiDmDumpTable (Length, Offset, Subtable, Offset,
767                     AcpiDmTableInfoCdatEntries);
768                 if (ACPI_FAILURE (Status))
769                 {
770                     return;
771                 }
772 
773                 EntriesLength -= sizeof (ACPI_CDAT_SSLBE);
774                 Offset += sizeof (ACPI_CDAT_SSLBE);
775                 Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
776             }
777 
778             SubtableLength = 0;
779             break;
780 
781         default:
782             break;
783         }
784 
785         DbgPrint (ASL_DEBUG_OUTPUT, "Offset: %X, Subtable Length: %X\n",
786             Offset, SubtableLength);
787 
788         /* Point to next subtable */
789 
790         Offset += SubtableLength;
791         Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
792     }
793 
794     return;
795 }
796 
797 
798 /*******************************************************************************
799  *
800  * FUNCTION:    AcpiDmDumpCedt
801  *
802  * PARAMETERS:  Table               - A CEDT table
803  *
804  * RETURN:      None
805  *
806  * DESCRIPTION: Format the contents of a CEDT. This table type consists
807  *              of an open-ended number of subtables.
808  *
809  ******************************************************************************/
810 
811 void
812 AcpiDmDumpCedt (
813     ACPI_TABLE_HEADER       *Table)
814 {
815     ACPI_STATUS             Status;
816     ACPI_CEDT_HEADER        *Subtable;
817     UINT32                  Length = Table->Length;
818     UINT32                  Offset = sizeof (ACPI_TABLE_CEDT);
819 
820 
821     /* There is no main table (other than the standard ACPI header) */
822 
823     Subtable = ACPI_ADD_PTR (ACPI_CEDT_HEADER, Table, Offset);
824     while (Offset < Table->Length)
825     {
826         /* Common subtable header */
827 
828         AcpiOsPrintf ("\n");
829         Status = AcpiDmDumpTable (Length, Offset, Subtable,
830             Subtable->Length, AcpiDmTableInfoCedtHdr);
831         if (ACPI_FAILURE (Status))
832         {
833             return;
834         }
835 
836         switch (Subtable->Type)
837         {
838         case ACPI_CEDT_TYPE_CHBS:
839             Status = AcpiDmDumpTable (Length, Offset, Subtable,
840                 Subtable->Length, AcpiDmTableInfoCedt0);
841             if (ACPI_FAILURE (Status))
842             {
843                 return;
844             }
845             break;
846 
847         case ACPI_CEDT_TYPE_CFMWS:
848         {
849             ACPI_CEDT_CFMWS *ptr = (ACPI_CEDT_CFMWS *) Subtable;
850             unsigned int i, max = 0x01 << (ptr->InterleaveWays);
851 
852             /* print out table with first "Interleave target" */
853 
854             Status = AcpiDmDumpTable (Length, Offset, Subtable,
855                 Subtable->Length, AcpiDmTableInfoCedt1);
856             if (ACPI_FAILURE (Status))
857             {
858                 return;
859             }
860 
861             /* Now, print out any interleave targets beyond the first. */
862 
863             for (i = 1; i < max; i++)
864             {
865                 unsigned int loc_offset = Offset + (i * 4) + ACPI_OFFSET (ACPI_CEDT_CFMWS, InterleaveTargets);
866                 unsigned int *trg = &(ptr->InterleaveTargets[i]);
867 
868                 Status = AcpiDmDumpTable (Length, loc_offset, trg,
869                         Subtable->Length, AcpiDmTableInfoCedt1_te);
870                 if (ACPI_FAILURE (Status))
871                 {
872                     return;
873                 }
874             }
875             break;
876         }
877 
878         default:
879             AcpiOsPrintf ("\n**** Unknown CEDT subtable type 0x%X\n\n",
880                 Subtable->Type);
881 
882             /* Attempt to continue */
883             if (!Subtable->Length)
884             {
885                 AcpiOsPrintf ("Invalid zero length subtable\n");
886                 return;
887             }
888         }
889 
890         /* Point to next subtable */
891         Offset += Subtable->Length;
892         Subtable = ACPI_ADD_PTR (ACPI_CEDT_HEADER, Subtable,
893             Subtable->Length);
894     }
895 }
896 
897 /*******************************************************************************
898  *
899  * FUNCTION:    AcpiDmDumpCpep
900  *
901  * PARAMETERS:  Table               - A CPEP table
902  *
903  * RETURN:      None
904  *
905  * DESCRIPTION: Format the contents of a CPEP. This table type consists
906  *              of an open-ended number of subtables.
907  *
908  ******************************************************************************/
909 
910 void
911 AcpiDmDumpCpep (
912     ACPI_TABLE_HEADER       *Table)
913 {
914     ACPI_STATUS             Status;
915     ACPI_CPEP_POLLING       *Subtable;
916     UINT32                  Length = Table->Length;
917     UINT32                  Offset = sizeof (ACPI_TABLE_CPEP);
918 
919 
920     /* Main table */
921 
922     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoCpep);
923     if (ACPI_FAILURE (Status))
924     {
925         return;
926     }
927 
928     /* Subtables */
929 
930     Subtable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, Table, Offset);
931     while (Offset < Table->Length)
932     {
933         AcpiOsPrintf ("\n");
934         Status = AcpiDmDumpTable (Length, Offset, Subtable,
935             Subtable->Header.Length, AcpiDmTableInfoCpep0);
936         if (ACPI_FAILURE (Status))
937         {
938             return;
939         }
940 
941         /* Point to next subtable */
942 
943         Offset += Subtable->Header.Length;
944         Subtable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, Subtable,
945             Subtable->Header.Length);
946     }
947 }
948 
949 
950 /*******************************************************************************
951  *
952  * FUNCTION:    AcpiDmDumpCsrt
953  *
954  * PARAMETERS:  Table               - A CSRT table
955  *
956  * RETURN:      None
957  *
958  * DESCRIPTION: Format the contents of a CSRT. This table type consists
959  *              of an open-ended number of subtables.
960  *
961  ******************************************************************************/
962 
963 void
964 AcpiDmDumpCsrt (
965     ACPI_TABLE_HEADER       *Table)
966 {
967     ACPI_STATUS             Status;
968     ACPI_CSRT_GROUP         *Subtable;
969     ACPI_CSRT_SHARED_INFO   *SharedInfoTable;
970     ACPI_CSRT_DESCRIPTOR    *SubSubtable;
971     UINT32                  Length = Table->Length;
972     UINT32                  Offset = sizeof (ACPI_TABLE_CSRT);
973     UINT32                  SubOffset;
974     UINT32                  SubSubOffset;
975     UINT32                  InfoLength;
976 
977 
978     /* The main table only contains the ACPI header, thus already handled */
979 
980     /* Subtables (Resource Groups) */
981 
982     Subtable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, Table, Offset);
983     while (Offset < Table->Length)
984     {
985         /* Resource group subtable */
986 
987         AcpiOsPrintf ("\n");
988         Status = AcpiDmDumpTable (Length, Offset, Subtable,
989             Subtable->Length, AcpiDmTableInfoCsrt0);
990         if (ACPI_FAILURE (Status))
991         {
992             return;
993         }
994 
995         /* Shared info subtable (One per resource group) */
996 
997         SubOffset = sizeof (ACPI_CSRT_GROUP);
998         SharedInfoTable = ACPI_ADD_PTR (ACPI_CSRT_SHARED_INFO, Table,
999             Offset + SubOffset);
1000 
1001         AcpiOsPrintf ("\n");
1002         Status = AcpiDmDumpTable (Length, Offset + SubOffset, SharedInfoTable,
1003             sizeof (ACPI_CSRT_SHARED_INFO), AcpiDmTableInfoCsrt1);
1004         if (ACPI_FAILURE (Status))
1005         {
1006             return;
1007         }
1008 
1009         SubOffset += Subtable->SharedInfoLength;
1010 
1011         /* Sub-Subtables (Resource Descriptors) */
1012 
1013         SubSubtable = ACPI_ADD_PTR (ACPI_CSRT_DESCRIPTOR, Table,
1014             Offset + SubOffset);
1015 
1016         while ((SubOffset < Subtable->Length) &&
1017               ((Offset + SubOffset) < Table->Length))
1018         {
1019             AcpiOsPrintf ("\n");
1020             Status = AcpiDmDumpTable (Length, Offset + SubOffset, SubSubtable,
1021                 SubSubtable->Length, AcpiDmTableInfoCsrt2);
1022             if (ACPI_FAILURE (Status))
1023             {
1024                 return;
1025             }
1026 
1027             SubSubOffset = sizeof (ACPI_CSRT_DESCRIPTOR);
1028 
1029             /* Resource-specific info buffer */
1030 
1031             InfoLength = SubSubtable->Length - SubSubOffset;
1032             if (InfoLength)
1033             {
1034                 Status = AcpiDmDumpTable (Length,
1035                     Offset + SubOffset + SubSubOffset, Table,
1036                     InfoLength, AcpiDmTableInfoCsrt2a);
1037                 if (ACPI_FAILURE (Status))
1038                 {
1039                     return;
1040                 }
1041             }
1042 
1043             /* Point to next sub-subtable */
1044 
1045             SubOffset += SubSubtable->Length;
1046             SubSubtable = ACPI_ADD_PTR (ACPI_CSRT_DESCRIPTOR, SubSubtable,
1047                 SubSubtable->Length);
1048         }
1049 
1050         /* Point to next subtable */
1051 
1052         Offset += Subtable->Length;
1053         Subtable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, Subtable,
1054             Subtable->Length);
1055     }
1056 }
1057 
1058 
1059 /*******************************************************************************
1060  *
1061  * FUNCTION:    AcpiDmDumpDbg2
1062  *
1063  * PARAMETERS:  Table               - A DBG2 table
1064  *
1065  * RETURN:      None
1066  *
1067  * DESCRIPTION: Format the contents of a DBG2. This table type consists
1068  *              of an open-ended number of subtables.
1069  *
1070  ******************************************************************************/
1071 
1072 void
1073 AcpiDmDumpDbg2 (
1074     ACPI_TABLE_HEADER       *Table)
1075 {
1076     ACPI_STATUS             Status;
1077     ACPI_DBG2_DEVICE        *Subtable;
1078     UINT32                  Length = Table->Length;
1079     UINT32                  Offset = sizeof (ACPI_TABLE_DBG2);
1080     UINT32                  i;
1081     UINT32                  ArrayOffset;
1082     UINT32                  AbsoluteOffset;
1083     UINT8                   *Array;
1084 
1085 
1086     /* Main table */
1087 
1088     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoDbg2);
1089     if (ACPI_FAILURE (Status))
1090     {
1091         return;
1092     }
1093 
1094     /* Subtables */
1095 
1096     Subtable = ACPI_ADD_PTR (ACPI_DBG2_DEVICE, Table, Offset);
1097     while (Offset < Table->Length)
1098     {
1099         AcpiOsPrintf ("\n");
1100         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1101             Subtable->Length, AcpiDmTableInfoDbg2Device);
1102         if (ACPI_FAILURE (Status))
1103         {
1104             return;
1105         }
1106 
1107         /* Dump the BaseAddress array */
1108 
1109         for (i = 0; i < Subtable->RegisterCount; i++)
1110         {
1111             ArrayOffset = Subtable->BaseAddressOffset +
1112                 (sizeof (ACPI_GENERIC_ADDRESS) * i);
1113             AbsoluteOffset = Offset + ArrayOffset;
1114             Array = (UINT8 *) Subtable + ArrayOffset;
1115 
1116             Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array,
1117                 Subtable->Length, AcpiDmTableInfoDbg2Addr);
1118             if (ACPI_FAILURE (Status))
1119             {
1120                 return;
1121             }
1122         }
1123 
1124         /* Dump the AddressSize array */
1125 
1126         for (i = 0; i < Subtable->RegisterCount; i++)
1127         {
1128             ArrayOffset = Subtable->AddressSizeOffset +
1129                 (sizeof (UINT32) * i);
1130             AbsoluteOffset = Offset + ArrayOffset;
1131             Array = (UINT8 *) Subtable + ArrayOffset;
1132 
1133             Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array,
1134                 Subtable->Length, AcpiDmTableInfoDbg2Size);
1135             if (ACPI_FAILURE (Status))
1136             {
1137                 return;
1138             }
1139         }
1140 
1141         /* Dump the Namestring (required) */
1142 
1143         AcpiOsPrintf ("\n");
1144         ArrayOffset = Subtable->NamepathOffset;
1145         AbsoluteOffset = Offset + ArrayOffset;
1146         Array = (UINT8 *) Subtable + ArrayOffset;
1147 
1148         Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array,
1149             Subtable->Length, AcpiDmTableInfoDbg2Name);
1150         if (ACPI_FAILURE (Status))
1151         {
1152             return;
1153         }
1154 
1155         /* Dump the OemData (optional) */
1156 
1157         if (Subtable->OemDataOffset)
1158         {
1159             Status = AcpiDmDumpTable (Length, Offset + Subtable->OemDataOffset,
1160                 Table, Subtable->OemDataLength,
1161                 AcpiDmTableInfoDbg2OemData);
1162             if (ACPI_FAILURE (Status))
1163             {
1164                 return;
1165             }
1166         }
1167 
1168         /* Point to next subtable */
1169 
1170         Offset += Subtable->Length;
1171         Subtable = ACPI_ADD_PTR (ACPI_DBG2_DEVICE, Subtable,
1172             Subtable->Length);
1173     }
1174 }
1175 
1176 
1177 /*******************************************************************************
1178  *
1179  * FUNCTION:    AcpiDmDumpDmar
1180  *
1181  * PARAMETERS:  Table               - A DMAR table
1182  *
1183  * RETURN:      None
1184  *
1185  * DESCRIPTION: Format the contents of a DMAR. This table type consists
1186  *              of an open-ended number of subtables.
1187  *
1188  ******************************************************************************/
1189 
1190 void
1191 AcpiDmDumpDmar (
1192     ACPI_TABLE_HEADER       *Table)
1193 {
1194     ACPI_STATUS             Status;
1195     ACPI_DMAR_HEADER        *Subtable;
1196     UINT32                  Length = Table->Length;
1197     UINT32                  Offset = sizeof (ACPI_TABLE_DMAR);
1198     ACPI_DMTABLE_INFO       *InfoTable;
1199     ACPI_DMAR_DEVICE_SCOPE  *ScopeTable;
1200     UINT32                  ScopeOffset;
1201     UINT8                   *PciPath;
1202     UINT32                  PathOffset;
1203 
1204 
1205     /* Main table */
1206 
1207     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoDmar);
1208     if (ACPI_FAILURE (Status))
1209     {
1210         return;
1211     }
1212 
1213     /* Subtables */
1214 
1215     Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Table, Offset);
1216     while (Offset < Table->Length)
1217     {
1218         /* Common subtable header */
1219 
1220         AcpiOsPrintf ("\n");
1221         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1222             Subtable->Length, AcpiDmTableInfoDmarHdr);
1223         if (ACPI_FAILURE (Status))
1224         {
1225             return;
1226         }
1227 
1228         AcpiOsPrintf ("\n");
1229 
1230         switch (Subtable->Type)
1231         {
1232         case ACPI_DMAR_TYPE_HARDWARE_UNIT:
1233 
1234             InfoTable = AcpiDmTableInfoDmar0;
1235             ScopeOffset = sizeof (ACPI_DMAR_HARDWARE_UNIT);
1236             break;
1237 
1238         case ACPI_DMAR_TYPE_RESERVED_MEMORY:
1239 
1240             InfoTable = AcpiDmTableInfoDmar1;
1241             ScopeOffset = sizeof (ACPI_DMAR_RESERVED_MEMORY);
1242             break;
1243 
1244         case ACPI_DMAR_TYPE_ROOT_ATS:
1245 
1246             InfoTable = AcpiDmTableInfoDmar2;
1247             ScopeOffset = sizeof (ACPI_DMAR_ATSR);
1248             break;
1249 
1250         case ACPI_DMAR_TYPE_HARDWARE_AFFINITY:
1251 
1252             InfoTable = AcpiDmTableInfoDmar3;
1253             ScopeOffset = sizeof (ACPI_DMAR_RHSA);
1254             break;
1255 
1256         case ACPI_DMAR_TYPE_NAMESPACE:
1257 
1258             InfoTable = AcpiDmTableInfoDmar4;
1259             ScopeOffset = sizeof (ACPI_DMAR_ANDD);
1260             break;
1261 
1262         case ACPI_DMAR_TYPE_SATC:
1263 
1264             InfoTable = AcpiDmTableInfoDmar5;
1265             ScopeOffset = sizeof (ACPI_DMAR_SATC);
1266             break;
1267 
1268         default:
1269 
1270             AcpiOsPrintf ("\n**** Unknown DMAR subtable type 0x%X\n\n",
1271                 Subtable->Type);
1272             return;
1273         }
1274 
1275         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1276             Subtable->Length, InfoTable);
1277         if (ACPI_FAILURE (Status))
1278         {
1279             return;
1280         }
1281 
1282         /*
1283          * Dump the optional device scope entries
1284          */
1285         if ((Subtable->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
1286             (Subtable->Type == ACPI_DMAR_TYPE_NAMESPACE))
1287         {
1288             /* These types do not support device scopes */
1289 
1290             goto NextSubtable;
1291         }
1292 
1293         ScopeTable = ACPI_ADD_PTR (ACPI_DMAR_DEVICE_SCOPE, Subtable, ScopeOffset);
1294         while (ScopeOffset < Subtable->Length)
1295         {
1296             AcpiOsPrintf ("\n");
1297             Status = AcpiDmDumpTable (Length, Offset + ScopeOffset, ScopeTable,
1298                 ScopeTable->Length, AcpiDmTableInfoDmarScope);
1299             if (ACPI_FAILURE (Status))
1300             {
1301                 return;
1302             }
1303             AcpiOsPrintf ("\n");
1304 
1305             /* Dump the PCI Path entries for this device scope */
1306 
1307             PathOffset = sizeof (ACPI_DMAR_DEVICE_SCOPE); /* Path entries start at this offset */
1308 
1309             PciPath = ACPI_ADD_PTR (UINT8, ScopeTable,
1310                 sizeof (ACPI_DMAR_DEVICE_SCOPE));
1311 
1312             while (PathOffset < ScopeTable->Length)
1313             {
1314                 AcpiDmLineHeader ((PathOffset + ScopeOffset + Offset), 2,
1315                     "PCI Path");
1316                 AcpiOsPrintf ("%2.2X,%2.2X\n", PciPath[0], PciPath[1]);
1317 
1318                 /* Point to next PCI Path entry */
1319 
1320                 PathOffset += 2;
1321                 PciPath += 2;
1322                 AcpiOsPrintf ("\n");
1323             }
1324 
1325             /* Point to next device scope entry */
1326 
1327             ScopeOffset += ScopeTable->Length;
1328             ScopeTable = ACPI_ADD_PTR (ACPI_DMAR_DEVICE_SCOPE,
1329                 ScopeTable, ScopeTable->Length);
1330         }
1331 
1332 NextSubtable:
1333         /* Point to next subtable */
1334 
1335         Offset += Subtable->Length;
1336         Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Subtable,
1337             Subtable->Length);
1338     }
1339 }
1340 
1341 
1342 /*******************************************************************************
1343  *
1344  * FUNCTION:    AcpiDmDumpDrtm
1345  *
1346  * PARAMETERS:  Table               - A DRTM table
1347  *
1348  * RETURN:      None
1349  *
1350  * DESCRIPTION: Format the contents of a DRTM.
1351  *
1352  ******************************************************************************/
1353 
1354 void
1355 AcpiDmDumpDrtm (
1356     ACPI_TABLE_HEADER       *Table)
1357 {
1358     ACPI_STATUS             Status;
1359     UINT32                  Offset;
1360     ACPI_DRTM_VTABLE_LIST   *DrtmVtl;
1361     ACPI_DRTM_RESOURCE_LIST *DrtmRl;
1362     ACPI_DRTM_DPS_ID        *DrtmDps;
1363     UINT32                  Count;
1364 
1365 
1366     /* Main table */
1367 
1368     Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
1369         AcpiDmTableInfoDrtm);
1370     if (ACPI_FAILURE (Status))
1371     {
1372         return;
1373     }
1374 
1375     Offset = sizeof (ACPI_TABLE_DRTM);
1376 
1377     /* Sub-tables */
1378 
1379     /* Dump ValidatedTable length */
1380 
1381     DrtmVtl = ACPI_ADD_PTR (ACPI_DRTM_VTABLE_LIST, Table, Offset);
1382     AcpiOsPrintf ("\n");
1383     Status = AcpiDmDumpTable (Table->Length, Offset,
1384         DrtmVtl, ACPI_OFFSET (ACPI_DRTM_VTABLE_LIST, ValidatedTables),
1385         AcpiDmTableInfoDrtm0);
1386     if (ACPI_FAILURE (Status))
1387     {
1388             return;
1389     }
1390 
1391     Offset += ACPI_OFFSET (ACPI_DRTM_VTABLE_LIST, ValidatedTables);
1392 
1393     /* Dump Validated table addresses */
1394 
1395     Count = 0;
1396     while ((Offset < Table->Length) &&
1397             (DrtmVtl->ValidatedTableCount > Count))
1398     {
1399         Status = AcpiDmDumpTable (Table->Length, Offset,
1400             ACPI_ADD_PTR (void, Table, Offset), sizeof (UINT64),
1401             AcpiDmTableInfoDrtm0a);
1402         if (ACPI_FAILURE (Status))
1403         {
1404             return;
1405         }
1406 
1407         Offset += sizeof (UINT64);
1408         Count++;
1409     }
1410 
1411     /* Dump ResourceList length */
1412 
1413     DrtmRl = ACPI_ADD_PTR (ACPI_DRTM_RESOURCE_LIST, Table, Offset);
1414     AcpiOsPrintf ("\n");
1415     Status = AcpiDmDumpTable (Table->Length, Offset,
1416         DrtmRl, ACPI_OFFSET (ACPI_DRTM_RESOURCE_LIST, Resources),
1417         AcpiDmTableInfoDrtm1);
1418     if (ACPI_FAILURE (Status))
1419     {
1420         return;
1421     }
1422 
1423     Offset += ACPI_OFFSET (ACPI_DRTM_RESOURCE_LIST, Resources);
1424 
1425     /* Dump the Resource List */
1426 
1427     Count = 0;
1428     while ((Offset < Table->Length) &&
1429            (DrtmRl->ResourceCount > Count))
1430     {
1431         Status = AcpiDmDumpTable (Table->Length, Offset,
1432             ACPI_ADD_PTR (void, Table, Offset),
1433             sizeof (ACPI_DRTM_RESOURCE), AcpiDmTableInfoDrtm1a);
1434         if (ACPI_FAILURE (Status))
1435         {
1436             return;
1437         }
1438 
1439         Offset += sizeof (ACPI_DRTM_RESOURCE);
1440         Count++;
1441     }
1442 
1443     /* Dump DPS */
1444 
1445     DrtmDps = ACPI_ADD_PTR (ACPI_DRTM_DPS_ID, Table, Offset);
1446     AcpiOsPrintf ("\n");
1447     (void) AcpiDmDumpTable (Table->Length, Offset,
1448         DrtmDps, sizeof (ACPI_DRTM_DPS_ID), AcpiDmTableInfoDrtm2);
1449 }
1450 
1451 
1452 /*******************************************************************************
1453  *
1454  * FUNCTION:    AcpiDmDumpEinj
1455  *
1456  * PARAMETERS:  Table               - A EINJ table
1457  *
1458  * RETURN:      None
1459  *
1460  * DESCRIPTION: Format the contents of a EINJ. This table type consists
1461  *              of an open-ended number of subtables.
1462  *
1463  ******************************************************************************/
1464 
1465 void
1466 AcpiDmDumpEinj (
1467     ACPI_TABLE_HEADER       *Table)
1468 {
1469     ACPI_STATUS             Status;
1470     ACPI_WHEA_HEADER        *Subtable;
1471     UINT32                  Length = Table->Length;
1472     UINT32                  Offset = sizeof (ACPI_TABLE_EINJ);
1473 
1474 
1475     /* Main table */
1476 
1477     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoEinj);
1478     if (ACPI_FAILURE (Status))
1479     {
1480         return;
1481     }
1482 
1483     /* Subtables */
1484 
1485     Subtable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Table, Offset);
1486     while (Offset < Table->Length)
1487     {
1488         AcpiOsPrintf ("\n");
1489         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1490             sizeof (ACPI_WHEA_HEADER), AcpiDmTableInfoEinj0);
1491         if (ACPI_FAILURE (Status))
1492         {
1493             return;
1494         }
1495 
1496         /* Point to next subtable (each subtable is of fixed length) */
1497 
1498         Offset += sizeof (ACPI_WHEA_HEADER);
1499         Subtable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Subtable,
1500             sizeof (ACPI_WHEA_HEADER));
1501     }
1502 }
1503 
1504 
1505 /*******************************************************************************
1506  *
1507  * FUNCTION:    AcpiDmDumpErst
1508  *
1509  * PARAMETERS:  Table               - A ERST table
1510  *
1511  * RETURN:      None
1512  *
1513  * DESCRIPTION: Format the contents of a ERST. This table type consists
1514  *              of an open-ended number of subtables.
1515  *
1516  ******************************************************************************/
1517 
1518 void
1519 AcpiDmDumpErst (
1520     ACPI_TABLE_HEADER       *Table)
1521 {
1522     ACPI_STATUS             Status;
1523     ACPI_WHEA_HEADER        *Subtable;
1524     UINT32                  Length = Table->Length;
1525     UINT32                  Offset = sizeof (ACPI_TABLE_ERST);
1526 
1527 
1528     /* Main table */
1529 
1530     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoErst);
1531     if (ACPI_FAILURE (Status))
1532     {
1533         return;
1534     }
1535 
1536     /* Subtables */
1537 
1538     Subtable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Table, Offset);
1539     while (Offset < Table->Length)
1540     {
1541         AcpiOsPrintf ("\n");
1542         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1543             sizeof (ACPI_WHEA_HEADER), AcpiDmTableInfoErst0);
1544         if (ACPI_FAILURE (Status))
1545         {
1546             return;
1547         }
1548 
1549         /* Point to next subtable (each subtable is of fixed length) */
1550 
1551         Offset += sizeof (ACPI_WHEA_HEADER);
1552         Subtable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Subtable,
1553             sizeof (ACPI_WHEA_HEADER));
1554     }
1555 }
1556 
1557 
1558 /*******************************************************************************
1559  *
1560  * FUNCTION:    AcpiDmDumpFpdt
1561  *
1562  * PARAMETERS:  Table               - A FPDT table
1563  *
1564  * RETURN:      None
1565  *
1566  * DESCRIPTION: Format the contents of a FPDT. This table type consists
1567  *              of an open-ended number of subtables.
1568  *
1569  ******************************************************************************/
1570 
1571 void
1572 AcpiDmDumpFpdt (
1573     ACPI_TABLE_HEADER       *Table)
1574 {
1575     ACPI_STATUS             Status;
1576     ACPI_FPDT_HEADER        *Subtable;
1577     UINT32                  Length = Table->Length;
1578     UINT32                  Offset = sizeof (ACPI_TABLE_FPDT);
1579     ACPI_DMTABLE_INFO       *InfoTable;
1580 
1581 
1582     /* There is no main table (other than the standard ACPI header) */
1583 
1584     /* Subtables */
1585 
1586     Subtable = ACPI_ADD_PTR (ACPI_FPDT_HEADER, Table, Offset);
1587     while (Offset < Table->Length)
1588     {
1589         /* Common subtable header */
1590 
1591         AcpiOsPrintf ("\n");
1592         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1593             Subtable->Length, AcpiDmTableInfoFpdtHdr);
1594         if (ACPI_FAILURE (Status))
1595         {
1596             return;
1597         }
1598 
1599         switch (Subtable->Type)
1600         {
1601         case ACPI_FPDT_TYPE_BOOT:
1602 
1603             InfoTable = AcpiDmTableInfoFpdt0;
1604             break;
1605 
1606         case ACPI_FPDT_TYPE_S3PERF:
1607 
1608             InfoTable = AcpiDmTableInfoFpdt1;
1609             break;
1610 
1611         default:
1612 
1613             AcpiOsPrintf ("\n**** Unknown FPDT subtable type 0x%X\n\n",
1614                 Subtable->Type);
1615 
1616             /* Attempt to continue */
1617 
1618             if (!Subtable->Length)
1619             {
1620                 AcpiOsPrintf ("Invalid zero length subtable\n");
1621                 return;
1622             }
1623             goto NextSubtable;
1624         }
1625 
1626         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1627             Subtable->Length, InfoTable);
1628         if (ACPI_FAILURE (Status))
1629         {
1630             return;
1631         }
1632 
1633 NextSubtable:
1634         /* Point to next subtable */
1635 
1636         Offset += Subtable->Length;
1637         Subtable = ACPI_ADD_PTR (ACPI_FPDT_HEADER, Subtable,
1638             Subtable->Length);
1639     }
1640 }
1641 
1642 
1643 /*******************************************************************************
1644  *
1645  * FUNCTION:    AcpiDmDumpGtdt
1646  *
1647  * PARAMETERS:  Table               - A GTDT table
1648  *
1649  * RETURN:      None
1650  *
1651  * DESCRIPTION: Format the contents of a GTDT. This table type consists
1652  *              of an open-ended number of subtables.
1653  *
1654  ******************************************************************************/
1655 
1656 void
1657 AcpiDmDumpGtdt (
1658     ACPI_TABLE_HEADER       *Table)
1659 {
1660     ACPI_STATUS             Status;
1661     ACPI_GTDT_HEADER        *Subtable;
1662     UINT32                  Length = Table->Length;
1663     UINT32                  Offset = sizeof (ACPI_TABLE_GTDT);
1664     ACPI_DMTABLE_INFO       *InfoTable;
1665     UINT32                  SubtableLength;
1666     UINT32                  GtCount;
1667     ACPI_GTDT_TIMER_ENTRY   *GtxTable;
1668 
1669 
1670     /* Main table */
1671 
1672     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoGtdt);
1673     if (ACPI_FAILURE (Status))
1674     {
1675         return;
1676     }
1677 
1678     /* Rev 3 fields */
1679 
1680     Subtable = ACPI_ADD_PTR (ACPI_GTDT_HEADER, Table, Offset);
1681 
1682     if (Table->Revision > 2)
1683     {
1684         SubtableLength = sizeof (ACPI_GTDT_EL2);
1685         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1686             SubtableLength, AcpiDmTableInfoGtdtEl2);
1687         if (ACPI_FAILURE (Status))
1688         {
1689             return;
1690         }
1691         Offset += SubtableLength;
1692     }
1693 
1694     Subtable = ACPI_ADD_PTR (ACPI_GTDT_HEADER, Table, Offset);
1695 
1696     /* Subtables */
1697 
1698     while (Offset < Table->Length)
1699     {
1700         /* Common subtable header */
1701 
1702         AcpiOsPrintf ("\n");
1703         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1704             Subtable->Length, AcpiDmTableInfoGtdtHdr);
1705         if (ACPI_FAILURE (Status))
1706         {
1707             return;
1708         }
1709 
1710         GtCount = 0;
1711         switch (Subtable->Type)
1712         {
1713         case ACPI_GTDT_TYPE_TIMER_BLOCK:
1714 
1715             SubtableLength = sizeof (ACPI_GTDT_TIMER_BLOCK);
1716             GtCount = (ACPI_CAST_PTR (ACPI_GTDT_TIMER_BLOCK,
1717                 Subtable))->TimerCount;
1718 
1719             InfoTable = AcpiDmTableInfoGtdt0;
1720             break;
1721 
1722         case ACPI_GTDT_TYPE_WATCHDOG:
1723 
1724             SubtableLength = sizeof (ACPI_GTDT_WATCHDOG);
1725 
1726             InfoTable = AcpiDmTableInfoGtdt1;
1727             break;
1728 
1729         default:
1730 
1731             /* Cannot continue on unknown type - no length */
1732 
1733             AcpiOsPrintf ("\n**** Unknown GTDT subtable type 0x%X\n",
1734                 Subtable->Type);
1735             return;
1736         }
1737 
1738         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1739             Subtable->Length, InfoTable);
1740         if (ACPI_FAILURE (Status))
1741         {
1742             return;
1743         }
1744 
1745         /* Point to end of current subtable (each subtable above is of fixed length) */
1746 
1747         Offset += SubtableLength;
1748 
1749         /* If there are any Gt Timer Blocks from above, dump them now */
1750 
1751         if (GtCount)
1752         {
1753             GtxTable = ACPI_ADD_PTR (
1754                 ACPI_GTDT_TIMER_ENTRY, Subtable, SubtableLength);
1755             SubtableLength += GtCount * sizeof (ACPI_GTDT_TIMER_ENTRY);
1756 
1757             while (GtCount)
1758             {
1759                 AcpiOsPrintf ("\n");
1760                 Status = AcpiDmDumpTable (Length, Offset, GtxTable,
1761                     sizeof (ACPI_GTDT_TIMER_ENTRY), AcpiDmTableInfoGtdt0a);
1762                 if (ACPI_FAILURE (Status))
1763                 {
1764                     return;
1765                 }
1766                 Offset += sizeof (ACPI_GTDT_TIMER_ENTRY);
1767                 GtxTable++;
1768                 GtCount--;
1769             }
1770         }
1771 
1772         /* Point to next subtable */
1773 
1774         Subtable = ACPI_ADD_PTR (ACPI_GTDT_HEADER, Subtable, SubtableLength);
1775     }
1776 }
1777 
1778 
1779 /*******************************************************************************
1780  *
1781  * FUNCTION:    AcpiDmDumpHest
1782  *
1783  * PARAMETERS:  Table               - A HEST table
1784  *
1785  * RETURN:      None
1786  *
1787  * DESCRIPTION: Format the contents of a HEST. This table type consists
1788  *              of an open-ended number of subtables.
1789  *
1790  ******************************************************************************/
1791 
1792 void
1793 AcpiDmDumpHest (
1794     ACPI_TABLE_HEADER       *Table)
1795 {
1796     ACPI_STATUS             Status;
1797     ACPI_HEST_HEADER        *Subtable;
1798     UINT32                  Length = Table->Length;
1799     UINT32                  Offset = sizeof (ACPI_TABLE_HEST);
1800     ACPI_DMTABLE_INFO       *InfoTable;
1801     UINT32                  SubtableLength;
1802     UINT32                  BankCount;
1803     ACPI_HEST_IA_ERROR_BANK *BankTable;
1804 
1805 
1806     /* Main table */
1807 
1808     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHest);
1809     if (ACPI_FAILURE (Status))
1810     {
1811         return;
1812     }
1813 
1814     /* Subtables */
1815 
1816     Subtable = ACPI_ADD_PTR (ACPI_HEST_HEADER, Table, Offset);
1817     while (Offset < Table->Length)
1818     {
1819         BankCount = 0;
1820         switch (Subtable->Type)
1821         {
1822         case ACPI_HEST_TYPE_IA32_CHECK:
1823 
1824             InfoTable = AcpiDmTableInfoHest0;
1825             SubtableLength = sizeof (ACPI_HEST_IA_MACHINE_CHECK);
1826             BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_MACHINE_CHECK,
1827                 Subtable))->NumHardwareBanks;
1828             break;
1829 
1830         case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK:
1831 
1832             InfoTable = AcpiDmTableInfoHest1;
1833             SubtableLength = sizeof (ACPI_HEST_IA_CORRECTED);
1834             BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_CORRECTED,
1835                 Subtable))->NumHardwareBanks;
1836             break;
1837 
1838         case ACPI_HEST_TYPE_IA32_NMI:
1839 
1840             InfoTable = AcpiDmTableInfoHest2;
1841             SubtableLength = sizeof (ACPI_HEST_IA_NMI);
1842             break;
1843 
1844         case ACPI_HEST_TYPE_AER_ROOT_PORT:
1845 
1846             InfoTable = AcpiDmTableInfoHest6;
1847             SubtableLength = sizeof (ACPI_HEST_AER_ROOT);
1848             break;
1849 
1850         case ACPI_HEST_TYPE_AER_ENDPOINT:
1851 
1852             InfoTable = AcpiDmTableInfoHest7;
1853             SubtableLength = sizeof (ACPI_HEST_AER);
1854             break;
1855 
1856         case ACPI_HEST_TYPE_AER_BRIDGE:
1857 
1858             InfoTable = AcpiDmTableInfoHest8;
1859             SubtableLength = sizeof (ACPI_HEST_AER_BRIDGE);
1860             break;
1861 
1862         case ACPI_HEST_TYPE_GENERIC_ERROR:
1863 
1864             InfoTable = AcpiDmTableInfoHest9;
1865             SubtableLength = sizeof (ACPI_HEST_GENERIC);
1866             break;
1867 
1868         case ACPI_HEST_TYPE_GENERIC_ERROR_V2:
1869 
1870             InfoTable = AcpiDmTableInfoHest10;
1871             SubtableLength = sizeof (ACPI_HEST_GENERIC_V2);
1872             break;
1873 
1874         case ACPI_HEST_TYPE_IA32_DEFERRED_CHECK:
1875 
1876             InfoTable = AcpiDmTableInfoHest11;
1877             SubtableLength = sizeof (ACPI_HEST_IA_DEFERRED_CHECK);
1878             BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_DEFERRED_CHECK,
1879                 Subtable))->NumHardwareBanks;
1880             break;
1881 
1882         default:
1883 
1884             /* Cannot continue on unknown type - no length */
1885 
1886             AcpiOsPrintf ("\n**** Unknown HEST subtable type 0x%X\n",
1887                 Subtable->Type);
1888             return;
1889         }
1890 
1891         AcpiOsPrintf ("\n");
1892         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1893             SubtableLength, InfoTable);
1894         if (ACPI_FAILURE (Status))
1895         {
1896             return;
1897         }
1898 
1899         /* Point to end of current subtable (each subtable above is of fixed length) */
1900 
1901         Offset += SubtableLength;
1902 
1903         /* If there are any (fixed-length) Error Banks from above, dump them now */
1904 
1905         if (BankCount)
1906         {
1907             BankTable = ACPI_ADD_PTR (ACPI_HEST_IA_ERROR_BANK, Subtable,
1908                 SubtableLength);
1909             SubtableLength += BankCount * sizeof (ACPI_HEST_IA_ERROR_BANK);
1910 
1911             while (BankCount)
1912             {
1913                 AcpiOsPrintf ("\n");
1914                 Status = AcpiDmDumpTable (Length, Offset, BankTable,
1915                     sizeof (ACPI_HEST_IA_ERROR_BANK), AcpiDmTableInfoHestBank);
1916                 if (ACPI_FAILURE (Status))
1917                 {
1918                     return;
1919                 }
1920 
1921                 Offset += sizeof (ACPI_HEST_IA_ERROR_BANK);
1922                 BankTable++;
1923                 BankCount--;
1924             }
1925         }
1926 
1927         /* Point to next subtable */
1928 
1929         Subtable = ACPI_ADD_PTR (ACPI_HEST_HEADER, Subtable, SubtableLength);
1930     }
1931 }
1932 
1933 
1934 /*******************************************************************************
1935  *
1936  * FUNCTION:    AcpiDmDumpHmat
1937  *
1938  * PARAMETERS:  Table               - A HMAT table
1939  *
1940  * RETURN:      None
1941  *
1942  * DESCRIPTION: Format the contents of a HMAT.
1943  *
1944  ******************************************************************************/
1945 
1946 void
1947 AcpiDmDumpHmat (
1948     ACPI_TABLE_HEADER       *Table)
1949 {
1950     ACPI_STATUS             Status;
1951     ACPI_HMAT_STRUCTURE     *HmatStruct;
1952     ACPI_HMAT_LOCALITY      *HmatLocality;
1953     ACPI_HMAT_CACHE         *HmatCache;
1954     UINT32                  Offset;
1955     UINT32                  SubtableOffset;
1956     UINT32                  Length;
1957     ACPI_DMTABLE_INFO       *InfoTable;
1958     UINT32                  i, j;
1959 
1960 
1961     /* Main table */
1962 
1963     Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoHmat);
1964     if (ACPI_FAILURE (Status))
1965     {
1966         return;
1967     }
1968     Offset = sizeof (ACPI_TABLE_HMAT);
1969 
1970     while (Offset < Table->Length)
1971     {
1972         AcpiOsPrintf ("\n");
1973 
1974         /* Dump HMAT structure header */
1975 
1976         HmatStruct = ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, Table, Offset);
1977         if (HmatStruct->Length < sizeof (ACPI_HMAT_STRUCTURE))
1978         {
1979             AcpiOsPrintf ("Invalid HMAT structure length\n");
1980             return;
1981         }
1982         Status = AcpiDmDumpTable (Table->Length, Offset, HmatStruct,
1983             HmatStruct->Length, AcpiDmTableInfoHmatHdr);
1984         if (ACPI_FAILURE (Status))
1985         {
1986             return;
1987         }
1988 
1989         switch (HmatStruct->Type)
1990         {
1991         case ACPI_HMAT_TYPE_ADDRESS_RANGE:
1992 
1993             InfoTable = AcpiDmTableInfoHmat0;
1994             Length = sizeof (ACPI_HMAT_PROXIMITY_DOMAIN);
1995             break;
1996 
1997         case ACPI_HMAT_TYPE_LOCALITY:
1998 
1999             InfoTable = AcpiDmTableInfoHmat1;
2000             Length = sizeof (ACPI_HMAT_LOCALITY);
2001             break;
2002 
2003         case ACPI_HMAT_TYPE_CACHE:
2004 
2005             InfoTable = AcpiDmTableInfoHmat2;
2006             Length = sizeof (ACPI_HMAT_CACHE);
2007             break;
2008 
2009         default:
2010 
2011             AcpiOsPrintf ("\n**** Unknown HMAT structure type 0x%X\n",
2012                 HmatStruct->Type);
2013 
2014             /* Attempt to continue */
2015 
2016             goto NextSubtable;
2017         }
2018 
2019         /* Dump HMAT structure body */
2020 
2021         if (HmatStruct->Length < Length)
2022         {
2023             AcpiOsPrintf ("Invalid HMAT structure length\n");
2024             return;
2025         }
2026         Status = AcpiDmDumpTable (Table->Length, Offset, HmatStruct,
2027             HmatStruct->Length, InfoTable);
2028         if (ACPI_FAILURE (Status))
2029         {
2030             return;
2031         }
2032 
2033         /* Dump HMAT structure additionals */
2034 
2035         switch (HmatStruct->Type)
2036         {
2037         case ACPI_HMAT_TYPE_LOCALITY:
2038 
2039             HmatLocality = ACPI_CAST_PTR (ACPI_HMAT_LOCALITY, HmatStruct);
2040             SubtableOffset = sizeof (ACPI_HMAT_LOCALITY);
2041 
2042             /* Dump initiator proximity domains */
2043 
2044             if ((UINT32)(HmatStruct->Length - SubtableOffset) <
2045                 (UINT32)(HmatLocality->NumberOfInitiatorPDs * 4))
2046             {
2047                 AcpiOsPrintf ("Invalid initiator proximity domain number\n");
2048                 return;
2049             }
2050             for (i = 0; i < HmatLocality->NumberOfInitiatorPDs; i++)
2051             {
2052                 Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
2053                     ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
2054                     4, AcpiDmTableInfoHmat1a);
2055                 if (ACPI_FAILURE (Status))
2056                 {
2057                     return;
2058                 }
2059 
2060                 SubtableOffset += 4;
2061             }
2062 
2063             /* Dump target proximity domains */
2064 
2065             if ((UINT32)(HmatStruct->Length - SubtableOffset) <
2066                 (UINT32)(HmatLocality->NumberOfTargetPDs * 4))
2067             {
2068                 AcpiOsPrintf ("Invalid target proximity domain number\n");
2069                 return;
2070             }
2071             for (i = 0; i < HmatLocality->NumberOfTargetPDs; i++)
2072             {
2073                 Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
2074                     ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
2075                     4, AcpiDmTableInfoHmat1b);
2076                 if (ACPI_FAILURE (Status))
2077                 {
2078                     return;
2079                 }
2080 
2081                 SubtableOffset += 4;
2082             }
2083 
2084             /* Dump latency/bandwidth entris */
2085 
2086             if ((UINT32)(HmatStruct->Length - SubtableOffset) <
2087                 (UINT32)(HmatLocality->NumberOfInitiatorPDs *
2088                          HmatLocality->NumberOfTargetPDs * 2))
2089             {
2090                 AcpiOsPrintf ("Invalid latency/bandwidth entry number\n");
2091                 return;
2092             }
2093             for (i = 0; i < HmatLocality->NumberOfInitiatorPDs; i++)
2094             {
2095                 for (j = 0; j < HmatLocality->NumberOfTargetPDs; j++)
2096                 {
2097                     Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
2098                         ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
2099                         2, AcpiDmTableInfoHmat1c);
2100                     if (ACPI_FAILURE(Status))
2101                     {
2102                         return;
2103                     }
2104 
2105                     SubtableOffset += 2;
2106                 }
2107             }
2108             break;
2109 
2110         case ACPI_HMAT_TYPE_CACHE:
2111 
2112             HmatCache = ACPI_CAST_PTR (ACPI_HMAT_CACHE, HmatStruct);
2113             SubtableOffset = sizeof (ACPI_HMAT_CACHE);
2114 
2115             /* Dump SMBIOS handles */
2116 
2117             if ((UINT32)(HmatStruct->Length - SubtableOffset) <
2118                 (UINT32)(HmatCache->NumberOfSMBIOSHandles * 2))
2119             {
2120                 AcpiOsPrintf ("Invalid SMBIOS handle number\n");
2121                 return;
2122             }
2123             for (i = 0; i < HmatCache->NumberOfSMBIOSHandles; i++)
2124             {
2125                 Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
2126                     ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
2127                     2, AcpiDmTableInfoHmat2a);
2128                 if (ACPI_FAILURE (Status))
2129                 {
2130                     return;
2131                 }
2132 
2133                 SubtableOffset += 2;
2134             }
2135             break;
2136 
2137         default:
2138 
2139             break;
2140         }
2141 
2142 NextSubtable:
2143         /* Point to next HMAT structure subtable */
2144 
2145         Offset += (HmatStruct->Length);
2146     }
2147 }
2148