exresolv.c revision 238381
167754Smsmith 267754Smsmith/****************************************************************************** 377424Smsmith * 467754Smsmith * Module Name: exresolv - AML Interpreter object resolution 567754Smsmith * 667754Smsmith *****************************************************************************/ 7217365Sjkim 8306536Sjkim/* 970243Smsmith * Copyright (C) 2000 - 2012, Intel Corp. 1067754Smsmith * All rights reserved. 11217365Sjkim * 12217365Sjkim * Redistribution and use in source and binary forms, with or without 13217365Sjkim * modification, are permitted provided that the following conditions 14217365Sjkim * are met: 15217365Sjkim * 1. Redistributions of source code must retain the above copyright 16217365Sjkim * notice, this list of conditions, and the following disclaimer, 17217365Sjkim * without modification. 18217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 19217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 20217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 21217365Sjkim * including a substantially similar Disclaimer requirement for further 22217365Sjkim * binary redistribution. 23217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 24217365Sjkim * of any contributors may be used to endorse or promote products derived 2567754Smsmith * from this software without specific prior written permission. 26217365Sjkim * 27217365Sjkim * Alternatively, this software may be distributed under the terms of the 28217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 2967754Smsmith * Software Foundation. 30217365Sjkim * 31217365Sjkim * NO WARRANTY 32217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 35217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 36217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 40217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 41217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 42217365Sjkim * POSSIBILITY OF SUCH DAMAGES. 4367754Smsmith */ 44193341Sjkim 45193341Sjkim#define __EXRESOLV_C__ 46193341Sjkim 47193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 48193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 49193341Sjkim#include <contrib/dev/acpica/include/amlcode.h> 5067754Smsmith#include <contrib/dev/acpica/include/acdispat.h> 5167754Smsmith#include <contrib/dev/acpica/include/acinterp.h> 5277424Smsmith#include <contrib/dev/acpica/include/acnamesp.h> 5391116Smsmith 5467754Smsmith 55151937Sjkim#define _COMPONENT ACPI_EXECUTER 5667754Smsmith ACPI_MODULE_NAME ("exresolv") 57151937Sjkim 58151937Sjkim/* Local prototypes */ 59151937Sjkim 60151937Sjkimstatic ACPI_STATUS 61151937SjkimAcpiExResolveObjectToValue ( 62151937Sjkim ACPI_OPERAND_OBJECT **StackPtr, 6367754Smsmith ACPI_WALK_STATE *WalkState); 6467754Smsmith 6577424Smsmith 6667754Smsmith/******************************************************************************* 6767754Smsmith * 6877424Smsmith * FUNCTION: AcpiExResolveToValue 6967754Smsmith * 7077424Smsmith * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can 7167754Smsmith * be either an (ACPI_OPERAND_OBJECT *) 7267754Smsmith * or an ACPI_HANDLE. 7367754Smsmith * WalkState - Current method state 7471867Smsmith * 7567754Smsmith * RETURN: Status 7667754Smsmith * 7767754Smsmith * DESCRIPTION: Convert Reference objects to values 7867754Smsmith * 7977424Smsmith ******************************************************************************/ 8067754Smsmith 8167754SmsmithACPI_STATUS 8267754SmsmithAcpiExResolveToValue ( 8377424Smsmith ACPI_OPERAND_OBJECT **StackPtr, 8467754Smsmith ACPI_WALK_STATE *WalkState) 8567754Smsmith{ 86167802Sjkim ACPI_STATUS Status; 8767754Smsmith 8867754Smsmith 8967754Smsmith ACPI_FUNCTION_TRACE_PTR (ExResolveToValue, StackPtr); 9067754Smsmith 91167802Sjkim 9267754Smsmith if (!StackPtr || !*StackPtr) 9367754Smsmith { 9467754Smsmith ACPI_ERROR ((AE_INFO, "Internal - null pointer")); 9567754Smsmith return_ACPI_STATUS (AE_AML_NO_OPERAND); 9667754Smsmith } 9767754Smsmith 9867754Smsmith /* 9967754Smsmith * The entity pointed to by the StackPtr can be either 10099679Siwasaki * 1) A valid ACPI_OPERAND_OBJECT, or 10167754Smsmith * 2) A ACPI_NAMESPACE_NODE (NamedObj) 10277424Smsmith */ 10367754Smsmith if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_OPERAND) 10467754Smsmith { 10567754Smsmith Status = AcpiExResolveObjectToValue (StackPtr, WalkState); 10667754Smsmith if (ACPI_FAILURE (Status)) 107151937Sjkim { 108151937Sjkim return_ACPI_STATUS (Status); 109151937Sjkim } 110167802Sjkim 111151937Sjkim if (!*StackPtr) 112151937Sjkim { 11367754Smsmith ACPI_ERROR ((AE_INFO, "Internal - null pointer")); 11467754Smsmith return_ACPI_STATUS (AE_AML_NO_OPERAND); 11567754Smsmith } 11677424Smsmith } 11767754Smsmith 11867754Smsmith /* 11991116Smsmith * Object on the stack may have changed if AcpiExResolveObjectToValue() 12067754Smsmith * was called (i.e., we can't use an _else_ here.) 12199679Siwasaki */ 122306536Sjkim if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED) 123306536Sjkim { 12477424Smsmith Status = AcpiExResolveNodeToValue ( 12577424Smsmith ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr), 12677424Smsmith WalkState); 12777424Smsmith if (ACPI_FAILURE (Status)) 12867754Smsmith { 12967754Smsmith return_ACPI_STATUS (Status); 13099146Siwasaki } 13177424Smsmith } 13267754Smsmith 13367754Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr)); 13467754Smsmith return_ACPI_STATUS (AE_OK); 13567754Smsmith} 13667754Smsmith 13777424Smsmith 13867754Smsmith/******************************************************************************* 139151937Sjkim * 14077424Smsmith * FUNCTION: AcpiExResolveObjectToValue 14167754Smsmith * 14267754Smsmith * PARAMETERS: StackPtr - Pointer to an internal object 14367754Smsmith * WalkState - Current method state 144151937Sjkim * 14567754Smsmith * RETURN: Status 14667754Smsmith * 14767754Smsmith * DESCRIPTION: Retrieve the value from an internal object. The Reference type 14867754Smsmith * uses the associated AML opcode to determine the value. 149151937Sjkim * 15077424Smsmith ******************************************************************************/ 15167754Smsmith 15267754Smsmithstatic ACPI_STATUS 15367754SmsmithAcpiExResolveObjectToValue ( 15477424Smsmith ACPI_OPERAND_OBJECT **StackPtr, 15567754Smsmith ACPI_WALK_STATE *WalkState) 156167802Sjkim{ 157193267Sjkim ACPI_STATUS Status = AE_OK; 15867754Smsmith ACPI_OPERAND_OBJECT *StackDesc; 15967754Smsmith ACPI_OPERAND_OBJECT *ObjDesc = NULL; 160167802Sjkim UINT8 RefType; 16167754Smsmith 16267754Smsmith 16367754Smsmith ACPI_FUNCTION_TRACE (ExResolveObjectToValue); 16467754Smsmith 165238381Sjkim 16667754Smsmith StackDesc = *StackPtr; 167193267Sjkim 16867754Smsmith /* This is an object of type ACPI_OPERAND_OBJECT */ 169107325Siwasaki 17067754Smsmith switch (StackDesc->Common.Type) 171193267Sjkim { 17267754Smsmith case ACPI_TYPE_LOCAL_REFERENCE: 173193267Sjkim 17467754Smsmith RefType = StackDesc->Reference.Class; 175193267Sjkim 176193267Sjkim switch (RefType) 17767754Smsmith { 17867754Smsmith case ACPI_REFCLASS_LOCAL: 17967754Smsmith case ACPI_REFCLASS_ARG: 18067754Smsmith 181193267Sjkim /* 182306536Sjkim * Get the local from the method's state info 18367754Smsmith * Note: this increments the local's object reference count 18467754Smsmith */ 18567754Smsmith Status = AcpiDsMethodDataGetValue (RefType, 18667754Smsmith StackDesc->Reference.Value, WalkState, &ObjDesc); 18767754Smsmith if (ACPI_FAILURE (Status)) 188129684Snjl { 189193267Sjkim return_ACPI_STATUS (Status); 190129684Snjl } 19167754Smsmith 19267754Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n", 193129684Snjl StackDesc->Reference.Value, ObjDesc)); 19467754Smsmith 19577424Smsmith /* 19667754Smsmith * Now we can delete the original Reference Object and 19767754Smsmith * replace it with the resolved value 19867754Smsmith */ 199193267Sjkim AcpiUtRemoveReference (StackDesc); 20067754Smsmith *StackPtr = ObjDesc; 20167754Smsmith break; 20267754Smsmith 20367754Smsmith 20467754Smsmith case ACPI_REFCLASS_INDEX: 205193267Sjkim 20667754Smsmith switch (StackDesc->Reference.TargetType) 20767754Smsmith { 20867754Smsmith case ACPI_TYPE_BUFFER_FIELD: 20999679Siwasaki 210193267Sjkim /* Just return - do not dereference */ 211193267Sjkim break; 212193267Sjkim 213193267Sjkim 214193267Sjkim case ACPI_TYPE_PACKAGE: 215193267Sjkim 216193267Sjkim /* If method call or CopyObject - do not dereference */ 217193267Sjkim 218193267Sjkim if ((WalkState->Opcode == AML_INT_METHODCALL_OP) || 219193267Sjkim (WalkState->Opcode == AML_COPY_OP)) 22067754Smsmith { 22167754Smsmith break; 22267754Smsmith } 22367754Smsmith 224193267Sjkim /* Otherwise, dereference the PackageIndex to a package element */ 22567754Smsmith 22667754Smsmith ObjDesc = *StackDesc->Reference.Where; 22767754Smsmith if (ObjDesc) 22877424Smsmith { 22967754Smsmith /* 23067754Smsmith * Valid object descriptor, copy pointer to return value 23167754Smsmith * (i.e., dereference the package index) 23267754Smsmith * Delete the ref object, increment the returned object 23367754Smsmith */ 234193267Sjkim AcpiUtRemoveReference (StackDesc); 23577424Smsmith AcpiUtAddReference (ObjDesc); 23667754Smsmith *StackPtr = ObjDesc; 237167802Sjkim } 238306536Sjkim else 239306536Sjkim { 24077424Smsmith /* 24167754Smsmith * A NULL object descriptor means an uninitialized element of 24267754Smsmith * the package, can't dereference it 24367754Smsmith */ 24467754Smsmith ACPI_ERROR ((AE_INFO, 24567754Smsmith "Attempt to dereference an Index to NULL package element Idx=%p", 24699679Siwasaki StackDesc)); 24777424Smsmith Status = AE_AML_UNINITIALIZED_ELEMENT; 24867754Smsmith } 249167802Sjkim break; 250204773Sjkim 25167754Smsmith 25267754Smsmith default: 25367754Smsmith 25467754Smsmith /* Invalid reference object */ 25567754Smsmith 25667754Smsmith ACPI_ERROR ((AE_INFO, 257193267Sjkim "Unknown TargetType 0x%X in Index/Reference object %p", 258193267Sjkim StackDesc->Reference.TargetType, StackDesc)); 259193267Sjkim Status = AE_AML_INTERNAL; 26067754Smsmith break; 261193267Sjkim } 262100966Siwasaki break; 26367754Smsmith 26467754Smsmith 265193267Sjkim case ACPI_REFCLASS_REFOF: 26667754Smsmith case ACPI_REFCLASS_DEBUG: 267167802Sjkim case ACPI_REFCLASS_TABLE: 268151937Sjkim 269167802Sjkim /* Just leave the object as-is, do not dereference */ 270167802Sjkim 271167802Sjkim break; 272167802Sjkim 273167802Sjkim case ACPI_REFCLASS_NAME: /* Reference to a named object */ 274167802Sjkim 275167802Sjkim /* Dereference the name */ 276167802Sjkim 277167802Sjkim if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) || 278167802Sjkim (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL)) 279167802Sjkim { 280167802Sjkim /* These node types do not have 'real' subobjects */ 281167802Sjkim 282167802Sjkim *StackPtr = (void *) StackDesc->Reference.Node; 283167802Sjkim } 284151937Sjkim else 285151937Sjkim { 286151937Sjkim /* Get the object pointed to by the namespace node */ 28767754Smsmith 28867754Smsmith *StackPtr = (StackDesc->Reference.Node)->Object; 289167802Sjkim AcpiUtAddReference (*StackPtr); 290306536Sjkim } 291306536Sjkim 29267754Smsmith AcpiUtRemoveReference (StackDesc); 29377424Smsmith break; 29499679Siwasaki 29599679Siwasaki default: 29667754Smsmith 29799146Siwasaki ACPI_ERROR ((AE_INFO, 29899146Siwasaki "Unknown Reference type 0x%X in %p", RefType, StackDesc)); 29999146Siwasaki Status = AE_AML_INTERNAL; 30099146Siwasaki break; 30199146Siwasaki } 30299146Siwasaki break; 30399146Siwasaki 30499146Siwasaki 30599146Siwasaki case ACPI_TYPE_BUFFER: 30699146Siwasaki 30777424Smsmith Status = AcpiDsGetBufferArguments (StackDesc); 308107325Siwasaki break; 309107325Siwasaki 310107325Siwasaki 31167754Smsmith case ACPI_TYPE_PACKAGE: 312306536Sjkim 313306536Sjkim Status = AcpiDsGetPackageArguments (StackDesc); 314193267Sjkim break; 31567754Smsmith 31699146Siwasaki 317167802Sjkim case ACPI_TYPE_BUFFER_FIELD: 318167802Sjkim case ACPI_TYPE_LOCAL_REGION_FIELD: 319167802Sjkim case ACPI_TYPE_LOCAL_BANK_FIELD: 320167802Sjkim case ACPI_TYPE_LOCAL_INDEX_FIELD: 32167754Smsmith 32267754Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n", 32367754Smsmith StackDesc, StackDesc->Common.Type)); 32467754Smsmith 325250838Sjkim Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc); 32667754Smsmith 32787031Smsmith /* Remove a reference to the original operand, then override */ 32867754Smsmith 32967754Smsmith AcpiUtRemoveReference (*StackPtr); 33067754Smsmith *StackPtr = (void *) ObjDesc; 33167754Smsmith break; 33267754Smsmith 333104470Siwasaki default: 334104470Siwasaki break; 335104470Siwasaki } 336104470Siwasaki 337104470Siwasaki return_ACPI_STATUS (Status); 338104470Siwasaki} 339104470Siwasaki 340104470Siwasaki 341104470Siwasaki/******************************************************************************* 342104470Siwasaki * 343104470Siwasaki * FUNCTION: AcpiExResolveMultiple 344241973Sjkim * 345104470Siwasaki * PARAMETERS: WalkState - Current state (contains AML opcode) 346104470Siwasaki * Operand - Starting point for resolution 347104470Siwasaki * ReturnType - Where the object type is returned 348104470Siwasaki * ReturnDesc - Where the resolved object is returned 349104470Siwasaki * 350104470Siwasaki * RETURN: Status 351104470Siwasaki * 352104470Siwasaki * DESCRIPTION: Return the base object and type. Traverse a reference list if 353104470Siwasaki * necessary to get to the base object. 354104470Siwasaki * 355104470Siwasaki ******************************************************************************/ 356306536Sjkim 357306536SjkimACPI_STATUS 358104470SiwasakiAcpiExResolveMultiple ( 359138287Smarks ACPI_WALK_STATE *WalkState, 360104470Siwasaki ACPI_OPERAND_OBJECT *Operand, 361104470Siwasaki ACPI_OBJECT_TYPE *ReturnType, 362167802Sjkim ACPI_OPERAND_OBJECT **ReturnDesc) 363104470Siwasaki{ 364104470Siwasaki ACPI_OPERAND_OBJECT *ObjDesc = (void *) Operand; 365151937Sjkim ACPI_NAMESPACE_NODE *Node; 366138287Smarks ACPI_OBJECT_TYPE Type; 367138287Smarks ACPI_STATUS Status; 368138287Smarks 369138287Smarks 370250838Sjkim ACPI_FUNCTION_TRACE (AcpiExResolveMultiple); 371138287Smarks 372138287Smarks 373138287Smarks /* Operand can be either a namespace node or an operand descriptor */ 374138287Smarks 375250838Sjkim switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) 376138287Smarks { 377306536Sjkim case ACPI_DESC_TYPE_OPERAND: 378138287Smarks Type = ObjDesc->Common.Type; 379138287Smarks break; 380138287Smarks 381138287Smarks case ACPI_DESC_TYPE_NAMED: 382138287Smarks Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; 383138287Smarks ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); 384306536Sjkim 385306536Sjkim /* If we had an Alias node, use the attached object for type info */ 386138287Smarks 387306536Sjkim if (Type == ACPI_TYPE_LOCAL_ALIAS) 388306536Sjkim { 389306536Sjkim Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; 390306536Sjkim ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); 391306536Sjkim } 392306536Sjkim break; 393306536Sjkim 394306536Sjkim default: 395138287Smarks return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 396138287Smarks } 397138287Smarks 398138287Smarks /* If type is anything other than a reference, we are done */ 399138287Smarks 400138287Smarks if (Type != ACPI_TYPE_LOCAL_REFERENCE) 401151937Sjkim { 402138287Smarks goto Exit; 403138287Smarks } 404138287Smarks 405138287Smarks /* 406138287Smarks * For reference objects created via the RefOf, Index, or Load/LoadTable 407138287Smarks * operators, we need to get to the base object (as per the ACPI 408138287Smarks * specification of the ObjectType and SizeOf operators). This means 409193267Sjkim * traversing the list of possibly many nested references. 410193267Sjkim */ 411193267Sjkim while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) 412193267Sjkim { 413104470Siwasaki switch (ObjDesc->Reference.Class) 414193267Sjkim { 415104470Siwasaki case ACPI_REFCLASS_REFOF: 416193267Sjkim case ACPI_REFCLASS_NAME: 417104470Siwasaki 418193267Sjkim /* Dereference the reference pointer */ 419193267Sjkim 420104470Siwasaki if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF) 421104470Siwasaki { 422104470Siwasaki Node = ObjDesc->Reference.Object; 423193267Sjkim } 424167802Sjkim else /* AML_INT_NAMEPATH_OP */ 425167802Sjkim { 426167802Sjkim Node = ObjDesc->Reference.Node; 427167802Sjkim } 428167802Sjkim 429167802Sjkim /* All "References" point to a NS node */ 430167802Sjkim 431104470Siwasaki if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 432104470Siwasaki { 433104470Siwasaki ACPI_ERROR ((AE_INFO, 434104470Siwasaki "Not a namespace node %p [%s]", 435104470Siwasaki Node, AcpiUtGetDescriptorName (Node))); 436167802Sjkim return_ACPI_STATUS (AE_AML_INTERNAL); 437204773Sjkim } 438151937Sjkim 439104470Siwasaki /* Get the attached object */ 440104470Siwasaki 441104470Siwasaki ObjDesc = AcpiNsGetAttachedObject (Node); 442104470Siwasaki if (!ObjDesc) 443104470Siwasaki { 444104470Siwasaki /* No object, use the NS node type */ 445104470Siwasaki 446104470Siwasaki Type = AcpiNsGetType (Node); 447104470Siwasaki goto Exit; 448104470Siwasaki } 449104470Siwasaki 450104470Siwasaki /* Check for circular references */ 451104470Siwasaki 452104470Siwasaki if (ObjDesc == Operand) 453104470Siwasaki { 454104470Siwasaki return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); 455104470Siwasaki } 456104470Siwasaki break; 457104470Siwasaki 458104470Siwasaki 459104470Siwasaki case ACPI_REFCLASS_INDEX: 460104470Siwasaki 461193267Sjkim /* Get the type of this reference (index into another object) */ 462104470Siwasaki 463104470Siwasaki Type = ObjDesc->Reference.TargetType; 464104470Siwasaki if (Type != ACPI_TYPE_PACKAGE) 465104470Siwasaki { 466104470Siwasaki goto Exit; 467104470Siwasaki } 468104470Siwasaki 469104470Siwasaki /* 470104470Siwasaki * The main object is a package, we want to get the type 471104470Siwasaki * of the individual package element that is referenced by 472104470Siwasaki * the index. 473104470Siwasaki * 474104470Siwasaki * This could of course in turn be another reference object. 475104470Siwasaki */ 476104470Siwasaki ObjDesc = *(ObjDesc->Reference.Where); 477104470Siwasaki if (!ObjDesc) 478104470Siwasaki { 479151937Sjkim /* NULL package elements are allowed */ 480151937Sjkim 481151937Sjkim Type = 0; /* Uninitialized */ 482151937Sjkim goto Exit; 483151937Sjkim } 484151937Sjkim break; 485151937Sjkim 486104470Siwasaki 487104470Siwasaki case ACPI_REFCLASS_TABLE: 488193267Sjkim 489138287Smarks Type = ACPI_TYPE_DDB_HANDLE; 490193267Sjkim goto Exit; 491193267Sjkim 492193267Sjkim 493193267Sjkim case ACPI_REFCLASS_LOCAL: 494193267Sjkim case ACPI_REFCLASS_ARG: 495193267Sjkim 496138287Smarks if (ReturnDesc) 497138287Smarks { 498193267Sjkim Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class, 499306536Sjkim ObjDesc->Reference.Value, WalkState, &ObjDesc); 500138287Smarks if (ACPI_FAILURE (Status)) 501138287Smarks { 502138287Smarks return_ACPI_STATUS (Status); 503138287Smarks } 504138287Smarks AcpiUtRemoveReference (ObjDesc); 505138287Smarks } 506138287Smarks else 507138287Smarks { 508193267Sjkim Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class, 509306536Sjkim ObjDesc->Reference.Value, WalkState, &Node); 510138287Smarks if (ACPI_FAILURE (Status)) 511138287Smarks { 512138287Smarks return_ACPI_STATUS (Status); 513138287Smarks } 514138287Smarks 515138287Smarks ObjDesc = AcpiNsGetAttachedObject (Node); 516138287Smarks if (!ObjDesc) 517138287Smarks { 518138287Smarks Type = ACPI_TYPE_ANY; 519138287Smarks goto Exit; 520138287Smarks } 521138287Smarks } 522138287Smarks break; 523138287Smarks 524193267Sjkim 525104470Siwasaki case ACPI_REFCLASS_DEBUG: 526104470Siwasaki 527104470Siwasaki /* The Debug Object is of type "DebugObject" */ 528104470Siwasaki 529104470Siwasaki Type = ACPI_TYPE_DEBUG_OBJECT; 530104470Siwasaki goto Exit; 531104470Siwasaki 532104470Siwasaki 533167802Sjkim default: 534306536Sjkim 535306536Sjkim ACPI_ERROR ((AE_INFO, 536104470Siwasaki "Unknown Reference Class 0x%2.2X", ObjDesc->Reference.Class)); 537104470Siwasaki return_ACPI_STATUS (AE_AML_INTERNAL); 538104470Siwasaki } 539104470Siwasaki } 540104470Siwasaki 541104470Siwasaki /* 542104470Siwasaki * Now we are guaranteed to have an object that has not been created 543104470Siwasaki * via the RefOf or Index operators. 544193267Sjkim */ 545104470Siwasaki Type = ObjDesc->Common.Type; 546104470Siwasaki 547104470Siwasaki 548104470SiwasakiExit: 549104470Siwasaki /* Convert internal types to external types */ 550104470Siwasaki 551104470Siwasaki switch (Type) 552107325Siwasaki { 553107325Siwasaki case ACPI_TYPE_LOCAL_REGION_FIELD: 554107325Siwasaki case ACPI_TYPE_LOCAL_BANK_FIELD: 555104470Siwasaki case ACPI_TYPE_LOCAL_INDEX_FIELD: 556104470Siwasaki 557104470Siwasaki Type = ACPI_TYPE_FIELD_UNIT; 558104470Siwasaki break; 559107325Siwasaki 560107325Siwasaki case ACPI_TYPE_LOCAL_SCOPE: 561107325Siwasaki 562107325Siwasaki /* Per ACPI Specification, Scope is untyped */ 563107325Siwasaki 564107325Siwasaki Type = ACPI_TYPE_ANY; 565107325Siwasaki break; 566104470Siwasaki 567250838Sjkim default: 568104470Siwasaki /* No change to Type required */ 569250838Sjkim break; 570104470Siwasaki } 571104470Siwasaki 572104470Siwasaki *ReturnType = Type; 573104470Siwasaki if (ReturnDesc) 574104470Siwasaki { 575104470Siwasaki *ReturnDesc = ObjDesc; 576104470Siwasaki } 577104470Siwasaki return_ACPI_STATUS (AE_OK); 578104470Siwasaki} 579104470Siwasaki 580 581