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