exresolv.c revision 250838
167754Smsmith/****************************************************************************** 267754Smsmith * 377424Smsmith * Module Name: exresolv - AML Interpreter object resolution 467754Smsmith * 567754Smsmith *****************************************************************************/ 667754Smsmith 7217365Sjkim/* 8245582Sjkim * Copyright (C) 2000 - 2013, 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 4477424Smsmith#define __EXRESOLV_C__ 4567754Smsmith 46193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 47193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 48193341Sjkim#include <contrib/dev/acpica/include/amlcode.h> 49193341Sjkim#include <contrib/dev/acpica/include/acdispat.h> 50193341Sjkim#include <contrib/dev/acpica/include/acinterp.h> 51193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h> 5267754Smsmith 5367754Smsmith 5477424Smsmith#define _COMPONENT ACPI_EXECUTER 5591116Smsmith ACPI_MODULE_NAME ("exresolv") 5667754Smsmith 57151937Sjkim/* Local prototypes */ 5867754Smsmith 59151937Sjkimstatic ACPI_STATUS 60151937SjkimAcpiExResolveObjectToValue ( 61151937Sjkim ACPI_OPERAND_OBJECT **StackPtr, 62151937Sjkim ACPI_WALK_STATE *WalkState); 63151937Sjkim 64151937Sjkim 6567754Smsmith/******************************************************************************* 6667754Smsmith * 6777424Smsmith * FUNCTION: AcpiExResolveToValue 6867754Smsmith * 6967754Smsmith * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can 7077424Smsmith * be either an (ACPI_OPERAND_OBJECT *) 7167754Smsmith * or an ACPI_HANDLE. 7277424Smsmith * WalkState - Current method state 7367754Smsmith * 7467754Smsmith * RETURN: Status 7567754Smsmith * 7671867Smsmith * DESCRIPTION: Convert Reference objects to values 7767754Smsmith * 7867754Smsmith ******************************************************************************/ 7967754Smsmith 8067754SmsmithACPI_STATUS 8177424SmsmithAcpiExResolveToValue ( 8267754Smsmith ACPI_OPERAND_OBJECT **StackPtr, 8367754Smsmith ACPI_WALK_STATE *WalkState) 8467754Smsmith{ 8577424Smsmith ACPI_STATUS Status; 8667754Smsmith 8767754Smsmith 88167802Sjkim ACPI_FUNCTION_TRACE_PTR (ExResolveToValue, StackPtr); 8967754Smsmith 9067754Smsmith 9167754Smsmith if (!StackPtr || !*StackPtr) 9267754Smsmith { 93167802Sjkim ACPI_ERROR ((AE_INFO, "Internal - null pointer")); 9467754Smsmith return_ACPI_STATUS (AE_AML_NO_OPERAND); 9567754Smsmith } 9667754Smsmith 9767754Smsmith /* 9867754Smsmith * The entity pointed to by the StackPtr can be either 9967754Smsmith * 1) A valid ACPI_OPERAND_OBJECT, or 10067754Smsmith * 2) A ACPI_NAMESPACE_NODE (NamedObj) 10167754Smsmith */ 10299679Siwasaki if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_OPERAND) 10367754Smsmith { 10477424Smsmith Status = AcpiExResolveObjectToValue (StackPtr, WalkState); 10567754Smsmith if (ACPI_FAILURE (Status)) 10667754Smsmith { 10767754Smsmith return_ACPI_STATUS (Status); 10867754Smsmith } 109151937Sjkim 110151937Sjkim if (!*StackPtr) 111151937Sjkim { 112167802Sjkim ACPI_ERROR ((AE_INFO, "Internal - null pointer")); 113151937Sjkim return_ACPI_STATUS (AE_AML_NO_OPERAND); 114151937Sjkim } 11567754Smsmith } 11667754Smsmith 11767754Smsmith /* 11877424Smsmith * Object on the stack may have changed if AcpiExResolveObjectToValue() 11967754Smsmith * was called (i.e., we can't use an _else_ here.) 12067754Smsmith */ 12191116Smsmith if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED) 12267754Smsmith { 12399679Siwasaki Status = AcpiExResolveNodeToValue ( 12499679Siwasaki ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr), 12577424Smsmith WalkState); 12677424Smsmith if (ACPI_FAILURE (Status)) 12777424Smsmith { 12877424Smsmith return_ACPI_STATUS (Status); 12977424Smsmith } 13067754Smsmith } 13167754Smsmith 13299146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr)); 13377424Smsmith return_ACPI_STATUS (AE_OK); 13467754Smsmith} 13567754Smsmith 13667754Smsmith 13767754Smsmith/******************************************************************************* 13867754Smsmith * 13977424Smsmith * FUNCTION: AcpiExResolveObjectToValue 14067754Smsmith * 141151937Sjkim * PARAMETERS: StackPtr - Pointer to an internal object 14277424Smsmith * WalkState - Current method state 14367754Smsmith * 14467754Smsmith * RETURN: Status 14567754Smsmith * 146151937Sjkim * DESCRIPTION: Retrieve the value from an internal object. The Reference type 14767754Smsmith * uses the associated AML opcode to determine the value. 14867754Smsmith * 14967754Smsmith ******************************************************************************/ 15067754Smsmith 151151937Sjkimstatic ACPI_STATUS 15277424SmsmithAcpiExResolveObjectToValue ( 15367754Smsmith ACPI_OPERAND_OBJECT **StackPtr, 15467754Smsmith ACPI_WALK_STATE *WalkState) 15567754Smsmith{ 15677424Smsmith ACPI_STATUS Status = AE_OK; 15767754Smsmith ACPI_OPERAND_OBJECT *StackDesc; 158167802Sjkim ACPI_OPERAND_OBJECT *ObjDesc = NULL; 159193267Sjkim UINT8 RefType; 16067754Smsmith 16167754Smsmith 162167802Sjkim ACPI_FUNCTION_TRACE (ExResolveObjectToValue); 16367754Smsmith 16467754Smsmith 16567754Smsmith StackDesc = *StackPtr; 16667754Smsmith 167238381Sjkim /* This is an object of type ACPI_OPERAND_OBJECT */ 16867754Smsmith 169193267Sjkim switch (StackDesc->Common.Type) 17067754Smsmith { 171107325Siwasaki case ACPI_TYPE_LOCAL_REFERENCE: 17267754Smsmith 173193267Sjkim RefType = StackDesc->Reference.Class; 17467754Smsmith 175193267Sjkim switch (RefType) 17667754Smsmith { 177193267Sjkim case ACPI_REFCLASS_LOCAL: 178193267Sjkim case ACPI_REFCLASS_ARG: 17967754Smsmith /* 18067754Smsmith * Get the local from the method's state info 18167754Smsmith * Note: this increments the local's object reference count 18267754Smsmith */ 183193267Sjkim Status = AcpiDsMethodDataGetValue (RefType, 184193267Sjkim StackDesc->Reference.Value, WalkState, &ObjDesc); 18567754Smsmith if (ACPI_FAILURE (Status)) 18667754Smsmith { 18767754Smsmith return_ACPI_STATUS (Status); 18867754Smsmith } 18967754Smsmith 190129684Snjl ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n", 191193267Sjkim StackDesc->Reference.Value, ObjDesc)); 192129684Snjl 19367754Smsmith /* 19467754Smsmith * Now we can delete the original Reference Object and 195129684Snjl * replace it with the resolved value 19667754Smsmith */ 19777424Smsmith AcpiUtRemoveReference (StackDesc); 19867754Smsmith *StackPtr = ObjDesc; 19967754Smsmith break; 20067754Smsmith 201193267Sjkim case ACPI_REFCLASS_INDEX: 20267754Smsmith 20367754Smsmith switch (StackDesc->Reference.TargetType) 20467754Smsmith { 20567754Smsmith case ACPI_TYPE_BUFFER_FIELD: 20667754Smsmith 207193267Sjkim /* Just return - do not dereference */ 20867754Smsmith break; 20967754Smsmith 21067754Smsmith case ACPI_TYPE_PACKAGE: 21199679Siwasaki 212193267Sjkim /* If method call or CopyObject - do not dereference */ 213193267Sjkim 214193267Sjkim if ((WalkState->Opcode == AML_INT_METHODCALL_OP) || 215193267Sjkim (WalkState->Opcode == AML_COPY_OP)) 216193267Sjkim { 217193267Sjkim break; 218193267Sjkim } 219193267Sjkim 220193267Sjkim /* Otherwise, dereference the PackageIndex to a package element */ 221193267Sjkim 22267754Smsmith ObjDesc = *StackDesc->Reference.Where; 22367754Smsmith if (ObjDesc) 22467754Smsmith { 22567754Smsmith /* 226193267Sjkim * Valid object descriptor, copy pointer to return value 22767754Smsmith * (i.e., dereference the package index) 22867754Smsmith * Delete the ref object, increment the returned object 22967754Smsmith */ 23077424Smsmith AcpiUtRemoveReference (StackDesc); 23177424Smsmith AcpiUtAddReference (ObjDesc); 23267754Smsmith *StackPtr = ObjDesc; 23367754Smsmith } 23467754Smsmith else 23567754Smsmith { 23667754Smsmith /* 237193267Sjkim * A NULL object descriptor means an uninitialized element of 23877424Smsmith * the package, can't dereference it 23967754Smsmith */ 240167802Sjkim ACPI_ERROR ((AE_INFO, 241193267Sjkim "Attempt to dereference an Index to NULL package element Idx=%p", 24277424Smsmith StackDesc)); 24367754Smsmith Status = AE_AML_UNINITIALIZED_ELEMENT; 24467754Smsmith } 24567754Smsmith break; 24667754Smsmith 24767754Smsmith default: 24899679Siwasaki 24977424Smsmith /* Invalid reference object */ 25067754Smsmith 251167802Sjkim ACPI_ERROR ((AE_INFO, 252204773Sjkim "Unknown TargetType 0x%X in Index/Reference object %p", 25367754Smsmith StackDesc->Reference.TargetType, StackDesc)); 25467754Smsmith Status = AE_AML_INTERNAL; 25567754Smsmith break; 25667754Smsmith } 25767754Smsmith break; 25867754Smsmith 259193267Sjkim case ACPI_REFCLASS_REFOF: 260193267Sjkim case ACPI_REFCLASS_DEBUG: 261193267Sjkim case ACPI_REFCLASS_TABLE: 26267754Smsmith 263193267Sjkim /* Just leave the object as-is, do not dereference */ 264100966Siwasaki 26567754Smsmith break; 26667754Smsmith 267193267Sjkim case ACPI_REFCLASS_NAME: /* Reference to a named object */ 26867754Smsmith 269167802Sjkim /* Dereference the name */ 270151937Sjkim 271167802Sjkim if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) || 272167802Sjkim (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL)) 273167802Sjkim { 274167802Sjkim /* These node types do not have 'real' subobjects */ 275167802Sjkim 276167802Sjkim *StackPtr = (void *) StackDesc->Reference.Node; 277167802Sjkim } 278167802Sjkim else 279167802Sjkim { 280167802Sjkim /* Get the object pointed to by the namespace node */ 281167802Sjkim 282167802Sjkim *StackPtr = (StackDesc->Reference.Node)->Object; 283167802Sjkim AcpiUtAddReference (*StackPtr); 284167802Sjkim } 285167802Sjkim 286151937Sjkim AcpiUtRemoveReference (StackDesc); 287151937Sjkim break; 288151937Sjkim 28967754Smsmith default: 29067754Smsmith 291167802Sjkim ACPI_ERROR ((AE_INFO, 292204773Sjkim "Unknown Reference type 0x%X in %p", RefType, StackDesc)); 29367754Smsmith Status = AE_AML_INTERNAL; 29477424Smsmith break; 29599679Siwasaki } 29699679Siwasaki break; 29767754Smsmith 29899146Siwasaki case ACPI_TYPE_BUFFER: 29999146Siwasaki 30099146Siwasaki Status = AcpiDsGetBufferArguments (StackDesc); 30199146Siwasaki break; 30299146Siwasaki 30399146Siwasaki case ACPI_TYPE_PACKAGE: 30499146Siwasaki 30599146Siwasaki Status = AcpiDsGetPackageArguments (StackDesc); 30699146Siwasaki break; 30799146Siwasaki 30877424Smsmith case ACPI_TYPE_BUFFER_FIELD: 309107325Siwasaki case ACPI_TYPE_LOCAL_REGION_FIELD: 310107325Siwasaki case ACPI_TYPE_LOCAL_BANK_FIELD: 311107325Siwasaki case ACPI_TYPE_LOCAL_INDEX_FIELD: 31267754Smsmith 31387031Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n", 314193267Sjkim StackDesc, StackDesc->Common.Type)); 31567754Smsmith 31699146Siwasaki Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc); 317167802Sjkim 318167802Sjkim /* Remove a reference to the original operand, then override */ 319167802Sjkim 320167802Sjkim AcpiUtRemoveReference (*StackPtr); 32167754Smsmith *StackPtr = (void *) ObjDesc; 32267754Smsmith break; 32367754Smsmith 32467754Smsmith default: 325250838Sjkim 32667754Smsmith break; 32787031Smsmith } 32867754Smsmith 32967754Smsmith return_ACPI_STATUS (Status); 33067754Smsmith} 33167754Smsmith 33267754Smsmith 333104470Siwasaki/******************************************************************************* 334104470Siwasaki * 335104470Siwasaki * FUNCTION: AcpiExResolveMultiple 336104470Siwasaki * 337104470Siwasaki * PARAMETERS: WalkState - Current state (contains AML opcode) 338104470Siwasaki * Operand - Starting point for resolution 339104470Siwasaki * ReturnType - Where the object type is returned 340104470Siwasaki * ReturnDesc - Where the resolved object is returned 341104470Siwasaki * 342104470Siwasaki * RETURN: Status 343104470Siwasaki * 344241973Sjkim * DESCRIPTION: Return the base object and type. Traverse a reference list if 345104470Siwasaki * necessary to get to the base object. 346104470Siwasaki * 347104470Siwasaki ******************************************************************************/ 348104470Siwasaki 349104470SiwasakiACPI_STATUS 350104470SiwasakiAcpiExResolveMultiple ( 351104470Siwasaki ACPI_WALK_STATE *WalkState, 352104470Siwasaki ACPI_OPERAND_OBJECT *Operand, 353104470Siwasaki ACPI_OBJECT_TYPE *ReturnType, 354104470Siwasaki ACPI_OPERAND_OBJECT **ReturnDesc) 355104470Siwasaki{ 356104470Siwasaki ACPI_OPERAND_OBJECT *ObjDesc = (void *) Operand; 357104470Siwasaki ACPI_NAMESPACE_NODE *Node; 358104470Siwasaki ACPI_OBJECT_TYPE Type; 359138287Smarks ACPI_STATUS Status; 360104470Siwasaki 361104470Siwasaki 362167802Sjkim ACPI_FUNCTION_TRACE (AcpiExResolveMultiple); 363104470Siwasaki 364104470Siwasaki 365151937Sjkim /* Operand can be either a namespace node or an operand descriptor */ 366138287Smarks 367138287Smarks switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) 368138287Smarks { 369138287Smarks case ACPI_DESC_TYPE_OPERAND: 370250838Sjkim 371138287Smarks Type = ObjDesc->Common.Type; 372138287Smarks break; 373138287Smarks 374138287Smarks case ACPI_DESC_TYPE_NAMED: 375250838Sjkim 376138287Smarks Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; 377138287Smarks ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); 378138287Smarks 379138287Smarks /* If we had an Alias node, use the attached object for type info */ 380138287Smarks 381138287Smarks if (Type == ACPI_TYPE_LOCAL_ALIAS) 382138287Smarks { 383138287Smarks Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; 384138287Smarks ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); 385138287Smarks } 386138287Smarks break; 387138287Smarks 388138287Smarks default: 389138287Smarks return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 390138287Smarks } 391138287Smarks 392151937Sjkim /* If type is anything other than a reference, we are done */ 393138287Smarks 394138287Smarks if (Type != ACPI_TYPE_LOCAL_REFERENCE) 395138287Smarks { 396138287Smarks goto Exit; 397138287Smarks } 398138287Smarks 399138287Smarks /* 400193267Sjkim * For reference objects created via the RefOf, Index, or Load/LoadTable 401193267Sjkim * operators, we need to get to the base object (as per the ACPI 402193267Sjkim * specification of the ObjectType and SizeOf operators). This means 403193267Sjkim * traversing the list of possibly many nested references. 404104470Siwasaki */ 405193267Sjkim while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) 406104470Siwasaki { 407193267Sjkim switch (ObjDesc->Reference.Class) 408104470Siwasaki { 409193267Sjkim case ACPI_REFCLASS_REFOF: 410193267Sjkim case ACPI_REFCLASS_NAME: 411104470Siwasaki 412104470Siwasaki /* Dereference the reference pointer */ 413104470Siwasaki 414193267Sjkim if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF) 415167802Sjkim { 416167802Sjkim Node = ObjDesc->Reference.Object; 417167802Sjkim } 418167802Sjkim else /* AML_INT_NAMEPATH_OP */ 419167802Sjkim { 420167802Sjkim Node = ObjDesc->Reference.Node; 421167802Sjkim } 422104470Siwasaki 423104470Siwasaki /* All "References" point to a NS node */ 424104470Siwasaki 425104470Siwasaki if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 426104470Siwasaki { 427167802Sjkim ACPI_ERROR ((AE_INFO, 428204773Sjkim "Not a namespace node %p [%s]", 429151937Sjkim Node, AcpiUtGetDescriptorName (Node))); 430104470Siwasaki return_ACPI_STATUS (AE_AML_INTERNAL); 431104470Siwasaki } 432104470Siwasaki 433104470Siwasaki /* Get the attached object */ 434104470Siwasaki 435104470Siwasaki ObjDesc = AcpiNsGetAttachedObject (Node); 436104470Siwasaki if (!ObjDesc) 437104470Siwasaki { 438104470Siwasaki /* No object, use the NS node type */ 439104470Siwasaki 440104470Siwasaki Type = AcpiNsGetType (Node); 441104470Siwasaki goto Exit; 442104470Siwasaki } 443104470Siwasaki 444104470Siwasaki /* Check for circular references */ 445104470Siwasaki 446104470Siwasaki if (ObjDesc == Operand) 447104470Siwasaki { 448104470Siwasaki return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); 449104470Siwasaki } 450104470Siwasaki break; 451104470Siwasaki 452193267Sjkim case ACPI_REFCLASS_INDEX: 453104470Siwasaki 454104470Siwasaki /* Get the type of this reference (index into another object) */ 455104470Siwasaki 456104470Siwasaki Type = ObjDesc->Reference.TargetType; 457104470Siwasaki if (Type != ACPI_TYPE_PACKAGE) 458104470Siwasaki { 459104470Siwasaki goto Exit; 460104470Siwasaki } 461104470Siwasaki 462104470Siwasaki /* 463104470Siwasaki * The main object is a package, we want to get the type 464104470Siwasaki * of the individual package element that is referenced by 465104470Siwasaki * the index. 466104470Siwasaki * 467104470Siwasaki * This could of course in turn be another reference object. 468104470Siwasaki */ 469104470Siwasaki ObjDesc = *(ObjDesc->Reference.Where); 470151937Sjkim if (!ObjDesc) 471151937Sjkim { 472151937Sjkim /* NULL package elements are allowed */ 473151937Sjkim 474151937Sjkim Type = 0; /* Uninitialized */ 475151937Sjkim goto Exit; 476151937Sjkim } 477104470Siwasaki break; 478104470Siwasaki 479193267Sjkim case ACPI_REFCLASS_TABLE: 480138287Smarks 481193267Sjkim Type = ACPI_TYPE_DDB_HANDLE; 482193267Sjkim goto Exit; 483193267Sjkim 484193267Sjkim case ACPI_REFCLASS_LOCAL: 485193267Sjkim case ACPI_REFCLASS_ARG: 486193267Sjkim 487138287Smarks if (ReturnDesc) 488138287Smarks { 489193267Sjkim Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class, 490193267Sjkim ObjDesc->Reference.Value, WalkState, &ObjDesc); 491138287Smarks if (ACPI_FAILURE (Status)) 492138287Smarks { 493138287Smarks return_ACPI_STATUS (Status); 494138287Smarks } 495138287Smarks AcpiUtRemoveReference (ObjDesc); 496138287Smarks } 497138287Smarks else 498138287Smarks { 499193267Sjkim Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class, 500193267Sjkim ObjDesc->Reference.Value, WalkState, &Node); 501138287Smarks if (ACPI_FAILURE (Status)) 502138287Smarks { 503138287Smarks return_ACPI_STATUS (Status); 504138287Smarks } 505138287Smarks 506138287Smarks ObjDesc = AcpiNsGetAttachedObject (Node); 507138287Smarks if (!ObjDesc) 508138287Smarks { 509138287Smarks Type = ACPI_TYPE_ANY; 510138287Smarks goto Exit; 511138287Smarks } 512138287Smarks } 513138287Smarks break; 514138287Smarks 515193267Sjkim case ACPI_REFCLASS_DEBUG: 516104470Siwasaki 517104470Siwasaki /* The Debug Object is of type "DebugObject" */ 518104470Siwasaki 519104470Siwasaki Type = ACPI_TYPE_DEBUG_OBJECT; 520104470Siwasaki goto Exit; 521104470Siwasaki 522104470Siwasaki default: 523104470Siwasaki 524167802Sjkim ACPI_ERROR ((AE_INFO, 525204773Sjkim "Unknown Reference Class 0x%2.2X", ObjDesc->Reference.Class)); 526104470Siwasaki return_ACPI_STATUS (AE_AML_INTERNAL); 527104470Siwasaki } 528104470Siwasaki } 529104470Siwasaki 530104470Siwasaki /* 531104470Siwasaki * Now we are guaranteed to have an object that has not been created 532104470Siwasaki * via the RefOf or Index operators. 533104470Siwasaki */ 534193267Sjkim Type = ObjDesc->Common.Type; 535104470Siwasaki 536104470Siwasaki 537104470SiwasakiExit: 538104470Siwasaki /* Convert internal types to external types */ 539104470Siwasaki 540104470Siwasaki switch (Type) 541104470Siwasaki { 542107325Siwasaki case ACPI_TYPE_LOCAL_REGION_FIELD: 543107325Siwasaki case ACPI_TYPE_LOCAL_BANK_FIELD: 544107325Siwasaki case ACPI_TYPE_LOCAL_INDEX_FIELD: 545104470Siwasaki 546104470Siwasaki Type = ACPI_TYPE_FIELD_UNIT; 547104470Siwasaki break; 548104470Siwasaki 549107325Siwasaki case ACPI_TYPE_LOCAL_SCOPE: 550107325Siwasaki 551107325Siwasaki /* Per ACPI Specification, Scope is untyped */ 552107325Siwasaki 553107325Siwasaki Type = ACPI_TYPE_ANY; 554107325Siwasaki break; 555107325Siwasaki 556104470Siwasaki default: 557250838Sjkim 558104470Siwasaki /* No change to Type required */ 559250838Sjkim 560104470Siwasaki break; 561104470Siwasaki } 562104470Siwasaki 563104470Siwasaki *ReturnType = Type; 564104470Siwasaki if (ReturnDesc) 565104470Siwasaki { 566104470Siwasaki *ReturnDesc = ObjDesc; 567104470Siwasaki } 568104470Siwasaki return_ACPI_STATUS (AE_OK); 569104470Siwasaki} 570