exresnte.c revision 104470
1255801Sdes 2255801Sdes/****************************************************************************** 3255801Sdes * 4255801Sdes * Module Name: exresnte - AML Interpreter object resolution 5255801Sdes * $Revision: 59 $ 6255801Sdes * 7255801Sdes *****************************************************************************/ 8255801Sdes 9255801Sdes/****************************************************************************** 10255801Sdes * 11255801Sdes * 1. Copyright Notice 12255801Sdes * 13255801Sdes * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. 14255801Sdes * All rights reserved. 15255801Sdes * 16255801Sdes * 2. License 17255801Sdes * 18255801Sdes * 2.1. This is your license from Intel Corp. under its intellectual property 19255801Sdes * rights. You may have additional license terms from the party that provided 20255801Sdes * you this software, covering your right to use that party's intellectual 21255801Sdes * property rights. 22255801Sdes * 23255801Sdes * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 24255801Sdes * copy of the source code appearing in this file ("Covered Code") an 25255801Sdes * irrevocable, perpetual, worldwide license under Intel's copyrights in the 26255801Sdes * base code distributed originally by Intel ("Original Intel Code") to copy, 27255801Sdes * make derivatives, distribute, use and display any portion of the Covered 28255801Sdes * Code in any form, with the right to sublicense such rights; and 29255801Sdes * 30255801Sdes * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 31255801Sdes * license (with the right to sublicense), under only those claims of Intel 32255801Sdes * patents that are infringed by the Original Intel Code, to make, use, sell, 33255801Sdes * offer to sell, and import the Covered Code and derivative works thereof 34255801Sdes * solely to the minimum extent necessary to exercise the above copyright 35255801Sdes * license, and in no event shall the patent license extend to any additions 36255801Sdes * to or modifications of the Original Intel Code. No other license or right 37255801Sdes * is granted directly or by implication, estoppel or otherwise; 38255801Sdes * 39255801Sdes * The above copyright and patent license is granted only if the following 40255801Sdes * conditions are met: 41255801Sdes * 42255801Sdes * 3. Conditions 43255801Sdes * 44255801Sdes * 3.1. Redistribution of Source with Rights to Further Distribute Source. 45255801Sdes * Redistribution of source code of any substantial portion of the Covered 46255801Sdes * Code or modification with rights to further distribute source must include 47255801Sdes * the above Copyright Notice, the above License, this list of Conditions, 48255801Sdes * and the following Disclaimer and Export Compliance provision. In addition, 49255801Sdes * Licensee must cause all Covered Code to which Licensee contributes to 50255801Sdes * contain a file documenting the changes Licensee made to create that Covered 51255801Sdes * Code and the date of any change. Licensee must include in that file the 52255801Sdes * documentation of any changes made by any predecessor Licensee. Licensee 53255801Sdes * must include a prominent statement that the modification is derived, 54255801Sdes * directly or indirectly, from Original Intel Code. 55255801Sdes * 56255801Sdes * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 57255801Sdes * Redistribution of source code of any substantial portion of the Covered 58255801Sdes * Code or modification without rights to further distribute source must 59255801Sdes * include the following Disclaimer and Export Compliance provision in the 60255801Sdes * documentation and/or other materials provided with distribution. In 61255801Sdes * addition, Licensee may not authorize further sublicense of source of any 62255801Sdes * portion of the Covered Code, and must include terms to the effect that the 63255801Sdes * license from Licensee to its licensee is limited to the intellectual 64255801Sdes * property embodied in the software Licensee provides to its licensee, and 65255801Sdes * not to intellectual property embodied in modifications its licensee may 66255801Sdes * make. 67255801Sdes * 68255801Sdes * 3.3. Redistribution of Executable. Redistribution in executable form of any 69255801Sdes * substantial portion of the Covered Code or modification must reproduce the 70255801Sdes * above Copyright Notice, and the following Disclaimer and Export Compliance 71255801Sdes * provision in the documentation and/or other materials provided with the 72255801Sdes * distribution. 73255801Sdes * 74255801Sdes * 3.4. Intel retains all right, title, and interest in and to the Original 75255801Sdes * Intel Code. 76255801Sdes * 77255801Sdes * 3.5. Neither the name Intel nor any other trademark owned or controlled by 78255801Sdes * Intel shall be used in advertising or otherwise to promote the sale, use or 79255801Sdes * other dealings in products derived from or relating to the Covered Code 80255801Sdes * without prior written authorization from Intel. 81255801Sdes * 82255801Sdes * 4. Disclaimer and Export Compliance 83255801Sdes * 84255801Sdes * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 85255801Sdes * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 86255801Sdes * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 87255801Sdes * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 88255801Sdes * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 89255801Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 90255801Sdes * PARTICULAR PURPOSE. 91255801Sdes * 92255801Sdes * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 93255801Sdes * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 94255801Sdes * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 95255801Sdes * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 96255801Sdes * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 97255801Sdes * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 98255801Sdes * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 99255801Sdes * LIMITED REMEDY. 100255801Sdes * 101255801Sdes * 4.3. Licensee shall not export, either directly or indirectly, any of this 102255801Sdes * software or system incorporating such software without first obtaining any 103255801Sdes * required license or other approval from the U. S. Department of Commerce or 104255801Sdes * any other agency or department of the United States Government. In the 105255801Sdes * event Licensee exports any such software from the United States or 106255801Sdes * re-exports any such software from a foreign destination, Licensee shall 107255801Sdes * ensure that the distribution and export/re-export of the software is in 108255801Sdes * compliance with all laws, regulations, orders, or other restrictions of the 109255801Sdes * U.S. Export Administration Regulations. Licensee agrees that neither it nor 110255801Sdes * any of its subsidiaries will export/re-export any technical data, process, 111255801Sdes * software, or service, directly or indirectly, to any country for which the 112255801Sdes * United States government or any agency thereof requires an export license, 113255801Sdes * other governmental approval, or letter of assurance, without first obtaining 114255801Sdes * such license, approval or letter. 115255801Sdes * 116255801Sdes *****************************************************************************/ 117255801Sdes 118255801Sdes#define __EXRESNTE_C__ 119255801Sdes 120255801Sdes#include "acpi.h" 121255801Sdes#include "acdispat.h" 122255801Sdes#include "acinterp.h" 123255801Sdes#include "acnamesp.h" 124255801Sdes 125282088Sdes 126255801Sdes#define _COMPONENT ACPI_EXECUTER 127255801Sdes ACPI_MODULE_NAME ("exresnte") 128255801Sdes 129255801Sdes 130255801Sdes/******************************************************************************* 131255801Sdes * 132255801Sdes * FUNCTION: AcpiExResolveNodeToValue 133255801Sdes * 134282088Sdes * PARAMETERS: ObjectPtr - Pointer to a location that contains 135255801Sdes * a pointer to a NS node, and will receive a 136255801Sdes * pointer to the resolved object. 137255801Sdes * WalkState - Current state. Valid only if executing AML 138255801Sdes * code. NULL if simply resolving an object 139255801Sdes * 140255801Sdes * RETURN: Status 141255801Sdes * 142255801Sdes * DESCRIPTION: Resolve a Namespace node to a valued object 143255801Sdes * 144255801Sdes * Note: for some of the data types, the pointer attached to the Node 145255801Sdes * can be either a pointer to an actual internal object or a pointer into the 146255801Sdes * AML stream itself. These types are currently: 147255801Sdes * 148255801Sdes * ACPI_TYPE_INTEGER 149255801Sdes * ACPI_TYPE_STRING 150255801Sdes * ACPI_TYPE_BUFFER 151255801Sdes * ACPI_TYPE_MUTEX 152255801Sdes * ACPI_TYPE_PACKAGE 153255801Sdes * 154255801Sdes ******************************************************************************/ 155255801Sdes 156255801SdesACPI_STATUS 157255801SdesAcpiExResolveNodeToValue ( 158255801Sdes ACPI_NAMESPACE_NODE **ObjectPtr, 159255801Sdes ACPI_WALK_STATE *WalkState) 160255801Sdes 161255801Sdes{ 162255801Sdes ACPI_STATUS Status = AE_OK; 163255801Sdes ACPI_OPERAND_OBJECT *SourceDesc; 164255801Sdes ACPI_OPERAND_OBJECT *ObjDesc = NULL; 165255801Sdes ACPI_NAMESPACE_NODE *Node; 166255801Sdes ACPI_OBJECT_TYPE EntryType; 167255801Sdes 168255801Sdes 169255801Sdes ACPI_FUNCTION_TRACE ("ExResolveNodeToValue"); 170255801Sdes 171255801Sdes 172255801Sdes /* 173255801Sdes * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the 174255801Sdes * object that is attached to the Node. 175255801Sdes */ 176255801Sdes Node = *ObjectPtr; 177255801Sdes SourceDesc = AcpiNsGetAttachedObject (Node); 178255801Sdes EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); 179255801Sdes 180255801Sdes ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p Type=%X\n", 181255801Sdes Node, SourceDesc, EntryType)); 182255801Sdes 183255801Sdes if (EntryType == INTERNAL_TYPE_ALIAS) 184255801Sdes { 185255801Sdes /* There is always exactly one level of indirection */ 186255801Sdes 187255801Sdes Node = (ACPI_NAMESPACE_NODE *) Node->Object; 188255801Sdes SourceDesc = AcpiNsGetAttachedObject (Node); 189255801Sdes EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); 190255801Sdes *ObjectPtr = Node; 191255801Sdes } 192255801Sdes 193255801Sdes /* 194255801Sdes * Several object types require no further processing: 195255801Sdes * 1) Devices rarely have an attached object, return the Node 196255801Sdes * 2) Method locals and arguments have a pseudo-Node 197255801Sdes */ 198255801Sdes if (EntryType == ACPI_TYPE_DEVICE || 199255801Sdes (Node->Flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) 200255801Sdes { 201255801Sdes return_ACPI_STATUS (AE_OK); 202255801Sdes } 203255801Sdes 204255801Sdes if (!SourceDesc) 205255801Sdes { 206255801Sdes ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object attached to node %p\n", 207255801Sdes Node)); 208255801Sdes return_ACPI_STATUS (AE_AML_NO_OPERAND); 209255801Sdes } 210255801Sdes 211255801Sdes /* 212255801Sdes * Action is based on the type of the Node, which indicates the type 213255801Sdes * of the attached object or pointer 214255801Sdes */ 215255801Sdes switch (EntryType) 216255801Sdes { 217255801Sdes case ACPI_TYPE_PACKAGE: 218255801Sdes 219255801Sdes if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_PACKAGE) 220255801Sdes { 221255801Sdes ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Package, type %s\n", 222255801Sdes AcpiUtGetObjectTypeName (SourceDesc))); 223255801Sdes return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 224255801Sdes } 225255801Sdes 226255801Sdes Status = AcpiDsGetPackageArguments (SourceDesc); 227255801Sdes if (ACPI_SUCCESS (Status)) 228255801Sdes { 229255801Sdes /* Return an additional reference to the object */ 230255801Sdes 231255801Sdes ObjDesc = SourceDesc; 232255801Sdes AcpiUtAddReference (ObjDesc); 233255801Sdes } 234255801Sdes break; 235255801Sdes 236255801Sdes 237255801Sdes case ACPI_TYPE_BUFFER: 238255801Sdes 239255801Sdes if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_BUFFER) 240255801Sdes { 241255801Sdes ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Buffer, type %s\n", 242255801Sdes AcpiUtGetObjectTypeName (SourceDesc))); 243255801Sdes return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 244255801Sdes } 245255801Sdes 246255801Sdes Status = AcpiDsGetBufferArguments (SourceDesc); 247255801Sdes if (ACPI_SUCCESS (Status)) 248255801Sdes { 249255801Sdes /* Return an additional reference to the object */ 250255801Sdes 251255801Sdes ObjDesc = SourceDesc; 252255801Sdes AcpiUtAddReference (ObjDesc); 253255801Sdes } 254255801Sdes break; 255255801Sdes 256255801Sdes 257255801Sdes case ACPI_TYPE_STRING: 258255801Sdes 259255801Sdes if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_STRING) 260255801Sdes { 261255801Sdes ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a String, type %s\n", 262255801Sdes AcpiUtGetObjectTypeName (SourceDesc))); 263255801Sdes return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 264255801Sdes } 265255801Sdes 266255801Sdes /* Return an additional reference to the object */ 267255801Sdes 268255801Sdes ObjDesc = SourceDesc; 269255801Sdes AcpiUtAddReference (ObjDesc); 270255801Sdes break; 271255801Sdes 272255801Sdes 273255801Sdes case ACPI_TYPE_INTEGER: 274255801Sdes 275255801Sdes if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_INTEGER) 276255801Sdes { 277255801Sdes ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Integer, type %s\n", 278255801Sdes AcpiUtGetObjectTypeName (SourceDesc))); 279255801Sdes return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 280255801Sdes } 281255801Sdes 282255801Sdes /* Return an additional reference to the object */ 283255801Sdes 284255801Sdes ObjDesc = SourceDesc; 285255801Sdes AcpiUtAddReference (ObjDesc); 286255801Sdes break; 287255801Sdes 288255801Sdes 289255801Sdes case ACPI_TYPE_BUFFER_FIELD: 290255801Sdes case INTERNAL_TYPE_REGION_FIELD: 291255801Sdes case INTERNAL_TYPE_BANK_FIELD: 292255801Sdes case INTERNAL_TYPE_INDEX_FIELD: 293255801Sdes 294255801Sdes ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead Node=%p SourceDesc=%p Type=%X\n", 295255801Sdes Node, SourceDesc, EntryType)); 296255801Sdes 297255801Sdes Status = AcpiExReadDataFromField (WalkState, SourceDesc, &ObjDesc); 298 break; 299 300 /* 301 * For these objects, just return the object attached to the Node 302 */ 303 case ACPI_TYPE_MUTEX: 304 case ACPI_TYPE_METHOD: 305 case ACPI_TYPE_POWER: 306 case ACPI_TYPE_PROCESSOR: 307 case ACPI_TYPE_THERMAL: 308 case ACPI_TYPE_EVENT: 309 case ACPI_TYPE_REGION: 310 311 /* Return an additional reference to the object */ 312 313 ObjDesc = SourceDesc; 314 AcpiUtAddReference (ObjDesc); 315 break; 316 317 318 /* TYPE_ANY is untyped, and thus there is no object associated with it */ 319 320 case ACPI_TYPE_ANY: 321 322 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Untyped entry %p, no attached object!\n", 323 Node)); 324 325 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ 326 327 328 case INTERNAL_TYPE_REFERENCE: 329 330 /* No named references are allowed here */ 331 332 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported Reference opcode %X\n", 333 SourceDesc->Reference.Opcode)); 334 335 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 336 337 338 /* Default case is for unknown types */ 339 340 default: 341 342 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Node %p - Unknown object type %X\n", 343 Node, EntryType)); 344 345 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 346 347 } /* switch (EntryType) */ 348 349 350 /* Put the object descriptor on the stack */ 351 352 *ObjectPtr = (void *) ObjDesc; 353 return_ACPI_STATUS (Status); 354} 355 356 357