1*bc36eafdSMike Gerdts /****************************************************************************** 2*bc36eafdSMike Gerdts * 3*bc36eafdSMike Gerdts * Module Name: adwalk - Application-level disassembler parse tree walk routines 4*bc36eafdSMike Gerdts * 5*bc36eafdSMike Gerdts *****************************************************************************/ 6*bc36eafdSMike Gerdts 7*bc36eafdSMike Gerdts /* 8*bc36eafdSMike Gerdts * Copyright (C) 2000 - 2016, Intel Corp. 9*bc36eafdSMike Gerdts * All rights reserved. 10*bc36eafdSMike Gerdts * 11*bc36eafdSMike Gerdts * Redistribution and use in source and binary forms, with or without 12*bc36eafdSMike Gerdts * modification, are permitted provided that the following conditions 13*bc36eafdSMike Gerdts * are met: 14*bc36eafdSMike Gerdts * 1. Redistributions of source code must retain the above copyright 15*bc36eafdSMike Gerdts * notice, this list of conditions, and the following disclaimer, 16*bc36eafdSMike Gerdts * without modification. 17*bc36eafdSMike Gerdts * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18*bc36eafdSMike Gerdts * substantially similar to the "NO WARRANTY" disclaimer below 19*bc36eafdSMike Gerdts * ("Disclaimer") and any redistribution must be conditioned upon 20*bc36eafdSMike Gerdts * including a substantially similar Disclaimer requirement for further 21*bc36eafdSMike Gerdts * binary redistribution. 22*bc36eafdSMike Gerdts * 3. Neither the names of the above-listed copyright holders nor the names 23*bc36eafdSMike Gerdts * of any contributors may be used to endorse or promote products derived 24*bc36eafdSMike Gerdts * from this software without specific prior written permission. 25*bc36eafdSMike Gerdts * 26*bc36eafdSMike Gerdts * Alternatively, this software may be distributed under the terms of the 27*bc36eafdSMike Gerdts * GNU General Public License ("GPL") version 2 as published by the Free 28*bc36eafdSMike Gerdts * Software Foundation. 29*bc36eafdSMike Gerdts * 30*bc36eafdSMike Gerdts * NO WARRANTY 31*bc36eafdSMike Gerdts * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32*bc36eafdSMike Gerdts * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33*bc36eafdSMike Gerdts * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34*bc36eafdSMike Gerdts * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35*bc36eafdSMike Gerdts * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36*bc36eafdSMike Gerdts * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37*bc36eafdSMike Gerdts * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38*bc36eafdSMike Gerdts * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39*bc36eafdSMike Gerdts * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40*bc36eafdSMike Gerdts * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41*bc36eafdSMike Gerdts * POSSIBILITY OF SUCH DAMAGES. 42*bc36eafdSMike Gerdts */ 43*bc36eafdSMike Gerdts 44*bc36eafdSMike Gerdts #include "acpi.h" 45*bc36eafdSMike Gerdts #include "accommon.h" 46*bc36eafdSMike Gerdts #include "acparser.h" 47*bc36eafdSMike Gerdts #include "amlcode.h" 48*bc36eafdSMike Gerdts #include "acdisasm.h" 49*bc36eafdSMike Gerdts #include "acdispat.h" 50*bc36eafdSMike Gerdts #include "acnamesp.h" 51*bc36eafdSMike Gerdts #include "acapps.h" 52*bc36eafdSMike Gerdts 53*bc36eafdSMike Gerdts 54*bc36eafdSMike Gerdts #define _COMPONENT ACPI_TOOLS 55*bc36eafdSMike Gerdts ACPI_MODULE_NAME ("adwalk") 56*bc36eafdSMike Gerdts 57*bc36eafdSMike Gerdts /* 58*bc36eafdSMike Gerdts * aslmap - opcode mappings and reserved method names 59*bc36eafdSMike Gerdts */ 60*bc36eafdSMike Gerdts ACPI_OBJECT_TYPE 61*bc36eafdSMike Gerdts AslMapNamedOpcodeToDataType ( 62*bc36eafdSMike Gerdts UINT16 Opcode); 63*bc36eafdSMike Gerdts 64*bc36eafdSMike Gerdts /* Local prototypes */ 65*bc36eafdSMike Gerdts 66*bc36eafdSMike Gerdts static ACPI_STATUS 67*bc36eafdSMike Gerdts AcpiDmFindOrphanDescending ( 68*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op, 69*bc36eafdSMike Gerdts UINT32 Level, 70*bc36eafdSMike Gerdts void *Context); 71*bc36eafdSMike Gerdts 72*bc36eafdSMike Gerdts static ACPI_STATUS 73*bc36eafdSMike Gerdts AcpiDmDumpDescending ( 74*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op, 75*bc36eafdSMike Gerdts UINT32 Level, 76*bc36eafdSMike Gerdts void *Context); 77*bc36eafdSMike Gerdts 78*bc36eafdSMike Gerdts static ACPI_STATUS 79*bc36eafdSMike Gerdts AcpiDmXrefDescendingOp ( 80*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op, 81*bc36eafdSMike Gerdts UINT32 Level, 82*bc36eafdSMike Gerdts void *Context); 83*bc36eafdSMike Gerdts 84*bc36eafdSMike Gerdts static ACPI_STATUS 85*bc36eafdSMike Gerdts AcpiDmCommonAscendingOp ( 86*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op, 87*bc36eafdSMike Gerdts UINT32 Level, 88*bc36eafdSMike Gerdts void *Context); 89*bc36eafdSMike Gerdts 90*bc36eafdSMike Gerdts static ACPI_STATUS 91*bc36eafdSMike Gerdts AcpiDmLoadDescendingOp ( 92*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op, 93*bc36eafdSMike Gerdts UINT32 Level, 94*bc36eafdSMike Gerdts void *Context); 95*bc36eafdSMike Gerdts 96*bc36eafdSMike Gerdts static UINT32 97*bc36eafdSMike Gerdts AcpiDmInspectPossibleArgs ( 98*bc36eafdSMike Gerdts UINT32 CurrentOpArgCount, 99*bc36eafdSMike Gerdts UINT32 TargetCount, 100*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op); 101*bc36eafdSMike Gerdts 102*bc36eafdSMike Gerdts static ACPI_STATUS 103*bc36eafdSMike Gerdts AcpiDmResourceDescendingOp ( 104*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op, 105*bc36eafdSMike Gerdts UINT32 Level, 106*bc36eafdSMike Gerdts void *Context); 107*bc36eafdSMike Gerdts 108*bc36eafdSMike Gerdts 109*bc36eafdSMike Gerdts /******************************************************************************* 110*bc36eafdSMike Gerdts * 111*bc36eafdSMike Gerdts * FUNCTION: AcpiDmDumpTree 112*bc36eafdSMike Gerdts * 113*bc36eafdSMike Gerdts * PARAMETERS: Origin - Starting object 114*bc36eafdSMike Gerdts * 115*bc36eafdSMike Gerdts * RETURN: None 116*bc36eafdSMike Gerdts * 117*bc36eafdSMike Gerdts * DESCRIPTION: Parse tree walk to format and output the nodes 118*bc36eafdSMike Gerdts * 119*bc36eafdSMike Gerdts ******************************************************************************/ 120*bc36eafdSMike Gerdts 121*bc36eafdSMike Gerdts void 122*bc36eafdSMike Gerdts AcpiDmDumpTree ( 123*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Origin) 124*bc36eafdSMike Gerdts { 125*bc36eafdSMike Gerdts ACPI_OP_WALK_INFO Info; 126*bc36eafdSMike Gerdts 127*bc36eafdSMike Gerdts 128*bc36eafdSMike Gerdts if (!Origin) 129*bc36eafdSMike Gerdts { 130*bc36eafdSMike Gerdts return; 131*bc36eafdSMike Gerdts } 132*bc36eafdSMike Gerdts 133*bc36eafdSMike Gerdts AcpiOsPrintf ("/*\nAML Parse Tree\n\n"); 134*bc36eafdSMike Gerdts Info.Flags = 0; 135*bc36eafdSMike Gerdts Info.Count = 0; 136*bc36eafdSMike Gerdts Info.Level = 0; 137*bc36eafdSMike Gerdts Info.WalkState = NULL; 138*bc36eafdSMike Gerdts 139*bc36eafdSMike Gerdts AcpiDmWalkParseTree (Origin, AcpiDmDumpDescending, NULL, &Info); 140*bc36eafdSMike Gerdts AcpiOsPrintf ("*/\n\n"); 141*bc36eafdSMike Gerdts } 142*bc36eafdSMike Gerdts 143*bc36eafdSMike Gerdts 144*bc36eafdSMike Gerdts /******************************************************************************* 145*bc36eafdSMike Gerdts * 146*bc36eafdSMike Gerdts * FUNCTION: AcpiDmFindOrphanMethods 147*bc36eafdSMike Gerdts * 148*bc36eafdSMike Gerdts * PARAMETERS: Origin - Starting object 149*bc36eafdSMike Gerdts * 150*bc36eafdSMike Gerdts * RETURN: None 151*bc36eafdSMike Gerdts * 152*bc36eafdSMike Gerdts * DESCRIPTION: Parse tree walk to find "orphaned" method invocations -- methods 153*bc36eafdSMike Gerdts * that are not resolved in the namespace 154*bc36eafdSMike Gerdts * 155*bc36eafdSMike Gerdts ******************************************************************************/ 156*bc36eafdSMike Gerdts 157*bc36eafdSMike Gerdts void 158*bc36eafdSMike Gerdts AcpiDmFindOrphanMethods ( 159*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Origin) 160*bc36eafdSMike Gerdts { 161*bc36eafdSMike Gerdts ACPI_OP_WALK_INFO Info; 162*bc36eafdSMike Gerdts 163*bc36eafdSMike Gerdts 164*bc36eafdSMike Gerdts if (!Origin) 165*bc36eafdSMike Gerdts { 166*bc36eafdSMike Gerdts return; 167*bc36eafdSMike Gerdts } 168*bc36eafdSMike Gerdts 169*bc36eafdSMike Gerdts Info.Flags = 0; 170*bc36eafdSMike Gerdts Info.Level = 0; 171*bc36eafdSMike Gerdts Info.WalkState = NULL; 172*bc36eafdSMike Gerdts 173*bc36eafdSMike Gerdts AcpiDmWalkParseTree (Origin, AcpiDmFindOrphanDescending, NULL, &Info); 174*bc36eafdSMike Gerdts } 175*bc36eafdSMike Gerdts 176*bc36eafdSMike Gerdts 177*bc36eafdSMike Gerdts /******************************************************************************* 178*bc36eafdSMike Gerdts * 179*bc36eafdSMike Gerdts * FUNCTION: AcpiDmFinishNamespaceLoad 180*bc36eafdSMike Gerdts * 181*bc36eafdSMike Gerdts * PARAMETERS: ParseTreeRoot - Root of the parse tree 182*bc36eafdSMike Gerdts * NamespaceRoot - Root of the internal namespace 183*bc36eafdSMike Gerdts * OwnerId - OwnerId of the table to be disassembled 184*bc36eafdSMike Gerdts * 185*bc36eafdSMike Gerdts * RETURN: None 186*bc36eafdSMike Gerdts * 187*bc36eafdSMike Gerdts * DESCRIPTION: Load all namespace items that are created within control 188*bc36eafdSMike Gerdts * methods. Used before namespace cross reference 189*bc36eafdSMike Gerdts * 190*bc36eafdSMike Gerdts ******************************************************************************/ 191*bc36eafdSMike Gerdts 192*bc36eafdSMike Gerdts void 193*bc36eafdSMike Gerdts AcpiDmFinishNamespaceLoad ( 194*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *ParseTreeRoot, 195*bc36eafdSMike Gerdts ACPI_NAMESPACE_NODE *NamespaceRoot, 196*bc36eafdSMike Gerdts ACPI_OWNER_ID OwnerId) 197*bc36eafdSMike Gerdts { 198*bc36eafdSMike Gerdts ACPI_STATUS Status; 199*bc36eafdSMike Gerdts ACPI_OP_WALK_INFO Info; 200*bc36eafdSMike Gerdts ACPI_WALK_STATE *WalkState; 201*bc36eafdSMike Gerdts 202*bc36eafdSMike Gerdts 203*bc36eafdSMike Gerdts if (!ParseTreeRoot) 204*bc36eafdSMike Gerdts { 205*bc36eafdSMike Gerdts return; 206*bc36eafdSMike Gerdts } 207*bc36eafdSMike Gerdts 208*bc36eafdSMike Gerdts /* Create and initialize a new walk state */ 209*bc36eafdSMike Gerdts 210*bc36eafdSMike Gerdts WalkState = AcpiDsCreateWalkState (OwnerId, ParseTreeRoot, NULL, NULL); 211*bc36eafdSMike Gerdts if (!WalkState) 212*bc36eafdSMike Gerdts { 213*bc36eafdSMike Gerdts return; 214*bc36eafdSMike Gerdts } 215*bc36eafdSMike Gerdts 216*bc36eafdSMike Gerdts Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type, 217*bc36eafdSMike Gerdts WalkState); 218*bc36eafdSMike Gerdts if (ACPI_FAILURE (Status)) 219*bc36eafdSMike Gerdts { 220*bc36eafdSMike Gerdts return; 221*bc36eafdSMike Gerdts } 222*bc36eafdSMike Gerdts 223*bc36eafdSMike Gerdts Info.Flags = 0; 224*bc36eafdSMike Gerdts Info.Level = 0; 225*bc36eafdSMike Gerdts Info.WalkState = WalkState; 226*bc36eafdSMike Gerdts 227*bc36eafdSMike Gerdts AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmLoadDescendingOp, 228*bc36eafdSMike Gerdts AcpiDmCommonAscendingOp, &Info); 229*bc36eafdSMike Gerdts ACPI_FREE (WalkState); 230*bc36eafdSMike Gerdts } 231*bc36eafdSMike Gerdts 232*bc36eafdSMike Gerdts 233*bc36eafdSMike Gerdts /******************************************************************************* 234*bc36eafdSMike Gerdts * 235*bc36eafdSMike Gerdts * FUNCTION: AcpiDmCrossReferenceNamespace 236*bc36eafdSMike Gerdts * 237*bc36eafdSMike Gerdts * PARAMETERS: ParseTreeRoot - Root of the parse tree 238*bc36eafdSMike Gerdts * NamespaceRoot - Root of the internal namespace 239*bc36eafdSMike Gerdts * OwnerId - OwnerId of the table to be disassembled 240*bc36eafdSMike Gerdts * 241*bc36eafdSMike Gerdts * RETURN: None 242*bc36eafdSMike Gerdts * 243*bc36eafdSMike Gerdts * DESCRIPTION: Cross reference the namespace to create externals 244*bc36eafdSMike Gerdts * 245*bc36eafdSMike Gerdts ******************************************************************************/ 246*bc36eafdSMike Gerdts 247*bc36eafdSMike Gerdts void 248*bc36eafdSMike Gerdts AcpiDmCrossReferenceNamespace ( 249*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *ParseTreeRoot, 250*bc36eafdSMike Gerdts ACPI_NAMESPACE_NODE *NamespaceRoot, 251*bc36eafdSMike Gerdts ACPI_OWNER_ID OwnerId) 252*bc36eafdSMike Gerdts { 253*bc36eafdSMike Gerdts ACPI_STATUS Status; 254*bc36eafdSMike Gerdts ACPI_OP_WALK_INFO Info; 255*bc36eafdSMike Gerdts ACPI_WALK_STATE *WalkState; 256*bc36eafdSMike Gerdts 257*bc36eafdSMike Gerdts 258*bc36eafdSMike Gerdts if (!ParseTreeRoot) 259*bc36eafdSMike Gerdts { 260*bc36eafdSMike Gerdts return; 261*bc36eafdSMike Gerdts } 262*bc36eafdSMike Gerdts 263*bc36eafdSMike Gerdts /* Create and initialize a new walk state */ 264*bc36eafdSMike Gerdts 265*bc36eafdSMike Gerdts WalkState = AcpiDsCreateWalkState (OwnerId, ParseTreeRoot, NULL, NULL); 266*bc36eafdSMike Gerdts if (!WalkState) 267*bc36eafdSMike Gerdts { 268*bc36eafdSMike Gerdts return; 269*bc36eafdSMike Gerdts } 270*bc36eafdSMike Gerdts 271*bc36eafdSMike Gerdts Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type, 272*bc36eafdSMike Gerdts WalkState); 273*bc36eafdSMike Gerdts if (ACPI_FAILURE (Status)) 274*bc36eafdSMike Gerdts { 275*bc36eafdSMike Gerdts return; 276*bc36eafdSMike Gerdts } 277*bc36eafdSMike Gerdts 278*bc36eafdSMike Gerdts Info.Flags = 0; 279*bc36eafdSMike Gerdts Info.Level = 0; 280*bc36eafdSMike Gerdts Info.WalkState = WalkState; 281*bc36eafdSMike Gerdts 282*bc36eafdSMike Gerdts AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmXrefDescendingOp, 283*bc36eafdSMike Gerdts AcpiDmCommonAscendingOp, &Info); 284*bc36eafdSMike Gerdts ACPI_FREE (WalkState); 285*bc36eafdSMike Gerdts } 286*bc36eafdSMike Gerdts 287*bc36eafdSMike Gerdts 288*bc36eafdSMike Gerdts /******************************************************************************* 289*bc36eafdSMike Gerdts * 290*bc36eafdSMike Gerdts * FUNCTION: AcpiDmConvertResourceIndexes 291*bc36eafdSMike Gerdts * 292*bc36eafdSMike Gerdts * PARAMETERS: ParseTreeRoot - Root of the parse tree 293*bc36eafdSMike Gerdts * NamespaceRoot - Root of the internal namespace 294*bc36eafdSMike Gerdts * 295*bc36eafdSMike Gerdts * RETURN: None 296*bc36eafdSMike Gerdts * 297*bc36eafdSMike Gerdts * DESCRIPTION: Convert fixed-offset references to resource descriptors to 298*bc36eafdSMike Gerdts * symbolic references. Should only be called after namespace has 299*bc36eafdSMike Gerdts * been cross referenced. 300*bc36eafdSMike Gerdts * 301*bc36eafdSMike Gerdts ******************************************************************************/ 302*bc36eafdSMike Gerdts 303*bc36eafdSMike Gerdts void 304*bc36eafdSMike Gerdts AcpiDmConvertResourceIndexes ( 305*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *ParseTreeRoot, 306*bc36eafdSMike Gerdts ACPI_NAMESPACE_NODE *NamespaceRoot) 307*bc36eafdSMike Gerdts { 308*bc36eafdSMike Gerdts ACPI_STATUS Status; 309*bc36eafdSMike Gerdts ACPI_OP_WALK_INFO Info; 310*bc36eafdSMike Gerdts ACPI_WALK_STATE *WalkState; 311*bc36eafdSMike Gerdts 312*bc36eafdSMike Gerdts 313*bc36eafdSMike Gerdts if (!ParseTreeRoot) 314*bc36eafdSMike Gerdts { 315*bc36eafdSMike Gerdts return; 316*bc36eafdSMike Gerdts } 317*bc36eafdSMike Gerdts 318*bc36eafdSMike Gerdts /* Create and initialize a new walk state */ 319*bc36eafdSMike Gerdts 320*bc36eafdSMike Gerdts WalkState = AcpiDsCreateWalkState (0, ParseTreeRoot, NULL, NULL); 321*bc36eafdSMike Gerdts if (!WalkState) 322*bc36eafdSMike Gerdts { 323*bc36eafdSMike Gerdts return; 324*bc36eafdSMike Gerdts } 325*bc36eafdSMike Gerdts 326*bc36eafdSMike Gerdts Status = AcpiDsScopeStackPush (NamespaceRoot, NamespaceRoot->Type, 327*bc36eafdSMike Gerdts WalkState); 328*bc36eafdSMike Gerdts if (ACPI_FAILURE (Status)) 329*bc36eafdSMike Gerdts { 330*bc36eafdSMike Gerdts ACPI_FREE (WalkState); 331*bc36eafdSMike Gerdts return; 332*bc36eafdSMike Gerdts } 333*bc36eafdSMike Gerdts 334*bc36eafdSMike Gerdts Info.Flags = 0; 335*bc36eafdSMike Gerdts Info.Level = 0; 336*bc36eafdSMike Gerdts Info.WalkState = WalkState; 337*bc36eafdSMike Gerdts 338*bc36eafdSMike Gerdts AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmResourceDescendingOp, 339*bc36eafdSMike Gerdts AcpiDmCommonAscendingOp, &Info); 340*bc36eafdSMike Gerdts ACPI_FREE (WalkState); 341*bc36eafdSMike Gerdts return; 342*bc36eafdSMike Gerdts } 343*bc36eafdSMike Gerdts 344*bc36eafdSMike Gerdts 345*bc36eafdSMike Gerdts /******************************************************************************* 346*bc36eafdSMike Gerdts * 347*bc36eafdSMike Gerdts * FUNCTION: AcpiDmDumpDescending 348*bc36eafdSMike Gerdts * 349*bc36eafdSMike Gerdts * PARAMETERS: ASL_WALK_CALLBACK 350*bc36eafdSMike Gerdts * 351*bc36eafdSMike Gerdts * RETURN: Status 352*bc36eafdSMike Gerdts * 353*bc36eafdSMike Gerdts * DESCRIPTION: Format and print contents of one parse Op. 354*bc36eafdSMike Gerdts * 355*bc36eafdSMike Gerdts ******************************************************************************/ 356*bc36eafdSMike Gerdts 357*bc36eafdSMike Gerdts static ACPI_STATUS 358*bc36eafdSMike Gerdts AcpiDmDumpDescending ( 359*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op, 360*bc36eafdSMike Gerdts UINT32 Level, 361*bc36eafdSMike Gerdts void *Context) 362*bc36eafdSMike Gerdts { 363*bc36eafdSMike Gerdts ACPI_OP_WALK_INFO *Info = Context; 364*bc36eafdSMike Gerdts char *Path; 365*bc36eafdSMike Gerdts 366*bc36eafdSMike Gerdts 367*bc36eafdSMike Gerdts if (!Op) 368*bc36eafdSMike Gerdts { 369*bc36eafdSMike Gerdts return (AE_OK); 370*bc36eafdSMike Gerdts } 371*bc36eafdSMike Gerdts 372*bc36eafdSMike Gerdts /* Most of the information (count, level, name) here */ 373*bc36eafdSMike Gerdts 374*bc36eafdSMike Gerdts Info->Count++; 375*bc36eafdSMike Gerdts AcpiOsPrintf ("% 5d [%2.2d] ", Info->Count, Level); 376*bc36eafdSMike Gerdts AcpiDmIndent (Level); 377*bc36eafdSMike Gerdts AcpiOsPrintf ("%-28s", AcpiPsGetOpcodeName (Op->Common.AmlOpcode)); 378*bc36eafdSMike Gerdts 379*bc36eafdSMike Gerdts /* Extra info is helpful */ 380*bc36eafdSMike Gerdts 381*bc36eafdSMike Gerdts switch (Op->Common.AmlOpcode) 382*bc36eafdSMike Gerdts { 383*bc36eafdSMike Gerdts case AML_BYTE_OP: 384*bc36eafdSMike Gerdts 385*bc36eafdSMike Gerdts AcpiOsPrintf ("%2.2X", (UINT32) Op->Common.Value.Integer); 386*bc36eafdSMike Gerdts break; 387*bc36eafdSMike Gerdts 388*bc36eafdSMike Gerdts case AML_WORD_OP: 389*bc36eafdSMike Gerdts 390*bc36eafdSMike Gerdts AcpiOsPrintf ("%4.4X", (UINT32) Op->Common.Value.Integer); 391*bc36eafdSMike Gerdts break; 392*bc36eafdSMike Gerdts 393*bc36eafdSMike Gerdts case AML_DWORD_OP: 394*bc36eafdSMike Gerdts 395*bc36eafdSMike Gerdts AcpiOsPrintf ("%8.8X", (UINT32) Op->Common.Value.Integer); 396*bc36eafdSMike Gerdts break; 397*bc36eafdSMike Gerdts 398*bc36eafdSMike Gerdts case AML_QWORD_OP: 399*bc36eafdSMike Gerdts 400*bc36eafdSMike Gerdts AcpiOsPrintf ("%8.8X%8.8X", ACPI_FORMAT_UINT64 (Op->Common.Value.Integer)); 401*bc36eafdSMike Gerdts break; 402*bc36eafdSMike Gerdts 403*bc36eafdSMike Gerdts case AML_INT_NAMEPATH_OP: 404*bc36eafdSMike Gerdts 405*bc36eafdSMike Gerdts if (Op->Common.Value.String) 406*bc36eafdSMike Gerdts { 407*bc36eafdSMike Gerdts AcpiNsExternalizeName (ACPI_UINT32_MAX, Op->Common.Value.String, 408*bc36eafdSMike Gerdts NULL, &Path); 409*bc36eafdSMike Gerdts AcpiOsPrintf ("%s %p", Path, Op->Common.Node); 410*bc36eafdSMike Gerdts ACPI_FREE (Path); 411*bc36eafdSMike Gerdts } 412*bc36eafdSMike Gerdts else 413*bc36eafdSMike Gerdts { 414*bc36eafdSMike Gerdts AcpiOsPrintf ("[NULL]"); 415*bc36eafdSMike Gerdts } 416*bc36eafdSMike Gerdts break; 417*bc36eafdSMike Gerdts 418*bc36eafdSMike Gerdts case AML_NAME_OP: 419*bc36eafdSMike Gerdts case AML_METHOD_OP: 420*bc36eafdSMike Gerdts case AML_DEVICE_OP: 421*bc36eafdSMike Gerdts case AML_INT_NAMEDFIELD_OP: 422*bc36eafdSMike Gerdts 423*bc36eafdSMike Gerdts AcpiOsPrintf ("%4.4s", ACPI_CAST_PTR (char, &Op->Named.Name)); 424*bc36eafdSMike Gerdts break; 425*bc36eafdSMike Gerdts 426*bc36eafdSMike Gerdts default: 427*bc36eafdSMike Gerdts 428*bc36eafdSMike Gerdts break; 429*bc36eafdSMike Gerdts } 430*bc36eafdSMike Gerdts 431*bc36eafdSMike Gerdts AcpiOsPrintf ("\n"); 432*bc36eafdSMike Gerdts return (AE_OK); 433*bc36eafdSMike Gerdts } 434*bc36eafdSMike Gerdts 435*bc36eafdSMike Gerdts 436*bc36eafdSMike Gerdts /******************************************************************************* 437*bc36eafdSMike Gerdts * 438*bc36eafdSMike Gerdts * FUNCTION: AcpiDmFindOrphanDescending 439*bc36eafdSMike Gerdts * 440*bc36eafdSMike Gerdts * PARAMETERS: ASL_WALK_CALLBACK 441*bc36eafdSMike Gerdts * 442*bc36eafdSMike Gerdts * RETURN: Status 443*bc36eafdSMike Gerdts * 444*bc36eafdSMike Gerdts * DESCRIPTION: Check namepath Ops for orphaned method invocations 445*bc36eafdSMike Gerdts * 446*bc36eafdSMike Gerdts * Note: Parts of this are experimental, under possible further development. 447*bc36eafdSMike Gerdts * 448*bc36eafdSMike Gerdts ******************************************************************************/ 449*bc36eafdSMike Gerdts 450*bc36eafdSMike Gerdts static ACPI_STATUS 451*bc36eafdSMike Gerdts AcpiDmFindOrphanDescending ( 452*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op, 453*bc36eafdSMike Gerdts UINT32 Level, 454*bc36eafdSMike Gerdts void *Context) 455*bc36eafdSMike Gerdts { 456*bc36eafdSMike Gerdts const ACPI_OPCODE_INFO *OpInfo; 457*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *ChildOp; 458*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *NextOp; 459*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *ParentOp; 460*bc36eafdSMike Gerdts UINT32 ArgCount; 461*bc36eafdSMike Gerdts 462*bc36eafdSMike Gerdts 463*bc36eafdSMike Gerdts if (!Op) 464*bc36eafdSMike Gerdts { 465*bc36eafdSMike Gerdts return (AE_OK); 466*bc36eafdSMike Gerdts } 467*bc36eafdSMike Gerdts 468*bc36eafdSMike Gerdts OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 469*bc36eafdSMike Gerdts 470*bc36eafdSMike Gerdts switch (Op->Common.AmlOpcode) 471*bc36eafdSMike Gerdts { 472*bc36eafdSMike Gerdts #ifdef ACPI_UNDER_DEVELOPMENT 473*bc36eafdSMike Gerdts case AML_ADD_OP: 474*bc36eafdSMike Gerdts 475*bc36eafdSMike Gerdts ChildOp = Op->Common.Value.Arg; 476*bc36eafdSMike Gerdts if ((ChildOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && 477*bc36eafdSMike Gerdts !ChildOp->Common.Node) 478*bc36eafdSMike Gerdts { 479*bc36eafdSMike Gerdts AcpiNsExternalizeName (ACPI_UINT32_MAX, ChildOp->Common.Value.String, 480*bc36eafdSMike Gerdts NULL, &Path); 481*bc36eafdSMike Gerdts AcpiOsPrintf ("/* %-16s A-NAMEPATH: %s */\n", 482*bc36eafdSMike Gerdts Op->Common.AmlOpName, Path); 483*bc36eafdSMike Gerdts ACPI_FREE (Path); 484*bc36eafdSMike Gerdts 485*bc36eafdSMike Gerdts NextOp = Op->Common.Next; 486*bc36eafdSMike Gerdts if (!NextOp) 487*bc36eafdSMike Gerdts { 488*bc36eafdSMike Gerdts /* This NamePath has no args, assume it is an integer */ 489*bc36eafdSMike Gerdts 490*bc36eafdSMike Gerdts AcpiDmAddOpToExternalList (ChildOp, 491*bc36eafdSMike Gerdts ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0); 492*bc36eafdSMike Gerdts return (AE_OK); 493*bc36eafdSMike Gerdts } 494*bc36eafdSMike Gerdts 495*bc36eafdSMike Gerdts ArgCount = AcpiDmInspectPossibleArgs (3, 1, NextOp); 496*bc36eafdSMike Gerdts AcpiOsPrintf ("/* A-CHILDREN: %u Actual %u */\n", 497*bc36eafdSMike Gerdts ArgCount, AcpiDmCountChildren (Op)); 498*bc36eafdSMike Gerdts 499*bc36eafdSMike Gerdts if (ArgCount < 1) 500*bc36eafdSMike Gerdts { 501*bc36eafdSMike Gerdts /* One Arg means this is just a Store(Name,Target) */ 502*bc36eafdSMike Gerdts 503*bc36eafdSMike Gerdts AcpiDmAddOpToExternalList (ChildOp, 504*bc36eafdSMike Gerdts ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0); 505*bc36eafdSMike Gerdts return (AE_OK); 506*bc36eafdSMike Gerdts } 507*bc36eafdSMike Gerdts 508*bc36eafdSMike Gerdts AcpiDmAddOpToExternalList (ChildOp, 509*bc36eafdSMike Gerdts ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0); 510*bc36eafdSMike Gerdts } 511*bc36eafdSMike Gerdts break; 512*bc36eafdSMike Gerdts 513*bc36eafdSMike Gerdts #endif 514*bc36eafdSMike Gerdts 515*bc36eafdSMike Gerdts case AML_STORE_OP: 516*bc36eafdSMike Gerdts 517*bc36eafdSMike Gerdts ChildOp = Op->Common.Value.Arg; 518*bc36eafdSMike Gerdts if ((ChildOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && 519*bc36eafdSMike Gerdts !ChildOp->Common.Node) 520*bc36eafdSMike Gerdts { 521*bc36eafdSMike Gerdts NextOp = Op->Common.Next; 522*bc36eafdSMike Gerdts if (!NextOp) 523*bc36eafdSMike Gerdts { 524*bc36eafdSMike Gerdts /* This NamePath has no args, assume it is an integer */ 525*bc36eafdSMike Gerdts 526*bc36eafdSMike Gerdts AcpiDmAddOpToExternalList (ChildOp, 527*bc36eafdSMike Gerdts ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0); 528*bc36eafdSMike Gerdts return (AE_OK); 529*bc36eafdSMike Gerdts } 530*bc36eafdSMike Gerdts 531*bc36eafdSMike Gerdts ArgCount = AcpiDmInspectPossibleArgs (2, 1, NextOp); 532*bc36eafdSMike Gerdts if (ArgCount <= 1) 533*bc36eafdSMike Gerdts { 534*bc36eafdSMike Gerdts /* One Arg means this is just a Store(Name,Target) */ 535*bc36eafdSMike Gerdts 536*bc36eafdSMike Gerdts AcpiDmAddOpToExternalList (ChildOp, 537*bc36eafdSMike Gerdts ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, ArgCount, 0); 538*bc36eafdSMike Gerdts return (AE_OK); 539*bc36eafdSMike Gerdts } 540*bc36eafdSMike Gerdts 541*bc36eafdSMike Gerdts AcpiDmAddOpToExternalList (ChildOp, 542*bc36eafdSMike Gerdts ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0); 543*bc36eafdSMike Gerdts } 544*bc36eafdSMike Gerdts break; 545*bc36eafdSMike Gerdts 546*bc36eafdSMike Gerdts case AML_INT_NAMEPATH_OP: 547*bc36eafdSMike Gerdts 548*bc36eafdSMike Gerdts /* Must examine parent to see if this namepath is an argument */ 549*bc36eafdSMike Gerdts 550*bc36eafdSMike Gerdts ParentOp = Op->Common.Parent; 551*bc36eafdSMike Gerdts OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode); 552*bc36eafdSMike Gerdts 553*bc36eafdSMike Gerdts if ((OpInfo->Class != AML_CLASS_EXECUTE) && 554*bc36eafdSMike Gerdts (OpInfo->Class != AML_CLASS_CREATE) && 555*bc36eafdSMike Gerdts (OpInfo->ObjectType != ACPI_TYPE_LOCAL_ALIAS) && 556*bc36eafdSMike Gerdts (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) && 557*bc36eafdSMike Gerdts !Op->Common.Node) 558*bc36eafdSMike Gerdts { 559*bc36eafdSMike Gerdts ArgCount = AcpiDmInspectPossibleArgs (0, 0, Op); 560*bc36eafdSMike Gerdts 561*bc36eafdSMike Gerdts /* 562*bc36eafdSMike Gerdts * Check if namepath is a predicate for if/while or lone parameter to 563*bc36eafdSMike Gerdts * a return. 564*bc36eafdSMike Gerdts */ 565*bc36eafdSMike Gerdts if (ArgCount == 0) 566*bc36eafdSMike Gerdts { 567*bc36eafdSMike Gerdts if (((ParentOp->Common.AmlOpcode == AML_IF_OP) || 568*bc36eafdSMike Gerdts (ParentOp->Common.AmlOpcode == AML_WHILE_OP) || 569*bc36eafdSMike Gerdts (ParentOp->Common.AmlOpcode == AML_RETURN_OP)) && 570*bc36eafdSMike Gerdts 571*bc36eafdSMike Gerdts /* And namepath is the first argument */ 572*bc36eafdSMike Gerdts (ParentOp->Common.Value.Arg == Op)) 573*bc36eafdSMike Gerdts { 574*bc36eafdSMike Gerdts AcpiDmAddOpToExternalList (Op, 575*bc36eafdSMike Gerdts Op->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0); 576*bc36eafdSMike Gerdts break; 577*bc36eafdSMike Gerdts } 578*bc36eafdSMike Gerdts } 579*bc36eafdSMike Gerdts 580*bc36eafdSMike Gerdts /* 581*bc36eafdSMike Gerdts * This is a standalone namestring (not a parameter to another 582*bc36eafdSMike Gerdts * operator) - it *must* be a method invocation, nothing else is 583*bc36eafdSMike Gerdts * grammatically possible. 584*bc36eafdSMike Gerdts */ 585*bc36eafdSMike Gerdts AcpiDmAddOpToExternalList (Op, 586*bc36eafdSMike Gerdts Op->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0); 587*bc36eafdSMike Gerdts } 588*bc36eafdSMike Gerdts break; 589*bc36eafdSMike Gerdts 590*bc36eafdSMike Gerdts default: 591*bc36eafdSMike Gerdts 592*bc36eafdSMike Gerdts break; 593*bc36eafdSMike Gerdts } 594*bc36eafdSMike Gerdts 595*bc36eafdSMike Gerdts return (AE_OK); 596*bc36eafdSMike Gerdts } 597*bc36eafdSMike Gerdts 598*bc36eafdSMike Gerdts 599*bc36eafdSMike Gerdts /******************************************************************************* 600*bc36eafdSMike Gerdts * 601*bc36eafdSMike Gerdts * FUNCTION: AcpiDmLoadDescendingOp 602*bc36eafdSMike Gerdts * 603*bc36eafdSMike Gerdts * PARAMETERS: ASL_WALK_CALLBACK 604*bc36eafdSMike Gerdts * 605*bc36eafdSMike Gerdts * RETURN: Status 606*bc36eafdSMike Gerdts * 607*bc36eafdSMike Gerdts * DESCRIPTION: Descending handler for namespace control method object load 608*bc36eafdSMike Gerdts * 609*bc36eafdSMike Gerdts ******************************************************************************/ 610*bc36eafdSMike Gerdts 611*bc36eafdSMike Gerdts static ACPI_STATUS 612*bc36eafdSMike Gerdts AcpiDmLoadDescendingOp ( 613*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op, 614*bc36eafdSMike Gerdts UINT32 Level, 615*bc36eafdSMike Gerdts void *Context) 616*bc36eafdSMike Gerdts { 617*bc36eafdSMike Gerdts ACPI_OP_WALK_INFO *Info = Context; 618*bc36eafdSMike Gerdts const ACPI_OPCODE_INFO *OpInfo; 619*bc36eafdSMike Gerdts ACPI_WALK_STATE *WalkState; 620*bc36eafdSMike Gerdts ACPI_OBJECT_TYPE ObjectType; 621*bc36eafdSMike Gerdts ACPI_STATUS Status; 622*bc36eafdSMike Gerdts char *Path = NULL; 623*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *NextOp; 624*bc36eafdSMike Gerdts ACPI_NAMESPACE_NODE *Node; 625*bc36eafdSMike Gerdts char FieldPath[5]; 626*bc36eafdSMike Gerdts BOOLEAN PreDefined = FALSE; 627*bc36eafdSMike Gerdts UINT8 PreDefineIndex = 0; 628*bc36eafdSMike Gerdts 629*bc36eafdSMike Gerdts 630*bc36eafdSMike Gerdts WalkState = Info->WalkState; 631*bc36eafdSMike Gerdts OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 632*bc36eafdSMike Gerdts ObjectType = OpInfo->ObjectType; 633*bc36eafdSMike Gerdts ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 634*bc36eafdSMike Gerdts 635*bc36eafdSMike Gerdts /* Only interested in operators that create new names */ 636*bc36eafdSMike Gerdts 637*bc36eafdSMike Gerdts if (!(OpInfo->Flags & AML_NAMED) && 638*bc36eafdSMike Gerdts !(OpInfo->Flags & AML_CREATE)) 639*bc36eafdSMike Gerdts { 640*bc36eafdSMike Gerdts goto Exit; 641*bc36eafdSMike Gerdts } 642*bc36eafdSMike Gerdts 643*bc36eafdSMike Gerdts /* Get the NamePath from the appropriate place */ 644*bc36eafdSMike Gerdts 645*bc36eafdSMike Gerdts if (OpInfo->Flags & AML_NAMED) 646*bc36eafdSMike Gerdts { 647*bc36eafdSMike Gerdts /* For all named operators, get the new name */ 648*bc36eafdSMike Gerdts 649*bc36eafdSMike Gerdts Path = (char *) Op->Named.Path; 650*bc36eafdSMike Gerdts 651*bc36eafdSMike Gerdts if (!Path && Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) 652*bc36eafdSMike Gerdts { 653*bc36eafdSMike Gerdts *ACPI_CAST_PTR (UINT32, &FieldPath[0]) = Op->Named.Name; 654*bc36eafdSMike Gerdts FieldPath[4] = 0; 655*bc36eafdSMike Gerdts Path = FieldPath; 656*bc36eafdSMike Gerdts } 657*bc36eafdSMike Gerdts } 658*bc36eafdSMike Gerdts else if (OpInfo->Flags & AML_CREATE) 659*bc36eafdSMike Gerdts { 660*bc36eafdSMike Gerdts /* New name is the last child */ 661*bc36eafdSMike Gerdts 662*bc36eafdSMike Gerdts NextOp = Op->Common.Value.Arg; 663*bc36eafdSMike Gerdts 664*bc36eafdSMike Gerdts while (NextOp->Common.Next) 665*bc36eafdSMike Gerdts { 666*bc36eafdSMike Gerdts NextOp = NextOp->Common.Next; 667*bc36eafdSMike Gerdts } 668*bc36eafdSMike Gerdts 669*bc36eafdSMike Gerdts Path = NextOp->Common.Value.String; 670*bc36eafdSMike Gerdts } 671*bc36eafdSMike Gerdts 672*bc36eafdSMike Gerdts if (!Path) 673*bc36eafdSMike Gerdts { 674*bc36eafdSMike Gerdts goto Exit; 675*bc36eafdSMike Gerdts } 676*bc36eafdSMike Gerdts 677*bc36eafdSMike Gerdts /* Insert the name into the namespace */ 678*bc36eafdSMike Gerdts 679*bc36eafdSMike Gerdts Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 680*bc36eafdSMike Gerdts ACPI_IMODE_LOAD_PASS2, ACPI_NS_DONT_OPEN_SCOPE, 681*bc36eafdSMike Gerdts WalkState, &Node); 682*bc36eafdSMike Gerdts 683*bc36eafdSMike Gerdts Op->Common.Node = Node; 684*bc36eafdSMike Gerdts 685*bc36eafdSMike Gerdts if (ACPI_SUCCESS (Status)) 686*bc36eafdSMike Gerdts { 687*bc36eafdSMike Gerdts /* Check if it's a predefined node */ 688*bc36eafdSMike Gerdts 689*bc36eafdSMike Gerdts while (AcpiGbl_PreDefinedNames[PreDefineIndex].Name) 690*bc36eafdSMike Gerdts { 691*bc36eafdSMike Gerdts if (ACPI_COMPARE_NAME (Node->Name.Ascii, 692*bc36eafdSMike Gerdts AcpiGbl_PreDefinedNames[PreDefineIndex].Name)) 693*bc36eafdSMike Gerdts { 694*bc36eafdSMike Gerdts PreDefined = TRUE; 695*bc36eafdSMike Gerdts break; 696*bc36eafdSMike Gerdts } 697*bc36eafdSMike Gerdts 698*bc36eafdSMike Gerdts PreDefineIndex++; 699*bc36eafdSMike Gerdts } 700*bc36eafdSMike Gerdts 701*bc36eafdSMike Gerdts /* 702*bc36eafdSMike Gerdts * Set node owner id if it satisfies all the following conditions: 703*bc36eafdSMike Gerdts * 1) Not a predefined node, _SB_ etc 704*bc36eafdSMike Gerdts * 2) Not the root node 705*bc36eafdSMike Gerdts * 3) Not a node created by Scope 706*bc36eafdSMike Gerdts */ 707*bc36eafdSMike Gerdts 708*bc36eafdSMike Gerdts if (!PreDefined && Node != AcpiGbl_RootNode && 709*bc36eafdSMike Gerdts Op->Common.AmlOpcode != AML_SCOPE_OP) 710*bc36eafdSMike Gerdts { 711*bc36eafdSMike Gerdts Node->OwnerId = WalkState->OwnerId; 712*bc36eafdSMike Gerdts } 713*bc36eafdSMike Gerdts } 714*bc36eafdSMike Gerdts 715*bc36eafdSMike Gerdts 716*bc36eafdSMike Gerdts Exit: 717*bc36eafdSMike Gerdts 718*bc36eafdSMike Gerdts if (AcpiNsOpensScope (ObjectType)) 719*bc36eafdSMike Gerdts { 720*bc36eafdSMike Gerdts if (Op->Common.Node) 721*bc36eafdSMike Gerdts { 722*bc36eafdSMike Gerdts Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, 723*bc36eafdSMike Gerdts WalkState); 724*bc36eafdSMike Gerdts if (ACPI_FAILURE (Status)) 725*bc36eafdSMike Gerdts { 726*bc36eafdSMike Gerdts return (Status); 727*bc36eafdSMike Gerdts } 728*bc36eafdSMike Gerdts } 729*bc36eafdSMike Gerdts } 730*bc36eafdSMike Gerdts 731*bc36eafdSMike Gerdts return (AE_OK); 732*bc36eafdSMike Gerdts } 733*bc36eafdSMike Gerdts 734*bc36eafdSMike Gerdts 735*bc36eafdSMike Gerdts /******************************************************************************* 736*bc36eafdSMike Gerdts * 737*bc36eafdSMike Gerdts * FUNCTION: AcpiDmXrefDescendingOp 738*bc36eafdSMike Gerdts * 739*bc36eafdSMike Gerdts * PARAMETERS: ASL_WALK_CALLBACK 740*bc36eafdSMike Gerdts * 741*bc36eafdSMike Gerdts * RETURN: Status 742*bc36eafdSMike Gerdts * 743*bc36eafdSMike Gerdts * DESCRIPTION: Descending handler for namespace cross reference 744*bc36eafdSMike Gerdts * 745*bc36eafdSMike Gerdts ******************************************************************************/ 746*bc36eafdSMike Gerdts 747*bc36eafdSMike Gerdts static ACPI_STATUS 748*bc36eafdSMike Gerdts AcpiDmXrefDescendingOp ( 749*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op, 750*bc36eafdSMike Gerdts UINT32 Level, 751*bc36eafdSMike Gerdts void *Context) 752*bc36eafdSMike Gerdts { 753*bc36eafdSMike Gerdts ACPI_OP_WALK_INFO *Info = Context; 754*bc36eafdSMike Gerdts const ACPI_OPCODE_INFO *OpInfo; 755*bc36eafdSMike Gerdts ACPI_WALK_STATE *WalkState; 756*bc36eafdSMike Gerdts ACPI_OBJECT_TYPE ObjectType; 757*bc36eafdSMike Gerdts ACPI_OBJECT_TYPE ObjectType2; 758*bc36eafdSMike Gerdts ACPI_STATUS Status; 759*bc36eafdSMike Gerdts char *Path = NULL; 760*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *NextOp; 761*bc36eafdSMike Gerdts ACPI_NAMESPACE_NODE *Node; 762*bc36eafdSMike Gerdts ACPI_OPERAND_OBJECT *Object; 763*bc36eafdSMike Gerdts UINT32 ParamCount = 0; 764*bc36eafdSMike Gerdts char *Pathname; 765*bc36eafdSMike Gerdts UINT16 Flags = 0; 766*bc36eafdSMike Gerdts 767*bc36eafdSMike Gerdts 768*bc36eafdSMike Gerdts WalkState = Info->WalkState; 769*bc36eafdSMike Gerdts OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 770*bc36eafdSMike Gerdts ObjectType = OpInfo->ObjectType; 771*bc36eafdSMike Gerdts ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 772*bc36eafdSMike Gerdts 773*bc36eafdSMike Gerdts if ((!(OpInfo->Flags & AML_NAMED)) && 774*bc36eafdSMike Gerdts (!(OpInfo->Flags & AML_CREATE)) && 775*bc36eafdSMike Gerdts (Op->Common.AmlOpcode != AML_INT_NAMEPATH_OP) && 776*bc36eafdSMike Gerdts (Op->Common.AmlOpcode != AML_NOTIFY_OP)) 777*bc36eafdSMike Gerdts { 778*bc36eafdSMike Gerdts goto Exit; 779*bc36eafdSMike Gerdts } 780*bc36eafdSMike Gerdts else if (Op->Common.Parent && 781*bc36eafdSMike Gerdts Op->Common.Parent->Common.AmlOpcode == AML_EXTERNAL_OP) 782*bc36eafdSMike Gerdts { 783*bc36eafdSMike Gerdts /* External() NamePath */ 784*bc36eafdSMike Gerdts 785*bc36eafdSMike Gerdts Path = Op->Common.Value.String; 786*bc36eafdSMike Gerdts ObjectType = (ACPI_OBJECT_TYPE) Op->Common.Next->Common.Value.Integer; 787*bc36eafdSMike Gerdts if (ObjectType == ACPI_TYPE_METHOD) 788*bc36eafdSMike Gerdts { 789*bc36eafdSMike Gerdts ParamCount = (UINT32) 790*bc36eafdSMike Gerdts Op->Common.Next->Common.Next->Common.Value.Integer; 791*bc36eafdSMike Gerdts } 792*bc36eafdSMike Gerdts 793*bc36eafdSMike Gerdts Flags |= ACPI_EXT_RESOLVED_REFERENCE | ACPI_EXT_ORIGIN_FROM_OPCODE; 794*bc36eafdSMike Gerdts AcpiDmAddOpToExternalList (Op, Path, 795*bc36eafdSMike Gerdts (UINT8) ObjectType, ParamCount, Flags); 796*bc36eafdSMike Gerdts 797*bc36eafdSMike Gerdts goto Exit; 798*bc36eafdSMike Gerdts } 799*bc36eafdSMike Gerdts 800*bc36eafdSMike Gerdts /* Get the NamePath from the appropriate place */ 801*bc36eafdSMike Gerdts 802*bc36eafdSMike Gerdts if (OpInfo->Flags & AML_NAMED) 803*bc36eafdSMike Gerdts { 804*bc36eafdSMike Gerdts /* 805*bc36eafdSMike Gerdts * Only these two operators (Alias, Scope) refer to an existing 806*bc36eafdSMike Gerdts * name, it is the first argument 807*bc36eafdSMike Gerdts */ 808*bc36eafdSMike Gerdts if (Op->Common.AmlOpcode == AML_ALIAS_OP) 809*bc36eafdSMike Gerdts { 810*bc36eafdSMike Gerdts ObjectType = ACPI_TYPE_ANY; 811*bc36eafdSMike Gerdts 812*bc36eafdSMike Gerdts NextOp = Op->Common.Value.Arg; 813*bc36eafdSMike Gerdts NextOp = NextOp->Common.Value.Arg; 814*bc36eafdSMike Gerdts if (NextOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) 815*bc36eafdSMike Gerdts { 816*bc36eafdSMike Gerdts Path = NextOp->Common.Value.String; 817*bc36eafdSMike Gerdts } 818*bc36eafdSMike Gerdts } 819*bc36eafdSMike Gerdts else if (Op->Common.AmlOpcode == AML_SCOPE_OP) 820*bc36eafdSMike Gerdts { 821*bc36eafdSMike Gerdts Path = (char *) Op->Named.Path; 822*bc36eafdSMike Gerdts } 823*bc36eafdSMike Gerdts } 824*bc36eafdSMike Gerdts else if (OpInfo->Flags & AML_CREATE) 825*bc36eafdSMike Gerdts { 826*bc36eafdSMike Gerdts /* Referenced Buffer Name is the first child */ 827*bc36eafdSMike Gerdts 828*bc36eafdSMike Gerdts ObjectType = ACPI_TYPE_BUFFER; /* Change from TYPE_BUFFER_FIELD */ 829*bc36eafdSMike Gerdts 830*bc36eafdSMike Gerdts NextOp = Op->Common.Value.Arg; 831*bc36eafdSMike Gerdts if (NextOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) 832*bc36eafdSMike Gerdts { 833*bc36eafdSMike Gerdts Path = NextOp->Common.Value.String; 834*bc36eafdSMike Gerdts } 835*bc36eafdSMike Gerdts } 836*bc36eafdSMike Gerdts else if (Op->Common.AmlOpcode == AML_NOTIFY_OP) 837*bc36eafdSMike Gerdts { 838*bc36eafdSMike Gerdts Path = Op->Common.Value.Arg->Asl.Value.String; 839*bc36eafdSMike Gerdts } 840*bc36eafdSMike Gerdts else 841*bc36eafdSMike Gerdts { 842*bc36eafdSMike Gerdts Path = Op->Common.Value.String; 843*bc36eafdSMike Gerdts } 844*bc36eafdSMike Gerdts 845*bc36eafdSMike Gerdts if (!Path) 846*bc36eafdSMike Gerdts { 847*bc36eafdSMike Gerdts goto Exit; 848*bc36eafdSMike Gerdts } 849*bc36eafdSMike Gerdts 850*bc36eafdSMike Gerdts /* 851*bc36eafdSMike Gerdts * Lookup the name in the namespace. Name must exist at this point, or it 852*bc36eafdSMike Gerdts * is an invalid reference. 853*bc36eafdSMike Gerdts * 854*bc36eafdSMike Gerdts * The namespace is also used as a lookup table for references to resource 855*bc36eafdSMike Gerdts * descriptors and the fields within them. 856*bc36eafdSMike Gerdts */ 857*bc36eafdSMike Gerdts Node = NULL; 858*bc36eafdSMike Gerdts Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, 859*bc36eafdSMike Gerdts ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 860*bc36eafdSMike Gerdts WalkState, &Node); 861*bc36eafdSMike Gerdts 862*bc36eafdSMike Gerdts if (ACPI_SUCCESS (Status) && (Node->Flags & ANOBJ_IS_EXTERNAL)) 863*bc36eafdSMike Gerdts { 864*bc36eafdSMike Gerdts /* Node was created by an External() statement */ 865*bc36eafdSMike Gerdts 866*bc36eafdSMike Gerdts Status = AE_NOT_FOUND; 867*bc36eafdSMike Gerdts } 868*bc36eafdSMike Gerdts 869*bc36eafdSMike Gerdts if (ACPI_FAILURE (Status)) 870*bc36eafdSMike Gerdts { 871*bc36eafdSMike Gerdts if (Status == AE_NOT_FOUND) 872*bc36eafdSMike Gerdts { 873*bc36eafdSMike Gerdts /* 874*bc36eafdSMike Gerdts * Add this symbol as an external declaration, except if the 875*bc36eafdSMike Gerdts * parent is a CondRefOf operator. For this operator, we do not 876*bc36eafdSMike Gerdts * need an external, nor do we want one, since this can cause 877*bc36eafdSMike Gerdts * disassembly problems if the symbol is actually a control 878*bc36eafdSMike Gerdts * method. 879*bc36eafdSMike Gerdts */ 880*bc36eafdSMike Gerdts if (!(Op->Asl.Parent && 881*bc36eafdSMike Gerdts (Op->Asl.Parent->Asl.AmlOpcode == AML_COND_REF_OF_OP))) 882*bc36eafdSMike Gerdts { 883*bc36eafdSMike Gerdts if (Node) 884*bc36eafdSMike Gerdts { 885*bc36eafdSMike Gerdts AcpiDmAddNodeToExternalList (Node, 886*bc36eafdSMike Gerdts (UINT8) ObjectType, 7, Flags); 887*bc36eafdSMike Gerdts } 888*bc36eafdSMike Gerdts else 889*bc36eafdSMike Gerdts { 890*bc36eafdSMike Gerdts AcpiDmAddOpToExternalList (Op, Path, 891*bc36eafdSMike Gerdts (UINT8) ObjectType, 7, Flags); 892*bc36eafdSMike Gerdts } 893*bc36eafdSMike Gerdts } 894*bc36eafdSMike Gerdts } 895*bc36eafdSMike Gerdts } 896*bc36eafdSMike Gerdts 897*bc36eafdSMike Gerdts /* 898*bc36eafdSMike Gerdts * Found the node, but check if it came from an external table. 899*bc36eafdSMike Gerdts * Add it to external list. Note: Node->OwnerId == 0 indicates 900*bc36eafdSMike Gerdts * one of the built-in ACPI Names (_OS_ etc.) which can safely 901*bc36eafdSMike Gerdts * be ignored. 902*bc36eafdSMike Gerdts */ 903*bc36eafdSMike Gerdts else if (Node->OwnerId && 904*bc36eafdSMike Gerdts (WalkState->OwnerId != Node->OwnerId)) 905*bc36eafdSMike Gerdts { 906*bc36eafdSMike Gerdts ObjectType2 = ObjectType; 907*bc36eafdSMike Gerdts 908*bc36eafdSMike Gerdts Object = AcpiNsGetAttachedObject (Node); 909*bc36eafdSMike Gerdts if (Object) 910*bc36eafdSMike Gerdts { 911*bc36eafdSMike Gerdts ObjectType2 = Object->Common.Type; 912*bc36eafdSMike Gerdts if (ObjectType2 == ACPI_TYPE_METHOD) 913*bc36eafdSMike Gerdts { 914*bc36eafdSMike Gerdts ParamCount = Object->Method.ParamCount; 915*bc36eafdSMike Gerdts } 916*bc36eafdSMike Gerdts } 917*bc36eafdSMike Gerdts 918*bc36eafdSMike Gerdts Pathname = AcpiNsGetExternalPathname (Node); 919*bc36eafdSMike Gerdts if (!Pathname) 920*bc36eafdSMike Gerdts { 921*bc36eafdSMike Gerdts return (AE_NO_MEMORY); 922*bc36eafdSMike Gerdts } 923*bc36eafdSMike Gerdts 924*bc36eafdSMike Gerdts AcpiDmAddNodeToExternalList (Node, (UINT8) ObjectType2, 925*bc36eafdSMike Gerdts ParamCount, ACPI_EXT_RESOLVED_REFERENCE); 926*bc36eafdSMike Gerdts 927*bc36eafdSMike Gerdts ACPI_FREE (Pathname); 928*bc36eafdSMike Gerdts Op->Common.Node = Node; 929*bc36eafdSMike Gerdts } 930*bc36eafdSMike Gerdts else 931*bc36eafdSMike Gerdts { 932*bc36eafdSMike Gerdts Op->Common.Node = Node; 933*bc36eafdSMike Gerdts } 934*bc36eafdSMike Gerdts 935*bc36eafdSMike Gerdts 936*bc36eafdSMike Gerdts Exit: 937*bc36eafdSMike Gerdts /* Open new scope if necessary */ 938*bc36eafdSMike Gerdts 939*bc36eafdSMike Gerdts if (AcpiNsOpensScope (ObjectType)) 940*bc36eafdSMike Gerdts { 941*bc36eafdSMike Gerdts if (Op->Common.Node) 942*bc36eafdSMike Gerdts { 943*bc36eafdSMike Gerdts Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, 944*bc36eafdSMike Gerdts WalkState); 945*bc36eafdSMike Gerdts if (ACPI_FAILURE (Status)) 946*bc36eafdSMike Gerdts { 947*bc36eafdSMike Gerdts return (Status); 948*bc36eafdSMike Gerdts } 949*bc36eafdSMike Gerdts } 950*bc36eafdSMike Gerdts } 951*bc36eafdSMike Gerdts 952*bc36eafdSMike Gerdts return (AE_OK); 953*bc36eafdSMike Gerdts } 954*bc36eafdSMike Gerdts 955*bc36eafdSMike Gerdts 956*bc36eafdSMike Gerdts /******************************************************************************* 957*bc36eafdSMike Gerdts * 958*bc36eafdSMike Gerdts * FUNCTION: AcpiDmResourceDescendingOp 959*bc36eafdSMike Gerdts * 960*bc36eafdSMike Gerdts * PARAMETERS: ASL_WALK_CALLBACK 961*bc36eafdSMike Gerdts * 962*bc36eafdSMike Gerdts * RETURN: None 963*bc36eafdSMike Gerdts * 964*bc36eafdSMike Gerdts * DESCRIPTION: Process one parse op during symbolic resource index conversion. 965*bc36eafdSMike Gerdts * 966*bc36eafdSMike Gerdts ******************************************************************************/ 967*bc36eafdSMike Gerdts 968*bc36eafdSMike Gerdts static ACPI_STATUS 969*bc36eafdSMike Gerdts AcpiDmResourceDescendingOp ( 970*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op, 971*bc36eafdSMike Gerdts UINT32 Level, 972*bc36eafdSMike Gerdts void *Context) 973*bc36eafdSMike Gerdts { 974*bc36eafdSMike Gerdts ACPI_OP_WALK_INFO *Info = Context; 975*bc36eafdSMike Gerdts const ACPI_OPCODE_INFO *OpInfo; 976*bc36eafdSMike Gerdts ACPI_WALK_STATE *WalkState; 977*bc36eafdSMike Gerdts ACPI_OBJECT_TYPE ObjectType; 978*bc36eafdSMike Gerdts ACPI_STATUS Status; 979*bc36eafdSMike Gerdts 980*bc36eafdSMike Gerdts 981*bc36eafdSMike Gerdts WalkState = Info->WalkState; 982*bc36eafdSMike Gerdts OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 983*bc36eafdSMike Gerdts 984*bc36eafdSMike Gerdts /* Open new scope if necessary */ 985*bc36eafdSMike Gerdts 986*bc36eafdSMike Gerdts ObjectType = OpInfo->ObjectType; 987*bc36eafdSMike Gerdts if (AcpiNsOpensScope (ObjectType)) 988*bc36eafdSMike Gerdts { 989*bc36eafdSMike Gerdts if (Op->Common.Node) 990*bc36eafdSMike Gerdts { 991*bc36eafdSMike Gerdts 992*bc36eafdSMike Gerdts Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, 993*bc36eafdSMike Gerdts WalkState); 994*bc36eafdSMike Gerdts if (ACPI_FAILURE (Status)) 995*bc36eafdSMike Gerdts { 996*bc36eafdSMike Gerdts return (Status); 997*bc36eafdSMike Gerdts } 998*bc36eafdSMike Gerdts } 999*bc36eafdSMike Gerdts } 1000*bc36eafdSMike Gerdts 1001*bc36eafdSMike Gerdts /* 1002*bc36eafdSMike Gerdts * Check if this operator contains a reference to a resource descriptor. 1003*bc36eafdSMike Gerdts * If so, convert the reference into a symbolic reference. 1004*bc36eafdSMike Gerdts */ 1005*bc36eafdSMike Gerdts AcpiDmCheckResourceReference (Op, WalkState); 1006*bc36eafdSMike Gerdts return (AE_OK); 1007*bc36eafdSMike Gerdts } 1008*bc36eafdSMike Gerdts 1009*bc36eafdSMike Gerdts 1010*bc36eafdSMike Gerdts /******************************************************************************* 1011*bc36eafdSMike Gerdts * 1012*bc36eafdSMike Gerdts * FUNCTION: AcpiDmCommonAscendingOp 1013*bc36eafdSMike Gerdts * 1014*bc36eafdSMike Gerdts * PARAMETERS: ASL_WALK_CALLBACK 1015*bc36eafdSMike Gerdts * 1016*bc36eafdSMike Gerdts * RETURN: None 1017*bc36eafdSMike Gerdts * 1018*bc36eafdSMike Gerdts * DESCRIPTION: Ascending handler for combined parse/namespace walks. Closes 1019*bc36eafdSMike Gerdts * scope if necessary. 1020*bc36eafdSMike Gerdts * 1021*bc36eafdSMike Gerdts ******************************************************************************/ 1022*bc36eafdSMike Gerdts 1023*bc36eafdSMike Gerdts static ACPI_STATUS 1024*bc36eafdSMike Gerdts AcpiDmCommonAscendingOp ( 1025*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op, 1026*bc36eafdSMike Gerdts UINT32 Level, 1027*bc36eafdSMike Gerdts void *Context) 1028*bc36eafdSMike Gerdts { 1029*bc36eafdSMike Gerdts ACPI_OP_WALK_INFO *Info = Context; 1030*bc36eafdSMike Gerdts const ACPI_OPCODE_INFO *OpInfo; 1031*bc36eafdSMike Gerdts ACPI_OBJECT_TYPE ObjectType; 1032*bc36eafdSMike Gerdts 1033*bc36eafdSMike Gerdts 1034*bc36eafdSMike Gerdts /* Close scope if necessary */ 1035*bc36eafdSMike Gerdts 1036*bc36eafdSMike Gerdts OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 1037*bc36eafdSMike Gerdts ObjectType = OpInfo->ObjectType; 1038*bc36eafdSMike Gerdts ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 1039*bc36eafdSMike Gerdts 1040*bc36eafdSMike Gerdts if (AcpiNsOpensScope (ObjectType)) 1041*bc36eafdSMike Gerdts { 1042*bc36eafdSMike Gerdts (void) AcpiDsScopeStackPop (Info->WalkState); 1043*bc36eafdSMike Gerdts } 1044*bc36eafdSMike Gerdts 1045*bc36eafdSMike Gerdts return (AE_OK); 1046*bc36eafdSMike Gerdts } 1047*bc36eafdSMike Gerdts 1048*bc36eafdSMike Gerdts 1049*bc36eafdSMike Gerdts /******************************************************************************* 1050*bc36eafdSMike Gerdts * 1051*bc36eafdSMike Gerdts * FUNCTION: AcpiDmInspectPossibleArgs 1052*bc36eafdSMike Gerdts * 1053*bc36eafdSMike Gerdts * PARAMETERS: CurrentOpArgCount - Which arg of the current op was the 1054*bc36eafdSMike Gerdts * possible method invocation found 1055*bc36eafdSMike Gerdts * TargetCount - Number of targets (0,1,2) for this op 1056*bc36eafdSMike Gerdts * Op - Parse op 1057*bc36eafdSMike Gerdts * 1058*bc36eafdSMike Gerdts * RETURN: Status 1059*bc36eafdSMike Gerdts * 1060*bc36eafdSMike Gerdts * DESCRIPTION: Examine following args and next ops for possible arguments 1061*bc36eafdSMike Gerdts * for an unrecognized method invocation. 1062*bc36eafdSMike Gerdts * 1063*bc36eafdSMike Gerdts ******************************************************************************/ 1064*bc36eafdSMike Gerdts 1065*bc36eafdSMike Gerdts static UINT32 1066*bc36eafdSMike Gerdts AcpiDmInspectPossibleArgs ( 1067*bc36eafdSMike Gerdts UINT32 CurrentOpArgCount, 1068*bc36eafdSMike Gerdts UINT32 TargetCount, 1069*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op) 1070*bc36eafdSMike Gerdts { 1071*bc36eafdSMike Gerdts const ACPI_OPCODE_INFO *OpInfo; 1072*bc36eafdSMike Gerdts UINT32 i; 1073*bc36eafdSMike Gerdts UINT32 ArgumentCount = 0; 1074*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *NextOp; 1075*bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *ExecuteOp; 1076*bc36eafdSMike Gerdts 1077*bc36eafdSMike Gerdts 1078*bc36eafdSMike Gerdts if (!Op) 1079*bc36eafdSMike Gerdts { 1080*bc36eafdSMike Gerdts return (0); 1081*bc36eafdSMike Gerdts } 1082*bc36eafdSMike Gerdts 1083*bc36eafdSMike Gerdts /* Lookahead for the maximum number of possible arguments */ 1084*bc36eafdSMike Gerdts 1085*bc36eafdSMike Gerdts NextOp = Op->Common.Next; 1086*bc36eafdSMike Gerdts 1087*bc36eafdSMike Gerdts for (i = 0; (i < ACPI_METHOD_NUM_ARGS) && NextOp; i++) 1088*bc36eafdSMike Gerdts { 1089*bc36eafdSMike Gerdts OpInfo = AcpiPsGetOpcodeInfo (NextOp->Common.AmlOpcode); 1090*bc36eafdSMike Gerdts 1091*bc36eafdSMike Gerdts /* Any one of these operators is "very probably" not a method arg */ 1092*bc36eafdSMike Gerdts 1093*bc36eafdSMike Gerdts if ((NextOp->Common.AmlOpcode == AML_STORE_OP) || 1094*bc36eafdSMike Gerdts (NextOp->Common.AmlOpcode == AML_NOTIFY_OP) || 1095*bc36eafdSMike Gerdts (OpInfo->Class == AML_CLASS_CONTROL) || 1096*bc36eafdSMike Gerdts (OpInfo->Class == AML_CLASS_CREATE) || 1097*bc36eafdSMike Gerdts (OpInfo->Class == AML_CLASS_NAMED_OBJECT)) 1098*bc36eafdSMike Gerdts { 1099*bc36eafdSMike Gerdts break; 1100*bc36eafdSMike Gerdts } 1101*bc36eafdSMike Gerdts 1102*bc36eafdSMike Gerdts if (OpInfo->Class == AML_CLASS_EXECUTE) 1103*bc36eafdSMike Gerdts { 1104*bc36eafdSMike Gerdts /* Probable that this is method arg if there is no target */ 1105*bc36eafdSMike Gerdts 1106*bc36eafdSMike Gerdts ExecuteOp = NextOp->Common.Value.Arg; 1107*bc36eafdSMike Gerdts while (ExecuteOp) 1108*bc36eafdSMike Gerdts { 1109*bc36eafdSMike Gerdts if ((ExecuteOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && 1110*bc36eafdSMike Gerdts (ExecuteOp->Common.Value.Arg == NULL)) 1111*bc36eafdSMike Gerdts { 1112*bc36eafdSMike Gerdts /* No target, could be a method arg */ 1113*bc36eafdSMike Gerdts 1114*bc36eafdSMike Gerdts break; 1115*bc36eafdSMike Gerdts } 1116*bc36eafdSMike Gerdts 1117*bc36eafdSMike Gerdts if (NextOp->Common.AmlOpcode == AML_REF_OF_OP) 1118*bc36eafdSMike Gerdts { 1119*bc36eafdSMike Gerdts break; 1120*bc36eafdSMike Gerdts } 1121*bc36eafdSMike Gerdts 1122*bc36eafdSMike Gerdts ExecuteOp = ExecuteOp->Common.Next; 1123*bc36eafdSMike Gerdts } 1124*bc36eafdSMike Gerdts 1125*bc36eafdSMike Gerdts if (!ExecuteOp) 1126*bc36eafdSMike Gerdts { 1127*bc36eafdSMike Gerdts /* Has a target, not method arg */ 1128*bc36eafdSMike Gerdts 1129*bc36eafdSMike Gerdts return (ArgumentCount); 1130*bc36eafdSMike Gerdts } 1131*bc36eafdSMike Gerdts } 1132*bc36eafdSMike Gerdts 1133*bc36eafdSMike Gerdts ArgumentCount++; 1134*bc36eafdSMike Gerdts NextOp = NextOp->Common.Next; 1135*bc36eafdSMike Gerdts } 1136*bc36eafdSMike Gerdts 1137*bc36eafdSMike Gerdts return (ArgumentCount); 1138*bc36eafdSMike Gerdts } 1139