167754Smsmith/****************************************************************************** 267754Smsmith * 377424Smsmith * Module Name: exresop - AML Interpreter operand/object resolution 467754Smsmith * 567754Smsmith *****************************************************************************/ 667754Smsmith 7316303Sjkim/****************************************************************************** 8316303Sjkim * 9316303Sjkim * 1. Copyright Notice 10316303Sjkim * 11316303Sjkim * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. 1270243Smsmith * All rights reserved. 1367754Smsmith * 14316303Sjkim * 2. License 15316303Sjkim * 16316303Sjkim * 2.1. This is your license from Intel Corp. under its intellectual property 17316303Sjkim * rights. You may have additional license terms from the party that provided 18316303Sjkim * you this software, covering your right to use that party's intellectual 19316303Sjkim * property rights. 20316303Sjkim * 21316303Sjkim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22316303Sjkim * copy of the source code appearing in this file ("Covered Code") an 23316303Sjkim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24316303Sjkim * base code distributed originally by Intel ("Original Intel Code") to copy, 25316303Sjkim * make derivatives, distribute, use and display any portion of the Covered 26316303Sjkim * Code in any form, with the right to sublicense such rights; and 27316303Sjkim * 28316303Sjkim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29316303Sjkim * license (with the right to sublicense), under only those claims of Intel 30316303Sjkim * patents that are infringed by the Original Intel Code, to make, use, sell, 31316303Sjkim * offer to sell, and import the Covered Code and derivative works thereof 32316303Sjkim * solely to the minimum extent necessary to exercise the above copyright 33316303Sjkim * license, and in no event shall the patent license extend to any additions 34316303Sjkim * to or modifications of the Original Intel Code. No other license or right 35316303Sjkim * is granted directly or by implication, estoppel or otherwise; 36316303Sjkim * 37316303Sjkim * The above copyright and patent license is granted only if the following 38316303Sjkim * conditions are met: 39316303Sjkim * 40316303Sjkim * 3. Conditions 41316303Sjkim * 42316303Sjkim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43316303Sjkim * Redistribution of source code of any substantial portion of the Covered 44316303Sjkim * Code or modification with rights to further distribute source must include 45316303Sjkim * the above Copyright Notice, the above License, this list of Conditions, 46316303Sjkim * and the following Disclaimer and Export Compliance provision. In addition, 47316303Sjkim * Licensee must cause all Covered Code to which Licensee contributes to 48316303Sjkim * contain a file documenting the changes Licensee made to create that Covered 49316303Sjkim * Code and the date of any change. Licensee must include in that file the 50316303Sjkim * documentation of any changes made by any predecessor Licensee. Licensee 51316303Sjkim * must include a prominent statement that the modification is derived, 52316303Sjkim * directly or indirectly, from Original Intel Code. 53316303Sjkim * 54316303Sjkim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55316303Sjkim * Redistribution of source code of any substantial portion of the Covered 56316303Sjkim * Code or modification without rights to further distribute source must 57316303Sjkim * include the following Disclaimer and Export Compliance provision in the 58316303Sjkim * documentation and/or other materials provided with distribution. In 59316303Sjkim * addition, Licensee may not authorize further sublicense of source of any 60316303Sjkim * portion of the Covered Code, and must include terms to the effect that the 61316303Sjkim * license from Licensee to its licensee is limited to the intellectual 62316303Sjkim * property embodied in the software Licensee provides to its licensee, and 63316303Sjkim * not to intellectual property embodied in modifications its licensee may 64316303Sjkim * make. 65316303Sjkim * 66316303Sjkim * 3.3. Redistribution of Executable. Redistribution in executable form of any 67316303Sjkim * substantial portion of the Covered Code or modification must reproduce the 68316303Sjkim * above Copyright Notice, and the following Disclaimer and Export Compliance 69316303Sjkim * provision in the documentation and/or other materials provided with the 70316303Sjkim * distribution. 71316303Sjkim * 72316303Sjkim * 3.4. Intel retains all right, title, and interest in and to the Original 73316303Sjkim * Intel Code. 74316303Sjkim * 75316303Sjkim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76316303Sjkim * Intel shall be used in advertising or otherwise to promote the sale, use or 77316303Sjkim * other dealings in products derived from or relating to the Covered Code 78316303Sjkim * without prior written authorization from Intel. 79316303Sjkim * 80316303Sjkim * 4. Disclaimer and Export Compliance 81316303Sjkim * 82316303Sjkim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83316303Sjkim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84316303Sjkim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85316303Sjkim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86316303Sjkim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87316303Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88316303Sjkim * PARTICULAR PURPOSE. 89316303Sjkim * 90316303Sjkim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91316303Sjkim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92316303Sjkim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93316303Sjkim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94316303Sjkim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95316303Sjkim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96316303Sjkim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97316303Sjkim * LIMITED REMEDY. 98316303Sjkim * 99316303Sjkim * 4.3. Licensee shall not export, either directly or indirectly, any of this 100316303Sjkim * software or system incorporating such software without first obtaining any 101316303Sjkim * required license or other approval from the U. S. Department of Commerce or 102316303Sjkim * any other agency or department of the United States Government. In the 103316303Sjkim * event Licensee exports any such software from the United States or 104316303Sjkim * re-exports any such software from a foreign destination, Licensee shall 105316303Sjkim * ensure that the distribution and export/re-export of the software is in 106316303Sjkim * compliance with all laws, regulations, orders, or other restrictions of the 107316303Sjkim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108316303Sjkim * any of its subsidiaries will export/re-export any technical data, process, 109316303Sjkim * software, or service, directly or indirectly, to any country for which the 110316303Sjkim * United States government or any agency thereof requires an export license, 111316303Sjkim * other governmental approval, or letter of assurance, without first obtaining 112316303Sjkim * such license, approval or letter. 113316303Sjkim * 114316303Sjkim ***************************************************************************** 115316303Sjkim * 116316303Sjkim * Alternatively, you may choose to be licensed under the terms of the 117316303Sjkim * following license: 118316303Sjkim * 119217365Sjkim * Redistribution and use in source and binary forms, with or without 120217365Sjkim * modification, are permitted provided that the following conditions 121217365Sjkim * are met: 122217365Sjkim * 1. Redistributions of source code must retain the above copyright 123217365Sjkim * notice, this list of conditions, and the following disclaimer, 124217365Sjkim * without modification. 125217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 127217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 128217365Sjkim * including a substantially similar Disclaimer requirement for further 129217365Sjkim * binary redistribution. 130217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 131217365Sjkim * of any contributors may be used to endorse or promote products derived 132217365Sjkim * from this software without specific prior written permission. 13367754Smsmith * 134316303Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135316303Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136316303Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137316303Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138316303Sjkim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139316303Sjkim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140316303Sjkim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141316303Sjkim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142316303Sjkim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143316303Sjkim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144316303Sjkim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145316303Sjkim * 146316303Sjkim * Alternatively, you may choose to be licensed under the terms of the 147217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 148217365Sjkim * Software Foundation. 14967754Smsmith * 150316303Sjkim *****************************************************************************/ 15167754Smsmith 152193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 153193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 154193341Sjkim#include <contrib/dev/acpica/include/amlcode.h> 155193341Sjkim#include <contrib/dev/acpica/include/acparser.h> 156193341Sjkim#include <contrib/dev/acpica/include/acinterp.h> 157193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h> 15867754Smsmith 15967754Smsmith 16077424Smsmith#define _COMPONENT ACPI_EXECUTER 16191116Smsmith ACPI_MODULE_NAME ("exresop") 16267754Smsmith 163151937Sjkim/* Local prototypes */ 16467754Smsmith 165151937Sjkimstatic ACPI_STATUS 166151937SjkimAcpiExCheckObjectType ( 167151937Sjkim ACPI_OBJECT_TYPE TypeNeeded, 168151937Sjkim ACPI_OBJECT_TYPE ThisType, 169151937Sjkim void *Object); 170151937Sjkim 171151937Sjkim 17267754Smsmith/******************************************************************************* 17367754Smsmith * 17477424Smsmith * FUNCTION: AcpiExCheckObjectType 17569746Smsmith * 17669746Smsmith * PARAMETERS: TypeNeeded Object type needed 17769746Smsmith * ThisType Actual object type 17869746Smsmith * Object Object pointer 17969746Smsmith * 18069746Smsmith * RETURN: Status 18169746Smsmith * 18269746Smsmith * DESCRIPTION: Check required type against actual type 18369746Smsmith * 18469746Smsmith ******************************************************************************/ 18569746Smsmith 186151937Sjkimstatic ACPI_STATUS 18777424SmsmithAcpiExCheckObjectType ( 18869746Smsmith ACPI_OBJECT_TYPE TypeNeeded, 18969746Smsmith ACPI_OBJECT_TYPE ThisType, 19069746Smsmith void *Object) 19169746Smsmith{ 192167802Sjkim ACPI_FUNCTION_ENTRY (); 19369746Smsmith 19483174Smsmith 19569746Smsmith if (TypeNeeded == ACPI_TYPE_ANY) 19669746Smsmith { 19769746Smsmith /* All types OK, so we don't perform any typechecks */ 19869746Smsmith 19969746Smsmith return (AE_OK); 20069746Smsmith } 20169746Smsmith 202107325Siwasaki if (TypeNeeded == ACPI_TYPE_LOCAL_REFERENCE) 20399679Siwasaki { 20499679Siwasaki /* 20599679Siwasaki * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference 206241973Sjkim * objects and thus allow them to be targets. (As per the ACPI 20799679Siwasaki * specification, a store to a constant is a noop.) 20899679Siwasaki */ 20999679Siwasaki if ((ThisType == ACPI_TYPE_INTEGER) && 210298714Sjkim (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & 211298714Sjkim AOPOBJ_AML_CONSTANT)) 21299679Siwasaki { 21399679Siwasaki return (AE_OK); 21499679Siwasaki } 21599679Siwasaki } 21699679Siwasaki 21769746Smsmith if (TypeNeeded != ThisType) 21869746Smsmith { 219167802Sjkim ACPI_ERROR ((AE_INFO, 220167802Sjkim "Needed type [%s], found [%s] %p", 22177424Smsmith AcpiUtGetTypeName (TypeNeeded), 22277424Smsmith AcpiUtGetTypeName (ThisType), Object)); 22369746Smsmith 22469746Smsmith return (AE_AML_OPERAND_TYPE); 22569746Smsmith } 22669746Smsmith 22769746Smsmith return (AE_OK); 22869746Smsmith} 22969746Smsmith 23069746Smsmith 23169746Smsmith/******************************************************************************* 23269746Smsmith * 23377424Smsmith * FUNCTION: AcpiExResolveOperands 23467754Smsmith * 23591116Smsmith * PARAMETERS: Opcode - Opcode being interpreted 23691116Smsmith * StackPtr - Pointer to the operand stack to be 23791116Smsmith * resolved 23899679Siwasaki * WalkState - Current state 23967754Smsmith * 24067754Smsmith * RETURN: Status 24167754Smsmith * 24291116Smsmith * DESCRIPTION: Convert multiple input operands to the types required by the 24391116Smsmith * target operator. 24467754Smsmith * 24599679Siwasaki * Each 5-bit group in ArgTypes represents one required 246102550Siwasaki * operand and indicates the required Type. The corresponding operand 247102550Siwasaki * will be converted to the required type if possible, otherwise we 24899679Siwasaki * abort with an exception. 24967754Smsmith * 25067754Smsmith ******************************************************************************/ 25167754Smsmith 25267754SmsmithACPI_STATUS 25377424SmsmithAcpiExResolveOperands ( 25467754Smsmith UINT16 Opcode, 25567754Smsmith ACPI_OPERAND_OBJECT **StackPtr, 25667754Smsmith ACPI_WALK_STATE *WalkState) 25767754Smsmith{ 25867754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 25967754Smsmith ACPI_STATUS Status = AE_OK; 26067754Smsmith UINT8 ObjectType; 26167754Smsmith UINT32 ArgTypes; 26283174Smsmith const ACPI_OPCODE_INFO *OpInfo; 26367754Smsmith UINT32 ThisArgType; 26469746Smsmith ACPI_OBJECT_TYPE TypeNeeded; 265151937Sjkim UINT16 TargetOp = 0; 26667754Smsmith 26767754Smsmith 268167802Sjkim ACPI_FUNCTION_TRACE_U32 (ExResolveOperands, Opcode); 26967754Smsmith 27067754Smsmith 27167754Smsmith OpInfo = AcpiPsGetOpcodeInfo (Opcode); 27285756Smsmith if (OpInfo->Class == AML_CLASS_UNKNOWN) 27367754Smsmith { 27467754Smsmith return_ACPI_STATUS (AE_AML_BAD_OPCODE); 27567754Smsmith } 27667754Smsmith 27767754Smsmith ArgTypes = OpInfo->RuntimeArgs; 27867754Smsmith if (ArgTypes == ARGI_INVALID_OPCODE) 27967754Smsmith { 280204773Sjkim ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", 28177424Smsmith Opcode)); 28269746Smsmith 28369746Smsmith return_ACPI_STATUS (AE_AML_INTERNAL); 28467754Smsmith } 28567754Smsmith 286151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 287151937Sjkim "Opcode %X [%s] RequiredOperandTypes=%8.8X\n", 28899146Siwasaki Opcode, OpInfo->Name, ArgTypes)); 28967754Smsmith 29077424Smsmith /* 29177424Smsmith * Normal exit is with (ArgTypes == 0) at end of argument list. 29267754Smsmith * Function will return an exception from within the loop upon 29377424Smsmith * finding an entry which is not (or cannot be converted 29477424Smsmith * to) the required type; if stack underflows; or upon 29577424Smsmith * finding a NULL stack entry (which should not happen). 29667754Smsmith */ 29767754Smsmith while (GET_CURRENT_ARG_TYPE (ArgTypes)) 29867754Smsmith { 29967754Smsmith if (!StackPtr || !*StackPtr) 30067754Smsmith { 301167802Sjkim ACPI_ERROR ((AE_INFO, "Null stack entry at %p", 30277424Smsmith StackPtr)); 30369746Smsmith 30469746Smsmith return_ACPI_STATUS (AE_AML_INTERNAL); 30567754Smsmith } 30667754Smsmith 30767754Smsmith /* Extract useful items */ 30867754Smsmith 30967754Smsmith ObjDesc = *StackPtr; 31067754Smsmith 31167754Smsmith /* Decode the descriptor type */ 31267754Smsmith 31391116Smsmith switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) 31467754Smsmith { 31591116Smsmith case ACPI_DESC_TYPE_NAMED: 31691116Smsmith 317151937Sjkim /* Namespace Node */ 31867754Smsmith 31967754Smsmith ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; 320167802Sjkim 321167802Sjkim /* 322167802Sjkim * Resolve an alias object. The construction of these objects 323167802Sjkim * guarantees that there is only one level of alias indirection; 324167802Sjkim * thus, the attached object is always the aliased namespace node 325167802Sjkim */ 326167802Sjkim if (ObjectType == ACPI_TYPE_LOCAL_ALIAS) 327167802Sjkim { 328298714Sjkim ObjDesc = AcpiNsGetAttachedObject ( 329298714Sjkim (ACPI_NAMESPACE_NODE *) ObjDesc); 330167802Sjkim *StackPtr = ObjDesc; 331167802Sjkim ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; 332167802Sjkim } 33391116Smsmith break; 33467754Smsmith 33599679Siwasaki case ACPI_DESC_TYPE_OPERAND: 33691116Smsmith 33767754Smsmith /* ACPI internal object */ 33867754Smsmith 339193267Sjkim ObjectType = ObjDesc->Common.Type; 34067754Smsmith 34167754Smsmith /* Check for bad ACPI_OBJECT_TYPE */ 34267754Smsmith 343107325Siwasaki if (!AcpiUtValidObjectType (ObjectType)) 34467754Smsmith { 345167802Sjkim ACPI_ERROR ((AE_INFO, 346204773Sjkim "Bad operand object type [0x%X]", ObjectType)); 34769746Smsmith 34869746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 34967754Smsmith } 35067754Smsmith 351107325Siwasaki if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE) 35267754Smsmith { 353193267Sjkim /* Validate the Reference */ 354151937Sjkim 355193267Sjkim switch (ObjDesc->Reference.Class) 35667754Smsmith { 357193267Sjkim case ACPI_REFCLASS_DEBUG: 35867754Smsmith 359151937Sjkim TargetOp = AML_DEBUG_OP; 360151937Sjkim 361151937Sjkim /*lint -fallthrough */ 362151937Sjkim 363193267Sjkim case ACPI_REFCLASS_ARG: 364193267Sjkim case ACPI_REFCLASS_LOCAL: 365193267Sjkim case ACPI_REFCLASS_INDEX: 366193267Sjkim case ACPI_REFCLASS_REFOF: 367193267Sjkim case ACPI_REFCLASS_TABLE: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */ 368193267Sjkim case ACPI_REFCLASS_NAME: /* Reference to a named object */ 36967754Smsmith 370193267Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 371193267Sjkim "Operand is a Reference, Class [%s] %2.2X\n", 372193267Sjkim AcpiUtGetReferenceName (ObjDesc), 373193267Sjkim ObjDesc->Reference.Class)); 37467754Smsmith break; 37567754Smsmith 37667754Smsmith default: 377193267Sjkim 378167802Sjkim ACPI_ERROR ((AE_INFO, 379204773Sjkim "Unknown Reference Class 0x%2.2X in %p", 380193267Sjkim ObjDesc->Reference.Class, ObjDesc)); 38167754Smsmith 38269746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 38367754Smsmith } 38467754Smsmith } 38591116Smsmith break; 38667754Smsmith 38791116Smsmith default: 38891116Smsmith 38967754Smsmith /* Invalid descriptor */ 39067754Smsmith 391193267Sjkim ACPI_ERROR ((AE_INFO, "Invalid descriptor %p [%s]", 392167802Sjkim ObjDesc, AcpiUtGetDescriptorName (ObjDesc))); 39367754Smsmith 39469746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 39567754Smsmith } 39667754Smsmith 397151937Sjkim /* Get one argument type, point to the next */ 39867754Smsmith 39967754Smsmith ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes); 40067754Smsmith INCREMENT_ARG_LIST (ArgTypes); 40167754Smsmith 40269746Smsmith /* 40370243Smsmith * Handle cases where the object does not need to be 40470243Smsmith * resolved to a value 40569746Smsmith */ 40667754Smsmith switch (ThisArgType) 40767754Smsmith { 40891116Smsmith case ARGI_REF_OR_STRING: /* Can be a String or Reference */ 40967754Smsmith 410298714Sjkim if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == 411298714Sjkim ACPI_DESC_TYPE_OPERAND) && 412193267Sjkim (ObjDesc->Common.Type == ACPI_TYPE_STRING)) 41391116Smsmith { 41491116Smsmith /* 415151937Sjkim * String found - the string references a named object and 416151937Sjkim * must be resolved to a node 41791116Smsmith */ 41891116Smsmith goto NextOperand; 41991116Smsmith } 42091116Smsmith 421151937Sjkim /* 422151937Sjkim * Else not a string - fall through to the normal Reference 423151937Sjkim * case below 424151937Sjkim */ 42599679Siwasaki /*lint -fallthrough */ 42691116Smsmith 42791116Smsmith case ARGI_REFERENCE: /* References: */ 42871867Smsmith case ARGI_INTEGER_REF: 42971867Smsmith case ARGI_OBJECT_REF: 43071867Smsmith case ARGI_DEVICE_REF: 431151937Sjkim case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ 432151937Sjkim case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ 433298714Sjkim case ARGI_STORE_TARGET: 434298714Sjkim 435151937Sjkim /* 436151937Sjkim * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE 437151937Sjkim * A Namespace Node is OK as-is 438151937Sjkim */ 439151937Sjkim if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) 44067754Smsmith { 44169746Smsmith goto NextOperand; 44267754Smsmith } 44367754Smsmith 444298714Sjkim Status = AcpiExCheckObjectType ( 445298714Sjkim ACPI_TYPE_LOCAL_REFERENCE, ObjectType, ObjDesc); 44669746Smsmith if (ACPI_FAILURE (Status)) 44767754Smsmith { 44869746Smsmith return_ACPI_STATUS (Status); 44967754Smsmith } 45069746Smsmith goto NextOperand; 45167754Smsmith 452151937Sjkim case ARGI_DATAREFOBJ: /* Store operator only */ 45369746Smsmith /* 45469746Smsmith * We don't want to resolve IndexOp reference objects during 45569746Smsmith * a store because this would be an implicit DeRefOf operation. 45669746Smsmith * Instead, we just want to store the reference object. 45769746Smsmith * -- All others must be resolved below. 45869746Smsmith */ 45969746Smsmith if ((Opcode == AML_STORE_OP) && 460193267Sjkim ((*StackPtr)->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && 461193267Sjkim ((*StackPtr)->Reference.Class == ACPI_REFCLASS_INDEX)) 46267754Smsmith { 46369746Smsmith goto NextOperand; 46467754Smsmith } 46567754Smsmith break; 46699679Siwasaki 46799679Siwasaki default: 468250838Sjkim 46999679Siwasaki /* All cases covered above */ 470250838Sjkim 47199679Siwasaki break; 47269746Smsmith } 47367754Smsmith 47469746Smsmith /* 47569746Smsmith * Resolve this object to a value 47669746Smsmith */ 47777424Smsmith Status = AcpiExResolveToValue (StackPtr, WalkState); 47869746Smsmith if (ACPI_FAILURE (Status)) 47969746Smsmith { 48069746Smsmith return_ACPI_STATUS (Status); 48169746Smsmith } 48267754Smsmith 483104470Siwasaki /* Get the resolved object */ 484104470Siwasaki 485104470Siwasaki ObjDesc = *StackPtr; 486104470Siwasaki 48769746Smsmith /* 48869746Smsmith * Check the resulting object (value) type 48969746Smsmith */ 49069746Smsmith switch (ThisArgType) 49169746Smsmith { 49269746Smsmith /* 49369746Smsmith * For the simple cases, only one type of resolved object 49469746Smsmith * is allowed 49569746Smsmith */ 49667754Smsmith case ARGI_MUTEX: 49767754Smsmith 49867754Smsmith /* Need an operand of type ACPI_TYPE_MUTEX */ 49967754Smsmith 50069746Smsmith TypeNeeded = ACPI_TYPE_MUTEX; 50167754Smsmith break; 50267754Smsmith 50367754Smsmith case ARGI_EVENT: 50467754Smsmith 50567754Smsmith /* Need an operand of type ACPI_TYPE_EVENT */ 50667754Smsmith 50769746Smsmith TypeNeeded = ACPI_TYPE_EVENT; 50867754Smsmith break; 50967754Smsmith 51067754Smsmith case ARGI_PACKAGE: /* Package */ 51167754Smsmith 51267754Smsmith /* Need an operand of type ACPI_TYPE_PACKAGE */ 51367754Smsmith 51469746Smsmith TypeNeeded = ACPI_TYPE_PACKAGE; 51569746Smsmith break; 51667754Smsmith 51769746Smsmith case ARGI_ANYTYPE: 51869746Smsmith 51969746Smsmith /* Any operand type will do */ 52069746Smsmith 52169746Smsmith TypeNeeded = ACPI_TYPE_ANY; 52267754Smsmith break; 52367754Smsmith 524123315Snjl case ARGI_DDBHANDLE: 52567754Smsmith 526123315Snjl /* Need an operand of type ACPI_TYPE_DDB_HANDLE */ 527123315Snjl 528123315Snjl TypeNeeded = ACPI_TYPE_LOCAL_REFERENCE; 529123315Snjl break; 530123315Snjl 531123315Snjl 53269746Smsmith /* 53369746Smsmith * The more complex cases allow multiple resolved object types 53469746Smsmith */ 535151937Sjkim case ARGI_INTEGER: 53671867Smsmith 53771867Smsmith /* 538316303Sjkim * Need an operand of type ACPI_TYPE_INTEGER, but we can 539316303Sjkim * implicitly convert from a STRING or BUFFER. 540316303Sjkim * 541316303Sjkim * Known as "Implicit Source Operand Conversion" 54271867Smsmith */ 543316303Sjkim Status = AcpiExConvertToInteger (ObjDesc, StackPtr, 544327557Sjkim ACPI_IMPLICIT_CONVERSION); 54571867Smsmith if (ACPI_FAILURE (Status)) 54671867Smsmith { 54771867Smsmith if (Status == AE_TYPE) 54871867Smsmith { 549167802Sjkim ACPI_ERROR ((AE_INFO, 550167802Sjkim "Needed [Integer/String/Buffer], found [%s] %p", 551104470Siwasaki AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 55271867Smsmith 55371867Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 55471867Smsmith } 55571867Smsmith 55671867Smsmith return_ACPI_STATUS (Status); 55771867Smsmith } 558151937Sjkim 559151937Sjkim if (ObjDesc != *StackPtr) 560151937Sjkim { 561151937Sjkim AcpiUtRemoveReference (ObjDesc); 562151937Sjkim } 56371867Smsmith goto NextOperand; 56471867Smsmith 56571867Smsmith case ARGI_BUFFER: 56671867Smsmith /* 56771867Smsmith * Need an operand of type ACPI_TYPE_BUFFER, 56871867Smsmith * But we can implicitly convert from a STRING or INTEGER 569104470Siwasaki * Aka - "Implicit Source Operand Conversion" 57071867Smsmith */ 571138287Smarks Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); 57271867Smsmith if (ACPI_FAILURE (Status)) 57371867Smsmith { 57471867Smsmith if (Status == AE_TYPE) 57571867Smsmith { 576167802Sjkim ACPI_ERROR ((AE_INFO, 577167802Sjkim "Needed [Integer/String/Buffer], found [%s] %p", 578104470Siwasaki AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 57971867Smsmith 58071867Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 58171867Smsmith } 58271867Smsmith 58371867Smsmith return_ACPI_STATUS (Status); 58471867Smsmith } 585151937Sjkim 586151937Sjkim if (ObjDesc != *StackPtr) 587151937Sjkim { 588151937Sjkim AcpiUtRemoveReference (ObjDesc); 589151937Sjkim } 59071867Smsmith goto NextOperand; 59171867Smsmith 59269746Smsmith case ARGI_STRING: 59371867Smsmith /* 59471867Smsmith * Need an operand of type ACPI_TYPE_STRING, 59571867Smsmith * But we can implicitly convert from a BUFFER or INTEGER 596104470Siwasaki * Aka - "Implicit Source Operand Conversion" 59771867Smsmith */ 598298714Sjkim Status = AcpiExConvertToString ( 599298714Sjkim ObjDesc, StackPtr, ACPI_IMPLICIT_CONVERT_HEX); 60071867Smsmith if (ACPI_FAILURE (Status)) 60171867Smsmith { 60271867Smsmith if (Status == AE_TYPE) 60371867Smsmith { 604167802Sjkim ACPI_ERROR ((AE_INFO, 605167802Sjkim "Needed [Integer/String/Buffer], found [%s] %p", 606104470Siwasaki AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 60767754Smsmith 60871867Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 60971867Smsmith } 61071867Smsmith 61171867Smsmith return_ACPI_STATUS (Status); 61271867Smsmith } 613151937Sjkim 614151937Sjkim if (ObjDesc != *StackPtr) 615151937Sjkim { 616151937Sjkim AcpiUtRemoveReference (ObjDesc); 617151937Sjkim } 61871867Smsmith goto NextOperand; 61971867Smsmith 62071867Smsmith case ARGI_COMPUTEDATA: 62171867Smsmith 62271867Smsmith /* Need an operand of type INTEGER, STRING or BUFFER */ 62371867Smsmith 624193267Sjkim switch (ObjDesc->Common.Type) 62567754Smsmith { 62691116Smsmith case ACPI_TYPE_INTEGER: 62791116Smsmith case ACPI_TYPE_STRING: 62891116Smsmith case ACPI_TYPE_BUFFER: 62991116Smsmith 63091116Smsmith /* Valid operand */ 63191116Smsmith break; 63291116Smsmith 63391116Smsmith default: 634167802Sjkim ACPI_ERROR ((AE_INFO, 635167802Sjkim "Needed [Integer/String/Buffer], found [%s] %p", 636104470Siwasaki AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 63767754Smsmith 63869746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 63967754Smsmith } 64069746Smsmith goto NextOperand; 64167754Smsmith 642114237Snjl case ARGI_BUFFER_OR_STRING: 643114237Snjl 644114237Snjl /* Need an operand of type STRING or BUFFER */ 645114237Snjl 646193267Sjkim switch (ObjDesc->Common.Type) 647114237Snjl { 648114237Snjl case ACPI_TYPE_STRING: 649114237Snjl case ACPI_TYPE_BUFFER: 650114237Snjl 651114237Snjl /* Valid operand */ 652114237Snjl break; 653114237Snjl 654114237Snjl case ACPI_TYPE_INTEGER: 655114237Snjl 656114237Snjl /* Highest priority conversion is to type Buffer */ 657114237Snjl 658138287Smarks Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); 659114237Snjl if (ACPI_FAILURE (Status)) 660114237Snjl { 661114237Snjl return_ACPI_STATUS (Status); 662114237Snjl } 663151937Sjkim 664151937Sjkim if (ObjDesc != *StackPtr) 665151937Sjkim { 666151937Sjkim AcpiUtRemoveReference (ObjDesc); 667151937Sjkim } 668114237Snjl break; 669114237Snjl 670114237Snjl default: 671167802Sjkim ACPI_ERROR ((AE_INFO, 672167802Sjkim "Needed [Integer/String/Buffer], found [%s] %p", 673114237Snjl AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 674114237Snjl 675114237Snjl return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 676114237Snjl } 677114237Snjl goto NextOperand; 678114237Snjl 67967754Smsmith case ARGI_DATAOBJECT: 68067754Smsmith /* 68167754Smsmith * ARGI_DATAOBJECT is only used by the SizeOf operator. 682104470Siwasaki * Need a buffer, string, package, or RefOf reference. 68367754Smsmith * 68491116Smsmith * The only reference allowed here is a direct reference to 68591116Smsmith * a namespace node. 68667754Smsmith */ 687193267Sjkim switch (ObjDesc->Common.Type) 68867754Smsmith { 68991116Smsmith case ACPI_TYPE_PACKAGE: 69091116Smsmith case ACPI_TYPE_STRING: 69191116Smsmith case ACPI_TYPE_BUFFER: 692107325Siwasaki case ACPI_TYPE_LOCAL_REFERENCE: 69391116Smsmith 69491116Smsmith /* Valid operand */ 69591116Smsmith break; 69691116Smsmith 69791116Smsmith default: 698250838Sjkim 699167802Sjkim ACPI_ERROR ((AE_INFO, 700167802Sjkim "Needed [Buffer/String/Package/Reference], found [%s] %p", 701104470Siwasaki AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 70291116Smsmith 70391116Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 70491116Smsmith } 70569746Smsmith goto NextOperand; 70667754Smsmith 70767754Smsmith case ARGI_COMPLEXOBJ: 70867754Smsmith 70977424Smsmith /* Need a buffer or package or (ACPI 2.0) String */ 71067754Smsmith 711193267Sjkim switch (ObjDesc->Common.Type) 71267754Smsmith { 71391116Smsmith case ACPI_TYPE_PACKAGE: 71491116Smsmith case ACPI_TYPE_STRING: 71591116Smsmith case ACPI_TYPE_BUFFER: 71691116Smsmith 71791116Smsmith /* Valid operand */ 71891116Smsmith break; 71991116Smsmith 72091116Smsmith default: 721250838Sjkim 722167802Sjkim ACPI_ERROR ((AE_INFO, 723167802Sjkim "Needed [Buffer/String/Package], found [%s] %p", 724104470Siwasaki AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 72569746Smsmith 72669746Smsmith return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 72767754Smsmith } 72869746Smsmith goto NextOperand; 72967754Smsmith 730167802Sjkim case ARGI_REGION_OR_BUFFER: /* Used by Load() only */ 731114237Snjl 732298714Sjkim /* 733298714Sjkim * Need an operand of type REGION or a BUFFER 734298714Sjkim * (which could be a resolved region field) 735298714Sjkim */ 736193267Sjkim switch (ObjDesc->Common.Type) 737114237Snjl { 738167802Sjkim case ACPI_TYPE_BUFFER: 739114237Snjl case ACPI_TYPE_REGION: 740114237Snjl 741114237Snjl /* Valid operand */ 742114237Snjl break; 743114237Snjl 744114237Snjl default: 745250838Sjkim 746167802Sjkim ACPI_ERROR ((AE_INFO, 747167802Sjkim "Needed [Region/Buffer], found [%s] %p", 748114237Snjl AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 749114237Snjl 750114237Snjl return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 751114237Snjl } 752114237Snjl goto NextOperand; 753114237Snjl 754151937Sjkim case ARGI_DATAREFOBJ: 755151937Sjkim 756151937Sjkim /* Used by the Store() operator only */ 757151937Sjkim 758193267Sjkim switch (ObjDesc->Common.Type) 759151937Sjkim { 760151937Sjkim case ACPI_TYPE_INTEGER: 761151937Sjkim case ACPI_TYPE_PACKAGE: 762151937Sjkim case ACPI_TYPE_STRING: 763151937Sjkim case ACPI_TYPE_BUFFER: 764151937Sjkim case ACPI_TYPE_BUFFER_FIELD: 765151937Sjkim case ACPI_TYPE_LOCAL_REFERENCE: 766151937Sjkim case ACPI_TYPE_LOCAL_REGION_FIELD: 767151937Sjkim case ACPI_TYPE_LOCAL_BANK_FIELD: 768151937Sjkim case ACPI_TYPE_LOCAL_INDEX_FIELD: 769151937Sjkim case ACPI_TYPE_DDB_HANDLE: 770151937Sjkim 771151937Sjkim /* Valid operand */ 772151937Sjkim break; 773151937Sjkim 774151937Sjkim default: 775151937Sjkim 776151937Sjkim if (AcpiGbl_EnableInterpreterSlack) 777151937Sjkim { 778151937Sjkim /* 779298714Sjkim * Enable original behavior of Store(), allowing any 780298714Sjkim * and all objects as the source operand. The ACPI 781298714Sjkim * spec does not allow this, however. 782151937Sjkim */ 783151937Sjkim break; 784151937Sjkim } 785151937Sjkim 786151937Sjkim if (TargetOp == AML_DEBUG_OP) 787151937Sjkim { 788151937Sjkim /* Allow store of any object to the Debug object */ 789151937Sjkim 790151937Sjkim break; 791151937Sjkim } 792151937Sjkim 793167802Sjkim ACPI_ERROR ((AE_INFO, 794298714Sjkim "Needed Integer/Buffer/String/Package/Ref/Ddb]" 795298714Sjkim ", found [%s] %p", 796151937Sjkim AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 797151937Sjkim 798151937Sjkim return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 799151937Sjkim } 800151937Sjkim goto NextOperand; 801151937Sjkim 80269746Smsmith default: 80367754Smsmith 80469746Smsmith /* Unknown type */ 80569746Smsmith 806167802Sjkim ACPI_ERROR ((AE_INFO, 807204773Sjkim "Internal - Unknown ARGI (required operand) type 0x%X", 80867754Smsmith ThisArgType)); 80967754Smsmith 81069746Smsmith return_ACPI_STATUS (AE_BAD_PARAMETER); 81169746Smsmith } 81267754Smsmith 81370243Smsmith /* 81469746Smsmith * Make sure that the original object was resolved to the 81569746Smsmith * required object type (Simple cases only). 81669746Smsmith */ 817298714Sjkim Status = AcpiExCheckObjectType ( 818298714Sjkim TypeNeeded, (*StackPtr)->Common.Type, *StackPtr); 81969746Smsmith if (ACPI_FAILURE (Status)) 82069746Smsmith { 82169746Smsmith return_ACPI_STATUS (Status); 82269746Smsmith } 82369746Smsmith 82469746SmsmithNextOperand: 82567754Smsmith /* 82667754Smsmith * If more operands needed, decrement StackPtr to point 82769746Smsmith * to next operand on stack 82867754Smsmith */ 82967754Smsmith if (GET_CURRENT_ARG_TYPE (ArgTypes)) 83067754Smsmith { 83167754Smsmith StackPtr--; 83267754Smsmith } 833151937Sjkim } 83467754Smsmith 835193267Sjkim ACPI_DUMP_OPERANDS (WalkState->Operands, 836193267Sjkim AcpiPsGetOpcodeName (Opcode), WalkState->NumOperands); 837193267Sjkim 83869746Smsmith return_ACPI_STATUS (Status); 83967754Smsmith} 840