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