Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | |
2 | /****************************************************************************** | |
3 | * | |
4 | * Module Name: exresop - AML Interpreter operand/object resolution | |
5 | * | |
6 | *****************************************************************************/ | |
7 | ||
8 | /* | |
77848130 | 9 | * Copyright (C) 2000 - 2012, Intel Corp. |
1da177e4 LT |
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 | ||
1da177e4 | 45 | #include <acpi/acpi.h> |
e2f7a777 LB |
46 | #include "accommon.h" |
47 | #include "amlcode.h" | |
48 | #include "acparser.h" | |
49 | #include "acinterp.h" | |
50 | #include "acnamesp.h" | |
1da177e4 | 51 | |
1da177e4 | 52 | #define _COMPONENT ACPI_EXECUTER |
4be44fcd | 53 | ACPI_MODULE_NAME("exresop") |
1da177e4 | 54 | |
44f6c012 | 55 | /* Local prototypes */ |
44f6c012 | 56 | static acpi_status |
4be44fcd LB |
57 | acpi_ex_check_object_type(acpi_object_type type_needed, |
58 | acpi_object_type this_type, void *object); | |
1da177e4 LT |
59 | |
60 | /******************************************************************************* | |
61 | * | |
62 | * FUNCTION: acpi_ex_check_object_type | |
63 | * | |
64 | * PARAMETERS: type_needed Object type needed | |
65 | * this_type Actual object type | |
66 | * Object Object pointer | |
67 | * | |
68 | * RETURN: Status | |
69 | * | |
70 | * DESCRIPTION: Check required type against actual type | |
71 | * | |
72 | ******************************************************************************/ | |
73 | ||
44f6c012 | 74 | static acpi_status |
4be44fcd LB |
75 | acpi_ex_check_object_type(acpi_object_type type_needed, |
76 | acpi_object_type this_type, void *object) | |
1da177e4 | 77 | { |
4a90c7e8 | 78 | ACPI_FUNCTION_ENTRY(); |
1da177e4 LT |
79 | |
80 | if (type_needed == ACPI_TYPE_ANY) { | |
52fc0b02 | 81 | |
1da177e4 LT |
82 | /* All types OK, so we don't perform any typechecks */ |
83 | ||
84 | return (AE_OK); | |
85 | } | |
86 | ||
87 | if (type_needed == ACPI_TYPE_LOCAL_REFERENCE) { | |
88 | /* | |
89 | * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference | |
90 | * objects and thus allow them to be targets. (As per the ACPI | |
91 | * specification, a store to a constant is a noop.) | |
92 | */ | |
93 | if ((this_type == ACPI_TYPE_INTEGER) && | |
4be44fcd LB |
94 | (((union acpi_operand_object *)object)->common. |
95 | flags & AOPOBJ_AML_CONSTANT)) { | |
1da177e4 LT |
96 | return (AE_OK); |
97 | } | |
98 | } | |
99 | ||
100 | if (type_needed != this_type) { | |
b8e4d893 BM |
101 | ACPI_ERROR((AE_INFO, |
102 | "Needed type [%s], found [%s] %p", | |
103 | acpi_ut_get_type_name(type_needed), | |
104 | acpi_ut_get_type_name(this_type), object)); | |
1da177e4 LT |
105 | |
106 | return (AE_AML_OPERAND_TYPE); | |
107 | } | |
108 | ||
109 | return (AE_OK); | |
110 | } | |
111 | ||
1da177e4 LT |
112 | /******************************************************************************* |
113 | * | |
114 | * FUNCTION: acpi_ex_resolve_operands | |
115 | * | |
ba494bee | 116 | * PARAMETERS: opcode - Opcode being interpreted |
1da177e4 LT |
117 | * stack_ptr - Pointer to the operand stack to be |
118 | * resolved | |
119 | * walk_state - Current state | |
120 | * | |
121 | * RETURN: Status | |
122 | * | |
123 | * DESCRIPTION: Convert multiple input operands to the types required by the | |
124 | * target operator. | |
125 | * | |
126 | * Each 5-bit group in arg_types represents one required | |
127 | * operand and indicates the required Type. The corresponding operand | |
128 | * will be converted to the required type if possible, otherwise we | |
129 | * abort with an exception. | |
130 | * | |
131 | ******************************************************************************/ | |
132 | ||
133 | acpi_status | |
4be44fcd LB |
134 | acpi_ex_resolve_operands(u16 opcode, |
135 | union acpi_operand_object ** stack_ptr, | |
136 | struct acpi_walk_state * walk_state) | |
1da177e4 | 137 | { |
4be44fcd LB |
138 | union acpi_operand_object *obj_desc; |
139 | acpi_status status = AE_OK; | |
140 | u8 object_type; | |
4be44fcd LB |
141 | u32 arg_types; |
142 | const struct acpi_opcode_info *op_info; | |
143 | u32 this_arg_type; | |
144 | acpi_object_type type_needed; | |
145 | u16 target_op = 0; | |
146 | ||
b229cf92 | 147 | ACPI_FUNCTION_TRACE_U32(ex_resolve_operands, opcode); |
4be44fcd LB |
148 | |
149 | op_info = acpi_ps_get_opcode_info(opcode); | |
1da177e4 | 150 | if (op_info->class == AML_CLASS_UNKNOWN) { |
4be44fcd | 151 | return_ACPI_STATUS(AE_AML_BAD_OPCODE); |
1da177e4 LT |
152 | } |
153 | ||
154 | arg_types = op_info->runtime_args; | |
155 | if (arg_types == ARGI_INVALID_OPCODE) { | |
f6a22b0b | 156 | ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X", opcode)); |
1da177e4 | 157 | |
4be44fcd | 158 | return_ACPI_STATUS(AE_AML_INTERNAL); |
1da177e4 LT |
159 | } |
160 | ||
4be44fcd | 161 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
b229cf92 | 162 | "Opcode %X [%s] RequiredOperandTypes=%8.8X\n", |
4be44fcd | 163 | opcode, op_info->name, arg_types)); |
1da177e4 LT |
164 | |
165 | /* | |
166 | * Normal exit is with (arg_types == 0) at end of argument list. | |
167 | * Function will return an exception from within the loop upon | |
168 | * finding an entry which is not (or cannot be converted | |
169 | * to) the required type; if stack underflows; or upon | |
170 | * finding a NULL stack entry (which should not happen). | |
171 | */ | |
4be44fcd | 172 | while (GET_CURRENT_ARG_TYPE(arg_types)) { |
1da177e4 | 173 | if (!stack_ptr || !*stack_ptr) { |
b8e4d893 BM |
174 | ACPI_ERROR((AE_INFO, "Null stack entry at %p", |
175 | stack_ptr)); | |
1da177e4 | 176 | |
4be44fcd | 177 | return_ACPI_STATUS(AE_AML_INTERNAL); |
1da177e4 LT |
178 | } |
179 | ||
180 | /* Extract useful items */ | |
181 | ||
182 | obj_desc = *stack_ptr; | |
183 | ||
184 | /* Decode the descriptor type */ | |
185 | ||
4be44fcd | 186 | switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) { |
1da177e4 LT |
187 | case ACPI_DESC_TYPE_NAMED: |
188 | ||
44f6c012 | 189 | /* Namespace Node */ |
1da177e4 | 190 | |
4be44fcd LB |
191 | object_type = |
192 | ((struct acpi_namespace_node *)obj_desc)->type; | |
b8e4d893 BM |
193 | |
194 | /* | |
195 | * Resolve an alias object. The construction of these objects | |
196 | * guarantees that there is only one level of alias indirection; | |
197 | * thus, the attached object is always the aliased namespace node | |
198 | */ | |
199 | if (object_type == ACPI_TYPE_LOCAL_ALIAS) { | |
200 | obj_desc = | |
201 | acpi_ns_get_attached_object((struct | |
202 | acpi_namespace_node | |
203 | *)obj_desc); | |
204 | *stack_ptr = obj_desc; | |
205 | object_type = | |
206 | ((struct acpi_namespace_node *)obj_desc)-> | |
207 | type; | |
208 | } | |
1da177e4 LT |
209 | break; |
210 | ||
1da177e4 LT |
211 | case ACPI_DESC_TYPE_OPERAND: |
212 | ||
213 | /* ACPI internal object */ | |
214 | ||
3371c19c | 215 | object_type = obj_desc->common.type; |
1da177e4 LT |
216 | |
217 | /* Check for bad acpi_object_type */ | |
218 | ||
4be44fcd | 219 | if (!acpi_ut_valid_object_type(object_type)) { |
b8e4d893 | 220 | ACPI_ERROR((AE_INFO, |
f6a22b0b | 221 | "Bad operand object type [0x%X]", |
b8e4d893 | 222 | object_type)); |
1da177e4 | 223 | |
4be44fcd | 224 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
225 | } |
226 | ||
227 | if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) { | |
52fc0b02 | 228 | |
1044f1f6 | 229 | /* Validate the Reference */ |
44f6c012 | 230 | |
1044f1f6 BM |
231 | switch (obj_desc->reference.class) { |
232 | case ACPI_REFCLASS_DEBUG: | |
1da177e4 | 233 | |
44f6c012 RM |
234 | target_op = AML_DEBUG_OP; |
235 | ||
236 | /*lint -fallthrough */ | |
237 | ||
1044f1f6 BM |
238 | case ACPI_REFCLASS_ARG: |
239 | case ACPI_REFCLASS_LOCAL: | |
240 | case ACPI_REFCLASS_INDEX: | |
241 | case ACPI_REFCLASS_REFOF: | |
242 | case ACPI_REFCLASS_TABLE: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */ | |
243 | case ACPI_REFCLASS_NAME: /* Reference to a named object */ | |
244 | ||
245 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | |
246 | "Operand is a Reference, Class [%s] %2.2X\n", | |
247 | acpi_ut_get_reference_name | |
248 | (obj_desc), | |
249 | obj_desc->reference. | |
250 | class)); | |
1da177e4 LT |
251 | break; |
252 | ||
253 | default: | |
1044f1f6 | 254 | |
b8e4d893 | 255 | ACPI_ERROR((AE_INFO, |
f6a22b0b | 256 | "Unknown Reference Class 0x%2.2X in %p", |
1044f1f6 BM |
257 | obj_desc->reference.class, |
258 | obj_desc)); | |
4be44fcd LB |
259 | |
260 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); | |
1da177e4 LT |
261 | } |
262 | } | |
263 | break; | |
264 | ||
1da177e4 LT |
265 | default: |
266 | ||
267 | /* Invalid descriptor */ | |
268 | ||
1044f1f6 | 269 | ACPI_ERROR((AE_INFO, "Invalid descriptor %p [%s]", |
b8e4d893 BM |
270 | obj_desc, |
271 | acpi_ut_get_descriptor_name(obj_desc))); | |
1da177e4 | 272 | |
4be44fcd | 273 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
274 | } |
275 | ||
44f6c012 | 276 | /* Get one argument type, point to the next */ |
1da177e4 | 277 | |
4be44fcd LB |
278 | this_arg_type = GET_CURRENT_ARG_TYPE(arg_types); |
279 | INCREMENT_ARG_LIST(arg_types); | |
1da177e4 LT |
280 | |
281 | /* | |
282 | * Handle cases where the object does not need to be | |
283 | * resolved to a value | |
284 | */ | |
285 | switch (this_arg_type) { | |
4be44fcd | 286 | case ARGI_REF_OR_STRING: /* Can be a String or Reference */ |
1da177e4 | 287 | |
4be44fcd LB |
288 | if ((ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == |
289 | ACPI_DESC_TYPE_OPERAND) | |
3371c19c | 290 | && (obj_desc->common.type == ACPI_TYPE_STRING)) { |
1da177e4 | 291 | /* |
44f6c012 RM |
292 | * String found - the string references a named object and |
293 | * must be resolved to a node | |
1da177e4 LT |
294 | */ |
295 | goto next_operand; | |
296 | } | |
297 | ||
44f6c012 RM |
298 | /* |
299 | * Else not a string - fall through to the normal Reference | |
300 | * case below | |
301 | */ | |
1da177e4 LT |
302 | /*lint -fallthrough */ |
303 | ||
4be44fcd | 304 | case ARGI_REFERENCE: /* References: */ |
1da177e4 LT |
305 | case ARGI_INTEGER_REF: |
306 | case ARGI_OBJECT_REF: | |
307 | case ARGI_DEVICE_REF: | |
4be44fcd LB |
308 | case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ |
309 | case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ | |
ba494bee | 310 | case ARGI_SIMPLE_TARGET: /* Name, Local, or arg - no implicit conversion */ |
1da177e4 | 311 | |
44f6c012 RM |
312 | /* |
313 | * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE | |
314 | * A Namespace Node is OK as-is | |
315 | */ | |
4be44fcd LB |
316 | if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == |
317 | ACPI_DESC_TYPE_NAMED) { | |
1da177e4 LT |
318 | goto next_operand; |
319 | } | |
320 | ||
4be44fcd LB |
321 | status = |
322 | acpi_ex_check_object_type(ACPI_TYPE_LOCAL_REFERENCE, | |
323 | object_type, obj_desc); | |
324 | if (ACPI_FAILURE(status)) { | |
325 | return_ACPI_STATUS(status); | |
1da177e4 | 326 | } |
1da177e4 LT |
327 | goto next_operand; |
328 | ||
4be44fcd | 329 | case ARGI_DATAREFOBJ: /* Store operator only */ |
1da177e4 LT |
330 | |
331 | /* | |
332 | * We don't want to resolve index_op reference objects during | |
333 | * a store because this would be an implicit de_ref_of operation. | |
334 | * Instead, we just want to store the reference object. | |
335 | * -- All others must be resolved below. | |
336 | */ | |
337 | if ((opcode == AML_STORE_OP) && | |
3371c19c | 338 | ((*stack_ptr)->common.type == |
4be44fcd | 339 | ACPI_TYPE_LOCAL_REFERENCE) |
1f86e8c1 LZ |
340 | && ((*stack_ptr)->reference.class == |
341 | ACPI_REFCLASS_INDEX)) { | |
1da177e4 LT |
342 | goto next_operand; |
343 | } | |
344 | break; | |
345 | ||
346 | default: | |
347 | /* All cases covered above */ | |
348 | break; | |
349 | } | |
350 | ||
1da177e4 LT |
351 | /* |
352 | * Resolve this object to a value | |
353 | */ | |
4be44fcd LB |
354 | status = acpi_ex_resolve_to_value(stack_ptr, walk_state); |
355 | if (ACPI_FAILURE(status)) { | |
356 | return_ACPI_STATUS(status); | |
1da177e4 LT |
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) { | |
4be44fcd LB |
367 | /* |
368 | * For the simple cases, only one type of resolved object | |
369 | * is allowed | |
370 | */ | |
1da177e4 LT |
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 | ||
4be44fcd | 385 | case ARGI_PACKAGE: /* Package */ |
1da177e4 LT |
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 | ||
4be44fcd LB |
406 | /* |
407 | * The more complex cases allow multiple resolved object types | |
408 | */ | |
44f6c012 | 409 | case ARGI_INTEGER: |
1da177e4 LT |
410 | |
411 | /* | |
412 | * Need an operand of type ACPI_TYPE_INTEGER, | |
413 | * But we can implicitly convert from a STRING or BUFFER | |
ba494bee | 414 | * aka - "Implicit Source Operand Conversion" |
1da177e4 | 415 | */ |
4be44fcd LB |
416 | status = |
417 | acpi_ex_convert_to_integer(obj_desc, stack_ptr, 16); | |
418 | if (ACPI_FAILURE(status)) { | |
1da177e4 | 419 | if (status == AE_TYPE) { |
b8e4d893 BM |
420 | ACPI_ERROR((AE_INFO, |
421 | "Needed [Integer/String/Buffer], found [%s] %p", | |
422 | acpi_ut_get_object_type_name | |
423 | (obj_desc), obj_desc)); | |
1da177e4 | 424 | |
4be44fcd | 425 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
426 | } |
427 | ||
4be44fcd | 428 | return_ACPI_STATUS(status); |
1da177e4 | 429 | } |
f9f4601f RM |
430 | |
431 | if (obj_desc != *stack_ptr) { | |
4be44fcd | 432 | acpi_ut_remove_reference(obj_desc); |
f9f4601f | 433 | } |
1da177e4 LT |
434 | goto next_operand; |
435 | ||
1da177e4 LT |
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 | |
ba494bee | 441 | * aka - "Implicit Source Operand Conversion" |
1da177e4 | 442 | */ |
4be44fcd LB |
443 | status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr); |
444 | if (ACPI_FAILURE(status)) { | |
1da177e4 | 445 | if (status == AE_TYPE) { |
b8e4d893 BM |
446 | ACPI_ERROR((AE_INFO, |
447 | "Needed [Integer/String/Buffer], found [%s] %p", | |
448 | acpi_ut_get_object_type_name | |
449 | (obj_desc), obj_desc)); | |
1da177e4 | 450 | |
4be44fcd | 451 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
452 | } |
453 | ||
4be44fcd | 454 | return_ACPI_STATUS(status); |
1da177e4 | 455 | } |
f9f4601f RM |
456 | |
457 | if (obj_desc != *stack_ptr) { | |
4be44fcd | 458 | acpi_ut_remove_reference(obj_desc); |
f9f4601f | 459 | } |
1da177e4 LT |
460 | goto next_operand; |
461 | ||
1da177e4 LT |
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 | |
ba494bee | 467 | * aka - "Implicit Source Operand Conversion" |
1da177e4 | 468 | */ |
4be44fcd LB |
469 | status = acpi_ex_convert_to_string(obj_desc, stack_ptr, |
470 | ACPI_IMPLICIT_CONVERT_HEX); | |
471 | if (ACPI_FAILURE(status)) { | |
1da177e4 | 472 | if (status == AE_TYPE) { |
b8e4d893 BM |
473 | ACPI_ERROR((AE_INFO, |
474 | "Needed [Integer/String/Buffer], found [%s] %p", | |
475 | acpi_ut_get_object_type_name | |
476 | (obj_desc), obj_desc)); | |
1da177e4 | 477 | |
4be44fcd | 478 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
479 | } |
480 | ||
4be44fcd | 481 | return_ACPI_STATUS(status); |
1da177e4 | 482 | } |
f9f4601f RM |
483 | |
484 | if (obj_desc != *stack_ptr) { | |
4be44fcd | 485 | acpi_ut_remove_reference(obj_desc); |
f9f4601f | 486 | } |
1da177e4 LT |
487 | goto next_operand; |
488 | ||
1da177e4 LT |
489 | case ARGI_COMPUTEDATA: |
490 | ||
491 | /* Need an operand of type INTEGER, STRING or BUFFER */ | |
492 | ||
3371c19c | 493 | switch (obj_desc->common.type) { |
1da177e4 LT |
494 | case ACPI_TYPE_INTEGER: |
495 | case ACPI_TYPE_STRING: | |
496 | case ACPI_TYPE_BUFFER: | |
497 | ||
498 | /* Valid operand */ | |
4be44fcd | 499 | break; |
1da177e4 LT |
500 | |
501 | default: | |
b8e4d893 BM |
502 | ACPI_ERROR((AE_INFO, |
503 | "Needed [Integer/String/Buffer], found [%s] %p", | |
504 | acpi_ut_get_object_type_name | |
505 | (obj_desc), obj_desc)); | |
1da177e4 | 506 | |
4be44fcd | 507 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
508 | } |
509 | goto next_operand; | |
510 | ||
1da177e4 LT |
511 | case ARGI_BUFFER_OR_STRING: |
512 | ||
513 | /* Need an operand of type STRING or BUFFER */ | |
514 | ||
3371c19c | 515 | switch (obj_desc->common.type) { |
1da177e4 LT |
516 | case ACPI_TYPE_STRING: |
517 | case ACPI_TYPE_BUFFER: | |
518 | ||
519 | /* Valid operand */ | |
4be44fcd | 520 | break; |
1da177e4 LT |
521 | |
522 | case ACPI_TYPE_INTEGER: | |
523 | ||
524 | /* Highest priority conversion is to type Buffer */ | |
525 | ||
4be44fcd LB |
526 | status = |
527 | acpi_ex_convert_to_buffer(obj_desc, | |
528 | stack_ptr); | |
529 | if (ACPI_FAILURE(status)) { | |
530 | return_ACPI_STATUS(status); | |
1da177e4 | 531 | } |
f9f4601f RM |
532 | |
533 | if (obj_desc != *stack_ptr) { | |
4be44fcd | 534 | acpi_ut_remove_reference(obj_desc); |
f9f4601f | 535 | } |
1da177e4 LT |
536 | break; |
537 | ||
538 | default: | |
b8e4d893 BM |
539 | ACPI_ERROR((AE_INFO, |
540 | "Needed [Integer/String/Buffer], found [%s] %p", | |
541 | acpi_ut_get_object_type_name | |
542 | (obj_desc), obj_desc)); | |
1da177e4 | 543 | |
4be44fcd | 544 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
545 | } |
546 | goto next_operand; | |
547 | ||
1da177e4 LT |
548 | case ARGI_DATAOBJECT: |
549 | /* | |
550 | * ARGI_DATAOBJECT is only used by the size_of operator. | |
551 | * Need a buffer, string, package, or ref_of reference. | |
552 | * | |
553 | * The only reference allowed here is a direct reference to | |
554 | * a namespace node. | |
555 | */ | |
3371c19c | 556 | switch (obj_desc->common.type) { |
1da177e4 LT |
557 | case ACPI_TYPE_PACKAGE: |
558 | case ACPI_TYPE_STRING: | |
559 | case ACPI_TYPE_BUFFER: | |
560 | case ACPI_TYPE_LOCAL_REFERENCE: | |
561 | ||
562 | /* Valid operand */ | |
563 | break; | |
564 | ||
565 | default: | |
b8e4d893 BM |
566 | ACPI_ERROR((AE_INFO, |
567 | "Needed [Buffer/String/Package/Reference], found [%s] %p", | |
568 | acpi_ut_get_object_type_name | |
569 | (obj_desc), obj_desc)); | |
1da177e4 | 570 | |
4be44fcd | 571 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
572 | } |
573 | goto next_operand; | |
574 | ||
1da177e4 LT |
575 | case ARGI_COMPLEXOBJ: |
576 | ||
577 | /* Need a buffer or package or (ACPI 2.0) String */ | |
578 | ||
3371c19c | 579 | switch (obj_desc->common.type) { |
1da177e4 LT |
580 | case ACPI_TYPE_PACKAGE: |
581 | case ACPI_TYPE_STRING: | |
582 | case ACPI_TYPE_BUFFER: | |
583 | ||
584 | /* Valid operand */ | |
585 | break; | |
586 | ||
587 | default: | |
b8e4d893 BM |
588 | ACPI_ERROR((AE_INFO, |
589 | "Needed [Buffer/String/Package], found [%s] %p", | |
590 | acpi_ut_get_object_type_name | |
591 | (obj_desc), obj_desc)); | |
1da177e4 | 592 | |
4be44fcd | 593 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
594 | } |
595 | goto next_operand; | |
596 | ||
a6823e12 | 597 | case ARGI_REGION_OR_BUFFER: /* Used by Load() only */ |
1da177e4 | 598 | |
a6823e12 | 599 | /* Need an operand of type REGION or a BUFFER (which could be a resolved region field) */ |
1da177e4 | 600 | |
3371c19c | 601 | switch (obj_desc->common.type) { |
a6823e12 | 602 | case ACPI_TYPE_BUFFER: |
1da177e4 | 603 | case ACPI_TYPE_REGION: |
1da177e4 LT |
604 | |
605 | /* Valid operand */ | |
606 | break; | |
607 | ||
608 | default: | |
b8e4d893 | 609 | ACPI_ERROR((AE_INFO, |
a6823e12 | 610 | "Needed [Region/Buffer], found [%s] %p", |
b8e4d893 BM |
611 | acpi_ut_get_object_type_name |
612 | (obj_desc), obj_desc)); | |
1da177e4 | 613 | |
4be44fcd | 614 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
615 | } |
616 | goto next_operand; | |
617 | ||
1da177e4 LT |
618 | case ARGI_DATAREFOBJ: |
619 | ||
620 | /* Used by the Store() operator only */ | |
621 | ||
3371c19c | 622 | switch (obj_desc->common.type) { |
1da177e4 LT |
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 | ||
44f6c012 | 648 | if (target_op == AML_DEBUG_OP) { |
52fc0b02 | 649 | |
44f6c012 RM |
650 | /* Allow store of any object to the Debug object */ |
651 | ||
652 | break; | |
653 | } | |
654 | ||
b8e4d893 BM |
655 | ACPI_ERROR((AE_INFO, |
656 | "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p", | |
657 | acpi_ut_get_object_type_name | |
658 | (obj_desc), obj_desc)); | |
1da177e4 | 659 | |
4be44fcd | 660 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
661 | } |
662 | goto next_operand; | |
663 | ||
1da177e4 LT |
664 | default: |
665 | ||
666 | /* Unknown type */ | |
667 | ||
b8e4d893 | 668 | ACPI_ERROR((AE_INFO, |
f6a22b0b | 669 | "Internal - Unknown ARGI (required operand) type 0x%X", |
b8e4d893 | 670 | this_arg_type)); |
1da177e4 | 671 | |
4be44fcd | 672 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
1da177e4 LT |
673 | } |
674 | ||
675 | /* | |
676 | * Make sure that the original object was resolved to the | |
677 | * required object type (Simple cases only). | |
678 | */ | |
4be44fcd | 679 | status = acpi_ex_check_object_type(type_needed, |
3371c19c BM |
680 | (*stack_ptr)->common.type, |
681 | *stack_ptr); | |
4be44fcd LB |
682 | if (ACPI_FAILURE(status)) { |
683 | return_ACPI_STATUS(status); | |
1da177e4 LT |
684 | } |
685 | ||
4be44fcd | 686 | next_operand: |
1da177e4 LT |
687 | /* |
688 | * If more operands needed, decrement stack_ptr to point | |
689 | * to next operand on stack | |
690 | */ | |
4be44fcd | 691 | if (GET_CURRENT_ARG_TYPE(arg_types)) { |
1da177e4 LT |
692 | stack_ptr--; |
693 | } | |
44f6c012 | 694 | } |
1da177e4 | 695 | |
71d993e1 BM |
696 | ACPI_DUMP_OPERANDS(walk_state->operands, |
697 | acpi_ps_get_opcode_name(opcode), | |
698 | walk_state->num_operands); | |
699 | ||
4be44fcd | 700 | return_ACPI_STATUS(status); |
1da177e4 | 701 | } |