dmtbdump3.c revision 1.1.1.7 1 /******************************************************************************
2 *
3 * Module Name: dmtbdump3 - Dump ACPI data tables that contain no AML code
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2021, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44 #include "acpi.h"
45 #include "accommon.h"
46 #include "acdisasm.h"
47 #include "actables.h"
48
49 /* This module used for application-level code only */
50
51 #define _COMPONENT ACPI_CA_DISASSEMBLER
52 ACPI_MODULE_NAME ("dmtbdump3")
53
54
55 /*******************************************************************************
56 *
57 * FUNCTION: AcpiDmDumpSlic
58 *
59 * PARAMETERS: Table - A SLIC table
60 *
61 * RETURN: None
62 *
63 * DESCRIPTION: Format the contents of a SLIC
64 *
65 ******************************************************************************/
66
67 void
68 AcpiDmDumpSlic (
69 ACPI_TABLE_HEADER *Table)
70 {
71
72 (void) AcpiDmDumpTable (Table->Length, sizeof (ACPI_TABLE_HEADER), Table,
73 Table->Length - sizeof (*Table), AcpiDmTableInfoSlic);
74 }
75
76
77 /*******************************************************************************
78 *
79 * FUNCTION: AcpiDmDumpSlit
80 *
81 * PARAMETERS: Table - An SLIT
82 *
83 * RETURN: None
84 *
85 * DESCRIPTION: Format the contents of a SLIT
86 *
87 ******************************************************************************/
88
89 void
90 AcpiDmDumpSlit (
91 ACPI_TABLE_HEADER *Table)
92 {
93 ACPI_STATUS Status;
94 UINT32 Offset;
95 UINT8 *Row;
96 UINT32 Localities;
97 UINT32 i;
98 UINT32 j;
99
100
101 /* Main table */
102
103 Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoSlit);
104 if (ACPI_FAILURE (Status))
105 {
106 return;
107 }
108
109 /* Display the Locality NxN Matrix */
110
111 Localities = (UINT32) ACPI_CAST_PTR (ACPI_TABLE_SLIT, Table)->LocalityCount;
112 Offset = ACPI_OFFSET (ACPI_TABLE_SLIT, Entry[0]);
113 Row = (UINT8 *) ACPI_CAST_PTR (ACPI_TABLE_SLIT, Table)->Entry;
114
115 for (i = 0; i < Localities; i++)
116 {
117 /* Display one row of the matrix */
118
119 AcpiDmLineHeader2 (Offset, Localities, "Locality", i);
120 for (j = 0; j < Localities; j++)
121 {
122 /* Check for beyond EOT */
123
124 if (Offset >= Table->Length)
125 {
126 AcpiOsPrintf (
127 "\n**** Not enough room in table for all localities\n");
128 return;
129 }
130
131 AcpiOsPrintf ("%2.2X", Row[j]);
132 Offset++;
133
134 /* Display up to 16 bytes per output row */
135
136 if ((j+1) < Localities)
137 {
138 AcpiOsPrintf (" ");
139
140 if (j && (((j+1) % 16) == 0))
141 {
142 AcpiOsPrintf ("\\\n"); /* With line continuation char */
143 AcpiDmLineHeader (Offset, 0, NULL);
144 }
145 }
146 }
147
148 /* Point to next row */
149
150 AcpiOsPrintf ("\n");
151 Row += Localities;
152 }
153 }
154
155
156 /*******************************************************************************
157 *
158 * FUNCTION: AcpiDmDumpSrat
159 *
160 * PARAMETERS: Table - A SRAT table
161 *
162 * RETURN: None
163 *
164 * DESCRIPTION: Format the contents of a SRAT
165 *
166 ******************************************************************************/
167
168 void
169 AcpiDmDumpSrat (
170 ACPI_TABLE_HEADER *Table)
171 {
172 ACPI_STATUS Status;
173 UINT32 Offset = sizeof (ACPI_TABLE_SRAT);
174 ACPI_SUBTABLE_HEADER *Subtable;
175 ACPI_DMTABLE_INFO *InfoTable;
176
177
178 /* Main table */
179
180 Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoSrat);
181 if (ACPI_FAILURE (Status))
182 {
183 return;
184 }
185
186 /* Subtables */
187
188 Subtable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, Table, Offset);
189 while (Offset < Table->Length)
190 {
191 /* Common subtable header */
192
193 AcpiOsPrintf ("\n");
194 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
195 Subtable->Length, AcpiDmTableInfoSratHdr);
196 if (ACPI_FAILURE (Status))
197 {
198 return;
199 }
200
201 switch (Subtable->Type)
202 {
203 case ACPI_SRAT_TYPE_CPU_AFFINITY:
204
205 InfoTable = AcpiDmTableInfoSrat0;
206 break;
207
208 case ACPI_SRAT_TYPE_MEMORY_AFFINITY:
209
210 InfoTable = AcpiDmTableInfoSrat1;
211 break;
212
213 case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY:
214
215 InfoTable = AcpiDmTableInfoSrat2;
216 break;
217
218 case ACPI_SRAT_TYPE_GICC_AFFINITY:
219
220 InfoTable = AcpiDmTableInfoSrat3;
221 break;
222
223 case ACPI_SRAT_TYPE_GIC_ITS_AFFINITY:
224
225 InfoTable = AcpiDmTableInfoSrat4;
226 break;
227
228 case ACPI_SRAT_TYPE_GENERIC_AFFINITY:
229
230 InfoTable = AcpiDmTableInfoSrat5;
231 break;
232
233 default:
234 AcpiOsPrintf ("\n**** Unknown SRAT subtable type 0x%X\n",
235 Subtable->Type);
236
237 /* Attempt to continue */
238
239 if (!Subtable->Length)
240 {
241 AcpiOsPrintf ("Invalid zero length subtable\n");
242 return;
243 }
244 goto NextSubtable;
245 }
246
247 AcpiOsPrintf ("\n");
248 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
249 Subtable->Length, InfoTable);
250 if (ACPI_FAILURE (Status))
251 {
252 return;
253 }
254
255 NextSubtable:
256 /* Point to next subtable */
257
258 Offset += Subtable->Length;
259 Subtable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, Subtable,
260 Subtable->Length);
261 }
262 }
263
264
265 /*******************************************************************************
266 *
267 * FUNCTION: AcpiDmDumpStao
268 *
269 * PARAMETERS: Table - A STAO table
270 *
271 * RETURN: None
272 *
273 * DESCRIPTION: Format the contents of a STAO. This is a variable-length
274 * table that contains an open-ended number of ASCII strings
275 * at the end of the table.
276 *
277 ******************************************************************************/
278
279 void
280 AcpiDmDumpStao (
281 ACPI_TABLE_HEADER *Table)
282 {
283 ACPI_STATUS Status;
284 char *Namepath;
285 UINT32 Length = Table->Length;
286 UINT32 StringLength;
287 UINT32 Offset = sizeof (ACPI_TABLE_STAO);
288
289
290 /* Main table */
291
292 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoStao);
293 if (ACPI_FAILURE (Status))
294 {
295 return;
296 }
297
298 /* The rest of the table consists of Namepath strings */
299
300 while (Offset < Table->Length)
301 {
302 Namepath = ACPI_ADD_PTR (char, Table, Offset);
303 StringLength = strlen (Namepath) + 1;
304
305 AcpiDmLineHeader (Offset, StringLength, "Namepath");
306 AcpiOsPrintf ("\"%s\"\n", Namepath);
307
308 /* Point to next namepath */
309
310 Offset += StringLength;
311 }
312 }
313
314
315 /*******************************************************************************
316 *
317 * FUNCTION: AcpiDmDumpSvkl
318 *
319 * PARAMETERS: Table - A SVKL table
320 *
321 * RETURN: None
322 *
323 * DESCRIPTION: Format the contents of a SVKL. This is a variable-length
324 * table that contains an open-ended number of key subtables at
325 * the end of the header.
326 *
327 * NOTES: SVKL is essentially a flat table, with a small main table and
328 * a variable number of a single type of subtable.
329 *
330 ******************************************************************************/
331
332 void
333 AcpiDmDumpSvkl (
334 ACPI_TABLE_HEADER *Table)
335 {
336 ACPI_STATUS Status;
337 UINT32 Length = Table->Length;
338 UINT32 Offset = sizeof (ACPI_TABLE_SVKL);
339 ACPI_SVKL_KEY *Subtable;
340
341
342 /* Main table */
343
344 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoSvkl);
345 if (ACPI_FAILURE (Status))
346 {
347 return;
348 }
349
350 /* The rest of the table consists of subtables (single type) */
351
352 Subtable = ACPI_ADD_PTR (ACPI_SVKL_KEY, Table, Offset);
353 while (Offset < Table->Length)
354 {
355 /* Dump the subtable */
356
357 AcpiOsPrintf ("\n");
358 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
359 sizeof (ACPI_SVKL_KEY), AcpiDmTableInfoSvkl0);
360 if (ACPI_FAILURE (Status))
361 {
362 return;
363 }
364
365 /* Point to next subtable */
366
367 Offset += sizeof (ACPI_SVKL_KEY);
368 Subtable = ACPI_ADD_PTR (ACPI_SVKL_KEY, Subtable,
369 sizeof (ACPI_SVKL_KEY));
370 }
371 }
372
373
374 /*******************************************************************************
375 *
376 * FUNCTION: AcpiDmDumpTcpa
377 *
378 * PARAMETERS: Table - A TCPA table
379 *
380 * RETURN: None
381 *
382 * DESCRIPTION: Format the contents of a TCPA.
383 *
384 * NOTE: There are two versions of the table with the same signature:
385 * the client version and the server version. The common
386 * PlatformClass field is used to differentiate the two types of
387 * tables.
388 *
389 ******************************************************************************/
390
391 void
392 AcpiDmDumpTcpa (
393 ACPI_TABLE_HEADER *Table)
394 {
395 UINT32 Offset = sizeof (ACPI_TABLE_TCPA_HDR);
396 ACPI_TABLE_TCPA_HDR *CommonHeader = ACPI_CAST_PTR (
397 ACPI_TABLE_TCPA_HDR, Table);
398 ACPI_TABLE_TCPA_HDR *Subtable = ACPI_ADD_PTR (
399 ACPI_TABLE_TCPA_HDR, Table, Offset);
400 ACPI_STATUS Status;
401
402
403 /* Main table */
404
405 Status = AcpiDmDumpTable (Table->Length, 0, Table,
406 0, AcpiDmTableInfoTcpaHdr);
407 if (ACPI_FAILURE (Status))
408 {
409 return;
410 }
411
412 /*
413 * Examine the PlatformClass field to determine the table type.
414 * Either a client or server table. Only one.
415 */
416 switch (CommonHeader->PlatformClass)
417 {
418 case ACPI_TCPA_CLIENT_TABLE:
419
420 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
421 Table->Length - Offset, AcpiDmTableInfoTcpaClient);
422 break;
423
424 case ACPI_TCPA_SERVER_TABLE:
425
426 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
427 Table->Length - Offset, AcpiDmTableInfoTcpaServer);
428 break;
429
430 default:
431
432 AcpiOsPrintf ("\n**** Unknown TCPA Platform Class 0x%X\n",
433 CommonHeader->PlatformClass);
434 Status = AE_ERROR;
435 break;
436 }
437
438 if (ACPI_FAILURE (Status))
439 {
440 AcpiOsPrintf ("\n**** Cannot disassemble TCPA table\n");
441 }
442 }
443
444
445 /*******************************************************************************
446 *
447 * FUNCTION: AcpiDmDumpTpm2
448 *
449 * PARAMETERS: Table - A TPM2 table
450 *
451 * RETURN: None
452 *
453 * DESCRIPTION: Format the contents of a TPM2.
454 *
455 ******************************************************************************/
456
457 static void
458 AcpiDmDumpTpm2Rev3 (
459 ACPI_TABLE_HEADER *Table)
460 {
461 UINT32 Offset = sizeof (ACPI_TABLE_TPM23);
462 ACPI_TABLE_TPM23 *CommonHeader = ACPI_CAST_PTR (ACPI_TABLE_TPM23, Table);
463 ACPI_TPM23_TRAILER *Subtable = ACPI_ADD_PTR (ACPI_TPM23_TRAILER, Table, Offset);
464 ACPI_STATUS Status;
465
466
467 /* Main table */
468
469 Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoTpm23);
470 if (ACPI_FAILURE (Status))
471 {
472 return;
473 }
474
475 /* Optional subtable if start method is ACPI start method */
476
477 switch (CommonHeader->StartMethod)
478 {
479 case ACPI_TPM23_ACPI_START_METHOD:
480
481 (void) AcpiDmDumpTable (Table->Length, Offset, Subtable,
482 Table->Length - Offset, AcpiDmTableInfoTpm23a);
483 break;
484
485 default:
486 break;
487 }
488 }
489
490
491 /*******************************************************************************
492 *
493 * FUNCTION: AcpiDmDumpTpm2
494 *
495 * PARAMETERS: Table - A TPM2 table
496 *
497 * RETURN: None
498 *
499 * DESCRIPTION: Format the contents of a TPM2.
500 *
501 ******************************************************************************/
502
503 void
504 AcpiDmDumpTpm2 (
505 ACPI_TABLE_HEADER *Table)
506 {
507 UINT32 Offset = sizeof (ACPI_TABLE_TPM2);
508 ACPI_TABLE_TPM2 *CommonHeader = ACPI_CAST_PTR (ACPI_TABLE_TPM2, Table);
509 ACPI_TPM2_TRAILER *Subtable = ACPI_ADD_PTR (ACPI_TPM2_TRAILER, Table, Offset);
510 ACPI_TPM2_ARM_SMC *ArmSubtable;
511 ACPI_STATUS Status;
512
513
514 if (Table->Revision == 3)
515 {
516 AcpiDmDumpTpm2Rev3(Table);
517 return;
518 }
519
520 /* Main table */
521
522 Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoTpm2);
523
524 if (ACPI_FAILURE (Status))
525 {
526 return;
527 }
528
529 AcpiOsPrintf ("\n");
530 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
531 Table->Length - Offset, AcpiDmTableInfoTpm2a);
532 if (ACPI_FAILURE (Status))
533 {
534 return;
535 }
536
537 switch (CommonHeader->StartMethod)
538 {
539 case ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC:
540
541 ArmSubtable = ACPI_ADD_PTR (ACPI_TPM2_ARM_SMC, Subtable,
542 sizeof (ACPI_TPM2_TRAILER));
543 Offset += sizeof (ACPI_TPM2_TRAILER);
544
545 AcpiOsPrintf ("\n");
546 (void) AcpiDmDumpTable (Table->Length, Offset, ArmSubtable,
547 Table->Length - Offset, AcpiDmTableInfoTpm211);
548 break;
549
550 default:
551 break;
552 }
553 }
554
555
556 /*******************************************************************************
557 *
558 * FUNCTION: AcpiDmDumpViot
559 *
560 * PARAMETERS: Table - A VIOT table
561 *
562 * RETURN: None
563 *
564 * DESCRIPTION: Format the contents of a VIOT
565 *
566 ******************************************************************************/
567
568 void
569 AcpiDmDumpViot (
570 ACPI_TABLE_HEADER *Table)
571 {
572 ACPI_STATUS Status;
573 ACPI_TABLE_VIOT *Viot;
574 ACPI_VIOT_HEADER *ViotHeader;
575 UINT16 Length;
576 UINT16 Offset;
577 ACPI_DMTABLE_INFO *InfoTable;
578
579 /* Main table */
580
581 Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoViot);
582 if (ACPI_FAILURE (Status))
583 {
584 return;
585 }
586
587 Viot = ACPI_CAST_PTR (ACPI_TABLE_VIOT, Table);
588
589 Offset = Viot->NodeOffset;
590 while (Offset < Table->Length)
591 {
592 /* Common subtable header */
593 ViotHeader = ACPI_ADD_PTR (ACPI_VIOT_HEADER, Table, Offset);
594 AcpiOsPrintf ("\n");
595
596 Length = sizeof (ACPI_VIOT_HEADER);
597 Status = AcpiDmDumpTable (Table->Length, Offset, ViotHeader, Length,
598 AcpiDmTableInfoViotHeader);
599 if (ACPI_FAILURE (Status))
600 {
601 return;
602 }
603
604 Length = ViotHeader->Length;
605 switch (ViotHeader->Type)
606 {
607 case ACPI_VIOT_NODE_PCI_RANGE:
608
609 InfoTable = AcpiDmTableInfoViot1;
610 break;
611
612 case ACPI_VIOT_NODE_MMIO:
613
614 InfoTable = AcpiDmTableInfoViot2;
615 break;
616
617 case ACPI_VIOT_NODE_VIRTIO_IOMMU_PCI:
618
619 InfoTable = AcpiDmTableInfoViot3;
620 break;
621
622 case ACPI_VIOT_NODE_VIRTIO_IOMMU_MMIO:
623
624 InfoTable = AcpiDmTableInfoViot4;
625 break;
626
627 default:
628
629 AcpiOsPrintf ("\n*** Unknown VIOT node type 0x%X\n",
630 ViotHeader->Type);
631
632 /* Attempt to continue */
633
634 if (!Length)
635 {
636 AcpiOsPrintf ("Invalid zero length VIOT node\n");
637 return;
638 }
639 goto NextSubtable;
640 }
641
642 AcpiOsPrintf ("\n");
643 Status = AcpiDmDumpTable (Table->Length, Offset, ViotHeader, Length,
644 InfoTable);
645 if (ACPI_FAILURE (Status))
646 {
647 return;
648 }
649
650 NextSubtable:
651 Offset += Length;
652 }
653 }
654
655
656 /*******************************************************************************
657 *
658 * FUNCTION: AcpiDmDumpWdat
659 *
660 * PARAMETERS: Table - A WDAT table
661 *
662 * RETURN: None
663 *
664 * DESCRIPTION: Format the contents of a WDAT
665 *
666 ******************************************************************************/
667
668 void
669 AcpiDmDumpWdat (
670 ACPI_TABLE_HEADER *Table)
671 {
672 ACPI_STATUS Status;
673 UINT32 Offset = sizeof (ACPI_TABLE_WDAT);
674 ACPI_WDAT_ENTRY *Subtable;
675
676
677 /* Main table */
678
679 Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoWdat);
680 if (ACPI_FAILURE (Status))
681 {
682 return;
683 }
684
685 /* Subtables */
686
687 Subtable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, Table, Offset);
688 while (Offset < Table->Length)
689 {
690 /* Common subtable header */
691
692 AcpiOsPrintf ("\n");
693 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
694 sizeof (ACPI_WDAT_ENTRY), AcpiDmTableInfoWdat0);
695 if (ACPI_FAILURE (Status))
696 {
697 return;
698 }
699
700 /* Point to next subtable */
701
702 Offset += sizeof (ACPI_WDAT_ENTRY);
703 Subtable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, Subtable,
704 sizeof (ACPI_WDAT_ENTRY));
705 }
706 }
707
708
709 /*******************************************************************************
710 *
711 * FUNCTION: AcpiDmDumpWpbt
712 *
713 * PARAMETERS: Table - A WPBT table
714 *
715 * RETURN: None
716 *
717 * DESCRIPTION: Format the contents of a WPBT. This table type consists
718 * of an open-ended arguments buffer at the end of the table.
719 *
720 ******************************************************************************/
721
722 void
723 AcpiDmDumpWpbt (
724 ACPI_TABLE_HEADER *Table)
725 {
726 ACPI_STATUS Status;
727 ACPI_TABLE_WPBT *Subtable;
728 UINT32 Length = Table->Length;
729 UINT16 ArgumentsLength;
730
731
732 /* Dump the main table */
733
734 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoWpbt);
735 if (ACPI_FAILURE (Status))
736 {
737 return;
738 }
739
740 /* Extract the arguments buffer length from the main table */
741
742 Subtable = ACPI_CAST_PTR (ACPI_TABLE_WPBT, Table);
743 ArgumentsLength = Subtable->ArgumentsLength;
744
745 /* Dump the arguments buffer */
746
747 (void) AcpiDmDumpTable (Table->Length, 0, Table, ArgumentsLength,
748 AcpiDmTableInfoWpbt0);
749 }
750