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