exresnte.c revision 82367
1251875Speter 2251875Speter/****************************************************************************** 3251875Speter * 4251875Speter * Module Name: exresnte - AML Interpreter object resolution 5251875Speter * $Revision: 39 $ 6251875Speter * 7251875Speter *****************************************************************************/ 8251875Speter 9251875Speter/****************************************************************************** 10251875Speter * 11251875Speter * 1. Copyright Notice 12251875Speter * 13251875Speter * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. 14251875Speter * All rights reserved. 15251875Speter * 16251875Speter * 2. License 17251875Speter * 18251875Speter * 2.1. This is your license from Intel Corp. under its intellectual property 19251875Speter * rights. You may have additional license terms from the party that provided 20251875Speter * you this software, covering your right to use that party's intellectual 21251875Speter * property rights. 22251875Speter * 23251875Speter * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 24251875Speter * copy of the source code appearing in this file ("Covered Code") an 25251875Speter * irrevocable, perpetual, worldwide license under Intel's copyrights in the 26251875Speter * base code distributed originally by Intel ("Original Intel Code") to copy, 27251875Speter * make derivatives, distribute, use and display any portion of the Covered 28251875Speter * Code in any form, with the right to sublicense such rights; and 29251875Speter * 30251875Speter * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 31251875Speter * license (with the right to sublicense), under only those claims of Intel 32251875Speter * patents that are infringed by the Original Intel Code, to make, use, sell, 33251875Speter * offer to sell, and import the Covered Code and derivative works thereof 34251875Speter * solely to the minimum extent necessary to exercise the above copyright 35251875Speter * license, and in no event shall the patent license extend to any additions 36251875Speter * to or modifications of the Original Intel Code. No other license or right 37251875Speter * is granted directly or by implication, estoppel or otherwise; 38251875Speter * 39251875Speter * The above copyright and patent license is granted only if the following 40251875Speter * conditions are met: 41251875Speter * 42251875Speter * 3. Conditions 43251875Speter * 44251875Speter * 3.1. Redistribution of Source with Rights to Further Distribute Source. 45251875Speter * Redistribution of source code of any substantial portion of the Covered 46251875Speter * Code or modification with rights to further distribute source must include 47251875Speter * the above Copyright Notice, the above License, this list of Conditions, 48251875Speter * and the following Disclaimer and Export Compliance provision. In addition, 49251875Speter * Licensee must cause all Covered Code to which Licensee contributes to 50251875Speter * contain a file documenting the changes Licensee made to create that Covered 51251875Speter * Code and the date of any change. Licensee must include in that file the 52251875Speter * documentation of any changes made by any predecessor Licensee. Licensee 53251875Speter * must include a prominent statement that the modification is derived, 54251875Speter * directly or indirectly, from Original Intel Code. 55251875Speter * 56251875Speter * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 57251875Speter * Redistribution of source code of any substantial portion of the Covered 58251875Speter * Code or modification without rights to further distribute source must 59251875Speter * include the following Disclaimer and Export Compliance provision in the 60251875Speter * documentation and/or other materials provided with distribution. In 61251875Speter * addition, Licensee may not authorize further sublicense of source of any 62251875Speter * portion of the Covered Code, and must include terms to the effect that the 63251875Speter * license from Licensee to its licensee is limited to the intellectual 64251875Speter * property embodied in the software Licensee provides to its licensee, and 65251875Speter * not to intellectual property embodied in modifications its licensee may 66251875Speter * make. 67251875Speter * 68251875Speter * 3.3. Redistribution of Executable. Redistribution in executable form of any 69251875Speter * substantial portion of the Covered Code or modification must reproduce the 70251875Speter * above Copyright Notice, and the following Disclaimer and Export Compliance 71251875Speter * provision in the documentation and/or other materials provided with the 72251875Speter * distribution. 73251875Speter * 74251875Speter * 3.4. Intel retains all right, title, and interest in and to the Original 75251875Speter * Intel Code. 76251875Speter * 77251875Speter * 3.5. Neither the name Intel nor any other trademark owned or controlled by 78251875Speter * Intel shall be used in advertising or otherwise to promote the sale, use or 79251875Speter * other dealings in products derived from or relating to the Covered Code 80251875Speter * without prior written authorization from Intel. 81251875Speter * 82251875Speter * 4. Disclaimer and Export Compliance 83251875Speter * 84251875Speter * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 85251875Speter * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 86251875Speter * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 87251875Speter * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 88251875Speter * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 89251875Speter * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 90251875Speter * PARTICULAR PURPOSE. 91251875Speter * 92251875Speter * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 93251875Speter * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 94251875Speter * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 95251875Speter * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 96251875Speter * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 97251875Speter * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 98251875Speter * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 99251875Speter * LIMITED REMEDY. 100251875Speter * 101251875Speter * 4.3. Licensee shall not export, either directly or indirectly, any of this 102251875Speter * software or system incorporating such software without first obtaining any 103251875Speter * required license or other approval from the U. S. Department of Commerce or 104251875Speter * any other agency or department of the United States Government. In the 105251875Speter * event Licensee exports any such software from the United States or 106251875Speter * re-exports any such software from a foreign destination, Licensee shall 107251875Speter * ensure that the distribution and export/re-export of the software is in 108251875Speter * compliance with all laws, regulations, orders, or other restrictions of the 109251875Speter * U.S. Export Administration Regulations. Licensee agrees that neither it nor 110251875Speter * any of its subsidiaries will export/re-export any technical data, process, 111251875Speter * software, or service, directly or indirectly, to any country for which the 112251875Speter * United States government or any agency thereof requires an export license, 113251875Speter * other governmental approval, or letter of assurance, without first obtaining 114269847Speter * such license, approval or letter. 115269847Speter * 116269847Speter *****************************************************************************/ 117269847Speter 118269847Speter#define __EXRESNTE_C__ 119269847Speter 120269847Speter#include "acpi.h" 121269847Speter#include "amlcode.h" 122269847Speter#include "acparser.h" 123269847Speter#include "acdispat.h" 124269847Speter#include "acinterp.h" 125269847Speter#include "acnamesp.h" 126269847Speter#include "actables.h" 127251875Speter#include "acevents.h" 128251875Speter 129251875Speter 130251875Speter#define _COMPONENT ACPI_EXECUTER 131251875Speter MODULE_NAME ("exresnte") 132251875Speter 133251875Speter 134251875Speter/******************************************************************************* 135251875Speter * 136251875Speter * FUNCTION: AcpiExResolveNodeToValue 137251875Speter * 138251875Speter * PARAMETERS: StackPtr - Pointer to a location on a stack that contains 139251875Speter * a pointer to a Node 140251875Speter * WalkState - Current state 141251875Speter * 142251875Speter * RETURN: Status 143251875Speter * 144251875Speter * DESCRIPTION: Resolve a Namespace node (AKA a "direct name pointer") to 145251875Speter * a valued object 146251875Speter * 147251875Speter * Note: for some of the data types, the pointer attached to the Node 148251875Speter * can be either a pointer to an actual internal object or a pointer into the 149251875Speter * AML stream itself. These types are currently: 150251875Speter * 151251875Speter * ACPI_TYPE_INTEGER 152251875Speter * ACPI_TYPE_STRING 153251875Speter * ACPI_TYPE_BUFFER 154251875Speter * ACPI_TYPE_MUTEX 155251875Speter * ACPI_TYPE_PACKAGE 156251875Speter * 157251875Speter ******************************************************************************/ 158251875Speter 159251875SpeterACPI_STATUS 160251875SpeterAcpiExResolveNodeToValue ( 161251875Speter ACPI_NAMESPACE_NODE **StackPtr, 162251875Speter ACPI_WALK_STATE *WalkState) 163251875Speter 164251875Speter{ 165251875Speter ACPI_STATUS Status = AE_OK; 166251875Speter ACPI_OPERAND_OBJECT *ValDesc; 167251875Speter ACPI_OPERAND_OBJECT *ObjDesc = NULL; 168251875Speter ACPI_NAMESPACE_NODE *Node; 169251875Speter ACPI_OBJECT_TYPE8 EntryType; 170251875Speter ACPI_INTEGER TempVal; 171251875Speter 172251875Speter 173251875Speter FUNCTION_TRACE ("ExResolveNodeToValue"); 174251875Speter 175251875Speter 176251875Speter /* 177251875Speter * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the 178251875Speter * object that is attached to the Node. 179251875Speter */ 180251875Speter Node = *StackPtr; 181251875Speter ValDesc = AcpiNsGetAttachedObject (Node); 182251875Speter EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); 183251875Speter 184251875Speter ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p ValDesc=%p Type=%X\n", 185251875Speter Node, ValDesc, EntryType)); 186251875Speter 187251875Speter 188251875Speter /* 189251875Speter * Several object types require no further processing: 190251875Speter * 1) Devices rarely have an attached object, return the Node 191251875Speter * 2) Method locals and arguments have a pseudo-Node 192251875Speter */ 193251875Speter if (EntryType == ACPI_TYPE_DEVICE || 194251875Speter (Node->Flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) 195251875Speter { 196251875Speter return_ACPI_STATUS (AE_OK); 197251875Speter } 198251875Speter 199251875Speter if (!ValDesc) 200251875Speter { 201251875Speter ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object attached to node %p\n", 202251875Speter Node)); 203251875Speter return_ACPI_STATUS (AE_AML_NO_OPERAND); 204251875Speter } 205251875Speter 206251875Speter /* 207251875Speter * Action is based on the type of the Node, which indicates the type 208251875Speter * of the attached object or pointer 209251875Speter */ 210251875Speter switch (EntryType) 211251875Speter { 212251875Speter 213251875Speter case ACPI_TYPE_PACKAGE: 214251875Speter 215251875Speter if (ACPI_TYPE_PACKAGE != ValDesc->Common.Type) 216251875Speter { 217251875Speter ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a package, type %X\n", 218251875Speter ValDesc->Common.Type)); 219251875Speter return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 220251875Speter } 221251875Speter 222251875Speter /* Return an additional reference to the object */ 223251875Speter 224251875Speter ObjDesc = ValDesc; 225251875Speter AcpiUtAddReference (ObjDesc); 226251875Speter break; 227251875Speter 228251875Speter 229251875Speter case ACPI_TYPE_BUFFER: 230251875Speter 231251875Speter if (ACPI_TYPE_BUFFER != ValDesc->Common.Type) 232251875Speter { 233251875Speter ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a buffer, type %X\n", 234251875Speter ValDesc->Common.Type)); 235251875Speter return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 236251875Speter } 237251875Speter 238251875Speter /* Return an additional reference to the object */ 239251875Speter 240251875Speter ObjDesc = ValDesc; 241251875Speter AcpiUtAddReference (ObjDesc); 242 break; 243 244 245 case ACPI_TYPE_STRING: 246 247 if (ACPI_TYPE_STRING != ValDesc->Common.Type) 248 { 249 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a string, type %X\n", 250 ValDesc->Common.Type)); 251 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 252 } 253 254 /* Return an additional reference to the object */ 255 256 ObjDesc = ValDesc; 257 AcpiUtAddReference (ObjDesc); 258 break; 259 260 261 case ACPI_TYPE_INTEGER: 262 263 if (ACPI_TYPE_INTEGER != ValDesc->Common.Type) 264 { 265 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Number, type %X\n", 266 ValDesc->Common.Type)); 267 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 268 } 269 270 /* Return an additional reference to the object */ 271 272 ObjDesc = ValDesc; 273 AcpiUtAddReference (ObjDesc); 274 break; 275 276 277 case ACPI_TYPE_BUFFER_FIELD: 278 case INTERNAL_TYPE_REGION_FIELD: 279 case INTERNAL_TYPE_BANK_FIELD: 280 case INTERNAL_TYPE_INDEX_FIELD: 281 282 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead Node=%p ValDesc=%p Type=%X\n", 283 Node, ValDesc, EntryType)); 284 285 Status = AcpiExReadDataFromField (ValDesc, &ObjDesc); 286 break; 287 288 289 /* 290 * For these objects, just return the object attached to the Node 291 */ 292 case ACPI_TYPE_MUTEX: 293 case ACPI_TYPE_METHOD: 294 case ACPI_TYPE_POWER: 295 case ACPI_TYPE_PROCESSOR: 296 case ACPI_TYPE_THERMAL: 297 case ACPI_TYPE_EVENT: 298 case ACPI_TYPE_REGION: 299 300 /* Return an additional reference to the object */ 301 302 ObjDesc = ValDesc; 303 AcpiUtAddReference (ObjDesc); 304 break; 305 306 307 /* TYPE_Any is untyped, and thus there is no object associated with it */ 308 309 case ACPI_TYPE_ANY: 310 311 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Untyped entry %p, no attached object!\n", 312 Node)); 313 314 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ 315 break; 316 317 318 /* 319 * The only named references allowed are named constants 320 * e.g. -- Name (\OSFL, Ones) 321 */ 322 case INTERNAL_TYPE_REFERENCE: 323 324 switch (ValDesc->Reference.Opcode) 325 { 326 327 case AML_ZERO_OP: 328 329 TempVal = 0; 330 break; 331 332 case AML_ONE_OP: 333 334 TempVal = 1; 335 break; 336 337 case AML_ONES_OP: 338 339 TempVal = ACPI_INTEGER_MAX; 340 break; 341 342 default: 343 344 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported reference opcode %X\n", 345 ValDesc->Reference.Opcode)); 346 347 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 348 } 349 350 /* Create object for result */ 351 352 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); 353 if (!ObjDesc) 354 { 355 return_ACPI_STATUS (AE_NO_MEMORY); 356 } 357 358 ObjDesc->Integer.Value = TempVal; 359 360 /* Truncate value if we are executing from a 32-bit ACPI table */ 361 362 AcpiExTruncateFor32bitTable (ObjDesc, WalkState); 363 break; 364 365 366 /* Default case is for unknown types */ 367 368 default: 369 370 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Node %p - Unknown object type %X\n", 371 Node, EntryType)); 372 373 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 374 375 } /* switch (EntryType) */ 376 377 378 /* Put the object descriptor on the stack */ 379 380 *StackPtr = (void *) ObjDesc; 381 return_ACPI_STATUS (Status); 382} 383 384 385