167754Smsmith/****************************************************************************** 267754Smsmith * 377424Smsmith * Module Name: exresolv - AML Interpreter object resolution 467754Smsmith * 567754Smsmith *****************************************************************************/ 667754Smsmith 7217365Sjkim/* 8306536Sjkim * Copyright (C) 2000 - 2016, 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 ( 122306536Sjkim ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr), 123306536Sjkim 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, 182306536Sjkim 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 AcpiUtAddReference (ObjDesc); 22967754Smsmith *StackPtr = ObjDesc; 23067754Smsmith } 23167754Smsmith else 23267754Smsmith { 23367754Smsmith /* 234193267Sjkim * A NULL object descriptor means an uninitialized element of 23577424Smsmith * the package, can't dereference it 23667754Smsmith */ 237167802Sjkim ACPI_ERROR ((AE_INFO, 238306536Sjkim "Attempt to dereference an Index to " 239306536Sjkim "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, 290306536Sjkim "Unknown Reference type 0x%X in %p", 291306536Sjkim RefType, StackDesc)); 29267754Smsmith Status = AE_AML_INTERNAL; 29377424Smsmith break; 29499679Siwasaki } 29599679Siwasaki break; 29667754Smsmith 29799146Siwasaki case ACPI_TYPE_BUFFER: 29899146Siwasaki 29999146Siwasaki Status = AcpiDsGetBufferArguments (StackDesc); 30099146Siwasaki break; 30199146Siwasaki 30299146Siwasaki case ACPI_TYPE_PACKAGE: 30399146Siwasaki 30499146Siwasaki Status = AcpiDsGetPackageArguments (StackDesc); 30599146Siwasaki break; 30699146Siwasaki 30777424Smsmith case ACPI_TYPE_BUFFER_FIELD: 308107325Siwasaki case ACPI_TYPE_LOCAL_REGION_FIELD: 309107325Siwasaki case ACPI_TYPE_LOCAL_BANK_FIELD: 310107325Siwasaki case ACPI_TYPE_LOCAL_INDEX_FIELD: 31167754Smsmith 312306536Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 313306536Sjkim "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{ 356306536Sjkim ACPI_OPERAND_OBJECT *ObjDesc = ACPI_CAST_PTR (void, Operand); 357306536Sjkim ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Operand); 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; 377306536Sjkim ObjDesc = AcpiNsGetAttachedObject (Node); 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; 384306536Sjkim ObjDesc = AcpiNsGetAttachedObject ( 385306536Sjkim (ACPI_NAMESPACE_NODE *) ObjDesc); 386138287Smarks } 387306536Sjkim 388306536Sjkim if (!ObjDesc) 389306536Sjkim { 390306536Sjkim ACPI_ERROR ((AE_INFO, 391306536Sjkim "[%4.4s] Node is unresolved or uninitialized", 392306536Sjkim AcpiUtGetNodeName (Node))); 393306536Sjkim return_ACPI_STATUS (AE_AML_UNINITIALIZED_NODE); 394306536Sjkim } 395138287Smarks break; 396138287Smarks 397138287Smarks default: 398138287Smarks return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 399138287Smarks } 400138287Smarks 401151937Sjkim /* If type is anything other than a reference, we are done */ 402138287Smarks 403138287Smarks if (Type != ACPI_TYPE_LOCAL_REFERENCE) 404138287Smarks { 405138287Smarks goto Exit; 406138287Smarks } 407138287Smarks 408138287Smarks /* 409193267Sjkim * For reference objects created via the RefOf, Index, or Load/LoadTable 410193267Sjkim * operators, we need to get to the base object (as per the ACPI 411193267Sjkim * specification of the ObjectType and SizeOf operators). This means 412193267Sjkim * traversing the list of possibly many nested references. 413104470Siwasaki */ 414193267Sjkim while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) 415104470Siwasaki { 416193267Sjkim switch (ObjDesc->Reference.Class) 417104470Siwasaki { 418193267Sjkim case ACPI_REFCLASS_REFOF: 419193267Sjkim case ACPI_REFCLASS_NAME: 420104470Siwasaki 421104470Siwasaki /* Dereference the reference pointer */ 422104470Siwasaki 423193267Sjkim if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF) 424167802Sjkim { 425167802Sjkim Node = ObjDesc->Reference.Object; 426167802Sjkim } 427167802Sjkim else /* AML_INT_NAMEPATH_OP */ 428167802Sjkim { 429167802Sjkim Node = ObjDesc->Reference.Node; 430167802Sjkim } 431104470Siwasaki 432104470Siwasaki /* All "References" point to a NS node */ 433104470Siwasaki 434104470Siwasaki if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 435104470Siwasaki { 436167802Sjkim ACPI_ERROR ((AE_INFO, 437204773Sjkim "Not a namespace node %p [%s]", 438151937Sjkim Node, AcpiUtGetDescriptorName (Node))); 439104470Siwasaki return_ACPI_STATUS (AE_AML_INTERNAL); 440104470Siwasaki } 441104470Siwasaki 442104470Siwasaki /* Get the attached object */ 443104470Siwasaki 444104470Siwasaki ObjDesc = AcpiNsGetAttachedObject (Node); 445104470Siwasaki if (!ObjDesc) 446104470Siwasaki { 447104470Siwasaki /* No object, use the NS node type */ 448104470Siwasaki 449104470Siwasaki Type = AcpiNsGetType (Node); 450104470Siwasaki goto Exit; 451104470Siwasaki } 452104470Siwasaki 453104470Siwasaki /* Check for circular references */ 454104470Siwasaki 455104470Siwasaki if (ObjDesc == Operand) 456104470Siwasaki { 457104470Siwasaki return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); 458104470Siwasaki } 459104470Siwasaki break; 460104470Siwasaki 461193267Sjkim case ACPI_REFCLASS_INDEX: 462104470Siwasaki 463104470Siwasaki /* Get the type of this reference (index into another object) */ 464104470Siwasaki 465104470Siwasaki Type = ObjDesc->Reference.TargetType; 466104470Siwasaki if (Type != ACPI_TYPE_PACKAGE) 467104470Siwasaki { 468104470Siwasaki goto Exit; 469104470Siwasaki } 470104470Siwasaki 471104470Siwasaki /* 472104470Siwasaki * The main object is a package, we want to get the type 473104470Siwasaki * of the individual package element that is referenced by 474104470Siwasaki * the index. 475104470Siwasaki * 476104470Siwasaki * This could of course in turn be another reference object. 477104470Siwasaki */ 478104470Siwasaki ObjDesc = *(ObjDesc->Reference.Where); 479151937Sjkim if (!ObjDesc) 480151937Sjkim { 481151937Sjkim /* NULL package elements are allowed */ 482151937Sjkim 483151937Sjkim Type = 0; /* Uninitialized */ 484151937Sjkim goto Exit; 485151937Sjkim } 486104470Siwasaki break; 487104470Siwasaki 488193267Sjkim case ACPI_REFCLASS_TABLE: 489138287Smarks 490193267Sjkim Type = ACPI_TYPE_DDB_HANDLE; 491193267Sjkim goto Exit; 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 case ACPI_REFCLASS_DEBUG: 525104470Siwasaki 526104470Siwasaki /* The Debug Object is of type "DebugObject" */ 527104470Siwasaki 528104470Siwasaki Type = ACPI_TYPE_DEBUG_OBJECT; 529104470Siwasaki goto Exit; 530104470Siwasaki 531104470Siwasaki default: 532104470Siwasaki 533167802Sjkim ACPI_ERROR ((AE_INFO, 534306536Sjkim "Unknown Reference Class 0x%2.2X", 535306536Sjkim ObjDesc->Reference.Class)); 536104470Siwasaki return_ACPI_STATUS (AE_AML_INTERNAL); 537104470Siwasaki } 538104470Siwasaki } 539104470Siwasaki 540104470Siwasaki /* 541104470Siwasaki * Now we are guaranteed to have an object that has not been created 542104470Siwasaki * via the RefOf or Index operators. 543104470Siwasaki */ 544193267Sjkim Type = ObjDesc->Common.Type; 545104470Siwasaki 546104470Siwasaki 547104470SiwasakiExit: 548104470Siwasaki /* Convert internal types to external types */ 549104470Siwasaki 550104470Siwasaki switch (Type) 551104470Siwasaki { 552107325Siwasaki case ACPI_TYPE_LOCAL_REGION_FIELD: 553107325Siwasaki case ACPI_TYPE_LOCAL_BANK_FIELD: 554107325Siwasaki case ACPI_TYPE_LOCAL_INDEX_FIELD: 555104470Siwasaki 556104470Siwasaki Type = ACPI_TYPE_FIELD_UNIT; 557104470Siwasaki break; 558104470Siwasaki 559107325Siwasaki case ACPI_TYPE_LOCAL_SCOPE: 560107325Siwasaki 561107325Siwasaki /* Per ACPI Specification, Scope is untyped */ 562107325Siwasaki 563107325Siwasaki Type = ACPI_TYPE_ANY; 564107325Siwasaki break; 565107325Siwasaki 566104470Siwasaki default: 567250838Sjkim 568104470Siwasaki /* No change to Type required */ 569250838Sjkim 570104470Siwasaki break; 571104470Siwasaki } 572104470Siwasaki 573104470Siwasaki *ReturnType = Type; 574104470Siwasaki if (ReturnDesc) 575104470Siwasaki { 576104470Siwasaki *ReturnDesc = ObjDesc; 577104470Siwasaki } 578104470Siwasaki return_ACPI_STATUS (AE_OK); 579104470Siwasaki} 580