1 /****************************************************************************** 2 * 3 * Module Name: dmtbdump3 - Dump ACPI data tables that contain no AML code 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2018, 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 default: 229 AcpiOsPrintf ("\n**** Unknown SRAT subtable type 0x%X\n", 230 Subtable->Type); 231 232 /* Attempt to continue */ 233 234 if (!Subtable->Length) 235 { 236 AcpiOsPrintf ("Invalid zero length subtable\n"); 237 return; 238 } 239 goto NextSubtable; 240 } 241 242 AcpiOsPrintf ("\n"); 243 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable, 244 Subtable->Length, InfoTable); 245 if (ACPI_FAILURE (Status)) 246 { 247 return; 248 } 249 250 NextSubtable: 251 /* Point to next subtable */ 252 253 Offset += Subtable->Length; 254 Subtable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, Subtable, 255 Subtable->Length); 256 } 257 } 258 259 260 /******************************************************************************* 261 * 262 * FUNCTION: AcpiDmDumpStao 263 * 264 * PARAMETERS: Table - A STAO table 265 * 266 * RETURN: None 267 * 268 * DESCRIPTION: Format the contents of a STAO. This is a variable-length 269 * table that contains an open-ended number of ASCII strings 270 * at the end of the table. 271 * 272 ******************************************************************************/ 273 274 void 275 AcpiDmDumpStao ( 276 ACPI_TABLE_HEADER *Table) 277 { 278 ACPI_STATUS Status; 279 char *Namepath; 280 UINT32 Length = Table->Length; 281 UINT32 StringLength; 282 UINT32 Offset = sizeof (ACPI_TABLE_STAO); 283 284 285 /* Main table */ 286 287 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoStao); 288 if (ACPI_FAILURE (Status)) 289 { 290 return; 291 } 292 293 /* The rest of the table consists of Namepath strings */ 294 295 while (Offset < Table->Length) 296 { 297 Namepath = ACPI_ADD_PTR (char, Table, Offset); 298 StringLength = strlen (Namepath) + 1; 299 300 AcpiDmLineHeader (Offset, StringLength, "Namestring"); 301 AcpiOsPrintf ("\"%s\"\n", Namepath); 302 303 /* Point to next namepath */ 304 305 Offset += StringLength; 306 } 307 } 308 309 310 /******************************************************************************* 311 * 312 * FUNCTION: AcpiDmDumpTcpa 313 * 314 * PARAMETERS: Table - A TCPA table 315 * 316 * RETURN: None 317 * 318 * DESCRIPTION: Format the contents of a TCPA. 319 * 320 * NOTE: There are two versions of the table with the same signature: 321 * the client version and the server version. The common 322 * PlatformClass field is used to differentiate the two types of 323 * tables. 324 * 325 ******************************************************************************/ 326 327 void 328 AcpiDmDumpTcpa ( 329 ACPI_TABLE_HEADER *Table) 330 { 331 UINT32 Offset = sizeof (ACPI_TABLE_TCPA_HDR); 332 ACPI_TABLE_TCPA_HDR *CommonHeader = ACPI_CAST_PTR ( 333 ACPI_TABLE_TCPA_HDR, Table); 334 ACPI_TABLE_TCPA_HDR *Subtable = ACPI_ADD_PTR ( 335 ACPI_TABLE_TCPA_HDR, Table, Offset); 336 ACPI_STATUS Status; 337 338 339 /* Main table */ 340 341 Status = AcpiDmDumpTable (Table->Length, 0, Table, 342 0, AcpiDmTableInfoTcpaHdr); 343 if (ACPI_FAILURE (Status)) 344 { 345 return; 346 } 347 348 /* 349 * Examine the PlatformClass field to determine the table type. 350 * Either a client or server table. Only one. 351 */ 352 switch (CommonHeader->PlatformClass) 353 { 354 case ACPI_TCPA_CLIENT_TABLE: 355 356 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable, 357 Table->Length - Offset, AcpiDmTableInfoTcpaClient); 358 break; 359 360 case ACPI_TCPA_SERVER_TABLE: 361 362 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable, 363 Table->Length - Offset, AcpiDmTableInfoTcpaServer); 364 break; 365 366 default: 367 368 AcpiOsPrintf ("\n**** Unknown TCPA Platform Class 0x%X\n", 369 CommonHeader->PlatformClass); 370 Status = AE_ERROR; 371 break; 372 } 373 374 if (ACPI_FAILURE (Status)) 375 { 376 AcpiOsPrintf ("\n**** Cannot disassemble TCPA table\n"); 377 } 378 } 379 380 381 /******************************************************************************* 382 * 383 * FUNCTION: AcpiDmDumpTpm2 384 * 385 * PARAMETERS: Table - A TPM2 table 386 * 387 * RETURN: None 388 * 389 * DESCRIPTION: Format the contents of a TPM2. 390 * 391 ******************************************************************************/ 392 393 void 394 AcpiDmDumpTpm2 ( 395 ACPI_TABLE_HEADER *Table) 396 { 397 UINT32 Offset = sizeof (ACPI_TABLE_TPM2); 398 ACPI_TABLE_TPM2 *CommonHeader = ACPI_CAST_PTR (ACPI_TABLE_TPM2, Table); 399 ACPI_TPM2_TRAILER *Subtable = ACPI_ADD_PTR (ACPI_TPM2_TRAILER, Table, Offset); 400 ACPI_TPM2_ARM_SMC *ArmSubtable; 401 ACPI_STATUS Status; 402 403 404 /* Main table */ 405 406 Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoTpm2); 407 if (ACPI_FAILURE (Status)) 408 { 409 return; 410 } 411 412 AcpiOsPrintf ("\n"); 413 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable, 414 Table->Length - Offset, AcpiDmTableInfoTpm2a); 415 if (ACPI_FAILURE (Status)) 416 { 417 return; 418 } 419 420 switch (CommonHeader->StartMethod) 421 { 422 case ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC: 423 424 ArmSubtable = ACPI_ADD_PTR (ACPI_TPM2_ARM_SMC, Subtable, 425 sizeof (ACPI_TPM2_TRAILER)); 426 Offset += sizeof (ACPI_TPM2_TRAILER); 427 428 AcpiOsPrintf ("\n"); 429 Status = AcpiDmDumpTable (Table->Length, Offset, ArmSubtable, 430 Table->Length - Offset, AcpiDmTableInfoTpm211); 431 break; 432 433 default: 434 break; 435 } 436 } 437 438 439 /******************************************************************************* 440 * 441 * FUNCTION: AcpiDmDumpVrtc 442 * 443 * PARAMETERS: Table - A VRTC table 444 * 445 * RETURN: None 446 * 447 * DESCRIPTION: Format the contents of a VRTC 448 * 449 ******************************************************************************/ 450 451 void 452 AcpiDmDumpVrtc ( 453 ACPI_TABLE_HEADER *Table) 454 { 455 ACPI_STATUS Status; 456 UINT32 Offset = sizeof (ACPI_TABLE_VRTC); 457 ACPI_VRTC_ENTRY *Subtable; 458 459 460 /* Main table */ 461 462 Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoVrtc); 463 if (ACPI_FAILURE (Status)) 464 { 465 return; 466 } 467 468 /* Subtables */ 469 470 Subtable = ACPI_ADD_PTR (ACPI_VRTC_ENTRY, Table, Offset); 471 while (Offset < Table->Length) 472 { 473 /* Common subtable header */ 474 475 AcpiOsPrintf ("\n"); 476 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable, 477 sizeof (ACPI_VRTC_ENTRY), AcpiDmTableInfoVrtc0); 478 if (ACPI_FAILURE (Status)) 479 { 480 return; 481 } 482 483 /* Point to next subtable */ 484 485 Offset += sizeof (ACPI_VRTC_ENTRY); 486 Subtable = ACPI_ADD_PTR (ACPI_VRTC_ENTRY, Subtable, 487 sizeof (ACPI_VRTC_ENTRY)); 488 } 489 } 490 491 492 /******************************************************************************* 493 * 494 * FUNCTION: AcpiDmDumpWdat 495 * 496 * PARAMETERS: Table - A WDAT table 497 * 498 * RETURN: None 499 * 500 * DESCRIPTION: Format the contents of a WDAT 501 * 502 ******************************************************************************/ 503 504 void 505 AcpiDmDumpWdat ( 506 ACPI_TABLE_HEADER *Table) 507 { 508 ACPI_STATUS Status; 509 UINT32 Offset = sizeof (ACPI_TABLE_WDAT); 510 ACPI_WDAT_ENTRY *Subtable; 511 512 513 /* Main table */ 514 515 Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoWdat); 516 if (ACPI_FAILURE (Status)) 517 { 518 return; 519 } 520 521 /* Subtables */ 522 523 Subtable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, Table, Offset); 524 while (Offset < Table->Length) 525 { 526 /* Common subtable header */ 527 528 AcpiOsPrintf ("\n"); 529 Status = AcpiDmDumpTable (Table->Length, Offset, Subtable, 530 sizeof (ACPI_WDAT_ENTRY), AcpiDmTableInfoWdat0); 531 if (ACPI_FAILURE (Status)) 532 { 533 return; 534 } 535 536 /* Point to next subtable */ 537 538 Offset += sizeof (ACPI_WDAT_ENTRY); 539 Subtable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, Subtable, 540 sizeof (ACPI_WDAT_ENTRY)); 541 } 542 } 543 544 545 /******************************************************************************* 546 * 547 * FUNCTION: AcpiDmDumpWpbt 548 * 549 * PARAMETERS: Table - A WPBT table 550 * 551 * RETURN: None 552 * 553 * DESCRIPTION: Format the contents of a WPBT. This table type consists 554 * of an open-ended arguments buffer at the end of the table. 555 * 556 ******************************************************************************/ 557 558 void 559 AcpiDmDumpWpbt ( 560 ACPI_TABLE_HEADER *Table) 561 { 562 ACPI_STATUS Status; 563 ACPI_TABLE_WPBT *Subtable; 564 UINT32 Length = Table->Length; 565 UINT16 ArgumentsLength; 566 567 568 /* Dump the main table */ 569 570 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoWpbt); 571 if (ACPI_FAILURE (Status)) 572 { 573 return; 574 } 575 576 /* Extract the arguments buffer length from the main table */ 577 578 Subtable = ACPI_CAST_PTR (ACPI_TABLE_WPBT, Table); 579 ArgumentsLength = Subtable->ArgumentsLength; 580 581 /* Dump the arguments buffer */ 582 583 (void) AcpiDmDumpTable (Table->Length, 0, Table, ArgumentsLength, 584 AcpiDmTableInfoWpbt0); 585 } 586