blob: a1c000f5a4157799744c9723fccb0906c65527e4 [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>
Bob Mooreb8e4d892006-01-27 16:43:00 -050049#include <acpi/acnamesp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#define _COMPONENT ACPI_EXECUTER
Len Brown4be44fc2005-08-05 00:44:28 -040052ACPI_MODULE_NAME("exresop")
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Robert Moore44f6c012005-04-18 22:49:35 -040054/* Local prototypes */
Robert Moore44f6c012005-04-18 22:49:35 -040055static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040056acpi_ex_check_object_type(acpi_object_type type_needed,
57 acpi_object_type this_type, void *object);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59/*******************************************************************************
60 *
61 * FUNCTION: acpi_ex_check_object_type
62 *
63 * PARAMETERS: type_needed Object type needed
64 * this_type Actual object type
65 * Object Object pointer
66 *
67 * RETURN: Status
68 *
69 * DESCRIPTION: Check required type against actual type
70 *
71 ******************************************************************************/
72
Robert Moore44f6c012005-04-18 22:49:35 -040073static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040074acpi_ex_check_object_type(acpi_object_type type_needed,
75 acpi_object_type this_type, void *object)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076{
Bob Moore4a90c7e2006-01-13 16:22:00 -050077 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79 if (type_needed == ACPI_TYPE_ANY) {
80 /* All types OK, so we don't perform any typechecks */
81
82 return (AE_OK);
83 }
84
85 if (type_needed == ACPI_TYPE_LOCAL_REFERENCE) {
86 /*
87 * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference
88 * objects and thus allow them to be targets. (As per the ACPI
89 * specification, a store to a constant is a noop.)
90 */
91 if ((this_type == ACPI_TYPE_INTEGER) &&
Len Brown4be44fc2005-08-05 00:44:28 -040092 (((union acpi_operand_object *)object)->common.
93 flags & AOPOBJ_AML_CONSTANT)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 return (AE_OK);
95 }
96 }
97
98 if (type_needed != this_type) {
Bob Mooreb8e4d892006-01-27 16:43:00 -050099 ACPI_ERROR((AE_INFO,
100 "Needed type [%s], found [%s] %p",
101 acpi_ut_get_type_name(type_needed),
102 acpi_ut_get_type_name(this_type), object));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
104 return (AE_AML_OPERAND_TYPE);
105 }
106
107 return (AE_OK);
108}
109
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110/*******************************************************************************
111 *
112 * FUNCTION: acpi_ex_resolve_operands
113 *
114 * PARAMETERS: Opcode - Opcode being interpreted
115 * stack_ptr - Pointer to the operand stack to be
116 * resolved
117 * walk_state - Current state
118 *
119 * RETURN: Status
120 *
121 * DESCRIPTION: Convert multiple input operands to the types required by the
122 * target operator.
123 *
124 * Each 5-bit group in arg_types represents one required
125 * operand and indicates the required Type. The corresponding operand
126 * will be converted to the required type if possible, otherwise we
127 * abort with an exception.
128 *
129 ******************************************************************************/
130
131acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400132acpi_ex_resolve_operands(u16 opcode,
133 union acpi_operand_object ** stack_ptr,
134 struct acpi_walk_state * walk_state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135{
Len Brown4be44fc2005-08-05 00:44:28 -0400136 union acpi_operand_object *obj_desc;
137 acpi_status status = AE_OK;
138 u8 object_type;
139 void *temp_node;
140 u32 arg_types;
141 const struct acpi_opcode_info *op_info;
142 u32 this_arg_type;
143 acpi_object_type type_needed;
144 u16 target_op = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
Len Brown4be44fc2005-08-05 00:44:28 -0400146 ACPI_FUNCTION_TRACE_U32("ex_resolve_operands", opcode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
Len Brown4be44fc2005-08-05 00:44:28 -0400148 op_info = acpi_ps_get_opcode_info(opcode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 if (op_info->class == AML_CLASS_UNKNOWN) {
Len Brown4be44fc2005-08-05 00:44:28 -0400150 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 }
152
153 arg_types = op_info->runtime_args;
154 if (arg_types == ARGI_INVALID_OPCODE) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500155 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", opcode));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156
Len Brown4be44fc2005-08-05 00:44:28 -0400157 return_ACPI_STATUS(AE_AML_INTERNAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 }
159
Len Brown4be44fc2005-08-05 00:44:28 -0400160 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
Bob Moore50eca3e2005-09-30 19:03:00 -0400161 "Opcode %X [%s] required_operand_types=%8.8X\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400162 opcode, op_info->name, arg_types));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
164 /*
165 * Normal exit is with (arg_types == 0) at end of argument list.
166 * Function will return an exception from within the loop upon
167 * finding an entry which is not (or cannot be converted
168 * to) the required type; if stack underflows; or upon
169 * finding a NULL stack entry (which should not happen).
170 */
Len Brown4be44fc2005-08-05 00:44:28 -0400171 while (GET_CURRENT_ARG_TYPE(arg_types)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 if (!stack_ptr || !*stack_ptr) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500173 ACPI_ERROR((AE_INFO, "Null stack entry at %p",
174 stack_ptr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175
Len Brown4be44fc2005-08-05 00:44:28 -0400176 return_ACPI_STATUS(AE_AML_INTERNAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 }
178
179 /* Extract useful items */
180
181 obj_desc = *stack_ptr;
182
183 /* Decode the descriptor type */
184
Len Brown4be44fc2005-08-05 00:44:28 -0400185 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 case ACPI_DESC_TYPE_NAMED:
187
Robert Moore44f6c012005-04-18 22:49:35 -0400188 /* Namespace Node */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189
Len Brown4be44fc2005-08-05 00:44:28 -0400190 object_type =
191 ((struct acpi_namespace_node *)obj_desc)->type;
Bob Mooreb8e4d892006-01-27 16:43:00 -0500192
193 /*
194 * Resolve an alias object. The construction of these objects
195 * guarantees that there is only one level of alias indirection;
196 * thus, the attached object is always the aliased namespace node
197 */
198 if (object_type == ACPI_TYPE_LOCAL_ALIAS) {
199 obj_desc =
200 acpi_ns_get_attached_object((struct
201 acpi_namespace_node
202 *)obj_desc);
203 *stack_ptr = obj_desc;
204 object_type =
205 ((struct acpi_namespace_node *)obj_desc)->
206 type;
207 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 break;
209
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 case ACPI_DESC_TYPE_OPERAND:
211
212 /* ACPI internal object */
213
Len Brown4be44fc2005-08-05 00:44:28 -0400214 object_type = ACPI_GET_OBJECT_TYPE(obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215
216 /* Check for bad acpi_object_type */
217
Len Brown4be44fc2005-08-05 00:44:28 -0400218 if (!acpi_ut_valid_object_type(object_type)) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500219 ACPI_ERROR((AE_INFO,
220 "Bad operand object type [%X]",
221 object_type));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
Len Brown4be44fc2005-08-05 00:44:28 -0400223 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 }
225
226 if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) {
Robert Moore44f6c012005-04-18 22:49:35 -0400227 /* Decode the Reference */
228
Len Brown4be44fc2005-08-05 00:44:28 -0400229 op_info = acpi_ps_get_opcode_info(opcode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 if (op_info->class == AML_CLASS_UNKNOWN) {
Len Brown4be44fc2005-08-05 00:44:28 -0400231 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 }
233
234 switch (obj_desc->reference.opcode) {
235 case AML_DEBUG_OP:
Robert Moore44f6c012005-04-18 22:49:35 -0400236 target_op = AML_DEBUG_OP;
237
238 /*lint -fallthrough */
239
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 case AML_NAME_OP:
241 case AML_INDEX_OP:
242 case AML_REF_OF_OP:
243 case AML_ARG_OP:
244 case AML_LOCAL_OP:
Len Brown4be44fc2005-08-05 00:44:28 -0400245 case AML_LOAD_OP: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */
246 case AML_INT_NAMEPATH_OP: /* Reference to a named object */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247
Len Brown4be44fc2005-08-05 00:44:28 -0400248 ACPI_DEBUG_ONLY_MEMBERS(ACPI_DEBUG_PRINT
249 ((ACPI_DB_EXEC,
250 "Operand is a Reference, ref_opcode [%s]\n",
251 (acpi_ps_get_opcode_info
252 (obj_desc->
253 reference.
254 opcode))->
255 name)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 break;
257
258 default:
Bob Mooreb8e4d892006-01-27 16:43:00 -0500259 ACPI_ERROR((AE_INFO,
260 "Operand is a Reference, Unknown Reference Opcode: %X",
261 obj_desc->reference.
262 opcode));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263
Len Brown4be44fc2005-08-05 00:44:28 -0400264 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 }
266 }
267 break;
268
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 default:
270
271 /* Invalid descriptor */
272
Bob Mooreb8e4d892006-01-27 16:43:00 -0500273 ACPI_ERROR((AE_INFO,
274 "Invalid descriptor %p [%s]",
275 obj_desc,
276 acpi_ut_get_descriptor_name(obj_desc)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Len Brown4be44fc2005-08-05 00:44:28 -0400278 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 }
280
Robert Moore44f6c012005-04-18 22:49:35 -0400281 /* Get one argument type, point to the next */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
Len Brown4be44fc2005-08-05 00:44:28 -0400283 this_arg_type = GET_CURRENT_ARG_TYPE(arg_types);
284 INCREMENT_ARG_LIST(arg_types);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
286 /*
287 * Handle cases where the object does not need to be
288 * resolved to a value
289 */
290 switch (this_arg_type) {
Len Brown4be44fc2005-08-05 00:44:28 -0400291 case ARGI_REF_OR_STRING: /* Can be a String or Reference */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
Len Brown4be44fc2005-08-05 00:44:28 -0400293 if ((ACPI_GET_DESCRIPTOR_TYPE(obj_desc) ==
294 ACPI_DESC_TYPE_OPERAND)
295 && (ACPI_GET_OBJECT_TYPE(obj_desc) ==
296 ACPI_TYPE_STRING)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 /*
Robert Moore44f6c012005-04-18 22:49:35 -0400298 * String found - the string references a named object and
299 * must be resolved to a node
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300 */
301 goto next_operand;
302 }
303
Robert Moore44f6c012005-04-18 22:49:35 -0400304 /*
305 * Else not a string - fall through to the normal Reference
306 * case below
307 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 /*lint -fallthrough */
309
Len Brown4be44fc2005-08-05 00:44:28 -0400310 case ARGI_REFERENCE: /* References: */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 case ARGI_INTEGER_REF:
312 case ARGI_OBJECT_REF:
313 case ARGI_DEVICE_REF:
Len Brown4be44fc2005-08-05 00:44:28 -0400314 case ARGI_TARGETREF: /* Allows implicit conversion rules before store */
315 case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */
316 case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317
Robert Moore44f6c012005-04-18 22:49:35 -0400318 /*
319 * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE
320 * A Namespace Node is OK as-is
321 */
Len Brown4be44fc2005-08-05 00:44:28 -0400322 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) ==
323 ACPI_DESC_TYPE_NAMED) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 goto next_operand;
325 }
326
Len Brown4be44fc2005-08-05 00:44:28 -0400327 status =
328 acpi_ex_check_object_type(ACPI_TYPE_LOCAL_REFERENCE,
329 object_type, obj_desc);
330 if (ACPI_FAILURE(status)) {
331 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 }
333
Robert Moore44f6c012005-04-18 22:49:35 -0400334 if (obj_desc->reference.opcode == AML_NAME_OP) {
335 /* Convert a named reference to the actual named object */
336
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 temp_node = obj_desc->reference.object;
Len Brown4be44fc2005-08-05 00:44:28 -0400338 acpi_ut_remove_reference(obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 (*stack_ptr) = temp_node;
340 }
341 goto next_operand;
342
Len Brown4be44fc2005-08-05 00:44:28 -0400343 case ARGI_DATAREFOBJ: /* Store operator only */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344
345 /*
346 * We don't want to resolve index_op reference objects during
347 * a store because this would be an implicit de_ref_of operation.
348 * Instead, we just want to store the reference object.
349 * -- All others must be resolved below.
350 */
351 if ((opcode == AML_STORE_OP) &&
Len Brown4be44fc2005-08-05 00:44:28 -0400352 (ACPI_GET_OBJECT_TYPE(*stack_ptr) ==
353 ACPI_TYPE_LOCAL_REFERENCE)
354 && ((*stack_ptr)->reference.opcode ==
355 AML_INDEX_OP)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 goto next_operand;
357 }
358 break;
359
360 default:
361 /* All cases covered above */
362 break;
363 }
364
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 /*
366 * Resolve this object to a value
367 */
Len Brown4be44fc2005-08-05 00:44:28 -0400368 status = acpi_ex_resolve_to_value(stack_ptr, walk_state);
369 if (ACPI_FAILURE(status)) {
370 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 }
372
373 /* Get the resolved object */
374
375 obj_desc = *stack_ptr;
376
377 /*
378 * Check the resulting object (value) type
379 */
380 switch (this_arg_type) {
Len Brown4be44fc2005-08-05 00:44:28 -0400381 /*
382 * For the simple cases, only one type of resolved object
383 * is allowed
384 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 case ARGI_MUTEX:
386
387 /* Need an operand of type ACPI_TYPE_MUTEX */
388
389 type_needed = ACPI_TYPE_MUTEX;
390 break;
391
392 case ARGI_EVENT:
393
394 /* Need an operand of type ACPI_TYPE_EVENT */
395
396 type_needed = ACPI_TYPE_EVENT;
397 break;
398
Len Brown4be44fc2005-08-05 00:44:28 -0400399 case ARGI_PACKAGE: /* Package */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400
401 /* Need an operand of type ACPI_TYPE_PACKAGE */
402
403 type_needed = ACPI_TYPE_PACKAGE;
404 break;
405
406 case ARGI_ANYTYPE:
407
408 /* Any operand type will do */
409
410 type_needed = ACPI_TYPE_ANY;
411 break;
412
413 case ARGI_DDBHANDLE:
414
415 /* Need an operand of type ACPI_TYPE_DDB_HANDLE */
416
417 type_needed = ACPI_TYPE_LOCAL_REFERENCE;
418 break;
419
Len Brown4be44fc2005-08-05 00:44:28 -0400420 /*
421 * The more complex cases allow multiple resolved object types
422 */
Robert Moore44f6c012005-04-18 22:49:35 -0400423 case ARGI_INTEGER:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424
425 /*
426 * Need an operand of type ACPI_TYPE_INTEGER,
427 * But we can implicitly convert from a STRING or BUFFER
428 * Aka - "Implicit Source Operand Conversion"
429 */
Len Brown4be44fc2005-08-05 00:44:28 -0400430 status =
431 acpi_ex_convert_to_integer(obj_desc, stack_ptr, 16);
432 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 if (status == AE_TYPE) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500434 ACPI_ERROR((AE_INFO,
435 "Needed [Integer/String/Buffer], found [%s] %p",
436 acpi_ut_get_object_type_name
437 (obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438
Len Brown4be44fc2005-08-05 00:44:28 -0400439 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 }
441
Len Brown4be44fc2005-08-05 00:44:28 -0400442 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 }
Robert Mooref9f46012005-07-08 00:00:00 -0400444
445 if (obj_desc != *stack_ptr) {
Len Brown4be44fc2005-08-05 00:44:28 -0400446 acpi_ut_remove_reference(obj_desc);
Robert Mooref9f46012005-07-08 00:00:00 -0400447 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 goto next_operand;
449
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 case ARGI_BUFFER:
451
452 /*
453 * Need an operand of type ACPI_TYPE_BUFFER,
454 * But we can implicitly convert from a STRING or INTEGER
455 * Aka - "Implicit Source Operand Conversion"
456 */
Len Brown4be44fc2005-08-05 00:44:28 -0400457 status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr);
458 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 if (status == AE_TYPE) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500460 ACPI_ERROR((AE_INFO,
461 "Needed [Integer/String/Buffer], found [%s] %p",
462 acpi_ut_get_object_type_name
463 (obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464
Len Brown4be44fc2005-08-05 00:44:28 -0400465 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 }
467
Len Brown4be44fc2005-08-05 00:44:28 -0400468 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 }
Robert Mooref9f46012005-07-08 00:00:00 -0400470
471 if (obj_desc != *stack_ptr) {
Len Brown4be44fc2005-08-05 00:44:28 -0400472 acpi_ut_remove_reference(obj_desc);
Robert Mooref9f46012005-07-08 00:00:00 -0400473 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 goto next_operand;
475
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 case ARGI_STRING:
477
478 /*
479 * Need an operand of type ACPI_TYPE_STRING,
480 * But we can implicitly convert from a BUFFER or INTEGER
481 * Aka - "Implicit Source Operand Conversion"
482 */
Len Brown4be44fc2005-08-05 00:44:28 -0400483 status = acpi_ex_convert_to_string(obj_desc, stack_ptr,
484 ACPI_IMPLICIT_CONVERT_HEX);
485 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 if (status == AE_TYPE) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500487 ACPI_ERROR((AE_INFO,
488 "Needed [Integer/String/Buffer], found [%s] %p",
489 acpi_ut_get_object_type_name
490 (obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491
Len Brown4be44fc2005-08-05 00:44:28 -0400492 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 }
494
Len Brown4be44fc2005-08-05 00:44:28 -0400495 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 }
Robert Mooref9f46012005-07-08 00:00:00 -0400497
498 if (obj_desc != *stack_ptr) {
Len Brown4be44fc2005-08-05 00:44:28 -0400499 acpi_ut_remove_reference(obj_desc);
Robert Mooref9f46012005-07-08 00:00:00 -0400500 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 goto next_operand;
502
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 case ARGI_COMPUTEDATA:
504
505 /* Need an operand of type INTEGER, STRING or BUFFER */
506
Len Brown4be44fc2005-08-05 00:44:28 -0400507 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508 case ACPI_TYPE_INTEGER:
509 case ACPI_TYPE_STRING:
510 case ACPI_TYPE_BUFFER:
511
512 /* Valid operand */
Len Brown4be44fc2005-08-05 00:44:28 -0400513 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514
515 default:
Bob Mooreb8e4d892006-01-27 16:43:00 -0500516 ACPI_ERROR((AE_INFO,
517 "Needed [Integer/String/Buffer], found [%s] %p",
518 acpi_ut_get_object_type_name
519 (obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520
Len Brown4be44fc2005-08-05 00:44:28 -0400521 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 }
523 goto next_operand;
524
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 case ARGI_BUFFER_OR_STRING:
526
527 /* Need an operand of type STRING or BUFFER */
528
Len Brown4be44fc2005-08-05 00:44:28 -0400529 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 case ACPI_TYPE_STRING:
531 case ACPI_TYPE_BUFFER:
532
533 /* Valid operand */
Len Brown4be44fc2005-08-05 00:44:28 -0400534 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535
536 case ACPI_TYPE_INTEGER:
537
538 /* Highest priority conversion is to type Buffer */
539
Len Brown4be44fc2005-08-05 00:44:28 -0400540 status =
541 acpi_ex_convert_to_buffer(obj_desc,
542 stack_ptr);
543 if (ACPI_FAILURE(status)) {
544 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 }
Robert Mooref9f46012005-07-08 00:00:00 -0400546
547 if (obj_desc != *stack_ptr) {
Len Brown4be44fc2005-08-05 00:44:28 -0400548 acpi_ut_remove_reference(obj_desc);
Robert Mooref9f46012005-07-08 00:00:00 -0400549 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 break;
551
552 default:
Bob Mooreb8e4d892006-01-27 16:43:00 -0500553 ACPI_ERROR((AE_INFO,
554 "Needed [Integer/String/Buffer], found [%s] %p",
555 acpi_ut_get_object_type_name
556 (obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557
Len Brown4be44fc2005-08-05 00:44:28 -0400558 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 }
560 goto next_operand;
561
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 case ARGI_DATAOBJECT:
563 /*
564 * ARGI_DATAOBJECT is only used by the size_of operator.
565 * Need a buffer, string, package, or ref_of reference.
566 *
567 * The only reference allowed here is a direct reference to
568 * a namespace node.
569 */
Len Brown4be44fc2005-08-05 00:44:28 -0400570 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 case ACPI_TYPE_PACKAGE:
572 case ACPI_TYPE_STRING:
573 case ACPI_TYPE_BUFFER:
574 case ACPI_TYPE_LOCAL_REFERENCE:
575
576 /* Valid operand */
577 break;
578
579 default:
Bob Mooreb8e4d892006-01-27 16:43:00 -0500580 ACPI_ERROR((AE_INFO,
581 "Needed [Buffer/String/Package/Reference], found [%s] %p",
582 acpi_ut_get_object_type_name
583 (obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584
Len Brown4be44fc2005-08-05 00:44:28 -0400585 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 }
587 goto next_operand;
588
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 case ARGI_COMPLEXOBJ:
590
591 /* Need a buffer or package or (ACPI 2.0) String */
592
Len Brown4be44fc2005-08-05 00:44:28 -0400593 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 case ACPI_TYPE_PACKAGE:
595 case ACPI_TYPE_STRING:
596 case ACPI_TYPE_BUFFER:
597
598 /* Valid operand */
599 break;
600
601 default:
Bob Mooreb8e4d892006-01-27 16:43:00 -0500602 ACPI_ERROR((AE_INFO,
603 "Needed [Buffer/String/Package], found [%s] %p",
604 acpi_ut_get_object_type_name
605 (obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606
Len Brown4be44fc2005-08-05 00:44:28 -0400607 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 }
609 goto next_operand;
610
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 case ARGI_REGION_OR_FIELD:
612
Robert Moore44f6c012005-04-18 22:49:35 -0400613 /* Need an operand of type REGION or a FIELD in a region */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614
Len Brown4be44fc2005-08-05 00:44:28 -0400615 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 case ACPI_TYPE_REGION:
617 case ACPI_TYPE_LOCAL_REGION_FIELD:
618 case ACPI_TYPE_LOCAL_BANK_FIELD:
619 case ACPI_TYPE_LOCAL_INDEX_FIELD:
620
621 /* Valid operand */
622 break;
623
624 default:
Bob Mooreb8e4d892006-01-27 16:43:00 -0500625 ACPI_ERROR((AE_INFO,
626 "Needed [Region/region_field], found [%s] %p",
627 acpi_ut_get_object_type_name
628 (obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629
Len Brown4be44fc2005-08-05 00:44:28 -0400630 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 }
632 goto next_operand;
633
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 case ARGI_DATAREFOBJ:
635
636 /* Used by the Store() operator only */
637
Len Brown4be44fc2005-08-05 00:44:28 -0400638 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 case ACPI_TYPE_INTEGER:
640 case ACPI_TYPE_PACKAGE:
641 case ACPI_TYPE_STRING:
642 case ACPI_TYPE_BUFFER:
643 case ACPI_TYPE_BUFFER_FIELD:
644 case ACPI_TYPE_LOCAL_REFERENCE:
645 case ACPI_TYPE_LOCAL_REGION_FIELD:
646 case ACPI_TYPE_LOCAL_BANK_FIELD:
647 case ACPI_TYPE_LOCAL_INDEX_FIELD:
648 case ACPI_TYPE_DDB_HANDLE:
649
650 /* Valid operand */
651 break;
652
653 default:
654
655 if (acpi_gbl_enable_interpreter_slack) {
656 /*
657 * Enable original behavior of Store(), allowing any and all
658 * objects as the source operand. The ACPI spec does not
659 * allow this, however.
660 */
661 break;
662 }
663
Robert Moore44f6c012005-04-18 22:49:35 -0400664 if (target_op == AML_DEBUG_OP) {
665 /* Allow store of any object to the Debug object */
666
667 break;
668 }
669
Bob Mooreb8e4d892006-01-27 16:43:00 -0500670 ACPI_ERROR((AE_INFO,
671 "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p",
672 acpi_ut_get_object_type_name
673 (obj_desc), obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674
Len Brown4be44fc2005-08-05 00:44:28 -0400675 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 }
677 goto next_operand;
678
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 default:
680
681 /* Unknown type */
682
Bob Mooreb8e4d892006-01-27 16:43:00 -0500683 ACPI_ERROR((AE_INFO,
684 "Internal - Unknown ARGI (required operand) type %X",
685 this_arg_type));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686
Len Brown4be44fc2005-08-05 00:44:28 -0400687 return_ACPI_STATUS(AE_BAD_PARAMETER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 }
689
690 /*
691 * Make sure that the original object was resolved to the
692 * required object type (Simple cases only).
693 */
Len Brown4be44fc2005-08-05 00:44:28 -0400694 status = acpi_ex_check_object_type(type_needed,
695 ACPI_GET_OBJECT_TYPE
696 (*stack_ptr), *stack_ptr);
697 if (ACPI_FAILURE(status)) {
698 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 }
700
Len Brown4be44fc2005-08-05 00:44:28 -0400701 next_operand:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 /*
703 * If more operands needed, decrement stack_ptr to point
704 * to next operand on stack
705 */
Len Brown4be44fc2005-08-05 00:44:28 -0400706 if (GET_CURRENT_ARG_TYPE(arg_types)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 stack_ptr--;
708 }
Robert Moore44f6c012005-04-18 22:49:35 -0400709 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710
Len Brown4be44fc2005-08-05 00:44:28 -0400711 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712}