exresop.c revision 69746
167754Smsmith 267754Smsmith/****************************************************************************** 367754Smsmith * 467754Smsmith * Module Name: amresop - AML Interpreter operand/object resolution 569746Smsmith * $Revision: 18 $ 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 __AMRESOP_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 ("amresop") 13267754Smsmith 13367754Smsmith 13469746Smsmith 13567754Smsmith/******************************************************************************* 13667754Smsmith * 13769746Smsmith * FUNCTION: AcpiAmlCheckObjectType 13869746Smsmith * 13969746Smsmith * PARAMETERS: TypeNeeded Object type needed 14069746Smsmith * ThisType Actual object type 14169746Smsmith * Object Object pointer 14269746Smsmith * 14369746Smsmith * RETURN: Status 14469746Smsmith * 14569746Smsmith * DESCRIPTION: Check required type against actual type 14669746Smsmith * 14769746Smsmith ******************************************************************************/ 14869746Smsmith 14969746SmsmithACPI_STATUS 15069746SmsmithAcpiAmlCheckObjectType ( 15169746Smsmith ACPI_OBJECT_TYPE TypeNeeded, 15269746Smsmith ACPI_OBJECT_TYPE ThisType, 15369746Smsmith void *Object) 15469746Smsmith{ 15569746Smsmith 15669746Smsmith 15769746Smsmith if (TypeNeeded == ACPI_TYPE_ANY) 15869746Smsmith { 15969746Smsmith /* All types OK, so we don't perform any typechecks */ 16069746Smsmith 16169746Smsmith return (AE_OK); 16269746Smsmith } 16369746Smsmith 16469746Smsmith 16569746Smsmith if (TypeNeeded != ThisType) 16669746Smsmith { 16769746Smsmith DEBUG_PRINT (ACPI_INFO, 16869746Smsmith ("AmlResolveOperands: Needed [%s], found [%s] %p\n", 16969746Smsmith AcpiCmGetTypeName (TypeNeeded), 17069746Smsmith AcpiCmGetTypeName (ThisType), Object)); 17169746Smsmith 17269746Smsmith return (AE_AML_OPERAND_TYPE); 17369746Smsmith } 17469746Smsmith 17569746Smsmith 17669746Smsmith return (AE_OK); 17769746Smsmith} 17869746Smsmith 17969746Smsmith 18069746Smsmith/******************************************************************************* 18169746Smsmith * 18267754Smsmith * FUNCTION: AcpiAmlResolveOperands 18367754Smsmith * 18467754Smsmith * PARAMETERS: Opcode Opcode being interpreted 18567754Smsmith * StackPtr Top of operand stack 18667754Smsmith * 18767754Smsmith * RETURN: Status 18867754Smsmith * 18967754Smsmith * DESCRIPTION: Convert stack entries to required types 19067754Smsmith * 19167754Smsmith * Each nibble in ArgTypes represents one required operand 19267754Smsmith * and indicates the required Type: 19367754Smsmith * 19467754Smsmith * The corresponding stack entry will be converted to the 19567754Smsmith * required type if possible, else return an exception 19667754Smsmith * 19767754Smsmith ******************************************************************************/ 19867754Smsmith 19967754SmsmithACPI_STATUS 20067754SmsmithAcpiAmlResolveOperands ( 20167754Smsmith UINT16 Opcode, 20267754Smsmith ACPI_OPERAND_OBJECT **StackPtr, 20367754Smsmith ACPI_WALK_STATE *WalkState) 20467754Smsmith{ 20567754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 20667754Smsmith ACPI_STATUS Status = AE_OK; 20767754Smsmith UINT8 ObjectType; 20867754Smsmith ACPI_HANDLE TempHandle; 20967754Smsmith UINT32 ArgTypes; 21067754Smsmith ACPI_OPCODE_INFO *OpInfo; 21167754Smsmith UINT32 ThisArgType; 21269746Smsmith ACPI_OBJECT_TYPE TypeNeeded; 21367754Smsmith 21467754Smsmith 21567754Smsmith FUNCTION_TRACE_U32 ("AmlResolveOperands", Opcode); 21667754Smsmith 21767754Smsmith 21867754Smsmith OpInfo = AcpiPsGetOpcodeInfo (Opcode); 21967754Smsmith if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) 22067754Smsmith { 22167754Smsmith return_ACPI_STATUS (AE_AML_BAD_OPCODE); 22267754Smsmith } 22367754Smsmith 22467754Smsmith 22567754Smsmith ArgTypes = OpInfo->RuntimeArgs; 22667754Smsmith if (ArgTypes == ARGI_INVALID_OPCODE) 22767754Smsmith { 22867754Smsmith DEBUG_PRINT (ACPI_ERROR, 22969746Smsmith ("AmlResolveOperands: Internal error - %X is not a valid AML opcode\n", Opcode)); 23069746Smsmith 23169746Smsmith return_ACPI_STATUS (AE_AML_INTERNAL); 23267754Smsmith } 23367754Smsmith 23467754Smsmith DEBUG_PRINT (TRACE_EXEC, 23567754Smsmith ("AmlResolveOperands: Opcode %X OperandTypes=%X \n", 23667754Smsmith Opcode, ArgTypes)); 23767754Smsmith 23867754Smsmith 23967754Smsmith /* 24067754Smsmith * Normal exit is with *Types == '\0' at end of string. 24167754Smsmith * Function will return an exception from within the loop upon 24267754Smsmith * finding an entry which is not, and cannot be converted 24367754Smsmith * to, the required type; if stack underflows; or upon 24467754Smsmith * finding a NULL stack entry (which "should never happen"). 24567754Smsmith */ 24667754Smsmith 24767754Smsmith while (GET_CURRENT_ARG_TYPE (ArgTypes)) 24867754Smsmith { 24967754Smsmith if (!StackPtr || !*StackPtr) 25067754Smsmith { 25167754Smsmith DEBUG_PRINT (ACPI_ERROR, 25267754Smsmith ("AmlResolveOperands: Internal error - null stack entry at %X\n", StackPtr)); 25369746Smsmith 25469746Smsmith return_ACPI_STATUS (AE_AML_INTERNAL); 25567754Smsmith } 25667754Smsmith 25767754Smsmith /* Extract useful items */ 25867754Smsmith 25967754Smsmith ObjDesc = *StackPtr; 26067754Smsmith 26167754Smsmith /* Decode the descriptor type */ 26267754Smsmith 26367754Smsmith if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) 26467754Smsmith { 26567754Smsmith /* Node */ 26667754Smsmith 26767754Smsmith ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; 26867754Smsmith } 26967754Smsmith 27067754Smsmith else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL)) 27167754Smsmith { 27267754Smsmith /* ACPI internal object */ 27367754Smsmith 27467754Smsmith ObjectType = ObjDesc->Common.Type; 27567754Smsmith 27667754Smsmith /* Check for bad ACPI_OBJECT_TYPE */ 27767754Smsmith 27867754Smsmith if (!AcpiAmlValidateObjectType (ObjectType)) 27967754Smsmith { 28067754Smsmith DEBUG_PRINT (ACPI_ERROR, 28169746Smsmith ("AmlResolveOperands: Bad operand object type [%X]\n", 28267754Smsmith ObjectType)); 28369746Smsmith 28469746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 28567754Smsmith } 28667754Smsmith 28767754Smsmith if (ObjectType == (UINT8) INTERNAL_TYPE_REFERENCE) 28867754Smsmith { 28967754Smsmith /* 29067754Smsmith * Decode the Reference 29167754Smsmith */ 29267754Smsmith 29367754Smsmith OpInfo = AcpiPsGetOpcodeInfo (Opcode); 29467754Smsmith if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) 29567754Smsmith { 29667754Smsmith return_ACPI_STATUS (AE_AML_BAD_OPCODE); 29767754Smsmith } 29867754Smsmith 29967754Smsmith 30067754Smsmith switch (ObjDesc->Reference.OpCode) 30167754Smsmith { 30267754Smsmith case AML_ZERO_OP: 30367754Smsmith case AML_ONE_OP: 30467754Smsmith case AML_ONES_OP: 30567754Smsmith case AML_DEBUG_OP: 30667754Smsmith case AML_NAME_OP: 30767754Smsmith case AML_INDEX_OP: 30867754Smsmith case AML_ARG_OP: 30967754Smsmith case AML_LOCAL_OP: 31067754Smsmith 31167754Smsmith DEBUG_ONLY_MEMBERS (DEBUG_PRINT (ACPI_INFO, 31267754Smsmith ("Reference Opcode: %s\n", OpInfo->Name))); 31367754Smsmith break; 31467754Smsmith 31567754Smsmith default: 31667754Smsmith DEBUG_PRINT (ACPI_INFO, 31767754Smsmith ("Reference Opcode: Unknown [%02x]\n", 31867754Smsmith ObjDesc->Reference.OpCode)); 31967754Smsmith 32069746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 32167754Smsmith break; 32267754Smsmith } 32367754Smsmith } 32467754Smsmith } 32567754Smsmith 32667754Smsmith else 32767754Smsmith { 32867754Smsmith /* Invalid descriptor */ 32967754Smsmith 33067754Smsmith DEBUG_PRINT (ACPI_ERROR, 33169746Smsmith ("Bad descriptor type %X in Obj %p\n", 33267754Smsmith ObjDesc->Common.DataType, ObjDesc)); 33367754Smsmith 33469746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 33567754Smsmith } 33667754Smsmith 33767754Smsmith 33867754Smsmith /* 33969746Smsmith * Get one argument type, point to the next 34067754Smsmith */ 34167754Smsmith 34267754Smsmith ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes); 34367754Smsmith INCREMENT_ARG_LIST (ArgTypes); 34467754Smsmith 34567754Smsmith 34669746Smsmith /* 34769746Smsmith * Handle cases where the object does not need to be 34869746Smsmith * resolved to a value 34969746Smsmith */ 35069746Smsmith 35167754Smsmith switch (ThisArgType) 35267754Smsmith { 35367754Smsmith 35467754Smsmith case ARGI_REFERENCE: /* Reference */ 35567754Smsmith case ARGI_TARGETREF: 35667754Smsmith 35767754Smsmith /* Need an operand of type INTERNAL_TYPE_REFERENCE */ 35867754Smsmith 35967754Smsmith if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) /* direct name ptr OK as-is */ 36067754Smsmith { 36169746Smsmith goto NextOperand; 36267754Smsmith } 36367754Smsmith 36469746Smsmith Status = AcpiAmlCheckObjectType (INTERNAL_TYPE_REFERENCE, 36569746Smsmith ObjectType, ObjDesc); 36669746Smsmith if (ACPI_FAILURE (Status)) 36767754Smsmith { 36869746Smsmith return_ACPI_STATUS (Status); 36967754Smsmith } 37067754Smsmith 37169746Smsmith 37267754Smsmith if (AML_NAME_OP == ObjDesc->Reference.OpCode) 37367754Smsmith { 37467754Smsmith /* 37567754Smsmith * Convert an indirect name ptr to direct name ptr and put 37667754Smsmith * it on the stack 37767754Smsmith */ 37867754Smsmith 37967754Smsmith TempHandle = ObjDesc->Reference.Object; 38067754Smsmith AcpiCmRemoveReference (ObjDesc); 38167754Smsmith (*StackPtr) = TempHandle; 38267754Smsmith } 38369746Smsmith 38469746Smsmith goto NextOperand; 38567754Smsmith break; 38667754Smsmith 38767754Smsmith 38869746Smsmith case ARGI_ANYTYPE: 38967754Smsmith 39069746Smsmith /* 39169746Smsmith * We don't want to resolve IndexOp reference objects during 39269746Smsmith * a store because this would be an implicit DeRefOf operation. 39369746Smsmith * Instead, we just want to store the reference object. 39469746Smsmith * -- All others must be resolved below. 39569746Smsmith */ 39667754Smsmith 39769746Smsmith if ((Opcode == AML_STORE_OP) && 39869746Smsmith ((*StackPtr)->Common.Type == INTERNAL_TYPE_REFERENCE) && 39969746Smsmith ((*StackPtr)->Reference.OpCode == AML_INDEX_OP)) 40067754Smsmith { 40169746Smsmith goto NextOperand; 40267754Smsmith } 40367754Smsmith break; 40469746Smsmith } 40567754Smsmith 40667754Smsmith 40767754Smsmith 40869746Smsmith /* 40969746Smsmith * Resolve this object to a value 41069746Smsmith */ 41167754Smsmith 41269746Smsmith Status = AcpiAmlResolveToValue (StackPtr, WalkState); 41369746Smsmith if (ACPI_FAILURE (Status)) 41469746Smsmith { 41569746Smsmith return_ACPI_STATUS (Status); 41669746Smsmith } 41767754Smsmith 41869746Smsmith 41969746Smsmith /* 42069746Smsmith * Check the resulting object (value) type 42169746Smsmith */ 42269746Smsmith switch (ThisArgType) 42369746Smsmith { 42469746Smsmith /* 42569746Smsmith * For the simple cases, only one type of resolved object 42669746Smsmith * is allowed 42769746Smsmith */ 42869746Smsmith case ARGI_NUMBER: /* Number */ 42969746Smsmith 43069746Smsmith /* Need an operand of type ACPI_TYPE_NUMBER */ 43169746Smsmith 43269746Smsmith TypeNeeded = ACPI_TYPE_NUMBER; 43367754Smsmith break; 43467754Smsmith 43567754Smsmith case ARGI_BUFFER: 43667754Smsmith 43767754Smsmith /* Need an operand of type ACPI_TYPE_BUFFER */ 43867754Smsmith 43969746Smsmith TypeNeeded = ACPI_TYPE_BUFFER; 44067754Smsmith break; 44167754Smsmith 44267754Smsmith case ARGI_MUTEX: 44367754Smsmith 44467754Smsmith /* Need an operand of type ACPI_TYPE_MUTEX */ 44567754Smsmith 44669746Smsmith TypeNeeded = ACPI_TYPE_MUTEX; 44767754Smsmith break; 44867754Smsmith 44967754Smsmith case ARGI_EVENT: 45067754Smsmith 45167754Smsmith /* Need an operand of type ACPI_TYPE_EVENT */ 45267754Smsmith 45369746Smsmith TypeNeeded = ACPI_TYPE_EVENT; 45467754Smsmith break; 45567754Smsmith 45667754Smsmith case ARGI_REGION: 45767754Smsmith 45867754Smsmith /* Need an operand of type ACPI_TYPE_REGION */ 45967754Smsmith 46069746Smsmith TypeNeeded = ACPI_TYPE_REGION; 46167754Smsmith break; 46267754Smsmith 46369746Smsmith case ARGI_IF: /* If */ 46467754Smsmith 46567754Smsmith /* Need an operand of type INTERNAL_TYPE_IF */ 46667754Smsmith 46769746Smsmith TypeNeeded = INTERNAL_TYPE_IF; 46867754Smsmith break; 46967754Smsmith 47067754Smsmith case ARGI_PACKAGE: /* Package */ 47167754Smsmith 47267754Smsmith /* Need an operand of type ACPI_TYPE_PACKAGE */ 47367754Smsmith 47469746Smsmith TypeNeeded = ACPI_TYPE_PACKAGE; 47569746Smsmith break; 47667754Smsmith 47769746Smsmith case ARGI_ANYTYPE: 47869746Smsmith 47969746Smsmith /* Any operand type will do */ 48069746Smsmith 48169746Smsmith TypeNeeded = ACPI_TYPE_ANY; 48267754Smsmith break; 48367754Smsmith 48467754Smsmith 48569746Smsmith /* 48669746Smsmith * The more complex cases allow multiple resolved object types 48769746Smsmith */ 48867754Smsmith 48969746Smsmith case ARGI_STRING: 49067754Smsmith 49169746Smsmith /* Need an operand of type ACPI_TYPE_STRING or ACPI_TYPE_BUFFER */ 49267754Smsmith 49369746Smsmith if ((ACPI_TYPE_STRING != (*StackPtr)->Common.Type) && 49469746Smsmith (ACPI_TYPE_BUFFER != (*StackPtr)->Common.Type)) 49567754Smsmith { 49669746Smsmith DEBUG_PRINT (ACPI_INFO, 49769746Smsmith ("AmlResolveOperands: Needed [String or Buffer], found [%s] %p\n", 49869746Smsmith AcpiCmGetTypeName ((*StackPtr)->Common.Type), *StackPtr)); 49967754Smsmith 50069746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 50167754Smsmith } 50269746Smsmith goto NextOperand; 50367754Smsmith break; 50467754Smsmith 50567754Smsmith 50667754Smsmith case ARGI_DATAOBJECT: 50767754Smsmith /* 50867754Smsmith * ARGI_DATAOBJECT is only used by the SizeOf operator. 50967754Smsmith * 51067754Smsmith * The ACPI specification allows SizeOf to return the size of 51167754Smsmith * a Buffer, String or Package. However, the MS ACPI.SYS AML 51267754Smsmith * Interpreter also allows an Node reference to return without 51367754Smsmith * error with a size of 4. 51467754Smsmith */ 51567754Smsmith 51667754Smsmith /* Need a buffer, string, package or Node reference */ 51767754Smsmith 51867754Smsmith if (((*StackPtr)->Common.Type != ACPI_TYPE_BUFFER) && 51967754Smsmith ((*StackPtr)->Common.Type != ACPI_TYPE_STRING) && 52067754Smsmith ((*StackPtr)->Common.Type != ACPI_TYPE_PACKAGE) && 52167754Smsmith ((*StackPtr)->Common.Type != INTERNAL_TYPE_REFERENCE)) 52267754Smsmith { 52367754Smsmith DEBUG_PRINT (ACPI_INFO, 52469746Smsmith ("AmlResolveOperands: Needed [Buf/Str/Pkg/Ref], found [%s] %p\n", 52569746Smsmith AcpiCmGetTypeName ((*StackPtr)->Common.Type), *StackPtr)); 52669746Smsmith 52769746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 52867754Smsmith } 52967754Smsmith 53067754Smsmith /* 53167754Smsmith * If this is a reference, only allow a reference to an Node. 53267754Smsmith */ 53367754Smsmith if ((*StackPtr)->Common.Type == INTERNAL_TYPE_REFERENCE) 53467754Smsmith { 53567754Smsmith if (!(*StackPtr)->Reference.Node) 53667754Smsmith { 53767754Smsmith DEBUG_PRINT (ACPI_INFO, 53869746Smsmith ("AmlResolveOperands: Needed [Node Reference], found [%p]\n", 53969746Smsmith *StackPtr)); 54069746Smsmith 54169746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 54267754Smsmith } 54367754Smsmith } 54469746Smsmith goto NextOperand; 54567754Smsmith break; 54667754Smsmith 54767754Smsmith 54867754Smsmith case ARGI_COMPLEXOBJ: 54967754Smsmith 55067754Smsmith /* Need a buffer or package */ 55167754Smsmith 55267754Smsmith if (((*StackPtr)->Common.Type != ACPI_TYPE_BUFFER) && 55367754Smsmith ((*StackPtr)->Common.Type != ACPI_TYPE_PACKAGE)) 55467754Smsmith { 55567754Smsmith DEBUG_PRINT (ACPI_INFO, 55669746Smsmith ("AmlResolveOperands: Needed [Buf/Pkg], found [%s] %p\n", 55769746Smsmith AcpiCmGetTypeName ((*StackPtr)->Common.Type), *StackPtr)); 55869746Smsmith 55969746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 56067754Smsmith } 56169746Smsmith goto NextOperand; 56267754Smsmith break; 56367754Smsmith 56467754Smsmith 56569746Smsmith default: 56667754Smsmith 56769746Smsmith /* Unknown type */ 56869746Smsmith 56967754Smsmith DEBUG_PRINT (ACPI_ERROR, 57069746Smsmith ("AmlResolveOperands: Internal error - Unknown ARGI type %X\n", 57167754Smsmith ThisArgType)); 57267754Smsmith 57369746Smsmith return_ACPI_STATUS (AE_BAD_PARAMETER); 57469746Smsmith } 57567754Smsmith 57667754Smsmith 57769746Smsmith /* 57869746Smsmith * Make sure that the original object was resolved to the 57969746Smsmith * required object type (Simple cases only). 58069746Smsmith */ 58169746Smsmith Status = AcpiAmlCheckObjectType (TypeNeeded, 58269746Smsmith (*StackPtr)->Common.Type, *StackPtr); 58369746Smsmith if (ACPI_FAILURE (Status)) 58469746Smsmith { 58569746Smsmith return_ACPI_STATUS (Status); 58669746Smsmith } 58769746Smsmith 58869746Smsmith 58969746Smsmith 59069746Smsmith 59169746SmsmithNextOperand: 59267754Smsmith /* 59367754Smsmith * If more operands needed, decrement StackPtr to point 59469746Smsmith * to next operand on stack 59567754Smsmith */ 59667754Smsmith if (GET_CURRENT_ARG_TYPE (ArgTypes)) 59767754Smsmith { 59867754Smsmith StackPtr--; 59967754Smsmith } 60067754Smsmith 60167754Smsmith } /* while (*Types) */ 60267754Smsmith 60367754Smsmith 60467754Smsmith 60569746Smsmith return_ACPI_STATUS (Status); 60667754Smsmith} 60767754Smsmith 60867754Smsmith 609