dmtbdump3.c revision 1.1.1.3 1 /******************************************************************************
2 *
3 * Module Name: dmtbdump3 - Dump ACPI data tables that contain no AML code
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2019, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44 #include "acpi.h"
45 #include "accommon.h"
46 #include "acdisasm.h"
47 #include "actables.h"
48
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, "Namestring");
306 AcpiOsPrintf ("\"%s\"\n", Namepath);
307
308 /* Point to next namepath */
309
310 Offset += StringLength;
311 }
312 }
313
314
315 /*******************************************************************************
316 *
317 * FUNCTION: AcpiDmDumpTcpa
318 *
319 * PARAMETERS: Table - A TCPA table
320 *
321 * RETURN: None
322 *
323 * DESCRIPTION: Format the contents of a TCPA.
324 *
325 * NOTE: There are two versions of the table with the same signature:
326 * the client version and the server version. The common
327 * PlatformClass field is used to differentiate the two types of
328 * tables.
329 *
330 ******************************************************************************/
331
332 void
333 AcpiDmDumpTcpa (
334 ACPI_TABLE_HEADER *Table)
335 {
336 UINT32 Offset = sizeof (ACPI_TABLE_TCPA_HDR);
337 ACPI_TABLE_TCPA_HDR *CommonHeader = ACPI_CAST_PTR (
338 ACPI_TABLE_TCPA_HDR, Table);
339 ACPI_TABLE_TCPA_HDR *Subtable = ACPI_ADD_PTR (
340 ACPI_TABLE_TCPA_HDR, Table, Offset);
341 ACPI_STATUS Status;
342
343
344 /* Main table */
345
346 Status = AcpiDmDumpTable (Table->Length, 0, Table,
347 0, AcpiDmTableInfoTcpaHdr);
348 if (ACPI_FAILURE (Status))
349 {
350 return;
351 }
352
353 /*
354 * Examine the PlatformClass field to determine the table type.
355 * Either a client or server table. Only one.
356 */
357 switch (CommonHeader->PlatformClass)
358 {
359 case ACPI_TCPA_CLIENT_TABLE:
360
361 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
362 Table->Length - Offset, AcpiDmTableInfoTcpaClient);
363 break;
364
365 case ACPI_TCPA_SERVER_TABLE:
366
367 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
368 Table->Length - Offset, AcpiDmTableInfoTcpaServer);
369 break;
370
371 default:
372
373 AcpiOsPrintf ("\n**** Unknown TCPA Platform Class 0x%X\n",
374 CommonHeader->PlatformClass);
375 Status = AE_ERROR;
376 break;
377 }
378
379 if (ACPI_FAILURE (Status))
380 {
381 AcpiOsPrintf ("\n**** Cannot disassemble TCPA table\n");
382 }
383 }
384
385
386 /*******************************************************************************
387 *
388 * FUNCTION: AcpiDmDumpTpm2
389 *
390 * PARAMETERS: Table - A TPM2 table
391 *
392 * RETURN: None
393 *
394 * DESCRIPTION: Format the contents of a TPM2.
395 *
396 ******************************************************************************/
397 static void
398 AcpiDmDumpTpm2Rev3 (
399 ACPI_TABLE_HEADER *Table)
400 {
401 UINT32 Offset = sizeof (ACPI_TABLE_TPM23);
402 ACPI_TABLE_TPM23 *CommonHeader = ACPI_CAST_PTR (ACPI_TABLE_TPM23, Table);
403 ACPI_TPM23_TRAILER *Subtable = ACPI_ADD_PTR (ACPI_TPM23_TRAILER, Table, Offset);
404 ACPI_STATUS Status;
405
406
407 /* Main table */
408
409 Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoTpm23);
410 if (ACPI_FAILURE (Status))
411 {
412 return;
413 }
414
415 /* Optional subtable if start method is ACPI start method */
416
417 switch (CommonHeader->StartMethod)
418 {
419 case ACPI_TPM23_ACPI_START_METHOD:
420
421 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
422 Table->Length - Offset, AcpiDmTableInfoTpm23a);
423 break;
424
425 default:
426 break;
427 }
428 }
429
430
431 /*******************************************************************************
432 *
433 * FUNCTION: AcpiDmDumpTpm2
434 *
435 * PARAMETERS: Table - A TPM2 table
436 *
437 * RETURN: None
438 *
439 * DESCRIPTION: Format the contents of a TPM2.
440 *
441 ******************************************************************************/
442
443 void
444 AcpiDmDumpTpm2 (
445 ACPI_TABLE_HEADER *Table)
446 {
447 UINT32 Offset = sizeof (ACPI_TABLE_TPM2);
448 ACPI_TABLE_TPM2 *CommonHeader = ACPI_CAST_PTR (ACPI_TABLE_TPM2, Table);
449 ACPI_TPM2_TRAILER *Subtable = ACPI_ADD_PTR (ACPI_TPM2_TRAILER, Table, Offset);
450 ACPI_TPM2_ARM_SMC *ArmSubtable;
451 ACPI_STATUS Status;
452
453
454 if (Table->Revision == 3)
455 {
456 AcpiDmDumpTpm2Rev3(Table);
457 return;
458 }
459
460 /* Main table */
461
462 Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoTpm2);
463
464 if (ACPI_FAILURE (Status))
465 {
466 return;
467 }
468
469 AcpiOsPrintf ("\n");
470 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
471 Table->Length - Offset, AcpiDmTableInfoTpm2a);
472 if (ACPI_FAILURE (Status))
473 {
474 return;
475 }
476
477 switch (CommonHeader->StartMethod)
478 {
479 case ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC:
480
481 ArmSubtable = ACPI_ADD_PTR (ACPI_TPM2_ARM_SMC, Subtable,
482 sizeof (ACPI_TPM2_TRAILER));
483 Offset += sizeof (ACPI_TPM2_TRAILER);
484
485 AcpiOsPrintf ("\n");
486 Status = AcpiDmDumpTable (Table->Length, Offset, ArmSubtable,
487 Table->Length - Offset, AcpiDmTableInfoTpm211);
488 break;
489
490 default:
491 break;
492 }
493 }
494
495
496 /*******************************************************************************
497 *
498 * FUNCTION: AcpiDmDumpVrtc
499 *
500 * PARAMETERS: Table - A VRTC table
501 *
502 * RETURN: None
503 *
504 * DESCRIPTION: Format the contents of a VRTC
505 *
506 ******************************************************************************/
507
508 void
509 AcpiDmDumpVrtc (
510 ACPI_TABLE_HEADER *Table)
511 {
512 ACPI_STATUS Status;
513 UINT32 Offset = sizeof (ACPI_TABLE_VRTC);
514 ACPI_VRTC_ENTRY *Subtable;
515
516
517 /* Main table */
518
519 Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoVrtc);
520 if (ACPI_FAILURE (Status))
521 {
522 return;
523 }
524
525 /* Subtables */
526
527 Subtable = ACPI_ADD_PTR (ACPI_VRTC_ENTRY, Table, Offset);
528 while (Offset < Table->Length)
529 {
530 /* Common subtable header */
531
532 AcpiOsPrintf ("\n");
533 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
534 sizeof (ACPI_VRTC_ENTRY), AcpiDmTableInfoVrtc0);
535 if (ACPI_FAILURE (Status))
536 {
537 return;
538 }
539
540 /* Point to next subtable */
541
542 Offset += sizeof (ACPI_VRTC_ENTRY);
543 Subtable = ACPI_ADD_PTR (ACPI_VRTC_ENTRY, Subtable,
544 sizeof (ACPI_VRTC_ENTRY));
545 }
546 }
547
548
549 /*******************************************************************************
550 *
551 * FUNCTION: AcpiDmDumpWdat
552 *
553 * PARAMETERS: Table - A WDAT table
554 *
555 * RETURN: None
556 *
557 * DESCRIPTION: Format the contents of a WDAT
558 *
559 ******************************************************************************/
560
561 void
562 AcpiDmDumpWdat (
563 ACPI_TABLE_HEADER *Table)
564 {
565 ACPI_STATUS Status;
566 UINT32 Offset = sizeof (ACPI_TABLE_WDAT);
567 ACPI_WDAT_ENTRY *Subtable;
568
569
570 /* Main table */
571
572 Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoWdat);
573 if (ACPI_FAILURE (Status))
574 {
575 return;
576 }
577
578 /* Subtables */
579
580 Subtable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, Table, Offset);
581 while (Offset < Table->Length)
582 {
583 /* Common subtable header */
584
585 AcpiOsPrintf ("\n");
586 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
587 sizeof (ACPI_WDAT_ENTRY), AcpiDmTableInfoWdat0);
588 if (ACPI_FAILURE (Status))
589 {
590 return;
591 }
592
593 /* Point to next subtable */
594
595 Offset += sizeof (ACPI_WDAT_ENTRY);
596 Subtable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, Subtable,
597 sizeof (ACPI_WDAT_ENTRY));
598 }
599 }
600
601
602 /*******************************************************************************
603 *
604 * FUNCTION: AcpiDmDumpWpbt
605 *
606 * PARAMETERS: Table - A WPBT table
607 *
608 * RETURN: None
609 *
610 * DESCRIPTION: Format the contents of a WPBT. This table type consists
611 * of an open-ended arguments buffer at the end of the table.
612 *
613 ******************************************************************************/
614
615 void
616 AcpiDmDumpWpbt (
617 ACPI_TABLE_HEADER *Table)
618 {
619 ACPI_STATUS Status;
620 ACPI_TABLE_WPBT *Subtable;
621 UINT32 Length = Table->Length;
622 UINT16 ArgumentsLength;
623
624
625 /* Dump the main table */
626
627 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoWpbt);
628 if (ACPI_FAILURE (Status))
629 {
630 return;
631 }
632
633 /* Extract the arguments buffer length from the main table */
634
635 Subtable = ACPI_CAST_PTR (ACPI_TABLE_WPBT, Table);
636 ArgumentsLength = Subtable->ArgumentsLength;
637
638 /* Dump the arguments buffer */
639
640 (void) AcpiDmDumpTable (Table->Length, 0, Table, ArgumentsLength,
641 AcpiDmTableInfoWpbt0);
642 }
643