Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | |
2 | /****************************************************************************** | |
3 | * | |
4 | * Module Name: exresop - AML Interpreter operand/object resolution | |
5 | * | |
6 | *****************************************************************************/ | |
7 | ||
8 | /* | |
4a90c7e8 | 9 | * Copyright (C) 2000 - 2006, R. Byron Moore |
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 LT |
45 | #include <acpi/acpi.h> |
46 | #include <acpi/amlcode.h> | |
47 | #include <acpi/acparser.h> | |
48 | #include <acpi/acinterp.h> | |
b8e4d893 | 49 | #include <acpi/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 | |
89 | * objects and thus allow them to be targets. (As per the ACPI | |
90 | * specification, a store to a constant is a noop.) | |
91 | */ | |
92 | if ((this_type == ACPI_TYPE_INTEGER) && | |
4be44fcd LB |
93 | (((union acpi_operand_object *)object)->common. |
94 | flags & 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 | * | |
115 | * PARAMETERS: Opcode - Opcode being interpreted | |
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 LB |
133 | acpi_ex_resolve_operands(u16 opcode, |
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; | |
140 | void *temp_node; | |
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) { | |
b8e4d893 | 156 | ACPI_ERROR((AE_INFO, "Unknown AML opcode %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 | ||
4be44fcd | 215 | object_type = ACPI_GET_OBJECT_TYPE(obj_desc); |
1da177e4 LT |
216 | |
217 | /* Check for bad acpi_object_type */ | |
218 | ||
4be44fcd | 219 | if (!acpi_ut_valid_object_type(object_type)) { |
b8e4d893 BM |
220 | ACPI_ERROR((AE_INFO, |
221 | "Bad operand object type [%X]", | |
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 | |
44f6c012 RM |
229 | /* Decode the Reference */ |
230 | ||
4be44fcd | 231 | op_info = acpi_ps_get_opcode_info(opcode); |
1da177e4 | 232 | if (op_info->class == AML_CLASS_UNKNOWN) { |
4be44fcd | 233 | return_ACPI_STATUS(AE_AML_BAD_OPCODE); |
1da177e4 LT |
234 | } |
235 | ||
236 | switch (obj_desc->reference.opcode) { | |
237 | case AML_DEBUG_OP: | |
44f6c012 RM |
238 | target_op = AML_DEBUG_OP; |
239 | ||
240 | /*lint -fallthrough */ | |
241 | ||
1da177e4 LT |
242 | case AML_NAME_OP: |
243 | case AML_INDEX_OP: | |
244 | case AML_REF_OF_OP: | |
245 | case AML_ARG_OP: | |
246 | case AML_LOCAL_OP: | |
4be44fcd LB |
247 | case AML_LOAD_OP: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */ |
248 | case AML_INT_NAMEPATH_OP: /* Reference to a named object */ | |
249 | ||
250 | ACPI_DEBUG_ONLY_MEMBERS(ACPI_DEBUG_PRINT | |
251 | ((ACPI_DB_EXEC, | |
b229cf92 | 252 | "Operand is a Reference, RefOpcode [%s]\n", |
4be44fcd LB |
253 | (acpi_ps_get_opcode_info |
254 | (obj_desc-> | |
255 | reference. | |
256 | opcode))-> | |
257 | name))); | |
1da177e4 LT |
258 | break; |
259 | ||
260 | default: | |
b8e4d893 BM |
261 | ACPI_ERROR((AE_INFO, |
262 | "Operand is a Reference, Unknown Reference Opcode: %X", | |
263 | obj_desc->reference. | |
264 | opcode)); | |
4be44fcd LB |
265 | |
266 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); | |
1da177e4 LT |
267 | } |
268 | } | |
269 | break; | |
270 | ||
1da177e4 LT |
271 | default: |
272 | ||
273 | /* Invalid descriptor */ | |
274 | ||
b8e4d893 BM |
275 | ACPI_ERROR((AE_INFO, |
276 | "Invalid descriptor %p [%s]", | |
277 | obj_desc, | |
278 | acpi_ut_get_descriptor_name(obj_desc))); | |
1da177e4 | 279 | |
4be44fcd | 280 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
281 | } |
282 | ||
44f6c012 | 283 | /* Get one argument type, point to the next */ |
1da177e4 | 284 | |
4be44fcd LB |
285 | this_arg_type = GET_CURRENT_ARG_TYPE(arg_types); |
286 | INCREMENT_ARG_LIST(arg_types); | |
1da177e4 LT |
287 | |
288 | /* | |
289 | * Handle cases where the object does not need to be | |
290 | * resolved to a value | |
291 | */ | |
292 | switch (this_arg_type) { | |
4be44fcd | 293 | case ARGI_REF_OR_STRING: /* Can be a String or Reference */ |
1da177e4 | 294 | |
4be44fcd LB |
295 | if ((ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == |
296 | ACPI_DESC_TYPE_OPERAND) | |
297 | && (ACPI_GET_OBJECT_TYPE(obj_desc) == | |
298 | ACPI_TYPE_STRING)) { | |
1da177e4 | 299 | /* |
44f6c012 RM |
300 | * String found - the string references a named object and |
301 | * must be resolved to a node | |
1da177e4 LT |
302 | */ |
303 | goto next_operand; | |
304 | } | |
305 | ||
44f6c012 RM |
306 | /* |
307 | * Else not a string - fall through to the normal Reference | |
308 | * case below | |
309 | */ | |
1da177e4 LT |
310 | /*lint -fallthrough */ |
311 | ||
4be44fcd | 312 | case ARGI_REFERENCE: /* References: */ |
1da177e4 LT |
313 | case ARGI_INTEGER_REF: |
314 | case ARGI_OBJECT_REF: | |
315 | case ARGI_DEVICE_REF: | |
4be44fcd LB |
316 | case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ |
317 | case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ | |
318 | case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ | |
1da177e4 | 319 | |
44f6c012 RM |
320 | /* |
321 | * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE | |
322 | * A Namespace Node is OK as-is | |
323 | */ | |
4be44fcd LB |
324 | if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == |
325 | ACPI_DESC_TYPE_NAMED) { | |
1da177e4 LT |
326 | goto next_operand; |
327 | } | |
328 | ||
4be44fcd LB |
329 | status = |
330 | acpi_ex_check_object_type(ACPI_TYPE_LOCAL_REFERENCE, | |
331 | object_type, obj_desc); | |
332 | if (ACPI_FAILURE(status)) { | |
333 | return_ACPI_STATUS(status); | |
1da177e4 LT |
334 | } |
335 | ||
44f6c012 | 336 | if (obj_desc->reference.opcode == AML_NAME_OP) { |
52fc0b02 | 337 | |
44f6c012 RM |
338 | /* Convert a named reference to the actual named object */ |
339 | ||
1da177e4 | 340 | temp_node = obj_desc->reference.object; |
4be44fcd | 341 | acpi_ut_remove_reference(obj_desc); |
1da177e4 LT |
342 | (*stack_ptr) = temp_node; |
343 | } | |
344 | goto next_operand; | |
345 | ||
4be44fcd | 346 | case ARGI_DATAREFOBJ: /* Store operator only */ |
1da177e4 LT |
347 | |
348 | /* | |
349 | * We don't want to resolve index_op reference objects during | |
350 | * a store because this would be an implicit de_ref_of operation. | |
351 | * Instead, we just want to store the reference object. | |
352 | * -- All others must be resolved below. | |
353 | */ | |
354 | if ((opcode == AML_STORE_OP) && | |
4be44fcd LB |
355 | (ACPI_GET_OBJECT_TYPE(*stack_ptr) == |
356 | ACPI_TYPE_LOCAL_REFERENCE) | |
357 | && ((*stack_ptr)->reference.opcode == | |
358 | AML_INDEX_OP)) { | |
1da177e4 LT |
359 | goto next_operand; |
360 | } | |
361 | break; | |
362 | ||
363 | default: | |
364 | /* All cases covered above */ | |
365 | break; | |
366 | } | |
367 | ||
1da177e4 LT |
368 | /* |
369 | * Resolve this object to a value | |
370 | */ | |
4be44fcd LB |
371 | status = acpi_ex_resolve_to_value(stack_ptr, walk_state); |
372 | if (ACPI_FAILURE(status)) { | |
373 | return_ACPI_STATUS(status); | |
1da177e4 LT |
374 | } |
375 | ||
376 | /* Get the resolved object */ | |
377 | ||
378 | obj_desc = *stack_ptr; | |
379 | ||
380 | /* | |
381 | * Check the resulting object (value) type | |
382 | */ | |
383 | switch (this_arg_type) { | |
4be44fcd LB |
384 | /* |
385 | * For the simple cases, only one type of resolved object | |
386 | * is allowed | |
387 | */ | |
1da177e4 LT |
388 | case ARGI_MUTEX: |
389 | ||
390 | /* Need an operand of type ACPI_TYPE_MUTEX */ | |
391 | ||
392 | type_needed = ACPI_TYPE_MUTEX; | |
393 | break; | |
394 | ||
395 | case ARGI_EVENT: | |
396 | ||
397 | /* Need an operand of type ACPI_TYPE_EVENT */ | |
398 | ||
399 | type_needed = ACPI_TYPE_EVENT; | |
400 | break; | |
401 | ||
4be44fcd | 402 | case ARGI_PACKAGE: /* Package */ |
1da177e4 LT |
403 | |
404 | /* Need an operand of type ACPI_TYPE_PACKAGE */ | |
405 | ||
406 | type_needed = ACPI_TYPE_PACKAGE; | |
407 | break; | |
408 | ||
409 | case ARGI_ANYTYPE: | |
410 | ||
411 | /* Any operand type will do */ | |
412 | ||
413 | type_needed = ACPI_TYPE_ANY; | |
414 | break; | |
415 | ||
416 | case ARGI_DDBHANDLE: | |
417 | ||
418 | /* Need an operand of type ACPI_TYPE_DDB_HANDLE */ | |
419 | ||
420 | type_needed = ACPI_TYPE_LOCAL_REFERENCE; | |
421 | break; | |
422 | ||
4be44fcd LB |
423 | /* |
424 | * The more complex cases allow multiple resolved object types | |
425 | */ | |
44f6c012 | 426 | case ARGI_INTEGER: |
1da177e4 LT |
427 | |
428 | /* | |
429 | * Need an operand of type ACPI_TYPE_INTEGER, | |
430 | * But we can implicitly convert from a STRING or BUFFER | |
431 | * Aka - "Implicit Source Operand Conversion" | |
432 | */ | |
4be44fcd LB |
433 | status = |
434 | acpi_ex_convert_to_integer(obj_desc, stack_ptr, 16); | |
435 | if (ACPI_FAILURE(status)) { | |
1da177e4 | 436 | if (status == AE_TYPE) { |
b8e4d893 BM |
437 | ACPI_ERROR((AE_INFO, |
438 | "Needed [Integer/String/Buffer], found [%s] %p", | |
439 | acpi_ut_get_object_type_name | |
440 | (obj_desc), obj_desc)); | |
1da177e4 | 441 | |
4be44fcd | 442 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
443 | } |
444 | ||
4be44fcd | 445 | return_ACPI_STATUS(status); |
1da177e4 | 446 | } |
f9f4601f RM |
447 | |
448 | if (obj_desc != *stack_ptr) { | |
4be44fcd | 449 | acpi_ut_remove_reference(obj_desc); |
f9f4601f | 450 | } |
1da177e4 LT |
451 | goto next_operand; |
452 | ||
1da177e4 LT |
453 | case ARGI_BUFFER: |
454 | ||
455 | /* | |
456 | * Need an operand of type ACPI_TYPE_BUFFER, | |
457 | * But we can implicitly convert from a STRING or INTEGER | |
458 | * Aka - "Implicit Source Operand Conversion" | |
459 | */ | |
4be44fcd LB |
460 | status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr); |
461 | if (ACPI_FAILURE(status)) { | |
1da177e4 | 462 | if (status == AE_TYPE) { |
b8e4d893 BM |
463 | ACPI_ERROR((AE_INFO, |
464 | "Needed [Integer/String/Buffer], found [%s] %p", | |
465 | acpi_ut_get_object_type_name | |
466 | (obj_desc), obj_desc)); | |
1da177e4 | 467 | |
4be44fcd | 468 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
469 | } |
470 | ||
4be44fcd | 471 | return_ACPI_STATUS(status); |
1da177e4 | 472 | } |
f9f4601f RM |
473 | |
474 | if (obj_desc != *stack_ptr) { | |
4be44fcd | 475 | acpi_ut_remove_reference(obj_desc); |
f9f4601f | 476 | } |
1da177e4 LT |
477 | goto next_operand; |
478 | ||
1da177e4 LT |
479 | case ARGI_STRING: |
480 | ||
481 | /* | |
482 | * Need an operand of type ACPI_TYPE_STRING, | |
483 | * But we can implicitly convert from a BUFFER or INTEGER | |
484 | * Aka - "Implicit Source Operand Conversion" | |
485 | */ | |
4be44fcd LB |
486 | status = acpi_ex_convert_to_string(obj_desc, stack_ptr, |
487 | ACPI_IMPLICIT_CONVERT_HEX); | |
488 | if (ACPI_FAILURE(status)) { | |
1da177e4 | 489 | if (status == AE_TYPE) { |
b8e4d893 BM |
490 | ACPI_ERROR((AE_INFO, |
491 | "Needed [Integer/String/Buffer], found [%s] %p", | |
492 | acpi_ut_get_object_type_name | |
493 | (obj_desc), obj_desc)); | |
1da177e4 | 494 | |
4be44fcd | 495 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
496 | } |
497 | ||
4be44fcd | 498 | return_ACPI_STATUS(status); |
1da177e4 | 499 | } |
f9f4601f RM |
500 | |
501 | if (obj_desc != *stack_ptr) { | |
4be44fcd | 502 | acpi_ut_remove_reference(obj_desc); |
f9f4601f | 503 | } |
1da177e4 LT |
504 | goto next_operand; |
505 | ||
1da177e4 LT |
506 | case ARGI_COMPUTEDATA: |
507 | ||
508 | /* Need an operand of type INTEGER, STRING or BUFFER */ | |
509 | ||
4be44fcd | 510 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { |
1da177e4 LT |
511 | case ACPI_TYPE_INTEGER: |
512 | case ACPI_TYPE_STRING: | |
513 | case ACPI_TYPE_BUFFER: | |
514 | ||
515 | /* Valid operand */ | |
4be44fcd | 516 | break; |
1da177e4 LT |
517 | |
518 | default: | |
b8e4d893 BM |
519 | ACPI_ERROR((AE_INFO, |
520 | "Needed [Integer/String/Buffer], found [%s] %p", | |
521 | acpi_ut_get_object_type_name | |
522 | (obj_desc), obj_desc)); | |
1da177e4 | 523 | |
4be44fcd | 524 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
525 | } |
526 | goto next_operand; | |
527 | ||
1da177e4 LT |
528 | case ARGI_BUFFER_OR_STRING: |
529 | ||
530 | /* Need an operand of type STRING or BUFFER */ | |
531 | ||
4be44fcd | 532 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { |
1da177e4 LT |
533 | case ACPI_TYPE_STRING: |
534 | case ACPI_TYPE_BUFFER: | |
535 | ||
536 | /* Valid operand */ | |
4be44fcd | 537 | break; |
1da177e4 LT |
538 | |
539 | case ACPI_TYPE_INTEGER: | |
540 | ||
541 | /* Highest priority conversion is to type Buffer */ | |
542 | ||
4be44fcd LB |
543 | status = |
544 | acpi_ex_convert_to_buffer(obj_desc, | |
545 | stack_ptr); | |
546 | if (ACPI_FAILURE(status)) { | |
547 | return_ACPI_STATUS(status); | |
1da177e4 | 548 | } |
f9f4601f RM |
549 | |
550 | if (obj_desc != *stack_ptr) { | |
4be44fcd | 551 | acpi_ut_remove_reference(obj_desc); |
f9f4601f | 552 | } |
1da177e4 LT |
553 | break; |
554 | ||
555 | default: | |
b8e4d893 BM |
556 | ACPI_ERROR((AE_INFO, |
557 | "Needed [Integer/String/Buffer], found [%s] %p", | |
558 | acpi_ut_get_object_type_name | |
559 | (obj_desc), obj_desc)); | |
1da177e4 | 560 | |
4be44fcd | 561 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
562 | } |
563 | goto next_operand; | |
564 | ||
1da177e4 LT |
565 | case ARGI_DATAOBJECT: |
566 | /* | |
567 | * ARGI_DATAOBJECT is only used by the size_of operator. | |
568 | * Need a buffer, string, package, or ref_of reference. | |
569 | * | |
570 | * The only reference allowed here is a direct reference to | |
571 | * a namespace node. | |
572 | */ | |
4be44fcd | 573 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { |
1da177e4 LT |
574 | case ACPI_TYPE_PACKAGE: |
575 | case ACPI_TYPE_STRING: | |
576 | case ACPI_TYPE_BUFFER: | |
577 | case ACPI_TYPE_LOCAL_REFERENCE: | |
578 | ||
579 | /* Valid operand */ | |
580 | break; | |
581 | ||
582 | default: | |
b8e4d893 BM |
583 | ACPI_ERROR((AE_INFO, |
584 | "Needed [Buffer/String/Package/Reference], found [%s] %p", | |
585 | acpi_ut_get_object_type_name | |
586 | (obj_desc), obj_desc)); | |
1da177e4 | 587 | |
4be44fcd | 588 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
589 | } |
590 | goto next_operand; | |
591 | ||
1da177e4 LT |
592 | case ARGI_COMPLEXOBJ: |
593 | ||
594 | /* Need a buffer or package or (ACPI 2.0) String */ | |
595 | ||
4be44fcd | 596 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { |
1da177e4 LT |
597 | case ACPI_TYPE_PACKAGE: |
598 | case ACPI_TYPE_STRING: | |
599 | case ACPI_TYPE_BUFFER: | |
600 | ||
601 | /* Valid operand */ | |
602 | break; | |
603 | ||
604 | default: | |
b8e4d893 BM |
605 | ACPI_ERROR((AE_INFO, |
606 | "Needed [Buffer/String/Package], found [%s] %p", | |
607 | acpi_ut_get_object_type_name | |
608 | (obj_desc), obj_desc)); | |
1da177e4 | 609 | |
4be44fcd | 610 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
611 | } |
612 | goto next_operand; | |
613 | ||
1da177e4 LT |
614 | case ARGI_REGION_OR_FIELD: |
615 | ||
44f6c012 | 616 | /* Need an operand of type REGION or a FIELD in a region */ |
1da177e4 | 617 | |
4be44fcd | 618 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { |
1da177e4 LT |
619 | case ACPI_TYPE_REGION: |
620 | case ACPI_TYPE_LOCAL_REGION_FIELD: | |
621 | case ACPI_TYPE_LOCAL_BANK_FIELD: | |
622 | case ACPI_TYPE_LOCAL_INDEX_FIELD: | |
623 | ||
624 | /* Valid operand */ | |
625 | break; | |
626 | ||
627 | default: | |
b8e4d893 | 628 | ACPI_ERROR((AE_INFO, |
b229cf92 | 629 | "Needed [Region/RegionField], 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 | case ARGI_DATAREFOBJ: |
638 | ||
639 | /* Used by the Store() operator only */ | |
640 | ||
4be44fcd | 641 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { |
1da177e4 LT |
642 | case ACPI_TYPE_INTEGER: |
643 | case ACPI_TYPE_PACKAGE: | |
644 | case ACPI_TYPE_STRING: | |
645 | case ACPI_TYPE_BUFFER: | |
646 | case ACPI_TYPE_BUFFER_FIELD: | |
647 | case ACPI_TYPE_LOCAL_REFERENCE: | |
648 | case ACPI_TYPE_LOCAL_REGION_FIELD: | |
649 | case ACPI_TYPE_LOCAL_BANK_FIELD: | |
650 | case ACPI_TYPE_LOCAL_INDEX_FIELD: | |
651 | case ACPI_TYPE_DDB_HANDLE: | |
652 | ||
653 | /* Valid operand */ | |
654 | break; | |
655 | ||
656 | default: | |
657 | ||
658 | if (acpi_gbl_enable_interpreter_slack) { | |
659 | /* | |
660 | * Enable original behavior of Store(), allowing any and all | |
661 | * objects as the source operand. The ACPI spec does not | |
662 | * allow this, however. | |
663 | */ | |
664 | break; | |
665 | } | |
666 | ||
44f6c012 | 667 | if (target_op == AML_DEBUG_OP) { |
52fc0b02 | 668 | |
44f6c012 RM |
669 | /* Allow store of any object to the Debug object */ |
670 | ||
671 | break; | |
672 | } | |
673 | ||
b8e4d893 BM |
674 | ACPI_ERROR((AE_INFO, |
675 | "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p", | |
676 | acpi_ut_get_object_type_name | |
677 | (obj_desc), obj_desc)); | |
1da177e4 | 678 | |
4be44fcd | 679 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4 LT |
680 | } |
681 | goto next_operand; | |
682 | ||
1da177e4 LT |
683 | default: |
684 | ||
685 | /* Unknown type */ | |
686 | ||
b8e4d893 BM |
687 | ACPI_ERROR((AE_INFO, |
688 | "Internal - Unknown ARGI (required operand) type %X", | |
689 | this_arg_type)); | |
1da177e4 | 690 | |
4be44fcd | 691 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
1da177e4 LT |
692 | } |
693 | ||
694 | /* | |
695 | * Make sure that the original object was resolved to the | |
696 | * required object type (Simple cases only). | |
697 | */ | |
4be44fcd LB |
698 | status = acpi_ex_check_object_type(type_needed, |
699 | ACPI_GET_OBJECT_TYPE | |
700 | (*stack_ptr), *stack_ptr); | |
701 | if (ACPI_FAILURE(status)) { | |
702 | return_ACPI_STATUS(status); | |
1da177e4 LT |
703 | } |
704 | ||
4be44fcd | 705 | next_operand: |
1da177e4 LT |
706 | /* |
707 | * If more operands needed, decrement stack_ptr to point | |
708 | * to next operand on stack | |
709 | */ | |
4be44fcd | 710 | if (GET_CURRENT_ARG_TYPE(arg_types)) { |
1da177e4 LT |
711 | stack_ptr--; |
712 | } | |
44f6c012 | 713 | } |
1da177e4 | 714 | |
4be44fcd | 715 | return_ACPI_STATUS(status); |
1da177e4 | 716 | } |