dmtable.c revision 167802
1167802Sjkim/****************************************************************************** 2167802Sjkim * 3167802Sjkim * Module Name: dmtable - Support for ACPI tables that contain no AML code 4167802Sjkim * $Revision: 1.12 $ 5167802Sjkim * 6167802Sjkim *****************************************************************************/ 7167802Sjkim 8167802Sjkim/****************************************************************************** 9167802Sjkim * 10167802Sjkim * 1. Copyright Notice 11167802Sjkim * 12167802Sjkim * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. 13167802Sjkim * All rights reserved. 14167802Sjkim * 15167802Sjkim * 2. License 16167802Sjkim * 17167802Sjkim * 2.1. This is your license from Intel Corp. under its intellectual property 18167802Sjkim * rights. You may have additional license terms from the party that provided 19167802Sjkim * you this software, covering your right to use that party's intellectual 20167802Sjkim * property rights. 21167802Sjkim * 22167802Sjkim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23167802Sjkim * copy of the source code appearing in this file ("Covered Code") an 24167802Sjkim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25167802Sjkim * base code distributed originally by Intel ("Original Intel Code") to copy, 26167802Sjkim * make derivatives, distribute, use and display any portion of the Covered 27167802Sjkim * Code in any form, with the right to sublicense such rights; and 28167802Sjkim * 29167802Sjkim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30167802Sjkim * license (with the right to sublicense), under only those claims of Intel 31167802Sjkim * patents that are infringed by the Original Intel Code, to make, use, sell, 32167802Sjkim * offer to sell, and import the Covered Code and derivative works thereof 33167802Sjkim * solely to the minimum extent necessary to exercise the above copyright 34167802Sjkim * license, and in no event shall the patent license extend to any additions 35167802Sjkim * to or modifications of the Original Intel Code. No other license or right 36167802Sjkim * is granted directly or by implication, estoppel or otherwise; 37167802Sjkim * 38167802Sjkim * The above copyright and patent license is granted only if the following 39167802Sjkim * conditions are met: 40167802Sjkim * 41167802Sjkim * 3. Conditions 42167802Sjkim * 43167802Sjkim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44167802Sjkim * Redistribution of source code of any substantial portion of the Covered 45167802Sjkim * Code or modification with rights to further distribute source must include 46167802Sjkim * the above Copyright Notice, the above License, this list of Conditions, 47167802Sjkim * and the following Disclaimer and Export Compliance provision. In addition, 48167802Sjkim * Licensee must cause all Covered Code to which Licensee contributes to 49167802Sjkim * contain a file documenting the changes Licensee made to create that Covered 50167802Sjkim * Code and the date of any change. Licensee must include in that file the 51167802Sjkim * documentation of any changes made by any predecessor Licensee. Licensee 52167802Sjkim * must include a prominent statement that the modification is derived, 53167802Sjkim * directly or indirectly, from Original Intel Code. 54167802Sjkim * 55167802Sjkim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56167802Sjkim * Redistribution of source code of any substantial portion of the Covered 57167802Sjkim * Code or modification without rights to further distribute source must 58167802Sjkim * include the following Disclaimer and Export Compliance provision in the 59167802Sjkim * documentation and/or other materials provided with distribution. In 60167802Sjkim * addition, Licensee may not authorize further sublicense of source of any 61167802Sjkim * portion of the Covered Code, and must include terms to the effect that the 62167802Sjkim * license from Licensee to its licensee is limited to the intellectual 63167802Sjkim * property embodied in the software Licensee provides to its licensee, and 64167802Sjkim * not to intellectual property embodied in modifications its licensee may 65167802Sjkim * make. 66167802Sjkim * 67167802Sjkim * 3.3. Redistribution of Executable. Redistribution in executable form of any 68167802Sjkim * substantial portion of the Covered Code or modification must reproduce the 69167802Sjkim * above Copyright Notice, and the following Disclaimer and Export Compliance 70167802Sjkim * provision in the documentation and/or other materials provided with the 71167802Sjkim * distribution. 72167802Sjkim * 73167802Sjkim * 3.4. Intel retains all right, title, and interest in and to the Original 74167802Sjkim * Intel Code. 75167802Sjkim * 76167802Sjkim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77167802Sjkim * Intel shall be used in advertising or otherwise to promote the sale, use or 78167802Sjkim * other dealings in products derived from or relating to the Covered Code 79167802Sjkim * without prior written authorization from Intel. 80167802Sjkim * 81167802Sjkim * 4. Disclaimer and Export Compliance 82167802Sjkim * 83167802Sjkim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84167802Sjkim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85167802Sjkim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86167802Sjkim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87167802Sjkim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88167802Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89167802Sjkim * PARTICULAR PURPOSE. 90167802Sjkim * 91167802Sjkim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92167802Sjkim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93167802Sjkim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94167802Sjkim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95167802Sjkim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96167802Sjkim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97167802Sjkim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98167802Sjkim * LIMITED REMEDY. 99167802Sjkim * 100167802Sjkim * 4.3. Licensee shall not export, either directly or indirectly, any of this 101167802Sjkim * software or system incorporating such software without first obtaining any 102167802Sjkim * required license or other approval from the U. S. Department of Commerce or 103167802Sjkim * any other agency or department of the United States Government. In the 104167802Sjkim * event Licensee exports any such software from the United States or 105167802Sjkim * re-exports any such software from a foreign destination, Licensee shall 106167802Sjkim * ensure that the distribution and export/re-export of the software is in 107167802Sjkim * compliance with all laws, regulations, orders, or other restrictions of the 108167802Sjkim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109167802Sjkim * any of its subsidiaries will export/re-export any technical data, process, 110167802Sjkim * software, or service, directly or indirectly, to any country for which the 111167802Sjkim * United States government or any agency thereof requires an export license, 112167802Sjkim * other governmental approval, or letter of assurance, without first obtaining 113167802Sjkim * such license, approval or letter. 114167802Sjkim * 115167802Sjkim *****************************************************************************/ 116167802Sjkim 117167802Sjkim#include <contrib/dev/acpica/acpi.h> 118167802Sjkim#include <contrib/dev/acpica/acdisasm.h> 119167802Sjkim#include <contrib/dev/acpica/actables.h> 120167802Sjkim 121167802Sjkim/* This module used for application-level code only */ 122167802Sjkim 123167802Sjkim#define _COMPONENT ACPI_CA_DISASSEMBLER 124167802Sjkim ACPI_MODULE_NAME ("dmtable") 125167802Sjkim 126167802Sjkim/* Local Prototypes */ 127167802Sjkim 128167802Sjkimstatic ACPI_DMTABLE_DATA * 129167802SjkimAcpiDmGetTableData ( 130167802Sjkim char *Signature); 131167802Sjkim 132167802Sjkimstatic void 133167802SjkimAcpiDmCheckAscii ( 134167802Sjkim UINT8 *Target, 135167802Sjkim UINT32 Count); 136167802Sjkim 137167802Sjkim 138167802Sjkim/* These tables map a subtable type to a description string */ 139167802Sjkim 140167802Sjkimstatic const char *AcpiDmDmarSubnames[] = 141167802Sjkim{ 142167802Sjkim "Hardware Unit Definition", 143167802Sjkim "Reserved Memory Region", 144167802Sjkim "Unknown SubTable Type" /* Reserved */ 145167802Sjkim}; 146167802Sjkim 147167802Sjkimstatic const char *AcpiDmMadtSubnames[] = 148167802Sjkim{ 149167802Sjkim "Processor Local APIC", /* ACPI_MADT_TYPE_LOCAL_APIC */ 150167802Sjkim "I/O APIC", /* ACPI_MADT_TYPE_IO_APIC */ 151167802Sjkim "Interrupt Source Override", /* ACPI_MADT_TYPE_INTERRUPT_OVERRIDE */ 152167802Sjkim "NMI Source", /* ACPI_MADT_TYPE_NMI_SOURCE */ 153167802Sjkim "Local APIC NMI", /* ACPI_MADT_TYPE_LOCAL_APIC_NMI */ 154167802Sjkim "Local APIC Address Override", /* ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE */ 155167802Sjkim "I/O SAPIC", /* ACPI_MADT_TYPE_IO_SAPIC */ 156167802Sjkim "Local SAPIC", /* ACPI_MADT_TYPE_LOCAL_SAPIC */ 157167802Sjkim "Platform Interrupt Sources", /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */ 158167802Sjkim "Unknown SubTable Type" /* Reserved */ 159167802Sjkim}; 160167802Sjkim 161167802Sjkimstatic const char *AcpiDmSratSubnames[] = 162167802Sjkim{ 163167802Sjkim "Processor Local APIC/SAPIC Affinity", 164167802Sjkim "Memory Affinity", 165167802Sjkim "Unknown SubTable Type" /* Reserved */ 166167802Sjkim}; 167167802Sjkim 168167802Sjkim 169167802Sjkim/******************************************************************************* 170167802Sjkim * 171167802Sjkim * ACPI Table Data, indexed by signature. 172167802Sjkim * 173167802Sjkim * Simple tables have only a TableInfo structure, complex tables have a handler. 174167802Sjkim * This table must be NULL terminated. RSDP and FACS are special-cased 175167802Sjkim * elsewhere. 176167802Sjkim * 177167802Sjkim ******************************************************************************/ 178167802Sjkim 179167802Sjkimstatic ACPI_DMTABLE_DATA AcpiDmTableData[] = 180167802Sjkim{ 181167802Sjkim {ACPI_SIG_ASF, NULL, AcpiDmDumpAsf, "Alert Standard Format table"}, 182167802Sjkim {ACPI_SIG_BOOT, AcpiDmTableInfoBoot, NULL, "Simple Boot Flag Table"}, 183167802Sjkim {ACPI_SIG_CPEP, NULL, AcpiDmDumpCpep, "Corrected Platform Error Polling table"}, 184167802Sjkim {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp, NULL, "Debug Port table"}, 185167802Sjkim {ACPI_SIG_DMAR, NULL, AcpiDmDumpDmar, "DMA Remapping table"}, 186167802Sjkim {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt, NULL, "Embedded Controller Boot Resources Table"}, 187167802Sjkim {ACPI_SIG_FADT, NULL, AcpiDmDumpFadt, "Fixed ACPI Description Table"}, 188167802Sjkim {ACPI_SIG_HPET, AcpiDmTableInfoHpet, NULL, "High Precision Event Timer table"}, 189167802Sjkim {ACPI_SIG_MADT, NULL, AcpiDmDumpMadt, "Multiple APIC Description Table"}, 190167802Sjkim {ACPI_SIG_MCFG, NULL, AcpiDmDumpMcfg, "Memory Mapped Configuration table"}, 191167802Sjkim {ACPI_SIG_RSDT, NULL, AcpiDmDumpRsdt, "Root System Description Table"}, 192167802Sjkim {ACPI_SIG_SBST, AcpiDmTableInfoSbst, NULL, "Smart Battery Specification Table"}, 193167802Sjkim {ACPI_SIG_SLIT, NULL, AcpiDmDumpSlit, "System Locality Information Table"}, 194167802Sjkim {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr, NULL, "Serial Port Console Redirection table"}, 195167802Sjkim {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi, NULL, "Server Platform Management Interface table"}, 196167802Sjkim {ACPI_SIG_SRAT, NULL, AcpiDmDumpSrat, "System Resource Affinity Table"}, 197167802Sjkim {ACPI_SIG_TCPA, AcpiDmTableInfoTcpa, NULL, "Trusted Computing Platform Alliance table"}, 198167802Sjkim {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt, NULL, "Watchdog Resource Table"}, 199167802Sjkim {ACPI_SIG_XSDT, NULL, AcpiDmDumpXsdt, "Extended System Description Table"}, 200167802Sjkim {NULL, NULL, NULL, NULL} 201167802Sjkim}; 202167802Sjkim 203167802Sjkim 204167802Sjkim/******************************************************************************* 205167802Sjkim * 206167802Sjkim * FUNCTION: AcpiTbGenerateChecksum 207167802Sjkim * 208167802Sjkim * PARAMETERS: Table - Pointer to a valid ACPI table (with a 209167802Sjkim * standard ACPI header) 210167802Sjkim * 211167802Sjkim * RETURN: 8 bit checksum of buffer 212167802Sjkim * 213167802Sjkim * DESCRIPTION: Computes an 8 bit checksum of the table. 214167802Sjkim * 215167802Sjkim ******************************************************************************/ 216167802Sjkim 217167802SjkimUINT8 218167802SjkimAcpiTbGenerateChecksum ( 219167802Sjkim ACPI_TABLE_HEADER *Table) 220167802Sjkim{ 221167802Sjkim UINT8 Checksum; 222167802Sjkim 223167802Sjkim 224167802Sjkim /* Sum the entire table as-is */ 225167802Sjkim 226167802Sjkim Checksum = AcpiTbChecksum ((UINT8 *) Table, Table->Length); 227167802Sjkim 228167802Sjkim /* Subtract off the existing checksum value in the table */ 229167802Sjkim 230167802Sjkim Checksum = (UINT8) (Checksum - Table->Checksum); 231167802Sjkim 232167802Sjkim /* Compute the final checksum */ 233167802Sjkim 234167802Sjkim Checksum = (UINT8) (0 - Checksum); 235167802Sjkim return (Checksum); 236167802Sjkim} 237167802Sjkim 238167802Sjkim 239167802Sjkim/******************************************************************************* 240167802Sjkim * 241167802Sjkim * FUNCTION: AcpiDmGetTableData 242167802Sjkim * 243167802Sjkim * PARAMETERS: Signature - ACPI signature (4 chars) to match 244167802Sjkim * 245167802Sjkim * RETURN: Pointer to a valid ACPI_DMTABLE_DATA. Null if no match found. 246167802Sjkim * 247167802Sjkim * DESCRIPTION: Find a match in the global table of supported ACPI tables 248167802Sjkim * 249167802Sjkim ******************************************************************************/ 250167802Sjkim 251167802Sjkimstatic ACPI_DMTABLE_DATA * 252167802SjkimAcpiDmGetTableData ( 253167802Sjkim char *Signature) 254167802Sjkim{ 255167802Sjkim ACPI_DMTABLE_DATA *TableData; 256167802Sjkim 257167802Sjkim 258167802Sjkim for (TableData = AcpiDmTableData; TableData->Signature; TableData++) 259167802Sjkim { 260167802Sjkim if (ACPI_COMPARE_NAME (Signature, TableData->Signature)) 261167802Sjkim { 262167802Sjkim return (TableData); 263167802Sjkim } 264167802Sjkim } 265167802Sjkim 266167802Sjkim return (NULL); 267167802Sjkim} 268167802Sjkim 269167802Sjkim 270167802Sjkim/******************************************************************************* 271167802Sjkim * 272167802Sjkim * FUNCTION: AcpiDmDumpDataTable 273167802Sjkim * 274167802Sjkim * PARAMETERS: Table - An ACPI table 275167802Sjkim * 276167802Sjkim * RETURN: None. 277167802Sjkim * 278167802Sjkim * DESCRIPTION: Format the contents of an ACPI data table (any table other 279167802Sjkim * than an SSDT or DSDT that does not contain executable AML code) 280167802Sjkim * 281167802Sjkim ******************************************************************************/ 282167802Sjkim 283167802Sjkimvoid 284167802SjkimAcpiDmDumpDataTable ( 285167802Sjkim ACPI_TABLE_HEADER *Table) 286167802Sjkim{ 287167802Sjkim ACPI_DMTABLE_DATA *TableData; 288167802Sjkim UINT32 Length; 289167802Sjkim 290167802Sjkim 291167802Sjkim /* Ignore tables that contain AML */ 292167802Sjkim 293167802Sjkim if (AcpiUtIsAmlTable (Table)) 294167802Sjkim { 295167802Sjkim return; 296167802Sjkim } 297167802Sjkim 298167802Sjkim /* 299167802Sjkim * Handle tables that don't use the common ACPI table header structure. 300167802Sjkim * Currently, these are the FACS and RSDP. 301167802Sjkim */ 302167802Sjkim if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS)) 303167802Sjkim { 304167802Sjkim Length = Table->Length; 305167802Sjkim AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFacs); 306167802Sjkim } 307167802Sjkim else if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_RSDP)) 308167802Sjkim { 309167802Sjkim Length = AcpiDmDumpRsdp (Table); 310167802Sjkim } 311167802Sjkim else 312167802Sjkim { 313167802Sjkim /* 314167802Sjkim * All other tables must use the common ACPI table header, dump it now 315167802Sjkim */ 316167802Sjkim Length = Table->Length; 317167802Sjkim AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHeader); 318167802Sjkim AcpiOsPrintf ("\n"); 319167802Sjkim 320167802Sjkim /* Match signature and dispatch appropriately */ 321167802Sjkim 322167802Sjkim TableData = AcpiDmGetTableData (Table->Signature); 323167802Sjkim if (!TableData) 324167802Sjkim { 325167802Sjkim if (!ACPI_STRNCMP (Table->Signature, "OEM", 3)) 326167802Sjkim { 327167802Sjkim AcpiOsPrintf ("\n**** OEM-defined ACPI table [%4.4s], unknown contents\n\n", 328167802Sjkim Table->Signature); 329167802Sjkim } 330167802Sjkim else 331167802Sjkim { 332167802Sjkim AcpiOsPrintf ("\n**** Unknown ACPI table type [%4.4s]\n\n", 333167802Sjkim Table->Signature); 334167802Sjkim } 335167802Sjkim } 336167802Sjkim else if (TableData->TableHandler) 337167802Sjkim { 338167802Sjkim /* Complex table, has a handler */ 339167802Sjkim 340167802Sjkim TableData->TableHandler (Table); 341167802Sjkim } 342167802Sjkim else if (TableData->TableInfo) 343167802Sjkim { 344167802Sjkim /* Simple table, just walk the info table */ 345167802Sjkim 346167802Sjkim AcpiDmDumpTable (Length, 0, Table, 0, TableData->TableInfo); 347167802Sjkim } 348167802Sjkim } 349167802Sjkim 350167802Sjkim /* Always dump the raw table data */ 351167802Sjkim 352167802Sjkim AcpiOsPrintf ("\nRaw Table Data\n\n"); 353167802Sjkim AcpiUtDumpBuffer2 (ACPI_CAST_PTR (UINT8, Table), Length, DB_BYTE_DISPLAY); 354167802Sjkim} 355167802Sjkim 356167802Sjkim 357167802Sjkim/******************************************************************************* 358167802Sjkim * 359167802Sjkim * FUNCTION: AcpiDmLineHeader 360167802Sjkim * 361167802Sjkim * PARAMETERS: Offset - Current byte offset, from table start 362167802Sjkim * ByteLength - Length of the field in bytes, 0 for flags 363167802Sjkim * Name - Name of this field 364167802Sjkim * Value - Optional value, displayed on left of ':' 365167802Sjkim * 366167802Sjkim * RETURN: None 367167802Sjkim * 368167802Sjkim * DESCRIPTION: Utility routines for formatting output lines. Displays the 369167802Sjkim * current table offset in hex and decimal, the field length, 370167802Sjkim * and the field name. 371167802Sjkim * 372167802Sjkim ******************************************************************************/ 373167802Sjkim 374167802Sjkimvoid 375167802SjkimAcpiDmLineHeader ( 376167802Sjkim UINT32 Offset, 377167802Sjkim UINT32 ByteLength, 378167802Sjkim char *Name) 379167802Sjkim{ 380167802Sjkim 381167802Sjkim if (ByteLength) 382167802Sjkim { 383167802Sjkim AcpiOsPrintf ("[%3.3Xh %3.3d% 3d] %28s : ", 384167802Sjkim Offset, Offset, ByteLength, Name); 385167802Sjkim } 386167802Sjkim else 387167802Sjkim { 388167802Sjkim AcpiOsPrintf ("%42s : ", 389167802Sjkim Name); 390167802Sjkim } 391167802Sjkim} 392167802Sjkim 393167802Sjkimvoid 394167802SjkimAcpiDmLineHeader2 ( 395167802Sjkim UINT32 Offset, 396167802Sjkim UINT32 ByteLength, 397167802Sjkim char *Name, 398167802Sjkim UINT32 Value) 399167802Sjkim{ 400167802Sjkim 401167802Sjkim if (ByteLength) 402167802Sjkim { 403167802Sjkim AcpiOsPrintf ("[%3.3Xh %3.3d% 3d] %24s % 3d : ", 404167802Sjkim Offset, Offset, ByteLength, Name, Value); 405167802Sjkim } 406167802Sjkim else 407167802Sjkim { 408167802Sjkim AcpiOsPrintf ("[%3.3Xh %3.3d ] %24s % 3d : ", 409167802Sjkim Offset, Offset, Name, Value); 410167802Sjkim } 411167802Sjkim} 412167802Sjkim 413167802Sjkim 414167802Sjkim/******************************************************************************* 415167802Sjkim * 416167802Sjkim * FUNCTION: AcpiDmDumpTable 417167802Sjkim * 418167802Sjkim * PARAMETERS: TableLength - Length of the entire ACPI table 419167802Sjkim * TableOffset - Starting offset within the table for this 420167802Sjkim * sub-descriptor (0 if main table) 421167802Sjkim * Table - The ACPI table 422167802Sjkim * SubtableLength - Lenghth of this sub-descriptor 423167802Sjkim * Info - Info table for this ACPI table 424167802Sjkim * 425167802Sjkim * RETURN: None 426167802Sjkim * 427167802Sjkim * DESCRIPTION: Display ACPI table contents by walking the Info table. 428167802Sjkim * 429167802Sjkim ******************************************************************************/ 430167802Sjkim 431167802Sjkimvoid 432167802SjkimAcpiDmDumpTable ( 433167802Sjkim UINT32 TableLength, 434167802Sjkim UINT32 TableOffset, 435167802Sjkim void *Table, 436167802Sjkim UINT32 SubtableLength, 437167802Sjkim ACPI_DMTABLE_INFO *Info) 438167802Sjkim{ 439167802Sjkim UINT8 *Target; 440167802Sjkim UINT32 CurrentOffset; 441167802Sjkim UINT32 ByteLength; 442167802Sjkim UINT8 Temp8; 443167802Sjkim UINT16 Temp16; 444167802Sjkim ACPI_DMTABLE_DATA *TableData; 445167802Sjkim 446167802Sjkim 447167802Sjkim if (!Info) 448167802Sjkim { 449167802Sjkim AcpiOsPrintf ("Display not implemented\n"); 450167802Sjkim return; 451167802Sjkim } 452167802Sjkim 453167802Sjkim /* Walk entire Info table; Null name terminates */ 454167802Sjkim 455167802Sjkim for (; Info->Name; Info++) 456167802Sjkim { 457167802Sjkim /* 458167802Sjkim * Target points to the field within the ACPI Table. CurrentOffset is 459167802Sjkim * the offset of the field from the start of the main table. 460167802Sjkim */ 461167802Sjkim Target = ACPI_ADD_PTR (UINT8, Table, Info->Offset); 462167802Sjkim CurrentOffset = TableOffset + Info->Offset; 463167802Sjkim 464167802Sjkim /* Check for beyond EOT or beyond subtable end */ 465167802Sjkim 466167802Sjkim if ((CurrentOffset >= TableLength) || 467167802Sjkim (SubtableLength && (Info->Offset >= SubtableLength))) 468167802Sjkim { 469167802Sjkim return; 470167802Sjkim } 471167802Sjkim 472167802Sjkim /* Generate the byte length for this field */ 473167802Sjkim 474167802Sjkim switch (Info->Opcode) 475167802Sjkim { 476167802Sjkim case ACPI_DMT_UINT8: 477167802Sjkim case ACPI_DMT_CHKSUM: 478167802Sjkim case ACPI_DMT_SPACEID: 479167802Sjkim case ACPI_DMT_MADT: 480167802Sjkim case ACPI_DMT_SRAT: 481167802Sjkim ByteLength = 1; 482167802Sjkim break; 483167802Sjkim case ACPI_DMT_UINT16: 484167802Sjkim case ACPI_DMT_DMAR: 485167802Sjkim ByteLength = 2; 486167802Sjkim break; 487167802Sjkim case ACPI_DMT_UINT24: 488167802Sjkim ByteLength = 3; 489167802Sjkim break; 490167802Sjkim case ACPI_DMT_UINT32: 491167802Sjkim case ACPI_DMT_NAME4: 492167802Sjkim case ACPI_DMT_SIG: 493167802Sjkim ByteLength = 4; 494167802Sjkim break; 495167802Sjkim case ACPI_DMT_NAME6: 496167802Sjkim ByteLength = 6; 497167802Sjkim break; 498167802Sjkim case ACPI_DMT_UINT56: 499167802Sjkim ByteLength = 7; 500167802Sjkim break; 501167802Sjkim case ACPI_DMT_UINT64: 502167802Sjkim case ACPI_DMT_NAME8: 503167802Sjkim ByteLength = 8; 504167802Sjkim break; 505167802Sjkim case ACPI_DMT_STRING: 506167802Sjkim ByteLength = ACPI_STRLEN (ACPI_CAST_PTR (char, Target)) + 1; 507167802Sjkim break; 508167802Sjkim case ACPI_DMT_GAS: 509167802Sjkim AcpiOsPrintf ("\n"); 510167802Sjkim ByteLength = sizeof (ACPI_GENERIC_ADDRESS); 511167802Sjkim break; 512167802Sjkim default: 513167802Sjkim ByteLength = 0; 514167802Sjkim break; 515167802Sjkim } 516167802Sjkim 517167802Sjkim /* Start a new line and decode the opcode */ 518167802Sjkim 519167802Sjkim AcpiDmLineHeader (CurrentOffset, ByteLength, Info->Name); 520167802Sjkim 521167802Sjkim switch (Info->Opcode) 522167802Sjkim { 523167802Sjkim /* Single-bit Flag fields. Note: Opcode is the bit position */ 524167802Sjkim 525167802Sjkim case ACPI_DMT_FLAG0: 526167802Sjkim case ACPI_DMT_FLAG1: 527167802Sjkim case ACPI_DMT_FLAG2: 528167802Sjkim case ACPI_DMT_FLAG3: 529167802Sjkim case ACPI_DMT_FLAG4: 530167802Sjkim case ACPI_DMT_FLAG5: 531167802Sjkim case ACPI_DMT_FLAG6: 532167802Sjkim case ACPI_DMT_FLAG7: 533167802Sjkim 534167802Sjkim AcpiOsPrintf ("%1.1X\n", (*Target >> Info->Opcode) & 0x01); 535167802Sjkim break; 536167802Sjkim 537167802Sjkim /* 2-bit Flag fields */ 538167802Sjkim 539167802Sjkim case ACPI_DMT_FLAGS0: 540167802Sjkim 541167802Sjkim AcpiOsPrintf ("%1.1X\n", *Target & 0x03); 542167802Sjkim break; 543167802Sjkim 544167802Sjkim case ACPI_DMT_FLAGS2: 545167802Sjkim 546167802Sjkim AcpiOsPrintf ("%1.1X\n", (*Target >> 2) & 0x03); 547167802Sjkim break; 548167802Sjkim 549167802Sjkim /* Standard Data Types */ 550167802Sjkim 551167802Sjkim case ACPI_DMT_UINT8: 552167802Sjkim 553167802Sjkim AcpiOsPrintf ("%2.2X\n", *Target); 554167802Sjkim break; 555167802Sjkim 556167802Sjkim case ACPI_DMT_UINT16: 557167802Sjkim 558167802Sjkim AcpiOsPrintf ("%4.4X\n", ACPI_GET16 (Target)); 559167802Sjkim break; 560167802Sjkim 561167802Sjkim case ACPI_DMT_UINT24: 562167802Sjkim 563167802Sjkim AcpiOsPrintf ("%2.2X%2.2X%2.2X\n", 564167802Sjkim *Target, *(Target + 1), *(Target + 2)); 565167802Sjkim break; 566167802Sjkim 567167802Sjkim case ACPI_DMT_UINT32: 568167802Sjkim 569167802Sjkim AcpiOsPrintf ("%8.8X\n", ACPI_GET32 (Target)); 570167802Sjkim break; 571167802Sjkim 572167802Sjkim case ACPI_DMT_UINT56: 573167802Sjkim 574167802Sjkim AcpiOsPrintf ("%6.6X%8.8X\n", 575167802Sjkim ACPI_HIDWORD (ACPI_GET64 (Target)) & 0x00FFFFFF, 576167802Sjkim ACPI_LODWORD (ACPI_GET64 (Target))); 577167802Sjkim break; 578167802Sjkim 579167802Sjkim case ACPI_DMT_UINT64: 580167802Sjkim 581167802Sjkim AcpiOsPrintf ("%8.8X%8.8X\n", 582167802Sjkim ACPI_FORMAT_UINT64 (ACPI_GET64 (Target))); 583167802Sjkim break; 584167802Sjkim 585167802Sjkim case ACPI_DMT_STRING: 586167802Sjkim 587167802Sjkim AcpiOsPrintf ("%s\n", ACPI_CAST_PTR (char, Target)); 588167802Sjkim break; 589167802Sjkim 590167802Sjkim /* Fixed length ASCII name fields */ 591167802Sjkim 592167802Sjkim case ACPI_DMT_SIG: 593167802Sjkim 594167802Sjkim AcpiDmCheckAscii (Target, 4); 595167802Sjkim AcpiOsPrintf ("\"%4.4s\" ", Target); 596167802Sjkim TableData = AcpiDmGetTableData (ACPI_CAST_PTR (char, Target)); 597167802Sjkim if (TableData) 598167802Sjkim { 599167802Sjkim AcpiOsPrintf ("/* %s */", TableData->Name); 600167802Sjkim } 601167802Sjkim AcpiOsPrintf ("\n"); 602167802Sjkim break; 603167802Sjkim 604167802Sjkim case ACPI_DMT_NAME4: 605167802Sjkim 606167802Sjkim AcpiDmCheckAscii (Target, 4); 607167802Sjkim AcpiOsPrintf ("\"%4.4s\"\n", Target); 608167802Sjkim break; 609167802Sjkim 610167802Sjkim case ACPI_DMT_NAME6: 611167802Sjkim 612167802Sjkim AcpiDmCheckAscii (Target, 6); 613167802Sjkim AcpiOsPrintf ("\"%6.6s\"\n", Target); 614167802Sjkim break; 615167802Sjkim 616167802Sjkim case ACPI_DMT_NAME8: 617167802Sjkim 618167802Sjkim AcpiDmCheckAscii (Target, 8); 619167802Sjkim AcpiOsPrintf ("\"%8.8s\"\n", Target); 620167802Sjkim break; 621167802Sjkim 622167802Sjkim /* Special Data Types */ 623167802Sjkim 624167802Sjkim case ACPI_DMT_CHKSUM: 625167802Sjkim 626167802Sjkim /* Checksum, display and validate */ 627167802Sjkim 628167802Sjkim AcpiOsPrintf ("%2.2X", *Target); 629167802Sjkim Temp8 = AcpiTbGenerateChecksum (Table); 630167802Sjkim if (Temp8 != ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum) 631167802Sjkim { 632167802Sjkim AcpiOsPrintf ( 633167802Sjkim " /* Incorrect checksum, should be %2.2X */", Temp8); 634167802Sjkim } 635167802Sjkim AcpiOsPrintf ("\n"); 636167802Sjkim break; 637167802Sjkim 638167802Sjkim case ACPI_DMT_SPACEID: 639167802Sjkim 640167802Sjkim /* Address Space ID */ 641167802Sjkim 642167802Sjkim AcpiOsPrintf ("%2.2X (%s)\n", *Target, AcpiUtGetRegionName (*Target)); 643167802Sjkim break; 644167802Sjkim 645167802Sjkim case ACPI_DMT_GAS: 646167802Sjkim 647167802Sjkim /* Generic Address Structure */ 648167802Sjkim 649167802Sjkim AcpiOsPrintf ("<Generic Address Structure>\n"); 650167802Sjkim AcpiDmDumpTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length, 651167802Sjkim CurrentOffset, Target, 0, AcpiDmTableInfoGas); 652167802Sjkim break; 653167802Sjkim 654167802Sjkim case ACPI_DMT_DMAR: 655167802Sjkim 656167802Sjkim /* DMAR subtable types */ 657167802Sjkim 658167802Sjkim Temp16 = *Target; 659167802Sjkim if (Temp16 > ACPI_DMAR_TYPE_RESERVED) 660167802Sjkim { 661167802Sjkim Temp16 = ACPI_DMAR_TYPE_RESERVED; 662167802Sjkim } 663167802Sjkim 664167802Sjkim AcpiOsPrintf ("%4.4X <%s>\n", *Target, AcpiDmDmarSubnames[Temp16]); 665167802Sjkim break; 666167802Sjkim 667167802Sjkim case ACPI_DMT_MADT: 668167802Sjkim 669167802Sjkim /* MADT subtable types */ 670167802Sjkim 671167802Sjkim Temp8 = *Target; 672167802Sjkim if (Temp8 > ACPI_MADT_TYPE_RESERVED) 673167802Sjkim { 674167802Sjkim Temp8 = ACPI_MADT_TYPE_RESERVED; 675167802Sjkim } 676167802Sjkim 677167802Sjkim AcpiOsPrintf ("%2.2X <%s>\n", *Target, AcpiDmMadtSubnames[Temp8]); 678167802Sjkim break; 679167802Sjkim 680167802Sjkim case ACPI_DMT_SRAT: 681167802Sjkim 682167802Sjkim /* SRAT subtable types */ 683167802Sjkim 684167802Sjkim Temp8 = *Target; 685167802Sjkim if (Temp8 > ACPI_SRAT_TYPE_RESERVED) 686167802Sjkim { 687167802Sjkim Temp8 = ACPI_SRAT_TYPE_RESERVED; 688167802Sjkim } 689167802Sjkim 690167802Sjkim AcpiOsPrintf ("%2.2X <%s>\n", *Target, AcpiDmSratSubnames[Temp8]); 691167802Sjkim break; 692167802Sjkim 693167802Sjkim case ACPI_DMT_EXIT: 694167802Sjkim return; 695167802Sjkim 696167802Sjkim default: 697167802Sjkim ACPI_ERROR ((AE_INFO, 698167802Sjkim "**** Invalid table opcode [%X] ****\n", Info->Opcode)); 699167802Sjkim return; 700167802Sjkim } 701167802Sjkim } 702167802Sjkim} 703167802Sjkim 704167802Sjkim 705167802Sjkim/******************************************************************************* 706167802Sjkim * 707167802Sjkim * FUNCTION: AcpiDmCheckAscii 708167802Sjkim * 709167802Sjkim * PARAMETERS: Name - Ascii string 710167802Sjkim * Count - Number of characters to check 711167802Sjkim * 712167802Sjkim * RETURN: None 713167802Sjkim * 714167802Sjkim * DESCRIPTION: Ensure that the requested number of characters are printable 715167802Sjkim * Ascii characters. Sets non-printable and null chars to <space>. 716167802Sjkim * 717167802Sjkim ******************************************************************************/ 718167802Sjkim 719167802Sjkimstatic void 720167802SjkimAcpiDmCheckAscii ( 721167802Sjkim UINT8 *Name, 722167802Sjkim UINT32 Count) 723167802Sjkim{ 724167802Sjkim UINT32 i; 725167802Sjkim 726167802Sjkim 727167802Sjkim for (i = 0; i < Count; i++) 728167802Sjkim { 729167802Sjkim if (!Name[i] || !isprint (Name[i])) 730167802Sjkim { 731167802Sjkim Name[i] = ' '; 732167802Sjkim } 733167802Sjkim } 734167802Sjkim} 735