1*3446Smrj /******************************************************************************* 2*3446Smrj * 3*3446Smrj * Module Name: dmwalk - AML disassembly tree walk 4*3446Smrj * $Revision: 1.32 $ 5*3446Smrj * 6*3446Smrj ******************************************************************************/ 7*3446Smrj 8*3446Smrj /****************************************************************************** 9*3446Smrj * 10*3446Smrj * 1. Copyright Notice 11*3446Smrj * 12*3446Smrj * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. 13*3446Smrj * All rights reserved. 14*3446Smrj * 15*3446Smrj * 2. License 16*3446Smrj * 17*3446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property 18*3446Smrj * rights. You may have additional license terms from the party that provided 19*3446Smrj * you this software, covering your right to use that party's intellectual 20*3446Smrj * property rights. 21*3446Smrj * 22*3446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23*3446Smrj * copy of the source code appearing in this file ("Covered Code") an 24*3446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25*3446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy, 26*3446Smrj * make derivatives, distribute, use and display any portion of the Covered 27*3446Smrj * Code in any form, with the right to sublicense such rights; and 28*3446Smrj * 29*3446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30*3446Smrj * license (with the right to sublicense), under only those claims of Intel 31*3446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell, 32*3446Smrj * offer to sell, and import the Covered Code and derivative works thereof 33*3446Smrj * solely to the minimum extent necessary to exercise the above copyright 34*3446Smrj * license, and in no event shall the patent license extend to any additions 35*3446Smrj * to or modifications of the Original Intel Code. No other license or right 36*3446Smrj * is granted directly or by implication, estoppel or otherwise; 37*3446Smrj * 38*3446Smrj * The above copyright and patent license is granted only if the following 39*3446Smrj * conditions are met: 40*3446Smrj * 41*3446Smrj * 3. Conditions 42*3446Smrj * 43*3446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44*3446Smrj * Redistribution of source code of any substantial portion of the Covered 45*3446Smrj * Code or modification with rights to further distribute source must include 46*3446Smrj * the above Copyright Notice, the above License, this list of Conditions, 47*3446Smrj * and the following Disclaimer and Export Compliance provision. In addition, 48*3446Smrj * Licensee must cause all Covered Code to which Licensee contributes to 49*3446Smrj * contain a file documenting the changes Licensee made to create that Covered 50*3446Smrj * Code and the date of any change. Licensee must include in that file the 51*3446Smrj * documentation of any changes made by any predecessor Licensee. Licensee 52*3446Smrj * must include a prominent statement that the modification is derived, 53*3446Smrj * directly or indirectly, from Original Intel Code. 54*3446Smrj * 55*3446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56*3446Smrj * Redistribution of source code of any substantial portion of the Covered 57*3446Smrj * Code or modification without rights to further distribute source must 58*3446Smrj * include the following Disclaimer and Export Compliance provision in the 59*3446Smrj * documentation and/or other materials provided with distribution. In 60*3446Smrj * addition, Licensee may not authorize further sublicense of source of any 61*3446Smrj * portion of the Covered Code, and must include terms to the effect that the 62*3446Smrj * license from Licensee to its licensee is limited to the intellectual 63*3446Smrj * property embodied in the software Licensee provides to its licensee, and 64*3446Smrj * not to intellectual property embodied in modifications its licensee may 65*3446Smrj * make. 66*3446Smrj * 67*3446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any 68*3446Smrj * substantial portion of the Covered Code or modification must reproduce the 69*3446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance 70*3446Smrj * provision in the documentation and/or other materials provided with the 71*3446Smrj * distribution. 72*3446Smrj * 73*3446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original 74*3446Smrj * Intel Code. 75*3446Smrj * 76*3446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77*3446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or 78*3446Smrj * other dealings in products derived from or relating to the Covered Code 79*3446Smrj * without prior written authorization from Intel. 80*3446Smrj * 81*3446Smrj * 4. Disclaimer and Export Compliance 82*3446Smrj * 83*3446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84*3446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85*3446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86*3446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87*3446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88*3446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89*3446Smrj * PARTICULAR PURPOSE. 90*3446Smrj * 91*3446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92*3446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93*3446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94*3446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95*3446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96*3446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97*3446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98*3446Smrj * LIMITED REMEDY. 99*3446Smrj * 100*3446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this 101*3446Smrj * software or system incorporating such software without first obtaining any 102*3446Smrj * required license or other approval from the U. S. Department of Commerce or 103*3446Smrj * any other agency or department of the United States Government. In the 104*3446Smrj * event Licensee exports any such software from the United States or 105*3446Smrj * re-exports any such software from a foreign destination, Licensee shall 106*3446Smrj * ensure that the distribution and export/re-export of the software is in 107*3446Smrj * compliance with all laws, regulations, orders, or other restrictions of the 108*3446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109*3446Smrj * any of its subsidiaries will export/re-export any technical data, process, 110*3446Smrj * software, or service, directly or indirectly, to any country for which the 111*3446Smrj * United States government or any agency thereof requires an export license, 112*3446Smrj * other governmental approval, or letter of assurance, without first obtaining 113*3446Smrj * such license, approval or letter. 114*3446Smrj * 115*3446Smrj *****************************************************************************/ 116*3446Smrj 117*3446Smrj 118*3446Smrj #include "acpi.h" 119*3446Smrj #include "acparser.h" 120*3446Smrj #include "amlcode.h" 121*3446Smrj #include "acdisasm.h" 122*3446Smrj #include "acdebug.h" 123*3446Smrj 124*3446Smrj 125*3446Smrj #ifdef ACPI_DISASSEMBLER 126*3446Smrj 127*3446Smrj #define _COMPONENT ACPI_CA_DEBUGGER 128*3446Smrj ACPI_MODULE_NAME ("dmwalk") 129*3446Smrj 130*3446Smrj 131*3446Smrj #define DB_FULL_OP_INFO "[%4.4s] @%5.5X #%4.4X: " 132*3446Smrj 133*3446Smrj /* Local prototypes */ 134*3446Smrj 135*3446Smrj static ACPI_STATUS 136*3446Smrj AcpiDmDescendingOp ( 137*3446Smrj ACPI_PARSE_OBJECT *Op, 138*3446Smrj UINT32 Level, 139*3446Smrj void *Context); 140*3446Smrj 141*3446Smrj static ACPI_STATUS 142*3446Smrj AcpiDmAscendingOp ( 143*3446Smrj ACPI_PARSE_OBJECT *Op, 144*3446Smrj UINT32 Level, 145*3446Smrj void *Context); 146*3446Smrj 147*3446Smrj static UINT32 148*3446Smrj AcpiDmBlockType ( 149*3446Smrj ACPI_PARSE_OBJECT *Op); 150*3446Smrj 151*3446Smrj 152*3446Smrj /******************************************************************************* 153*3446Smrj * 154*3446Smrj * FUNCTION: AcpiDmDisassemble 155*3446Smrj * 156*3446Smrj * PARAMETERS: WalkState - Current state 157*3446Smrj * Origin - Starting object 158*3446Smrj * NumOpcodes - Max number of opcodes to be displayed 159*3446Smrj * 160*3446Smrj * RETURN: None 161*3446Smrj * 162*3446Smrj * DESCRIPTION: Disassemble parser object and its children. This is the 163*3446Smrj * main entry point of the disassembler. 164*3446Smrj * 165*3446Smrj ******************************************************************************/ 166*3446Smrj 167*3446Smrj void 168*3446Smrj AcpiDmDisassemble ( 169*3446Smrj ACPI_WALK_STATE *WalkState, 170*3446Smrj ACPI_PARSE_OBJECT *Origin, 171*3446Smrj UINT32 NumOpcodes) 172*3446Smrj { 173*3446Smrj ACPI_PARSE_OBJECT *Op = Origin; 174*3446Smrj ACPI_OP_WALK_INFO Info; 175*3446Smrj 176*3446Smrj 177*3446Smrj if (!Op) 178*3446Smrj { 179*3446Smrj return; 180*3446Smrj } 181*3446Smrj 182*3446Smrj Info.Flags = 0; 183*3446Smrj Info.Level = 0; 184*3446Smrj Info.Count = 0; 185*3446Smrj Info.WalkState = WalkState; 186*3446Smrj AcpiDmWalkParseTree (Op, AcpiDmDescendingOp, AcpiDmAscendingOp, &Info); 187*3446Smrj return; 188*3446Smrj } 189*3446Smrj 190*3446Smrj 191*3446Smrj /******************************************************************************* 192*3446Smrj * 193*3446Smrj * FUNCTION: AcpiDmWalkParseTree 194*3446Smrj * 195*3446Smrj * PARAMETERS: Op - Root Op object 196*3446Smrj * DescendingCallback - Called during tree descent 197*3446Smrj * AscendingCallback - Called during tree ascent 198*3446Smrj * Context - To be passed to the callbacks 199*3446Smrj * 200*3446Smrj * RETURN: Status from callback(s) 201*3446Smrj * 202*3446Smrj * DESCRIPTION: Walk the entire parse tree. 203*3446Smrj * 204*3446Smrj ******************************************************************************/ 205*3446Smrj 206*3446Smrj void 207*3446Smrj AcpiDmWalkParseTree ( 208*3446Smrj ACPI_PARSE_OBJECT *Op, 209*3446Smrj ASL_WALK_CALLBACK DescendingCallback, 210*3446Smrj ASL_WALK_CALLBACK AscendingCallback, 211*3446Smrj void *Context) 212*3446Smrj { 213*3446Smrj BOOLEAN NodePreviouslyVisited; 214*3446Smrj ACPI_PARSE_OBJECT *StartOp = Op; 215*3446Smrj ACPI_STATUS Status; 216*3446Smrj ACPI_PARSE_OBJECT *Next; 217*3446Smrj ACPI_OP_WALK_INFO *Info = Context; 218*3446Smrj 219*3446Smrj 220*3446Smrj Info->Level = 0; 221*3446Smrj NodePreviouslyVisited = FALSE; 222*3446Smrj 223*3446Smrj while (Op) 224*3446Smrj { 225*3446Smrj if (NodePreviouslyVisited) 226*3446Smrj { 227*3446Smrj if (AscendingCallback) 228*3446Smrj { 229*3446Smrj Status = AscendingCallback (Op, Info->Level, Context); 230*3446Smrj if (ACPI_FAILURE (Status)) 231*3446Smrj { 232*3446Smrj return; 233*3446Smrj } 234*3446Smrj } 235*3446Smrj } 236*3446Smrj else 237*3446Smrj { 238*3446Smrj /* Let the callback process the node */ 239*3446Smrj 240*3446Smrj Status = DescendingCallback (Op, Info->Level, Context); 241*3446Smrj if (ACPI_SUCCESS (Status)) 242*3446Smrj { 243*3446Smrj /* Visit children first, once */ 244*3446Smrj 245*3446Smrj Next = AcpiPsGetArg (Op, 0); 246*3446Smrj if (Next) 247*3446Smrj { 248*3446Smrj Info->Level++; 249*3446Smrj Op = Next; 250*3446Smrj continue; 251*3446Smrj } 252*3446Smrj } 253*3446Smrj else if (Status != AE_CTRL_DEPTH) 254*3446Smrj { 255*3446Smrj /* Exit immediately on any error */ 256*3446Smrj 257*3446Smrj return; 258*3446Smrj } 259*3446Smrj } 260*3446Smrj 261*3446Smrj /* Terminate walk at start op */ 262*3446Smrj 263*3446Smrj if (Op == StartOp) 264*3446Smrj { 265*3446Smrj break; 266*3446Smrj } 267*3446Smrj 268*3446Smrj /* No more children, re-visit this node */ 269*3446Smrj 270*3446Smrj if (!NodePreviouslyVisited) 271*3446Smrj { 272*3446Smrj NodePreviouslyVisited = TRUE; 273*3446Smrj continue; 274*3446Smrj } 275*3446Smrj 276*3446Smrj /* No more children, visit peers */ 277*3446Smrj 278*3446Smrj if (Op->Common.Next) 279*3446Smrj { 280*3446Smrj Op = Op->Common.Next; 281*3446Smrj NodePreviouslyVisited = FALSE; 282*3446Smrj } 283*3446Smrj else 284*3446Smrj { 285*3446Smrj /* No peers, re-visit parent */ 286*3446Smrj 287*3446Smrj if (Info->Level != 0 ) 288*3446Smrj { 289*3446Smrj Info->Level--; 290*3446Smrj } 291*3446Smrj 292*3446Smrj Op = Op->Common.Parent; 293*3446Smrj NodePreviouslyVisited = TRUE; 294*3446Smrj } 295*3446Smrj } 296*3446Smrj 297*3446Smrj /* If we get here, the walk completed with no errors */ 298*3446Smrj 299*3446Smrj return; 300*3446Smrj } 301*3446Smrj 302*3446Smrj 303*3446Smrj /******************************************************************************* 304*3446Smrj * 305*3446Smrj * FUNCTION: AcpiDmBlockType 306*3446Smrj * 307*3446Smrj * PARAMETERS: Op - Object to be examined 308*3446Smrj * 309*3446Smrj * RETURN: BlockType - not a block, parens, braces, or even both. 310*3446Smrj * 311*3446Smrj * DESCRIPTION: Type of block for this op (parens or braces) 312*3446Smrj * 313*3446Smrj ******************************************************************************/ 314*3446Smrj 315*3446Smrj static UINT32 316*3446Smrj AcpiDmBlockType ( 317*3446Smrj ACPI_PARSE_OBJECT *Op) 318*3446Smrj { 319*3446Smrj const ACPI_OPCODE_INFO *OpInfo; 320*3446Smrj 321*3446Smrj 322*3446Smrj if (!Op) 323*3446Smrj { 324*3446Smrj return (BLOCK_NONE); 325*3446Smrj } 326*3446Smrj 327*3446Smrj switch (Op->Common.AmlOpcode) 328*3446Smrj { 329*3446Smrj case AML_ELSE_OP: 330*3446Smrj 331*3446Smrj return (BLOCK_BRACE); 332*3446Smrj 333*3446Smrj case AML_METHOD_OP: 334*3446Smrj case AML_DEVICE_OP: 335*3446Smrj case AML_SCOPE_OP: 336*3446Smrj case AML_PROCESSOR_OP: 337*3446Smrj case AML_POWER_RES_OP: 338*3446Smrj case AML_THERMAL_ZONE_OP: 339*3446Smrj case AML_IF_OP: 340*3446Smrj case AML_WHILE_OP: 341*3446Smrj case AML_FIELD_OP: 342*3446Smrj case AML_INDEX_FIELD_OP: 343*3446Smrj case AML_BANK_FIELD_OP: 344*3446Smrj 345*3446Smrj return (BLOCK_PAREN | BLOCK_BRACE); 346*3446Smrj 347*3446Smrj case AML_BUFFER_OP: 348*3446Smrj 349*3446Smrj if (Op->Common.DisasmOpcode == ACPI_DASM_UNICODE) 350*3446Smrj { 351*3446Smrj return (BLOCK_NONE); 352*3446Smrj } 353*3446Smrj 354*3446Smrj /*lint -fallthrough */ 355*3446Smrj 356*3446Smrj case AML_PACKAGE_OP: 357*3446Smrj case AML_VAR_PACKAGE_OP: 358*3446Smrj 359*3446Smrj return (BLOCK_PAREN | BLOCK_BRACE); 360*3446Smrj 361*3446Smrj case AML_EVENT_OP: 362*3446Smrj 363*3446Smrj return (BLOCK_PAREN); 364*3446Smrj 365*3446Smrj default: 366*3446Smrj 367*3446Smrj OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 368*3446Smrj if (OpInfo->Flags & AML_HAS_ARGS) 369*3446Smrj { 370*3446Smrj return (BLOCK_PAREN); 371*3446Smrj } 372*3446Smrj 373*3446Smrj return (BLOCK_NONE); 374*3446Smrj } 375*3446Smrj } 376*3446Smrj 377*3446Smrj 378*3446Smrj /******************************************************************************* 379*3446Smrj * 380*3446Smrj * FUNCTION: AcpiDmListType 381*3446Smrj * 382*3446Smrj * PARAMETERS: Op - Object to be examined 383*3446Smrj * 384*3446Smrj * RETURN: ListType - has commas or not. 385*3446Smrj * 386*3446Smrj * DESCRIPTION: Type of block for this op (parens or braces) 387*3446Smrj * 388*3446Smrj ******************************************************************************/ 389*3446Smrj 390*3446Smrj UINT32 391*3446Smrj AcpiDmListType ( 392*3446Smrj ACPI_PARSE_OBJECT *Op) 393*3446Smrj { 394*3446Smrj const ACPI_OPCODE_INFO *OpInfo; 395*3446Smrj 396*3446Smrj 397*3446Smrj if (!Op) 398*3446Smrj { 399*3446Smrj return (BLOCK_NONE); 400*3446Smrj } 401*3446Smrj 402*3446Smrj switch (Op->Common.AmlOpcode) 403*3446Smrj { 404*3446Smrj 405*3446Smrj case AML_ELSE_OP: 406*3446Smrj case AML_METHOD_OP: 407*3446Smrj case AML_DEVICE_OP: 408*3446Smrj case AML_SCOPE_OP: 409*3446Smrj case AML_POWER_RES_OP: 410*3446Smrj case AML_PROCESSOR_OP: 411*3446Smrj case AML_THERMAL_ZONE_OP: 412*3446Smrj case AML_IF_OP: 413*3446Smrj case AML_WHILE_OP: 414*3446Smrj case AML_FIELD_OP: 415*3446Smrj case AML_INDEX_FIELD_OP: 416*3446Smrj case AML_BANK_FIELD_OP: 417*3446Smrj 418*3446Smrj return (BLOCK_NONE); 419*3446Smrj 420*3446Smrj case AML_BUFFER_OP: 421*3446Smrj case AML_PACKAGE_OP: 422*3446Smrj case AML_VAR_PACKAGE_OP: 423*3446Smrj 424*3446Smrj return (BLOCK_COMMA_LIST); 425*3446Smrj 426*3446Smrj default: 427*3446Smrj 428*3446Smrj OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 429*3446Smrj if (OpInfo->Flags & AML_HAS_ARGS) 430*3446Smrj { 431*3446Smrj return (BLOCK_COMMA_LIST); 432*3446Smrj } 433*3446Smrj 434*3446Smrj return (BLOCK_NONE); 435*3446Smrj } 436*3446Smrj } 437*3446Smrj 438*3446Smrj 439*3446Smrj /******************************************************************************* 440*3446Smrj * 441*3446Smrj * FUNCTION: AcpiDmDescendingOp 442*3446Smrj * 443*3446Smrj * PARAMETERS: ASL_WALK_CALLBACK 444*3446Smrj * 445*3446Smrj * RETURN: Status 446*3446Smrj * 447*3446Smrj * DESCRIPTION: First visitation of a parse object during tree descent. 448*3446Smrj * Decode opcode name and begin parameter list(s), if any. 449*3446Smrj * 450*3446Smrj ******************************************************************************/ 451*3446Smrj 452*3446Smrj static ACPI_STATUS 453*3446Smrj AcpiDmDescendingOp ( 454*3446Smrj ACPI_PARSE_OBJECT *Op, 455*3446Smrj UINT32 Level, 456*3446Smrj void *Context) 457*3446Smrj { 458*3446Smrj ACPI_OP_WALK_INFO *Info = Context; 459*3446Smrj const ACPI_OPCODE_INFO *OpInfo; 460*3446Smrj UINT32 Name; 461*3446Smrj ACPI_PARSE_OBJECT *NextOp; 462*3446Smrj ACPI_EXTERNAL_LIST *NextExternal; 463*3446Smrj 464*3446Smrj 465*3446Smrj if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE) 466*3446Smrj { 467*3446Smrj /* Ignore this op -- it was handled elsewhere */ 468*3446Smrj 469*3446Smrj return (AE_CTRL_DEPTH); 470*3446Smrj } 471*3446Smrj 472*3446Smrj /* Level 0 is at the Definition Block level */ 473*3446Smrj 474*3446Smrj if (Level == 0) 475*3446Smrj { 476*3446Smrj /* In verbose mode, print the AML offset, opcode and depth count */ 477*3446Smrj 478*3446Smrj if (Info->WalkState) 479*3446Smrj { 480*3446Smrj VERBOSE_PRINT ((DB_FULL_OP_INFO, 481*3446Smrj (Info->WalkState->MethodNode ? 482*3446Smrj Info->WalkState->MethodNode->Name.Ascii : " "), 483*3446Smrj Op->Common.AmlOffset, (UINT32) Op->Common.AmlOpcode)); 484*3446Smrj } 485*3446Smrj 486*3446Smrj if (Op->Common.AmlOpcode == AML_SCOPE_OP) 487*3446Smrj { 488*3446Smrj /* This is the beginning of the Definition Block */ 489*3446Smrj 490*3446Smrj AcpiOsPrintf ("{\n"); 491*3446Smrj 492*3446Smrj /* Emit all External() declarations here */ 493*3446Smrj 494*3446Smrj if (AcpiGbl_ExternalList) 495*3446Smrj { 496*3446Smrj /* 497*3446Smrj * Walk the list of externals (unresolved references) 498*3446Smrj * found during parsing 499*3446Smrj */ 500*3446Smrj while (AcpiGbl_ExternalList) 501*3446Smrj { 502*3446Smrj AcpiOsPrintf (" External (%s", 503*3446Smrj AcpiGbl_ExternalList->Path); 504*3446Smrj 505*3446Smrj /* TBD: should be a lookup table */ 506*3446Smrj 507*3446Smrj switch (AcpiGbl_ExternalList->Type) 508*3446Smrj { 509*3446Smrj case ACPI_TYPE_DEVICE: 510*3446Smrj AcpiOsPrintf (", DeviceObj"); 511*3446Smrj break; 512*3446Smrj 513*3446Smrj case ACPI_TYPE_METHOD: 514*3446Smrj AcpiOsPrintf (", MethodObj"); 515*3446Smrj break; 516*3446Smrj 517*3446Smrj case ACPI_TYPE_INTEGER: 518*3446Smrj AcpiOsPrintf (", IntObj"); 519*3446Smrj break; 520*3446Smrj 521*3446Smrj default: 522*3446Smrj break; 523*3446Smrj } 524*3446Smrj 525*3446Smrj if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD) 526*3446Smrj { 527*3446Smrj AcpiOsPrintf (") // %d Arguments\n", AcpiGbl_ExternalList->Value); 528*3446Smrj } 529*3446Smrj else 530*3446Smrj { 531*3446Smrj AcpiOsPrintf (")\n"); 532*3446Smrj } 533*3446Smrj 534*3446Smrj NextExternal = AcpiGbl_ExternalList->Next; 535*3446Smrj ACPI_FREE (AcpiGbl_ExternalList->Path); 536*3446Smrj ACPI_FREE (AcpiGbl_ExternalList); 537*3446Smrj AcpiGbl_ExternalList = NextExternal; 538*3446Smrj } 539*3446Smrj AcpiOsPrintf ("\n"); 540*3446Smrj } 541*3446Smrj 542*3446Smrj return (AE_OK); 543*3446Smrj } 544*3446Smrj } 545*3446Smrj else if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) && 546*3446Smrj (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) && 547*3446Smrj (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) 548*3446Smrj { 549*3446Smrj /* 550*3446Smrj * This is a first-level element of a term list, 551*3446Smrj * indent a new line 552*3446Smrj */ 553*3446Smrj AcpiDmIndent (Level); 554*3446Smrj Info->LastLevel = Level; 555*3446Smrj Info->Count = 0; 556*3446Smrj } 557*3446Smrj 558*3446Smrj /* 559*3446Smrj * This is an inexpensive mechanism to try and keep lines from getting 560*3446Smrj * too long. When the limit is hit, start a new line at the previous 561*3446Smrj * indent plus one. A better but more expensive mechanism would be to 562*3446Smrj * keep track of the current column. 563*3446Smrj */ 564*3446Smrj Info->Count++; 565*3446Smrj if (Info->Count /*+Info->LastLevel*/ > 10) 566*3446Smrj { 567*3446Smrj Info->Count = 0; 568*3446Smrj AcpiOsPrintf ("\n"); 569*3446Smrj AcpiDmIndent (Info->LastLevel + 1); 570*3446Smrj } 571*3446Smrj 572*3446Smrj /* Print the opcode name */ 573*3446Smrj 574*3446Smrj AcpiDmDisassembleOneOp (NULL, Info, Op); 575*3446Smrj 576*3446Smrj if (Op->Common.DisasmOpcode == ACPI_DASM_LNOT_PREFIX) 577*3446Smrj { 578*3446Smrj return (AE_OK); 579*3446Smrj } 580*3446Smrj 581*3446Smrj if ((Op->Common.AmlOpcode == AML_NAME_OP) || 582*3446Smrj (Op->Common.AmlOpcode == AML_RETURN_OP)) 583*3446Smrj { 584*3446Smrj Info->Level--; 585*3446Smrj } 586*3446Smrj 587*3446Smrj /* Start the opcode argument list if necessary */ 588*3446Smrj 589*3446Smrj OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 590*3446Smrj 591*3446Smrj if ((OpInfo->Flags & AML_HAS_ARGS) || 592*3446Smrj (Op->Common.AmlOpcode == AML_EVENT_OP)) 593*3446Smrj { 594*3446Smrj /* This opcode has an argument list */ 595*3446Smrj 596*3446Smrj if (AcpiDmBlockType (Op) & BLOCK_PAREN) 597*3446Smrj { 598*3446Smrj AcpiOsPrintf (" ("); 599*3446Smrj } 600*3446Smrj 601*3446Smrj /* If this is a named opcode, print the associated name value */ 602*3446Smrj 603*3446Smrj if (OpInfo->Flags & AML_NAMED) 604*3446Smrj { 605*3446Smrj switch (Op->Common.AmlOpcode) 606*3446Smrj { 607*3446Smrj case AML_ALIAS_OP: 608*3446Smrj 609*3446Smrj NextOp = AcpiPsGetDepthNext (NULL, Op); 610*3446Smrj NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; 611*3446Smrj AcpiDmNamestring (NextOp->Common.Value.Name); 612*3446Smrj AcpiOsPrintf (", "); 613*3446Smrj 614*3446Smrj /*lint -fallthrough */ 615*3446Smrj 616*3446Smrj default: 617*3446Smrj 618*3446Smrj Name = AcpiPsGetName (Op); 619*3446Smrj if (Op->Named.Path) 620*3446Smrj { 621*3446Smrj AcpiDmNamestring ((char *) Op->Named.Path); 622*3446Smrj } 623*3446Smrj else 624*3446Smrj { 625*3446Smrj AcpiDmDumpName ((char *) &Name); 626*3446Smrj } 627*3446Smrj 628*3446Smrj if (Op->Common.AmlOpcode != AML_INT_NAMEDFIELD_OP) 629*3446Smrj { 630*3446Smrj if (AcpiGbl_DbOpt_verbose) 631*3446Smrj { 632*3446Smrj (void) AcpiPsDisplayObjectPathname (NULL, Op); 633*3446Smrj } 634*3446Smrj } 635*3446Smrj break; 636*3446Smrj } 637*3446Smrj 638*3446Smrj switch (Op->Common.AmlOpcode) 639*3446Smrj { 640*3446Smrj case AML_METHOD_OP: 641*3446Smrj 642*3446Smrj AcpiDmMethodFlags (Op); 643*3446Smrj AcpiOsPrintf (")"); 644*3446Smrj break; 645*3446Smrj 646*3446Smrj 647*3446Smrj case AML_NAME_OP: 648*3446Smrj 649*3446Smrj /* Check for _HID and related EISAID() */ 650*3446Smrj 651*3446Smrj AcpiDmIsEisaId (Op); 652*3446Smrj AcpiOsPrintf (", "); 653*3446Smrj break; 654*3446Smrj 655*3446Smrj 656*3446Smrj case AML_REGION_OP: 657*3446Smrj 658*3446Smrj AcpiDmRegionFlags (Op); 659*3446Smrj break; 660*3446Smrj 661*3446Smrj 662*3446Smrj case AML_POWER_RES_OP: 663*3446Smrj 664*3446Smrj /* Mark the next two Ops as part of the parameter list */ 665*3446Smrj 666*3446Smrj AcpiOsPrintf (", "); 667*3446Smrj NextOp = AcpiPsGetDepthNext (NULL, Op); 668*3446Smrj NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; 669*3446Smrj 670*3446Smrj NextOp = NextOp->Common.Next; 671*3446Smrj NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; 672*3446Smrj return (AE_OK); 673*3446Smrj 674*3446Smrj 675*3446Smrj case AML_PROCESSOR_OP: 676*3446Smrj 677*3446Smrj /* Mark the next three Ops as part of the parameter list */ 678*3446Smrj 679*3446Smrj AcpiOsPrintf (", "); 680*3446Smrj NextOp = AcpiPsGetDepthNext (NULL, Op); 681*3446Smrj NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; 682*3446Smrj 683*3446Smrj NextOp = NextOp->Common.Next; 684*3446Smrj NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; 685*3446Smrj 686*3446Smrj NextOp = NextOp->Common.Next; 687*3446Smrj NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; 688*3446Smrj return (AE_OK); 689*3446Smrj 690*3446Smrj 691*3446Smrj case AML_MUTEX_OP: 692*3446Smrj case AML_DATA_REGION_OP: 693*3446Smrj 694*3446Smrj AcpiOsPrintf (", "); 695*3446Smrj return (AE_OK); 696*3446Smrj 697*3446Smrj 698*3446Smrj case AML_EVENT_OP: 699*3446Smrj case AML_ALIAS_OP: 700*3446Smrj 701*3446Smrj return (AE_OK); 702*3446Smrj 703*3446Smrj 704*3446Smrj case AML_SCOPE_OP: 705*3446Smrj case AML_DEVICE_OP: 706*3446Smrj case AML_THERMAL_ZONE_OP: 707*3446Smrj 708*3446Smrj AcpiOsPrintf (")"); 709*3446Smrj break; 710*3446Smrj 711*3446Smrj 712*3446Smrj default: 713*3446Smrj 714*3446Smrj AcpiOsPrintf ("*** Unhandled named opcode %X\n", Op->Common.AmlOpcode); 715*3446Smrj break; 716*3446Smrj } 717*3446Smrj } 718*3446Smrj 719*3446Smrj else switch (Op->Common.AmlOpcode) 720*3446Smrj { 721*3446Smrj case AML_FIELD_OP: 722*3446Smrj case AML_BANK_FIELD_OP: 723*3446Smrj case AML_INDEX_FIELD_OP: 724*3446Smrj 725*3446Smrj Info->BitOffset = 0; 726*3446Smrj 727*3446Smrj /* Name of the parent OperationRegion */ 728*3446Smrj 729*3446Smrj NextOp = AcpiPsGetDepthNext (NULL, Op); 730*3446Smrj AcpiDmNamestring (NextOp->Common.Value.Name); 731*3446Smrj AcpiOsPrintf (", "); 732*3446Smrj NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; 733*3446Smrj 734*3446Smrj switch (Op->Common.AmlOpcode) 735*3446Smrj { 736*3446Smrj case AML_BANK_FIELD_OP: 737*3446Smrj 738*3446Smrj /* Namestring - Bank Name */ 739*3446Smrj 740*3446Smrj NextOp = AcpiPsGetDepthNext (NULL, NextOp); 741*3446Smrj AcpiDmNamestring (NextOp->Common.Value.Name); 742*3446Smrj NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; 743*3446Smrj AcpiOsPrintf (", "); 744*3446Smrj 745*3446Smrj /* 746*3446Smrj * Bank Value. This is a TermArg in the middle of the parameter 747*3446Smrj * list, must handle it here. 748*3446Smrj * 749*3446Smrj * Disassemble the TermArg parse tree. ACPI_PARSEOP_PARAMLIST 750*3446Smrj * eliminates newline in the output. 751*3446Smrj */ 752*3446Smrj NextOp = NextOp->Common.Next; 753*3446Smrj 754*3446Smrj Info->Flags = ACPI_PARSEOP_PARAMLIST; 755*3446Smrj AcpiDmWalkParseTree (NextOp, AcpiDmDescendingOp, AcpiDmAscendingOp, Info); 756*3446Smrj Info->Flags = 0; 757*3446Smrj Info->Level = Level; 758*3446Smrj 759*3446Smrj NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; 760*3446Smrj AcpiOsPrintf (", "); 761*3446Smrj break; 762*3446Smrj 763*3446Smrj case AML_INDEX_FIELD_OP: 764*3446Smrj 765*3446Smrj /* Namestring - Data Name */ 766*3446Smrj 767*3446Smrj NextOp = AcpiPsGetDepthNext (NULL, NextOp); 768*3446Smrj AcpiDmNamestring (NextOp->Common.Value.Name); 769*3446Smrj AcpiOsPrintf (", "); 770*3446Smrj NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; 771*3446Smrj break; 772*3446Smrj 773*3446Smrj default: 774*3446Smrj 775*3446Smrj break; 776*3446Smrj } 777*3446Smrj 778*3446Smrj AcpiDmFieldFlags (NextOp); 779*3446Smrj break; 780*3446Smrj 781*3446Smrj 782*3446Smrj case AML_BUFFER_OP: 783*3446Smrj 784*3446Smrj /* The next op is the size parameter */ 785*3446Smrj 786*3446Smrj NextOp = AcpiPsGetDepthNext (NULL, Op); 787*3446Smrj if (!NextOp) 788*3446Smrj { 789*3446Smrj /* Single-step support */ 790*3446Smrj 791*3446Smrj return (AE_OK); 792*3446Smrj } 793*3446Smrj 794*3446Smrj if (Op->Common.DisasmOpcode == ACPI_DASM_RESOURCE) 795*3446Smrj { 796*3446Smrj /* 797*3446Smrj * We have a resource list. Don't need to output 798*3446Smrj * the buffer size Op. Open up a new block 799*3446Smrj */ 800*3446Smrj NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; 801*3446Smrj NextOp = NextOp->Common.Next; 802*3446Smrj AcpiOsPrintf (")\n"); 803*3446Smrj AcpiDmIndent (Info->Level); 804*3446Smrj AcpiOsPrintf ("{\n"); 805*3446Smrj return (AE_OK); 806*3446Smrj } 807*3446Smrj 808*3446Smrj /* Normal Buffer, mark size as in the parameter list */ 809*3446Smrj 810*3446Smrj NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; 811*3446Smrj return (AE_OK); 812*3446Smrj 813*3446Smrj 814*3446Smrj case AML_VAR_PACKAGE_OP: 815*3446Smrj case AML_IF_OP: 816*3446Smrj case AML_WHILE_OP: 817*3446Smrj 818*3446Smrj /* The next op is the size or predicate parameter */ 819*3446Smrj 820*3446Smrj NextOp = AcpiPsGetDepthNext (NULL, Op); 821*3446Smrj if (NextOp) 822*3446Smrj { 823*3446Smrj NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; 824*3446Smrj } 825*3446Smrj return (AE_OK); 826*3446Smrj 827*3446Smrj 828*3446Smrj case AML_PACKAGE_OP: 829*3446Smrj 830*3446Smrj /* The next op is the size or predicate parameter */ 831*3446Smrj 832*3446Smrj NextOp = AcpiPsGetDepthNext (NULL, Op); 833*3446Smrj if (NextOp) 834*3446Smrj { 835*3446Smrj NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST; 836*3446Smrj } 837*3446Smrj return (AE_OK); 838*3446Smrj 839*3446Smrj 840*3446Smrj case AML_MATCH_OP: 841*3446Smrj 842*3446Smrj AcpiDmMatchOp (Op); 843*3446Smrj break; 844*3446Smrj 845*3446Smrj 846*3446Smrj default: 847*3446Smrj 848*3446Smrj break; 849*3446Smrj } 850*3446Smrj 851*3446Smrj if (AcpiDmBlockType (Op) & BLOCK_BRACE) 852*3446Smrj { 853*3446Smrj AcpiOsPrintf ("\n"); 854*3446Smrj AcpiDmIndent (Level); 855*3446Smrj AcpiOsPrintf ("{\n"); 856*3446Smrj } 857*3446Smrj } 858*3446Smrj 859*3446Smrj return (AE_OK); 860*3446Smrj } 861*3446Smrj 862*3446Smrj 863*3446Smrj /******************************************************************************* 864*3446Smrj * 865*3446Smrj * FUNCTION: AcpiDmAscendingOp 866*3446Smrj * 867*3446Smrj * PARAMETERS: ASL_WALK_CALLBACK 868*3446Smrj * 869*3446Smrj * RETURN: Status 870*3446Smrj * 871*3446Smrj * DESCRIPTION: Second visitation of a parse object, during ascent of parse 872*3446Smrj * tree. Close out any parameter lists and complete the opcode. 873*3446Smrj * 874*3446Smrj ******************************************************************************/ 875*3446Smrj 876*3446Smrj static ACPI_STATUS 877*3446Smrj AcpiDmAscendingOp ( 878*3446Smrj ACPI_PARSE_OBJECT *Op, 879*3446Smrj UINT32 Level, 880*3446Smrj void *Context) 881*3446Smrj { 882*3446Smrj ACPI_OP_WALK_INFO *Info = Context; 883*3446Smrj 884*3446Smrj 885*3446Smrj if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE) 886*3446Smrj { 887*3446Smrj /* Ignore this op -- it was handled elsewhere */ 888*3446Smrj 889*3446Smrj return (AE_OK); 890*3446Smrj } 891*3446Smrj 892*3446Smrj if ((Level == 0) && (Op->Common.AmlOpcode == AML_SCOPE_OP)) 893*3446Smrj { 894*3446Smrj /* Indicates the end of the current descriptor block (table) */ 895*3446Smrj 896*3446Smrj AcpiOsPrintf ("}\n\n"); 897*3446Smrj return (AE_OK); 898*3446Smrj } 899*3446Smrj 900*3446Smrj switch (AcpiDmBlockType (Op)) 901*3446Smrj { 902*3446Smrj case BLOCK_PAREN: 903*3446Smrj 904*3446Smrj /* Completed an op that has arguments, add closing paren */ 905*3446Smrj 906*3446Smrj AcpiOsPrintf (")"); 907*3446Smrj 908*3446Smrj /* Could be a nested operator, check if comma required */ 909*3446Smrj 910*3446Smrj if (!AcpiDmCommaIfListMember (Op)) 911*3446Smrj { 912*3446Smrj if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) && 913*3446Smrj (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) && 914*3446Smrj (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) 915*3446Smrj { 916*3446Smrj /* 917*3446Smrj * This is a first-level element of a term list 918*3446Smrj * start a new line 919*3446Smrj */ 920*3446Smrj if (!(Info->Flags & ACPI_PARSEOP_PARAMLIST)) 921*3446Smrj { 922*3446Smrj AcpiOsPrintf ("\n"); 923*3446Smrj } 924*3446Smrj } 925*3446Smrj } 926*3446Smrj break; 927*3446Smrj 928*3446Smrj 929*3446Smrj case BLOCK_BRACE: 930*3446Smrj case (BLOCK_BRACE | BLOCK_PAREN): 931*3446Smrj 932*3446Smrj /* Completed an op that has a term list, add closing brace */ 933*3446Smrj 934*3446Smrj if (Op->Common.DisasmFlags & ACPI_PARSEOP_EMPTY_TERMLIST) 935*3446Smrj { 936*3446Smrj AcpiOsPrintf ("}"); 937*3446Smrj } 938*3446Smrj else 939*3446Smrj { 940*3446Smrj AcpiDmIndent (Level); 941*3446Smrj AcpiOsPrintf ("}"); 942*3446Smrj } 943*3446Smrj 944*3446Smrj AcpiDmCommaIfListMember (Op); 945*3446Smrj 946*3446Smrj if (AcpiDmBlockType (Op->Common.Parent) != BLOCK_PAREN) 947*3446Smrj { 948*3446Smrj AcpiOsPrintf ("\n"); 949*3446Smrj if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_EMPTY_TERMLIST)) 950*3446Smrj { 951*3446Smrj if ((Op->Common.AmlOpcode == AML_IF_OP) && 952*3446Smrj (Op->Common.Next) && 953*3446Smrj (Op->Common.Next->Common.AmlOpcode == AML_ELSE_OP)) 954*3446Smrj { 955*3446Smrj break; 956*3446Smrj } 957*3446Smrj 958*3446Smrj if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) && 959*3446Smrj (!Op->Common.Next)) 960*3446Smrj { 961*3446Smrj break; 962*3446Smrj } 963*3446Smrj AcpiOsPrintf ("\n"); 964*3446Smrj } 965*3446Smrj } 966*3446Smrj break; 967*3446Smrj 968*3446Smrj 969*3446Smrj case BLOCK_NONE: 970*3446Smrj default: 971*3446Smrj 972*3446Smrj /* Could be a nested operator, check if comma required */ 973*3446Smrj 974*3446Smrj if (!AcpiDmCommaIfListMember (Op)) 975*3446Smrj { 976*3446Smrj if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) && 977*3446Smrj (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) && 978*3446Smrj (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) 979*3446Smrj { 980*3446Smrj /* 981*3446Smrj * This is a first-level element of a term list 982*3446Smrj * start a new line 983*3446Smrj */ 984*3446Smrj AcpiOsPrintf ("\n"); 985*3446Smrj } 986*3446Smrj } 987*3446Smrj else if (Op->Common.Parent) 988*3446Smrj { 989*3446Smrj switch (Op->Common.Parent->Common.AmlOpcode) 990*3446Smrj { 991*3446Smrj case AML_PACKAGE_OP: 992*3446Smrj case AML_VAR_PACKAGE_OP: 993*3446Smrj 994*3446Smrj if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) 995*3446Smrj { 996*3446Smrj AcpiOsPrintf ("\n"); 997*3446Smrj } 998*3446Smrj break; 999*3446Smrj 1000*3446Smrj default: 1001*3446Smrj 1002*3446Smrj break; 1003*3446Smrj } 1004*3446Smrj } 1005*3446Smrj break; 1006*3446Smrj } 1007*3446Smrj 1008*3446Smrj if (Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST) 1009*3446Smrj { 1010*3446Smrj if ((Op->Common.Next) && 1011*3446Smrj (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) 1012*3446Smrj { 1013*3446Smrj return (AE_OK); 1014*3446Smrj } 1015*3446Smrj 1016*3446Smrj /* 1017*3446Smrj * Just completed a parameter node for something like "Buffer (param)". 1018*3446Smrj * Close the paren and open up the term list block with a brace 1019*3446Smrj */ 1020*3446Smrj if (Op->Common.Next) 1021*3446Smrj { 1022*3446Smrj AcpiOsPrintf (")\n"); 1023*3446Smrj AcpiDmIndent (Level - 1); 1024*3446Smrj AcpiOsPrintf ("{\n"); 1025*3446Smrj } 1026*3446Smrj else 1027*3446Smrj { 1028*3446Smrj Op->Common.Parent->Common.DisasmFlags |= 1029*3446Smrj ACPI_PARSEOP_EMPTY_TERMLIST; 1030*3446Smrj AcpiOsPrintf (") {"); 1031*3446Smrj } 1032*3446Smrj } 1033*3446Smrj 1034*3446Smrj if ((Op->Common.AmlOpcode == AML_NAME_OP) || 1035*3446Smrj (Op->Common.AmlOpcode == AML_RETURN_OP)) 1036*3446Smrj { 1037*3446Smrj Info->Level++; 1038*3446Smrj } 1039*3446Smrj return (AE_OK); 1040*3446Smrj } 1041*3446Smrj 1042*3446Smrj 1043*3446Smrj #endif /* ACPI_DISASSEMBLER */ 1044