blob: 804faebf825c5d9a9207c0573f33b8e564a5fc94 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001
2/******************************************************************************
3 *
4 * Module Name: exresop - AML Interpreter operand/object resolution
5 *
6 *****************************************************************************/
7
8/*
Bob Moore4a90c7e2006-01-13 16:22:00 -05009 * Copyright (C) 2000 - 2006, R. Byron Moore
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <acpi/acpi.h>
46#include <acpi/amlcode.h>
47#include <acpi/acparser.h>
48#include <acpi/acinterp.h>
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050#define _COMPONENT ACPI_EXECUTER
Len Brown4be44fc2005-08-05 00:44:28 -040051ACPI_MODULE_NAME("exresop")
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Robert Moore44f6c012005-04-18 22:49:35 -040053/* Local prototypes */
Robert Moore44f6c012005-04-18 22:49:35 -040054static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040055acpi_ex_check_object_type(acpi_object_type type_needed,
56 acpi_object_type this_type, void *object);
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58/*******************************************************************************
59 *
60 * FUNCTION: acpi_ex_check_object_type
61 *
62 * PARAMETERS: type_needed Object type needed
63 * this_type Actual object type
64 * Object Object pointer
65 *
66 * RETURN: Status
67 *
68 * DESCRIPTION: Check required type against actual type
69 *
70 ******************************************************************************/
71
Robert Moore44f6c012005-04-18 22:49:35 -040072static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040073acpi_ex_check_object_type(acpi_object_type type_needed,
74 acpi_object_type this_type, void *object)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075{
Bob Moore4a90c7e2006-01-13 16:22:00 -050076 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
78 if (type_needed == ACPI_TYPE_ANY) {
79 /* All types OK, so we don't perform any typechecks */
80
81 return (AE_OK);
82 }
83
84 if (type_needed == ACPI_TYPE_LOCAL_REFERENCE) {
85 /*
86 * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference
87 * objects and thus allow them to be targets. (As per the ACPI
88 * specification, a store to a constant is a noop.)
89 */
90 if ((this_type == ACPI_TYPE_INTEGER) &&
Len Brown4be44fc2005-08-05 00:44:28 -040091 (((union acpi_operand_object *)object)->common.
92 flags & AOPOBJ_AML_CONSTANT)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 return (AE_OK);
94 }
95 }
96
97 if (type_needed != this_type) {
Bob Moore4a90c7e2006-01-13 16:22:00 -050098 ACPI_REPORT_ERROR(("Needed type [%s], found [%s] %p\n",
99 acpi_ut_get_type_name(type_needed),
100 acpi_ut_get_type_name(this_type), object));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101
102 return (AE_AML_OPERAND_TYPE);
103 }
104
105 return (AE_OK);
106}
107
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108/*******************************************************************************
109 *
110 * FUNCTION: acpi_ex_resolve_operands
111 *
112 * PARAMETERS: Opcode - Opcode being interpreted
113 * stack_ptr - Pointer to the operand stack to be
114 * resolved
115 * walk_state - Current state
116 *
117 * RETURN: Status
118 *
119 * DESCRIPTION: Convert multiple input operands to the types required by the
120 * target operator.
121 *
122 * Each 5-bit group in arg_types represents one required
123 * operand and indicates the required Type. The corresponding operand
124 * will be converted to the required type if possible, otherwise we
125 * abort with an exception.
126 *
127 ******************************************************************************/
128
129acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400130acpi_ex_resolve_operands(u16 opcode,
131 union acpi_operand_object ** stack_ptr,
132 struct acpi_walk_state * walk_state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133{
Len Brown4be44fc2005-08-05 00:44:28 -0400134 union acpi_operand_object *obj_desc;
135 acpi_status status = AE_OK;
136 u8 object_type;
137 void *temp_node;
138 u32 arg_types;
139 const struct acpi_opcode_info *op_info;
140 u32 this_arg_type;
141 acpi_object_type type_needed;
142 u16 target_op = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
Len Brown4be44fc2005-08-05 00:44:28 -0400144 ACPI_FUNCTION_TRACE_U32("ex_resolve_operands", opcode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
Len Brown4be44fc2005-08-05 00:44:28 -0400146 op_info = acpi_ps_get_opcode_info(opcode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 if (op_info->class == AML_CLASS_UNKNOWN) {
Len Brown4be44fc2005-08-05 00:44:28 -0400148 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 }
150
151 arg_types = op_info->runtime_args;
152 if (arg_types == ARGI_INVALID_OPCODE) {
Bob Moore4a90c7e2006-01-13 16:22:00 -0500153 ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", opcode));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
Len Brown4be44fc2005-08-05 00:44:28 -0400155 return_ACPI_STATUS(AE_AML_INTERNAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 }
157
Len Brown4be44fc2005-08-05 00:44:28 -0400158 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
Bob Moore50eca3e2005-09-30 19:03:00 -0400159 "Opcode %X [%s] required_operand_types=%8.8X\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400160 opcode, op_info->name, arg_types));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
162 /*
163 * Normal exit is with (arg_types == 0) at end of argument list.
164 * Function will return an exception from within the loop upon
165 * finding an entry which is not (or cannot be converted
166 * to) the required type; if stack underflows; or upon
167 * finding a NULL stack entry (which should not happen).
168 */
Len Brown4be44fc2005-08-05 00:44:28 -0400169 while (GET_CURRENT_ARG_TYPE(arg_types)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 if (!stack_ptr || !*stack_ptr) {
Bob Moore4a90c7e2006-01-13 16:22:00 -0500171 ACPI_REPORT_ERROR(("Null stack entry at %p\n",
172 stack_ptr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
Len Brown4be44fc2005-08-05 00:44:28 -0400174 return_ACPI_STATUS(AE_AML_INTERNAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 }
176
177 /* Extract useful items */
178
179 obj_desc = *stack_ptr;
180
181 /* Decode the descriptor type */
182
Len Brown4be44fc2005-08-05 00:44:28 -0400183 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 case ACPI_DESC_TYPE_NAMED:
185
Robert Moore44f6c012005-04-18 22:49:35 -0400186 /* Namespace Node */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187
Len Brown4be44fc2005-08-05 00:44:28 -0400188 object_type =
189 ((struct acpi_namespace_node *)obj_desc)->type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 break;
191
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 case ACPI_DESC_TYPE_OPERAND:
193
194 /* ACPI internal object */
195
Len Brown4be44fc2005-08-05 00:44:28 -0400196 object_type = ACPI_GET_OBJECT_TYPE(obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197
198 /* Check for bad acpi_object_type */
199
Len Brown4be44fc2005-08-05 00:44:28 -0400200 if (!acpi_ut_valid_object_type(object_type)) {
Bob Moore4a90c7e2006-01-13 16:22:00 -0500201 ACPI_REPORT_ERROR(("Bad operand object type [%X]\n", object_type));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
Len Brown4be44fc2005-08-05 00:44:28 -0400203 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 }
205
206 if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) {
Robert Moore44f6c012005-04-18 22:49:35 -0400207 /* Decode the Reference */
208
Len Brown4be44fc2005-08-05 00:44:28 -0400209 op_info = acpi_ps_get_opcode_info(opcode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 if (op_info->class == AML_CLASS_UNKNOWN) {
Len Brown4be44fc2005-08-05 00:44:28 -0400211 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 }
213
214 switch (obj_desc->reference.opcode) {
215 case AML_DEBUG_OP:
Robert Moore44f6c012005-04-18 22:49:35 -0400216 target_op = AML_DEBUG_OP;
217
218 /*lint -fallthrough */
219
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 case AML_NAME_OP:
221 case AML_INDEX_OP:
222 case AML_REF_OF_OP:
223 case AML_ARG_OP:
224 case AML_LOCAL_OP:
Len Brown4be44fc2005-08-05 00:44:28 -0400225 case AML_LOAD_OP: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */
226 case AML_INT_NAMEPATH_OP: /* Reference to a named object */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227
Len Brown4be44fc2005-08-05 00:44:28 -0400228 ACPI_DEBUG_ONLY_MEMBERS(ACPI_DEBUG_PRINT
229 ((ACPI_DB_EXEC,
230 "Operand is a Reference, ref_opcode [%s]\n",
231 (acpi_ps_get_opcode_info
232 (obj_desc->
233 reference.
234 opcode))->
235 name)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 break;
237
238 default:
Bob Moore4a90c7e2006-01-13 16:22:00 -0500239 ACPI_REPORT_ERROR(("Operand is a Reference, Unknown Reference Opcode: %X\n", obj_desc->reference.opcode));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240
Len Brown4be44fc2005-08-05 00:44:28 -0400241 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 }
243 }
244 break;
245
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 default:
247
248 /* Invalid descriptor */
249
Bob Moore4a90c7e2006-01-13 16:22:00 -0500250 ACPI_REPORT_ERROR(("Invalid descriptor %p [%s]\n",
251 obj_desc,
252 acpi_ut_get_descriptor_name
253 (obj_desc)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254
Len Brown4be44fc2005-08-05 00:44:28 -0400255 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 }
257
Robert Moore44f6c012005-04-18 22:49:35 -0400258 /* Get one argument type, point to the next */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
Len Brown4be44fc2005-08-05 00:44:28 -0400260 this_arg_type = GET_CURRENT_ARG_TYPE(arg_types);
261 INCREMENT_ARG_LIST(arg_types);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262
263 /*
264 * Handle cases where the object does not need to be
265 * resolved to a value
266 */
267 switch (this_arg_type) {
Len Brown4be44fc2005-08-05 00:44:28 -0400268 case ARGI_REF_OR_STRING: /* Can be a String or Reference */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269
Len Brown4be44fc2005-08-05 00:44:28 -0400270 if ((ACPI_GET_DESCRIPTOR_TYPE(obj_desc) ==
271 ACPI_DESC_TYPE_OPERAND)
272 && (ACPI_GET_OBJECT_TYPE(obj_desc) ==
273 ACPI_TYPE_STRING)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 /*
Robert Moore44f6c012005-04-18 22:49:35 -0400275 * String found - the string references a named object and
276 * must be resolved to a node
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 */
278 goto next_operand;
279 }
280
Robert Moore44f6c012005-04-18 22:49:35 -0400281 /*
282 * Else not a string - fall through to the normal Reference
283 * case below
284 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 /*lint -fallthrough */
286
Len Brown4be44fc2005-08-05 00:44:28 -0400287 case ARGI_REFERENCE: /* References: */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 case ARGI_INTEGER_REF:
289 case ARGI_OBJECT_REF:
290 case ARGI_DEVICE_REF:
Len Brown4be44fc2005-08-05 00:44:28 -0400291 case ARGI_TARGETREF: /* Allows implicit conversion rules before store */
292 case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */
293 case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294
Robert Moore44f6c012005-04-18 22:49:35 -0400295 /*
296 * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE
297 * A Namespace Node is OK as-is
298 */
Len Brown4be44fc2005-08-05 00:44:28 -0400299 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) ==
300 ACPI_DESC_TYPE_NAMED) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 goto next_operand;
302 }
303
Len Brown4be44fc2005-08-05 00:44:28 -0400304 status =
305 acpi_ex_check_object_type(ACPI_TYPE_LOCAL_REFERENCE,
306 object_type, obj_desc);
307 if (ACPI_FAILURE(status)) {
308 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 }
310
Robert Moore44f6c012005-04-18 22:49:35 -0400311 if (obj_desc->reference.opcode == AML_NAME_OP) {
312 /* Convert a named reference to the actual named object */
313
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 temp_node = obj_desc->reference.object;
Len Brown4be44fc2005-08-05 00:44:28 -0400315 acpi_ut_remove_reference(obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 (*stack_ptr) = temp_node;
317 }
318 goto next_operand;
319
Len Brown4be44fc2005-08-05 00:44:28 -0400320 case ARGI_DATAREFOBJ: /* Store operator only */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321
322 /*
323 * We don't want to resolve index_op reference objects during
324 * a store because this would be an implicit de_ref_of operation.
325 * Instead, we just want to store the reference object.
326 * -- All others must be resolved below.
327 */
328 if ((opcode == AML_STORE_OP) &&
Len Brown4be44fc2005-08-05 00:44:28 -0400329 (ACPI_GET_OBJECT_TYPE(*stack_ptr) ==
330 ACPI_TYPE_LOCAL_REFERENCE)
331 && ((*stack_ptr)->reference.opcode ==
332 AML_INDEX_OP)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 goto next_operand;
334 }
335 break;
336
337 default:
338 /* All cases covered above */
339 break;
340 }
341
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 /*
343 * Resolve this object to a value
344 */
Len Brown4be44fc2005-08-05 00:44:28 -0400345 status = acpi_ex_resolve_to_value(stack_ptr, walk_state);
346 if (ACPI_FAILURE(status)) {
347 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 }
349
350 /* Get the resolved object */
351
352 obj_desc = *stack_ptr;
353
354 /*
355 * Check the resulting object (value) type
356 */
357 switch (this_arg_type) {
Len Brown4be44fc2005-08-05 00:44:28 -0400358 /*
359 * For the simple cases, only one type of resolved object
360 * is allowed
361 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 case ARGI_MUTEX:
363
364 /* Need an operand of type ACPI_TYPE_MUTEX */
365
366 type_needed = ACPI_TYPE_MUTEX;
367 break;
368
369 case ARGI_EVENT:
370
371 /* Need an operand of type ACPI_TYPE_EVENT */
372
373 type_needed = ACPI_TYPE_EVENT;
374 break;
375
Len Brown4be44fc2005-08-05 00:44:28 -0400376 case ARGI_PACKAGE: /* Package */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377
378 /* Need an operand of type ACPI_TYPE_PACKAGE */
379
380 type_needed = ACPI_TYPE_PACKAGE;
381 break;
382
383 case ARGI_ANYTYPE:
384
385 /* Any operand type will do */
386
387 type_needed = ACPI_TYPE_ANY;
388 break;
389
390 case ARGI_DDBHANDLE:
391
392 /* Need an operand of type ACPI_TYPE_DDB_HANDLE */
393
394 type_needed = ACPI_TYPE_LOCAL_REFERENCE;
395 break;
396
Len Brown4be44fc2005-08-05 00:44:28 -0400397 /*
398 * The more complex cases allow multiple resolved object types
399 */
Robert Moore44f6c012005-04-18 22:49:35 -0400400 case ARGI_INTEGER:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401
402 /*
403 * Need an operand of type ACPI_TYPE_INTEGER,
404 * But we can implicitly convert from a STRING or BUFFER
405 * Aka - "Implicit Source Operand Conversion"
406 */
Len Brown4be44fc2005-08-05 00:44:28 -0400407 status =
408 acpi_ex_convert_to_integer(obj_desc, stack_ptr, 16);
409 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 if (status == AE_TYPE) {
Bob Moore4a90c7e2006-01-13 16:22:00 -0500411 ACPI_REPORT_ERROR(("Needed [Integer/String/Buffer], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412
Len Brown4be44fc2005-08-05 00:44:28 -0400413 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 }
415
Len Brown4be44fc2005-08-05 00:44:28 -0400416 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417 }
Robert Mooref9f46012005-07-08 00:00:00 -0400418
419 if (obj_desc != *stack_ptr) {
Len Brown4be44fc2005-08-05 00:44:28 -0400420 acpi_ut_remove_reference(obj_desc);
Robert Mooref9f46012005-07-08 00:00:00 -0400421 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 goto next_operand;
423
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 case ARGI_BUFFER:
425
426 /*
427 * Need an operand of type ACPI_TYPE_BUFFER,
428 * But we can implicitly convert from a STRING or INTEGER
429 * Aka - "Implicit Source Operand Conversion"
430 */
Len Brown4be44fc2005-08-05 00:44:28 -0400431 status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr);
432 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 if (status == AE_TYPE) {
Bob Moore4a90c7e2006-01-13 16:22:00 -0500434 ACPI_REPORT_ERROR(("Needed [Integer/String/Buffer], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435
Len Brown4be44fc2005-08-05 00:44:28 -0400436 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 }
438
Len Brown4be44fc2005-08-05 00:44:28 -0400439 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 }
Robert Mooref9f46012005-07-08 00:00:00 -0400441
442 if (obj_desc != *stack_ptr) {
Len Brown4be44fc2005-08-05 00:44:28 -0400443 acpi_ut_remove_reference(obj_desc);
Robert Mooref9f46012005-07-08 00:00:00 -0400444 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 goto next_operand;
446
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 case ARGI_STRING:
448
449 /*
450 * Need an operand of type ACPI_TYPE_STRING,
451 * But we can implicitly convert from a BUFFER or INTEGER
452 * Aka - "Implicit Source Operand Conversion"
453 */
Len Brown4be44fc2005-08-05 00:44:28 -0400454 status = acpi_ex_convert_to_string(obj_desc, stack_ptr,
455 ACPI_IMPLICIT_CONVERT_HEX);
456 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 if (status == AE_TYPE) {
Bob Moore4a90c7e2006-01-13 16:22:00 -0500458 ACPI_REPORT_ERROR(("Needed [Integer/String/Buffer], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459
Len Brown4be44fc2005-08-05 00:44:28 -0400460 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 }
462
Len Brown4be44fc2005-08-05 00:44:28 -0400463 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 }
Robert Mooref9f46012005-07-08 00:00:00 -0400465
466 if (obj_desc != *stack_ptr) {
Len Brown4be44fc2005-08-05 00:44:28 -0400467 acpi_ut_remove_reference(obj_desc);
Robert Mooref9f46012005-07-08 00:00:00 -0400468 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 goto next_operand;
470
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 case ARGI_COMPUTEDATA:
472
473 /* Need an operand of type INTEGER, STRING or BUFFER */
474
Len Brown4be44fc2005-08-05 00:44:28 -0400475 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 case ACPI_TYPE_INTEGER:
477 case ACPI_TYPE_STRING:
478 case ACPI_TYPE_BUFFER:
479
480 /* Valid operand */
Len Brown4be44fc2005-08-05 00:44:28 -0400481 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482
483 default:
Bob Moore4a90c7e2006-01-13 16:22:00 -0500484 ACPI_REPORT_ERROR(("Needed [Integer/String/Buffer], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485
Len Brown4be44fc2005-08-05 00:44:28 -0400486 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 }
488 goto next_operand;
489
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 case ARGI_BUFFER_OR_STRING:
491
492 /* Need an operand of type STRING or BUFFER */
493
Len Brown4be44fc2005-08-05 00:44:28 -0400494 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 case ACPI_TYPE_STRING:
496 case ACPI_TYPE_BUFFER:
497
498 /* Valid operand */
Len Brown4be44fc2005-08-05 00:44:28 -0400499 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500
501 case ACPI_TYPE_INTEGER:
502
503 /* Highest priority conversion is to type Buffer */
504
Len Brown4be44fc2005-08-05 00:44:28 -0400505 status =
506 acpi_ex_convert_to_buffer(obj_desc,
507 stack_ptr);
508 if (ACPI_FAILURE(status)) {
509 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 }
Robert Mooref9f46012005-07-08 00:00:00 -0400511
512 if (obj_desc != *stack_ptr) {
Len Brown4be44fc2005-08-05 00:44:28 -0400513 acpi_ut_remove_reference(obj_desc);
Robert Mooref9f46012005-07-08 00:00:00 -0400514 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 break;
516
517 default:
Bob Moore4a90c7e2006-01-13 16:22:00 -0500518 ACPI_REPORT_ERROR(("Needed [Integer/String/Buffer], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519
Len Brown4be44fc2005-08-05 00:44:28 -0400520 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 }
522 goto next_operand;
523
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 case ARGI_DATAOBJECT:
525 /*
526 * ARGI_DATAOBJECT is only used by the size_of operator.
527 * Need a buffer, string, package, or ref_of reference.
528 *
529 * The only reference allowed here is a direct reference to
530 * a namespace node.
531 */
Len Brown4be44fc2005-08-05 00:44:28 -0400532 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 case ACPI_TYPE_PACKAGE:
534 case ACPI_TYPE_STRING:
535 case ACPI_TYPE_BUFFER:
536 case ACPI_TYPE_LOCAL_REFERENCE:
537
538 /* Valid operand */
539 break;
540
541 default:
Bob Moore4a90c7e2006-01-13 16:22:00 -0500542 ACPI_REPORT_ERROR(("Needed [Buffer/String/Package/Reference], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543
Len Brown4be44fc2005-08-05 00:44:28 -0400544 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 }
546 goto next_operand;
547
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 case ARGI_COMPLEXOBJ:
549
550 /* Need a buffer or package or (ACPI 2.0) String */
551
Len Brown4be44fc2005-08-05 00:44:28 -0400552 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 case ACPI_TYPE_PACKAGE:
554 case ACPI_TYPE_STRING:
555 case ACPI_TYPE_BUFFER:
556
557 /* Valid operand */
558 break;
559
560 default:
Bob Moore4a90c7e2006-01-13 16:22:00 -0500561 ACPI_REPORT_ERROR(("Needed [Buffer/String/Package], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562
Len Brown4be44fc2005-08-05 00:44:28 -0400563 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 }
565 goto next_operand;
566
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 case ARGI_REGION_OR_FIELD:
568
Robert Moore44f6c012005-04-18 22:49:35 -0400569 /* Need an operand of type REGION or a FIELD in a region */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570
Len Brown4be44fc2005-08-05 00:44:28 -0400571 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 case ACPI_TYPE_REGION:
573 case ACPI_TYPE_LOCAL_REGION_FIELD:
574 case ACPI_TYPE_LOCAL_BANK_FIELD:
575 case ACPI_TYPE_LOCAL_INDEX_FIELD:
576
577 /* Valid operand */
578 break;
579
580 default:
Bob Moore4a90c7e2006-01-13 16:22:00 -0500581 ACPI_REPORT_ERROR(("Needed [Region/region_field], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582
Len Brown4be44fc2005-08-05 00:44:28 -0400583 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 }
585 goto next_operand;
586
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 case ARGI_DATAREFOBJ:
588
589 /* Used by the Store() operator only */
590
Len Brown4be44fc2005-08-05 00:44:28 -0400591 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 case ACPI_TYPE_INTEGER:
593 case ACPI_TYPE_PACKAGE:
594 case ACPI_TYPE_STRING:
595 case ACPI_TYPE_BUFFER:
596 case ACPI_TYPE_BUFFER_FIELD:
597 case ACPI_TYPE_LOCAL_REFERENCE:
598 case ACPI_TYPE_LOCAL_REGION_FIELD:
599 case ACPI_TYPE_LOCAL_BANK_FIELD:
600 case ACPI_TYPE_LOCAL_INDEX_FIELD:
601 case ACPI_TYPE_DDB_HANDLE:
602
603 /* Valid operand */
604 break;
605
606 default:
607
608 if (acpi_gbl_enable_interpreter_slack) {
609 /*
610 * Enable original behavior of Store(), allowing any and all
611 * objects as the source operand. The ACPI spec does not
612 * allow this, however.
613 */
614 break;
615 }
616
Robert Moore44f6c012005-04-18 22:49:35 -0400617 if (target_op == AML_DEBUG_OP) {
618 /* Allow store of any object to the Debug object */
619
620 break;
621 }
622
Bob Moore4a90c7e2006-01-13 16:22:00 -0500623 ACPI_REPORT_ERROR(("Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624
Len Brown4be44fc2005-08-05 00:44:28 -0400625 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 }
627 goto next_operand;
628
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 default:
630
631 /* Unknown type */
632
Bob Moore4a90c7e2006-01-13 16:22:00 -0500633 ACPI_REPORT_ERROR(("Internal - Unknown ARGI (required operand) type %X\n", this_arg_type));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634
Len Brown4be44fc2005-08-05 00:44:28 -0400635 return_ACPI_STATUS(AE_BAD_PARAMETER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 }
637
638 /*
639 * Make sure that the original object was resolved to the
640 * required object type (Simple cases only).
641 */
Len Brown4be44fc2005-08-05 00:44:28 -0400642 status = acpi_ex_check_object_type(type_needed,
643 ACPI_GET_OBJECT_TYPE
644 (*stack_ptr), *stack_ptr);
645 if (ACPI_FAILURE(status)) {
646 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 }
648
Len Brown4be44fc2005-08-05 00:44:28 -0400649 next_operand:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 /*
651 * If more operands needed, decrement stack_ptr to point
652 * to next operand on stack
653 */
Len Brown4be44fc2005-08-05 00:44:28 -0400654 if (GET_CURRENT_ARG_TYPE(arg_types)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 stack_ptr--;
656 }
Robert Moore44f6c012005-04-18 22:49:35 -0400657 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658
Len Brown4be44fc2005-08-05 00:44:28 -0400659 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660}