exresop.c revision 204773
167754Smsmith 267754Smsmith/****************************************************************************** 367754Smsmith * 477424Smsmith * Module Name: exresop - AML Interpreter operand/object resolution 567754Smsmith * 667754Smsmith *****************************************************************************/ 767754Smsmith 867754Smsmith/****************************************************************************** 967754Smsmith * 1067754Smsmith * 1. Copyright Notice 1167754Smsmith * 12202771Sjkim * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. 1370243Smsmith * All rights reserved. 1467754Smsmith * 1567754Smsmith * 2. License 1667754Smsmith * 1767754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 1867754Smsmith * rights. You may have additional license terms from the party that provided 1967754Smsmith * you this software, covering your right to use that party's intellectual 2067754Smsmith * property rights. 2167754Smsmith * 2267754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2367754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2467754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2567754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2667754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2767754Smsmith * Code in any form, with the right to sublicense such rights; and 2867754Smsmith * 2967754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3067754Smsmith * license (with the right to sublicense), under only those claims of Intel 3167754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3267754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3367754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3467754Smsmith * license, and in no event shall the patent license extend to any additions 3567754Smsmith * to or modifications of the Original Intel Code. No other license or right 3667754Smsmith * is granted directly or by implication, estoppel or otherwise; 3767754Smsmith * 3867754Smsmith * The above copyright and patent license is granted only if the following 3967754Smsmith * conditions are met: 4067754Smsmith * 4167754Smsmith * 3. Conditions 4267754Smsmith * 4367754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4467754Smsmith * Redistribution of source code of any substantial portion of the Covered 4567754Smsmith * Code or modification with rights to further distribute source must include 4667754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4767754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 4867754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 4967754Smsmith * contain a file documenting the changes Licensee made to create that Covered 5067754Smsmith * Code and the date of any change. Licensee must include in that file the 5167754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5267754Smsmith * must include a prominent statement that the modification is derived, 5367754Smsmith * directly or indirectly, from Original Intel Code. 5467754Smsmith * 5567754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5667754Smsmith * Redistribution of source code of any substantial portion of the Covered 5767754Smsmith * Code or modification without rights to further distribute source must 5867754Smsmith * include the following Disclaimer and Export Compliance provision in the 5967754Smsmith * documentation and/or other materials provided with distribution. In 6067754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6167754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6267754Smsmith * license from Licensee to its licensee is limited to the intellectual 6367754Smsmith * property embodied in the software Licensee provides to its licensee, and 6467754Smsmith * not to intellectual property embodied in modifications its licensee may 6567754Smsmith * make. 6667754Smsmith * 6767754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 6867754Smsmith * substantial portion of the Covered Code or modification must reproduce the 6967754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 7067754Smsmith * provision in the documentation and/or other materials provided with the 7167754Smsmith * distribution. 7267754Smsmith * 7367754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7467754Smsmith * Intel Code. 7567754Smsmith * 7667754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7767754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 7867754Smsmith * other dealings in products derived from or relating to the Covered Code 7967754Smsmith * without prior written authorization from Intel. 8067754Smsmith * 8167754Smsmith * 4. Disclaimer and Export Compliance 8267754Smsmith * 8367754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8467754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8567754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8667754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8767754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8867754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 8967754Smsmith * PARTICULAR PURPOSE. 9067754Smsmith * 9167754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9267754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9367754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9467754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9567754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9667754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9767754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9867754Smsmith * LIMITED REMEDY. 9967754Smsmith * 10067754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10167754Smsmith * software or system incorporating such software without first obtaining any 10267754Smsmith * required license or other approval from the U. S. Department of Commerce or 10367754Smsmith * any other agency or department of the United States Government. In the 10467754Smsmith * event Licensee exports any such software from the United States or 10567754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10667754Smsmith * ensure that the distribution and export/re-export of the software is in 10767754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 10867754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 10967754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 11067754Smsmith * software, or service, directly or indirectly, to any country for which the 11167754Smsmith * United States government or any agency thereof requires an export license, 11267754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11367754Smsmith * such license, approval or letter. 11467754Smsmith * 11567754Smsmith *****************************************************************************/ 11667754Smsmith 11777424Smsmith#define __EXRESOP_C__ 11867754Smsmith 119193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 120193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 121193341Sjkim#include <contrib/dev/acpica/include/amlcode.h> 122193341Sjkim#include <contrib/dev/acpica/include/acparser.h> 123193341Sjkim#include <contrib/dev/acpica/include/acinterp.h> 124193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h> 12567754Smsmith 12667754Smsmith 12777424Smsmith#define _COMPONENT ACPI_EXECUTER 12891116Smsmith ACPI_MODULE_NAME ("exresop") 12967754Smsmith 130151937Sjkim/* Local prototypes */ 13167754Smsmith 132151937Sjkimstatic ACPI_STATUS 133151937SjkimAcpiExCheckObjectType ( 134151937Sjkim ACPI_OBJECT_TYPE TypeNeeded, 135151937Sjkim ACPI_OBJECT_TYPE ThisType, 136151937Sjkim void *Object); 137151937Sjkim 138151937Sjkim 13967754Smsmith/******************************************************************************* 14067754Smsmith * 14177424Smsmith * FUNCTION: AcpiExCheckObjectType 14269746Smsmith * 14369746Smsmith * PARAMETERS: TypeNeeded Object type needed 14469746Smsmith * ThisType Actual object type 14569746Smsmith * Object Object pointer 14669746Smsmith * 14769746Smsmith * RETURN: Status 14869746Smsmith * 14969746Smsmith * DESCRIPTION: Check required type against actual type 15069746Smsmith * 15169746Smsmith ******************************************************************************/ 15269746Smsmith 153151937Sjkimstatic ACPI_STATUS 15477424SmsmithAcpiExCheckObjectType ( 15569746Smsmith ACPI_OBJECT_TYPE TypeNeeded, 15669746Smsmith ACPI_OBJECT_TYPE ThisType, 15769746Smsmith void *Object) 15869746Smsmith{ 159167802Sjkim ACPI_FUNCTION_ENTRY (); 16069746Smsmith 16183174Smsmith 16269746Smsmith if (TypeNeeded == ACPI_TYPE_ANY) 16369746Smsmith { 16469746Smsmith /* All types OK, so we don't perform any typechecks */ 16569746Smsmith 16669746Smsmith return (AE_OK); 16769746Smsmith } 16869746Smsmith 169107325Siwasaki if (TypeNeeded == ACPI_TYPE_LOCAL_REFERENCE) 17099679Siwasaki { 17199679Siwasaki /* 17299679Siwasaki * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference 17399679Siwasaki * objects and thus allow them to be targets. (As per the ACPI 17499679Siwasaki * specification, a store to a constant is a noop.) 17599679Siwasaki */ 17699679Siwasaki if ((ThisType == ACPI_TYPE_INTEGER) && 17799679Siwasaki (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & AOPOBJ_AML_CONSTANT)) 17899679Siwasaki { 17999679Siwasaki return (AE_OK); 18099679Siwasaki } 18199679Siwasaki } 18299679Siwasaki 18369746Smsmith if (TypeNeeded != ThisType) 18469746Smsmith { 185167802Sjkim ACPI_ERROR ((AE_INFO, 186167802Sjkim "Needed type [%s], found [%s] %p", 18777424Smsmith AcpiUtGetTypeName (TypeNeeded), 18877424Smsmith AcpiUtGetTypeName (ThisType), Object)); 18969746Smsmith 19069746Smsmith return (AE_AML_OPERAND_TYPE); 19169746Smsmith } 19269746Smsmith 19369746Smsmith return (AE_OK); 19469746Smsmith} 19569746Smsmith 19669746Smsmith 19769746Smsmith/******************************************************************************* 19869746Smsmith * 19977424Smsmith * FUNCTION: AcpiExResolveOperands 20067754Smsmith * 20191116Smsmith * PARAMETERS: Opcode - Opcode being interpreted 20291116Smsmith * StackPtr - Pointer to the operand stack to be 20391116Smsmith * resolved 20499679Siwasaki * WalkState - Current state 20567754Smsmith * 20667754Smsmith * RETURN: Status 20767754Smsmith * 20891116Smsmith * DESCRIPTION: Convert multiple input operands to the types required by the 20991116Smsmith * target operator. 21067754Smsmith * 21199679Siwasaki * Each 5-bit group in ArgTypes represents one required 212102550Siwasaki * operand and indicates the required Type. The corresponding operand 213102550Siwasaki * will be converted to the required type if possible, otherwise we 21499679Siwasaki * abort with an exception. 21567754Smsmith * 21667754Smsmith ******************************************************************************/ 21767754Smsmith 21867754SmsmithACPI_STATUS 21977424SmsmithAcpiExResolveOperands ( 22067754Smsmith UINT16 Opcode, 22167754Smsmith ACPI_OPERAND_OBJECT **StackPtr, 22267754Smsmith ACPI_WALK_STATE *WalkState) 22367754Smsmith{ 22467754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 22567754Smsmith ACPI_STATUS Status = AE_OK; 22667754Smsmith UINT8 ObjectType; 22767754Smsmith UINT32 ArgTypes; 22883174Smsmith const ACPI_OPCODE_INFO *OpInfo; 22967754Smsmith UINT32 ThisArgType; 23069746Smsmith ACPI_OBJECT_TYPE TypeNeeded; 231151937Sjkim UINT16 TargetOp = 0; 23267754Smsmith 23367754Smsmith 234167802Sjkim ACPI_FUNCTION_TRACE_U32 (ExResolveOperands, Opcode); 23567754Smsmith 23667754Smsmith 23767754Smsmith OpInfo = AcpiPsGetOpcodeInfo (Opcode); 23885756Smsmith if (OpInfo->Class == AML_CLASS_UNKNOWN) 23967754Smsmith { 24067754Smsmith return_ACPI_STATUS (AE_AML_BAD_OPCODE); 24167754Smsmith } 24267754Smsmith 24367754Smsmith ArgTypes = OpInfo->RuntimeArgs; 24467754Smsmith if (ArgTypes == ARGI_INVALID_OPCODE) 24567754Smsmith { 246204773Sjkim ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", 24777424Smsmith Opcode)); 24869746Smsmith 24969746Smsmith return_ACPI_STATUS (AE_AML_INTERNAL); 25067754Smsmith } 25167754Smsmith 252151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 253151937Sjkim "Opcode %X [%s] RequiredOperandTypes=%8.8X\n", 25499146Siwasaki Opcode, OpInfo->Name, ArgTypes)); 25567754Smsmith 25677424Smsmith /* 25777424Smsmith * Normal exit is with (ArgTypes == 0) at end of argument list. 25867754Smsmith * Function will return an exception from within the loop upon 25977424Smsmith * finding an entry which is not (or cannot be converted 26077424Smsmith * to) the required type; if stack underflows; or upon 26177424Smsmith * finding a NULL stack entry (which should not happen). 26267754Smsmith */ 26367754Smsmith while (GET_CURRENT_ARG_TYPE (ArgTypes)) 26467754Smsmith { 26567754Smsmith if (!StackPtr || !*StackPtr) 26667754Smsmith { 267167802Sjkim ACPI_ERROR ((AE_INFO, "Null stack entry at %p", 26877424Smsmith StackPtr)); 26969746Smsmith 27069746Smsmith return_ACPI_STATUS (AE_AML_INTERNAL); 27167754Smsmith } 27267754Smsmith 27367754Smsmith /* Extract useful items */ 27467754Smsmith 27567754Smsmith ObjDesc = *StackPtr; 27667754Smsmith 27767754Smsmith /* Decode the descriptor type */ 27867754Smsmith 27991116Smsmith switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) 28067754Smsmith { 28191116Smsmith case ACPI_DESC_TYPE_NAMED: 28291116Smsmith 283151937Sjkim /* Namespace Node */ 28467754Smsmith 28567754Smsmith ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; 286167802Sjkim 287167802Sjkim /* 288167802Sjkim * Resolve an alias object. The construction of these objects 289167802Sjkim * guarantees that there is only one level of alias indirection; 290167802Sjkim * thus, the attached object is always the aliased namespace node 291167802Sjkim */ 292167802Sjkim if (ObjectType == ACPI_TYPE_LOCAL_ALIAS) 293167802Sjkim { 294167802Sjkim ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); 295167802Sjkim *StackPtr = ObjDesc; 296167802Sjkim ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; 297167802Sjkim } 29891116Smsmith break; 29967754Smsmith 30091116Smsmith 30199679Siwasaki case ACPI_DESC_TYPE_OPERAND: 30291116Smsmith 30367754Smsmith /* ACPI internal object */ 30467754Smsmith 305193267Sjkim ObjectType = ObjDesc->Common.Type; 30667754Smsmith 30767754Smsmith /* Check for bad ACPI_OBJECT_TYPE */ 30867754Smsmith 309107325Siwasaki if (!AcpiUtValidObjectType (ObjectType)) 31067754Smsmith { 311167802Sjkim ACPI_ERROR ((AE_INFO, 312204773Sjkim "Bad operand object type [0x%X]", ObjectType)); 31369746Smsmith 31469746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 31567754Smsmith } 31667754Smsmith 317107325Siwasaki if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE) 31867754Smsmith { 319193267Sjkim /* Validate the Reference */ 320151937Sjkim 321193267Sjkim switch (ObjDesc->Reference.Class) 32267754Smsmith { 323193267Sjkim case ACPI_REFCLASS_DEBUG: 32467754Smsmith 325151937Sjkim TargetOp = AML_DEBUG_OP; 326151937Sjkim 327151937Sjkim /*lint -fallthrough */ 328151937Sjkim 329193267Sjkim case ACPI_REFCLASS_ARG: 330193267Sjkim case ACPI_REFCLASS_LOCAL: 331193267Sjkim case ACPI_REFCLASS_INDEX: 332193267Sjkim case ACPI_REFCLASS_REFOF: 333193267Sjkim case ACPI_REFCLASS_TABLE: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */ 334193267Sjkim case ACPI_REFCLASS_NAME: /* Reference to a named object */ 33567754Smsmith 336193267Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 337193267Sjkim "Operand is a Reference, Class [%s] %2.2X\n", 338193267Sjkim AcpiUtGetReferenceName (ObjDesc), 339193267Sjkim ObjDesc->Reference.Class)); 34067754Smsmith break; 34167754Smsmith 34267754Smsmith default: 343193267Sjkim 344167802Sjkim ACPI_ERROR ((AE_INFO, 345204773Sjkim "Unknown Reference Class 0x%2.2X in %p", 346193267Sjkim ObjDesc->Reference.Class, ObjDesc)); 34767754Smsmith 34869746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 34967754Smsmith } 35067754Smsmith } 35191116Smsmith break; 35267754Smsmith 35391116Smsmith 35491116Smsmith default: 35591116Smsmith 35667754Smsmith /* Invalid descriptor */ 35767754Smsmith 358193267Sjkim ACPI_ERROR ((AE_INFO, "Invalid descriptor %p [%s]", 359167802Sjkim ObjDesc, AcpiUtGetDescriptorName (ObjDesc))); 36067754Smsmith 36169746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 36267754Smsmith } 36367754Smsmith 364151937Sjkim /* Get one argument type, point to the next */ 36567754Smsmith 36667754Smsmith ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes); 36767754Smsmith INCREMENT_ARG_LIST (ArgTypes); 36867754Smsmith 36969746Smsmith /* 37070243Smsmith * Handle cases where the object does not need to be 37170243Smsmith * resolved to a value 37269746Smsmith */ 37367754Smsmith switch (ThisArgType) 37467754Smsmith { 37591116Smsmith case ARGI_REF_OR_STRING: /* Can be a String or Reference */ 37667754Smsmith 37799679Siwasaki if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) && 378193267Sjkim (ObjDesc->Common.Type == ACPI_TYPE_STRING)) 37991116Smsmith { 38091116Smsmith /* 381151937Sjkim * String found - the string references a named object and 382151937Sjkim * must be resolved to a node 38391116Smsmith */ 38491116Smsmith goto NextOperand; 38591116Smsmith } 38691116Smsmith 387151937Sjkim /* 388151937Sjkim * Else not a string - fall through to the normal Reference 389151937Sjkim * case below 390151937Sjkim */ 39199679Siwasaki /*lint -fallthrough */ 39291116Smsmith 39391116Smsmith case ARGI_REFERENCE: /* References: */ 39471867Smsmith case ARGI_INTEGER_REF: 39571867Smsmith case ARGI_OBJECT_REF: 39671867Smsmith case ARGI_DEVICE_REF: 397151937Sjkim case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ 398151937Sjkim case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ 399151937Sjkim case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ 40067754Smsmith 401151937Sjkim /* 402151937Sjkim * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE 403151937Sjkim * A Namespace Node is OK as-is 404151937Sjkim */ 405151937Sjkim if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) 40667754Smsmith { 40769746Smsmith goto NextOperand; 40867754Smsmith } 40967754Smsmith 410107325Siwasaki Status = AcpiExCheckObjectType (ACPI_TYPE_LOCAL_REFERENCE, 41169746Smsmith ObjectType, ObjDesc); 41269746Smsmith if (ACPI_FAILURE (Status)) 41367754Smsmith { 41469746Smsmith return_ACPI_STATUS (Status); 41567754Smsmith } 41669746Smsmith goto NextOperand; 41767754Smsmith 41867754Smsmith 419151937Sjkim case ARGI_DATAREFOBJ: /* Store operator only */ 42067754Smsmith 42169746Smsmith /* 42269746Smsmith * We don't want to resolve IndexOp reference objects during 42369746Smsmith * a store because this would be an implicit DeRefOf operation. 42469746Smsmith * Instead, we just want to store the reference object. 42569746Smsmith * -- All others must be resolved below. 42669746Smsmith */ 42769746Smsmith if ((Opcode == AML_STORE_OP) && 428193267Sjkim ((*StackPtr)->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && 429193267Sjkim ((*StackPtr)->Reference.Class == ACPI_REFCLASS_INDEX)) 43067754Smsmith { 43169746Smsmith goto NextOperand; 43267754Smsmith } 43367754Smsmith break; 43499679Siwasaki 43599679Siwasaki default: 43699679Siwasaki /* All cases covered above */ 43799679Siwasaki break; 43869746Smsmith } 43967754Smsmith 44069746Smsmith /* 44169746Smsmith * Resolve this object to a value 44269746Smsmith */ 44377424Smsmith Status = AcpiExResolveToValue (StackPtr, WalkState); 44469746Smsmith if (ACPI_FAILURE (Status)) 44569746Smsmith { 44669746Smsmith return_ACPI_STATUS (Status); 44769746Smsmith } 44867754Smsmith 449104470Siwasaki /* Get the resolved object */ 450104470Siwasaki 451104470Siwasaki ObjDesc = *StackPtr; 452104470Siwasaki 45369746Smsmith /* 45469746Smsmith * Check the resulting object (value) type 45569746Smsmith */ 45669746Smsmith switch (ThisArgType) 45769746Smsmith { 45869746Smsmith /* 45969746Smsmith * For the simple cases, only one type of resolved object 46069746Smsmith * is allowed 46169746Smsmith */ 46267754Smsmith case ARGI_MUTEX: 46367754Smsmith 46467754Smsmith /* Need an operand of type ACPI_TYPE_MUTEX */ 46567754Smsmith 46669746Smsmith TypeNeeded = ACPI_TYPE_MUTEX; 46767754Smsmith break; 46867754Smsmith 46967754Smsmith case ARGI_EVENT: 47067754Smsmith 47167754Smsmith /* Need an operand of type ACPI_TYPE_EVENT */ 47267754Smsmith 47369746Smsmith TypeNeeded = ACPI_TYPE_EVENT; 47467754Smsmith break; 47567754Smsmith 47667754Smsmith case ARGI_PACKAGE: /* Package */ 47767754Smsmith 47867754Smsmith /* Need an operand of type ACPI_TYPE_PACKAGE */ 47967754Smsmith 48069746Smsmith TypeNeeded = ACPI_TYPE_PACKAGE; 48169746Smsmith break; 48267754Smsmith 48369746Smsmith case ARGI_ANYTYPE: 48469746Smsmith 48569746Smsmith /* Any operand type will do */ 48669746Smsmith 48769746Smsmith TypeNeeded = ACPI_TYPE_ANY; 48867754Smsmith break; 48967754Smsmith 490123315Snjl case ARGI_DDBHANDLE: 49167754Smsmith 492123315Snjl /* Need an operand of type ACPI_TYPE_DDB_HANDLE */ 493123315Snjl 494123315Snjl TypeNeeded = ACPI_TYPE_LOCAL_REFERENCE; 495123315Snjl break; 496123315Snjl 497123315Snjl 49869746Smsmith /* 49969746Smsmith * The more complex cases allow multiple resolved object types 50069746Smsmith */ 501151937Sjkim case ARGI_INTEGER: 50271867Smsmith 50371867Smsmith /* 50471867Smsmith * Need an operand of type ACPI_TYPE_INTEGER, 50571867Smsmith * But we can implicitly convert from a STRING or BUFFER 506104470Siwasaki * Aka - "Implicit Source Operand Conversion" 50771867Smsmith */ 508138287Smarks Status = AcpiExConvertToInteger (ObjDesc, StackPtr, 16); 50971867Smsmith if (ACPI_FAILURE (Status)) 51071867Smsmith { 51171867Smsmith if (Status == AE_TYPE) 51271867Smsmith { 513167802Sjkim ACPI_ERROR ((AE_INFO, 514167802Sjkim "Needed [Integer/String/Buffer], found [%s] %p", 515104470Siwasaki AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 51671867Smsmith 51771867Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 51871867Smsmith } 51971867Smsmith 52071867Smsmith return_ACPI_STATUS (Status); 52171867Smsmith } 522151937Sjkim 523151937Sjkim if (ObjDesc != *StackPtr) 524151937Sjkim { 525151937Sjkim AcpiUtRemoveReference (ObjDesc); 526151937Sjkim } 52771867Smsmith goto NextOperand; 52871867Smsmith 52971867Smsmith 53071867Smsmith case ARGI_BUFFER: 53171867Smsmith 53271867Smsmith /* 53371867Smsmith * Need an operand of type ACPI_TYPE_BUFFER, 53471867Smsmith * But we can implicitly convert from a STRING or INTEGER 535104470Siwasaki * Aka - "Implicit Source Operand Conversion" 53671867Smsmith */ 537138287Smarks Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); 53871867Smsmith if (ACPI_FAILURE (Status)) 53971867Smsmith { 54071867Smsmith if (Status == AE_TYPE) 54171867Smsmith { 542167802Sjkim ACPI_ERROR ((AE_INFO, 543167802Sjkim "Needed [Integer/String/Buffer], found [%s] %p", 544104470Siwasaki AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 54571867Smsmith 54671867Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 54771867Smsmith } 54871867Smsmith 54971867Smsmith return_ACPI_STATUS (Status); 55071867Smsmith } 551151937Sjkim 552151937Sjkim if (ObjDesc != *StackPtr) 553151937Sjkim { 554151937Sjkim AcpiUtRemoveReference (ObjDesc); 555151937Sjkim } 55671867Smsmith goto NextOperand; 55771867Smsmith 55871867Smsmith 55969746Smsmith case ARGI_STRING: 56067754Smsmith 56171867Smsmith /* 56271867Smsmith * Need an operand of type ACPI_TYPE_STRING, 56371867Smsmith * But we can implicitly convert from a BUFFER or INTEGER 564104470Siwasaki * Aka - "Implicit Source Operand Conversion" 56571867Smsmith */ 566138287Smarks Status = AcpiExConvertToString (ObjDesc, StackPtr, 567138287Smarks ACPI_IMPLICIT_CONVERT_HEX); 56871867Smsmith if (ACPI_FAILURE (Status)) 56971867Smsmith { 57071867Smsmith if (Status == AE_TYPE) 57171867Smsmith { 572167802Sjkim ACPI_ERROR ((AE_INFO, 573167802Sjkim "Needed [Integer/String/Buffer], found [%s] %p", 574104470Siwasaki AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 57567754Smsmith 57671867Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 57771867Smsmith } 57871867Smsmith 57971867Smsmith return_ACPI_STATUS (Status); 58071867Smsmith } 581151937Sjkim 582151937Sjkim if (ObjDesc != *StackPtr) 583151937Sjkim { 584151937Sjkim AcpiUtRemoveReference (ObjDesc); 585151937Sjkim } 58671867Smsmith goto NextOperand; 58771867Smsmith 58871867Smsmith 58971867Smsmith case ARGI_COMPUTEDATA: 59071867Smsmith 59171867Smsmith /* Need an operand of type INTEGER, STRING or BUFFER */ 59271867Smsmith 593193267Sjkim switch (ObjDesc->Common.Type) 59467754Smsmith { 59591116Smsmith case ACPI_TYPE_INTEGER: 59691116Smsmith case ACPI_TYPE_STRING: 59791116Smsmith case ACPI_TYPE_BUFFER: 59891116Smsmith 59991116Smsmith /* Valid operand */ 60091116Smsmith break; 60191116Smsmith 60291116Smsmith default: 603167802Sjkim ACPI_ERROR ((AE_INFO, 604167802Sjkim "Needed [Integer/String/Buffer], found [%s] %p", 605104470Siwasaki AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 60667754Smsmith 60769746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 60867754Smsmith } 60969746Smsmith goto NextOperand; 61067754Smsmith 61167754Smsmith 612114237Snjl case ARGI_BUFFER_OR_STRING: 613114237Snjl 614114237Snjl /* Need an operand of type STRING or BUFFER */ 615114237Snjl 616193267Sjkim switch (ObjDesc->Common.Type) 617114237Snjl { 618114237Snjl case ACPI_TYPE_STRING: 619114237Snjl case ACPI_TYPE_BUFFER: 620114237Snjl 621114237Snjl /* Valid operand */ 622114237Snjl break; 623114237Snjl 624114237Snjl case ACPI_TYPE_INTEGER: 625114237Snjl 626114237Snjl /* Highest priority conversion is to type Buffer */ 627114237Snjl 628138287Smarks Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); 629114237Snjl if (ACPI_FAILURE (Status)) 630114237Snjl { 631114237Snjl return_ACPI_STATUS (Status); 632114237Snjl } 633151937Sjkim 634151937Sjkim if (ObjDesc != *StackPtr) 635151937Sjkim { 636151937Sjkim AcpiUtRemoveReference (ObjDesc); 637151937Sjkim } 638114237Snjl break; 639114237Snjl 640114237Snjl default: 641167802Sjkim ACPI_ERROR ((AE_INFO, 642167802Sjkim "Needed [Integer/String/Buffer], found [%s] %p", 643114237Snjl AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 644114237Snjl 645114237Snjl return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 646114237Snjl } 647114237Snjl goto NextOperand; 648114237Snjl 649114237Snjl 65067754Smsmith case ARGI_DATAOBJECT: 65167754Smsmith /* 65267754Smsmith * ARGI_DATAOBJECT is only used by the SizeOf operator. 653104470Siwasaki * Need a buffer, string, package, or RefOf reference. 65467754Smsmith * 65591116Smsmith * The only reference allowed here is a direct reference to 65691116Smsmith * a namespace node. 65767754Smsmith */ 658193267Sjkim switch (ObjDesc->Common.Type) 65967754Smsmith { 66091116Smsmith case ACPI_TYPE_PACKAGE: 66191116Smsmith case ACPI_TYPE_STRING: 66291116Smsmith case ACPI_TYPE_BUFFER: 663107325Siwasaki case ACPI_TYPE_LOCAL_REFERENCE: 66491116Smsmith 66591116Smsmith /* Valid operand */ 66691116Smsmith break; 66791116Smsmith 66891116Smsmith default: 669167802Sjkim ACPI_ERROR ((AE_INFO, 670167802Sjkim "Needed [Buffer/String/Package/Reference], found [%s] %p", 671104470Siwasaki AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 67291116Smsmith 67391116Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 67491116Smsmith } 67569746Smsmith goto NextOperand; 67667754Smsmith 67767754Smsmith 67867754Smsmith case ARGI_COMPLEXOBJ: 67967754Smsmith 68077424Smsmith /* Need a buffer or package or (ACPI 2.0) String */ 68167754Smsmith 682193267Sjkim switch (ObjDesc->Common.Type) 68367754Smsmith { 68491116Smsmith case ACPI_TYPE_PACKAGE: 68591116Smsmith case ACPI_TYPE_STRING: 68691116Smsmith case ACPI_TYPE_BUFFER: 68791116Smsmith 68891116Smsmith /* Valid operand */ 68991116Smsmith break; 69091116Smsmith 69191116Smsmith default: 692167802Sjkim ACPI_ERROR ((AE_INFO, 693167802Sjkim "Needed [Buffer/String/Package], found [%s] %p", 694104470Siwasaki AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 69569746Smsmith 69669746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 69767754Smsmith } 69869746Smsmith goto NextOperand; 69967754Smsmith 70067754Smsmith 701167802Sjkim case ARGI_REGION_OR_BUFFER: /* Used by Load() only */ 702114237Snjl 703167802Sjkim /* Need an operand of type REGION or a BUFFER (which could be a resolved region field) */ 704114237Snjl 705193267Sjkim switch (ObjDesc->Common.Type) 706114237Snjl { 707167802Sjkim case ACPI_TYPE_BUFFER: 708114237Snjl case ACPI_TYPE_REGION: 709114237Snjl 710114237Snjl /* Valid operand */ 711114237Snjl break; 712114237Snjl 713114237Snjl default: 714167802Sjkim ACPI_ERROR ((AE_INFO, 715167802Sjkim "Needed [Region/Buffer], found [%s] %p", 716114237Snjl AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 717114237Snjl 718114237Snjl return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 719114237Snjl } 720114237Snjl goto NextOperand; 721114237Snjl 722114237Snjl 723151937Sjkim case ARGI_DATAREFOBJ: 724151937Sjkim 725151937Sjkim /* Used by the Store() operator only */ 726151937Sjkim 727193267Sjkim switch (ObjDesc->Common.Type) 728151937Sjkim { 729151937Sjkim case ACPI_TYPE_INTEGER: 730151937Sjkim case ACPI_TYPE_PACKAGE: 731151937Sjkim case ACPI_TYPE_STRING: 732151937Sjkim case ACPI_TYPE_BUFFER: 733151937Sjkim case ACPI_TYPE_BUFFER_FIELD: 734151937Sjkim case ACPI_TYPE_LOCAL_REFERENCE: 735151937Sjkim case ACPI_TYPE_LOCAL_REGION_FIELD: 736151937Sjkim case ACPI_TYPE_LOCAL_BANK_FIELD: 737151937Sjkim case ACPI_TYPE_LOCAL_INDEX_FIELD: 738151937Sjkim case ACPI_TYPE_DDB_HANDLE: 739151937Sjkim 740151937Sjkim /* Valid operand */ 741151937Sjkim break; 742151937Sjkim 743151937Sjkim default: 744151937Sjkim 745151937Sjkim if (AcpiGbl_EnableInterpreterSlack) 746151937Sjkim { 747151937Sjkim /* 748151937Sjkim * Enable original behavior of Store(), allowing any and all 749151937Sjkim * objects as the source operand. The ACPI spec does not 750151937Sjkim * allow this, however. 751151937Sjkim */ 752151937Sjkim break; 753151937Sjkim } 754151937Sjkim 755151937Sjkim if (TargetOp == AML_DEBUG_OP) 756151937Sjkim { 757151937Sjkim /* Allow store of any object to the Debug object */ 758151937Sjkim 759151937Sjkim break; 760151937Sjkim } 761151937Sjkim 762167802Sjkim ACPI_ERROR ((AE_INFO, 763167802Sjkim "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p", 764151937Sjkim AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 765151937Sjkim 766151937Sjkim return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 767151937Sjkim } 768151937Sjkim goto NextOperand; 769151937Sjkim 770151937Sjkim 77169746Smsmith default: 77267754Smsmith 77369746Smsmith /* Unknown type */ 77469746Smsmith 775167802Sjkim ACPI_ERROR ((AE_INFO, 776204773Sjkim "Internal - Unknown ARGI (required operand) type 0x%X", 77767754Smsmith ThisArgType)); 77867754Smsmith 77969746Smsmith return_ACPI_STATUS (AE_BAD_PARAMETER); 78069746Smsmith } 78167754Smsmith 78270243Smsmith /* 78369746Smsmith * Make sure that the original object was resolved to the 78469746Smsmith * required object type (Simple cases only). 78569746Smsmith */ 78677424Smsmith Status = AcpiExCheckObjectType (TypeNeeded, 787193267Sjkim (*StackPtr)->Common.Type, *StackPtr); 78869746Smsmith if (ACPI_FAILURE (Status)) 78969746Smsmith { 79069746Smsmith return_ACPI_STATUS (Status); 79169746Smsmith } 79269746Smsmith 79369746SmsmithNextOperand: 79467754Smsmith /* 79567754Smsmith * If more operands needed, decrement StackPtr to point 79669746Smsmith * to next operand on stack 79767754Smsmith */ 79867754Smsmith if (GET_CURRENT_ARG_TYPE (ArgTypes)) 79967754Smsmith { 80067754Smsmith StackPtr--; 80167754Smsmith } 802151937Sjkim } 80367754Smsmith 804193267Sjkim ACPI_DUMP_OPERANDS (WalkState->Operands, 805193267Sjkim AcpiPsGetOpcodeName (Opcode), WalkState->NumOperands); 806193267Sjkim 80769746Smsmith return_ACPI_STATUS (Status); 80867754Smsmith} 80967754Smsmith 81067754Smsmith 811