2 /******************************************************************************
4 * Module Name: exoparg1 - AML execution - opcodes with 1 argument
6 *****************************************************************************/
9 * Copyright (C) 2000 - 2005, 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
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.
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")
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
69 * xA - ARGUMENTS: The number of arguments (input operands) that are
70 * required for this opcode type (0 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.
80 /*******************************************************************************
82 * FUNCTION: acpi_ex_opcode_0A_0T_1R
84 * PARAMETERS: walk_state - Current state (contains AML opcode)
88 * DESCRIPTION: Execute operator with no operands, one return value
90 ******************************************************************************/
93 acpi_ex_opcode_0A_0T_1R (
94 struct acpi_walk_state *walk_state)
96 acpi_status status = AE_OK;
97 union acpi_operand_object *return_desc = NULL;
100 ACPI_FUNCTION_TRACE_STR ("ex_opcode_0A_0T_1R",
101 acpi_ps_get_opcode_name (walk_state->opcode));
104 /* Examine the AML opcode */
106 switch (walk_state->opcode) {
107 case AML_TIMER_OP: /* Timer () */
109 /* Create a return object of type Integer */
111 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
113 status = AE_NO_MEMORY;
117 return_desc->integer.value = acpi_os_get_timer ();
120 default: /* Unknown opcode */
122 ACPI_REPORT_ERROR (("acpi_ex_opcode_0A_0T_1R: Unknown opcode %X\n",
123 walk_state->opcode));
124 status = AE_AML_BAD_OPCODE;
130 /* Delete return object on error */
132 if ((ACPI_FAILURE (status)) || walk_state->result_obj) {
133 acpi_ut_remove_reference (return_desc);
136 /* Save the return value */
138 walk_state->result_obj = return_desc;
141 return_ACPI_STATUS (status);
145 /*******************************************************************************
147 * FUNCTION: acpi_ex_opcode_1A_0T_0R
149 * PARAMETERS: walk_state - Current state (contains AML opcode)
153 * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
156 ******************************************************************************/
159 acpi_ex_opcode_1A_0T_0R (
160 struct acpi_walk_state *walk_state)
162 union acpi_operand_object **operand = &walk_state->operands[0];
163 acpi_status status = AE_OK;
166 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_0R",
167 acpi_ps_get_opcode_name (walk_state->opcode));
170 /* Examine the AML opcode */
172 switch (walk_state->opcode) {
173 case AML_RELEASE_OP: /* Release (mutex_object) */
175 status = acpi_ex_release_mutex (operand[0], walk_state);
179 case AML_RESET_OP: /* Reset (event_object) */
181 status = acpi_ex_system_reset_event (operand[0]);
185 case AML_SIGNAL_OP: /* Signal (event_object) */
187 status = acpi_ex_system_signal_event (operand[0]);
191 case AML_SLEEP_OP: /* Sleep (msec_time) */
193 status = acpi_ex_system_do_suspend (operand[0]->integer.value);
197 case AML_STALL_OP: /* Stall (usec_time) */
199 status = acpi_ex_system_do_stall ((u32) operand[0]->integer.value);
203 case AML_UNLOAD_OP: /* Unload (Handle) */
205 status = acpi_ex_unload_table (operand[0]);
209 default: /* Unknown opcode */
211 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n",
212 walk_state->opcode));
213 status = AE_AML_BAD_OPCODE;
217 return_ACPI_STATUS (status);
221 /*******************************************************************************
223 * FUNCTION: acpi_ex_opcode_1A_1T_0R
225 * PARAMETERS: walk_state - Current state (contains AML opcode)
229 * DESCRIPTION: Execute opcode with one argument, one target, and no
232 ******************************************************************************/
235 acpi_ex_opcode_1A_1T_0R (
236 struct acpi_walk_state *walk_state)
238 acpi_status status = AE_OK;
239 union acpi_operand_object **operand = &walk_state->operands[0];
242 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_0R",
243 acpi_ps_get_opcode_name (walk_state->opcode));
246 /* Examine the AML opcode */
248 switch (walk_state->opcode) {
251 status = acpi_ex_load_op (operand[0], operand[1], walk_state);
254 default: /* Unknown opcode */
256 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n",
257 walk_state->opcode));
258 status = AE_AML_BAD_OPCODE;
265 return_ACPI_STATUS (status);
269 /*******************************************************************************
271 * FUNCTION: acpi_ex_opcode_1A_1T_1R
273 * PARAMETERS: walk_state - Current state (contains AML opcode)
277 * DESCRIPTION: Execute opcode with one argument, one target, and a
280 ******************************************************************************/
283 acpi_ex_opcode_1A_1T_1R (
284 struct acpi_walk_state *walk_state)
286 acpi_status status = AE_OK;
287 union acpi_operand_object **operand = &walk_state->operands[0];
288 union acpi_operand_object *return_desc = NULL;
289 union acpi_operand_object *return_desc2 = NULL;
292 acpi_integer power_of_ten;
296 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_1R",
297 acpi_ps_get_opcode_name (walk_state->opcode));
300 /* Examine the AML opcode */
302 switch (walk_state->opcode) {
304 case AML_FIND_SET_LEFT_BIT_OP:
305 case AML_FIND_SET_RIGHT_BIT_OP:
306 case AML_FROM_BCD_OP:
308 case AML_COND_REF_OF_OP:
310 /* Create a return object of type Integer for these opcodes */
312 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
314 status = AE_NO_MEMORY;
318 switch (walk_state->opcode) {
319 case AML_BIT_NOT_OP: /* Not (Operand, Result) */
321 return_desc->integer.value = ~operand[0]->integer.value;
325 case AML_FIND_SET_LEFT_BIT_OP: /* find_set_left_bit (Operand, Result) */
327 return_desc->integer.value = operand[0]->integer.value;
330 * Acpi specification describes Integer type as a little
331 * endian unsigned value, so this boundary condition is valid.
333 for (temp32 = 0; return_desc->integer.value &&
334 temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
335 return_desc->integer.value >>= 1;
338 return_desc->integer.value = temp32;
342 case AML_FIND_SET_RIGHT_BIT_OP: /* find_set_right_bit (Operand, Result) */
344 return_desc->integer.value = operand[0]->integer.value;
347 * The Acpi specification describes Integer type as a little
348 * endian unsigned value, so this boundary condition is valid.
350 for (temp32 = 0; return_desc->integer.value &&
351 temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
352 return_desc->integer.value <<= 1;
355 /* Since the bit position is one-based, subtract from 33 (65) */
357 return_desc->integer.value = temp32 == 0 ? 0 :
358 (ACPI_INTEGER_BIT_SIZE + 1) - temp32;
362 case AML_FROM_BCD_OP: /* from_bcd (BCDValue, Result) */
365 * The 64-bit ACPI integer can hold 16 4-bit BCD characters
366 * (if table is 32-bit, integer can hold 8 BCD characters)
367 * Convert each 4-bit BCD value
370 return_desc->integer.value = 0;
371 digit = operand[0]->integer.value;
373 /* Convert each BCD digit (each is one nybble wide) */
375 for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) {
376 /* Get the least significant 4-bit BCD digit */
378 temp32 = ((u32) digit) & 0xF;
380 /* Check the range of the digit */
383 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
384 "BCD digit too large (not decimal): 0x%X\n",
387 status = AE_AML_NUMERIC_OVERFLOW;
391 /* Sum the digit into the result with the current power of 10 */
393 return_desc->integer.value += (((acpi_integer) temp32) *
396 /* Shift to next BCD digit */
400 /* Next power of 10 */
407 case AML_TO_BCD_OP: /* to_bcd (Operand, Result) */
409 return_desc->integer.value = 0;
410 digit = operand[0]->integer.value;
412 /* Each BCD digit is one nybble wide */
414 for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) {
415 (void) acpi_ut_short_divide (digit, 10, &digit, &temp32);
418 * Insert the BCD digit that resides in the
419 * remainder from above
421 return_desc->integer.value |= (((acpi_integer) temp32) <<
425 /* Overflow if there is any data left in Digit */
428 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
429 "Integer too large to convert to BCD: %8.8X%8.8X\n",
430 ACPI_FORMAT_UINT64 (operand[0]->integer.value)));
431 status = AE_AML_NUMERIC_OVERFLOW;
437 case AML_COND_REF_OF_OP: /* cond_ref_of (source_object, Result) */
440 * This op is a little strange because the internal return value is
441 * different than the return value stored in the result descriptor
442 * (There are really two return values)
444 if ((struct acpi_namespace_node *) operand[0] == acpi_gbl_root_node) {
446 * This means that the object does not exist in the namespace,
449 return_desc->integer.value = 0;
453 /* Get the object reference, store it, and remove our reference */
455 status = acpi_ex_get_object_reference (operand[0],
456 &return_desc2, walk_state);
457 if (ACPI_FAILURE (status)) {
461 status = acpi_ex_store (return_desc2, operand[1], walk_state);
462 acpi_ut_remove_reference (return_desc2);
464 /* The object exists in the namespace, return TRUE */
466 return_desc->integer.value = ACPI_INTEGER_MAX;
471 /* No other opcodes get here */
477 case AML_STORE_OP: /* Store (Source, Target) */
480 * A store operand is typically a number, string, buffer or lvalue
481 * Be careful about deleting the source object,
482 * since the object itself may have been stored.
484 status = acpi_ex_store (operand[0], operand[1], walk_state);
485 if (ACPI_FAILURE (status)) {
486 return_ACPI_STATUS (status);
489 /* It is possible that the Store already produced a return object */
491 if (!walk_state->result_obj) {
493 * Normally, we would remove a reference on the Operand[0]
494 * parameter; But since it is being used as the internal return
495 * object (meaning we would normally increment it), the two
496 * cancel out, and we simply don't do anything.
498 walk_state->result_obj = operand[0];
499 walk_state->operands[0] = NULL; /* Prevent deletion */
501 return_ACPI_STATUS (status);
507 case AML_COPY_OP: /* Copy (Source, Target) */
509 status = acpi_ut_copy_iobject_to_iobject (operand[0], &return_desc,
514 case AML_TO_DECSTRING_OP: /* to_decimal_string (Data, Result) */
516 status = acpi_ex_convert_to_string (operand[0], &return_desc,
517 ACPI_EXPLICIT_CONVERT_DECIMAL);
518 if (return_desc == operand[0]) {
519 /* No conversion performed, add ref to handle return value */
520 acpi_ut_add_reference (return_desc);
525 case AML_TO_HEXSTRING_OP: /* to_hex_string (Data, Result) */
527 status = acpi_ex_convert_to_string (operand[0], &return_desc,
528 ACPI_EXPLICIT_CONVERT_HEX);
529 if (return_desc == operand[0]) {
530 /* No conversion performed, add ref to handle return value */
531 acpi_ut_add_reference (return_desc);
536 case AML_TO_BUFFER_OP: /* to_buffer (Data, Result) */
538 status = acpi_ex_convert_to_buffer (operand[0], &return_desc);
539 if (return_desc == operand[0]) {
540 /* No conversion performed, add ref to handle return value */
541 acpi_ut_add_reference (return_desc);
546 case AML_TO_INTEGER_OP: /* to_integer (Data, Result) */
548 status = acpi_ex_convert_to_integer (operand[0], &return_desc,
550 if (return_desc == operand[0]) {
551 /* No conversion performed, add ref to handle return value */
552 acpi_ut_add_reference (return_desc);
557 case AML_SHIFT_LEFT_BIT_OP: /* shift_left_bit (Source, bit_num) */
558 case AML_SHIFT_RIGHT_BIT_OP: /* shift_right_bit (Source, bit_num) */
560 /* These are two obsolete opcodes */
562 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
563 "%s is obsolete and not implemented\n",
564 acpi_ps_get_opcode_name (walk_state->opcode)));
569 default: /* Unknown opcode */
571 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n",
572 walk_state->opcode));
573 status = AE_AML_BAD_OPCODE;
577 if (ACPI_SUCCESS (status)) {
578 /* Store the return value computed above into the target object */
580 status = acpi_ex_store (return_desc, operand[1], walk_state);
586 if (!walk_state->result_obj) {
587 walk_state->result_obj = return_desc;
590 /* Delete return object on error */
592 if (ACPI_FAILURE (status)) {
593 acpi_ut_remove_reference (return_desc);
596 return_ACPI_STATUS (status);
600 /*******************************************************************************
602 * FUNCTION: acpi_ex_opcode_1A_0T_1R
604 * PARAMETERS: walk_state - Current state (contains AML opcode)
608 * DESCRIPTION: Execute opcode with one argument, no target, and a return value
610 ******************************************************************************/
613 acpi_ex_opcode_1A_0T_1R (
614 struct acpi_walk_state *walk_state)
616 union acpi_operand_object **operand = &walk_state->operands[0];
617 union acpi_operand_object *temp_desc;
618 union acpi_operand_object *return_desc = NULL;
619 acpi_status status = AE_OK;
624 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_1R",
625 acpi_ps_get_opcode_name (walk_state->opcode));
628 /* Examine the AML opcode */
630 switch (walk_state->opcode) {
631 case AML_LNOT_OP: /* LNot (Operand) */
633 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
635 status = AE_NO_MEMORY;
640 * Set result to ONES (TRUE) if Value == 0. Note:
641 * return_desc->Integer.Value is initially == 0 (FALSE) from above.
643 if (!operand[0]->integer.value) {
644 return_desc->integer.value = ACPI_INTEGER_MAX;
649 case AML_DECREMENT_OP: /* Decrement (Operand) */
650 case AML_INCREMENT_OP: /* Increment (Operand) */
653 * Create a new integer. Can't just get the base integer and
654 * increment it because it may be an Arg or Field.
656 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
658 status = AE_NO_MEMORY;
663 * Since we are expecting a Reference operand, it can be either a
664 * NS Node or an internal object.
666 temp_desc = operand[0];
667 if (ACPI_GET_DESCRIPTOR_TYPE (temp_desc) == ACPI_DESC_TYPE_OPERAND) {
668 /* Internal reference object - prevent deletion */
670 acpi_ut_add_reference (temp_desc);
674 * Convert the Reference operand to an Integer (This removes a
675 * reference on the Operand[0] object)
677 * NOTE: We use LNOT_OP here in order to force resolution of the
678 * reference operand to an actual integer.
680 status = acpi_ex_resolve_operands (AML_LNOT_OP, &temp_desc, walk_state);
681 if (ACPI_FAILURE (status)) {
682 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s: bad operand(s) %s\n",
683 acpi_ps_get_opcode_name (walk_state->opcode),
684 acpi_format_exception(status)));
690 * temp_desc is now guaranteed to be an Integer object --
691 * Perform the actual increment or decrement
693 if (walk_state->opcode == AML_INCREMENT_OP) {
694 return_desc->integer.value = temp_desc->integer.value +1;
697 return_desc->integer.value = temp_desc->integer.value -1;
700 /* Finished with this Integer object */
702 acpi_ut_remove_reference (temp_desc);
705 * Store the result back (indirectly) through the original
708 status = acpi_ex_store (return_desc, operand[0], walk_state);
712 case AML_TYPE_OP: /* object_type (source_object) */
715 * Note: The operand is not resolved at this point because we want to
716 * get the associated object, not its value. For example, we don't
717 * want to resolve a field_unit to its value, we want the actual
721 /* Get the type of the base object */
723 status = acpi_ex_resolve_multiple (walk_state, operand[0], &type, NULL);
724 if (ACPI_FAILURE (status)) {
727 /* Allocate a descriptor to hold the type. */
729 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
731 status = AE_NO_MEMORY;
735 return_desc->integer.value = type;
739 case AML_SIZE_OF_OP: /* size_of (source_object) */
742 * Note: The operand is not resolved at this point because we want to
743 * get the associated object, not its value.
746 /* Get the base object */
748 status = acpi_ex_resolve_multiple (walk_state,
749 operand[0], &type, &temp_desc);
750 if (ACPI_FAILURE (status)) {
755 * The type of the base object must be integer, buffer, string, or
756 * package. All others are not supported.
758 * NOTE: Integer is not specifically supported by the ACPI spec,
759 * but is supported implicitly via implicit operand conversion.
760 * rather than bother with conversion, we just use the byte width
761 * global (4 or 8 bytes).
764 case ACPI_TYPE_INTEGER:
765 value = acpi_gbl_integer_byte_width;
768 case ACPI_TYPE_BUFFER:
769 value = temp_desc->buffer.length;
772 case ACPI_TYPE_STRING:
773 value = temp_desc->string.length;
776 case ACPI_TYPE_PACKAGE:
777 value = temp_desc->package.count;
781 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
782 "size_of - Operand is not Buf/Int/Str/Pkg - found type %s\n",
783 acpi_ut_get_type_name (type)));
784 status = AE_AML_OPERAND_TYPE;
789 * Now that we have the size of the object, create a result
790 * object to hold the value
792 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
794 status = AE_NO_MEMORY;
798 return_desc->integer.value = value;
802 case AML_REF_OF_OP: /* ref_of (source_object) */
804 status = acpi_ex_get_object_reference (operand[0], &return_desc, walk_state);
805 if (ACPI_FAILURE (status)) {
811 case AML_DEREF_OF_OP: /* deref_of (obj_reference | String) */
813 /* Check for a method local or argument, or standalone String */
815 if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) != ACPI_DESC_TYPE_NAMED) {
816 switch (ACPI_GET_OBJECT_TYPE (operand[0])) {
817 case ACPI_TYPE_LOCAL_REFERENCE:
819 * This is a deref_of (local_x | arg_x)
821 * Must resolve/dereference the local/arg reference first
823 switch (operand[0]->reference.opcode) {
827 /* Set Operand[0] to the value of the local/arg */
829 status = acpi_ds_method_data_get_value (
830 operand[0]->reference.opcode,
831 operand[0]->reference.offset,
832 walk_state, &temp_desc);
833 if (ACPI_FAILURE (status)) {
838 * Delete our reference to the input object and
839 * point to the object just retrieved
841 acpi_ut_remove_reference (operand[0]);
842 operand[0] = temp_desc;
847 /* Get the object to which the reference refers */
849 temp_desc = operand[0]->reference.object;
850 acpi_ut_remove_reference (operand[0]);
851 operand[0] = temp_desc;
856 /* Must be an Index op - handled below */
862 case ACPI_TYPE_STRING:
865 * This is a deref_of (String). The string is a reference
866 * to a named ACPI object.
868 * 1) Find the owning Node
869 * 2) Dereference the node to an actual object. Could be a
870 * Field, so we need to resolve the node to a value.
872 status = acpi_ns_get_node_by_path (operand[0]->string.pointer,
873 walk_state->scope_info->scope.node,
874 ACPI_NS_SEARCH_PARENT,
875 ACPI_CAST_INDIRECT_PTR (
876 struct acpi_namespace_node, &return_desc));
877 if (ACPI_FAILURE (status)) {
881 status = acpi_ex_resolve_node_to_value (
882 ACPI_CAST_INDIRECT_PTR (
883 struct acpi_namespace_node, &return_desc),
890 status = AE_AML_OPERAND_TYPE;
895 /* Operand[0] may have changed from the code above */
897 if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) == ACPI_DESC_TYPE_NAMED) {
899 * This is a deref_of (object_reference)
900 * Get the actual object from the Node (This is the dereference).
901 * This case may only happen when a local_x or arg_x is
902 * dereferenced above.
904 return_desc = acpi_ns_get_attached_object (
905 (struct acpi_namespace_node *) operand[0]);
909 * This must be a reference object produced by either the
910 * Index() or ref_of() operator
912 switch (operand[0]->reference.opcode) {
916 * The target type for the Index operator must be
917 * either a Buffer or a Package
919 switch (operand[0]->reference.target_type) {
920 case ACPI_TYPE_BUFFER_FIELD:
922 temp_desc = operand[0]->reference.object;
925 * Create a new object that contains one element of the
926 * buffer -- the element pointed to by the index.
928 * NOTE: index into a buffer is NOT a pointer to a
929 * sub-buffer of the main buffer, it is only a pointer to a
930 * single element (byte) of the buffer!
932 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
934 status = AE_NO_MEMORY;
939 * Since we are returning the value of the buffer at the
940 * indexed location, we don't need to add an additional
941 * reference to the buffer itself.
943 return_desc->integer.value =
944 temp_desc->buffer.pointer[operand[0]->reference.offset];
948 case ACPI_TYPE_PACKAGE:
951 * Return the referenced element of the package. We must
952 * add another reference to the referenced object, however.
954 return_desc = *(operand[0]->reference.where);
957 * We can't return a NULL dereferenced value. This is
958 * an uninitialized package element and is thus a
961 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
962 "NULL package element obj %p\n",
964 status = AE_AML_UNINITIALIZED_ELEMENT;
968 acpi_ut_add_reference (return_desc);
974 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
975 "Unknown Index target_type %X in obj %p\n",
976 operand[0]->reference.target_type, operand[0]));
977 status = AE_AML_OPERAND_TYPE;
985 return_desc = operand[0]->reference.object;
987 if (ACPI_GET_DESCRIPTOR_TYPE (return_desc) ==
988 ACPI_DESC_TYPE_NAMED) {
990 return_desc = acpi_ns_get_attached_object (
991 (struct acpi_namespace_node *) return_desc);
994 /* Add another reference to the object! */
996 acpi_ut_add_reference (return_desc);
1001 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
1002 "Unknown opcode in ref(%p) - %X\n",
1003 operand[0], operand[0]->reference.opcode));
1014 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_0T_1R: Unknown opcode %X\n",
1015 walk_state->opcode));
1016 status = AE_AML_BAD_OPCODE;
1023 /* Delete return object on error */
1025 if (ACPI_FAILURE (status)) {
1026 acpi_ut_remove_reference (return_desc);
1029 walk_state->result_obj = return_desc;
1030 return_ACPI_STATUS (status);