1*433d6423SLionel Sambuc 2*433d6423SLionel Sambuc /****************************************************************************** 3*433d6423SLionel Sambuc * 4*433d6423SLionel Sambuc * Module Name: exresolv - AML Interpreter object resolution 5*433d6423SLionel Sambuc * 6*433d6423SLionel Sambuc *****************************************************************************/ 7*433d6423SLionel Sambuc 8*433d6423SLionel Sambuc /****************************************************************************** 9*433d6423SLionel Sambuc * 10*433d6423SLionel Sambuc * 1. Copyright Notice 11*433d6423SLionel Sambuc * 12*433d6423SLionel Sambuc * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. 13*433d6423SLionel Sambuc * All rights reserved. 14*433d6423SLionel Sambuc * 15*433d6423SLionel Sambuc * 2. License 16*433d6423SLionel Sambuc * 17*433d6423SLionel Sambuc * 2.1. This is your license from Intel Corp. under its intellectual property 18*433d6423SLionel Sambuc * rights. You may have additional license terms from the party that provided 19*433d6423SLionel Sambuc * you this software, covering your right to use that party's intellectual 20*433d6423SLionel Sambuc * property rights. 21*433d6423SLionel Sambuc * 22*433d6423SLionel Sambuc * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23*433d6423SLionel Sambuc * copy of the source code appearing in this file ("Covered Code") an 24*433d6423SLionel Sambuc * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25*433d6423SLionel Sambuc * base code distributed originally by Intel ("Original Intel Code") to copy, 26*433d6423SLionel Sambuc * make derivatives, distribute, use and display any portion of the Covered 27*433d6423SLionel Sambuc * Code in any form, with the right to sublicense such rights; and 28*433d6423SLionel Sambuc * 29*433d6423SLionel Sambuc * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30*433d6423SLionel Sambuc * license (with the right to sublicense), under only those claims of Intel 31*433d6423SLionel Sambuc * patents that are infringed by the Original Intel Code, to make, use, sell, 32*433d6423SLionel Sambuc * offer to sell, and import the Covered Code and derivative works thereof 33*433d6423SLionel Sambuc * solely to the minimum extent necessary to exercise the above copyright 34*433d6423SLionel Sambuc * license, and in no event shall the patent license extend to any additions 35*433d6423SLionel Sambuc * to or modifications of the Original Intel Code. No other license or right 36*433d6423SLionel Sambuc * is granted directly or by implication, estoppel or otherwise; 37*433d6423SLionel Sambuc * 38*433d6423SLionel Sambuc * The above copyright and patent license is granted only if the following 39*433d6423SLionel Sambuc * conditions are met: 40*433d6423SLionel Sambuc * 41*433d6423SLionel Sambuc * 3. Conditions 42*433d6423SLionel Sambuc * 43*433d6423SLionel Sambuc * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44*433d6423SLionel Sambuc * Redistribution of source code of any substantial portion of the Covered 45*433d6423SLionel Sambuc * Code or modification with rights to further distribute source must include 46*433d6423SLionel Sambuc * the above Copyright Notice, the above License, this list of Conditions, 47*433d6423SLionel Sambuc * and the following Disclaimer and Export Compliance provision. In addition, 48*433d6423SLionel Sambuc * Licensee must cause all Covered Code to which Licensee contributes to 49*433d6423SLionel Sambuc * contain a file documenting the changes Licensee made to create that Covered 50*433d6423SLionel Sambuc * Code and the date of any change. Licensee must include in that file the 51*433d6423SLionel Sambuc * documentation of any changes made by any predecessor Licensee. Licensee 52*433d6423SLionel Sambuc * must include a prominent statement that the modification is derived, 53*433d6423SLionel Sambuc * directly or indirectly, from Original Intel Code. 54*433d6423SLionel Sambuc * 55*433d6423SLionel Sambuc * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56*433d6423SLionel Sambuc * Redistribution of source code of any substantial portion of the Covered 57*433d6423SLionel Sambuc * Code or modification without rights to further distribute source must 58*433d6423SLionel Sambuc * include the following Disclaimer and Export Compliance provision in the 59*433d6423SLionel Sambuc * documentation and/or other materials provided with distribution. In 60*433d6423SLionel Sambuc * addition, Licensee may not authorize further sublicense of source of any 61*433d6423SLionel Sambuc * portion of the Covered Code, and must include terms to the effect that the 62*433d6423SLionel Sambuc * license from Licensee to its licensee is limited to the intellectual 63*433d6423SLionel Sambuc * property embodied in the software Licensee provides to its licensee, and 64*433d6423SLionel Sambuc * not to intellectual property embodied in modifications its licensee may 65*433d6423SLionel Sambuc * make. 66*433d6423SLionel Sambuc * 67*433d6423SLionel Sambuc * 3.3. Redistribution of Executable. Redistribution in executable form of any 68*433d6423SLionel Sambuc * substantial portion of the Covered Code or modification must reproduce the 69*433d6423SLionel Sambuc * above Copyright Notice, and the following Disclaimer and Export Compliance 70*433d6423SLionel Sambuc * provision in the documentation and/or other materials provided with the 71*433d6423SLionel Sambuc * distribution. 72*433d6423SLionel Sambuc * 73*433d6423SLionel Sambuc * 3.4. Intel retains all right, title, and interest in and to the Original 74*433d6423SLionel Sambuc * Intel Code. 75*433d6423SLionel Sambuc * 76*433d6423SLionel Sambuc * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77*433d6423SLionel Sambuc * Intel shall be used in advertising or otherwise to promote the sale, use or 78*433d6423SLionel Sambuc * other dealings in products derived from or relating to the Covered Code 79*433d6423SLionel Sambuc * without prior written authorization from Intel. 80*433d6423SLionel Sambuc * 81*433d6423SLionel Sambuc * 4. Disclaimer and Export Compliance 82*433d6423SLionel Sambuc * 83*433d6423SLionel Sambuc * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84*433d6423SLionel Sambuc * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85*433d6423SLionel Sambuc * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86*433d6423SLionel Sambuc * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87*433d6423SLionel Sambuc * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88*433d6423SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89*433d6423SLionel Sambuc * PARTICULAR PURPOSE. 90*433d6423SLionel Sambuc * 91*433d6423SLionel Sambuc * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92*433d6423SLionel Sambuc * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93*433d6423SLionel Sambuc * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94*433d6423SLionel Sambuc * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95*433d6423SLionel Sambuc * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96*433d6423SLionel Sambuc * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97*433d6423SLionel Sambuc * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98*433d6423SLionel Sambuc * LIMITED REMEDY. 99*433d6423SLionel Sambuc * 100*433d6423SLionel Sambuc * 4.3. Licensee shall not export, either directly or indirectly, any of this 101*433d6423SLionel Sambuc * software or system incorporating such software without first obtaining any 102*433d6423SLionel Sambuc * required license or other approval from the U. S. Department of Commerce or 103*433d6423SLionel Sambuc * any other agency or department of the United States Government. In the 104*433d6423SLionel Sambuc * event Licensee exports any such software from the United States or 105*433d6423SLionel Sambuc * re-exports any such software from a foreign destination, Licensee shall 106*433d6423SLionel Sambuc * ensure that the distribution and export/re-export of the software is in 107*433d6423SLionel Sambuc * compliance with all laws, regulations, orders, or other restrictions of the 108*433d6423SLionel Sambuc * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109*433d6423SLionel Sambuc * any of its subsidiaries will export/re-export any technical data, process, 110*433d6423SLionel Sambuc * software, or service, directly or indirectly, to any country for which the 111*433d6423SLionel Sambuc * United States government or any agency thereof requires an export license, 112*433d6423SLionel Sambuc * other governmental approval, or letter of assurance, without first obtaining 113*433d6423SLionel Sambuc * such license, approval or letter. 114*433d6423SLionel Sambuc * 115*433d6423SLionel Sambuc *****************************************************************************/ 116*433d6423SLionel Sambuc 117*433d6423SLionel Sambuc #define __EXRESOLV_C__ 118*433d6423SLionel Sambuc 119*433d6423SLionel Sambuc #include "acpi.h" 120*433d6423SLionel Sambuc #include "accommon.h" 121*433d6423SLionel Sambuc #include "amlcode.h" 122*433d6423SLionel Sambuc #include "acdispat.h" 123*433d6423SLionel Sambuc #include "acinterp.h" 124*433d6423SLionel Sambuc #include "acnamesp.h" 125*433d6423SLionel Sambuc 126*433d6423SLionel Sambuc 127*433d6423SLionel Sambuc #define _COMPONENT ACPI_EXECUTER 128*433d6423SLionel Sambuc ACPI_MODULE_NAME ("exresolv") 129*433d6423SLionel Sambuc 130*433d6423SLionel Sambuc /* Local prototypes */ 131*433d6423SLionel Sambuc 132*433d6423SLionel Sambuc static ACPI_STATUS 133*433d6423SLionel Sambuc AcpiExResolveObjectToValue ( 134*433d6423SLionel Sambuc ACPI_OPERAND_OBJECT **StackPtr, 135*433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState); 136*433d6423SLionel Sambuc 137*433d6423SLionel Sambuc 138*433d6423SLionel Sambuc /******************************************************************************* 139*433d6423SLionel Sambuc * 140*433d6423SLionel Sambuc * FUNCTION: AcpiExResolveToValue 141*433d6423SLionel Sambuc * 142*433d6423SLionel Sambuc * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can 143*433d6423SLionel Sambuc * be either an (ACPI_OPERAND_OBJECT *) 144*433d6423SLionel Sambuc * or an ACPI_HANDLE. 145*433d6423SLionel Sambuc * WalkState - Current method state 146*433d6423SLionel Sambuc * 147*433d6423SLionel Sambuc * RETURN: Status 148*433d6423SLionel Sambuc * 149*433d6423SLionel Sambuc * DESCRIPTION: Convert Reference objects to values 150*433d6423SLionel Sambuc * 151*433d6423SLionel Sambuc ******************************************************************************/ 152*433d6423SLionel Sambuc 153*433d6423SLionel Sambuc ACPI_STATUS 154*433d6423SLionel Sambuc AcpiExResolveToValue ( 155*433d6423SLionel Sambuc ACPI_OPERAND_OBJECT **StackPtr, 156*433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState) 157*433d6423SLionel Sambuc { 158*433d6423SLionel Sambuc ACPI_STATUS Status; 159*433d6423SLionel Sambuc 160*433d6423SLionel Sambuc 161*433d6423SLionel Sambuc ACPI_FUNCTION_TRACE_PTR (ExResolveToValue, StackPtr); 162*433d6423SLionel Sambuc 163*433d6423SLionel Sambuc 164*433d6423SLionel Sambuc if (!StackPtr || !*StackPtr) 165*433d6423SLionel Sambuc { 166*433d6423SLionel Sambuc ACPI_ERROR ((AE_INFO, "Internal - null pointer")); 167*433d6423SLionel Sambuc return_ACPI_STATUS (AE_AML_NO_OPERAND); 168*433d6423SLionel Sambuc } 169*433d6423SLionel Sambuc 170*433d6423SLionel Sambuc /* 171*433d6423SLionel Sambuc * The entity pointed to by the StackPtr can be either 172*433d6423SLionel Sambuc * 1) A valid ACPI_OPERAND_OBJECT, or 173*433d6423SLionel Sambuc * 2) A ACPI_NAMESPACE_NODE (NamedObj) 174*433d6423SLionel Sambuc */ 175*433d6423SLionel Sambuc if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_OPERAND) 176*433d6423SLionel Sambuc { 177*433d6423SLionel Sambuc Status = AcpiExResolveObjectToValue (StackPtr, WalkState); 178*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 179*433d6423SLionel Sambuc { 180*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 181*433d6423SLionel Sambuc } 182*433d6423SLionel Sambuc 183*433d6423SLionel Sambuc if (!*StackPtr) 184*433d6423SLionel Sambuc { 185*433d6423SLionel Sambuc ACPI_ERROR ((AE_INFO, "Internal - null pointer")); 186*433d6423SLionel Sambuc return_ACPI_STATUS (AE_AML_NO_OPERAND); 187*433d6423SLionel Sambuc } 188*433d6423SLionel Sambuc } 189*433d6423SLionel Sambuc 190*433d6423SLionel Sambuc /* 191*433d6423SLionel Sambuc * Object on the stack may have changed if AcpiExResolveObjectToValue() 192*433d6423SLionel Sambuc * was called (i.e., we can't use an _else_ here.) 193*433d6423SLionel Sambuc */ 194*433d6423SLionel Sambuc if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED) 195*433d6423SLionel Sambuc { 196*433d6423SLionel Sambuc Status = AcpiExResolveNodeToValue ( 197*433d6423SLionel Sambuc ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr), 198*433d6423SLionel Sambuc WalkState); 199*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 200*433d6423SLionel Sambuc { 201*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 202*433d6423SLionel Sambuc } 203*433d6423SLionel Sambuc } 204*433d6423SLionel Sambuc 205*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr)); 206*433d6423SLionel Sambuc return_ACPI_STATUS (AE_OK); 207*433d6423SLionel Sambuc } 208*433d6423SLionel Sambuc 209*433d6423SLionel Sambuc 210*433d6423SLionel Sambuc /******************************************************************************* 211*433d6423SLionel Sambuc * 212*433d6423SLionel Sambuc * FUNCTION: AcpiExResolveObjectToValue 213*433d6423SLionel Sambuc * 214*433d6423SLionel Sambuc * PARAMETERS: StackPtr - Pointer to an internal object 215*433d6423SLionel Sambuc * WalkState - Current method state 216*433d6423SLionel Sambuc * 217*433d6423SLionel Sambuc * RETURN: Status 218*433d6423SLionel Sambuc * 219*433d6423SLionel Sambuc * DESCRIPTION: Retrieve the value from an internal object. The Reference type 220*433d6423SLionel Sambuc * uses the associated AML opcode to determine the value. 221*433d6423SLionel Sambuc * 222*433d6423SLionel Sambuc ******************************************************************************/ 223*433d6423SLionel Sambuc 224*433d6423SLionel Sambuc static ACPI_STATUS 225*433d6423SLionel Sambuc AcpiExResolveObjectToValue ( 226*433d6423SLionel Sambuc ACPI_OPERAND_OBJECT **StackPtr, 227*433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState) 228*433d6423SLionel Sambuc { 229*433d6423SLionel Sambuc ACPI_STATUS Status = AE_OK; 230*433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *StackDesc; 231*433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ObjDesc = NULL; 232*433d6423SLionel Sambuc UINT8 RefType; 233*433d6423SLionel Sambuc 234*433d6423SLionel Sambuc 235*433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (ExResolveObjectToValue); 236*433d6423SLionel Sambuc 237*433d6423SLionel Sambuc 238*433d6423SLionel Sambuc StackDesc = *StackPtr; 239*433d6423SLionel Sambuc 240*433d6423SLionel Sambuc /* This is an ACPI_OPERAND_OBJECT */ 241*433d6423SLionel Sambuc 242*433d6423SLionel Sambuc switch (StackDesc->Common.Type) 243*433d6423SLionel Sambuc { 244*433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_REFERENCE: 245*433d6423SLionel Sambuc 246*433d6423SLionel Sambuc RefType = StackDesc->Reference.Class; 247*433d6423SLionel Sambuc 248*433d6423SLionel Sambuc switch (RefType) 249*433d6423SLionel Sambuc { 250*433d6423SLionel Sambuc case ACPI_REFCLASS_LOCAL: 251*433d6423SLionel Sambuc case ACPI_REFCLASS_ARG: 252*433d6423SLionel Sambuc 253*433d6423SLionel Sambuc /* 254*433d6423SLionel Sambuc * Get the local from the method's state info 255*433d6423SLionel Sambuc * Note: this increments the local's object reference count 256*433d6423SLionel Sambuc */ 257*433d6423SLionel Sambuc Status = AcpiDsMethodDataGetValue (RefType, 258*433d6423SLionel Sambuc StackDesc->Reference.Value, WalkState, &ObjDesc); 259*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 260*433d6423SLionel Sambuc { 261*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 262*433d6423SLionel Sambuc } 263*433d6423SLionel Sambuc 264*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n", 265*433d6423SLionel Sambuc StackDesc->Reference.Value, ObjDesc)); 266*433d6423SLionel Sambuc 267*433d6423SLionel Sambuc /* 268*433d6423SLionel Sambuc * Now we can delete the original Reference Object and 269*433d6423SLionel Sambuc * replace it with the resolved value 270*433d6423SLionel Sambuc */ 271*433d6423SLionel Sambuc AcpiUtRemoveReference (StackDesc); 272*433d6423SLionel Sambuc *StackPtr = ObjDesc; 273*433d6423SLionel Sambuc break; 274*433d6423SLionel Sambuc 275*433d6423SLionel Sambuc 276*433d6423SLionel Sambuc case ACPI_REFCLASS_INDEX: 277*433d6423SLionel Sambuc 278*433d6423SLionel Sambuc switch (StackDesc->Reference.TargetType) 279*433d6423SLionel Sambuc { 280*433d6423SLionel Sambuc case ACPI_TYPE_BUFFER_FIELD: 281*433d6423SLionel Sambuc 282*433d6423SLionel Sambuc /* Just return - do not dereference */ 283*433d6423SLionel Sambuc break; 284*433d6423SLionel Sambuc 285*433d6423SLionel Sambuc 286*433d6423SLionel Sambuc case ACPI_TYPE_PACKAGE: 287*433d6423SLionel Sambuc 288*433d6423SLionel Sambuc /* If method call or CopyObject - do not dereference */ 289*433d6423SLionel Sambuc 290*433d6423SLionel Sambuc if ((WalkState->Opcode == AML_INT_METHODCALL_OP) || 291*433d6423SLionel Sambuc (WalkState->Opcode == AML_COPY_OP)) 292*433d6423SLionel Sambuc { 293*433d6423SLionel Sambuc break; 294*433d6423SLionel Sambuc } 295*433d6423SLionel Sambuc 296*433d6423SLionel Sambuc /* Otherwise, dereference the PackageIndex to a package element */ 297*433d6423SLionel Sambuc 298*433d6423SLionel Sambuc ObjDesc = *StackDesc->Reference.Where; 299*433d6423SLionel Sambuc if (ObjDesc) 300*433d6423SLionel Sambuc { 301*433d6423SLionel Sambuc /* 302*433d6423SLionel Sambuc * Valid object descriptor, copy pointer to return value 303*433d6423SLionel Sambuc * (i.e., dereference the package index) 304*433d6423SLionel Sambuc * Delete the ref object, increment the returned object 305*433d6423SLionel Sambuc */ 306*433d6423SLionel Sambuc AcpiUtRemoveReference (StackDesc); 307*433d6423SLionel Sambuc AcpiUtAddReference (ObjDesc); 308*433d6423SLionel Sambuc *StackPtr = ObjDesc; 309*433d6423SLionel Sambuc } 310*433d6423SLionel Sambuc else 311*433d6423SLionel Sambuc { 312*433d6423SLionel Sambuc /* 313*433d6423SLionel Sambuc * A NULL object descriptor means an uninitialized element of 314*433d6423SLionel Sambuc * the package, can't dereference it 315*433d6423SLionel Sambuc */ 316*433d6423SLionel Sambuc ACPI_ERROR ((AE_INFO, 317*433d6423SLionel Sambuc "Attempt to dereference an Index to NULL package element Idx=%p", 318*433d6423SLionel Sambuc StackDesc)); 319*433d6423SLionel Sambuc Status = AE_AML_UNINITIALIZED_ELEMENT; 320*433d6423SLionel Sambuc } 321*433d6423SLionel Sambuc break; 322*433d6423SLionel Sambuc 323*433d6423SLionel Sambuc 324*433d6423SLionel Sambuc default: 325*433d6423SLionel Sambuc 326*433d6423SLionel Sambuc /* Invalid reference object */ 327*433d6423SLionel Sambuc 328*433d6423SLionel Sambuc ACPI_ERROR ((AE_INFO, 329*433d6423SLionel Sambuc "Unknown TargetType 0x%X in Index/Reference object %p", 330*433d6423SLionel Sambuc StackDesc->Reference.TargetType, StackDesc)); 331*433d6423SLionel Sambuc Status = AE_AML_INTERNAL; 332*433d6423SLionel Sambuc break; 333*433d6423SLionel Sambuc } 334*433d6423SLionel Sambuc break; 335*433d6423SLionel Sambuc 336*433d6423SLionel Sambuc 337*433d6423SLionel Sambuc case ACPI_REFCLASS_REFOF: 338*433d6423SLionel Sambuc case ACPI_REFCLASS_DEBUG: 339*433d6423SLionel Sambuc case ACPI_REFCLASS_TABLE: 340*433d6423SLionel Sambuc 341*433d6423SLionel Sambuc /* Just leave the object as-is, do not dereference */ 342*433d6423SLionel Sambuc 343*433d6423SLionel Sambuc break; 344*433d6423SLionel Sambuc 345*433d6423SLionel Sambuc case ACPI_REFCLASS_NAME: /* Reference to a named object */ 346*433d6423SLionel Sambuc 347*433d6423SLionel Sambuc /* Dereference the name */ 348*433d6423SLionel Sambuc 349*433d6423SLionel Sambuc if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) || 350*433d6423SLionel Sambuc (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL)) 351*433d6423SLionel Sambuc { 352*433d6423SLionel Sambuc /* These node types do not have 'real' subobjects */ 353*433d6423SLionel Sambuc 354*433d6423SLionel Sambuc *StackPtr = (void *) StackDesc->Reference.Node; 355*433d6423SLionel Sambuc } 356*433d6423SLionel Sambuc else 357*433d6423SLionel Sambuc { 358*433d6423SLionel Sambuc /* Get the object pointed to by the namespace node */ 359*433d6423SLionel Sambuc 360*433d6423SLionel Sambuc *StackPtr = (StackDesc->Reference.Node)->Object; 361*433d6423SLionel Sambuc AcpiUtAddReference (*StackPtr); 362*433d6423SLionel Sambuc } 363*433d6423SLionel Sambuc 364*433d6423SLionel Sambuc AcpiUtRemoveReference (StackDesc); 365*433d6423SLionel Sambuc break; 366*433d6423SLionel Sambuc 367*433d6423SLionel Sambuc default: 368*433d6423SLionel Sambuc 369*433d6423SLionel Sambuc ACPI_ERROR ((AE_INFO, 370*433d6423SLionel Sambuc "Unknown Reference type 0x%X in %p", RefType, StackDesc)); 371*433d6423SLionel Sambuc Status = AE_AML_INTERNAL; 372*433d6423SLionel Sambuc break; 373*433d6423SLionel Sambuc } 374*433d6423SLionel Sambuc break; 375*433d6423SLionel Sambuc 376*433d6423SLionel Sambuc 377*433d6423SLionel Sambuc case ACPI_TYPE_BUFFER: 378*433d6423SLionel Sambuc 379*433d6423SLionel Sambuc Status = AcpiDsGetBufferArguments (StackDesc); 380*433d6423SLionel Sambuc break; 381*433d6423SLionel Sambuc 382*433d6423SLionel Sambuc 383*433d6423SLionel Sambuc case ACPI_TYPE_PACKAGE: 384*433d6423SLionel Sambuc 385*433d6423SLionel Sambuc Status = AcpiDsGetPackageArguments (StackDesc); 386*433d6423SLionel Sambuc break; 387*433d6423SLionel Sambuc 388*433d6423SLionel Sambuc 389*433d6423SLionel Sambuc case ACPI_TYPE_BUFFER_FIELD: 390*433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_REGION_FIELD: 391*433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_BANK_FIELD: 392*433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_INDEX_FIELD: 393*433d6423SLionel Sambuc 394*433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n", 395*433d6423SLionel Sambuc StackDesc, StackDesc->Common.Type)); 396*433d6423SLionel Sambuc 397*433d6423SLionel Sambuc Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc); 398*433d6423SLionel Sambuc 399*433d6423SLionel Sambuc /* Remove a reference to the original operand, then override */ 400*433d6423SLionel Sambuc 401*433d6423SLionel Sambuc AcpiUtRemoveReference (*StackPtr); 402*433d6423SLionel Sambuc *StackPtr = (void *) ObjDesc; 403*433d6423SLionel Sambuc break; 404*433d6423SLionel Sambuc 405*433d6423SLionel Sambuc default: 406*433d6423SLionel Sambuc break; 407*433d6423SLionel Sambuc } 408*433d6423SLionel Sambuc 409*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 410*433d6423SLionel Sambuc } 411*433d6423SLionel Sambuc 412*433d6423SLionel Sambuc 413*433d6423SLionel Sambuc /******************************************************************************* 414*433d6423SLionel Sambuc * 415*433d6423SLionel Sambuc * FUNCTION: AcpiExResolveMultiple 416*433d6423SLionel Sambuc * 417*433d6423SLionel Sambuc * PARAMETERS: WalkState - Current state (contains AML opcode) 418*433d6423SLionel Sambuc * Operand - Starting point for resolution 419*433d6423SLionel Sambuc * ReturnType - Where the object type is returned 420*433d6423SLionel Sambuc * ReturnDesc - Where the resolved object is returned 421*433d6423SLionel Sambuc * 422*433d6423SLionel Sambuc * RETURN: Status 423*433d6423SLionel Sambuc * 424*433d6423SLionel Sambuc * DESCRIPTION: Return the base object and type. Traverse a reference list if 425*433d6423SLionel Sambuc * necessary to get to the base object. 426*433d6423SLionel Sambuc * 427*433d6423SLionel Sambuc ******************************************************************************/ 428*433d6423SLionel Sambuc 429*433d6423SLionel Sambuc ACPI_STATUS 430*433d6423SLionel Sambuc AcpiExResolveMultiple ( 431*433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState, 432*433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *Operand, 433*433d6423SLionel Sambuc ACPI_OBJECT_TYPE *ReturnType, 434*433d6423SLionel Sambuc ACPI_OPERAND_OBJECT **ReturnDesc) 435*433d6423SLionel Sambuc { 436*433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ObjDesc = (void *) Operand; 437*433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *Node; 438*433d6423SLionel Sambuc ACPI_OBJECT_TYPE Type; 439*433d6423SLionel Sambuc ACPI_STATUS Status; 440*433d6423SLionel Sambuc 441*433d6423SLionel Sambuc 442*433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (AcpiExResolveMultiple); 443*433d6423SLionel Sambuc 444*433d6423SLionel Sambuc 445*433d6423SLionel Sambuc /* Operand can be either a namespace node or an operand descriptor */ 446*433d6423SLionel Sambuc 447*433d6423SLionel Sambuc switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) 448*433d6423SLionel Sambuc { 449*433d6423SLionel Sambuc case ACPI_DESC_TYPE_OPERAND: 450*433d6423SLionel Sambuc Type = ObjDesc->Common.Type; 451*433d6423SLionel Sambuc break; 452*433d6423SLionel Sambuc 453*433d6423SLionel Sambuc case ACPI_DESC_TYPE_NAMED: 454*433d6423SLionel Sambuc Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; 455*433d6423SLionel Sambuc ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); 456*433d6423SLionel Sambuc 457*433d6423SLionel Sambuc /* If we had an Alias node, use the attached object for type info */ 458*433d6423SLionel Sambuc 459*433d6423SLionel Sambuc if (Type == ACPI_TYPE_LOCAL_ALIAS) 460*433d6423SLionel Sambuc { 461*433d6423SLionel Sambuc Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; 462*433d6423SLionel Sambuc ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); 463*433d6423SLionel Sambuc } 464*433d6423SLionel Sambuc break; 465*433d6423SLionel Sambuc 466*433d6423SLionel Sambuc default: 467*433d6423SLionel Sambuc return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 468*433d6423SLionel Sambuc } 469*433d6423SLionel Sambuc 470*433d6423SLionel Sambuc /* If type is anything other than a reference, we are done */ 471*433d6423SLionel Sambuc 472*433d6423SLionel Sambuc if (Type != ACPI_TYPE_LOCAL_REFERENCE) 473*433d6423SLionel Sambuc { 474*433d6423SLionel Sambuc goto Exit; 475*433d6423SLionel Sambuc } 476*433d6423SLionel Sambuc 477*433d6423SLionel Sambuc /* 478*433d6423SLionel Sambuc * For reference objects created via the RefOf, Index, or Load/LoadTable 479*433d6423SLionel Sambuc * operators, we need to get to the base object (as per the ACPI 480*433d6423SLionel Sambuc * specification of the ObjectType and SizeOf operators). This means 481*433d6423SLionel Sambuc * traversing the list of possibly many nested references. 482*433d6423SLionel Sambuc */ 483*433d6423SLionel Sambuc while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) 484*433d6423SLionel Sambuc { 485*433d6423SLionel Sambuc switch (ObjDesc->Reference.Class) 486*433d6423SLionel Sambuc { 487*433d6423SLionel Sambuc case ACPI_REFCLASS_REFOF: 488*433d6423SLionel Sambuc case ACPI_REFCLASS_NAME: 489*433d6423SLionel Sambuc 490*433d6423SLionel Sambuc /* Dereference the reference pointer */ 491*433d6423SLionel Sambuc 492*433d6423SLionel Sambuc if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF) 493*433d6423SLionel Sambuc { 494*433d6423SLionel Sambuc Node = ObjDesc->Reference.Object; 495*433d6423SLionel Sambuc } 496*433d6423SLionel Sambuc else /* AML_INT_NAMEPATH_OP */ 497*433d6423SLionel Sambuc { 498*433d6423SLionel Sambuc Node = ObjDesc->Reference.Node; 499*433d6423SLionel Sambuc } 500*433d6423SLionel Sambuc 501*433d6423SLionel Sambuc /* All "References" point to a NS node */ 502*433d6423SLionel Sambuc 503*433d6423SLionel Sambuc if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 504*433d6423SLionel Sambuc { 505*433d6423SLionel Sambuc ACPI_ERROR ((AE_INFO, 506*433d6423SLionel Sambuc "Not a namespace node %p [%s]", 507*433d6423SLionel Sambuc Node, AcpiUtGetDescriptorName (Node))); 508*433d6423SLionel Sambuc return_ACPI_STATUS (AE_AML_INTERNAL); 509*433d6423SLionel Sambuc } 510*433d6423SLionel Sambuc 511*433d6423SLionel Sambuc /* Get the attached object */ 512*433d6423SLionel Sambuc 513*433d6423SLionel Sambuc ObjDesc = AcpiNsGetAttachedObject (Node); 514*433d6423SLionel Sambuc if (!ObjDesc) 515*433d6423SLionel Sambuc { 516*433d6423SLionel Sambuc /* No object, use the NS node type */ 517*433d6423SLionel Sambuc 518*433d6423SLionel Sambuc Type = AcpiNsGetType (Node); 519*433d6423SLionel Sambuc goto Exit; 520*433d6423SLionel Sambuc } 521*433d6423SLionel Sambuc 522*433d6423SLionel Sambuc /* Check for circular references */ 523*433d6423SLionel Sambuc 524*433d6423SLionel Sambuc if (ObjDesc == Operand) 525*433d6423SLionel Sambuc { 526*433d6423SLionel Sambuc return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); 527*433d6423SLionel Sambuc } 528*433d6423SLionel Sambuc break; 529*433d6423SLionel Sambuc 530*433d6423SLionel Sambuc 531*433d6423SLionel Sambuc case ACPI_REFCLASS_INDEX: 532*433d6423SLionel Sambuc 533*433d6423SLionel Sambuc /* Get the type of this reference (index into another object) */ 534*433d6423SLionel Sambuc 535*433d6423SLionel Sambuc Type = ObjDesc->Reference.TargetType; 536*433d6423SLionel Sambuc if (Type != ACPI_TYPE_PACKAGE) 537*433d6423SLionel Sambuc { 538*433d6423SLionel Sambuc goto Exit; 539*433d6423SLionel Sambuc } 540*433d6423SLionel Sambuc 541*433d6423SLionel Sambuc /* 542*433d6423SLionel Sambuc * The main object is a package, we want to get the type 543*433d6423SLionel Sambuc * of the individual package element that is referenced by 544*433d6423SLionel Sambuc * the index. 545*433d6423SLionel Sambuc * 546*433d6423SLionel Sambuc * This could of course in turn be another reference object. 547*433d6423SLionel Sambuc */ 548*433d6423SLionel Sambuc ObjDesc = *(ObjDesc->Reference.Where); 549*433d6423SLionel Sambuc if (!ObjDesc) 550*433d6423SLionel Sambuc { 551*433d6423SLionel Sambuc /* NULL package elements are allowed */ 552*433d6423SLionel Sambuc 553*433d6423SLionel Sambuc Type = 0; /* Uninitialized */ 554*433d6423SLionel Sambuc goto Exit; 555*433d6423SLionel Sambuc } 556*433d6423SLionel Sambuc break; 557*433d6423SLionel Sambuc 558*433d6423SLionel Sambuc 559*433d6423SLionel Sambuc case ACPI_REFCLASS_TABLE: 560*433d6423SLionel Sambuc 561*433d6423SLionel Sambuc Type = ACPI_TYPE_DDB_HANDLE; 562*433d6423SLionel Sambuc goto Exit; 563*433d6423SLionel Sambuc 564*433d6423SLionel Sambuc 565*433d6423SLionel Sambuc case ACPI_REFCLASS_LOCAL: 566*433d6423SLionel Sambuc case ACPI_REFCLASS_ARG: 567*433d6423SLionel Sambuc 568*433d6423SLionel Sambuc if (ReturnDesc) 569*433d6423SLionel Sambuc { 570*433d6423SLionel Sambuc Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class, 571*433d6423SLionel Sambuc ObjDesc->Reference.Value, WalkState, &ObjDesc); 572*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 573*433d6423SLionel Sambuc { 574*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 575*433d6423SLionel Sambuc } 576*433d6423SLionel Sambuc AcpiUtRemoveReference (ObjDesc); 577*433d6423SLionel Sambuc } 578*433d6423SLionel Sambuc else 579*433d6423SLionel Sambuc { 580*433d6423SLionel Sambuc Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class, 581*433d6423SLionel Sambuc ObjDesc->Reference.Value, WalkState, &Node); 582*433d6423SLionel Sambuc if (ACPI_FAILURE (Status)) 583*433d6423SLionel Sambuc { 584*433d6423SLionel Sambuc return_ACPI_STATUS (Status); 585*433d6423SLionel Sambuc } 586*433d6423SLionel Sambuc 587*433d6423SLionel Sambuc ObjDesc = AcpiNsGetAttachedObject (Node); 588*433d6423SLionel Sambuc if (!ObjDesc) 589*433d6423SLionel Sambuc { 590*433d6423SLionel Sambuc Type = ACPI_TYPE_ANY; 591*433d6423SLionel Sambuc goto Exit; 592*433d6423SLionel Sambuc } 593*433d6423SLionel Sambuc } 594*433d6423SLionel Sambuc break; 595*433d6423SLionel Sambuc 596*433d6423SLionel Sambuc 597*433d6423SLionel Sambuc case ACPI_REFCLASS_DEBUG: 598*433d6423SLionel Sambuc 599*433d6423SLionel Sambuc /* The Debug Object is of type "DebugObject" */ 600*433d6423SLionel Sambuc 601*433d6423SLionel Sambuc Type = ACPI_TYPE_DEBUG_OBJECT; 602*433d6423SLionel Sambuc goto Exit; 603*433d6423SLionel Sambuc 604*433d6423SLionel Sambuc 605*433d6423SLionel Sambuc default: 606*433d6423SLionel Sambuc 607*433d6423SLionel Sambuc ACPI_ERROR ((AE_INFO, 608*433d6423SLionel Sambuc "Unknown Reference Class 0x%2.2X", ObjDesc->Reference.Class)); 609*433d6423SLionel Sambuc return_ACPI_STATUS (AE_AML_INTERNAL); 610*433d6423SLionel Sambuc } 611*433d6423SLionel Sambuc } 612*433d6423SLionel Sambuc 613*433d6423SLionel Sambuc /* 614*433d6423SLionel Sambuc * Now we are guaranteed to have an object that has not been created 615*433d6423SLionel Sambuc * via the RefOf or Index operators. 616*433d6423SLionel Sambuc */ 617*433d6423SLionel Sambuc Type = ObjDesc->Common.Type; 618*433d6423SLionel Sambuc 619*433d6423SLionel Sambuc 620*433d6423SLionel Sambuc Exit: 621*433d6423SLionel Sambuc /* Convert internal types to external types */ 622*433d6423SLionel Sambuc 623*433d6423SLionel Sambuc switch (Type) 624*433d6423SLionel Sambuc { 625*433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_REGION_FIELD: 626*433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_BANK_FIELD: 627*433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_INDEX_FIELD: 628*433d6423SLionel Sambuc 629*433d6423SLionel Sambuc Type = ACPI_TYPE_FIELD_UNIT; 630*433d6423SLionel Sambuc break; 631*433d6423SLionel Sambuc 632*433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_SCOPE: 633*433d6423SLionel Sambuc 634*433d6423SLionel Sambuc /* Per ACPI Specification, Scope is untyped */ 635*433d6423SLionel Sambuc 636*433d6423SLionel Sambuc Type = ACPI_TYPE_ANY; 637*433d6423SLionel Sambuc break; 638*433d6423SLionel Sambuc 639*433d6423SLionel Sambuc default: 640*433d6423SLionel Sambuc /* No change to Type required */ 641*433d6423SLionel Sambuc break; 642*433d6423SLionel Sambuc } 643*433d6423SLionel Sambuc 644*433d6423SLionel Sambuc *ReturnType = Type; 645*433d6423SLionel Sambuc if (ReturnDesc) 646*433d6423SLionel Sambuc { 647*433d6423SLionel Sambuc *ReturnDesc = ObjDesc; 648*433d6423SLionel Sambuc } 649*433d6423SLionel Sambuc return_ACPI_STATUS (AE_OK); 650*433d6423SLionel Sambuc } 651*433d6423SLionel Sambuc 652*433d6423SLionel Sambuc 653