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