exresolv.c revision 67754
167754Smsmith 267754Smsmith/****************************************************************************** 367754Smsmith * 467754Smsmith * Module Name: amresolv - AML Interpreter object resolution 567754Smsmith * $Revision: 76 $ 667754Smsmith * 767754Smsmith *****************************************************************************/ 867754Smsmith 967754Smsmith/****************************************************************************** 1067754Smsmith * 1167754Smsmith * 1. Copyright Notice 1267754Smsmith * 1367754Smsmith * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights 1467754Smsmith * reserved. 1567754Smsmith * 1667754Smsmith * 2. License 1767754Smsmith * 1867754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 1967754Smsmith * rights. You may have additional license terms from the party that provided 2067754Smsmith * you this software, covering your right to use that party's intellectual 2167754Smsmith * property rights. 2267754Smsmith * 2367754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2467754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2567754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2667754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2767754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2867754Smsmith * Code in any form, with the right to sublicense such rights; and 2967754Smsmith * 3067754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3167754Smsmith * license (with the right to sublicense), under only those claims of Intel 3267754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3367754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3467754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3567754Smsmith * license, and in no event shall the patent license extend to any additions 3667754Smsmith * to or modifications of the Original Intel Code. No other license or right 3767754Smsmith * is granted directly or by implication, estoppel or otherwise; 3867754Smsmith * 3967754Smsmith * The above copyright and patent license is granted only if the following 4067754Smsmith * conditions are met: 4167754Smsmith * 4267754Smsmith * 3. Conditions 4367754Smsmith * 4467754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4567754Smsmith * Redistribution of source code of any substantial portion of the Covered 4667754Smsmith * Code or modification with rights to further distribute source must include 4767754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4867754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 4967754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 5067754Smsmith * contain a file documenting the changes Licensee made to create that Covered 5167754Smsmith * Code and the date of any change. Licensee must include in that file the 5267754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5367754Smsmith * must include a prominent statement that the modification is derived, 5467754Smsmith * directly or indirectly, from Original Intel Code. 5567754Smsmith * 5667754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5767754Smsmith * Redistribution of source code of any substantial portion of the Covered 5867754Smsmith * Code or modification without rights to further distribute source must 5967754Smsmith * include the following Disclaimer and Export Compliance provision in the 6067754Smsmith * documentation and/or other materials provided with distribution. In 6167754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6267754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6367754Smsmith * license from Licensee to its licensee is limited to the intellectual 6467754Smsmith * property embodied in the software Licensee provides to its licensee, and 6567754Smsmith * not to intellectual property embodied in modifications its licensee may 6667754Smsmith * make. 6767754Smsmith * 6867754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 6967754Smsmith * substantial portion of the Covered Code or modification must reproduce the 7067754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 7167754Smsmith * provision in the documentation and/or other materials provided with the 7267754Smsmith * distribution. 7367754Smsmith * 7467754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7567754Smsmith * Intel Code. 7667754Smsmith * 7767754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7867754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 7967754Smsmith * other dealings in products derived from or relating to the Covered Code 8067754Smsmith * without prior written authorization from Intel. 8167754Smsmith * 8267754Smsmith * 4. Disclaimer and Export Compliance 8367754Smsmith * 8467754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8567754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8667754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8767754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8867754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8967754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 9067754Smsmith * PARTICULAR PURPOSE. 9167754Smsmith * 9267754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9367754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9467754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9567754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9667754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9767754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9867754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9967754Smsmith * LIMITED REMEDY. 10067754Smsmith * 10167754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10267754Smsmith * software or system incorporating such software without first obtaining any 10367754Smsmith * required license or other approval from the U. S. Department of Commerce or 10467754Smsmith * any other agency or department of the United States Government. In the 10567754Smsmith * event Licensee exports any such software from the United States or 10667754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10767754Smsmith * ensure that the distribution and export/re-export of the software is in 10867754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 10967754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 11067754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 11167754Smsmith * software, or service, directly or indirectly, to any country for which the 11267754Smsmith * United States government or any agency thereof requires an export license, 11367754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11467754Smsmith * such license, approval or letter. 11567754Smsmith * 11667754Smsmith *****************************************************************************/ 11767754Smsmith 11867754Smsmith#define __AMRESOLV_C__ 11967754Smsmith 12067754Smsmith#include "acpi.h" 12167754Smsmith#include "amlcode.h" 12267754Smsmith#include "acparser.h" 12367754Smsmith#include "acdispat.h" 12467754Smsmith#include "acinterp.h" 12567754Smsmith#include "acnamesp.h" 12667754Smsmith#include "actables.h" 12767754Smsmith#include "acevents.h" 12867754Smsmith 12967754Smsmith 13067754Smsmith#define _COMPONENT INTERPRETER 13167754Smsmith MODULE_NAME ("amresolv") 13267754Smsmith 13367754Smsmith 13467754Smsmith/******************************************************************************* 13567754Smsmith * 13667754Smsmith * FUNCTION: AcpiAmlGetFieldUnitValue 13767754Smsmith * 13867754Smsmith * PARAMETERS: *FieldDesc - Pointer to a FieldUnit 13967754Smsmith * *ResultDesc - Pointer to an empty descriptor 14067754Smsmith * which will become a Number 14167754Smsmith * containing the field's value. 14267754Smsmith * 14367754Smsmith * RETURN: Status 14467754Smsmith * 14567754Smsmith * DESCRIPTION: Retrieve the value from a FieldUnit 14667754Smsmith * 14767754Smsmith ******************************************************************************/ 14867754Smsmith 14967754SmsmithACPI_STATUS 15067754SmsmithAcpiAmlGetFieldUnitValue ( 15167754Smsmith ACPI_OPERAND_OBJECT *FieldDesc, 15267754Smsmith ACPI_OPERAND_OBJECT *ResultDesc) 15367754Smsmith{ 15467754Smsmith ACPI_STATUS Status = AE_OK; 15567754Smsmith UINT32 Mask; 15667754Smsmith UINT8 *Location = NULL; 15767754Smsmith BOOLEAN Locked = FALSE; 15867754Smsmith 15967754Smsmith 16067754Smsmith FUNCTION_TRACE ("AmlGetFieldUnitValue"); 16167754Smsmith 16267754Smsmith 16367754Smsmith if (!FieldDesc) 16467754Smsmith { 16567754Smsmith DEBUG_PRINT (ACPI_ERROR, 16667754Smsmith ("AmlGetFieldUnitValue: Internal error - null field pointer\n")); 16767754Smsmith Status = AE_AML_NO_OPERAND; 16867754Smsmith } 16967754Smsmith 17067754Smsmith if (!(FieldDesc->Common.Flags & AOPOBJ_DATA_VALID)) 17167754Smsmith { 17267754Smsmith Status = AcpiDsGetFieldUnitArguments (FieldDesc); 17367754Smsmith if (ACPI_FAILURE (Status)) 17467754Smsmith { 17567754Smsmith return_ACPI_STATUS (Status); 17667754Smsmith } 17767754Smsmith } 17867754Smsmith 17967754Smsmith if (!FieldDesc->FieldUnit.Container) 18067754Smsmith { 18167754Smsmith DEBUG_PRINT (ACPI_ERROR, 18267754Smsmith ("AmlGetFieldUnitValue: Internal error - null container pointer\n")); 18367754Smsmith Status = AE_AML_INTERNAL; 18467754Smsmith } 18567754Smsmith 18667754Smsmith else if (ACPI_TYPE_BUFFER != FieldDesc->FieldUnit.Container->Common.Type) 18767754Smsmith { 18867754Smsmith DEBUG_PRINT (ACPI_ERROR, 18967754Smsmith ("AmlGetFieldUnitValue: Internal error - container is not a Buffer\n")); 19067754Smsmith Status = AE_AML_OPERAND_TYPE; 19167754Smsmith } 19267754Smsmith 19367754Smsmith else if (!ResultDesc) 19467754Smsmith { 19567754Smsmith DEBUG_PRINT (ACPI_ERROR, 19667754Smsmith ("AmlGetFieldUnitValue: Internal error - null result pointer\n")); 19767754Smsmith Status = AE_AML_INTERNAL; 19867754Smsmith } 19967754Smsmith 20067754Smsmith if (ACPI_FAILURE (Status)) 20167754Smsmith { 20267754Smsmith return_ACPI_STATUS (Status); 20367754Smsmith } 20467754Smsmith 20567754Smsmith 20667754Smsmith /* Get the global lock if needed */ 20767754Smsmith 20867754Smsmith Locked = AcpiAmlAcquireGlobalLock (FieldDesc->FieldUnit.LockRule); 20967754Smsmith 21067754Smsmith /* Field location is (base of buffer) + (byte offset) */ 21167754Smsmith 21267754Smsmith Location = FieldDesc->FieldUnit.Container->Buffer.Pointer 21367754Smsmith + FieldDesc->FieldUnit.Offset; 21467754Smsmith 21567754Smsmith /* 21667754Smsmith * Construct Mask with as many 1 bits as the field width 21767754Smsmith * 21867754Smsmith * NOTE: Only the bottom 5 bits are valid for a shift operation, so 21967754Smsmith * special care must be taken for any shift greater than 31 bits. 22067754Smsmith * 22167754Smsmith * TBD: [Unhandled] Fields greater than 32-bits will not work. 22267754Smsmith */ 22367754Smsmith 22467754Smsmith if (FieldDesc->FieldUnit.Length < 32) 22567754Smsmith { 22667754Smsmith Mask = ((UINT32) 1 << FieldDesc->FieldUnit.Length) - (UINT32) 1; 22767754Smsmith } 22867754Smsmith else 22967754Smsmith { 23067754Smsmith Mask = ACPI_UINT32_MAX; 23167754Smsmith } 23267754Smsmith 23367754Smsmith ResultDesc->Number.Type = (UINT8) ACPI_TYPE_NUMBER; 23467754Smsmith 23567754Smsmith /* Get the 32 bit value at the location */ 23667754Smsmith 23767754Smsmith MOVE_UNALIGNED32_TO_32 (&ResultDesc->Number.Value, Location); 23867754Smsmith 23967754Smsmith /* 24067754Smsmith * Shift the 32-bit word containing the field, and mask off the 24167754Smsmith * resulting value 24267754Smsmith */ 24367754Smsmith 24467754Smsmith ResultDesc->Number.Value = 24567754Smsmith (ResultDesc->Number.Value >> FieldDesc->FieldUnit.BitOffset) & Mask; 24667754Smsmith 24767754Smsmith DEBUG_PRINT (ACPI_INFO, 24867754Smsmith ("** Read from buffer %p byte %ld bit %d width %d addr %p mask %08lx val %08lx\n", 24967754Smsmith FieldDesc->FieldUnit.Container->Buffer.Pointer, 25067754Smsmith FieldDesc->FieldUnit.Offset, 25167754Smsmith FieldDesc->FieldUnit.BitOffset, 25267754Smsmith FieldDesc->FieldUnit.Length, 25367754Smsmith Location, Mask, ResultDesc->Number.Value)); 25467754Smsmith 25567754Smsmith /* Release global lock if we acquired it earlier */ 25667754Smsmith 25767754Smsmith AcpiAmlReleaseGlobalLock (Locked); 25867754Smsmith 25967754Smsmith return_ACPI_STATUS (Status); 26067754Smsmith} 26167754Smsmith 26267754Smsmith 26367754Smsmith/******************************************************************************* 26467754Smsmith * 26567754Smsmith * FUNCTION: AcpiAmlResolveToValue 26667754Smsmith * 26767754Smsmith * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can 26867754Smsmith * be either an (ACPI_OPERAND_OBJECT *) 26967754Smsmith * or an ACPI_HANDLE. 27067754Smsmith * 27167754Smsmith * RETURN: Status 27267754Smsmith * 27367754Smsmith * DESCRIPTION: Convert Reference entries on ObjStack to Rvalues 27467754Smsmith * 27567754Smsmith ******************************************************************************/ 27667754Smsmith 27767754SmsmithACPI_STATUS 27867754SmsmithAcpiAmlResolveToValue ( 27967754Smsmith ACPI_OPERAND_OBJECT **StackPtr, 28067754Smsmith ACPI_WALK_STATE *WalkState) 28167754Smsmith{ 28267754Smsmith ACPI_STATUS Status = AE_OK; 28367754Smsmith 28467754Smsmith 28567754Smsmith FUNCTION_TRACE_PTR ("AmlResolveToValue", StackPtr); 28667754Smsmith 28767754Smsmith 28867754Smsmith if (!StackPtr || !*StackPtr) 28967754Smsmith { 29067754Smsmith DEBUG_PRINT (ACPI_ERROR, 29167754Smsmith ("AmlResolveToValue: Internal error - null pointer\n")); 29267754Smsmith return_ACPI_STATUS (AE_AML_NO_OPERAND); 29367754Smsmith } 29467754Smsmith 29567754Smsmith 29667754Smsmith /* 29767754Smsmith * The entity pointed to by the StackPtr can be either 29867754Smsmith * 1) A valid ACPI_OPERAND_OBJECT, or 29967754Smsmith * 2) A ACPI_NAMESPACE_NODE (NamedObj) 30067754Smsmith */ 30167754Smsmith 30267754Smsmith if (VALID_DESCRIPTOR_TYPE (*StackPtr, ACPI_DESC_TYPE_INTERNAL)) 30367754Smsmith { 30467754Smsmith 30567754Smsmith Status = AcpiAmlResolveObjectToValue (StackPtr, WalkState); 30667754Smsmith if (ACPI_FAILURE (Status)) 30767754Smsmith { 30867754Smsmith return_ACPI_STATUS (Status); 30967754Smsmith } 31067754Smsmith } 31167754Smsmith 31267754Smsmith /* 31367754Smsmith * Object on the stack may have changed if AcpiAmlResolveObjectToValue() 31467754Smsmith * was called (i.e., we can't use an _else_ here.) 31567754Smsmith */ 31667754Smsmith 31767754Smsmith if (VALID_DESCRIPTOR_TYPE (*StackPtr, ACPI_DESC_TYPE_NAMED)) 31867754Smsmith { 31967754Smsmith Status = AcpiAmlResolveNodeToValue ((ACPI_NAMESPACE_NODE **) StackPtr); 32067754Smsmith } 32167754Smsmith 32267754Smsmith 32367754Smsmith DEBUG_PRINT (ACPI_INFO, 32467754Smsmith ("AmlResolveToValue: Returning resolved object %p\n", *StackPtr)); 32567754Smsmith 32667754Smsmith return_ACPI_STATUS (Status); 32767754Smsmith} 32867754Smsmith 32967754Smsmith 33067754Smsmith/******************************************************************************* 33167754Smsmith * 33267754Smsmith * FUNCTION: AcpiAmlResolveObjectToValue 33367754Smsmith * 33467754Smsmith * PARAMETERS: StackPtr - Pointer to a stack location that contains a 33567754Smsmith * ptr to an internal object. 33667754Smsmith * 33767754Smsmith * RETURN: Status 33867754Smsmith * 33967754Smsmith * DESCRIPTION: Retrieve the value from an internal object. The Reference type 34067754Smsmith * uses the associated AML opcode to determine the value. 34167754Smsmith * 34267754Smsmith ******************************************************************************/ 34367754Smsmith 34467754SmsmithACPI_STATUS 34567754SmsmithAcpiAmlResolveObjectToValue ( 34667754Smsmith ACPI_OPERAND_OBJECT **StackPtr, 34767754Smsmith ACPI_WALK_STATE *WalkState) 34867754Smsmith{ 34967754Smsmith ACPI_OPERAND_OBJECT *StackDesc; 35067754Smsmith ACPI_STATUS Status = AE_OK; 35167754Smsmith ACPI_HANDLE TempHandle = NULL; 35267754Smsmith ACPI_OPERAND_OBJECT *ObjDesc = NULL; 35367754Smsmith UINT32 Index = 0; 35467754Smsmith UINT16 Opcode; 35567754Smsmith 35667754Smsmith 35767754Smsmith FUNCTION_TRACE ("AmlResolveObjectToValue"); 35867754Smsmith 35967754Smsmith 36067754Smsmith StackDesc = *StackPtr; 36167754Smsmith 36267754Smsmith /* This is an ACPI_OPERAND_OBJECT */ 36367754Smsmith 36467754Smsmith switch (StackDesc->Common.Type) 36567754Smsmith { 36667754Smsmith 36767754Smsmith case INTERNAL_TYPE_REFERENCE: 36867754Smsmith 36967754Smsmith Opcode = StackDesc->Reference.OpCode; 37067754Smsmith 37167754Smsmith switch (Opcode) 37267754Smsmith { 37367754Smsmith 37467754Smsmith case AML_NAME_OP: 37567754Smsmith 37667754Smsmith /* 37767754Smsmith * Convert indirect name ptr to a direct name ptr. 37867754Smsmith * Then, AcpiAmlResolveNodeToValue can be used to get the value 37967754Smsmith */ 38067754Smsmith 38167754Smsmith TempHandle = StackDesc->Reference.Object; 38267754Smsmith 38367754Smsmith /* Delete the Reference Object */ 38467754Smsmith 38567754Smsmith AcpiCmRemoveReference (StackDesc); 38667754Smsmith 38767754Smsmith /* Put direct name pointer onto stack and exit */ 38867754Smsmith 38967754Smsmith (*StackPtr) = TempHandle; 39067754Smsmith Status = AE_OK; 39167754Smsmith break; 39267754Smsmith 39367754Smsmith 39467754Smsmith case AML_LOCAL_OP: 39567754Smsmith 39667754Smsmith Index = StackDesc->Reference.Offset; 39767754Smsmith 39867754Smsmith /* 39967754Smsmith * Get the local from the method's state info 40067754Smsmith * Note: this increments the local's object reference count 40167754Smsmith */ 40267754Smsmith 40367754Smsmith Status = AcpiDsMethodDataGetValue (MTH_TYPE_LOCAL, Index, 40467754Smsmith WalkState, &ObjDesc); 40567754Smsmith if (ACPI_FAILURE (Status)) 40667754Smsmith { 40767754Smsmith return_ACPI_STATUS (Status); 40867754Smsmith } 40967754Smsmith 41067754Smsmith /* 41167754Smsmith * Now we can delete the original Reference Object and 41267754Smsmith * replace it with the resolve value 41367754Smsmith */ 41467754Smsmith 41567754Smsmith AcpiCmRemoveReference (StackDesc); 41667754Smsmith *StackPtr = ObjDesc; 41767754Smsmith 41867754Smsmith DEBUG_PRINT (ACPI_INFO, 41967754Smsmith ("AmlResolveObjectToValue: [Local%d] ValueObj is %p\n", 42067754Smsmith Index, ObjDesc)); 42167754Smsmith 42267754Smsmith if (ACPI_TYPE_NUMBER == ObjDesc->Common.Type) 42367754Smsmith { 42467754Smsmith /* Value is a Number */ 42567754Smsmith 42667754Smsmith DEBUG_PRINT (ACPI_INFO, 42767754Smsmith ("AmlResolveObjectToValue: [Local%d] value is [0x%X] \n", 42867754Smsmith Index, ObjDesc->Number.Value)); 42967754Smsmith } 43067754Smsmith 43167754Smsmith break; 43267754Smsmith 43367754Smsmith 43467754Smsmith case AML_ARG_OP: 43567754Smsmith 43667754Smsmith Index = StackDesc->Reference.Offset; 43767754Smsmith 43867754Smsmith 43967754Smsmith /* 44067754Smsmith * Get the argument from the method's state info 44167754Smsmith * Note: this increments the object reference count 44267754Smsmith */ 44367754Smsmith 44467754Smsmith Status = AcpiDsMethodDataGetValue (MTH_TYPE_ARG, Index, 44567754Smsmith WalkState, &ObjDesc); 44667754Smsmith if (ACPI_FAILURE (Status)) 44767754Smsmith { 44867754Smsmith return_ACPI_STATUS (Status); 44967754Smsmith } 45067754Smsmith 45167754Smsmith /* 45267754Smsmith * Now we can delete the original Reference Object and 45367754Smsmith * replace it with the resolve value 45467754Smsmith */ 45567754Smsmith 45667754Smsmith AcpiCmRemoveReference (StackDesc); 45767754Smsmith *StackPtr = ObjDesc; 45867754Smsmith 45967754Smsmith DEBUG_PRINT (TRACE_EXEC, 46067754Smsmith ("AmlResolveObjectToValue: [Arg%d] ValueObj is %p\n", 46167754Smsmith Index, ObjDesc)); 46267754Smsmith 46367754Smsmith if (ACPI_TYPE_NUMBER == ObjDesc->Common.Type) 46467754Smsmith { 46567754Smsmith /* Value is a Number */ 46667754Smsmith 46767754Smsmith DEBUG_PRINT (ACPI_INFO, 46867754Smsmith ("AmlResolveObjectToValue: [Arg%d] value is [0x%X] \n", 46967754Smsmith Index, ObjDesc->Number.Value)); 47067754Smsmith } 47167754Smsmith 47267754Smsmith break; 47367754Smsmith 47467754Smsmith 47567754Smsmith /* 47667754Smsmith * TBD: [Restructure] These next three opcodes change the type of 47767754Smsmith * the object, which is actually a no-no. 47867754Smsmith */ 47967754Smsmith 48067754Smsmith case AML_ZERO_OP: 48167754Smsmith 48267754Smsmith StackDesc->Common.Type = (UINT8) ACPI_TYPE_NUMBER; 48367754Smsmith StackDesc->Number.Value = 0; 48467754Smsmith break; 48567754Smsmith 48667754Smsmith 48767754Smsmith case AML_ONE_OP: 48867754Smsmith 48967754Smsmith StackDesc->Common.Type = (UINT8) ACPI_TYPE_NUMBER; 49067754Smsmith StackDesc->Number.Value = 1; 49167754Smsmith break; 49267754Smsmith 49367754Smsmith 49467754Smsmith case AML_ONES_OP: 49567754Smsmith 49667754Smsmith StackDesc->Common.Type = (UINT8) ACPI_TYPE_NUMBER; 49767754Smsmith StackDesc->Number.Value = ACPI_INTEGER_MAX; 49867754Smsmith break; 49967754Smsmith 50067754Smsmith 50167754Smsmith case AML_INDEX_OP: 50267754Smsmith 50367754Smsmith switch (StackDesc->Reference.TargetType) 50467754Smsmith { 50567754Smsmith case ACPI_TYPE_BUFFER_FIELD: 50667754Smsmith 50767754Smsmith /* Just return - leave the Reference on the stack */ 50867754Smsmith break; 50967754Smsmith 51067754Smsmith 51167754Smsmith case ACPI_TYPE_PACKAGE: 51267754Smsmith ObjDesc = *StackDesc->Reference.Where; 51367754Smsmith if (ObjDesc) 51467754Smsmith { 51567754Smsmith /* 51667754Smsmith * Valid obj descriptor, copy pointer to return value 51767754Smsmith * (i.e., dereference the package index) 51867754Smsmith * Delete the ref object, increment the returned object 51967754Smsmith */ 52067754Smsmith AcpiCmRemoveReference (StackDesc); 52167754Smsmith AcpiCmAddReference (ObjDesc); 52267754Smsmith *StackPtr = ObjDesc; 52367754Smsmith } 52467754Smsmith 52567754Smsmith else 52667754Smsmith { 52767754Smsmith /* 52867754Smsmith * A NULL object descriptor means an unitialized element of 52967754Smsmith * the package, can't deref it 53067754Smsmith */ 53167754Smsmith 53267754Smsmith DEBUG_PRINT (ACPI_ERROR, 53367754Smsmith ("AmlResolveObjectToValue: Attempt to deref an Index to NULL pkg element Idx=%p\n", StackDesc)); 53467754Smsmith Status = AE_AML_UNINITIALIZED_ELEMENT; 53567754Smsmith } 53667754Smsmith break; 53767754Smsmith 53867754Smsmith default: 53967754Smsmith /* Invalid reference OBJ*/ 54067754Smsmith 54167754Smsmith DEBUG_PRINT (ACPI_ERROR, 54267754Smsmith ("AmlResolveObjectToValue: Unknown TargetType %d in Index/Reference obj %p\n", 54367754Smsmith StackDesc->Reference.TargetType, StackDesc)); 54467754Smsmith Status = AE_AML_INTERNAL; 54567754Smsmith break; 54667754Smsmith } 54767754Smsmith 54867754Smsmith break; 54967754Smsmith 55067754Smsmith 55167754Smsmith case AML_DEBUG_OP: 55267754Smsmith 55367754Smsmith /* Just leave the object as-is */ 55467754Smsmith break; 55567754Smsmith 55667754Smsmith 55767754Smsmith default: 55867754Smsmith 55967754Smsmith DEBUG_PRINT (ACPI_ERROR, 56067754Smsmith ("AmlResolveObjectToValue: Unknown Reference object subtype %02x in %p\n", 56167754Smsmith Opcode, StackDesc)); 56267754Smsmith Status = AE_AML_INTERNAL; 56367754Smsmith 56467754Smsmith } /* switch (Opcode) */ 56567754Smsmith 56667754Smsmith 56767754Smsmith if (ACPI_FAILURE (Status)) 56867754Smsmith { 56967754Smsmith return_ACPI_STATUS (Status); 57067754Smsmith } 57167754Smsmith 57267754Smsmith break; /* case INTERNAL_TYPE_REFERENCE */ 57367754Smsmith 57467754Smsmith 57567754Smsmith case ACPI_TYPE_FIELD_UNIT: 57667754Smsmith 57767754Smsmith ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_ANY); 57867754Smsmith if (!ObjDesc) 57967754Smsmith { 58067754Smsmith /* Descriptor allocation failure */ 58167754Smsmith 58267754Smsmith return_ACPI_STATUS (AE_NO_MEMORY); 58367754Smsmith } 58467754Smsmith 58567754Smsmith Status = AcpiAmlGetFieldUnitValue (StackDesc, ObjDesc); 58667754Smsmith if (ACPI_FAILURE (Status)) 58767754Smsmith { 58867754Smsmith AcpiCmRemoveReference (ObjDesc); 58967754Smsmith ObjDesc = NULL; 59067754Smsmith } 59167754Smsmith 59267754Smsmith *StackPtr = (void *) ObjDesc; 59367754Smsmith break; 59467754Smsmith 59567754Smsmith 59667754Smsmith case INTERNAL_TYPE_BANK_FIELD: 59767754Smsmith 59867754Smsmith ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_ANY); 59967754Smsmith if (!ObjDesc) 60067754Smsmith { 60167754Smsmith /* Descriptor allocation failure */ 60267754Smsmith 60367754Smsmith return_ACPI_STATUS (AE_NO_MEMORY); 60467754Smsmith } 60567754Smsmith 60667754Smsmith Status = AcpiAmlGetFieldUnitValue (StackDesc, ObjDesc); 60767754Smsmith if (ACPI_FAILURE (Status)) 60867754Smsmith { 60967754Smsmith AcpiCmRemoveReference (ObjDesc); 61067754Smsmith ObjDesc = NULL; 61167754Smsmith } 61267754Smsmith 61367754Smsmith *StackPtr = (void *) ObjDesc; 61467754Smsmith break; 61567754Smsmith 61667754Smsmith 61767754Smsmith /* TBD: [Future] - may need to handle IndexField, and DefField someday */ 61867754Smsmith 61967754Smsmith default: 62067754Smsmith 62167754Smsmith break; 62267754Smsmith 62367754Smsmith } /* switch (StackDesc->Common.Type) */ 62467754Smsmith 62567754Smsmith 62667754Smsmith return_ACPI_STATUS (Status); 62767754Smsmith} 62867754Smsmith 62967754Smsmith 630