1db2bae30SDana Myers /****************************************************************************** 2db2bae30SDana Myers * 3db2bae30SDana Myers * Module Name: exresop - AML Interpreter operand/object resolution 4db2bae30SDana Myers * 5db2bae30SDana Myers *****************************************************************************/ 6db2bae30SDana Myers 726f3cdf0SGordon Ross /* 8*385cc6b4SJerry Jelinek * Copyright (C) 2000 - 2016, Intel Corp. 9db2bae30SDana Myers * All rights reserved. 10db2bae30SDana Myers * 1126f3cdf0SGordon Ross * Redistribution and use in source and binary forms, with or without 1226f3cdf0SGordon Ross * modification, are permitted provided that the following conditions 1326f3cdf0SGordon Ross * are met: 1426f3cdf0SGordon Ross * 1. Redistributions of source code must retain the above copyright 1526f3cdf0SGordon Ross * notice, this list of conditions, and the following disclaimer, 1626f3cdf0SGordon Ross * without modification. 1726f3cdf0SGordon Ross * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1826f3cdf0SGordon Ross * substantially similar to the "NO WARRANTY" disclaimer below 1926f3cdf0SGordon Ross * ("Disclaimer") and any redistribution must be conditioned upon 2026f3cdf0SGordon Ross * including a substantially similar Disclaimer requirement for further 2126f3cdf0SGordon Ross * binary redistribution. 2226f3cdf0SGordon Ross * 3. Neither the names of the above-listed copyright holders nor the names 2326f3cdf0SGordon Ross * of any contributors may be used to endorse or promote products derived 2426f3cdf0SGordon Ross * from this software without specific prior written permission. 25db2bae30SDana Myers * 2626f3cdf0SGordon Ross * Alternatively, this software may be distributed under the terms of the 2726f3cdf0SGordon Ross * GNU General Public License ("GPL") version 2 as published by the Free 2826f3cdf0SGordon Ross * Software Foundation. 29db2bae30SDana Myers * 3026f3cdf0SGordon Ross * NO WARRANTY 3126f3cdf0SGordon Ross * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 3226f3cdf0SGordon Ross * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3326f3cdf0SGordon Ross * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 3426f3cdf0SGordon Ross * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3526f3cdf0SGordon Ross * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3626f3cdf0SGordon Ross * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3726f3cdf0SGordon Ross * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3826f3cdf0SGordon Ross * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 3926f3cdf0SGordon Ross * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 4026f3cdf0SGordon Ross * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 4126f3cdf0SGordon Ross * POSSIBILITY OF SUCH DAMAGES. 4226f3cdf0SGordon Ross */ 43db2bae30SDana Myers 44db2bae30SDana Myers #include "acpi.h" 45aa2aa9a6SDana Myers #include "accommon.h" 46db2bae30SDana Myers #include "amlcode.h" 47db2bae30SDana Myers #include "acparser.h" 48db2bae30SDana Myers #include "acinterp.h" 49db2bae30SDana Myers #include "acnamesp.h" 50db2bae30SDana Myers 51db2bae30SDana Myers 52db2bae30SDana Myers #define _COMPONENT ACPI_EXECUTER 53db2bae30SDana Myers ACPI_MODULE_NAME ("exresop") 54db2bae30SDana Myers 55db2bae30SDana Myers /* Local prototypes */ 56db2bae30SDana Myers 57db2bae30SDana Myers static ACPI_STATUS 58db2bae30SDana Myers AcpiExCheckObjectType ( 59db2bae30SDana Myers ACPI_OBJECT_TYPE TypeNeeded, 60db2bae30SDana Myers ACPI_OBJECT_TYPE ThisType, 61db2bae30SDana Myers void *Object); 62db2bae30SDana Myers 63db2bae30SDana Myers 64db2bae30SDana Myers /******************************************************************************* 65db2bae30SDana Myers * 66db2bae30SDana Myers * FUNCTION: AcpiExCheckObjectType 67db2bae30SDana Myers * 68db2bae30SDana Myers * PARAMETERS: TypeNeeded Object type needed 69db2bae30SDana Myers * ThisType Actual object type 70db2bae30SDana Myers * Object Object pointer 71db2bae30SDana Myers * 72db2bae30SDana Myers * RETURN: Status 73db2bae30SDana Myers * 74db2bae30SDana Myers * DESCRIPTION: Check required type against actual type 75db2bae30SDana Myers * 76db2bae30SDana Myers ******************************************************************************/ 77db2bae30SDana Myers 78db2bae30SDana Myers static ACPI_STATUS 79db2bae30SDana Myers AcpiExCheckObjectType ( 80db2bae30SDana Myers ACPI_OBJECT_TYPE TypeNeeded, 81db2bae30SDana Myers ACPI_OBJECT_TYPE ThisType, 82db2bae30SDana Myers void *Object) 83db2bae30SDana Myers { 84db2bae30SDana Myers ACPI_FUNCTION_ENTRY (); 85db2bae30SDana Myers 86db2bae30SDana Myers 87db2bae30SDana Myers if (TypeNeeded == ACPI_TYPE_ANY) 88db2bae30SDana Myers { 89db2bae30SDana Myers /* All types OK, so we don't perform any typechecks */ 90db2bae30SDana Myers 91db2bae30SDana Myers return (AE_OK); 92db2bae30SDana Myers } 93db2bae30SDana Myers 94db2bae30SDana Myers if (TypeNeeded == ACPI_TYPE_LOCAL_REFERENCE) 95db2bae30SDana Myers { 96db2bae30SDana Myers /* 97db2bae30SDana Myers * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference 98db2bae30SDana Myers * objects and thus allow them to be targets. (As per the ACPI 99db2bae30SDana Myers * specification, a store to a constant is a noop.) 100db2bae30SDana Myers */ 101db2bae30SDana Myers if ((ThisType == ACPI_TYPE_INTEGER) && 102*385cc6b4SJerry Jelinek (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & 103*385cc6b4SJerry Jelinek AOPOBJ_AML_CONSTANT)) 104db2bae30SDana Myers { 105db2bae30SDana Myers return (AE_OK); 106db2bae30SDana Myers } 107db2bae30SDana Myers } 108db2bae30SDana Myers 109db2bae30SDana Myers if (TypeNeeded != ThisType) 110db2bae30SDana Myers { 111db2bae30SDana Myers ACPI_ERROR ((AE_INFO, 112db2bae30SDana Myers "Needed type [%s], found [%s] %p", 113db2bae30SDana Myers AcpiUtGetTypeName (TypeNeeded), 114db2bae30SDana Myers AcpiUtGetTypeName (ThisType), Object)); 115db2bae30SDana Myers 116db2bae30SDana Myers return (AE_AML_OPERAND_TYPE); 117db2bae30SDana Myers } 118db2bae30SDana Myers 119db2bae30SDana Myers return (AE_OK); 120db2bae30SDana Myers } 121db2bae30SDana Myers 122db2bae30SDana Myers 123db2bae30SDana Myers /******************************************************************************* 124db2bae30SDana Myers * 125db2bae30SDana Myers * FUNCTION: AcpiExResolveOperands 126db2bae30SDana Myers * 127db2bae30SDana Myers * PARAMETERS: Opcode - Opcode being interpreted 128db2bae30SDana Myers * StackPtr - Pointer to the operand stack to be 129db2bae30SDana Myers * resolved 130db2bae30SDana Myers * WalkState - Current state 131db2bae30SDana Myers * 132db2bae30SDana Myers * RETURN: Status 133db2bae30SDana Myers * 134db2bae30SDana Myers * DESCRIPTION: Convert multiple input operands to the types required by the 135db2bae30SDana Myers * target operator. 136db2bae30SDana Myers * 137db2bae30SDana Myers * Each 5-bit group in ArgTypes represents one required 138db2bae30SDana Myers * operand and indicates the required Type. The corresponding operand 139db2bae30SDana Myers * will be converted to the required type if possible, otherwise we 140db2bae30SDana Myers * abort with an exception. 141db2bae30SDana Myers * 142db2bae30SDana Myers ******************************************************************************/ 143db2bae30SDana Myers 144db2bae30SDana Myers ACPI_STATUS 145db2bae30SDana Myers AcpiExResolveOperands ( 146db2bae30SDana Myers UINT16 Opcode, 147db2bae30SDana Myers ACPI_OPERAND_OBJECT **StackPtr, 148db2bae30SDana Myers ACPI_WALK_STATE *WalkState) 149db2bae30SDana Myers { 150db2bae30SDana Myers ACPI_OPERAND_OBJECT *ObjDesc; 151db2bae30SDana Myers ACPI_STATUS Status = AE_OK; 152db2bae30SDana Myers UINT8 ObjectType; 153db2bae30SDana Myers UINT32 ArgTypes; 154db2bae30SDana Myers const ACPI_OPCODE_INFO *OpInfo; 155db2bae30SDana Myers UINT32 ThisArgType; 156db2bae30SDana Myers ACPI_OBJECT_TYPE TypeNeeded; 157db2bae30SDana Myers UINT16 TargetOp = 0; 158db2bae30SDana Myers 159db2bae30SDana Myers 160db2bae30SDana Myers ACPI_FUNCTION_TRACE_U32 (ExResolveOperands, Opcode); 161db2bae30SDana Myers 162db2bae30SDana Myers 163db2bae30SDana Myers OpInfo = AcpiPsGetOpcodeInfo (Opcode); 164db2bae30SDana Myers if (OpInfo->Class == AML_CLASS_UNKNOWN) 165db2bae30SDana Myers { 166db2bae30SDana Myers return_ACPI_STATUS (AE_AML_BAD_OPCODE); 167db2bae30SDana Myers } 168db2bae30SDana Myers 169db2bae30SDana Myers ArgTypes = OpInfo->RuntimeArgs; 170db2bae30SDana Myers if (ArgTypes == ARGI_INVALID_OPCODE) 171db2bae30SDana Myers { 17226f3cdf0SGordon Ross ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X", 173db2bae30SDana Myers Opcode)); 174db2bae30SDana Myers 175db2bae30SDana Myers return_ACPI_STATUS (AE_AML_INTERNAL); 176db2bae30SDana Myers } 177db2bae30SDana Myers 178db2bae30SDana Myers ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 179db2bae30SDana Myers "Opcode %X [%s] RequiredOperandTypes=%8.8X\n", 180db2bae30SDana Myers Opcode, OpInfo->Name, ArgTypes)); 181db2bae30SDana Myers 182db2bae30SDana Myers /* 183db2bae30SDana Myers * Normal exit is with (ArgTypes == 0) at end of argument list. 184db2bae30SDana Myers * Function will return an exception from within the loop upon 185db2bae30SDana Myers * finding an entry which is not (or cannot be converted 186db2bae30SDana Myers * to) the required type; if stack underflows; or upon 187db2bae30SDana Myers * finding a NULL stack entry (which should not happen). 188db2bae30SDana Myers */ 189db2bae30SDana Myers while (GET_CURRENT_ARG_TYPE (ArgTypes)) 190db2bae30SDana Myers { 191db2bae30SDana Myers if (!StackPtr || !*StackPtr) 192db2bae30SDana Myers { 193db2bae30SDana Myers ACPI_ERROR ((AE_INFO, "Null stack entry at %p", 194db2bae30SDana Myers StackPtr)); 195db2bae30SDana Myers 196db2bae30SDana Myers return_ACPI_STATUS (AE_AML_INTERNAL); 197db2bae30SDana Myers } 198db2bae30SDana Myers 199db2bae30SDana Myers /* Extract useful items */ 200db2bae30SDana Myers 201db2bae30SDana Myers ObjDesc = *StackPtr; 202db2bae30SDana Myers 203db2bae30SDana Myers /* Decode the descriptor type */ 204db2bae30SDana Myers 205db2bae30SDana Myers switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) 206db2bae30SDana Myers { 207db2bae30SDana Myers case ACPI_DESC_TYPE_NAMED: 208db2bae30SDana Myers 209db2bae30SDana Myers /* Namespace Node */ 210db2bae30SDana Myers 211db2bae30SDana Myers ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; 212db2bae30SDana Myers 213db2bae30SDana Myers /* 214db2bae30SDana Myers * Resolve an alias object. The construction of these objects 215db2bae30SDana Myers * guarantees that there is only one level of alias indirection; 216db2bae30SDana Myers * thus, the attached object is always the aliased namespace node 217db2bae30SDana Myers */ 218db2bae30SDana Myers if (ObjectType == ACPI_TYPE_LOCAL_ALIAS) 219db2bae30SDana Myers { 220*385cc6b4SJerry Jelinek ObjDesc = AcpiNsGetAttachedObject ( 221*385cc6b4SJerry Jelinek (ACPI_NAMESPACE_NODE *) ObjDesc); 222db2bae30SDana Myers *StackPtr = ObjDesc; 223db2bae30SDana Myers ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; 224db2bae30SDana Myers } 225db2bae30SDana Myers break; 226db2bae30SDana Myers 227db2bae30SDana Myers case ACPI_DESC_TYPE_OPERAND: 228db2bae30SDana Myers 229db2bae30SDana Myers /* ACPI internal object */ 230db2bae30SDana Myers 231aa2aa9a6SDana Myers ObjectType = ObjDesc->Common.Type; 232db2bae30SDana Myers 233db2bae30SDana Myers /* Check for bad ACPI_OBJECT_TYPE */ 234db2bae30SDana Myers 235db2bae30SDana Myers if (!AcpiUtValidObjectType (ObjectType)) 236db2bae30SDana Myers { 237db2bae30SDana Myers ACPI_ERROR ((AE_INFO, 23826f3cdf0SGordon Ross "Bad operand object type [0x%X]", ObjectType)); 239db2bae30SDana Myers 240db2bae30SDana Myers return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 241db2bae30SDana Myers } 242db2bae30SDana Myers 243db2bae30SDana Myers if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE) 244db2bae30SDana Myers { 245db2bae30SDana Myers /* Validate the Reference */ 246db2bae30SDana Myers 247db2bae30SDana Myers switch (ObjDesc->Reference.Class) 248db2bae30SDana Myers { 249db2bae30SDana Myers case ACPI_REFCLASS_DEBUG: 250db2bae30SDana Myers 251db2bae30SDana Myers TargetOp = AML_DEBUG_OP; 252db2bae30SDana Myers 253db2bae30SDana Myers /*lint -fallthrough */ 254db2bae30SDana Myers 255db2bae30SDana Myers case ACPI_REFCLASS_ARG: 256db2bae30SDana Myers case ACPI_REFCLASS_LOCAL: 257db2bae30SDana Myers case ACPI_REFCLASS_INDEX: 258db2bae30SDana Myers case ACPI_REFCLASS_REFOF: 259db2bae30SDana Myers case ACPI_REFCLASS_TABLE: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */ 260db2bae30SDana Myers case ACPI_REFCLASS_NAME: /* Reference to a named object */ 261db2bae30SDana Myers 262db2bae30SDana Myers ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 263db2bae30SDana Myers "Operand is a Reference, Class [%s] %2.2X\n", 264db2bae30SDana Myers AcpiUtGetReferenceName (ObjDesc), 265db2bae30SDana Myers ObjDesc->Reference.Class)); 266db2bae30SDana Myers break; 267db2bae30SDana Myers 268db2bae30SDana Myers default: 269db2bae30SDana Myers 270db2bae30SDana Myers ACPI_ERROR ((AE_INFO, 27126f3cdf0SGordon Ross "Unknown Reference Class 0x%2.2X in %p", 272db2bae30SDana Myers ObjDesc->Reference.Class, ObjDesc)); 273db2bae30SDana Myers 274db2bae30SDana Myers return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 275db2bae30SDana Myers } 276db2bae30SDana Myers } 277db2bae30SDana Myers break; 278db2bae30SDana Myers 279db2bae30SDana Myers default: 280db2bae30SDana Myers 281db2bae30SDana Myers /* Invalid descriptor */ 282db2bae30SDana Myers 283db2bae30SDana Myers ACPI_ERROR ((AE_INFO, "Invalid descriptor %p [%s]", 284db2bae30SDana Myers ObjDesc, AcpiUtGetDescriptorName (ObjDesc))); 285db2bae30SDana Myers 286db2bae30SDana Myers return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 287db2bae30SDana Myers } 288db2bae30SDana Myers 289db2bae30SDana Myers /* Get one argument type, point to the next */ 290db2bae30SDana Myers 291db2bae30SDana Myers ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes); 292db2bae30SDana Myers INCREMENT_ARG_LIST (ArgTypes); 293db2bae30SDana Myers 294db2bae30SDana Myers /* 295db2bae30SDana Myers * Handle cases where the object does not need to be 296db2bae30SDana Myers * resolved to a value 297db2bae30SDana Myers */ 298db2bae30SDana Myers switch (ThisArgType) 299db2bae30SDana Myers { 300db2bae30SDana Myers case ARGI_REF_OR_STRING: /* Can be a String or Reference */ 301db2bae30SDana Myers 302*385cc6b4SJerry Jelinek if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == 303*385cc6b4SJerry Jelinek ACPI_DESC_TYPE_OPERAND) && 304aa2aa9a6SDana Myers (ObjDesc->Common.Type == ACPI_TYPE_STRING)) 305db2bae30SDana Myers { 306db2bae30SDana Myers /* 307db2bae30SDana Myers * String found - the string references a named object and 308db2bae30SDana Myers * must be resolved to a node 309db2bae30SDana Myers */ 310db2bae30SDana Myers goto NextOperand; 311db2bae30SDana Myers } 312db2bae30SDana Myers 313db2bae30SDana Myers /* 314db2bae30SDana Myers * Else not a string - fall through to the normal Reference 315db2bae30SDana Myers * case below 316db2bae30SDana Myers */ 317db2bae30SDana Myers /*lint -fallthrough */ 318db2bae30SDana Myers 319db2bae30SDana Myers case ARGI_REFERENCE: /* References: */ 320db2bae30SDana Myers case ARGI_INTEGER_REF: 321db2bae30SDana Myers case ARGI_OBJECT_REF: 322db2bae30SDana Myers case ARGI_DEVICE_REF: 323db2bae30SDana Myers case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ 324db2bae30SDana Myers case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ 325db2bae30SDana Myers case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ 326*385cc6b4SJerry Jelinek case ARGI_STORE_TARGET: 327db2bae30SDana Myers 328db2bae30SDana Myers /* 329db2bae30SDana Myers * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE 330db2bae30SDana Myers * A Namespace Node is OK as-is 331db2bae30SDana Myers */ 332db2bae30SDana Myers if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) 333db2bae30SDana Myers { 334db2bae30SDana Myers goto NextOperand; 335db2bae30SDana Myers } 336db2bae30SDana Myers 337*385cc6b4SJerry Jelinek Status = AcpiExCheckObjectType ( 338*385cc6b4SJerry Jelinek ACPI_TYPE_LOCAL_REFERENCE, ObjectType, ObjDesc); 339db2bae30SDana Myers if (ACPI_FAILURE (Status)) 340db2bae30SDana Myers { 341db2bae30SDana Myers return_ACPI_STATUS (Status); 342db2bae30SDana Myers } 343db2bae30SDana Myers goto NextOperand; 344db2bae30SDana Myers 345db2bae30SDana Myers case ARGI_DATAREFOBJ: /* Store operator only */ 346db2bae30SDana Myers /* 347db2bae30SDana Myers * We don't want to resolve IndexOp reference objects during 348db2bae30SDana Myers * a store because this would be an implicit DeRefOf operation. 349db2bae30SDana Myers * Instead, we just want to store the reference object. 350db2bae30SDana Myers * -- All others must be resolved below. 351db2bae30SDana Myers */ 352db2bae30SDana Myers if ((Opcode == AML_STORE_OP) && 353aa2aa9a6SDana Myers ((*StackPtr)->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && 354db2bae30SDana Myers ((*StackPtr)->Reference.Class == ACPI_REFCLASS_INDEX)) 355db2bae30SDana Myers { 356db2bae30SDana Myers goto NextOperand; 357db2bae30SDana Myers } 358db2bae30SDana Myers break; 359db2bae30SDana Myers 360db2bae30SDana Myers default: 361*385cc6b4SJerry Jelinek 362db2bae30SDana Myers /* All cases covered above */ 363*385cc6b4SJerry Jelinek 364db2bae30SDana Myers break; 365db2bae30SDana Myers } 366db2bae30SDana Myers 367db2bae30SDana Myers /* 368db2bae30SDana Myers * Resolve this object to a value 369db2bae30SDana Myers */ 370db2bae30SDana Myers Status = AcpiExResolveToValue (StackPtr, WalkState); 371db2bae30SDana Myers if (ACPI_FAILURE (Status)) 372db2bae30SDana Myers { 373db2bae30SDana Myers return_ACPI_STATUS (Status); 374db2bae30SDana Myers } 375db2bae30SDana Myers 376db2bae30SDana Myers /* Get the resolved object */ 377db2bae30SDana Myers 378db2bae30SDana Myers ObjDesc = *StackPtr; 379db2bae30SDana Myers 380db2bae30SDana Myers /* 381db2bae30SDana Myers * Check the resulting object (value) type 382db2bae30SDana Myers */ 383db2bae30SDana Myers switch (ThisArgType) 384db2bae30SDana Myers { 385db2bae30SDana Myers /* 386db2bae30SDana Myers * For the simple cases, only one type of resolved object 387db2bae30SDana Myers * is allowed 388db2bae30SDana Myers */ 389db2bae30SDana Myers case ARGI_MUTEX: 390db2bae30SDana Myers 391db2bae30SDana Myers /* Need an operand of type ACPI_TYPE_MUTEX */ 392db2bae30SDana Myers 393db2bae30SDana Myers TypeNeeded = ACPI_TYPE_MUTEX; 394db2bae30SDana Myers break; 395db2bae30SDana Myers 396db2bae30SDana Myers case ARGI_EVENT: 397db2bae30SDana Myers 398db2bae30SDana Myers /* Need an operand of type ACPI_TYPE_EVENT */ 399db2bae30SDana Myers 400db2bae30SDana Myers TypeNeeded = ACPI_TYPE_EVENT; 401db2bae30SDana Myers break; 402db2bae30SDana Myers 403db2bae30SDana Myers case ARGI_PACKAGE: /* Package */ 404db2bae30SDana Myers 405db2bae30SDana Myers /* Need an operand of type ACPI_TYPE_PACKAGE */ 406db2bae30SDana Myers 407db2bae30SDana Myers TypeNeeded = ACPI_TYPE_PACKAGE; 408db2bae30SDana Myers break; 409db2bae30SDana Myers 410db2bae30SDana Myers case ARGI_ANYTYPE: 411db2bae30SDana Myers 412db2bae30SDana Myers /* Any operand type will do */ 413db2bae30SDana Myers 414db2bae30SDana Myers TypeNeeded = ACPI_TYPE_ANY; 415db2bae30SDana Myers break; 416db2bae30SDana Myers 417db2bae30SDana Myers case ARGI_DDBHANDLE: 418db2bae30SDana Myers 419db2bae30SDana Myers /* Need an operand of type ACPI_TYPE_DDB_HANDLE */ 420db2bae30SDana Myers 421db2bae30SDana Myers TypeNeeded = ACPI_TYPE_LOCAL_REFERENCE; 422db2bae30SDana Myers break; 423db2bae30SDana Myers 424db2bae30SDana Myers 425db2bae30SDana Myers /* 426db2bae30SDana Myers * The more complex cases allow multiple resolved object types 427db2bae30SDana Myers */ 428db2bae30SDana Myers case ARGI_INTEGER: 429db2bae30SDana Myers 430db2bae30SDana Myers /* 431db2bae30SDana Myers * Need an operand of type ACPI_TYPE_INTEGER, 432db2bae30SDana Myers * But we can implicitly convert from a STRING or BUFFER 433db2bae30SDana Myers * Aka - "Implicit Source Operand Conversion" 434db2bae30SDana Myers */ 435db2bae30SDana Myers Status = AcpiExConvertToInteger (ObjDesc, StackPtr, 16); 436db2bae30SDana Myers if (ACPI_FAILURE (Status)) 437db2bae30SDana Myers { 438db2bae30SDana Myers if (Status == AE_TYPE) 439db2bae30SDana Myers { 440db2bae30SDana Myers ACPI_ERROR ((AE_INFO, 441db2bae30SDana Myers "Needed [Integer/String/Buffer], found [%s] %p", 442db2bae30SDana Myers AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 443db2bae30SDana Myers 444db2bae30SDana Myers return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 445db2bae30SDana Myers } 446db2bae30SDana Myers 447db2bae30SDana Myers return_ACPI_STATUS (Status); 448db2bae30SDana Myers } 449db2bae30SDana Myers 450db2bae30SDana Myers if (ObjDesc != *StackPtr) 451db2bae30SDana Myers { 452db2bae30SDana Myers AcpiUtRemoveReference (ObjDesc); 453db2bae30SDana Myers } 454db2bae30SDana Myers goto NextOperand; 455db2bae30SDana Myers 456db2bae30SDana Myers case ARGI_BUFFER: 457db2bae30SDana Myers /* 458db2bae30SDana Myers * Need an operand of type ACPI_TYPE_BUFFER, 459db2bae30SDana Myers * But we can implicitly convert from a STRING or INTEGER 460db2bae30SDana Myers * Aka - "Implicit Source Operand Conversion" 461db2bae30SDana Myers */ 462db2bae30SDana Myers Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); 463db2bae30SDana Myers if (ACPI_FAILURE (Status)) 464db2bae30SDana Myers { 465db2bae30SDana Myers if (Status == AE_TYPE) 466db2bae30SDana Myers { 467db2bae30SDana Myers ACPI_ERROR ((AE_INFO, 468db2bae30SDana Myers "Needed [Integer/String/Buffer], found [%s] %p", 469db2bae30SDana Myers AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 470db2bae30SDana Myers 471db2bae30SDana Myers return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 472db2bae30SDana Myers } 473db2bae30SDana Myers 474db2bae30SDana Myers return_ACPI_STATUS (Status); 475db2bae30SDana Myers } 476db2bae30SDana Myers 477db2bae30SDana Myers if (ObjDesc != *StackPtr) 478db2bae30SDana Myers { 479db2bae30SDana Myers AcpiUtRemoveReference (ObjDesc); 480db2bae30SDana Myers } 481db2bae30SDana Myers goto NextOperand; 482db2bae30SDana Myers 483db2bae30SDana Myers case ARGI_STRING: 484db2bae30SDana Myers /* 485db2bae30SDana Myers * Need an operand of type ACPI_TYPE_STRING, 486db2bae30SDana Myers * But we can implicitly convert from a BUFFER or INTEGER 487db2bae30SDana Myers * Aka - "Implicit Source Operand Conversion" 488db2bae30SDana Myers */ 489*385cc6b4SJerry Jelinek Status = AcpiExConvertToString ( 490*385cc6b4SJerry Jelinek ObjDesc, StackPtr, ACPI_IMPLICIT_CONVERT_HEX); 491db2bae30SDana Myers if (ACPI_FAILURE (Status)) 492db2bae30SDana Myers { 493db2bae30SDana Myers if (Status == AE_TYPE) 494db2bae30SDana Myers { 495db2bae30SDana Myers ACPI_ERROR ((AE_INFO, 496db2bae30SDana Myers "Needed [Integer/String/Buffer], found [%s] %p", 497db2bae30SDana Myers AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 498db2bae30SDana Myers 499db2bae30SDana Myers return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 500db2bae30SDana Myers } 501db2bae30SDana Myers 502db2bae30SDana Myers return_ACPI_STATUS (Status); 503db2bae30SDana Myers } 504db2bae30SDana Myers 505db2bae30SDana Myers if (ObjDesc != *StackPtr) 506db2bae30SDana Myers { 507db2bae30SDana Myers AcpiUtRemoveReference (ObjDesc); 508db2bae30SDana Myers } 509db2bae30SDana Myers goto NextOperand; 510db2bae30SDana Myers 511db2bae30SDana Myers case ARGI_COMPUTEDATA: 512db2bae30SDana Myers 513db2bae30SDana Myers /* Need an operand of type INTEGER, STRING or BUFFER */ 514db2bae30SDana Myers 515aa2aa9a6SDana Myers switch (ObjDesc->Common.Type) 516db2bae30SDana Myers { 517db2bae30SDana Myers case ACPI_TYPE_INTEGER: 518db2bae30SDana Myers case ACPI_TYPE_STRING: 519db2bae30SDana Myers case ACPI_TYPE_BUFFER: 520db2bae30SDana Myers 521db2bae30SDana Myers /* Valid operand */ 522db2bae30SDana Myers break; 523db2bae30SDana Myers 524db2bae30SDana Myers default: 525db2bae30SDana Myers ACPI_ERROR ((AE_INFO, 526db2bae30SDana Myers "Needed [Integer/String/Buffer], found [%s] %p", 527db2bae30SDana Myers AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 528db2bae30SDana Myers 529db2bae30SDana Myers return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 530db2bae30SDana Myers } 531db2bae30SDana Myers goto NextOperand; 532db2bae30SDana Myers 533db2bae30SDana Myers case ARGI_BUFFER_OR_STRING: 534db2bae30SDana Myers 535db2bae30SDana Myers /* Need an operand of type STRING or BUFFER */ 536db2bae30SDana Myers 537aa2aa9a6SDana Myers switch (ObjDesc->Common.Type) 538db2bae30SDana Myers { 539db2bae30SDana Myers case ACPI_TYPE_STRING: 540db2bae30SDana Myers case ACPI_TYPE_BUFFER: 541db2bae30SDana Myers 542db2bae30SDana Myers /* Valid operand */ 543db2bae30SDana Myers break; 544db2bae30SDana Myers 545db2bae30SDana Myers case ACPI_TYPE_INTEGER: 546db2bae30SDana Myers 547db2bae30SDana Myers /* Highest priority conversion is to type Buffer */ 548db2bae30SDana Myers 549db2bae30SDana Myers Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); 550db2bae30SDana Myers if (ACPI_FAILURE (Status)) 551db2bae30SDana Myers { 552db2bae30SDana Myers return_ACPI_STATUS (Status); 553db2bae30SDana Myers } 554db2bae30SDana Myers 555db2bae30SDana Myers if (ObjDesc != *StackPtr) 556db2bae30SDana Myers { 557db2bae30SDana Myers AcpiUtRemoveReference (ObjDesc); 558db2bae30SDana Myers } 559db2bae30SDana Myers break; 560db2bae30SDana Myers 561db2bae30SDana Myers default: 562db2bae30SDana Myers ACPI_ERROR ((AE_INFO, 563db2bae30SDana Myers "Needed [Integer/String/Buffer], found [%s] %p", 564db2bae30SDana Myers AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 565db2bae30SDana Myers 566db2bae30SDana Myers return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 567db2bae30SDana Myers } 568db2bae30SDana Myers goto NextOperand; 569db2bae30SDana Myers 570db2bae30SDana Myers case ARGI_DATAOBJECT: 571db2bae30SDana Myers /* 572db2bae30SDana Myers * ARGI_DATAOBJECT is only used by the SizeOf operator. 573db2bae30SDana Myers * Need a buffer, string, package, or RefOf reference. 574db2bae30SDana Myers * 575db2bae30SDana Myers * The only reference allowed here is a direct reference to 576db2bae30SDana Myers * a namespace node. 577db2bae30SDana Myers */ 578aa2aa9a6SDana Myers switch (ObjDesc->Common.Type) 579db2bae30SDana Myers { 580db2bae30SDana Myers case ACPI_TYPE_PACKAGE: 581db2bae30SDana Myers case ACPI_TYPE_STRING: 582db2bae30SDana Myers case ACPI_TYPE_BUFFER: 583db2bae30SDana Myers case ACPI_TYPE_LOCAL_REFERENCE: 584db2bae30SDana Myers 585db2bae30SDana Myers /* Valid operand */ 586db2bae30SDana Myers break; 587db2bae30SDana Myers 588db2bae30SDana Myers default: 589*385cc6b4SJerry Jelinek 590db2bae30SDana Myers ACPI_ERROR ((AE_INFO, 591db2bae30SDana Myers "Needed [Buffer/String/Package/Reference], found [%s] %p", 592db2bae30SDana Myers AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 593db2bae30SDana Myers 594db2bae30SDana Myers return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 595db2bae30SDana Myers } 596db2bae30SDana Myers goto NextOperand; 597db2bae30SDana Myers 598db2bae30SDana Myers case ARGI_COMPLEXOBJ: 599db2bae30SDana Myers 600db2bae30SDana Myers /* Need a buffer or package or (ACPI 2.0) String */ 601db2bae30SDana Myers 602aa2aa9a6SDana Myers switch (ObjDesc->Common.Type) 603db2bae30SDana Myers { 604db2bae30SDana Myers case ACPI_TYPE_PACKAGE: 605db2bae30SDana Myers case ACPI_TYPE_STRING: 606db2bae30SDana Myers case ACPI_TYPE_BUFFER: 607db2bae30SDana Myers 608db2bae30SDana Myers /* Valid operand */ 609db2bae30SDana Myers break; 610db2bae30SDana Myers 611db2bae30SDana Myers default: 612*385cc6b4SJerry Jelinek 613db2bae30SDana Myers ACPI_ERROR ((AE_INFO, 614db2bae30SDana Myers "Needed [Buffer/String/Package], found [%s] %p", 615db2bae30SDana Myers AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 616db2bae30SDana Myers 617db2bae30SDana Myers return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 618db2bae30SDana Myers } 619db2bae30SDana Myers goto NextOperand; 620db2bae30SDana Myers 621db2bae30SDana Myers case ARGI_REGION_OR_BUFFER: /* Used by Load() only */ 622db2bae30SDana Myers 623*385cc6b4SJerry Jelinek /* 624*385cc6b4SJerry Jelinek * Need an operand of type REGION or a BUFFER 625*385cc6b4SJerry Jelinek * (which could be a resolved region field) 626*385cc6b4SJerry Jelinek */ 627aa2aa9a6SDana Myers switch (ObjDesc->Common.Type) 628db2bae30SDana Myers { 629db2bae30SDana Myers case ACPI_TYPE_BUFFER: 630db2bae30SDana Myers case ACPI_TYPE_REGION: 631db2bae30SDana Myers 632db2bae30SDana Myers /* Valid operand */ 633db2bae30SDana Myers break; 634db2bae30SDana Myers 635db2bae30SDana Myers default: 636*385cc6b4SJerry Jelinek 637db2bae30SDana Myers ACPI_ERROR ((AE_INFO, 638db2bae30SDana Myers "Needed [Region/Buffer], found [%s] %p", 639db2bae30SDana Myers AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 640db2bae30SDana Myers 641db2bae30SDana Myers return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 642db2bae30SDana Myers } 643db2bae30SDana Myers goto NextOperand; 644db2bae30SDana Myers 645db2bae30SDana Myers case ARGI_DATAREFOBJ: 646db2bae30SDana Myers 647db2bae30SDana Myers /* Used by the Store() operator only */ 648db2bae30SDana Myers 649aa2aa9a6SDana Myers switch (ObjDesc->Common.Type) 650db2bae30SDana Myers { 651db2bae30SDana Myers case ACPI_TYPE_INTEGER: 652db2bae30SDana Myers case ACPI_TYPE_PACKAGE: 653db2bae30SDana Myers case ACPI_TYPE_STRING: 654db2bae30SDana Myers case ACPI_TYPE_BUFFER: 655db2bae30SDana Myers case ACPI_TYPE_BUFFER_FIELD: 656db2bae30SDana Myers case ACPI_TYPE_LOCAL_REFERENCE: 657db2bae30SDana Myers case ACPI_TYPE_LOCAL_REGION_FIELD: 658db2bae30SDana Myers case ACPI_TYPE_LOCAL_BANK_FIELD: 659db2bae30SDana Myers case ACPI_TYPE_LOCAL_INDEX_FIELD: 660db2bae30SDana Myers case ACPI_TYPE_DDB_HANDLE: 661db2bae30SDana Myers 662db2bae30SDana Myers /* Valid operand */ 663db2bae30SDana Myers break; 664db2bae30SDana Myers 665db2bae30SDana Myers default: 666db2bae30SDana Myers 667db2bae30SDana Myers if (AcpiGbl_EnableInterpreterSlack) 668db2bae30SDana Myers { 669db2bae30SDana Myers /* 670*385cc6b4SJerry Jelinek * Enable original behavior of Store(), allowing any 671*385cc6b4SJerry Jelinek * and all objects as the source operand. The ACPI 672*385cc6b4SJerry Jelinek * spec does not allow this, however. 673db2bae30SDana Myers */ 674db2bae30SDana Myers break; 675db2bae30SDana Myers } 676db2bae30SDana Myers 677db2bae30SDana Myers if (TargetOp == AML_DEBUG_OP) 678db2bae30SDana Myers { 679db2bae30SDana Myers /* Allow store of any object to the Debug object */ 680db2bae30SDana Myers 681db2bae30SDana Myers break; 682db2bae30SDana Myers } 683db2bae30SDana Myers 684db2bae30SDana Myers ACPI_ERROR ((AE_INFO, 685*385cc6b4SJerry Jelinek "Needed Integer/Buffer/String/Package/Ref/Ddb]" 686*385cc6b4SJerry Jelinek ", found [%s] %p", 687db2bae30SDana Myers AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); 688db2bae30SDana Myers 689db2bae30SDana Myers return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 690db2bae30SDana Myers } 691db2bae30SDana Myers goto NextOperand; 692db2bae30SDana Myers 693db2bae30SDana Myers default: 694db2bae30SDana Myers 695db2bae30SDana Myers /* Unknown type */ 696db2bae30SDana Myers 697db2bae30SDana Myers ACPI_ERROR ((AE_INFO, 69826f3cdf0SGordon Ross "Internal - Unknown ARGI (required operand) type 0x%X", 699db2bae30SDana Myers ThisArgType)); 700db2bae30SDana Myers 701db2bae30SDana Myers return_ACPI_STATUS (AE_BAD_PARAMETER); 702db2bae30SDana Myers } 703db2bae30SDana Myers 704db2bae30SDana Myers /* 705db2bae30SDana Myers * Make sure that the original object was resolved to the 706db2bae30SDana Myers * required object type (Simple cases only). 707db2bae30SDana Myers */ 708*385cc6b4SJerry Jelinek Status = AcpiExCheckObjectType ( 709*385cc6b4SJerry Jelinek TypeNeeded, (*StackPtr)->Common.Type, *StackPtr); 710db2bae30SDana Myers if (ACPI_FAILURE (Status)) 711db2bae30SDana Myers { 712db2bae30SDana Myers return_ACPI_STATUS (Status); 713db2bae30SDana Myers } 714db2bae30SDana Myers 715db2bae30SDana Myers NextOperand: 716db2bae30SDana Myers /* 717db2bae30SDana Myers * If more operands needed, decrement StackPtr to point 718db2bae30SDana Myers * to next operand on stack 719db2bae30SDana Myers */ 720db2bae30SDana Myers if (GET_CURRENT_ARG_TYPE (ArgTypes)) 721db2bae30SDana Myers { 722db2bae30SDana Myers StackPtr--; 723db2bae30SDana Myers } 724db2bae30SDana Myers } 725db2bae30SDana Myers 726db2bae30SDana Myers ACPI_DUMP_OPERANDS (WalkState->Operands, 727db2bae30SDana Myers AcpiPsGetOpcodeName (Opcode), WalkState->NumOperands); 728db2bae30SDana Myers 729db2bae30SDana Myers return_ACPI_STATUS (Status); 730db2bae30SDana Myers } 731