MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / acpi / executer / exoparg1.c
blob8ba1e646974d78e0f8bbf93d136de02226ce6113
2 /******************************************************************************
4 * Module Name: exoparg1 - AML execution - opcodes with 1 argument
6 *****************************************************************************/
8 /*
9 * Copyright (C) 2000 - 2004, R. Byron Moore
10 * All rights reserved.
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.
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.
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.
46 #include <acpi/acpi.h>
47 #include <acpi/acparser.h>
48 #include <acpi/acdispat.h>
49 #include <acpi/acinterp.h>
50 #include <acpi/amlcode.h>
51 #include <acpi/acnamesp.h>
54 #define _COMPONENT ACPI_EXECUTER
55 ACPI_MODULE_NAME ("exoparg1")
58 /*!
59 * Naming convention for AML interpreter execution routines.
61 * The routines that begin execution of AML opcodes are named with a common
62 * convention based upon the number of arguments, the number of target operands,
63 * and whether or not a value is returned:
65 * AcpiExOpcode_xA_yT_zR
67 * Where:
69 * xA - ARGUMENTS: The number of arguments (input operands) that are
70 * required for this opcode type (1 through 6 args).
71 * yT - TARGETS: The number of targets (output operands) that are required
72 * for this opcode type (0, 1, or 2 targets).
73 * zR - RETURN VALUE: Indicates whether this opcode type returns a value
74 * as the function return (0 or 1).
76 * The AcpiExOpcode* functions are called via the Dispatcher component with
77 * fully resolved operands.
78 !*/
80 /*******************************************************************************
82 * FUNCTION: acpi_ex_opcode_1A_0T_0R
84 * PARAMETERS: walk_state - Current state (contains AML opcode)
86 * RETURN: Status
88 * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
89 * object stack
91 ******************************************************************************/
93 acpi_status
94 acpi_ex_opcode_1A_0T_0R (
95 struct acpi_walk_state *walk_state)
97 union acpi_operand_object **operand = &walk_state->operands[0];
98 acpi_status status = AE_OK;
101 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
104 /* Examine the AML opcode */
106 switch (walk_state->opcode) {
107 case AML_RELEASE_OP: /* Release (mutex_object) */
109 status = acpi_ex_release_mutex (operand[0], walk_state);
110 break;
113 case AML_RESET_OP: /* Reset (event_object) */
115 status = acpi_ex_system_reset_event (operand[0]);
116 break;
119 case AML_SIGNAL_OP: /* Signal (event_object) */
121 status = acpi_ex_system_signal_event (operand[0]);
122 break;
125 case AML_SLEEP_OP: /* Sleep (msec_time) */
127 status = acpi_ex_system_do_suspend ((u32) operand[0]->integer.value);
128 break;
131 case AML_STALL_OP: /* Stall (usec_time) */
133 status = acpi_ex_system_do_stall ((u32) operand[0]->integer.value);
134 break;
137 case AML_UNLOAD_OP: /* Unload (Handle) */
139 status = acpi_ex_unload_table (operand[0]);
140 break;
143 default: /* Unknown opcode */
145 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n",
146 walk_state->opcode));
147 status = AE_AML_BAD_OPCODE;
148 break;
151 return_ACPI_STATUS (status);
155 /*******************************************************************************
157 * FUNCTION: acpi_ex_opcode_1A_1T_0R
159 * PARAMETERS: walk_state - Current state (contains AML opcode)
161 * RETURN: Status
163 * DESCRIPTION: Execute opcode with one argument, one target, and no
164 * return value.
166 ******************************************************************************/
168 acpi_status
169 acpi_ex_opcode_1A_1T_0R (
170 struct acpi_walk_state *walk_state)
172 acpi_status status = AE_OK;
173 union acpi_operand_object **operand = &walk_state->operands[0];
176 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
179 /* Examine the AML opcode */
181 switch (walk_state->opcode) {
182 case AML_LOAD_OP:
184 status = acpi_ex_load_op (operand[0], operand[1], walk_state);
185 break;
187 default: /* Unknown opcode */
189 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n",
190 walk_state->opcode));
191 status = AE_AML_BAD_OPCODE;
192 goto cleanup;
196 cleanup:
198 return_ACPI_STATUS (status);
202 /*******************************************************************************
204 * FUNCTION: acpi_ex_opcode_1A_1T_1R
206 * PARAMETERS: walk_state - Current state (contains AML opcode)
208 * RETURN: Status
210 * DESCRIPTION: Execute opcode with one argument, one target, and a
211 * return value.
213 ******************************************************************************/
215 acpi_status
216 acpi_ex_opcode_1A_1T_1R (
217 struct acpi_walk_state *walk_state)
219 acpi_status status = AE_OK;
220 union acpi_operand_object **operand = &walk_state->operands[0];
221 union acpi_operand_object *return_desc = NULL;
222 union acpi_operand_object *return_desc2 = NULL;
223 u32 temp32;
224 u32 i;
225 u32 power_of_ten;
226 acpi_integer digit;
229 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
232 /* Examine the AML opcode */
234 switch (walk_state->opcode) {
235 case AML_BIT_NOT_OP:
236 case AML_FIND_SET_LEFT_BIT_OP:
237 case AML_FIND_SET_RIGHT_BIT_OP:
238 case AML_FROM_BCD_OP:
239 case AML_TO_BCD_OP:
240 case AML_COND_REF_OF_OP:
242 /* Create a return object of type Integer for these opcodes */
244 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
245 if (!return_desc) {
246 status = AE_NO_MEMORY;
247 goto cleanup;
250 switch (walk_state->opcode) {
251 case AML_BIT_NOT_OP: /* Not (Operand, Result) */
253 return_desc->integer.value = ~operand[0]->integer.value;
254 break;
257 case AML_FIND_SET_LEFT_BIT_OP: /* find_set_left_bit (Operand, Result) */
259 return_desc->integer.value = operand[0]->integer.value;
262 * Acpi specification describes Integer type as a little
263 * endian unsigned value, so this boundary condition is valid.
265 for (temp32 = 0; return_desc->integer.value && temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
266 return_desc->integer.value >>= 1;
269 return_desc->integer.value = temp32;
270 break;
273 case AML_FIND_SET_RIGHT_BIT_OP: /* find_set_right_bit (Operand, Result) */
275 return_desc->integer.value = operand[0]->integer.value;
278 * The Acpi specification describes Integer type as a little
279 * endian unsigned value, so this boundary condition is valid.
281 for (temp32 = 0; return_desc->integer.value && temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
282 return_desc->integer.value <<= 1;
285 /* Since the bit position is one-based, subtract from 33 (65) */
287 return_desc->integer.value = temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - temp32;
288 break;
291 case AML_FROM_BCD_OP: /* from_bcd (BCDValue, Result) */
294 * The 64-bit ACPI integer can hold 16 4-bit BCD characters
295 * (if table is 32-bit, integer can hold 8 BCD characters)
296 * Convert each 4-bit BCD value
298 power_of_ten = 1;
299 return_desc->integer.value = 0;
300 digit = operand[0]->integer.value;
302 /* Convert each BCD digit (each is one nybble wide) */
304 for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) {
305 /* Get the least significant 4-bit BCD digit */
307 temp32 = ((u32) digit) & 0xF;
309 /* Check the range of the digit */
311 if (temp32 > 9) {
312 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
313 "BCD digit too large (not decimal): 0x%X\n",
314 temp32));
316 status = AE_AML_NUMERIC_OVERFLOW;
317 goto cleanup;
320 /* Sum the digit into the result with the current power of 10 */
322 return_desc->integer.value += (((acpi_integer) temp32) * power_of_ten);
324 /* Shift to next BCD digit */
326 digit >>= 4;
328 /* Next power of 10 */
330 power_of_ten *= 10;
332 break;
335 case AML_TO_BCD_OP: /* to_bcd (Operand, Result) */
337 return_desc->integer.value = 0;
338 digit = operand[0]->integer.value;
340 /* Each BCD digit is one nybble wide */
342 for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) {
343 (void) acpi_ut_short_divide (&digit, 10, &digit, &temp32);
345 /* Insert the BCD digit that resides in the remainder from above */
347 return_desc->integer.value |= (((acpi_integer) temp32) << (i * 4));
350 /* Overflow if there is any data left in Digit */
352 if (digit > 0) {
353 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Integer too large to convert to BCD: %8.8X%8.8X\n",
354 ACPI_FORMAT_UINT64 (operand[0]->integer.value)));
355 status = AE_AML_NUMERIC_OVERFLOW;
356 goto cleanup;
358 break;
361 case AML_COND_REF_OF_OP: /* cond_ref_of (source_object, Result) */
364 * This op is a little strange because the internal return value is
365 * different than the return value stored in the result descriptor
366 * (There are really two return values)
368 if ((struct acpi_namespace_node *) operand[0] == acpi_gbl_root_node) {
370 * This means that the object does not exist in the namespace,
371 * return FALSE
373 return_desc->integer.value = 0;
374 goto cleanup;
377 /* Get the object reference, store it, and remove our reference */
379 status = acpi_ex_get_object_reference (operand[0], &return_desc2, walk_state);
380 if (ACPI_FAILURE (status)) {
381 goto cleanup;
384 status = acpi_ex_store (return_desc2, operand[1], walk_state);
385 acpi_ut_remove_reference (return_desc2);
387 /* The object exists in the namespace, return TRUE */
389 return_desc->integer.value = ACPI_INTEGER_MAX;
390 goto cleanup;
393 default:
394 /* No other opcodes get here */
395 break;
397 break;
400 case AML_STORE_OP: /* Store (Source, Target) */
403 * A store operand is typically a number, string, buffer or lvalue
404 * Be careful about deleting the source object,
405 * since the object itself may have been stored.
407 status = acpi_ex_store (operand[0], operand[1], walk_state);
408 if (ACPI_FAILURE (status)) {
409 return_ACPI_STATUS (status);
412 /* It is possible that the Store already produced a return object */
414 if (!walk_state->result_obj) {
416 * Normally, we would remove a reference on the Operand[0] parameter;
417 * But since it is being used as the internal return object
418 * (meaning we would normally increment it), the two cancel out,
419 * and we simply don't do anything.
421 walk_state->result_obj = operand[0];
422 walk_state->operands[0] = NULL; /* Prevent deletion */
424 return_ACPI_STATUS (status);
428 * ACPI 2.0 Opcodes
430 case AML_COPY_OP: /* Copy (Source, Target) */
432 status = acpi_ut_copy_iobject_to_iobject (operand[0], &return_desc, walk_state);
433 break;
436 case AML_TO_DECSTRING_OP: /* to_decimal_string (Data, Result) */
438 status = acpi_ex_convert_to_string (operand[0], &return_desc, 10, ACPI_UINT32_MAX, walk_state);
439 break;
442 case AML_TO_HEXSTRING_OP: /* to_hex_string (Data, Result) */
444 status = acpi_ex_convert_to_string (operand[0], &return_desc, 16, ACPI_UINT32_MAX, walk_state);
445 break;
448 case AML_TO_BUFFER_OP: /* to_buffer (Data, Result) */
450 status = acpi_ex_convert_to_buffer (operand[0], &return_desc, walk_state);
451 break;
454 case AML_TO_INTEGER_OP: /* to_integer (Data, Result) */
456 status = acpi_ex_convert_to_integer (operand[0], &return_desc, walk_state);
457 break;
460 case AML_SHIFT_LEFT_BIT_OP: /* shift_left_bit (Source, bit_num) */
461 case AML_SHIFT_RIGHT_BIT_OP: /* shift_right_bit (Source, bit_num) */
464 * These are two obsolete opcodes
466 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s is obsolete and not implemented\n",
467 acpi_ps_get_opcode_name (walk_state->opcode)));
468 status = AE_SUPPORT;
469 goto cleanup;
472 default: /* Unknown opcode */
474 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n",
475 walk_state->opcode));
476 status = AE_AML_BAD_OPCODE;
477 goto cleanup;
481 * Store the return value computed above into the target object
483 status = acpi_ex_store (return_desc, operand[1], walk_state);
486 cleanup:
488 if (!walk_state->result_obj) {
489 walk_state->result_obj = return_desc;
492 /* Delete return object on error */
494 if (ACPI_FAILURE (status)) {
495 acpi_ut_remove_reference (return_desc);
498 return_ACPI_STATUS (status);
502 /*******************************************************************************
504 * FUNCTION: acpi_ex_opcode_1A_0T_1R
506 * PARAMETERS: walk_state - Current state (contains AML opcode)
508 * RETURN: Status
510 * DESCRIPTION: Execute opcode with one argument, no target, and a return value
512 ******************************************************************************/
514 acpi_status
515 acpi_ex_opcode_1A_0T_1R (
516 struct acpi_walk_state *walk_state)
518 union acpi_operand_object **operand = &walk_state->operands[0];
519 union acpi_operand_object *temp_desc;
520 union acpi_operand_object *return_desc = NULL;
521 acpi_status status = AE_OK;
522 u32 type;
523 acpi_integer value;
526 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
529 /* Examine the AML opcode */
531 switch (walk_state->opcode) {
532 case AML_LNOT_OP: /* LNot (Operand) */
534 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
535 if (!return_desc) {
536 status = AE_NO_MEMORY;
537 goto cleanup;
540 return_desc->integer.value = !operand[0]->integer.value;
541 break;
544 case AML_DECREMENT_OP: /* Decrement (Operand) */
545 case AML_INCREMENT_OP: /* Increment (Operand) */
548 * Since we are expecting a Reference operand, it
549 * can be either a NS Node or an internal object.
551 return_desc = operand[0];
552 if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) == ACPI_DESC_TYPE_OPERAND) {
553 /* Internal reference object - prevent deletion */
555 acpi_ut_add_reference (return_desc);
559 * Convert the return_desc Reference to a Number
560 * (This removes a reference on the return_desc object)
562 status = acpi_ex_resolve_operands (AML_LNOT_OP, &return_desc, walk_state);
563 if (ACPI_FAILURE (status)) {
564 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s: bad operand(s) %s\n",
565 acpi_ps_get_opcode_name (walk_state->opcode), acpi_format_exception(status)));
567 goto cleanup;
571 * return_desc is now guaranteed to be an Integer object
572 * Do the actual increment or decrement
574 if (AML_INCREMENT_OP == walk_state->opcode) {
575 return_desc->integer.value++;
577 else {
578 return_desc->integer.value--;
581 /* Store the result back in the original descriptor */
583 status = acpi_ex_store (return_desc, operand[0], walk_state);
584 break;
587 case AML_TYPE_OP: /* object_type (source_object) */
589 /* Get the type of the base object */
591 status = acpi_ex_resolve_multiple (walk_state, operand[0], &type, NULL);
592 if (ACPI_FAILURE (status)) {
593 goto cleanup;
596 /* Allocate a descriptor to hold the type. */
598 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
599 if (!return_desc) {
600 status = AE_NO_MEMORY;
601 goto cleanup;
604 return_desc->integer.value = type;
605 break;
608 case AML_SIZE_OF_OP: /* size_of (source_object) */
610 /* Get the base object */
612 status = acpi_ex_resolve_multiple (walk_state, operand[0], &type, &temp_desc);
613 if (ACPI_FAILURE (status)) {
614 goto cleanup;
618 * Type is guaranteed to be a buffer, string, or package at this
619 * point (even if the original operand was an object reference, it
620 * will be resolved and typechecked during operand resolution.)
622 switch (type) {
623 case ACPI_TYPE_BUFFER:
624 value = temp_desc->buffer.length;
625 break;
627 case ACPI_TYPE_STRING:
628 value = temp_desc->string.length;
629 break;
631 case ACPI_TYPE_PACKAGE:
632 value = temp_desc->package.count;
633 break;
635 default:
636 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "size_of, Not Buf/Str/Pkg - found type %s\n",
637 acpi_ut_get_type_name (type)));
638 status = AE_AML_OPERAND_TYPE;
639 goto cleanup;
643 * Now that we have the size of the object, create a result
644 * object to hold the value
646 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
647 if (!return_desc) {
648 status = AE_NO_MEMORY;
649 goto cleanup;
652 return_desc->integer.value = value;
653 break;
656 case AML_REF_OF_OP: /* ref_of (source_object) */
658 status = acpi_ex_get_object_reference (operand[0], &return_desc, walk_state);
659 if (ACPI_FAILURE (status)) {
660 goto cleanup;
662 break;
665 case AML_DEREF_OF_OP: /* deref_of (obj_reference | String) */
667 /* Check for a method local or argument, or standalone String */
669 if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) != ACPI_DESC_TYPE_NAMED) {
670 switch (ACPI_GET_OBJECT_TYPE (operand[0])) {
671 case ACPI_TYPE_LOCAL_REFERENCE:
673 * This is a deref_of (local_x | arg_x)
675 * Must resolve/dereference the local/arg reference first
677 switch (operand[0]->reference.opcode) {
678 case AML_LOCAL_OP:
679 case AML_ARG_OP:
681 /* Set Operand[0] to the value of the local/arg */
683 status = acpi_ds_method_data_get_value (operand[0]->reference.opcode,
684 operand[0]->reference.offset, walk_state, &temp_desc);
685 if (ACPI_FAILURE (status)) {
686 goto cleanup;
690 * Delete our reference to the input object and
691 * point to the object just retrieved
693 acpi_ut_remove_reference (operand[0]);
694 operand[0] = temp_desc;
695 break;
697 case AML_REF_OF_OP:
699 /* Get the object to which the reference refers */
701 temp_desc = operand[0]->reference.object;
702 acpi_ut_remove_reference (operand[0]);
703 operand[0] = temp_desc;
704 break;
706 default:
708 /* Must be an Index op - handled below */
709 break;
711 break;
714 case ACPI_TYPE_STRING:
717 * This is a deref_of (String). The string is a reference to a named ACPI object.
719 * 1) Find the owning Node
720 * 2) Dereference the node to an actual object. Could be a Field, so we nee
721 * to resolve the node to a value.
723 status = acpi_ns_get_node_by_path (operand[0]->string.pointer,
724 walk_state->scope_info->scope.node, ACPI_NS_SEARCH_PARENT,
725 ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, &return_desc));
726 if (ACPI_FAILURE (status)) {
727 goto cleanup;
730 status = acpi_ex_resolve_node_to_value (
731 ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, &return_desc), walk_state);
732 goto cleanup;
735 default:
737 status = AE_AML_OPERAND_TYPE;
738 goto cleanup;
742 /* Operand[0] may have changed from the code above */
744 if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) == ACPI_DESC_TYPE_NAMED) {
746 * This is a deref_of (object_reference)
747 * Get the actual object from the Node (This is the dereference).
748 * -- This case may only happen when a local_x or arg_x is dereferenced above.
750 return_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) operand[0]);
752 else {
754 * This must be a reference object produced by either the Index() or
755 * ref_of() operator
757 switch (operand[0]->reference.opcode) {
758 case AML_INDEX_OP:
761 * The target type for the Index operator must be
762 * either a Buffer or a Package
764 switch (operand[0]->reference.target_type) {
765 case ACPI_TYPE_BUFFER_FIELD:
767 temp_desc = operand[0]->reference.object;
770 * Create a new object that contains one element of the
771 * buffer -- the element pointed to by the index.
773 * NOTE: index into a buffer is NOT a pointer to a
774 * sub-buffer of the main buffer, it is only a pointer to a
775 * single element (byte) of the buffer!
777 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
778 if (!return_desc) {
779 status = AE_NO_MEMORY;
780 goto cleanup;
784 * Since we are returning the value of the buffer at the
785 * indexed location, we don't need to add an additional
786 * reference to the buffer itself.
788 return_desc->integer.value =
789 temp_desc->buffer.pointer[operand[0]->reference.offset];
790 break;
793 case ACPI_TYPE_PACKAGE:
796 * Return the referenced element of the package. We must add
797 * another reference to the referenced object, however.
799 return_desc = *(operand[0]->reference.where);
800 if (!return_desc) {
802 * We can't return a NULL dereferenced value. This is
803 * an uninitialized package element and is thus a
804 * severe error.
806 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "NULL package element obj %p\n",
807 operand[0]));
808 status = AE_AML_UNINITIALIZED_ELEMENT;
809 goto cleanup;
812 acpi_ut_add_reference (return_desc);
813 break;
816 default:
818 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Index target_type %X in obj %p\n",
819 operand[0]->reference.target_type, operand[0]));
820 status = AE_AML_OPERAND_TYPE;
821 goto cleanup;
823 break;
826 case AML_REF_OF_OP:
828 return_desc = operand[0]->reference.object;
830 if (ACPI_GET_DESCRIPTOR_TYPE (return_desc) == ACPI_DESC_TYPE_NAMED) {
832 return_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) return_desc);
835 /* Add another reference to the object! */
837 acpi_ut_add_reference (return_desc);
838 break;
841 default:
842 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode in ref(%p) - %X\n",
843 operand[0], operand[0]->reference.opcode));
845 status = AE_TYPE;
846 goto cleanup;
849 break;
852 default:
854 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_0T_1R: Unknown opcode %X\n",
855 walk_state->opcode));
856 status = AE_AML_BAD_OPCODE;
857 goto cleanup;
861 cleanup:
863 /* Delete return object on error */
865 if (ACPI_FAILURE (status)) {
866 acpi_ut_remove_reference (return_desc);
869 walk_state->result_obj = return_desc;
870 return_ACPI_STATUS (status);