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 if (!walk_state->result_obj) {
131 walk_state->result_obj = return_desc;
134 /* Delete return object on error */
136 if (ACPI_FAILURE (status)) {
137 acpi_ut_remove_reference (return_desc);
140 return_ACPI_STATUS (status);
144 /*******************************************************************************
146 * FUNCTION: acpi_ex_opcode_1A_0T_0R
148 * PARAMETERS: walk_state - Current state (contains AML opcode)
152 * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
155 ******************************************************************************/
158 acpi_ex_opcode_1A_0T_0R (
159 struct acpi_walk_state *walk_state)
161 union acpi_operand_object **operand = &walk_state->operands[0];
162 acpi_status status = AE_OK;
165 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_0R",
166 acpi_ps_get_opcode_name (walk_state->opcode));
169 /* Examine the AML opcode */
171 switch (walk_state->opcode) {
172 case AML_RELEASE_OP: /* Release (mutex_object) */
174 status = acpi_ex_release_mutex (operand[0], walk_state);
178 case AML_RESET_OP: /* Reset (event_object) */
180 status = acpi_ex_system_reset_event (operand[0]);
184 case AML_SIGNAL_OP: /* Signal (event_object) */
186 status = acpi_ex_system_signal_event (operand[0]);
190 case AML_SLEEP_OP: /* Sleep (msec_time) */
192 status = acpi_ex_system_do_suspend (operand[0]->integer.value);
196 case AML_STALL_OP: /* Stall (usec_time) */
198 status = acpi_ex_system_do_stall ((u32) operand[0]->integer.value);
202 case AML_UNLOAD_OP: /* Unload (Handle) */
204 status = acpi_ex_unload_table (operand[0]);
208 default: /* Unknown opcode */
210 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n",
211 walk_state->opcode));
212 status = AE_AML_BAD_OPCODE;
216 return_ACPI_STATUS (status);
220 /*******************************************************************************
222 * FUNCTION: acpi_ex_opcode_1A_1T_0R
224 * PARAMETERS: walk_state - Current state (contains AML opcode)
228 * DESCRIPTION: Execute opcode with one argument, one target, and no
231 ******************************************************************************/
234 acpi_ex_opcode_1A_1T_0R (
235 struct acpi_walk_state *walk_state)
237 acpi_status status = AE_OK;
238 union acpi_operand_object **operand = &walk_state->operands[0];
241 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_0R",
242 acpi_ps_get_opcode_name (walk_state->opcode));
245 /* Examine the AML opcode */
247 switch (walk_state->opcode) {
250 status = acpi_ex_load_op (operand[0], operand[1], walk_state);
253 default: /* Unknown opcode */
255 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n",
256 walk_state->opcode));
257 status = AE_AML_BAD_OPCODE;
264 return_ACPI_STATUS (status);
268 /*******************************************************************************
270 * FUNCTION: acpi_ex_opcode_1A_1T_1R
272 * PARAMETERS: walk_state - Current state (contains AML opcode)
276 * DESCRIPTION: Execute opcode with one argument, one target, and a
279 ******************************************************************************/
282 acpi_ex_opcode_1A_1T_1R (
283 struct acpi_walk_state *walk_state)
285 acpi_status status = AE_OK;
286 union acpi_operand_object **operand = &walk_state->operands[0];
287 union acpi_operand_object *return_desc = NULL;
288 union acpi_operand_object *return_desc2 = NULL;
291 acpi_integer power_of_ten;
295 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_1R",
296 acpi_ps_get_opcode_name (walk_state->opcode));
299 /* Examine the AML opcode */
301 switch (walk_state->opcode) {
303 case AML_FIND_SET_LEFT_BIT_OP:
304 case AML_FIND_SET_RIGHT_BIT_OP:
305 case AML_FROM_BCD_OP:
307 case AML_COND_REF_OF_OP:
309 /* Create a return object of type Integer for these opcodes */
311 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
313 status = AE_NO_MEMORY;
317 switch (walk_state->opcode) {
318 case AML_BIT_NOT_OP: /* Not (Operand, Result) */
320 return_desc->integer.value = ~operand[0]->integer.value;
324 case AML_FIND_SET_LEFT_BIT_OP: /* find_set_left_bit (Operand, Result) */
326 return_desc->integer.value = operand[0]->integer.value;
329 * Acpi specification describes Integer type as a little
330 * endian unsigned value, so this boundary condition is valid.
332 for (temp32 = 0; return_desc->integer.value &&
333 temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
334 return_desc->integer.value >>= 1;
337 return_desc->integer.value = temp32;
341 case AML_FIND_SET_RIGHT_BIT_OP: /* find_set_right_bit (Operand, Result) */
343 return_desc->integer.value = operand[0]->integer.value;
346 * The Acpi specification describes Integer type as a little
347 * endian unsigned value, so this boundary condition is valid.
349 for (temp32 = 0; return_desc->integer.value &&
350 temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
351 return_desc->integer.value <<= 1;
354 /* Since the bit position is one-based, subtract from 33 (65) */
356 return_desc->integer.value = temp32 == 0 ? 0 :
357 (ACPI_INTEGER_BIT_SIZE + 1) - temp32;
361 case AML_FROM_BCD_OP: /* from_bcd (BCDValue, Result) */
364 * The 64-bit ACPI integer can hold 16 4-bit BCD characters
365 * (if table is 32-bit, integer can hold 8 BCD characters)
366 * Convert each 4-bit BCD value
369 return_desc->integer.value = 0;
370 digit = operand[0]->integer.value;
372 /* Convert each BCD digit (each is one nybble wide) */
374 for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) {
375 /* Get the least significant 4-bit BCD digit */
377 temp32 = ((u32) digit) & 0xF;
379 /* Check the range of the digit */
382 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
383 "BCD digit too large (not decimal): 0x%X\n",
386 status = AE_AML_NUMERIC_OVERFLOW;
390 /* Sum the digit into the result with the current power of 10 */
392 return_desc->integer.value += (((acpi_integer) temp32) *
395 /* Shift to next BCD digit */
399 /* Next power of 10 */
406 case AML_TO_BCD_OP: /* to_bcd (Operand, Result) */
408 return_desc->integer.value = 0;
409 digit = operand[0]->integer.value;
411 /* Each BCD digit is one nybble wide */
413 for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) {
414 (void) acpi_ut_short_divide (digit, 10, &digit, &temp32);
417 * Insert the BCD digit that resides in the
418 * remainder from above
420 return_desc->integer.value |= (((acpi_integer) temp32) <<
424 /* Overflow if there is any data left in Digit */
427 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
428 "Integer too large to convert to BCD: %8.8X%8.8X\n",
429 ACPI_FORMAT_UINT64 (operand[0]->integer.value)));
430 status = AE_AML_NUMERIC_OVERFLOW;
436 case AML_COND_REF_OF_OP: /* cond_ref_of (source_object, Result) */
439 * This op is a little strange because the internal return value is
440 * different than the return value stored in the result descriptor
441 * (There are really two return values)
443 if ((struct acpi_namespace_node *) operand[0] == acpi_gbl_root_node) {
445 * This means that the object does not exist in the namespace,
448 return_desc->integer.value = 0;
452 /* Get the object reference, store it, and remove our reference */
454 status = acpi_ex_get_object_reference (operand[0],
455 &return_desc2, walk_state);
456 if (ACPI_FAILURE (status)) {
460 status = acpi_ex_store (return_desc2, operand[1], walk_state);
461 acpi_ut_remove_reference (return_desc2);
463 /* The object exists in the namespace, return TRUE */
465 return_desc->integer.value = ACPI_INTEGER_MAX;
470 /* No other opcodes get here */
476 case AML_STORE_OP: /* Store (Source, Target) */
479 * A store operand is typically a number, string, buffer or lvalue
480 * Be careful about deleting the source object,
481 * since the object itself may have been stored.
483 status = acpi_ex_store (operand[0], operand[1], walk_state);
484 if (ACPI_FAILURE (status)) {
485 return_ACPI_STATUS (status);
488 /* It is possible that the Store already produced a return object */
490 if (!walk_state->result_obj) {
492 * Normally, we would remove a reference on the Operand[0]
493 * parameter; But since it is being used as the internal return
494 * object (meaning we would normally increment it), the two
495 * cancel out, and we simply don't do anything.
497 walk_state->result_obj = operand[0];
498 walk_state->operands[0] = NULL; /* Prevent deletion */
500 return_ACPI_STATUS (status);
506 case AML_COPY_OP: /* Copy (Source, Target) */
508 status = acpi_ut_copy_iobject_to_iobject (operand[0], &return_desc,
513 case AML_TO_DECSTRING_OP: /* to_decimal_string (Data, Result) */
515 status = acpi_ex_convert_to_string (operand[0], &return_desc,
516 ACPI_EXPLICIT_CONVERT_DECIMAL);
517 if (return_desc == operand[0]) {
518 /* No conversion performed, add ref to handle return value */
519 acpi_ut_add_reference (return_desc);
524 case AML_TO_HEXSTRING_OP: /* to_hex_string (Data, Result) */
526 status = acpi_ex_convert_to_string (operand[0], &return_desc,
527 ACPI_EXPLICIT_CONVERT_HEX);
528 if (return_desc == operand[0]) {
529 /* No conversion performed, add ref to handle return value */
530 acpi_ut_add_reference (return_desc);
535 case AML_TO_BUFFER_OP: /* to_buffer (Data, Result) */
537 status = acpi_ex_convert_to_buffer (operand[0], &return_desc);
538 if (return_desc == operand[0]) {
539 /* No conversion performed, add ref to handle return value */
540 acpi_ut_add_reference (return_desc);
545 case AML_TO_INTEGER_OP: /* to_integer (Data, Result) */
547 status = acpi_ex_convert_to_integer (operand[0], &return_desc,
549 if (return_desc == operand[0]) {
550 /* No conversion performed, add ref to handle return value */
551 acpi_ut_add_reference (return_desc);
556 case AML_SHIFT_LEFT_BIT_OP: /* shift_left_bit (Source, bit_num) */
557 case AML_SHIFT_RIGHT_BIT_OP: /* shift_right_bit (Source, bit_num) */
559 /* These are two obsolete opcodes */
561 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
562 "%s is obsolete and not implemented\n",
563 acpi_ps_get_opcode_name (walk_state->opcode)));
568 default: /* Unknown opcode */
570 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n",
571 walk_state->opcode));
572 status = AE_AML_BAD_OPCODE;
576 if (ACPI_SUCCESS (status)) {
577 /* Store the return value computed above into the target object */
579 status = acpi_ex_store (return_desc, operand[1], walk_state);
585 if (!walk_state->result_obj) {
586 walk_state->result_obj = return_desc;
589 /* Delete return object on error */
591 if (ACPI_FAILURE (status)) {
592 acpi_ut_remove_reference (return_desc);
595 return_ACPI_STATUS (status);
599 /*******************************************************************************
601 * FUNCTION: acpi_ex_opcode_1A_0T_1R
603 * PARAMETERS: walk_state - Current state (contains AML opcode)
607 * DESCRIPTION: Execute opcode with one argument, no target, and a return value
609 ******************************************************************************/
612 acpi_ex_opcode_1A_0T_1R (
613 struct acpi_walk_state *walk_state)
615 union acpi_operand_object **operand = &walk_state->operands[0];
616 union acpi_operand_object *temp_desc;
617 union acpi_operand_object *return_desc = NULL;
618 acpi_status status = AE_OK;
623 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_1R",
624 acpi_ps_get_opcode_name (walk_state->opcode));
627 /* Examine the AML opcode */
629 switch (walk_state->opcode) {
630 case AML_LNOT_OP: /* LNot (Operand) */
632 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
634 status = AE_NO_MEMORY;
639 * Set result to ONES (TRUE) if Value == 0. Note:
640 * return_desc->Integer.Value is initially == 0 (FALSE) from above.
642 if (!operand[0]->integer.value) {
643 return_desc->integer.value = ACPI_INTEGER_MAX;
648 case AML_DECREMENT_OP: /* Decrement (Operand) */
649 case AML_INCREMENT_OP: /* Increment (Operand) */
652 * Create a new integer. Can't just get the base integer and
653 * increment it because it may be an Arg or Field.
655 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
657 status = AE_NO_MEMORY;
662 * Since we are expecting a Reference operand, it can be either a
663 * NS Node or an internal object.
665 temp_desc = operand[0];
666 if (ACPI_GET_DESCRIPTOR_TYPE (temp_desc) == ACPI_DESC_TYPE_OPERAND) {
667 /* Internal reference object - prevent deletion */
669 acpi_ut_add_reference (temp_desc);
673 * Convert the Reference operand to an Integer (This removes a
674 * reference on the Operand[0] object)
676 * NOTE: We use LNOT_OP here in order to force resolution of the
677 * reference operand to an actual integer.
679 status = acpi_ex_resolve_operands (AML_LNOT_OP, &temp_desc, walk_state);
680 if (ACPI_FAILURE (status)) {
681 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s: bad operand(s) %s\n",
682 acpi_ps_get_opcode_name (walk_state->opcode),
683 acpi_format_exception(status)));
689 * temp_desc is now guaranteed to be an Integer object --
690 * Perform the actual increment or decrement
692 if (walk_state->opcode == AML_INCREMENT_OP) {
693 return_desc->integer.value = temp_desc->integer.value +1;
696 return_desc->integer.value = temp_desc->integer.value -1;
699 /* Finished with this Integer object */
701 acpi_ut_remove_reference (temp_desc);
704 * Store the result back (indirectly) through the original
707 status = acpi_ex_store (return_desc, operand[0], walk_state);
711 case AML_TYPE_OP: /* object_type (source_object) */
714 * Note: The operand is not resolved at this point because we want to
715 * get the associated object, not its value. For example, we don't
716 * want to resolve a field_unit to its value, we want the actual
720 /* Get the type of the base object */
722 status = acpi_ex_resolve_multiple (walk_state, operand[0], &type, NULL);
723 if (ACPI_FAILURE (status)) {
726 /* Allocate a descriptor to hold the type. */
728 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
730 status = AE_NO_MEMORY;
734 return_desc->integer.value = type;
738 case AML_SIZE_OF_OP: /* size_of (source_object) */
741 * Note: The operand is not resolved at this point because we want to
742 * get the associated object, not its value.
745 /* Get the base object */
747 status = acpi_ex_resolve_multiple (walk_state,
748 operand[0], &type, &temp_desc);
749 if (ACPI_FAILURE (status)) {
754 * The type of the base object must be integer, buffer, string, or
755 * package. All others are not supported.
757 * NOTE: Integer is not specifically supported by the ACPI spec,
758 * but is supported implicitly via implicit operand conversion.
759 * rather than bother with conversion, we just use the byte width
760 * global (4 or 8 bytes).
763 case ACPI_TYPE_INTEGER:
764 value = acpi_gbl_integer_byte_width;
767 case ACPI_TYPE_BUFFER:
768 value = temp_desc->buffer.length;
771 case ACPI_TYPE_STRING:
772 value = temp_desc->string.length;
775 case ACPI_TYPE_PACKAGE:
776 value = temp_desc->package.count;
780 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
781 "size_of - Operand is not Buf/Int/Str/Pkg - found type %s\n",
782 acpi_ut_get_type_name (type)));
783 status = AE_AML_OPERAND_TYPE;
788 * Now that we have the size of the object, create a result
789 * object to hold the value
791 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
793 status = AE_NO_MEMORY;
797 return_desc->integer.value = value;
801 case AML_REF_OF_OP: /* ref_of (source_object) */
803 status = acpi_ex_get_object_reference (operand[0], &return_desc, walk_state);
804 if (ACPI_FAILURE (status)) {
810 case AML_DEREF_OF_OP: /* deref_of (obj_reference | String) */
812 /* Check for a method local or argument, or standalone String */
814 if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) != ACPI_DESC_TYPE_NAMED) {
815 switch (ACPI_GET_OBJECT_TYPE (operand[0])) {
816 case ACPI_TYPE_LOCAL_REFERENCE:
818 * This is a deref_of (local_x | arg_x)
820 * Must resolve/dereference the local/arg reference first
822 switch (operand[0]->reference.opcode) {
826 /* Set Operand[0] to the value of the local/arg */
828 status = acpi_ds_method_data_get_value (
829 operand[0]->reference.opcode,
830 operand[0]->reference.offset,
831 walk_state, &temp_desc);
832 if (ACPI_FAILURE (status)) {
837 * Delete our reference to the input object and
838 * point to the object just retrieved
840 acpi_ut_remove_reference (operand[0]);
841 operand[0] = temp_desc;
846 /* Get the object to which the reference refers */
848 temp_desc = operand[0]->reference.object;
849 acpi_ut_remove_reference (operand[0]);
850 operand[0] = temp_desc;
855 /* Must be an Index op - handled below */
861 case ACPI_TYPE_STRING:
864 * This is a deref_of (String). The string is a reference
865 * to a named ACPI object.
867 * 1) Find the owning Node
868 * 2) Dereference the node to an actual object. Could be a
869 * Field, so we need to resolve the node to a value.
871 status = acpi_ns_get_node_by_path (operand[0]->string.pointer,
872 walk_state->scope_info->scope.node,
873 ACPI_NS_SEARCH_PARENT,
874 ACPI_CAST_INDIRECT_PTR (
875 struct acpi_namespace_node, &return_desc));
876 if (ACPI_FAILURE (status)) {
880 status = acpi_ex_resolve_node_to_value (
881 ACPI_CAST_INDIRECT_PTR (
882 struct acpi_namespace_node, &return_desc),
889 status = AE_AML_OPERAND_TYPE;
894 /* Operand[0] may have changed from the code above */
896 if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) == ACPI_DESC_TYPE_NAMED) {
898 * This is a deref_of (object_reference)
899 * Get the actual object from the Node (This is the dereference).
900 * This case may only happen when a local_x or arg_x is
901 * dereferenced above.
903 return_desc = acpi_ns_get_attached_object (
904 (struct acpi_namespace_node *) operand[0]);
908 * This must be a reference object produced by either the
909 * Index() or ref_of() operator
911 switch (operand[0]->reference.opcode) {
915 * The target type for the Index operator must be
916 * either a Buffer or a Package
918 switch (operand[0]->reference.target_type) {
919 case ACPI_TYPE_BUFFER_FIELD:
921 temp_desc = operand[0]->reference.object;
924 * Create a new object that contains one element of the
925 * buffer -- the element pointed to by the index.
927 * NOTE: index into a buffer is NOT a pointer to a
928 * sub-buffer of the main buffer, it is only a pointer to a
929 * single element (byte) of the buffer!
931 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
933 status = AE_NO_MEMORY;
938 * Since we are returning the value of the buffer at the
939 * indexed location, we don't need to add an additional
940 * reference to the buffer itself.
942 return_desc->integer.value =
943 temp_desc->buffer.pointer[operand[0]->reference.offset];
947 case ACPI_TYPE_PACKAGE:
950 * Return the referenced element of the package. We must
951 * add another reference to the referenced object, however.
953 return_desc = *(operand[0]->reference.where);
956 * We can't return a NULL dereferenced value. This is
957 * an uninitialized package element and is thus a
960 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
961 "NULL package element obj %p\n",
963 status = AE_AML_UNINITIALIZED_ELEMENT;
967 acpi_ut_add_reference (return_desc);
973 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
974 "Unknown Index target_type %X in obj %p\n",
975 operand[0]->reference.target_type, operand[0]));
976 status = AE_AML_OPERAND_TYPE;
984 return_desc = operand[0]->reference.object;
986 if (ACPI_GET_DESCRIPTOR_TYPE (return_desc) ==
987 ACPI_DESC_TYPE_NAMED) {
989 return_desc = acpi_ns_get_attached_object (
990 (struct acpi_namespace_node *) return_desc);
993 /* Add another reference to the object! */
995 acpi_ut_add_reference (return_desc);
1000 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
1001 "Unknown opcode in ref(%p) - %X\n",
1002 operand[0], operand[0]->reference.opcode));
1013 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_0T_1R: Unknown opcode %X\n",
1014 walk_state->opcode));
1015 status = AE_AML_BAD_OPCODE;
1022 /* Delete return object on error */
1024 if (ACPI_FAILURE (status)) {
1025 acpi_ut_remove_reference (return_desc);
1028 walk_state->result_obj = return_desc;
1029 return_ACPI_STATUS (status);