167754Smsmith/****************************************************************************** 267754Smsmith * 377424Smsmith * Module Name: exresolv - AML Interpreter object resolution 467754Smsmith * 567754Smsmith *****************************************************************************/ 667754Smsmith 7217365Sjkim/* 8281075Sdim * Copyright (C) 2000 - 2015, Intel Corp. 970243Smsmith * All rights reserved. 1067754Smsmith * 11217365Sjkim * Redistribution and use in source and binary forms, with or without 12217365Sjkim * modification, are permitted provided that the following conditions 13217365Sjkim * are met: 14217365Sjkim * 1. Redistributions of source code must retain the above copyright 15217365Sjkim * notice, this list of conditions, and the following disclaimer, 16217365Sjkim * without modification. 17217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 19217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 20217365Sjkim * including a substantially similar Disclaimer requirement for further 21217365Sjkim * binary redistribution. 22217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 23217365Sjkim * of any contributors may be used to endorse or promote products derived 24217365Sjkim * from this software without specific prior written permission. 2567754Smsmith * 26217365Sjkim * Alternatively, this software may be distributed under the terms of the 27217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 28217365Sjkim * Software Foundation. 2967754Smsmith * 30217365Sjkim * NO WARRANTY 31217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41217365Sjkim * POSSIBILITY OF SUCH DAMAGES. 42217365Sjkim */ 4367754Smsmith 44193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 45193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 46193341Sjkim#include <contrib/dev/acpica/include/amlcode.h> 47193341Sjkim#include <contrib/dev/acpica/include/acdispat.h> 48193341Sjkim#include <contrib/dev/acpica/include/acinterp.h> 49193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h> 5067754Smsmith 5167754Smsmith 5277424Smsmith#define _COMPONENT ACPI_EXECUTER 5391116Smsmith ACPI_MODULE_NAME ("exresolv") 5467754Smsmith 55151937Sjkim/* Local prototypes */ 5667754Smsmith 57151937Sjkimstatic ACPI_STATUS 58151937SjkimAcpiExResolveObjectToValue ( 59151937Sjkim ACPI_OPERAND_OBJECT **StackPtr, 60151937Sjkim ACPI_WALK_STATE *WalkState); 61151937Sjkim 62151937Sjkim 6367754Smsmith/******************************************************************************* 6467754Smsmith * 6577424Smsmith * FUNCTION: AcpiExResolveToValue 6667754Smsmith * 6767754Smsmith * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can 6877424Smsmith * be either an (ACPI_OPERAND_OBJECT *) 6967754Smsmith * or an ACPI_HANDLE. 7077424Smsmith * WalkState - Current method state 7167754Smsmith * 7267754Smsmith * RETURN: Status 7367754Smsmith * 7471867Smsmith * DESCRIPTION: Convert Reference objects to values 7567754Smsmith * 7667754Smsmith ******************************************************************************/ 7767754Smsmith 7867754SmsmithACPI_STATUS 7977424SmsmithAcpiExResolveToValue ( 8067754Smsmith ACPI_OPERAND_OBJECT **StackPtr, 8167754Smsmith ACPI_WALK_STATE *WalkState) 8267754Smsmith{ 8377424Smsmith ACPI_STATUS Status; 8467754Smsmith 8567754Smsmith 86167802Sjkim ACPI_FUNCTION_TRACE_PTR (ExResolveToValue, StackPtr); 8767754Smsmith 8867754Smsmith 8967754Smsmith if (!StackPtr || !*StackPtr) 9067754Smsmith { 91167802Sjkim ACPI_ERROR ((AE_INFO, "Internal - null pointer")); 9267754Smsmith return_ACPI_STATUS (AE_AML_NO_OPERAND); 9367754Smsmith } 9467754Smsmith 9567754Smsmith /* 9667754Smsmith * The entity pointed to by the StackPtr can be either 9767754Smsmith * 1) A valid ACPI_OPERAND_OBJECT, or 9867754Smsmith * 2) A ACPI_NAMESPACE_NODE (NamedObj) 9967754Smsmith */ 10099679Siwasaki if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_OPERAND) 10167754Smsmith { 10277424Smsmith Status = AcpiExResolveObjectToValue (StackPtr, WalkState); 10367754Smsmith if (ACPI_FAILURE (Status)) 10467754Smsmith { 10567754Smsmith return_ACPI_STATUS (Status); 10667754Smsmith } 107151937Sjkim 108151937Sjkim if (!*StackPtr) 109151937Sjkim { 110167802Sjkim ACPI_ERROR ((AE_INFO, "Internal - null pointer")); 111151937Sjkim return_ACPI_STATUS (AE_AML_NO_OPERAND); 112151937Sjkim } 11367754Smsmith } 11467754Smsmith 11567754Smsmith /* 11677424Smsmith * Object on the stack may have changed if AcpiExResolveObjectToValue() 11767754Smsmith * was called (i.e., we can't use an _else_ here.) 11867754Smsmith */ 11991116Smsmith if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED) 12067754Smsmith { 12199679Siwasaki Status = AcpiExResolveNodeToValue ( 12299679Siwasaki ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr), 12377424Smsmith WalkState); 12477424Smsmith if (ACPI_FAILURE (Status)) 12577424Smsmith { 12677424Smsmith return_ACPI_STATUS (Status); 12777424Smsmith } 12867754Smsmith } 12967754Smsmith 13099146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr)); 13177424Smsmith return_ACPI_STATUS (AE_OK); 13267754Smsmith} 13367754Smsmith 13467754Smsmith 13567754Smsmith/******************************************************************************* 13667754Smsmith * 13777424Smsmith * FUNCTION: AcpiExResolveObjectToValue 13867754Smsmith * 139151937Sjkim * PARAMETERS: StackPtr - Pointer to an internal object 14077424Smsmith * WalkState - Current method state 14167754Smsmith * 14267754Smsmith * RETURN: Status 14367754Smsmith * 144151937Sjkim * DESCRIPTION: Retrieve the value from an internal object. The Reference type 14567754Smsmith * uses the associated AML opcode to determine the value. 14667754Smsmith * 14767754Smsmith ******************************************************************************/ 14867754Smsmith 149151937Sjkimstatic ACPI_STATUS 15077424SmsmithAcpiExResolveObjectToValue ( 15167754Smsmith ACPI_OPERAND_OBJECT **StackPtr, 15267754Smsmith ACPI_WALK_STATE *WalkState) 15367754Smsmith{ 15477424Smsmith ACPI_STATUS Status = AE_OK; 15567754Smsmith ACPI_OPERAND_OBJECT *StackDesc; 156167802Sjkim ACPI_OPERAND_OBJECT *ObjDesc = NULL; 157193267Sjkim UINT8 RefType; 15867754Smsmith 15967754Smsmith 160167802Sjkim ACPI_FUNCTION_TRACE (ExResolveObjectToValue); 16167754Smsmith 16267754Smsmith 16367754Smsmith StackDesc = *StackPtr; 16467754Smsmith 165238381Sjkim /* This is an object of type ACPI_OPERAND_OBJECT */ 16667754Smsmith 167193267Sjkim switch (StackDesc->Common.Type) 16867754Smsmith { 169107325Siwasaki case ACPI_TYPE_LOCAL_REFERENCE: 17067754Smsmith 171193267Sjkim RefType = StackDesc->Reference.Class; 17267754Smsmith 173193267Sjkim switch (RefType) 17467754Smsmith { 175193267Sjkim case ACPI_REFCLASS_LOCAL: 176193267Sjkim case ACPI_REFCLASS_ARG: 17767754Smsmith /* 17867754Smsmith * Get the local from the method's state info 17967754Smsmith * Note: this increments the local's object reference count 18067754Smsmith */ 181193267Sjkim Status = AcpiDsMethodDataGetValue (RefType, 182193267Sjkim StackDesc->Reference.Value, WalkState, &ObjDesc); 18367754Smsmith if (ACPI_FAILURE (Status)) 18467754Smsmith { 18567754Smsmith return_ACPI_STATUS (Status); 18667754Smsmith } 18767754Smsmith 188129684Snjl ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n", 189193267Sjkim StackDesc->Reference.Value, ObjDesc)); 190129684Snjl 19167754Smsmith /* 19267754Smsmith * Now we can delete the original Reference Object and 193129684Snjl * replace it with the resolved value 19467754Smsmith */ 19577424Smsmith AcpiUtRemoveReference (StackDesc); 19667754Smsmith *StackPtr = ObjDesc; 19767754Smsmith break; 19867754Smsmith 199193267Sjkim case ACPI_REFCLASS_INDEX: 20067754Smsmith 20167754Smsmith switch (StackDesc->Reference.TargetType) 20267754Smsmith { 20367754Smsmith case ACPI_TYPE_BUFFER_FIELD: 20467754Smsmith 205193267Sjkim /* Just return - do not dereference */ 20667754Smsmith break; 20767754Smsmith 20867754Smsmith case ACPI_TYPE_PACKAGE: 20999679Siwasaki 210193267Sjkim /* If method call or CopyObject - do not dereference */ 211193267Sjkim 212193267Sjkim if ((WalkState->Opcode == AML_INT_METHODCALL_OP) || 213193267Sjkim (WalkState->Opcode == AML_COPY_OP)) 214193267Sjkim { 215193267Sjkim break; 216193267Sjkim } 217193267Sjkim 218193267Sjkim /* Otherwise, dereference the PackageIndex to a package element */ 219193267Sjkim 22067754Smsmith ObjDesc = *StackDesc->Reference.Where; 22167754Smsmith if (ObjDesc) 22267754Smsmith { 22367754Smsmith /* 224193267Sjkim * Valid object descriptor, copy pointer to return value 22567754Smsmith * (i.e., dereference the package index) 22667754Smsmith * Delete the ref object, increment the returned object 22767754Smsmith */ 22877424Smsmith AcpiUtRemoveReference (StackDesc); 22977424Smsmith AcpiUtAddReference (ObjDesc); 23067754Smsmith *StackPtr = ObjDesc; 23167754Smsmith } 23267754Smsmith else 23367754Smsmith { 23467754Smsmith /* 235193267Sjkim * A NULL object descriptor means an uninitialized element of 23677424Smsmith * the package, can't dereference it 23767754Smsmith */ 238167802Sjkim ACPI_ERROR ((AE_INFO, 239193267Sjkim "Attempt to dereference an Index to NULL package element Idx=%p", 24077424Smsmith StackDesc)); 24167754Smsmith Status = AE_AML_UNINITIALIZED_ELEMENT; 24267754Smsmith } 24367754Smsmith break; 24467754Smsmith 24567754Smsmith default: 24699679Siwasaki 24777424Smsmith /* Invalid reference object */ 24867754Smsmith 249167802Sjkim ACPI_ERROR ((AE_INFO, 250204773Sjkim "Unknown TargetType 0x%X in Index/Reference object %p", 25167754Smsmith StackDesc->Reference.TargetType, StackDesc)); 25267754Smsmith Status = AE_AML_INTERNAL; 25367754Smsmith break; 25467754Smsmith } 25567754Smsmith break; 25667754Smsmith 257193267Sjkim case ACPI_REFCLASS_REFOF: 258193267Sjkim case ACPI_REFCLASS_DEBUG: 259193267Sjkim case ACPI_REFCLASS_TABLE: 26067754Smsmith 261193267Sjkim /* Just leave the object as-is, do not dereference */ 262100966Siwasaki 26367754Smsmith break; 26467754Smsmith 265193267Sjkim case ACPI_REFCLASS_NAME: /* Reference to a named object */ 26667754Smsmith 267167802Sjkim /* Dereference the name */ 268151937Sjkim 269167802Sjkim if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) || 270167802Sjkim (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL)) 271167802Sjkim { 272167802Sjkim /* These node types do not have 'real' subobjects */ 273167802Sjkim 274167802Sjkim *StackPtr = (void *) StackDesc->Reference.Node; 275167802Sjkim } 276167802Sjkim else 277167802Sjkim { 278167802Sjkim /* Get the object pointed to by the namespace node */ 279167802Sjkim 280167802Sjkim *StackPtr = (StackDesc->Reference.Node)->Object; 281167802Sjkim AcpiUtAddReference (*StackPtr); 282167802Sjkim } 283167802Sjkim 284151937Sjkim AcpiUtRemoveReference (StackDesc); 285151937Sjkim break; 286151937Sjkim 28767754Smsmith default: 28867754Smsmith 289167802Sjkim ACPI_ERROR ((AE_INFO, 290204773Sjkim "Unknown Reference type 0x%X in %p", RefType, StackDesc)); 29167754Smsmith Status = AE_AML_INTERNAL; 29277424Smsmith break; 29399679Siwasaki } 29499679Siwasaki break; 29567754Smsmith 29699146Siwasaki case ACPI_TYPE_BUFFER: 29799146Siwasaki 29899146Siwasaki Status = AcpiDsGetBufferArguments (StackDesc); 29999146Siwasaki break; 30099146Siwasaki 30199146Siwasaki case ACPI_TYPE_PACKAGE: 30299146Siwasaki 30399146Siwasaki Status = AcpiDsGetPackageArguments (StackDesc); 30499146Siwasaki break; 30599146Siwasaki 30677424Smsmith case ACPI_TYPE_BUFFER_FIELD: 307107325Siwasaki case ACPI_TYPE_LOCAL_REGION_FIELD: 308107325Siwasaki case ACPI_TYPE_LOCAL_BANK_FIELD: 309107325Siwasaki case ACPI_TYPE_LOCAL_INDEX_FIELD: 31067754Smsmith 31187031Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n", 312193267Sjkim StackDesc, StackDesc->Common.Type)); 31367754Smsmith 31499146Siwasaki Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc); 315167802Sjkim 316167802Sjkim /* Remove a reference to the original operand, then override */ 317167802Sjkim 318167802Sjkim AcpiUtRemoveReference (*StackPtr); 31967754Smsmith *StackPtr = (void *) ObjDesc; 32067754Smsmith break; 32167754Smsmith 32267754Smsmith default: 323250838Sjkim 32467754Smsmith break; 32587031Smsmith } 32667754Smsmith 32767754Smsmith return_ACPI_STATUS (Status); 32867754Smsmith} 32967754Smsmith 33067754Smsmith 331104470Siwasaki/******************************************************************************* 332104470Siwasaki * 333104470Siwasaki * FUNCTION: AcpiExResolveMultiple 334104470Siwasaki * 335104470Siwasaki * PARAMETERS: WalkState - Current state (contains AML opcode) 336104470Siwasaki * Operand - Starting point for resolution 337104470Siwasaki * ReturnType - Where the object type is returned 338104470Siwasaki * ReturnDesc - Where the resolved object is returned 339104470Siwasaki * 340104470Siwasaki * RETURN: Status 341104470Siwasaki * 342241973Sjkim * DESCRIPTION: Return the base object and type. Traverse a reference list if 343104470Siwasaki * necessary to get to the base object. 344104470Siwasaki * 345104470Siwasaki ******************************************************************************/ 346104470Siwasaki 347104470SiwasakiACPI_STATUS 348104470SiwasakiAcpiExResolveMultiple ( 349104470Siwasaki ACPI_WALK_STATE *WalkState, 350104470Siwasaki ACPI_OPERAND_OBJECT *Operand, 351104470Siwasaki ACPI_OBJECT_TYPE *ReturnType, 352104470Siwasaki ACPI_OPERAND_OBJECT **ReturnDesc) 353104470Siwasaki{ 354104470Siwasaki ACPI_OPERAND_OBJECT *ObjDesc = (void *) Operand; 355104470Siwasaki ACPI_NAMESPACE_NODE *Node; 356104470Siwasaki ACPI_OBJECT_TYPE Type; 357138287Smarks ACPI_STATUS Status; 358104470Siwasaki 359104470Siwasaki 360167802Sjkim ACPI_FUNCTION_TRACE (AcpiExResolveMultiple); 361104470Siwasaki 362104470Siwasaki 363151937Sjkim /* Operand can be either a namespace node or an operand descriptor */ 364138287Smarks 365138287Smarks switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) 366138287Smarks { 367138287Smarks case ACPI_DESC_TYPE_OPERAND: 368250838Sjkim 369138287Smarks Type = ObjDesc->Common.Type; 370138287Smarks break; 371138287Smarks 372138287Smarks case ACPI_DESC_TYPE_NAMED: 373250838Sjkim 374138287Smarks Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; 375138287Smarks ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); 376138287Smarks 377138287Smarks /* If we had an Alias node, use the attached object for type info */ 378138287Smarks 379138287Smarks if (Type == ACPI_TYPE_LOCAL_ALIAS) 380138287Smarks { 381138287Smarks Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; 382138287Smarks ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); 383138287Smarks } 384138287Smarks break; 385138287Smarks 386138287Smarks default: 387138287Smarks return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 388138287Smarks } 389138287Smarks 390151937Sjkim /* If type is anything other than a reference, we are done */ 391138287Smarks 392138287Smarks if (Type != ACPI_TYPE_LOCAL_REFERENCE) 393138287Smarks { 394138287Smarks goto Exit; 395138287Smarks } 396138287Smarks 397138287Smarks /* 398193267Sjkim * For reference objects created via the RefOf, Index, or Load/LoadTable 399193267Sjkim * operators, we need to get to the base object (as per the ACPI 400193267Sjkim * specification of the ObjectType and SizeOf operators). This means 401193267Sjkim * traversing the list of possibly many nested references. 402104470Siwasaki */ 403193267Sjkim while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) 404104470Siwasaki { 405193267Sjkim switch (ObjDesc->Reference.Class) 406104470Siwasaki { 407193267Sjkim case ACPI_REFCLASS_REFOF: 408193267Sjkim case ACPI_REFCLASS_NAME: 409104470Siwasaki 410104470Siwasaki /* Dereference the reference pointer */ 411104470Siwasaki 412193267Sjkim if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF) 413167802Sjkim { 414167802Sjkim Node = ObjDesc->Reference.Object; 415167802Sjkim } 416167802Sjkim else /* AML_INT_NAMEPATH_OP */ 417167802Sjkim { 418167802Sjkim Node = ObjDesc->Reference.Node; 419167802Sjkim } 420104470Siwasaki 421104470Siwasaki /* All "References" point to a NS node */ 422104470Siwasaki 423104470Siwasaki if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 424104470Siwasaki { 425167802Sjkim ACPI_ERROR ((AE_INFO, 426204773Sjkim "Not a namespace node %p [%s]", 427151937Sjkim Node, AcpiUtGetDescriptorName (Node))); 428104470Siwasaki return_ACPI_STATUS (AE_AML_INTERNAL); 429104470Siwasaki } 430104470Siwasaki 431104470Siwasaki /* Get the attached object */ 432104470Siwasaki 433104470Siwasaki ObjDesc = AcpiNsGetAttachedObject (Node); 434104470Siwasaki if (!ObjDesc) 435104470Siwasaki { 436104470Siwasaki /* No object, use the NS node type */ 437104470Siwasaki 438104470Siwasaki Type = AcpiNsGetType (Node); 439104470Siwasaki goto Exit; 440104470Siwasaki } 441104470Siwasaki 442104470Siwasaki /* Check for circular references */ 443104470Siwasaki 444104470Siwasaki if (ObjDesc == Operand) 445104470Siwasaki { 446104470Siwasaki return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); 447104470Siwasaki } 448104470Siwasaki break; 449104470Siwasaki 450193267Sjkim case ACPI_REFCLASS_INDEX: 451104470Siwasaki 452104470Siwasaki /* Get the type of this reference (index into another object) */ 453104470Siwasaki 454104470Siwasaki Type = ObjDesc->Reference.TargetType; 455104470Siwasaki if (Type != ACPI_TYPE_PACKAGE) 456104470Siwasaki { 457104470Siwasaki goto Exit; 458104470Siwasaki } 459104470Siwasaki 460104470Siwasaki /* 461104470Siwasaki * The main object is a package, we want to get the type 462104470Siwasaki * of the individual package element that is referenced by 463104470Siwasaki * the index. 464104470Siwasaki * 465104470Siwasaki * This could of course in turn be another reference object. 466104470Siwasaki */ 467104470Siwasaki ObjDesc = *(ObjDesc->Reference.Where); 468151937Sjkim if (!ObjDesc) 469151937Sjkim { 470151937Sjkim /* NULL package elements are allowed */ 471151937Sjkim 472151937Sjkim Type = 0; /* Uninitialized */ 473151937Sjkim goto Exit; 474151937Sjkim } 475104470Siwasaki break; 476104470Siwasaki 477193267Sjkim case ACPI_REFCLASS_TABLE: 478138287Smarks 479193267Sjkim Type = ACPI_TYPE_DDB_HANDLE; 480193267Sjkim goto Exit; 481193267Sjkim 482193267Sjkim case ACPI_REFCLASS_LOCAL: 483193267Sjkim case ACPI_REFCLASS_ARG: 484193267Sjkim 485138287Smarks if (ReturnDesc) 486138287Smarks { 487193267Sjkim Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class, 488193267Sjkim ObjDesc->Reference.Value, WalkState, &ObjDesc); 489138287Smarks if (ACPI_FAILURE (Status)) 490138287Smarks { 491138287Smarks return_ACPI_STATUS (Status); 492138287Smarks } 493138287Smarks AcpiUtRemoveReference (ObjDesc); 494138287Smarks } 495138287Smarks else 496138287Smarks { 497193267Sjkim Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class, 498193267Sjkim ObjDesc->Reference.Value, WalkState, &Node); 499138287Smarks if (ACPI_FAILURE (Status)) 500138287Smarks { 501138287Smarks return_ACPI_STATUS (Status); 502138287Smarks } 503138287Smarks 504138287Smarks ObjDesc = AcpiNsGetAttachedObject (Node); 505138287Smarks if (!ObjDesc) 506138287Smarks { 507138287Smarks Type = ACPI_TYPE_ANY; 508138287Smarks goto Exit; 509138287Smarks } 510138287Smarks } 511138287Smarks break; 512138287Smarks 513193267Sjkim case ACPI_REFCLASS_DEBUG: 514104470Siwasaki 515104470Siwasaki /* The Debug Object is of type "DebugObject" */ 516104470Siwasaki 517104470Siwasaki Type = ACPI_TYPE_DEBUG_OBJECT; 518104470Siwasaki goto Exit; 519104470Siwasaki 520104470Siwasaki default: 521104470Siwasaki 522167802Sjkim ACPI_ERROR ((AE_INFO, 523204773Sjkim "Unknown Reference Class 0x%2.2X", ObjDesc->Reference.Class)); 524104470Siwasaki return_ACPI_STATUS (AE_AML_INTERNAL); 525104470Siwasaki } 526104470Siwasaki } 527104470Siwasaki 528104470Siwasaki /* 529104470Siwasaki * Now we are guaranteed to have an object that has not been created 530104470Siwasaki * via the RefOf or Index operators. 531104470Siwasaki */ 532193267Sjkim Type = ObjDesc->Common.Type; 533104470Siwasaki 534104470Siwasaki 535104470SiwasakiExit: 536104470Siwasaki /* Convert internal types to external types */ 537104470Siwasaki 538104470Siwasaki switch (Type) 539104470Siwasaki { 540107325Siwasaki case ACPI_TYPE_LOCAL_REGION_FIELD: 541107325Siwasaki case ACPI_TYPE_LOCAL_BANK_FIELD: 542107325Siwasaki case ACPI_TYPE_LOCAL_INDEX_FIELD: 543104470Siwasaki 544104470Siwasaki Type = ACPI_TYPE_FIELD_UNIT; 545104470Siwasaki break; 546104470Siwasaki 547107325Siwasaki case ACPI_TYPE_LOCAL_SCOPE: 548107325Siwasaki 549107325Siwasaki /* Per ACPI Specification, Scope is untyped */ 550107325Siwasaki 551107325Siwasaki Type = ACPI_TYPE_ANY; 552107325Siwasaki break; 553107325Siwasaki 554104470Siwasaki default: 555250838Sjkim 556104470Siwasaki /* No change to Type required */ 557250838Sjkim 558104470Siwasaki break; 559104470Siwasaki } 560104470Siwasaki 561104470Siwasaki *ReturnType = Type; 562104470Siwasaki if (ReturnDesc) 563104470Siwasaki { 564104470Siwasaki *ReturnDesc = ObjDesc; 565104470Siwasaki } 566104470Siwasaki return_ACPI_STATUS (AE_OK); 567104470Siwasaki} 568