dmutils.c revision 114237
1100966Siwasaki/******************************************************************************* 2100966Siwasaki * 3100966Siwasaki * Module Name: dmutils - AML disassembler utilities 4114237Snjl * $Revision: 8 $ 5100966Siwasaki * 6100966Siwasaki ******************************************************************************/ 7100966Siwasaki 8100966Siwasaki/****************************************************************************** 9100966Siwasaki * 10100966Siwasaki * 1. Copyright Notice 11100966Siwasaki * 12114237Snjl * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. 13100966Siwasaki * All rights reserved. 14100966Siwasaki * 15100966Siwasaki * 2. License 16100966Siwasaki * 17100966Siwasaki * 2.1. This is your license from Intel Corp. under its intellectual property 18100966Siwasaki * rights. You may have additional license terms from the party that provided 19100966Siwasaki * you this software, covering your right to use that party's intellectual 20100966Siwasaki * property rights. 21100966Siwasaki * 22100966Siwasaki * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23100966Siwasaki * copy of the source code appearing in this file ("Covered Code") an 24100966Siwasaki * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25100966Siwasaki * base code distributed originally by Intel ("Original Intel Code") to copy, 26100966Siwasaki * make derivatives, distribute, use and display any portion of the Covered 27100966Siwasaki * Code in any form, with the right to sublicense such rights; and 28100966Siwasaki * 29100966Siwasaki * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30100966Siwasaki * license (with the right to sublicense), under only those claims of Intel 31100966Siwasaki * patents that are infringed by the Original Intel Code, to make, use, sell, 32100966Siwasaki * offer to sell, and import the Covered Code and derivative works thereof 33100966Siwasaki * solely to the minimum extent necessary to exercise the above copyright 34100966Siwasaki * license, and in no event shall the patent license extend to any additions 35100966Siwasaki * to or modifications of the Original Intel Code. No other license or right 36100966Siwasaki * is granted directly or by implication, estoppel or otherwise; 37100966Siwasaki * 38100966Siwasaki * The above copyright and patent license is granted only if the following 39100966Siwasaki * conditions are met: 40100966Siwasaki * 41100966Siwasaki * 3. Conditions 42100966Siwasaki * 43100966Siwasaki * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44100966Siwasaki * Redistribution of source code of any substantial portion of the Covered 45100966Siwasaki * Code or modification with rights to further distribute source must include 46100966Siwasaki * the above Copyright Notice, the above License, this list of Conditions, 47100966Siwasaki * and the following Disclaimer and Export Compliance provision. In addition, 48100966Siwasaki * Licensee must cause all Covered Code to which Licensee contributes to 49100966Siwasaki * contain a file documenting the changes Licensee made to create that Covered 50100966Siwasaki * Code and the date of any change. Licensee must include in that file the 51100966Siwasaki * documentation of any changes made by any predecessor Licensee. Licensee 52100966Siwasaki * must include a prominent statement that the modification is derived, 53100966Siwasaki * directly or indirectly, from Original Intel Code. 54100966Siwasaki * 55100966Siwasaki * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56100966Siwasaki * Redistribution of source code of any substantial portion of the Covered 57100966Siwasaki * Code or modification without rights to further distribute source must 58100966Siwasaki * include the following Disclaimer and Export Compliance provision in the 59100966Siwasaki * documentation and/or other materials provided with distribution. In 60100966Siwasaki * addition, Licensee may not authorize further sublicense of source of any 61100966Siwasaki * portion of the Covered Code, and must include terms to the effect that the 62100966Siwasaki * license from Licensee to its licensee is limited to the intellectual 63100966Siwasaki * property embodied in the software Licensee provides to its licensee, and 64100966Siwasaki * not to intellectual property embodied in modifications its licensee may 65100966Siwasaki * make. 66100966Siwasaki * 67100966Siwasaki * 3.3. Redistribution of Executable. Redistribution in executable form of any 68100966Siwasaki * substantial portion of the Covered Code or modification must reproduce the 69100966Siwasaki * above Copyright Notice, and the following Disclaimer and Export Compliance 70100966Siwasaki * provision in the documentation and/or other materials provided with the 71100966Siwasaki * distribution. 72100966Siwasaki * 73100966Siwasaki * 3.4. Intel retains all right, title, and interest in and to the Original 74100966Siwasaki * Intel Code. 75100966Siwasaki * 76100966Siwasaki * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77100966Siwasaki * Intel shall be used in advertising or otherwise to promote the sale, use or 78100966Siwasaki * other dealings in products derived from or relating to the Covered Code 79100966Siwasaki * without prior written authorization from Intel. 80100966Siwasaki * 81100966Siwasaki * 4. Disclaimer and Export Compliance 82100966Siwasaki * 83100966Siwasaki * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84100966Siwasaki * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85100966Siwasaki * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86100966Siwasaki * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87100966Siwasaki * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88100966Siwasaki * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89100966Siwasaki * PARTICULAR PURPOSE. 90100966Siwasaki * 91100966Siwasaki * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92100966Siwasaki * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93100966Siwasaki * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94100966Siwasaki * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95100966Siwasaki * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96100966Siwasaki * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97100966Siwasaki * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98100966Siwasaki * LIMITED REMEDY. 99100966Siwasaki * 100100966Siwasaki * 4.3. Licensee shall not export, either directly or indirectly, any of this 101100966Siwasaki * software or system incorporating such software without first obtaining any 102100966Siwasaki * required license or other approval from the U. S. Department of Commerce or 103100966Siwasaki * any other agency or department of the United States Government. In the 104100966Siwasaki * event Licensee exports any such software from the United States or 105100966Siwasaki * re-exports any such software from a foreign destination, Licensee shall 106100966Siwasaki * ensure that the distribution and export/re-export of the software is in 107100966Siwasaki * compliance with all laws, regulations, orders, or other restrictions of the 108100966Siwasaki * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109100966Siwasaki * any of its subsidiaries will export/re-export any technical data, process, 110100966Siwasaki * software, or service, directly or indirectly, to any country for which the 111100966Siwasaki * United States government or any agency thereof requires an export license, 112100966Siwasaki * other governmental approval, or letter of assurance, without first obtaining 113100966Siwasaki * such license, approval or letter. 114100966Siwasaki * 115100966Siwasaki *****************************************************************************/ 116100966Siwasaki 117100966Siwasaki 118100966Siwasaki#include "acpi.h" 119100966Siwasaki#include "amlcode.h" 120100966Siwasaki#include "acdisasm.h" 121100966Siwasaki 122100966Siwasaki 123100966Siwasaki#ifdef ACPI_DISASSEMBLER 124100966Siwasaki 125102550Siwasaki#define _COMPONENT ACPI_CA_DEBUGGER 126100966Siwasaki ACPI_MODULE_NAME ("dmutils") 127100966Siwasaki 128100966Siwasaki 129100966Siwasaki/* Data used in keeping track of fields */ 130100966Siwasaki#if 0 131114237Snjlconst char *AcpiGbl_FENames[ACPI_NUM_FIELD_NAMES] = 132100966Siwasaki{ 133100966Siwasaki "skip", 134100966Siwasaki "?access?" 135100966Siwasaki}; /* FE = Field Element */ 136100966Siwasaki#endif 137100966Siwasaki 138100966Siwasaki 139114237Snjlconst char *AcpiGbl_MatchOps[ACPI_NUM_MATCH_OPS] = 140100966Siwasaki{ 141100966Siwasaki "MTR", 142100966Siwasaki "MEQ", 143100966Siwasaki "MLE", 144100966Siwasaki "MLT", 145100966Siwasaki "MGE", 146100966Siwasaki "MGT" 147100966Siwasaki}; 148100966Siwasaki 149100966Siwasaki 150100966Siwasaki/* Access type decoding */ 151100966Siwasaki 152114237Snjlconst char *AcpiGbl_AccessTypes[ACPI_NUM_ACCESS_TYPES] = 153100966Siwasaki{ 154100966Siwasaki "AnyAcc", 155100966Siwasaki "ByteAcc", 156100966Siwasaki "WordAcc", 157100966Siwasaki "DWordAcc", 158100966Siwasaki "QWordAcc", 159100966Siwasaki "BufferAcc", 160100966Siwasaki}; 161100966Siwasaki 162100966Siwasaki 163100966Siwasaki/* Lock rule decoding */ 164100966Siwasaki 165114237Snjlconst char *AcpiGbl_LockRule[ACPI_NUM_LOCK_RULES] = 166100966Siwasaki{ 167100966Siwasaki "NoLock", 168100966Siwasaki "Lock" 169100966Siwasaki}; 170100966Siwasaki 171100966Siwasaki/* Update rule decoding */ 172100966Siwasaki 173114237Snjlconst char *AcpiGbl_UpdateRules[ACPI_NUM_UPDATE_RULES] = 174100966Siwasaki{ 175100966Siwasaki "Preserve", 176100966Siwasaki "WriteAsOnes", 177100966Siwasaki "WriteAsZeros" 178100966Siwasaki}; 179100966Siwasaki 180100966Siwasaki/* 181100966Siwasaki * Strings used to decode resource descriptors 182100966Siwasaki */ 183100966Siwasakiconst char *AcpiGbl_IoDecode[2] = 184100966Siwasaki{ 185100966Siwasaki "Decode10", 186100966Siwasaki "Decode16" 187100966Siwasaki}; 188100966Siwasaki 189100966Siwasakiconst char *AcpiGbl_WordDecode[4] = 190100966Siwasaki{ 191100966Siwasaki "WordMemory", 192100966Siwasaki "WordIO", 193100966Siwasaki "WordBusNumber", 194100966Siwasaki "Unknown-resource-type" 195100966Siwasaki}; 196100966Siwasaki 197100966Siwasakiconst char *AcpiGbl_ConsumeDecode[2] = 198100966Siwasaki{ 199100966Siwasaki "ResourceProducer", 200100966Siwasaki "ResourceConsumer" 201100966Siwasaki}; 202100966Siwasaki 203100966Siwasakiconst char *AcpiGbl_MinDecode[2] = 204100966Siwasaki{ 205100966Siwasaki "MinNotFixed", 206100966Siwasaki "MinFixed" 207100966Siwasaki}; 208100966Siwasaki 209100966Siwasakiconst char *AcpiGbl_MaxDecode[2] = 210100966Siwasaki{ 211100966Siwasaki "MaxNotFixed", 212100966Siwasaki "MaxFixed" 213100966Siwasaki}; 214100966Siwasaki 215100966Siwasakiconst char *AcpiGbl_DECDecode[2] = 216100966Siwasaki{ 217100966Siwasaki "PosDecode", 218100966Siwasaki "SubDecode" 219100966Siwasaki}; 220100966Siwasaki 221100966Siwasakiconst char *AcpiGbl_RNGDecode[4] = 222100966Siwasaki{ 223100966Siwasaki "InvalidRanges", 224100966Siwasaki "NonISAOnlyRanges", 225100966Siwasaki "ISAOnlyRanges", 226100966Siwasaki "EntireRange" 227100966Siwasaki}; 228100966Siwasaki 229100966Siwasakiconst char *AcpiGbl_MEMDecode[4] = 230100966Siwasaki{ 231100966Siwasaki "NonCacheable", 232100966Siwasaki "Cacheable", 233100966Siwasaki "WriteCombining", 234100966Siwasaki "Prefetchable" 235100966Siwasaki}; 236100966Siwasaki 237100966Siwasakiconst char *AcpiGbl_RWDecode[2] = 238100966Siwasaki{ 239100966Siwasaki "ReadOnly", 240100966Siwasaki "ReadWrite" 241100966Siwasaki}; 242100966Siwasaki 243100966Siwasakiconst char *AcpiGbl_IrqDecode[2] = 244100966Siwasaki{ 245100966Siwasaki "IRQNoFlags", 246100966Siwasaki "IRQ" 247100966Siwasaki}; 248100966Siwasaki 249100966Siwasakiconst char *AcpiGbl_HEDecode[2] = 250100966Siwasaki{ 251100966Siwasaki "Level", 252100966Siwasaki "Edge" 253100966Siwasaki}; 254100966Siwasaki 255100966Siwasakiconst char *AcpiGbl_LLDecode[2] = 256100966Siwasaki{ 257100966Siwasaki "ActiveHigh", 258100966Siwasaki "ActiveLow" 259100966Siwasaki}; 260100966Siwasaki 261100966Siwasakiconst char *AcpiGbl_SHRDecode[2] = 262100966Siwasaki{ 263100966Siwasaki "Exclusive", 264100966Siwasaki "Shared" 265100966Siwasaki}; 266100966Siwasaki 267100966Siwasakiconst char *AcpiGbl_TYPDecode[4] = 268100966Siwasaki{ 269100966Siwasaki "Compatibility", 270100966Siwasaki "TypeA", 271100966Siwasaki "TypeB", 272100966Siwasaki "TypeF" 273100966Siwasaki}; 274100966Siwasaki 275100966Siwasakiconst char *AcpiGbl_BMDecode[2] = 276100966Siwasaki{ 277100966Siwasaki "NotBusMaster", 278100966Siwasaki "BusMaster" 279100966Siwasaki}; 280100966Siwasaki 281100966Siwasakiconst char *AcpiGbl_SIZDecode[4] = 282100966Siwasaki{ 283100966Siwasaki "Transfer8", 284100966Siwasaki "Transfer8_16", 285100966Siwasaki "Transfer16", 286100966Siwasaki "InvalidSize" 287100966Siwasaki}; 288100966Siwasaki 289100966Siwasaki 290100966Siwasaki/******************************************************************************* 291100966Siwasaki * 292107325Siwasaki * FUNCTION: AcpiDmDecodeAttribute 293107325Siwasaki * 294107325Siwasaki * PARAMETERS: Attribute - Attribute field of AccessAs keyword 295107325Siwasaki * 296107325Siwasaki * RETURN: None 297107325Siwasaki * 298107325Siwasaki * DESCRIPTION: Decode the AccessAs attribute byte. (Mostly SMBus stuff) 299107325Siwasaki * 300107325Siwasaki ******************************************************************************/ 301107325Siwasaki 302107325Siwasakivoid 303107325SiwasakiAcpiDmDecodeAttribute ( 304107325Siwasaki UINT8 Attribute) 305107325Siwasaki{ 306107325Siwasaki 307107325Siwasaki switch (Attribute) 308107325Siwasaki { 309107325Siwasaki case AML_FIELD_ATTRIB_SMB_QUICK: 310107325Siwasaki 311107325Siwasaki AcpiOsPrintf ("SMBQuick"); 312107325Siwasaki break; 313107325Siwasaki 314107325Siwasaki case AML_FIELD_ATTRIB_SMB_SEND_RCV: 315107325Siwasaki 316107325Siwasaki AcpiOsPrintf ("SMBSendReceive"); 317107325Siwasaki break; 318107325Siwasaki 319107325Siwasaki case AML_FIELD_ATTRIB_SMB_BYTE: 320107325Siwasaki 321107325Siwasaki AcpiOsPrintf ("SMBByte"); 322107325Siwasaki break; 323107325Siwasaki 324107325Siwasaki case AML_FIELD_ATTRIB_SMB_WORD: 325107325Siwasaki 326107325Siwasaki AcpiOsPrintf ("SMBWord"); 327107325Siwasaki break; 328107325Siwasaki 329107325Siwasaki case AML_FIELD_ATTRIB_SMB_WORD_CALL: 330107325Siwasaki 331107325Siwasaki AcpiOsPrintf ("SMBProcessCall"); 332107325Siwasaki break; 333107325Siwasaki 334107325Siwasaki case AML_FIELD_ATTRIB_SMB_BLOCK: 335107325Siwasaki 336107325Siwasaki AcpiOsPrintf ("SMBBlock"); 337107325Siwasaki break; 338107325Siwasaki 339107325Siwasaki case AML_FIELD_ATTRIB_SMB_BLOCK_CALL: 340107325Siwasaki 341107325Siwasaki AcpiOsPrintf ("SMBBlockProcessCall"); 342107325Siwasaki break; 343107325Siwasaki 344107325Siwasaki default: 345107325Siwasaki 346107325Siwasaki AcpiOsPrintf ("0x%.2X", Attribute); 347107325Siwasaki break; 348107325Siwasaki } 349107325Siwasaki} 350107325Siwasaki 351107325Siwasaki 352107325Siwasaki/******************************************************************************* 353107325Siwasaki * 354100966Siwasaki * FUNCTION: AcpiDmIndent 355100966Siwasaki * 356100966Siwasaki * PARAMETERS: Level - Current source code indentation level 357100966Siwasaki * 358100966Siwasaki * RETURN: None 359100966Siwasaki * 360100966Siwasaki * DESCRIPTION: Indent 4 spaces per indentation level. 361100966Siwasaki * 362100966Siwasaki ******************************************************************************/ 363100966Siwasaki 364100966Siwasakivoid 365100966SiwasakiAcpiDmIndent ( 366100966Siwasaki UINT32 Level) 367100966Siwasaki{ 368100966Siwasaki 369100966Siwasaki if (!Level) 370100966Siwasaki { 371100966Siwasaki return; 372100966Siwasaki } 373100966Siwasaki 374100966Siwasaki AcpiOsPrintf ("%*.s", ACPI_MUL_4 (Level), " "); 375100966Siwasaki} 376100966Siwasaki 377100966Siwasaki 378100966Siwasaki/******************************************************************************* 379100966Siwasaki * 380100966Siwasaki * FUNCTION: AcpiDmCommaIfListMember 381100966Siwasaki * 382100966Siwasaki * PARAMETERS: Op - Current operator/operand 383100966Siwasaki * 384100966Siwasaki * RETURN: TRUE if a comma was inserted 385100966Siwasaki * 386100966Siwasaki * DESCRIPTION: Insert a comma if this Op is a member of an argument list. 387100966Siwasaki * 388100966Siwasaki ******************************************************************************/ 389100966Siwasaki 390100966SiwasakiBOOLEAN 391100966SiwasakiAcpiDmCommaIfListMember ( 392100966Siwasaki ACPI_PARSE_OBJECT *Op) 393100966Siwasaki{ 394100966Siwasaki 395100966Siwasaki if (!Op->Common.Next) 396100966Siwasaki { 397100966Siwasaki return FALSE; 398100966Siwasaki } 399100966Siwasaki 400100966Siwasaki if (AcpiDmListType (Op->Common.Parent) & BLOCK_COMMA_LIST) 401100966Siwasaki { 402100966Siwasaki /* Check for a NULL target operand */ 403100966Siwasaki 404100966Siwasaki if ((Op->Common.Next->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && 405100966Siwasaki (!Op->Common.Next->Common.Value.String)) 406100966Siwasaki { 407100966Siwasaki /* 408100966Siwasaki * To handle the Divide() case where there are two optional 409100966Siwasaki * targets, look ahead one more op. If null, this null target 410100966Siwasaki * is the one and only target -- no comma needed. Otherwise, 411100966Siwasaki * we need a comma to prepare for the next target. 412100966Siwasaki */ 413100966Siwasaki if (!Op->Common.Next->Common.Next) 414100966Siwasaki { 415100966Siwasaki return FALSE; 416100966Siwasaki } 417100966Siwasaki } 418100966Siwasaki 419100966Siwasaki if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST) && 420100966Siwasaki (!(Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST))) 421100966Siwasaki { 422100966Siwasaki return FALSE; 423100966Siwasaki } 424100966Siwasaki 425100966Siwasaki AcpiOsPrintf (", "); 426100966Siwasaki return (TRUE); 427100966Siwasaki } 428100966Siwasaki 429100966Siwasaki else if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST) && 430100966Siwasaki (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) 431100966Siwasaki { 432100966Siwasaki AcpiOsPrintf (", "); 433100966Siwasaki return (TRUE); 434100966Siwasaki } 435100966Siwasaki 436100966Siwasaki return (FALSE); 437100966Siwasaki} 438100966Siwasaki 439100966Siwasaki 440100966Siwasaki/******************************************************************************* 441100966Siwasaki * 442100966Siwasaki * FUNCTION: AcpiDmCommaIfFieldMember 443100966Siwasaki * 444100966Siwasaki * PARAMETERS: Op - Current operator/operand 445100966Siwasaki * 446100966Siwasaki * RETURN: None 447100966Siwasaki * 448100966Siwasaki * DESCRIPTION: Insert a comma if this Op is a member of a Field argument list. 449100966Siwasaki * 450100966Siwasaki ******************************************************************************/ 451100966Siwasaki 452100966Siwasakivoid 453100966SiwasakiAcpiDmCommaIfFieldMember ( 454100966Siwasaki ACPI_PARSE_OBJECT *Op) 455100966Siwasaki{ 456100966Siwasaki 457100966Siwasaki if (Op->Common.Next) 458100966Siwasaki { 459100966Siwasaki AcpiOsPrintf (", "); 460100966Siwasaki } 461100966Siwasaki} 462100966Siwasaki 463100966Siwasaki 464100966Siwasaki#endif 465