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;
116 #if ACPI_MACHINE_WIDTH != 16
117 return_desc->integer.value = acpi_os_get_timer ();
121 default: /* Unknown opcode */
123 ACPI_REPORT_ERROR (("acpi_ex_opcode_0A_0T_1R: Unknown opcode %X\n",
124 walk_state->opcode));
125 status = AE_AML_BAD_OPCODE;
131 /* Delete return object on error */
133 if ((ACPI_FAILURE (status)) || walk_state->result_obj) {
134 acpi_ut_remove_reference (return_desc);
137 /* Save the return value */
139 walk_state->result_obj = return_desc;
142 return_ACPI_STATUS (status);
146 /*******************************************************************************
148 * FUNCTION: acpi_ex_opcode_1A_0T_0R
150 * PARAMETERS: walk_state - Current state (contains AML opcode)
154 * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
157 ******************************************************************************/
160 acpi_ex_opcode_1A_0T_0R (
161 struct acpi_walk_state *walk_state)
163 union acpi_operand_object **operand = &walk_state->operands[0];
164 acpi_status status = AE_OK;
167 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_0R",
168 acpi_ps_get_opcode_name (walk_state->opcode));
171 /* Examine the AML opcode */
173 switch (walk_state->opcode) {
174 case AML_RELEASE_OP: /* Release (mutex_object) */
176 status = acpi_ex_release_mutex (operand[0], walk_state);
180 case AML_RESET_OP: /* Reset (event_object) */
182 status = acpi_ex_system_reset_event (operand[0]);
186 case AML_SIGNAL_OP: /* Signal (event_object) */
188 status = acpi_ex_system_signal_event (operand[0]);
192 case AML_SLEEP_OP: /* Sleep (msec_time) */
194 status = acpi_ex_system_do_suspend (operand[0]->integer.value);
198 case AML_STALL_OP: /* Stall (usec_time) */
200 status = acpi_ex_system_do_stall ((u32) operand[0]->integer.value);
204 case AML_UNLOAD_OP: /* Unload (Handle) */
206 status = acpi_ex_unload_table (operand[0]);
210 default: /* Unknown opcode */
212 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n",
213 walk_state->opcode));
214 status = AE_AML_BAD_OPCODE;
218 return_ACPI_STATUS (status);
222 /*******************************************************************************
224 * FUNCTION: acpi_ex_opcode_1A_1T_0R
226 * PARAMETERS: walk_state - Current state (contains AML opcode)
230 * DESCRIPTION: Execute opcode with one argument, one target, and no
233 ******************************************************************************/
236 acpi_ex_opcode_1A_1T_0R (
237 struct acpi_walk_state *walk_state)
239 acpi_status status = AE_OK;
240 union acpi_operand_object **operand = &walk_state->operands[0];
243 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_0R",
244 acpi_ps_get_opcode_name (walk_state->opcode));
247 /* Examine the AML opcode */
249 switch (walk_state->opcode) {
252 status = acpi_ex_load_op (operand[0], operand[1], walk_state);
255 default: /* Unknown opcode */
257 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n",
258 walk_state->opcode));
259 status = AE_AML_BAD_OPCODE;
266 return_ACPI_STATUS (status);
270 /*******************************************************************************
272 * FUNCTION: acpi_ex_opcode_1A_1T_1R
274 * PARAMETERS: walk_state - Current state (contains AML opcode)
278 * DESCRIPTION: Execute opcode with one argument, one target, and a
281 ******************************************************************************/
284 acpi_ex_opcode_1A_1T_1R (
285 struct acpi_walk_state *walk_state)
287 acpi_status status = AE_OK;
288 union acpi_operand_object **operand = &walk_state->operands[0];
289 union acpi_operand_object *return_desc = NULL;
290 union acpi_operand_object *return_desc2 = NULL;
293 acpi_integer power_of_ten;
297 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_1R",
298 acpi_ps_get_opcode_name (walk_state->opcode));
301 /* Examine the AML opcode */
303 switch (walk_state->opcode) {
305 case AML_FIND_SET_LEFT_BIT_OP:
306 case AML_FIND_SET_RIGHT_BIT_OP:
307 case AML_FROM_BCD_OP:
309 case AML_COND_REF_OF_OP:
311 /* Create a return object of type Integer for these opcodes */
313 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
315 status = AE_NO_MEMORY;
319 switch (walk_state->opcode) {
320 case AML_BIT_NOT_OP: /* Not (Operand, Result) */
322 return_desc->integer.value = ~operand[0]->integer.value;
326 case AML_FIND_SET_LEFT_BIT_OP: /* find_set_left_bit (Operand, Result) */
328 return_desc->integer.value = operand[0]->integer.value;
331 * Acpi specification describes Integer type as a little
332 * endian unsigned value, so this boundary condition is valid.
334 for (temp32 = 0; return_desc->integer.value &&
335 temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
336 return_desc->integer.value >>= 1;
339 return_desc->integer.value = temp32;
343 case AML_FIND_SET_RIGHT_BIT_OP: /* find_set_right_bit (Operand, Result) */
345 return_desc->integer.value = operand[0]->integer.value;
348 * The Acpi specification describes Integer type as a little
349 * endian unsigned value, so this boundary condition is valid.
351 for (temp32 = 0; return_desc->integer.value &&
352 temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
353 return_desc->integer.value <<= 1;
356 /* Since the bit position is one-based, subtract from 33 (65) */
358 return_desc->integer.value = temp32 == 0 ? 0 :
359 (ACPI_INTEGER_BIT_SIZE + 1) - temp32;
363 case AML_FROM_BCD_OP: /* from_bcd (BCDValue, Result) */
366 * The 64-bit ACPI integer can hold 16 4-bit BCD characters
367 * (if table is 32-bit, integer can hold 8 BCD characters)
368 * Convert each 4-bit BCD value
371 return_desc->integer.value = 0;
372 digit = operand[0]->integer.value;
374 /* Convert each BCD digit (each is one nybble wide) */
376 for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) {
377 /* Get the least significant 4-bit BCD digit */
379 temp32 = ((u32) digit) & 0xF;
381 /* Check the range of the digit */
384 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
385 "BCD digit too large (not decimal): 0x%X\n",
388 status = AE_AML_NUMERIC_OVERFLOW;
392 /* Sum the digit into the result with the current power of 10 */
394 return_desc->integer.value += (((acpi_integer) temp32) *
397 /* Shift to next BCD digit */
401 /* Next power of 10 */
408 case AML_TO_BCD_OP: /* to_bcd (Operand, Result) */
410 return_desc->integer.value = 0;
411 digit = operand[0]->integer.value;
413 /* Each BCD digit is one nybble wide */
415 for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) {
416 (void) acpi_ut_short_divide (digit, 10, &digit, &temp32);
419 * Insert the BCD digit that resides in the
420 * remainder from above
422 return_desc->integer.value |= (((acpi_integer) temp32) <<
426 /* Overflow if there is any data left in Digit */
429 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
430 "Integer too large to convert to BCD: %8.8X%8.8X\n",
431 ACPI_FORMAT_UINT64 (operand[0]->integer.value)));
432 status = AE_AML_NUMERIC_OVERFLOW;
438 case AML_COND_REF_OF_OP: /* cond_ref_of (source_object, Result) */
441 * This op is a little strange because the internal return value is
442 * different than the return value stored in the result descriptor
443 * (There are really two return values)
445 if ((struct acpi_namespace_node *) operand[0] == acpi_gbl_root_node) {
447 * This means that the object does not exist in the namespace,
450 return_desc->integer.value = 0;
454 /* Get the object reference, store it, and remove our reference */
456 status = acpi_ex_get_object_reference (operand[0],
457 &return_desc2, walk_state);
458 if (ACPI_FAILURE (status)) {
462 status = acpi_ex_store (return_desc2, operand[1], walk_state);
463 acpi_ut_remove_reference (return_desc2);
465 /* The object exists in the namespace, return TRUE */
467 return_desc->integer.value = ACPI_INTEGER_MAX;
472 /* No other opcodes get here */
478 case AML_STORE_OP: /* Store (Source, Target) */
481 * A store operand is typically a number, string, buffer or lvalue
482 * Be careful about deleting the source object,
483 * since the object itself may have been stored.
485 status = acpi_ex_store (operand[0], operand[1], walk_state);
486 if (ACPI_FAILURE (status)) {
487 return_ACPI_STATUS (status);
490 /* It is possible that the Store already produced a return object */
492 if (!walk_state->result_obj) {
494 * Normally, we would remove a reference on the Operand[0]
495 * parameter; But since it is being used as the internal return
496 * object (meaning we would normally increment it), the two
497 * cancel out, and we simply don't do anything.
499 walk_state->result_obj = operand[0];
500 walk_state->operands[0] = NULL; /* Prevent deletion */
502 return_ACPI_STATUS (status);
508 case AML_COPY_OP: /* Copy (Source, Target) */
510 status = acpi_ut_copy_iobject_to_iobject (operand[0], &return_desc,
515 case AML_TO_DECSTRING_OP: /* to_decimal_string (Data, Result) */
517 status = acpi_ex_convert_to_string (operand[0], &return_desc,
518 ACPI_EXPLICIT_CONVERT_DECIMAL);
519 if (return_desc == operand[0]) {
520 /* No conversion performed, add ref to handle return value */
521 acpi_ut_add_reference (return_desc);
526 case AML_TO_HEXSTRING_OP: /* to_hex_string (Data, Result) */
528 status = acpi_ex_convert_to_string (operand[0], &return_desc,
529 ACPI_EXPLICIT_CONVERT_HEX);
530 if (return_desc == operand[0]) {
531 /* No conversion performed, add ref to handle return value */
532 acpi_ut_add_reference (return_desc);
537 case AML_TO_BUFFER_OP: /* to_buffer (Data, Result) */
539 status = acpi_ex_convert_to_buffer (operand[0], &return_desc);
540 if (return_desc == operand[0]) {
541 /* No conversion performed, add ref to handle return value */
542 acpi_ut_add_reference (return_desc);
547 case AML_TO_INTEGER_OP: /* to_integer (Data, Result) */
549 status = acpi_ex_convert_to_integer (operand[0], &return_desc,
551 if (return_desc == operand[0]) {
552 /* No conversion performed, add ref to handle return value */
553 acpi_ut_add_reference (return_desc);
558 case AML_SHIFT_LEFT_BIT_OP: /* shift_left_bit (Source, bit_num) */
559 case AML_SHIFT_RIGHT_BIT_OP: /* shift_right_bit (Source, bit_num) */
561 /* These are two obsolete opcodes */
563 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
564 "%s is obsolete and not implemented\n",
565 acpi_ps_get_opcode_name (walk_state->opcode)));
570 default: /* Unknown opcode */
572 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n",
573 walk_state->opcode));
574 status = AE_AML_BAD_OPCODE;
578 if (ACPI_SUCCESS (status)) {
579 /* Store the return value computed above into the target object */
581 status = acpi_ex_store (return_desc, operand[1], walk_state);
587 if (!walk_state->result_obj) {
588 walk_state->result_obj = return_desc;
591 /* Delete return object on error */
593 if (ACPI_FAILURE (status)) {
594 acpi_ut_remove_reference (return_desc);
597 return_ACPI_STATUS (status);
601 /*******************************************************************************
603 * FUNCTION: acpi_ex_opcode_1A_0T_1R
605 * PARAMETERS: walk_state - Current state (contains AML opcode)
609 * DESCRIPTION: Execute opcode with one argument, no target, and a return value
611 ******************************************************************************/
614 acpi_ex_opcode_1A_0T_1R (
615 struct acpi_walk_state *walk_state)
617 union acpi_operand_object **operand = &walk_state->operands[0];
618 union acpi_operand_object *temp_desc;
619 union acpi_operand_object *return_desc = NULL;
620 acpi_status status = AE_OK;
625 ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_1R",
626 acpi_ps_get_opcode_name (walk_state->opcode));
629 /* Examine the AML opcode */
631 switch (walk_state->opcode) {
632 case AML_LNOT_OP: /* LNot (Operand) */
634 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
636 status = AE_NO_MEMORY;
641 * Set result to ONES (TRUE) if Value == 0. Note:
642 * return_desc->Integer.Value is initially == 0 (FALSE) from above.
644 if (!operand[0]->integer.value) {
645 return_desc->integer.value = ACPI_INTEGER_MAX;
650 case AML_DECREMENT_OP: /* Decrement (Operand) */
651 case AML_INCREMENT_OP: /* Increment (Operand) */
654 * Create a new integer. Can't just get the base integer and
655 * increment it because it may be an Arg or Field.
657 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
659 status = AE_NO_MEMORY;
664 * Since we are expecting a Reference operand, it can be either a
665 * NS Node or an internal object.
667 temp_desc = operand[0];
668 if (ACPI_GET_DESCRIPTOR_TYPE (temp_desc) == ACPI_DESC_TYPE_OPERAND) {
669 /* Internal reference object - prevent deletion */
671 acpi_ut_add_reference (temp_desc);
675 * Convert the Reference operand to an Integer (This removes a
676 * reference on the Operand[0] object)
678 * NOTE: We use LNOT_OP here in order to force resolution of the
679 * reference operand to an actual integer.
681 status = acpi_ex_resolve_operands (AML_LNOT_OP, &temp_desc, walk_state);
682 if (ACPI_FAILURE (status)) {
683 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s: bad operand(s) %s\n",
684 acpi_ps_get_opcode_name (walk_state->opcode),
685 acpi_format_exception(status)));
691 * temp_desc is now guaranteed to be an Integer object --
692 * Perform the actual increment or decrement
694 if (walk_state->opcode == AML_INCREMENT_OP) {
695 return_desc->integer.value = temp_desc->integer.value +1;
698 return_desc->integer.value = temp_desc->integer.value -1;
701 /* Finished with this Integer object */
703 acpi_ut_remove_reference (temp_desc);
706 * Store the result back (indirectly) through the original
709 status = acpi_ex_store (return_desc, operand[0], walk_state);
713 case AML_TYPE_OP: /* object_type (source_object) */
716 * Note: The operand is not resolved at this point because we want to
717 * get the associated object, not its value. For example, we don't
718 * want to resolve a field_unit to its value, we want the actual
722 /* Get the type of the base object */
724 status = acpi_ex_resolve_multiple (walk_state, operand[0], &type, NULL);
725 if (ACPI_FAILURE (status)) {
728 /* Allocate a descriptor to hold the type. */
730 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
732 status = AE_NO_MEMORY;
736 return_desc->integer.value = type;
740 case AML_SIZE_OF_OP: /* size_of (source_object) */
743 * Note: The operand is not resolved at this point because we want to
744 * get the associated object, not its value.
747 /* Get the base object */
749 status = acpi_ex_resolve_multiple (walk_state,
750 operand[0], &type, &temp_desc);
751 if (ACPI_FAILURE (status)) {
756 * The type of the base object must be integer, buffer, string, or
757 * package. All others are not supported.
759 * NOTE: Integer is not specifically supported by the ACPI spec,
760 * but is supported implicitly via implicit operand conversion.
761 * rather than bother with conversion, we just use the byte width
762 * global (4 or 8 bytes).
765 case ACPI_TYPE_INTEGER:
766 value = acpi_gbl_integer_byte_width;
769 case ACPI_TYPE_BUFFER:
770 value = temp_desc->buffer.length;
773 case ACPI_TYPE_STRING:
774 value = temp_desc->string.length;
777 case ACPI_TYPE_PACKAGE:
778 value = temp_desc->package.count;
782 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
783 "size_of - Operand is not Buf/Int/Str/Pkg - found type %s\n",
784 acpi_ut_get_type_name (type)));
785 status = AE_AML_OPERAND_TYPE;
790 * Now that we have the size of the object, create a result
791 * object to hold the value
793 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
795 status = AE_NO_MEMORY;
799 return_desc->integer.value = value;
803 case AML_REF_OF_OP: /* ref_of (source_object) */
805 status = acpi_ex_get_object_reference (operand[0], &return_desc, walk_state);
806 if (ACPI_FAILURE (status)) {
812 case AML_DEREF_OF_OP: /* deref_of (obj_reference | String) */
814 /* Check for a method local or argument, or standalone String */
816 if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) != ACPI_DESC_TYPE_NAMED) {
817 switch (ACPI_GET_OBJECT_TYPE (operand[0])) {
818 case ACPI_TYPE_LOCAL_REFERENCE:
820 * This is a deref_of (local_x | arg_x)
822 * Must resolve/dereference the local/arg reference first
824 switch (operand[0]->reference.opcode) {
828 /* Set Operand[0] to the value of the local/arg */
830 status = acpi_ds_method_data_get_value (
831 operand[0]->reference.opcode,
832 operand[0]->reference.offset,
833 walk_state, &temp_desc);
834 if (ACPI_FAILURE (status)) {
839 * Delete our reference to the input object and
840 * point to the object just retrieved
842 acpi_ut_remove_reference (operand[0]);
843 operand[0] = temp_desc;
848 /* Get the object to which the reference refers */
850 temp_desc = operand[0]->reference.object;
851 acpi_ut_remove_reference (operand[0]);
852 operand[0] = temp_desc;
857 /* Must be an Index op - handled below */
863 case ACPI_TYPE_STRING:
866 * This is a deref_of (String). The string is a reference
867 * to a named ACPI object.
869 * 1) Find the owning Node
870 * 2) Dereference the node to an actual object. Could be a
871 * Field, so we need to resolve the node to a value.
873 status = acpi_ns_get_node_by_path (operand[0]->string.pointer,
874 walk_state->scope_info->scope.node,
875 ACPI_NS_SEARCH_PARENT,
876 ACPI_CAST_INDIRECT_PTR (
877 struct acpi_namespace_node, &return_desc));
878 if (ACPI_FAILURE (status)) {
882 status = acpi_ex_resolve_node_to_value (
883 ACPI_CAST_INDIRECT_PTR (
884 struct acpi_namespace_node, &return_desc),
891 status = AE_AML_OPERAND_TYPE;
896 /* Operand[0] may have changed from the code above */
898 if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) == ACPI_DESC_TYPE_NAMED) {
900 * This is a deref_of (object_reference)
901 * Get the actual object from the Node (This is the dereference).
902 * This case may only happen when a local_x or arg_x is
903 * dereferenced above.
905 return_desc = acpi_ns_get_attached_object (
906 (struct acpi_namespace_node *) operand[0]);
907 acpi_ut_add_reference (return_desc);
911 * This must be a reference object produced by either the
912 * Index() or ref_of() operator
914 switch (operand[0]->reference.opcode) {
918 * The target type for the Index operator must be
919 * either a Buffer or a Package
921 switch (operand[0]->reference.target_type) {
922 case ACPI_TYPE_BUFFER_FIELD:
924 temp_desc = operand[0]->reference.object;
927 * Create a new object that contains one element of the
928 * buffer -- the element pointed to by the index.
930 * NOTE: index into a buffer is NOT a pointer to a
931 * sub-buffer of the main buffer, it is only a pointer to a
932 * single element (byte) of the buffer!
934 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
936 status = AE_NO_MEMORY;
941 * Since we are returning the value of the buffer at the
942 * indexed location, we don't need to add an additional
943 * reference to the buffer itself.
945 return_desc->integer.value =
946 temp_desc->buffer.pointer[operand[0]->reference.offset];
950 case ACPI_TYPE_PACKAGE:
953 * Return the referenced element of the package. We must
954 * add another reference to the referenced object, however.
956 return_desc = *(operand[0]->reference.where);
958 acpi_ut_add_reference (return_desc);
966 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
967 "Unknown Index target_type %X in obj %p\n",
968 operand[0]->reference.target_type, operand[0]));
969 status = AE_AML_OPERAND_TYPE;
977 return_desc = operand[0]->reference.object;
979 if (ACPI_GET_DESCRIPTOR_TYPE (return_desc) ==
980 ACPI_DESC_TYPE_NAMED) {
982 return_desc = acpi_ns_get_attached_object (
983 (struct acpi_namespace_node *) return_desc);
986 /* Add another reference to the object! */
988 acpi_ut_add_reference (return_desc);
993 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
994 "Unknown opcode in ref(%p) - %X\n",
995 operand[0], operand[0]->reference.opcode));
1006 ACPI_REPORT_ERROR (("acpi_ex_opcode_1A_0T_1R: Unknown opcode %X\n",
1007 walk_state->opcode));
1008 status = AE_AML_BAD_OPCODE;
1015 /* Delete return object on error */
1017 if (ACPI_FAILURE (status)) {
1018 acpi_ut_remove_reference (return_desc);
1021 walk_state->result_obj = return_desc;
1022 return_ACPI_STATUS (status);