1 /****************************************************************************** 2 * 3 * Module Name: dmtable - Support for ACPI 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 - 2010, 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 #include <contrib/dev/acpica/include/acpi.h> 117 #include <contrib/dev/acpica/include/accommon.h> 118 #include <contrib/dev/acpica/include/acdisasm.h> 119 #include <contrib/dev/acpica/include/actables.h> 120 121 /* This module used for application-level code only */ 122 123 #define _COMPONENT ACPI_CA_DISASSEMBLER 124 ACPI_MODULE_NAME ("dmtable") 125 126 /* Local Prototypes */ 127 128 static ACPI_DMTABLE_DATA * 129 AcpiDmGetTableData ( 130 char *Signature); 131 132 static void 133 AcpiDmCheckAscii ( 134 UINT8 *Target, 135 char *RepairedName, 136 UINT32 Count); 137 138 UINT8 139 AcpiTbGenerateChecksum ( 140 ACPI_TABLE_HEADER *Table); 141 142 143 /* These tables map a subtable type to a description string */ 144 145 static const char *AcpiDmAsfSubnames[] = 146 { 147 "ASF Information", 148 "ASF Alerts", 149 "ASF Remote Control", 150 "ASF RMCP Boot Options", 151 "ASF Address", 152 "Unknown SubTable Type" /* Reserved */ 153 }; 154 155 static const char *AcpiDmDmarSubnames[] = 156 { 157 "Hardware Unit Definition", 158 "Reserved Memory Region", 159 "Root Port ATS Capability", 160 "Remapping Hardware Static Affinity", 161 "Unknown SubTable Type" /* Reserved */ 162 }; 163 164 static const char *AcpiDmHestSubnames[] = 165 { 166 "IA-32 Machine Check Exception", 167 "IA-32 Corrected Machine Check", 168 "IA-32 Non-Maskable Interrupt", 169 "Unknown SubTable Type", /* 3 - Reserved */ 170 "Unknown SubTable Type", /* 4 - Reserved */ 171 "Unknown SubTable Type", /* 5 - Reserved */ 172 "PCI Express Root Port AER", 173 "PCI Express AER (AER Endpoint)", 174 "PCI Express/PCI-X Bridge AER", 175 "Generic Hardware Error Source", 176 "Unknown SubTable Type" /* Reserved */ 177 }; 178 179 static const char *AcpiDmHestNotifySubnames[] = 180 { 181 "Polled", 182 "External Interrupt", 183 "Local Interrupt", 184 "SCI", 185 "NMI", 186 "Unknown Notify Type" /* Reserved */ 187 }; 188 189 static const char *AcpiDmMadtSubnames[] = 190 { 191 "Processor Local APIC", /* ACPI_MADT_TYPE_LOCAL_APIC */ 192 "I/O APIC", /* ACPI_MADT_TYPE_IO_APIC */ 193 "Interrupt Source Override", /* ACPI_MADT_TYPE_INTERRUPT_OVERRIDE */ 194 "NMI Source", /* ACPI_MADT_TYPE_NMI_SOURCE */ 195 "Local APIC NMI", /* ACPI_MADT_TYPE_LOCAL_APIC_NMI */ 196 "Local APIC Address Override", /* ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE */ 197 "I/O SAPIC", /* ACPI_MADT_TYPE_IO_SAPIC */ 198 "Local SAPIC", /* ACPI_MADT_TYPE_LOCAL_SAPIC */ 199 "Platform Interrupt Sources", /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */ 200 "Processor Local x2APIC", /* ACPI_MADT_TYPE_LOCAL_X2APIC */ 201 "Local x2APIC NMI", /* ACPI_MADT_TYPE_LOCAL_X2APIC_NMI */ 202 "Unknown SubTable Type" /* Reserved */ 203 }; 204 205 static const char *AcpiDmSratSubnames[] = 206 { 207 "Processor Local APIC/SAPIC Affinity", 208 "Memory Affinity", 209 "Processor Local x2APIC Affinity", 210 "Unknown SubTable Type" /* Reserved */ 211 }; 212 213 static const char *AcpiDmIvrsSubnames[] = 214 { 215 "Hardware Definition Block", 216 "Memory Definition Block", 217 "Unknown SubTable Type" /* Reserved */ 218 }; 219 220 221 #define ACPI_FADT_PM_RESERVED 8 222 223 static const char *AcpiDmFadtProfiles[] = 224 { 225 "Unspecified", 226 "Desktop", 227 "Mobile", 228 "Workstation", 229 "Enterprise Server", 230 "SOHO Server", 231 "Appliance PC", 232 "Performance Server", 233 "Unknown Profile Type" 234 }; 235 236 /******************************************************************************* 237 * 238 * ACPI Table Data, indexed by signature. 239 * 240 * Each entry contains: Signature, Table Info, Handler, Description 241 * 242 * Simple tables have only a TableInfo structure, complex tables have a handler. 243 * This table must be NULL terminated. RSDP and FACS are special-cased 244 * elsewhere. 245 * 246 ******************************************************************************/ 247 248 static ACPI_DMTABLE_DATA AcpiDmTableData[] = 249 { 250 {ACPI_SIG_ASF, NULL, AcpiDmDumpAsf, "Alert Standard Format table"}, 251 {ACPI_SIG_BOOT, AcpiDmTableInfoBoot, NULL, "Simple Boot Flag Table"}, 252 {ACPI_SIG_BERT, AcpiDmTableInfoBert, NULL, "Boot Error Record Table"}, 253 {ACPI_SIG_CPEP, NULL, AcpiDmDumpCpep, "Corrected Platform Error Polling table"}, 254 {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp, NULL, "Debug Port table"}, 255 {ACPI_SIG_DMAR, NULL, AcpiDmDumpDmar, "DMA Remapping table"}, 256 {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt, NULL, "Embedded Controller Boot Resources Table"}, 257 {ACPI_SIG_EINJ, NULL, AcpiDmDumpEinj, "Error Injection table"}, 258 {ACPI_SIG_ERST, NULL, AcpiDmDumpErst, "Error Record Serialization Table"}, 259 {ACPI_SIG_FADT, NULL, AcpiDmDumpFadt, "Fixed ACPI Description Table"}, 260 {ACPI_SIG_HEST, NULL, AcpiDmDumpHest, "Hardware Error Source Table"}, 261 {ACPI_SIG_HPET, AcpiDmTableInfoHpet, NULL, "High Precision Event Timer table"}, 262 {ACPI_SIG_IVRS, NULL, AcpiDmDumpIvrs, "I/O Virtualization Reporting Structure"}, 263 {ACPI_SIG_MADT, NULL, AcpiDmDumpMadt, "Multiple APIC Description Table"}, 264 {ACPI_SIG_MCFG, NULL, AcpiDmDumpMcfg, "Memory Mapped Configuration table"}, 265 {ACPI_SIG_MCHI, AcpiDmTableInfoMchi, NULL, "Management Controller Host Interface table"}, 266 {ACPI_SIG_MSCT, NULL, AcpiDmDumpMsct, "Maximum System Characteristics Table"}, 267 {ACPI_SIG_RSDT, NULL, AcpiDmDumpRsdt, "Root System Description Table"}, 268 {ACPI_SIG_SBST, AcpiDmTableInfoSbst, NULL, "Smart Battery Specification Table"}, 269 {ACPI_SIG_SLIC, AcpiDmTableInfoSlic, NULL, "Software Licensing Description Table"}, 270 {ACPI_SIG_SLIT, NULL, AcpiDmDumpSlit, "System Locality Information Table"}, 271 {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr, NULL, "Serial Port Console Redirection table"}, 272 {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi, NULL, "Server Platform Management Interface table"}, 273 {ACPI_SIG_SRAT, NULL, AcpiDmDumpSrat, "System Resource Affinity Table"}, 274 {ACPI_SIG_TCPA, AcpiDmTableInfoTcpa, NULL, "Trusted Computing Platform Alliance table"}, 275 {ACPI_SIG_UEFI, AcpiDmTableInfoUefi, NULL, "UEFI Boot Optimization Table"}, 276 {ACPI_SIG_WAET, AcpiDmTableInfoWaet, NULL, "Windows ACPI Emulated Devices Table"}, 277 {ACPI_SIG_WDAT, NULL, AcpiDmDumpWdat, "Watchdog Action Table"}, 278 {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt, NULL, "Watchdog Resource Table"}, 279 {ACPI_SIG_XSDT, NULL, AcpiDmDumpXsdt, "Extended System Description Table"}, 280 {NULL, NULL, NULL, NULL} 281 }; 282 283 284 /******************************************************************************* 285 * 286 * FUNCTION: AcpiTbGenerateChecksum 287 * 288 * PARAMETERS: Table - Pointer to a valid ACPI table (with a 289 * standard ACPI header) 290 * 291 * RETURN: 8 bit checksum of buffer 292 * 293 * DESCRIPTION: Computes an 8 bit checksum of the table. 294 * 295 ******************************************************************************/ 296 297 UINT8 298 AcpiTbGenerateChecksum ( 299 ACPI_TABLE_HEADER *Table) 300 { 301 UINT8 Checksum; 302 303 304 /* Sum the entire table as-is */ 305 306 Checksum = AcpiTbChecksum ((UINT8 *) Table, Table->Length); 307 308 /* Subtract off the existing checksum value in the table */ 309 310 Checksum = (UINT8) (Checksum - Table->Checksum); 311 312 /* Compute the final checksum */ 313 314 Checksum = (UINT8) (0 - Checksum); 315 return (Checksum); 316 } 317 318 319 /******************************************************************************* 320 * 321 * FUNCTION: AcpiDmGetTableData 322 * 323 * PARAMETERS: Signature - ACPI signature (4 chars) to match 324 * 325 * RETURN: Pointer to a valid ACPI_DMTABLE_DATA. Null if no match found. 326 * 327 * DESCRIPTION: Find a match in the global table of supported ACPI tables 328 * 329 ******************************************************************************/ 330 331 static ACPI_DMTABLE_DATA * 332 AcpiDmGetTableData ( 333 char *Signature) 334 { 335 ACPI_DMTABLE_DATA *TableData; 336 337 338 for (TableData = AcpiDmTableData; TableData->Signature; TableData++) 339 { 340 if (ACPI_COMPARE_NAME (Signature, TableData->Signature)) 341 { 342 return (TableData); 343 } 344 } 345 346 return (NULL); 347 } 348 349 350 /******************************************************************************* 351 * 352 * FUNCTION: AcpiDmDumpDataTable 353 * 354 * PARAMETERS: Table - An ACPI table 355 * 356 * RETURN: None. 357 * 358 * DESCRIPTION: Format the contents of an ACPI data table (any table other 359 * than an SSDT or DSDT that does not contain executable AML code) 360 * 361 ******************************************************************************/ 362 363 void 364 AcpiDmDumpDataTable ( 365 ACPI_TABLE_HEADER *Table) 366 { 367 ACPI_STATUS Status; 368 ACPI_DMTABLE_DATA *TableData; 369 UINT32 Length; 370 371 372 /* Ignore tables that contain AML */ 373 374 if (AcpiUtIsAmlTable (Table)) 375 { 376 return; 377 } 378 379 /* 380 * Handle tables that don't use the common ACPI table header structure. 381 * Currently, these are the FACS and RSDP. 382 */ 383 if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS)) 384 { 385 Length = Table->Length; 386 AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFacs); 387 } 388 else if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_RSDP)) 389 { 390 Length = AcpiDmDumpRsdp (Table); 391 } 392 else 393 { 394 /* 395 * All other tables must use the common ACPI table header, dump it now 396 */ 397 Length = Table->Length; 398 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHeader); 399 if (ACPI_FAILURE (Status)) 400 { 401 return; 402 } 403 AcpiOsPrintf ("\n"); 404 405 /* Match signature and dispatch appropriately */ 406 407 TableData = AcpiDmGetTableData (Table->Signature); 408 if (!TableData) 409 { 410 if (!ACPI_STRNCMP (Table->Signature, "OEM", 3)) 411 { 412 AcpiOsPrintf ("\n**** OEM-defined ACPI table [%4.4s], unknown contents\n\n", 413 Table->Signature); 414 } 415 else 416 { 417 AcpiOsPrintf ("\n**** Unknown ACPI table type [%4.4s]\n\n", 418 Table->Signature); 419 } 420 } 421 else if (TableData->TableHandler) 422 { 423 /* Complex table, has a handler */ 424 425 TableData->TableHandler (Table); 426 } 427 else if (TableData->TableInfo) 428 { 429 /* Simple table, just walk the info table */ 430 431 AcpiDmDumpTable (Length, 0, Table, 0, TableData->TableInfo); 432 } 433 } 434 435 /* Always dump the raw table data */ 436 437 AcpiOsPrintf ("\nRaw Table Data\n\n"); 438 AcpiUtDumpBuffer2 (ACPI_CAST_PTR (UINT8, Table), Length, DB_BYTE_DISPLAY); 439 } 440 441 442 /******************************************************************************* 443 * 444 * FUNCTION: AcpiDmLineHeader 445 * 446 * PARAMETERS: Offset - Current byte offset, from table start 447 * ByteLength - Length of the field in bytes, 0 for flags 448 * Name - Name of this field 449 * Value - Optional value, displayed on left of ':' 450 * 451 * RETURN: None 452 * 453 * DESCRIPTION: Utility routines for formatting output lines. Displays the 454 * current table offset in hex and decimal, the field length, 455 * and the field name. 456 * 457 ******************************************************************************/ 458 459 void 460 AcpiDmLineHeader ( 461 UINT32 Offset, 462 UINT32 ByteLength, 463 char *Name) 464 { 465 466 if (ByteLength) 467 { 468 AcpiOsPrintf ("[%3.3Xh %4.4d% 3d] %28s : ", 469 Offset, Offset, ByteLength, Name); 470 } 471 else 472 { 473 AcpiOsPrintf ("%43s : ", 474 Name); 475 } 476 } 477 478 void 479 AcpiDmLineHeader2 ( 480 UINT32 Offset, 481 UINT32 ByteLength, 482 char *Name, 483 UINT32 Value) 484 { 485 486 if (ByteLength) 487 { 488 AcpiOsPrintf ("[%3.3Xh %4.4d% 3d] %24s % 3d : ", 489 Offset, Offset, ByteLength, Name, Value); 490 } 491 else 492 { 493 AcpiOsPrintf ("[%3.3Xh %4.4d ] %24s % 3d : ", 494 Offset, Offset, Name, Value); 495 } 496 } 497 498 499 /******************************************************************************* 500 * 501 * FUNCTION: AcpiDmDumpTable 502 * 503 * PARAMETERS: TableLength - Length of the entire ACPI table 504 * TableOffset - Starting offset within the table for this 505 * sub-descriptor (0 if main table) 506 * Table - The ACPI table 507 * SubtableLength - Length of this sub-descriptor 508 * Info - Info table for this ACPI table 509 * 510 * RETURN: None 511 * 512 * DESCRIPTION: Display ACPI table contents by walking the Info table. 513 * 514 ******************************************************************************/ 515 516 ACPI_STATUS 517 AcpiDmDumpTable ( 518 UINT32 TableLength, 519 UINT32 TableOffset, 520 void *Table, 521 UINT32 SubtableLength, 522 ACPI_DMTABLE_INFO *Info) 523 { 524 UINT8 *Target; 525 UINT32 CurrentOffset; 526 UINT32 ByteLength; 527 UINT8 Temp8; 528 UINT16 Temp16; 529 ACPI_DMTABLE_DATA *TableData; 530 const char *Name; 531 BOOLEAN LastOutputBlankLine = FALSE; 532 char RepairedName[8]; 533 534 535 if (!Info) 536 { 537 AcpiOsPrintf ("Display not implemented\n"); 538 return (AE_NOT_IMPLEMENTED); 539 } 540 541 /* Walk entire Info table; Null name terminates */ 542 543 for (; Info->Name; Info++) 544 { 545 /* 546 * Target points to the field within the ACPI Table. CurrentOffset is 547 * the offset of the field from the start of the main table. 548 */ 549 Target = ACPI_ADD_PTR (UINT8, Table, Info->Offset); 550 CurrentOffset = TableOffset + Info->Offset; 551 552 /* Check for beyond EOT or beyond subtable end */ 553 554 if ((CurrentOffset >= TableLength) || 555 (SubtableLength && (Info->Offset >= SubtableLength))) 556 { 557 AcpiOsPrintf ("**** ACPI table terminates in the middle of a data structure!\n"); 558 return (AE_BAD_DATA); 559 } 560 561 /* Generate the byte length for this field */ 562 563 switch (Info->Opcode) 564 { 565 case ACPI_DMT_UINT8: 566 case ACPI_DMT_CHKSUM: 567 case ACPI_DMT_SPACEID: 568 case ACPI_DMT_IVRS: 569 case ACPI_DMT_MADT: 570 case ACPI_DMT_SRAT: 571 case ACPI_DMT_ASF: 572 case ACPI_DMT_HESTNTYP: 573 case ACPI_DMT_FADTPM: 574 ByteLength = 1; 575 break; 576 case ACPI_DMT_UINT16: 577 case ACPI_DMT_DMAR: 578 case ACPI_DMT_HEST: 579 ByteLength = 2; 580 break; 581 case ACPI_DMT_UINT24: 582 ByteLength = 3; 583 break; 584 case ACPI_DMT_UINT32: 585 case ACPI_DMT_NAME4: 586 case ACPI_DMT_SIG: 587 ByteLength = 4; 588 break; 589 case ACPI_DMT_NAME6: 590 ByteLength = 6; 591 break; 592 case ACPI_DMT_UINT56: 593 ByteLength = 7; 594 break; 595 case ACPI_DMT_UINT64: 596 case ACPI_DMT_NAME8: 597 ByteLength = 8; 598 break; 599 case ACPI_DMT_BUF16: 600 ByteLength = 16; 601 break; 602 case ACPI_DMT_STRING: 603 ByteLength = ACPI_STRLEN (ACPI_CAST_PTR (char, Target)) + 1; 604 break; 605 case ACPI_DMT_GAS: 606 if (!LastOutputBlankLine) 607 { 608 AcpiOsPrintf ("\n"); 609 LastOutputBlankLine = TRUE; 610 } 611 ByteLength = sizeof (ACPI_GENERIC_ADDRESS); 612 break; 613 case ACPI_DMT_HESTNTFY: 614 if (!LastOutputBlankLine) 615 { 616 AcpiOsPrintf ("\n"); 617 LastOutputBlankLine = TRUE; 618 } 619 ByteLength = sizeof (ACPI_HEST_NOTIFY); 620 break; 621 default: 622 ByteLength = 0; 623 break; 624 } 625 626 if (CurrentOffset + ByteLength > TableLength) 627 { 628 AcpiOsPrintf ("**** ACPI table terminates in the middle of a data structure!\n"); 629 return (AE_BAD_DATA); 630 } 631 632 /* Start a new line and decode the opcode */ 633 634 AcpiDmLineHeader (CurrentOffset, ByteLength, Info->Name); 635 636 switch (Info->Opcode) 637 { 638 /* Single-bit Flag fields. Note: Opcode is the bit position */ 639 640 case ACPI_DMT_FLAG0: 641 case ACPI_DMT_FLAG1: 642 case ACPI_DMT_FLAG2: 643 case ACPI_DMT_FLAG3: 644 case ACPI_DMT_FLAG4: 645 case ACPI_DMT_FLAG5: 646 case ACPI_DMT_FLAG6: 647 case ACPI_DMT_FLAG7: 648 649 AcpiOsPrintf ("%1.1X\n", (*Target >> Info->Opcode) & 0x01); 650 break; 651 652 /* 2-bit Flag fields */ 653 654 case ACPI_DMT_FLAGS0: 655 656 AcpiOsPrintf ("%1.1X\n", *Target & 0x03); 657 break; 658 659 case ACPI_DMT_FLAGS2: 660 661 AcpiOsPrintf ("%1.1X\n", (*Target >> 2) & 0x03); 662 break; 663 664 /* Standard Data Types */ 665 666 case ACPI_DMT_UINT8: 667 668 AcpiOsPrintf ("%2.2X\n", *Target); 669 break; 670 671 case ACPI_DMT_UINT16: 672 673 AcpiOsPrintf ("%4.4X\n", ACPI_GET16 (Target)); 674 break; 675 676 case ACPI_DMT_UINT24: 677 678 AcpiOsPrintf ("%2.2X%2.2X%2.2X\n", 679 *Target, *(Target + 1), *(Target + 2)); 680 break; 681 682 case ACPI_DMT_UINT32: 683 684 AcpiOsPrintf ("%8.8X\n", ACPI_GET32 (Target)); 685 break; 686 687 case ACPI_DMT_UINT56: 688 689 for (Temp8 = 0; Temp8 < 7; Temp8++) 690 { 691 AcpiOsPrintf ("%2.2X", Target[Temp8]); 692 } 693 AcpiOsPrintf ("\n"); 694 break; 695 696 case ACPI_DMT_UINT64: 697 698 AcpiOsPrintf ("%8.8X%8.8X\n", 699 ACPI_FORMAT_UINT64 (ACPI_GET64 (Target))); 700 break; 701 702 case ACPI_DMT_BUF16: 703 704 /* Buffer of length 16 */ 705 706 for (Temp8 = 0; Temp8 < 16; Temp8++) 707 { 708 AcpiOsPrintf ("%2.2X,", Target[Temp8]); 709 } 710 AcpiOsPrintf ("\n"); 711 break; 712 713 case ACPI_DMT_STRING: 714 715 AcpiOsPrintf ("\"%s\"\n", ACPI_CAST_PTR (char, Target)); 716 break; 717 718 /* Fixed length ASCII name fields */ 719 720 case ACPI_DMT_SIG: 721 722 AcpiDmCheckAscii (Target, RepairedName, 4); 723 AcpiOsPrintf ("\"%.4s\" ", RepairedName); 724 TableData = AcpiDmGetTableData (ACPI_CAST_PTR (char, Target)); 725 if (TableData) 726 { 727 AcpiOsPrintf ("/* %s */", TableData->Name); 728 } 729 AcpiOsPrintf ("\n"); 730 break; 731 732 case ACPI_DMT_NAME4: 733 734 AcpiDmCheckAscii (Target, RepairedName, 4); 735 AcpiOsPrintf ("\"%.4s\"\n", RepairedName); 736 break; 737 738 case ACPI_DMT_NAME6: 739 740 AcpiDmCheckAscii (Target, RepairedName, 6); 741 AcpiOsPrintf ("\"%.6s\"\n", RepairedName); 742 break; 743 744 case ACPI_DMT_NAME8: 745 746 AcpiDmCheckAscii (Target, RepairedName, 8); 747 AcpiOsPrintf ("\"%.8s\"\n", RepairedName); 748 break; 749 750 /* Special Data Types */ 751 752 case ACPI_DMT_CHKSUM: 753 754 /* Checksum, display and validate */ 755 756 AcpiOsPrintf ("%2.2X", *Target); 757 Temp8 = AcpiTbGenerateChecksum (Table); 758 if (Temp8 != ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum) 759 { 760 AcpiOsPrintf ( 761 " /* Incorrect checksum, should be %2.2X */", Temp8); 762 } 763 AcpiOsPrintf ("\n"); 764 break; 765 766 case ACPI_DMT_SPACEID: 767 768 /* Address Space ID */ 769 770 AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiUtGetRegionName (*Target)); 771 break; 772 773 case ACPI_DMT_GAS: 774 775 /* Generic Address Structure */ 776 777 AcpiOsPrintf ("<Generic Address Structure>\n"); 778 AcpiDmDumpTable (TableLength, CurrentOffset, Target, 779 sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas); 780 AcpiOsPrintf ("\n"); 781 LastOutputBlankLine = TRUE; 782 break; 783 784 case ACPI_DMT_ASF: 785 786 /* ASF subtable types */ 787 788 Temp16 = (UINT16) ((*Target) & 0x7F); /* Top bit can be zero or one */ 789 if (Temp16 > ACPI_ASF_TYPE_RESERVED) 790 { 791 Temp16 = ACPI_ASF_TYPE_RESERVED; 792 } 793 794 AcpiOsPrintf ("%2.2X <%s>\n", *Target, AcpiDmAsfSubnames[Temp16]); 795 break; 796 797 case ACPI_DMT_DMAR: 798 799 /* DMAR subtable types */ 800 801 Temp16 = ACPI_GET16 (Target); 802 if (Temp16 > ACPI_DMAR_TYPE_RESERVED) 803 { 804 Temp16 = ACPI_DMAR_TYPE_RESERVED; 805 } 806 807 AcpiOsPrintf ("%4.4X <%s>\n", ACPI_GET16 (Target), AcpiDmDmarSubnames[Temp16]); 808 break; 809 810 case ACPI_DMT_HEST: 811 812 /* HEST subtable types */ 813 814 Temp16 = ACPI_GET16 (Target); 815 if (Temp16 > ACPI_HEST_TYPE_RESERVED) 816 { 817 Temp16 = ACPI_HEST_TYPE_RESERVED; 818 } 819 820 AcpiOsPrintf ("%4.4X (%s)\n", ACPI_GET16 (Target), AcpiDmHestSubnames[Temp16]); 821 break; 822 823 case ACPI_DMT_HESTNTFY: 824 825 AcpiOsPrintf ("<Hardware Error Notification Structure>\n"); 826 AcpiDmDumpTable (TableLength, CurrentOffset, Target, 827 sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify); 828 AcpiOsPrintf ("\n"); 829 LastOutputBlankLine = TRUE; 830 break; 831 832 case ACPI_DMT_HESTNTYP: 833 834 /* HEST Notify types */ 835 836 Temp8 = *Target; 837 if (Temp8 > ACPI_HEST_NOTIFY_RESERVED) 838 { 839 Temp8 = ACPI_HEST_NOTIFY_RESERVED; 840 } 841 842 AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiDmHestNotifySubnames[Temp8]); 843 break; 844 845 846 case ACPI_DMT_MADT: 847 848 /* MADT subtable types */ 849 850 Temp8 = *Target; 851 if (Temp8 > ACPI_MADT_TYPE_RESERVED) 852 { 853 Temp8 = ACPI_MADT_TYPE_RESERVED; 854 } 855 856 AcpiOsPrintf ("%2.2X <%s>\n", *Target, AcpiDmMadtSubnames[Temp8]); 857 break; 858 859 case ACPI_DMT_SRAT: 860 861 /* SRAT subtable types */ 862 863 Temp8 = *Target; 864 if (Temp8 > ACPI_SRAT_TYPE_RESERVED) 865 { 866 Temp8 = ACPI_SRAT_TYPE_RESERVED; 867 } 868 869 AcpiOsPrintf ("%2.2X <%s>\n", *Target, AcpiDmSratSubnames[Temp8]); 870 break; 871 872 case ACPI_DMT_FADTPM: 873 874 /* FADT Preferred PM Profile names */ 875 876 Temp8 = *Target; 877 if (Temp8 > ACPI_FADT_PM_RESERVED) 878 { 879 Temp8 = ACPI_FADT_PM_RESERVED; 880 } 881 882 AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiDmFadtProfiles[Temp8]); 883 break; 884 885 case ACPI_DMT_IVRS: 886 887 /* IVRS subtable types */ 888 889 Temp8 = *Target; 890 switch (Temp8) 891 { 892 case ACPI_IVRS_TYPE_HARDWARE: 893 Name = AcpiDmIvrsSubnames[0]; 894 break; 895 896 case ACPI_IVRS_TYPE_MEMORY1: 897 case ACPI_IVRS_TYPE_MEMORY2: 898 case ACPI_IVRS_TYPE_MEMORY3: 899 Name = AcpiDmIvrsSubnames[1]; 900 break; 901 902 default: 903 Name = AcpiDmIvrsSubnames[2]; 904 break; 905 } 906 907 AcpiOsPrintf ("%2.2X <%s>\n", *Target, Name); 908 break; 909 910 case ACPI_DMT_EXIT: 911 return (AE_OK); 912 913 default: 914 ACPI_ERROR ((AE_INFO, 915 "**** Invalid table opcode [0x%X] ****\n", Info->Opcode)); 916 return (AE_SUPPORT); 917 } 918 } 919 920 if (TableOffset && !SubtableLength) 921 { 922 /* If this table is not the main table, subtable must have valid length */ 923 924 AcpiOsPrintf ("Invalid zero length subtable\n"); 925 return (AE_BAD_DATA); 926 } 927 928 return (AE_OK); 929 } 930 931 932 /******************************************************************************* 933 * 934 * FUNCTION: AcpiDmCheckAscii 935 * 936 * PARAMETERS: Name - Ascii string 937 * Count - Number of characters to check 938 * 939 * RETURN: None 940 * 941 * DESCRIPTION: Ensure that the requested number of characters are printable 942 * Ascii characters. Sets non-printable and null chars to <space>. 943 * 944 ******************************************************************************/ 945 946 static void 947 AcpiDmCheckAscii ( 948 UINT8 *Name, 949 char *RepairedName, 950 UINT32 Count) 951 { 952 UINT32 i; 953 954 955 for (i = 0; i < Count; i++) 956 { 957 RepairedName[i] = (char) Name[i]; 958 959 if (!Name[i]) 960 { 961 return; 962 } 963 if (!isprint (Name[i])) 964 { 965 RepairedName[i] = ' '; 966 } 967 } 968 } 969