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 - 2023, 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 "acpi.h"
153 #include "accommon.h"
154 #include "acdisasm.h"
155 #include "actables.h"
156 #include "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
AcpiDmDumpAest(ACPI_TABLE_HEADER * Table)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
AcpiDmDumpApmt(ACPI_TABLE_HEADER * Table)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
AcpiDmDumpAsf(ACPI_TABLE_HEADER * Table)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  * FUNCTION:    AcpiDmDumpAspt
615  *
616  * PARAMETERS:  Table               - A ASPT table
617  *
618  * RETURN:      None
619  *
620  * DESCRIPTION: Format the contents of a ASPT table
621  *
622  ******************************************************************************/
623 
624 void
AcpiDmDumpAspt(ACPI_TABLE_HEADER * Table)625 AcpiDmDumpAspt (
626     ACPI_TABLE_HEADER       *Table)
627 {
628     ACPI_STATUS             Status;
629     UINT32                  Offset = sizeof (ACPI_TABLE_ASPT);
630     UINT32                  Length = Table->Length;
631     ACPI_ASPT_HEADER        *Subtable;
632     ACPI_DMTABLE_INFO       *InfoTable;
633     UINT16                   Type;
634 
635     /* Main table */
636     Status = AcpiDmDumpTable(Length, 0, Table, 0, AcpiDmTableInfoAspt);
637 
638     /* Subtables */
639 
640     Subtable = ACPI_ADD_PTR (ACPI_ASPT_HEADER, Table, Offset);
641     while (Offset < Table->Length)
642     {
643         AcpiOsPrintf ("\n");
644 
645         /* Common subtable header */
646         Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
647             Subtable->Length, AcpiDmTableInfoAsptHdr);
648         if (ACPI_FAILURE (Status))
649         {
650             return;
651         }
652 
653         Type = Subtable->Type;
654 
655         switch (Type)
656         {
657         case ACPI_ASPT_TYPE_GLOBAL_REGS:
658 
659             InfoTable = AcpiDmTableInfoAspt0;
660             break;
661 
662         case ACPI_ASPT_TYPE_SEV_MBOX_REGS:
663 
664             InfoTable = AcpiDmTableInfoAspt1;
665             break;
666 
667         case ACPI_ASPT_TYPE_ACPI_MBOX_REGS:
668 
669             InfoTable = AcpiDmTableInfoAspt2;
670             break;
671 
672         default:
673 
674             AcpiOsPrintf ("\n**** Unknown ASPT subtable type 0x%X\n",
675                 Subtable->Type);
676             return;
677         }
678 
679         Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
680             Subtable->Length, InfoTable);
681         if (ACPI_FAILURE (Status))
682         {
683             return;
684         }
685 
686         AcpiOsPrintf ("\n");
687 
688         /* Point to next subtable */
689         if (!Subtable->Length)
690         {
691             AcpiOsPrintf ("Invalid zero subtable header length\n");
692             return;
693         }
694 
695         Offset += Subtable->Length;
696         Subtable = ACPI_ADD_PTR (ACPI_ASPT_HEADER, Subtable,
697             Subtable->Length);
698     }
699 }
700 
701 
702 /*******************************************************************************
703  *
704  * FUNCTION:    AcpiDmDumpCdat
705  *
706  * PARAMETERS:  InTable             - A CDAT table
707  *
708  * RETURN:      None
709  *
710  * DESCRIPTION: Format the contents of a CDAT. This table type consists
711  *              of an open-ended number of subtables.
712  *
713  ******************************************************************************/
714 
715 void
AcpiDmDumpCdat(ACPI_TABLE_HEADER * InTable)716 AcpiDmDumpCdat (
717     ACPI_TABLE_HEADER       *InTable)
718 {
719     ACPI_TABLE_CDAT         *Table = ACPI_CAST_PTR (ACPI_TABLE_CDAT, InTable);
720     ACPI_STATUS             Status;
721     ACPI_CDAT_HEADER        *Subtable;
722     ACPI_TABLE_CDAT         *CdatTable = ACPI_CAST_PTR (ACPI_TABLE_CDAT, Table);
723     ACPI_DMTABLE_INFO       *InfoTable;
724     UINT32                  Length = CdatTable->Length;
725     UINT32                  Offset = sizeof (ACPI_TABLE_CDAT);
726     UINT32                  SubtableLength;
727     UINT32                  SubtableType;
728     INT32                   EntriesLength;
729 
730 
731     /* Main table */
732 
733     Status = AcpiDmDumpTable (Offset, 0, CdatTable, 0,
734         AcpiDmTableInfoCdatTableHdr);
735     if (ACPI_FAILURE (Status))
736     {
737         return;
738     }
739 
740     Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, sizeof (ACPI_TABLE_CDAT));
741     while (Offset < Table->Length)
742     {
743         /* Dump the common subtable header */
744 
745         DbgPrint (ASL_DEBUG_OUTPUT, "0) HeaderOffset: %X\n", Offset);
746         AcpiOsPrintf ("\n");
747         Status = AcpiDmDumpTable (Length, Offset, Subtable,
748             sizeof (ACPI_CDAT_HEADER), AcpiDmTableInfoCdatHeader);
749         if (ACPI_FAILURE (Status))
750         {
751             return;
752         }
753 
754         /* Point past the common subtable header, decode the subtable type */
755 
756         Offset += sizeof (ACPI_CDAT_HEADER);
757         SubtableType = Subtable->Type;
758 
759         switch (Subtable->Type)
760         {
761         case ACPI_CDAT_TYPE_DSMAS:
762             Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
763             SubtableLength = sizeof (ACPI_CDAT_DSMAS);
764 
765             InfoTable = AcpiDmTableInfoCdat0;
766             break;
767 
768         case ACPI_CDAT_TYPE_DSLBIS:
769             Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
770             SubtableLength = sizeof (ACPI_CDAT_DSLBIS);
771             DbgPrint (ASL_DEBUG_OUTPUT, "1) Offset: %X\n", Offset);
772 
773             InfoTable = AcpiDmTableInfoCdat1;
774             break;
775 
776         case ACPI_CDAT_TYPE_DSMSCIS:
777             Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
778             SubtableLength = sizeof (ACPI_CDAT_DSMSCIS);
779 
780             InfoTable = AcpiDmTableInfoCdat2;
781             break;
782 
783         case ACPI_CDAT_TYPE_DSIS:
784             DbgPrint (ASL_DEBUG_OUTPUT, "2) Offset: %X ", Offset);
785             SubtableLength = sizeof (ACPI_CDAT_DSIS);
786             DbgPrint (ASL_DEBUG_OUTPUT, "1) input pointer: %p\n", Table);
787             Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
788             DbgPrint (ASL_DEBUG_OUTPUT, "1) output pointers: %p, %p, Offset: %X\n",
789                 Table, Subtable, Offset);
790             DbgPrint (ASL_DEBUG_OUTPUT, "3) Offset: %X\n", Offset);
791 
792             InfoTable = AcpiDmTableInfoCdat3;
793             break;
794 
795         case ACPI_CDAT_TYPE_DSEMTS:
796             Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
797             SubtableLength = sizeof (ACPI_CDAT_DSEMTS);
798 
799             InfoTable = AcpiDmTableInfoCdat4;
800             break;
801 
802         case ACPI_CDAT_TYPE_SSLBIS:
803             SubtableLength = Subtable->Length;
804 
805             InfoTable = AcpiDmTableInfoCdat5;
806             Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
807             break;
808 
809         default:
810             fprintf (stderr, "ERROR: Unknown SubtableType: %X\n", Subtable->Type);
811             return;
812         }
813 
814         DbgPrint (ASL_DEBUG_OUTPUT, "SubtableType: %X, Length: %X Actual "
815             "Length: %X Offset: %X tableptr: %p\n", SubtableType,
816             Subtable->Length, SubtableLength, Offset, Table);
817 
818         /*
819          * Do the subtable-specific fields
820          */
821         Status = AcpiDmDumpTable (Length, Offset, Subtable, Offset, InfoTable);
822         if (ACPI_FAILURE (Status))
823         {
824             return;
825         }
826 
827         DbgPrint (ASL_DEBUG_OUTPUT, "Subtable Type: %X, Offset: %X, SubtableLength: %X\n",
828             SubtableType, Offset, SubtableLength);
829 
830         /* Additional sub-subtables, dependent on the main subtable type */
831 
832         switch (SubtableType)
833         {
834         case ACPI_CDAT_TYPE_SSLBIS:
835             Offset += sizeof (ACPI_CDAT_SSLBIS);
836             Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table,
837                 Offset);
838 
839             DbgPrint (ASL_DEBUG_OUTPUT, "Case SSLBIS, Offset: %X, SubtableLength: %X "
840                 "Subtable->Length %X\n", Offset, SubtableLength, Subtable->Length);
841 
842             /* Generate the total length of all the SSLBE entries */
843 
844             EntriesLength = SubtableLength - sizeof (ACPI_CDAT_HEADER) -
845                 sizeof (ACPI_CDAT_SSLBIS);
846             DbgPrint (ASL_DEBUG_OUTPUT, "EntriesLength: %X, Offset: %X, Table->Length: %X\n",
847                 EntriesLength, Offset, Table->Length);
848 
849             /* Do each of the SSLBE Entries */
850 
851             while ((EntriesLength > 0) && (Offset < Table->Length))
852             {
853                 AcpiOsPrintf ("\n");
854 
855                 Status = AcpiDmDumpTable (Length, Offset, Subtable, Offset,
856                     AcpiDmTableInfoCdatEntries);
857                 if (ACPI_FAILURE (Status))
858                 {
859                     return;
860                 }
861 
862                 EntriesLength -= sizeof (ACPI_CDAT_SSLBE);
863                 Offset += sizeof (ACPI_CDAT_SSLBE);
864                 Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
865             }
866 
867             SubtableLength = 0;
868             break;
869 
870         default:
871             break;
872         }
873 
874         DbgPrint (ASL_DEBUG_OUTPUT, "Offset: %X, Subtable Length: %X\n",
875             Offset, SubtableLength);
876 
877         /* Point to next subtable */
878 
879         Offset += SubtableLength;
880         Subtable = ACPI_ADD_PTR (ACPI_CDAT_HEADER, Table, Offset);
881     }
882 
883     return;
884 }
885 
886 
887 /*******************************************************************************
888  *
889  * FUNCTION:    AcpiDmDumpCedt
890  *
891  * PARAMETERS:  Table               - A CEDT table
892  *
893  * RETURN:      None
894  *
895  * DESCRIPTION: Format the contents of a CEDT. This table type consists
896  *              of an open-ended number of subtables.
897  *
898  ******************************************************************************/
899 
900 void
AcpiDmDumpCedt(ACPI_TABLE_HEADER * Table)901 AcpiDmDumpCedt (
902     ACPI_TABLE_HEADER       *Table)
903 {
904     ACPI_STATUS             Status;
905     ACPI_CEDT_HEADER        *Subtable;
906     UINT32                  Length = Table->Length;
907     UINT32                  Offset = sizeof (ACPI_TABLE_CEDT);
908 
909 
910     /* There is no main table (other than the standard ACPI header) */
911 
912     Subtable = ACPI_ADD_PTR (ACPI_CEDT_HEADER, Table, Offset);
913     while (Offset < Table->Length)
914     {
915         /* Common subtable header */
916 
917         AcpiOsPrintf ("\n");
918         Status = AcpiDmDumpTable (Length, Offset, Subtable,
919             Subtable->Length, AcpiDmTableInfoCedtHdr);
920         if (ACPI_FAILURE (Status))
921         {
922             return;
923         }
924 
925         switch (Subtable->Type)
926         {
927         case ACPI_CEDT_TYPE_CHBS:
928             Status = AcpiDmDumpTable (Length, Offset, Subtable,
929                 Subtable->Length, AcpiDmTableInfoCedt0);
930             if (ACPI_FAILURE (Status))
931             {
932                 return;
933             }
934             break;
935 
936         case ACPI_CEDT_TYPE_CFMWS:
937         {
938             ACPI_CEDT_CFMWS *ptr = (ACPI_CEDT_CFMWS *) Subtable;
939             unsigned int i, max = 0x01 << (ptr->InterleaveWays);
940 
941             /* print out table with first "Interleave target" */
942 
943             Status = AcpiDmDumpTable (Length, Offset, Subtable,
944                 Subtable->Length, AcpiDmTableInfoCedt1);
945             if (ACPI_FAILURE (Status))
946             {
947                 return;
948             }
949 
950             /* Now, print out any interleave targets beyond the first. */
951 
952             for (i = 1; i < max; i++)
953             {
954                 unsigned int loc_offset = Offset + (i * 4) + ACPI_OFFSET (ACPI_CEDT_CFMWS, InterleaveTargets);
955                 unsigned int *trg = &(ptr->InterleaveTargets[i]);
956 
957                 Status = AcpiDmDumpTable (Length, loc_offset, trg,
958                         Subtable->Length, AcpiDmTableInfoCedt1_te);
959                 if (ACPI_FAILURE (Status))
960                 {
961                     return;
962                 }
963             }
964             break;
965         }
966 
967         default:
968             AcpiOsPrintf ("\n**** Unknown CEDT subtable type 0x%X\n\n",
969                 Subtable->Type);
970 
971             /* Attempt to continue */
972             if (!Subtable->Length)
973             {
974                 AcpiOsPrintf ("Invalid zero length subtable\n");
975                 return;
976             }
977         }
978 
979         /* Point to next subtable */
980         Offset += Subtable->Length;
981         Subtable = ACPI_ADD_PTR (ACPI_CEDT_HEADER, Subtable,
982             Subtable->Length);
983     }
984 }
985 
986 /*******************************************************************************
987  *
988  * FUNCTION:    AcpiDmDumpCpep
989  *
990  * PARAMETERS:  Table               - A CPEP table
991  *
992  * RETURN:      None
993  *
994  * DESCRIPTION: Format the contents of a CPEP. This table type consists
995  *              of an open-ended number of subtables.
996  *
997  ******************************************************************************/
998 
999 void
AcpiDmDumpCpep(ACPI_TABLE_HEADER * Table)1000 AcpiDmDumpCpep (
1001     ACPI_TABLE_HEADER       *Table)
1002 {
1003     ACPI_STATUS             Status;
1004     ACPI_CPEP_POLLING       *Subtable;
1005     UINT32                  Length = Table->Length;
1006     UINT32                  Offset = sizeof (ACPI_TABLE_CPEP);
1007 
1008 
1009     /* Main table */
1010 
1011     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoCpep);
1012     if (ACPI_FAILURE (Status))
1013     {
1014         return;
1015     }
1016 
1017     /* Subtables */
1018 
1019     Subtable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, Table, Offset);
1020     while (Offset < Table->Length)
1021     {
1022         AcpiOsPrintf ("\n");
1023         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1024             Subtable->Header.Length, AcpiDmTableInfoCpep0);
1025         if (ACPI_FAILURE (Status))
1026         {
1027             return;
1028         }
1029 
1030         /* Point to next subtable */
1031 
1032         Offset += Subtable->Header.Length;
1033         Subtable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, Subtable,
1034             Subtable->Header.Length);
1035     }
1036 }
1037 
1038 
1039 /*******************************************************************************
1040  *
1041  * FUNCTION:    AcpiDmDumpCsrt
1042  *
1043  * PARAMETERS:  Table               - A CSRT table
1044  *
1045  * RETURN:      None
1046  *
1047  * DESCRIPTION: Format the contents of a CSRT. This table type consists
1048  *              of an open-ended number of subtables.
1049  *
1050  ******************************************************************************/
1051 
1052 void
AcpiDmDumpCsrt(ACPI_TABLE_HEADER * Table)1053 AcpiDmDumpCsrt (
1054     ACPI_TABLE_HEADER       *Table)
1055 {
1056     ACPI_STATUS             Status;
1057     ACPI_CSRT_GROUP         *Subtable;
1058     ACPI_CSRT_SHARED_INFO   *SharedInfoTable;
1059     ACPI_CSRT_DESCRIPTOR    *SubSubtable;
1060     UINT32                  Length = Table->Length;
1061     UINT32                  Offset = sizeof (ACPI_TABLE_CSRT);
1062     UINT32                  SubOffset;
1063     UINT32                  SubSubOffset;
1064     UINT32                  InfoLength;
1065 
1066 
1067     /* The main table only contains the ACPI header, thus already handled */
1068 
1069     /* Subtables (Resource Groups) */
1070 
1071     Subtable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, Table, Offset);
1072     while (Offset < Table->Length)
1073     {
1074         /* Resource group subtable */
1075 
1076         AcpiOsPrintf ("\n");
1077         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1078             Subtable->Length, AcpiDmTableInfoCsrt0);
1079         if (ACPI_FAILURE (Status))
1080         {
1081             return;
1082         }
1083 
1084         /* Shared info subtable (One per resource group) */
1085 
1086         SubOffset = sizeof (ACPI_CSRT_GROUP);
1087         SharedInfoTable = ACPI_ADD_PTR (ACPI_CSRT_SHARED_INFO, Table,
1088             Offset + SubOffset);
1089 
1090         AcpiOsPrintf ("\n");
1091         Status = AcpiDmDumpTable (Length, Offset + SubOffset, SharedInfoTable,
1092             sizeof (ACPI_CSRT_SHARED_INFO), AcpiDmTableInfoCsrt1);
1093         if (ACPI_FAILURE (Status))
1094         {
1095             return;
1096         }
1097 
1098         SubOffset += Subtable->SharedInfoLength;
1099 
1100         /* Sub-Subtables (Resource Descriptors) */
1101 
1102         SubSubtable = ACPI_ADD_PTR (ACPI_CSRT_DESCRIPTOR, Table,
1103             Offset + SubOffset);
1104 
1105         while ((SubOffset < Subtable->Length) &&
1106               ((Offset + SubOffset) < Table->Length))
1107         {
1108             AcpiOsPrintf ("\n");
1109             Status = AcpiDmDumpTable (Length, Offset + SubOffset, SubSubtable,
1110                 SubSubtable->Length, AcpiDmTableInfoCsrt2);
1111             if (ACPI_FAILURE (Status))
1112             {
1113                 return;
1114             }
1115 
1116             SubSubOffset = sizeof (ACPI_CSRT_DESCRIPTOR);
1117 
1118             /* Resource-specific info buffer */
1119 
1120             InfoLength = SubSubtable->Length - SubSubOffset;
1121             if (InfoLength)
1122             {
1123                 Status = AcpiDmDumpTable (Length,
1124                     Offset + SubOffset + SubSubOffset, Table,
1125                     InfoLength, AcpiDmTableInfoCsrt2a);
1126                 if (ACPI_FAILURE (Status))
1127                 {
1128                     return;
1129                 }
1130             }
1131 
1132             /* Point to next sub-subtable */
1133 
1134             SubOffset += SubSubtable->Length;
1135             SubSubtable = ACPI_ADD_PTR (ACPI_CSRT_DESCRIPTOR, SubSubtable,
1136                 SubSubtable->Length);
1137         }
1138 
1139         /* Point to next subtable */
1140 
1141         Offset += Subtable->Length;
1142         Subtable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, Subtable,
1143             Subtable->Length);
1144     }
1145 }
1146 
1147 
1148 /*******************************************************************************
1149  *
1150  * FUNCTION:    AcpiDmDumpDbg2
1151  *
1152  * PARAMETERS:  Table               - A DBG2 table
1153  *
1154  * RETURN:      None
1155  *
1156  * DESCRIPTION: Format the contents of a DBG2. This table type consists
1157  *              of an open-ended number of subtables.
1158  *
1159  ******************************************************************************/
1160 
1161 void
AcpiDmDumpDbg2(ACPI_TABLE_HEADER * Table)1162 AcpiDmDumpDbg2 (
1163     ACPI_TABLE_HEADER       *Table)
1164 {
1165     ACPI_STATUS             Status;
1166     ACPI_DBG2_DEVICE        *Subtable;
1167     UINT32                  Length = Table->Length;
1168     UINT32                  Offset = sizeof (ACPI_TABLE_DBG2);
1169     UINT32                  i;
1170     UINT32                  ArrayOffset;
1171     UINT32                  AbsoluteOffset;
1172     UINT8                   *Array;
1173 
1174 
1175     /* Main table */
1176 
1177     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoDbg2);
1178     if (ACPI_FAILURE (Status))
1179     {
1180         return;
1181     }
1182 
1183     /* Subtables */
1184 
1185     Subtable = ACPI_ADD_PTR (ACPI_DBG2_DEVICE, Table, Offset);
1186     while (Offset < Table->Length)
1187     {
1188         AcpiOsPrintf ("\n");
1189         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1190             Subtable->Length, AcpiDmTableInfoDbg2Device);
1191         if (ACPI_FAILURE (Status))
1192         {
1193             return;
1194         }
1195 
1196         /* Dump the BaseAddress array */
1197 
1198         for (i = 0; i < Subtable->RegisterCount; i++)
1199         {
1200             ArrayOffset = Subtable->BaseAddressOffset +
1201                 (sizeof (ACPI_GENERIC_ADDRESS) * i);
1202             AbsoluteOffset = Offset + ArrayOffset;
1203             Array = (UINT8 *) Subtable + ArrayOffset;
1204 
1205             Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array,
1206                 Subtable->Length, AcpiDmTableInfoDbg2Addr);
1207             if (ACPI_FAILURE (Status))
1208             {
1209                 return;
1210             }
1211         }
1212 
1213         /* Dump the AddressSize array */
1214 
1215         for (i = 0; i < Subtable->RegisterCount; i++)
1216         {
1217             ArrayOffset = Subtable->AddressSizeOffset +
1218                 (sizeof (UINT32) * i);
1219             AbsoluteOffset = Offset + ArrayOffset;
1220             Array = (UINT8 *) Subtable + ArrayOffset;
1221 
1222             Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array,
1223                 Subtable->Length, AcpiDmTableInfoDbg2Size);
1224             if (ACPI_FAILURE (Status))
1225             {
1226                 return;
1227             }
1228         }
1229 
1230         /* Dump the Namestring (required) */
1231 
1232         AcpiOsPrintf ("\n");
1233         ArrayOffset = Subtable->NamepathOffset;
1234         AbsoluteOffset = Offset + ArrayOffset;
1235         Array = (UINT8 *) Subtable + ArrayOffset;
1236 
1237         Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array,
1238             Subtable->Length, AcpiDmTableInfoDbg2Name);
1239         if (ACPI_FAILURE (Status))
1240         {
1241             return;
1242         }
1243 
1244         /* Dump the OemData (optional) */
1245 
1246         if (Subtable->OemDataOffset)
1247         {
1248             Status = AcpiDmDumpTable (Length, Offset + Subtable->OemDataOffset,
1249                 Table, Subtable->OemDataLength,
1250                 AcpiDmTableInfoDbg2OemData);
1251             if (ACPI_FAILURE (Status))
1252             {
1253                 return;
1254             }
1255         }
1256 
1257         /* Point to next subtable */
1258 
1259         Offset += Subtable->Length;
1260         Subtable = ACPI_ADD_PTR (ACPI_DBG2_DEVICE, Subtable,
1261             Subtable->Length);
1262     }
1263 }
1264 
1265 
1266 /*******************************************************************************
1267  *
1268  * FUNCTION:    AcpiDmDumpDmar
1269  *
1270  * PARAMETERS:  Table               - A DMAR table
1271  *
1272  * RETURN:      None
1273  *
1274  * DESCRIPTION: Format the contents of a DMAR. This table type consists
1275  *              of an open-ended number of subtables.
1276  *
1277  ******************************************************************************/
1278 
1279 void
AcpiDmDumpDmar(ACPI_TABLE_HEADER * Table)1280 AcpiDmDumpDmar (
1281     ACPI_TABLE_HEADER       *Table)
1282 {
1283     ACPI_STATUS             Status;
1284     ACPI_DMAR_HEADER        *Subtable;
1285     UINT32                  Length = Table->Length;
1286     UINT32                  Offset = sizeof (ACPI_TABLE_DMAR);
1287     ACPI_DMTABLE_INFO       *InfoTable;
1288     ACPI_DMAR_DEVICE_SCOPE  *ScopeTable;
1289     UINT32                  ScopeOffset;
1290     UINT8                   *PciPath;
1291     UINT32                  PathOffset;
1292 
1293 
1294     /* Main table */
1295 
1296     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoDmar);
1297     if (ACPI_FAILURE (Status))
1298     {
1299         return;
1300     }
1301 
1302     /* Subtables */
1303 
1304     Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Table, Offset);
1305     while (Offset < Table->Length)
1306     {
1307         /* Common subtable header */
1308 
1309         AcpiOsPrintf ("\n");
1310         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1311             Subtable->Length, AcpiDmTableInfoDmarHdr);
1312         if (ACPI_FAILURE (Status))
1313         {
1314             return;
1315         }
1316 
1317         AcpiOsPrintf ("\n");
1318 
1319         switch (Subtable->Type)
1320         {
1321         case ACPI_DMAR_TYPE_HARDWARE_UNIT:
1322 
1323             InfoTable = AcpiDmTableInfoDmar0;
1324             ScopeOffset = sizeof (ACPI_DMAR_HARDWARE_UNIT);
1325             break;
1326 
1327         case ACPI_DMAR_TYPE_RESERVED_MEMORY:
1328 
1329             InfoTable = AcpiDmTableInfoDmar1;
1330             ScopeOffset = sizeof (ACPI_DMAR_RESERVED_MEMORY);
1331             break;
1332 
1333         case ACPI_DMAR_TYPE_ROOT_ATS:
1334 
1335             InfoTable = AcpiDmTableInfoDmar2;
1336             ScopeOffset = sizeof (ACPI_DMAR_ATSR);
1337             break;
1338 
1339         case ACPI_DMAR_TYPE_HARDWARE_AFFINITY:
1340 
1341             InfoTable = AcpiDmTableInfoDmar3;
1342             ScopeOffset = sizeof (ACPI_DMAR_RHSA);
1343             break;
1344 
1345         case ACPI_DMAR_TYPE_NAMESPACE:
1346 
1347             InfoTable = AcpiDmTableInfoDmar4;
1348             ScopeOffset = sizeof (ACPI_DMAR_ANDD);
1349             break;
1350 
1351         case ACPI_DMAR_TYPE_SATC:
1352 
1353             InfoTable = AcpiDmTableInfoDmar5;
1354             ScopeOffset = sizeof (ACPI_DMAR_SATC);
1355             break;
1356 
1357         default:
1358 
1359             AcpiOsPrintf ("\n**** Unknown DMAR subtable type 0x%X\n\n",
1360                 Subtable->Type);
1361             return;
1362         }
1363 
1364         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1365             Subtable->Length, InfoTable);
1366         if (ACPI_FAILURE (Status))
1367         {
1368             return;
1369         }
1370 
1371         /*
1372          * Dump the optional device scope entries
1373          */
1374         if ((Subtable->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
1375             (Subtable->Type == ACPI_DMAR_TYPE_NAMESPACE))
1376         {
1377             /* These types do not support device scopes */
1378 
1379             goto NextSubtable;
1380         }
1381 
1382         ScopeTable = ACPI_ADD_PTR (ACPI_DMAR_DEVICE_SCOPE, Subtable, ScopeOffset);
1383         while (ScopeOffset < Subtable->Length)
1384         {
1385             AcpiOsPrintf ("\n");
1386             Status = AcpiDmDumpTable (Length, Offset + ScopeOffset, ScopeTable,
1387                 ScopeTable->Length, AcpiDmTableInfoDmarScope);
1388             if (ACPI_FAILURE (Status))
1389             {
1390                 return;
1391             }
1392             AcpiOsPrintf ("\n");
1393 
1394             /* Dump the PCI Path entries for this device scope */
1395 
1396             PathOffset = sizeof (ACPI_DMAR_DEVICE_SCOPE); /* Path entries start at this offset */
1397 
1398             PciPath = ACPI_ADD_PTR (UINT8, ScopeTable,
1399                 sizeof (ACPI_DMAR_DEVICE_SCOPE));
1400 
1401             while (PathOffset < ScopeTable->Length)
1402             {
1403                 AcpiDmLineHeader ((PathOffset + ScopeOffset + Offset), 2,
1404                     "PCI Path");
1405                 AcpiOsPrintf ("%2.2X,%2.2X\n", PciPath[0], PciPath[1]);
1406 
1407                 /* Point to next PCI Path entry */
1408 
1409                 PathOffset += 2;
1410                 PciPath += 2;
1411                 AcpiOsPrintf ("\n");
1412             }
1413 
1414             /* Point to next device scope entry */
1415 
1416             ScopeOffset += ScopeTable->Length;
1417             ScopeTable = ACPI_ADD_PTR (ACPI_DMAR_DEVICE_SCOPE,
1418                 ScopeTable, ScopeTable->Length);
1419         }
1420 
1421 NextSubtable:
1422         /* Point to next subtable */
1423 
1424         Offset += Subtable->Length;
1425         Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Subtable,
1426             Subtable->Length);
1427     }
1428 }
1429 
1430 
1431 /*******************************************************************************
1432  *
1433  * FUNCTION:    AcpiDmDumpDrtm
1434  *
1435  * PARAMETERS:  Table               - A DRTM table
1436  *
1437  * RETURN:      None
1438  *
1439  * DESCRIPTION: Format the contents of a DRTM.
1440  *
1441  ******************************************************************************/
1442 
1443 void
AcpiDmDumpDrtm(ACPI_TABLE_HEADER * Table)1444 AcpiDmDumpDrtm (
1445     ACPI_TABLE_HEADER       *Table)
1446 {
1447     ACPI_STATUS             Status;
1448     UINT32                  Offset;
1449     ACPI_DRTM_VTABLE_LIST   *DrtmVtl;
1450     ACPI_DRTM_RESOURCE_LIST *DrtmRl;
1451     ACPI_DRTM_DPS_ID        *DrtmDps;
1452     UINT32                  Count;
1453 
1454 
1455     /* Main table */
1456 
1457     Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
1458         AcpiDmTableInfoDrtm);
1459     if (ACPI_FAILURE (Status))
1460     {
1461         return;
1462     }
1463 
1464     Offset = sizeof (ACPI_TABLE_DRTM);
1465 
1466     /* Sub-tables */
1467 
1468     /* Dump ValidatedTable length */
1469 
1470     DrtmVtl = ACPI_ADD_PTR (ACPI_DRTM_VTABLE_LIST, Table, Offset);
1471     AcpiOsPrintf ("\n");
1472     Status = AcpiDmDumpTable (Table->Length, Offset,
1473         DrtmVtl, ACPI_OFFSET (ACPI_DRTM_VTABLE_LIST, ValidatedTables),
1474         AcpiDmTableInfoDrtm0);
1475     if (ACPI_FAILURE (Status))
1476     {
1477             return;
1478     }
1479 
1480     Offset += ACPI_OFFSET (ACPI_DRTM_VTABLE_LIST, ValidatedTables);
1481 
1482     /* Dump Validated table addresses */
1483 
1484     Count = 0;
1485     while ((Offset < Table->Length) &&
1486             (DrtmVtl->ValidatedTableCount > Count))
1487     {
1488         Status = AcpiDmDumpTable (Table->Length, Offset,
1489             ACPI_ADD_PTR (void, Table, Offset), sizeof (UINT64),
1490             AcpiDmTableInfoDrtm0a);
1491         if (ACPI_FAILURE (Status))
1492         {
1493             return;
1494         }
1495 
1496         Offset += sizeof (UINT64);
1497         Count++;
1498     }
1499 
1500     /* Dump ResourceList length */
1501 
1502     DrtmRl = ACPI_ADD_PTR (ACPI_DRTM_RESOURCE_LIST, Table, Offset);
1503     AcpiOsPrintf ("\n");
1504     Status = AcpiDmDumpTable (Table->Length, Offset,
1505         DrtmRl, ACPI_OFFSET (ACPI_DRTM_RESOURCE_LIST, Resources),
1506         AcpiDmTableInfoDrtm1);
1507     if (ACPI_FAILURE (Status))
1508     {
1509         return;
1510     }
1511 
1512     Offset += ACPI_OFFSET (ACPI_DRTM_RESOURCE_LIST, Resources);
1513 
1514     /* Dump the Resource List */
1515 
1516     Count = 0;
1517     while ((Offset < Table->Length) &&
1518            (DrtmRl->ResourceCount > Count))
1519     {
1520         Status = AcpiDmDumpTable (Table->Length, Offset,
1521             ACPI_ADD_PTR (void, Table, Offset),
1522             sizeof (ACPI_DRTM_RESOURCE), AcpiDmTableInfoDrtm1a);
1523         if (ACPI_FAILURE (Status))
1524         {
1525             return;
1526         }
1527 
1528         Offset += sizeof (ACPI_DRTM_RESOURCE);
1529         Count++;
1530     }
1531 
1532     /* Dump DPS */
1533 
1534     DrtmDps = ACPI_ADD_PTR (ACPI_DRTM_DPS_ID, Table, Offset);
1535     AcpiOsPrintf ("\n");
1536     (void) AcpiDmDumpTable (Table->Length, Offset,
1537         DrtmDps, sizeof (ACPI_DRTM_DPS_ID), AcpiDmTableInfoDrtm2);
1538 }
1539 
1540 
1541 /*******************************************************************************
1542  *
1543  * FUNCTION:    AcpiDmDumpEinj
1544  *
1545  * PARAMETERS:  Table               - A EINJ table
1546  *
1547  * RETURN:      None
1548  *
1549  * DESCRIPTION: Format the contents of a EINJ. This table type consists
1550  *              of an open-ended number of subtables.
1551  *
1552  ******************************************************************************/
1553 
1554 void
AcpiDmDumpEinj(ACPI_TABLE_HEADER * Table)1555 AcpiDmDumpEinj (
1556     ACPI_TABLE_HEADER       *Table)
1557 {
1558     ACPI_STATUS             Status;
1559     ACPI_WHEA_HEADER        *Subtable;
1560     UINT32                  Length = Table->Length;
1561     UINT32                  Offset = sizeof (ACPI_TABLE_EINJ);
1562 
1563 
1564     /* Main table */
1565 
1566     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoEinj);
1567     if (ACPI_FAILURE (Status))
1568     {
1569         return;
1570     }
1571 
1572     /* Subtables */
1573 
1574     Subtable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Table, Offset);
1575     while (Offset < Table->Length)
1576     {
1577         AcpiOsPrintf ("\n");
1578         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1579             sizeof (ACPI_WHEA_HEADER), AcpiDmTableInfoEinj0);
1580         if (ACPI_FAILURE (Status))
1581         {
1582             return;
1583         }
1584 
1585         /* Point to next subtable (each subtable is of fixed length) */
1586 
1587         Offset += sizeof (ACPI_WHEA_HEADER);
1588         Subtable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Subtable,
1589             sizeof (ACPI_WHEA_HEADER));
1590     }
1591 }
1592 
1593 
1594 /*******************************************************************************
1595  *
1596  * FUNCTION:    AcpiDmDumpErst
1597  *
1598  * PARAMETERS:  Table               - A ERST table
1599  *
1600  * RETURN:      None
1601  *
1602  * DESCRIPTION: Format the contents of a ERST. This table type consists
1603  *              of an open-ended number of subtables.
1604  *
1605  ******************************************************************************/
1606 
1607 void
AcpiDmDumpErst(ACPI_TABLE_HEADER * Table)1608 AcpiDmDumpErst (
1609     ACPI_TABLE_HEADER       *Table)
1610 {
1611     ACPI_STATUS             Status;
1612     ACPI_WHEA_HEADER        *Subtable;
1613     UINT32                  Length = Table->Length;
1614     UINT32                  Offset = sizeof (ACPI_TABLE_ERST);
1615 
1616 
1617     /* Main table */
1618 
1619     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoErst);
1620     if (ACPI_FAILURE (Status))
1621     {
1622         return;
1623     }
1624 
1625     /* Subtables */
1626 
1627     Subtable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Table, Offset);
1628     while (Offset < Table->Length)
1629     {
1630         AcpiOsPrintf ("\n");
1631         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1632             sizeof (ACPI_WHEA_HEADER), AcpiDmTableInfoErst0);
1633         if (ACPI_FAILURE (Status))
1634         {
1635             return;
1636         }
1637 
1638         /* Point to next subtable (each subtable is of fixed length) */
1639 
1640         Offset += sizeof (ACPI_WHEA_HEADER);
1641         Subtable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Subtable,
1642             sizeof (ACPI_WHEA_HEADER));
1643     }
1644 }
1645 
1646 
1647 /*******************************************************************************
1648  *
1649  * FUNCTION:    AcpiDmDumpFpdt
1650  *
1651  * PARAMETERS:  Table               - A FPDT table
1652  *
1653  * RETURN:      None
1654  *
1655  * DESCRIPTION: Format the contents of a FPDT. This table type consists
1656  *              of an open-ended number of subtables.
1657  *
1658  ******************************************************************************/
1659 
1660 void
AcpiDmDumpFpdt(ACPI_TABLE_HEADER * Table)1661 AcpiDmDumpFpdt (
1662     ACPI_TABLE_HEADER       *Table)
1663 {
1664     ACPI_STATUS             Status;
1665     ACPI_FPDT_HEADER        *Subtable;
1666     UINT32                  Length = Table->Length;
1667     UINT32                  Offset = sizeof (ACPI_TABLE_FPDT);
1668     ACPI_DMTABLE_INFO       *InfoTable;
1669 
1670 
1671     /* There is no main table (other than the standard ACPI header) */
1672 
1673     /* Subtables */
1674 
1675     Subtable = ACPI_ADD_PTR (ACPI_FPDT_HEADER, Table, Offset);
1676     while (Offset < Table->Length)
1677     {
1678         /* Common subtable header */
1679 
1680         AcpiOsPrintf ("\n");
1681         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1682             Subtable->Length, AcpiDmTableInfoFpdtHdr);
1683         if (ACPI_FAILURE (Status))
1684         {
1685             return;
1686         }
1687 
1688         switch (Subtable->Type)
1689         {
1690         case ACPI_FPDT_TYPE_BOOT:
1691 
1692             InfoTable = AcpiDmTableInfoFpdt0;
1693             break;
1694 
1695         case ACPI_FPDT_TYPE_S3PERF:
1696 
1697             InfoTable = AcpiDmTableInfoFpdt1;
1698             break;
1699 
1700         default:
1701 
1702             AcpiOsPrintf ("\n**** Unknown FPDT subtable type 0x%X\n\n",
1703                 Subtable->Type);
1704 
1705             /* Attempt to continue */
1706 
1707             if (!Subtable->Length)
1708             {
1709                 AcpiOsPrintf ("Invalid zero length subtable\n");
1710                 return;
1711             }
1712             goto NextSubtable;
1713         }
1714 
1715         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1716             Subtable->Length, InfoTable);
1717         if (ACPI_FAILURE (Status))
1718         {
1719             return;
1720         }
1721 
1722 NextSubtable:
1723         /* Point to next subtable */
1724 
1725         Offset += Subtable->Length;
1726         Subtable = ACPI_ADD_PTR (ACPI_FPDT_HEADER, Subtable,
1727             Subtable->Length);
1728     }
1729 }
1730 
1731 
1732 /*******************************************************************************
1733  *
1734  * FUNCTION:    AcpiDmDumpGtdt
1735  *
1736  * PARAMETERS:  Table               - A GTDT table
1737  *
1738  * RETURN:      None
1739  *
1740  * DESCRIPTION: Format the contents of a GTDT. This table type consists
1741  *              of an open-ended number of subtables.
1742  *
1743  ******************************************************************************/
1744 
1745 void
AcpiDmDumpGtdt(ACPI_TABLE_HEADER * Table)1746 AcpiDmDumpGtdt (
1747     ACPI_TABLE_HEADER       *Table)
1748 {
1749     ACPI_STATUS             Status;
1750     ACPI_GTDT_HEADER        *Subtable;
1751     UINT32                  Length = Table->Length;
1752     UINT32                  Offset = sizeof (ACPI_TABLE_GTDT);
1753     ACPI_DMTABLE_INFO       *InfoTable;
1754     UINT32                  SubtableLength;
1755     UINT32                  GtCount;
1756     ACPI_GTDT_TIMER_ENTRY   *GtxTable;
1757 
1758 
1759     /* Main table */
1760 
1761     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoGtdt);
1762     if (ACPI_FAILURE (Status))
1763     {
1764         return;
1765     }
1766 
1767     /* Rev 3 fields */
1768 
1769     Subtable = ACPI_ADD_PTR (ACPI_GTDT_HEADER, Table, Offset);
1770 
1771     if (Table->Revision > 2)
1772     {
1773         SubtableLength = sizeof (ACPI_GTDT_EL2);
1774         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1775             SubtableLength, AcpiDmTableInfoGtdtEl2);
1776         if (ACPI_FAILURE (Status))
1777         {
1778             return;
1779         }
1780         Offset += SubtableLength;
1781     }
1782 
1783     Subtable = ACPI_ADD_PTR (ACPI_GTDT_HEADER, Table, Offset);
1784 
1785     /* Subtables */
1786 
1787     while (Offset < Table->Length)
1788     {
1789         /* Common subtable header */
1790 
1791         AcpiOsPrintf ("\n");
1792         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1793             Subtable->Length, AcpiDmTableInfoGtdtHdr);
1794         if (ACPI_FAILURE (Status))
1795         {
1796             return;
1797         }
1798 
1799         GtCount = 0;
1800         switch (Subtable->Type)
1801         {
1802         case ACPI_GTDT_TYPE_TIMER_BLOCK:
1803 
1804             SubtableLength = sizeof (ACPI_GTDT_TIMER_BLOCK);
1805             GtCount = (ACPI_CAST_PTR (ACPI_GTDT_TIMER_BLOCK,
1806                 Subtable))->TimerCount;
1807 
1808             InfoTable = AcpiDmTableInfoGtdt0;
1809             break;
1810 
1811         case ACPI_GTDT_TYPE_WATCHDOG:
1812 
1813             SubtableLength = sizeof (ACPI_GTDT_WATCHDOG);
1814 
1815             InfoTable = AcpiDmTableInfoGtdt1;
1816             break;
1817 
1818         default:
1819 
1820             /* Cannot continue on unknown type - no length */
1821 
1822             AcpiOsPrintf ("\n**** Unknown GTDT subtable type 0x%X\n",
1823                 Subtable->Type);
1824             return;
1825         }
1826 
1827         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1828             Subtable->Length, InfoTable);
1829         if (ACPI_FAILURE (Status))
1830         {
1831             return;
1832         }
1833 
1834         /* Point to end of current subtable (each subtable above is of fixed length) */
1835 
1836         Offset += SubtableLength;
1837 
1838         /* If there are any Gt Timer Blocks from above, dump them now */
1839 
1840         if (GtCount)
1841         {
1842             GtxTable = ACPI_ADD_PTR (
1843                 ACPI_GTDT_TIMER_ENTRY, Subtable, SubtableLength);
1844             SubtableLength += GtCount * sizeof (ACPI_GTDT_TIMER_ENTRY);
1845 
1846             while (GtCount)
1847             {
1848                 AcpiOsPrintf ("\n");
1849                 Status = AcpiDmDumpTable (Length, Offset, GtxTable,
1850                     sizeof (ACPI_GTDT_TIMER_ENTRY), AcpiDmTableInfoGtdt0a);
1851                 if (ACPI_FAILURE (Status))
1852                 {
1853                     return;
1854                 }
1855                 Offset += sizeof (ACPI_GTDT_TIMER_ENTRY);
1856                 GtxTable++;
1857                 GtCount--;
1858             }
1859         }
1860 
1861         /* Point to next subtable */
1862 
1863         Subtable = ACPI_ADD_PTR (ACPI_GTDT_HEADER, Subtable, SubtableLength);
1864     }
1865 }
1866 
1867 
1868 /*******************************************************************************
1869  *
1870  * FUNCTION:    AcpiDmDumpHest
1871  *
1872  * PARAMETERS:  Table               - A HEST table
1873  *
1874  * RETURN:      None
1875  *
1876  * DESCRIPTION: Format the contents of a HEST. This table type consists
1877  *              of an open-ended number of subtables.
1878  *
1879  ******************************************************************************/
1880 
1881 void
AcpiDmDumpHest(ACPI_TABLE_HEADER * Table)1882 AcpiDmDumpHest (
1883     ACPI_TABLE_HEADER       *Table)
1884 {
1885     ACPI_STATUS             Status;
1886     ACPI_HEST_HEADER        *Subtable;
1887     UINT32                  Length = Table->Length;
1888     UINT32                  Offset = sizeof (ACPI_TABLE_HEST);
1889     ACPI_DMTABLE_INFO       *InfoTable;
1890     UINT32                  SubtableLength;
1891     UINT32                  BankCount;
1892     ACPI_HEST_IA_ERROR_BANK *BankTable;
1893 
1894 
1895     /* Main table */
1896 
1897     Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHest);
1898     if (ACPI_FAILURE (Status))
1899     {
1900         return;
1901     }
1902 
1903     /* Subtables */
1904 
1905     Subtable = ACPI_ADD_PTR (ACPI_HEST_HEADER, Table, Offset);
1906     while (Offset < Table->Length)
1907     {
1908         BankCount = 0;
1909         switch (Subtable->Type)
1910         {
1911         case ACPI_HEST_TYPE_IA32_CHECK:
1912 
1913             InfoTable = AcpiDmTableInfoHest0;
1914             SubtableLength = sizeof (ACPI_HEST_IA_MACHINE_CHECK);
1915             BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_MACHINE_CHECK,
1916                 Subtable))->NumHardwareBanks;
1917             break;
1918 
1919         case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK:
1920 
1921             InfoTable = AcpiDmTableInfoHest1;
1922             SubtableLength = sizeof (ACPI_HEST_IA_CORRECTED);
1923             BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_CORRECTED,
1924                 Subtable))->NumHardwareBanks;
1925             break;
1926 
1927         case ACPI_HEST_TYPE_IA32_NMI:
1928 
1929             InfoTable = AcpiDmTableInfoHest2;
1930             SubtableLength = sizeof (ACPI_HEST_IA_NMI);
1931             break;
1932 
1933         case ACPI_HEST_TYPE_AER_ROOT_PORT:
1934 
1935             InfoTable = AcpiDmTableInfoHest6;
1936             SubtableLength = sizeof (ACPI_HEST_AER_ROOT);
1937             break;
1938 
1939         case ACPI_HEST_TYPE_AER_ENDPOINT:
1940 
1941             InfoTable = AcpiDmTableInfoHest7;
1942             SubtableLength = sizeof (ACPI_HEST_AER);
1943             break;
1944 
1945         case ACPI_HEST_TYPE_AER_BRIDGE:
1946 
1947             InfoTable = AcpiDmTableInfoHest8;
1948             SubtableLength = sizeof (ACPI_HEST_AER_BRIDGE);
1949             break;
1950 
1951         case ACPI_HEST_TYPE_GENERIC_ERROR:
1952 
1953             InfoTable = AcpiDmTableInfoHest9;
1954             SubtableLength = sizeof (ACPI_HEST_GENERIC);
1955             break;
1956 
1957         case ACPI_HEST_TYPE_GENERIC_ERROR_V2:
1958 
1959             InfoTable = AcpiDmTableInfoHest10;
1960             SubtableLength = sizeof (ACPI_HEST_GENERIC_V2);
1961             break;
1962 
1963         case ACPI_HEST_TYPE_IA32_DEFERRED_CHECK:
1964 
1965             InfoTable = AcpiDmTableInfoHest11;
1966             SubtableLength = sizeof (ACPI_HEST_IA_DEFERRED_CHECK);
1967             BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_DEFERRED_CHECK,
1968                 Subtable))->NumHardwareBanks;
1969             break;
1970 
1971         default:
1972 
1973             /* Cannot continue on unknown type - no length */
1974 
1975             AcpiOsPrintf ("\n**** Unknown HEST subtable type 0x%X\n",
1976                 Subtable->Type);
1977             return;
1978         }
1979 
1980         AcpiOsPrintf ("\n");
1981         Status = AcpiDmDumpTable (Length, Offset, Subtable,
1982             SubtableLength, InfoTable);
1983         if (ACPI_FAILURE (Status))
1984         {
1985             return;
1986         }
1987 
1988         /* Point to end of current subtable (each subtable above is of fixed length) */
1989 
1990         Offset += SubtableLength;
1991 
1992         /* If there are any (fixed-length) Error Banks from above, dump them now */
1993 
1994         if (BankCount)
1995         {
1996             BankTable = ACPI_ADD_PTR (ACPI_HEST_IA_ERROR_BANK, Subtable,
1997                 SubtableLength);
1998             SubtableLength += BankCount * sizeof (ACPI_HEST_IA_ERROR_BANK);
1999 
2000             while (BankCount)
2001             {
2002                 AcpiOsPrintf ("\n");
2003                 Status = AcpiDmDumpTable (Length, Offset, BankTable,
2004                     sizeof (ACPI_HEST_IA_ERROR_BANK), AcpiDmTableInfoHestBank);
2005                 if (ACPI_FAILURE (Status))
2006                 {
2007                     return;
2008                 }
2009 
2010                 Offset += sizeof (ACPI_HEST_IA_ERROR_BANK);
2011                 BankTable++;
2012                 BankCount--;
2013             }
2014         }
2015 
2016         /* Point to next subtable */
2017 
2018         Subtable = ACPI_ADD_PTR (ACPI_HEST_HEADER, Subtable, SubtableLength);
2019     }
2020 }
2021 
2022 
2023 /*******************************************************************************
2024  *
2025  * FUNCTION:    AcpiDmDumpHmat
2026  *
2027  * PARAMETERS:  Table               - A HMAT table
2028  *
2029  * RETURN:      None
2030  *
2031  * DESCRIPTION: Format the contents of a HMAT.
2032  *
2033  ******************************************************************************/
2034 
2035 void
AcpiDmDumpHmat(ACPI_TABLE_HEADER * Table)2036 AcpiDmDumpHmat (
2037     ACPI_TABLE_HEADER       *Table)
2038 {
2039     ACPI_STATUS             Status;
2040     ACPI_HMAT_STRUCTURE     *HmatStruct;
2041     ACPI_HMAT_LOCALITY      *HmatLocality;
2042     ACPI_HMAT_CACHE         *HmatCache;
2043     UINT32                  Offset;
2044     UINT32                  SubtableOffset;
2045     UINT32                  Length;
2046     ACPI_DMTABLE_INFO       *InfoTable;
2047     UINT32                  i, j;
2048 
2049 
2050     /* Main table */
2051 
2052     Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoHmat);
2053     if (ACPI_FAILURE (Status))
2054     {
2055         return;
2056     }
2057     Offset = sizeof (ACPI_TABLE_HMAT);
2058 
2059     while (Offset < Table->Length)
2060     {
2061         AcpiOsPrintf ("\n");
2062 
2063         /* Dump HMAT structure header */
2064 
2065         HmatStruct = ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, Table, Offset);
2066         if (HmatStruct->Length < sizeof (ACPI_HMAT_STRUCTURE))
2067         {
2068             AcpiOsPrintf ("Invalid HMAT structure length\n");
2069             return;
2070         }
2071         Status = AcpiDmDumpTable (Table->Length, Offset, HmatStruct,
2072             HmatStruct->Length, AcpiDmTableInfoHmatHdr);
2073         if (ACPI_FAILURE (Status))
2074         {
2075             return;
2076         }
2077 
2078         switch (HmatStruct->Type)
2079         {
2080         case ACPI_HMAT_TYPE_ADDRESS_RANGE:
2081 
2082             InfoTable = AcpiDmTableInfoHmat0;
2083             Length = sizeof (ACPI_HMAT_PROXIMITY_DOMAIN);
2084             break;
2085 
2086         case ACPI_HMAT_TYPE_LOCALITY:
2087 
2088             InfoTable = AcpiDmTableInfoHmat1;
2089             Length = sizeof (ACPI_HMAT_LOCALITY);
2090             break;
2091 
2092         case ACPI_HMAT_TYPE_CACHE:
2093 
2094             InfoTable = AcpiDmTableInfoHmat2;
2095             Length = sizeof (ACPI_HMAT_CACHE);
2096             break;
2097 
2098         default:
2099 
2100             AcpiOsPrintf ("\n**** Unknown HMAT structure type 0x%X\n",
2101                 HmatStruct->Type);
2102 
2103             /* Attempt to continue */
2104 
2105             goto NextSubtable;
2106         }
2107 
2108         /* Dump HMAT structure body */
2109 
2110         if (HmatStruct->Length < Length)
2111         {
2112             AcpiOsPrintf ("Invalid HMAT structure length\n");
2113             return;
2114         }
2115         Status = AcpiDmDumpTable (Table->Length, Offset, HmatStruct,
2116             HmatStruct->Length, InfoTable);
2117         if (ACPI_FAILURE (Status))
2118         {
2119             return;
2120         }
2121 
2122         /* Dump HMAT structure additional */
2123 
2124         switch (HmatStruct->Type)
2125         {
2126         case ACPI_HMAT_TYPE_LOCALITY:
2127 
2128             HmatLocality = ACPI_CAST_PTR (ACPI_HMAT_LOCALITY, HmatStruct);
2129             SubtableOffset = sizeof (ACPI_HMAT_LOCALITY);
2130 
2131             /* Dump initiator proximity domains */
2132 
2133             if ((UINT32)(HmatStruct->Length - SubtableOffset) <
2134                 (UINT32)(HmatLocality->NumberOfInitiatorPDs * 4))
2135             {
2136                 AcpiOsPrintf ("Invalid initiator proximity domain number\n");
2137                 return;
2138             }
2139             for (i = 0; i < HmatLocality->NumberOfInitiatorPDs; i++)
2140             {
2141                 Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
2142                     ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
2143                     4, AcpiDmTableInfoHmat1a);
2144                 if (ACPI_FAILURE (Status))
2145                 {
2146                     return;
2147                 }
2148 
2149                 SubtableOffset += 4;
2150             }
2151 
2152             /* Dump target proximity domains */
2153 
2154             if ((UINT32)(HmatStruct->Length - SubtableOffset) <
2155                 (UINT32)(HmatLocality->NumberOfTargetPDs * 4))
2156             {
2157                 AcpiOsPrintf ("Invalid target proximity domain number\n");
2158                 return;
2159             }
2160             for (i = 0; i < HmatLocality->NumberOfTargetPDs; i++)
2161             {
2162                 Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
2163                     ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
2164                     4, AcpiDmTableInfoHmat1b);
2165                 if (ACPI_FAILURE (Status))
2166                 {
2167                     return;
2168                 }
2169 
2170                 SubtableOffset += 4;
2171             }
2172 
2173             /* Dump latency/bandwidth entris */
2174 
2175             if ((UINT32)(HmatStruct->Length - SubtableOffset) <
2176                 (UINT32)(HmatLocality->NumberOfInitiatorPDs *
2177                          HmatLocality->NumberOfTargetPDs * 2))
2178             {
2179                 AcpiOsPrintf ("Invalid latency/bandwidth entry number\n");
2180                 return;
2181             }
2182             for (i = 0; i < HmatLocality->NumberOfInitiatorPDs; i++)
2183             {
2184                 for (j = 0; j < HmatLocality->NumberOfTargetPDs; j++)
2185                 {
2186                     Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
2187                         ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
2188                         2, AcpiDmTableInfoHmat1c);
2189                     if (ACPI_FAILURE(Status))
2190                     {
2191                         return;
2192                     }
2193 
2194                     SubtableOffset += 2;
2195                 }
2196             }
2197             break;
2198 
2199         case ACPI_HMAT_TYPE_CACHE:
2200 
2201             HmatCache = ACPI_CAST_PTR (ACPI_HMAT_CACHE, HmatStruct);
2202             SubtableOffset = sizeof (ACPI_HMAT_CACHE);
2203 
2204             /* Dump SMBIOS handles */
2205 
2206             if ((UINT32)(HmatStruct->Length - SubtableOffset) <
2207                 (UINT32)(HmatCache->NumberOfSMBIOSHandles * 2))
2208             {
2209                 AcpiOsPrintf ("Invalid SMBIOS handle number\n");
2210                 return;
2211             }
2212             for (i = 0; i < HmatCache->NumberOfSMBIOSHandles; i++)
2213             {
2214                 Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
2215                     ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
2216                     2, AcpiDmTableInfoHmat2a);
2217                 if (ACPI_FAILURE (Status))
2218                 {
2219                     return;
2220                 }
2221 
2222                 SubtableOffset += 2;
2223             }
2224             break;
2225 
2226         default:
2227 
2228             break;
2229         }
2230 
2231 NextSubtable:
2232         /* Point to next HMAT structure subtable */
2233 
2234         Offset += (HmatStruct->Length);
2235     }
2236 }
2237