2 /******************************************************************************
4 * Module Name: exoparg1 - AML execution - opcodes with 1 argument
7 *****************************************************************************/
9 /******************************************************************************
13 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
14 * All rights reserved.
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
23 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24 * copy of the source code appearing in this file ("Covered Code") an
25 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26 * base code distributed originally by Intel ("Original Intel Code") to copy,
27 * make derivatives, distribute, use and display any portion of the Covered
28 * Code in any form, with the right to sublicense such rights; and
30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31 * license (with the right to sublicense), under only those claims of Intel
32 * patents that are infringed by the Original Intel Code, to make, use, sell,
33 * offer to sell, and import the Covered Code and derivative works thereof
34 * solely to the minimum extent necessary to exercise the above copyright
35 * license, and in no event shall the patent license extend to any additions
36 * to or modifications of the Original Intel Code. No other license or right
37 * is granted directly or by implication, estoppel or otherwise;
39 * The above copyright and patent license is granted only if the following
44 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45 * Redistribution of source code of any substantial portion of the Covered
46 * Code or modification with rights to further distribute source must include
47 * the above Copyright Notice, the above License, this list of Conditions,
48 * and the following Disclaimer and Export Compliance provision. In addition,
49 * Licensee must cause all Covered Code to which Licensee contributes to
50 * contain a file documenting the changes Licensee made to create that Covered
51 * Code and the date of any change. Licensee must include in that file the
52 * documentation of any changes made by any predecessor Licensee. Licensee
53 * must include a prominent statement that the modification is derived,
54 * directly or indirectly, from Original Intel Code.
56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57 * Redistribution of source code of any substantial portion of the Covered
58 * Code or modification without rights to further distribute source must
59 * include the following Disclaimer and Export Compliance provision in the
60 * documentation and/or other materials provided with distribution. In
61 * addition, Licensee may not authorize further sublicense of source of any
62 * portion of the Covered Code, and must include terms to the effect that the
63 * license from Licensee to its licensee is limited to the intellectual
64 * property embodied in the software Licensee provides to its licensee, and
65 * not to intellectual property embodied in modifications its licensee may
68 * 3.3. Redistribution of Executable. Redistribution in executable form of any
69 * substantial portion of the Covered Code or modification must reproduce the
70 * above Copyright Notice, and the following Disclaimer and Export Compliance
71 * provision in the documentation and/or other materials provided with the
74 * 3.4. Intel retains all right, title, and interest in and to the Original
77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78 * Intel shall be used in advertising or otherwise to promote the sale, use or
79 * other dealings in products derived from or relating to the Covered Code
80 * without prior written authorization from Intel.
82 * 4. Disclaimer and Export Compliance
84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
101 * 4.3. Licensee shall not export, either directly or indirectly, any of this
102 * software or system incorporating such software without first obtaining any
103 * required license or other approval from the U. S. Department of Commerce or
104 * any other agency or department of the United States Government. In the
105 * event Licensee exports any such software from the United States or
106 * re-exports any such software from a foreign destination, Licensee shall
107 * ensure that the distribution and export/re-export of the software is in
108 * compliance with all laws, regulations, orders, or other restrictions of the
109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110 * any of its subsidiaries will export/re-export any technical data, process,
111 * software, or service, directly or indirectly, to any country for which the
112 * United States government or any agency thereof requires an export license,
113 * other governmental approval, or letter of assurance, without first obtaining
114 * such license, approval or letter.
116 *****************************************************************************/
117 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/exoparg1.c,v 1.1 2003/09/24 03:32:16 drhodus Exp $ */
119 #define __EXOPARG1_C__
122 #include "acparser.h"
123 #include "acdispat.h"
124 #include "acinterp.h"
126 #include "acnamesp.h"
129 #define _COMPONENT ACPI_EXECUTER
130 ACPI_MODULE_NAME ("exoparg1")
134 * Naming convention for AML interpreter execution routines.
136 * The routines that begin execution of AML opcodes are named with a common
137 * convention based upon the number of arguments, the number of target operands,
138 * and whether or not a value is returned:
140 * AcpiExOpcode_xA_yT_zR
144 * xA - ARGUMENTS: The number of arguments (input operands) that are
145 * required for this opcode type (1 through 6 args).
146 * yT - TARGETS: The number of targets (output operands) that are required
147 * for this opcode type (0, 1, or 2 targets).
148 * zR - RETURN VALUE: Indicates whether this opcode type returns a value
149 * as the function return (0 or 1).
151 * The AcpiExOpcode* functions are called via the Dispatcher component with
152 * fully resolved operands.
155 /*******************************************************************************
157 * FUNCTION: AcpiExOpcode_1A_0T_0R
159 * PARAMETERS: WalkState - Current state (contains AML opcode)
163 * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
166 ******************************************************************************/
169 AcpiExOpcode_1A_0T_0R (
170 ACPI_WALK_STATE *WalkState)
172 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
173 ACPI_STATUS Status = AE_OK;
176 ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_0R", AcpiPsGetOpcodeName (WalkState->Opcode));
179 /* Examine the AML opcode */
181 switch (WalkState->Opcode)
183 case AML_RELEASE_OP: /* Release (MutexObject) */
185 Status = AcpiExReleaseMutex (Operand[0], WalkState);
189 case AML_RESET_OP: /* Reset (EventObject) */
191 Status = AcpiExSystemResetEvent (Operand[0]);
195 case AML_SIGNAL_OP: /* Signal (EventObject) */
197 Status = AcpiExSystemSignalEvent (Operand[0]);
201 case AML_SLEEP_OP: /* Sleep (MsecTime) */
203 Status = AcpiExSystemDoSuspend ((UINT32) Operand[0]->Integer.Value);
207 case AML_STALL_OP: /* Stall (UsecTime) */
209 Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value);
213 case AML_UNLOAD_OP: /* Unload (Handle) */
215 Status = AcpiExUnloadTable (Operand[0]);
219 default: /* Unknown opcode */
221 ACPI_REPORT_ERROR (("AcpiExOpcode_1A_0T_0R: Unknown opcode %X\n",
223 Status = AE_AML_BAD_OPCODE;
227 return_ACPI_STATUS (Status);
231 /*******************************************************************************
233 * FUNCTION: AcpiExOpcode_1A_1T_0R
235 * PARAMETERS: WalkState - Current state (contains AML opcode)
239 * DESCRIPTION: Execute opcode with one argument, one target, and no
242 ******************************************************************************/
245 AcpiExOpcode_1A_1T_0R (
246 ACPI_WALK_STATE *WalkState)
248 ACPI_STATUS Status = AE_OK;
249 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
252 ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_0R", AcpiPsGetOpcodeName (WalkState->Opcode));
255 /* Examine the AML opcode */
257 switch (WalkState->Opcode)
261 Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState);
264 default: /* Unknown opcode */
266 ACPI_REPORT_ERROR (("AcpiExOpcode_1A_1T_0R: Unknown opcode %X\n",
268 Status = AE_AML_BAD_OPCODE;
275 return_ACPI_STATUS (Status);
279 /*******************************************************************************
281 * FUNCTION: AcpiExOpcode_1A_1T_1R
283 * PARAMETERS: WalkState - Current state (contains AML opcode)
287 * DESCRIPTION: Execute opcode with one argument, one target, and a
290 ******************************************************************************/
293 AcpiExOpcode_1A_1T_1R (
294 ACPI_WALK_STATE *WalkState)
296 ACPI_STATUS Status = AE_OK;
297 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
298 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
299 ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL;
306 ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_1R", AcpiPsGetOpcodeName (WalkState->Opcode));
309 /* Examine the AML opcode */
311 switch (WalkState->Opcode)
314 case AML_FIND_SET_LEFT_BIT_OP:
315 case AML_FIND_SET_RIGHT_BIT_OP:
316 case AML_FROM_BCD_OP:
318 case AML_COND_REF_OF_OP:
320 /* Create a return object of type Integer for these opcodes */
322 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
325 Status = AE_NO_MEMORY;
329 switch (WalkState->Opcode)
331 case AML_BIT_NOT_OP: /* Not (Operand, Result) */
333 ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value;
337 case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */
339 ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
342 * Acpi specification describes Integer type as a little
343 * endian unsigned value, so this boundary condition is valid.
345 for (Temp32 = 0; ReturnDesc->Integer.Value && Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
347 ReturnDesc->Integer.Value >>= 1;
350 ReturnDesc->Integer.Value = Temp32;
354 case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */
356 ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
359 * The Acpi specification describes Integer type as a little
360 * endian unsigned value, so this boundary condition is valid.
362 for (Temp32 = 0; ReturnDesc->Integer.Value && Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
364 ReturnDesc->Integer.Value <<= 1;
367 /* Since the bit position is one-based, subtract from 33 (65) */
369 ReturnDesc->Integer.Value = Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32;
373 case AML_FROM_BCD_OP: /* FromBcd (BCDValue, Result) */
376 * The 64-bit ACPI integer can hold 16 4-bit BCD integers
378 ReturnDesc->Integer.Value = 0;
379 for (i = 0; i < ACPI_MAX_BCD_DIGITS; i++)
381 /* Get one BCD digit */
383 Digit = (ACPI_INTEGER) ((Operand[0]->Integer.Value >> (i * 4)) & 0xF);
385 /* Check the range of the digit */
389 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "BCD digit too large: %d\n",
391 Status = AE_AML_NUMERIC_OVERFLOW;
397 /* Sum into the result with the appropriate power of 10 */
399 for (j = 0; j < i; j++)
404 ReturnDesc->Integer.Value += Digit;
410 case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */
412 if (Operand[0]->Integer.Value > ACPI_MAX_BCD_VALUE)
414 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "BCD overflow: %8.8X%8.8X\n",
415 ACPI_HIDWORD(Operand[0]->Integer.Value),
416 ACPI_LODWORD(Operand[0]->Integer.Value)));
417 Status = AE_AML_NUMERIC_OVERFLOW;
421 ReturnDesc->Integer.Value = 0;
422 for (i = 0; i < ACPI_MAX_BCD_DIGITS; i++)
424 /* Divide by nth factor of 10 */
427 Digit = Operand[0]->Integer.Value;
428 for (j = 0; j < i; j++)
430 (void) AcpiUtShortDivide (&Digit, 10, &Digit, &Temp32);
433 /* Create the BCD digit from the remainder above */
437 ReturnDesc->Integer.Value += ((ACPI_INTEGER) Temp32 << (i * 4));
443 case AML_COND_REF_OF_OP: /* CondRefOf (SourceObject, Result) */
446 * This op is a little strange because the internal return value is
447 * different than the return value stored in the result descriptor
448 * (There are really two return values)
450 if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode)
453 * This means that the object does not exist in the namespace,
456 ReturnDesc->Integer.Value = 0;
460 /* Get the object reference, store it, and remove our reference */
462 Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc2, WalkState);
463 if (ACPI_FAILURE (Status))
468 Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState);
469 AcpiUtRemoveReference (ReturnDesc2);
471 /* The object exists in the namespace, return TRUE */
473 ReturnDesc->Integer.Value = ACPI_INTEGER_MAX;
478 /* No other opcodes get here */
484 case AML_STORE_OP: /* Store (Source, Target) */
487 * A store operand is typically a number, string, buffer or lvalue
488 * Be careful about deleting the source object,
489 * since the object itself may have been stored.
491 Status = AcpiExStore (Operand[0], Operand[1], WalkState);
492 if (ACPI_FAILURE (Status))
494 return_ACPI_STATUS (Status);
497 /* It is possible that the Store already produced a return object */
499 if (!WalkState->ResultObj)
502 * Normally, we would remove a reference on the Operand[0] parameter;
503 * But since it is being used as the internal return object
504 * (meaning we would normally increment it), the two cancel out,
505 * and we simply don't do anything.
507 WalkState->ResultObj = Operand[0];
508 WalkState->Operands[0] = NULL; /* Prevent deletion */
510 return_ACPI_STATUS (Status);
516 case AML_COPY_OP: /* Copy (Source, Target) */
518 Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc, WalkState);
522 case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */
524 Status = AcpiExConvertToString (Operand[0], &ReturnDesc, 10, ACPI_UINT32_MAX, WalkState);
528 case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */
530 Status = AcpiExConvertToString (Operand[0], &ReturnDesc, 16, ACPI_UINT32_MAX, WalkState);
534 case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */
536 Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc, WalkState);
540 case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */
542 Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, WalkState);
546 case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */
547 case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */
550 * These are two obsolete opcodes
552 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s is obsolete and not implemented\n",
553 AcpiPsGetOpcodeName (WalkState->Opcode)));
558 default: /* Unknown opcode */
560 ACPI_REPORT_ERROR (("AcpiExOpcode_1A_1T_1R: Unknown opcode %X\n",
562 Status = AE_AML_BAD_OPCODE;
567 * Store the return value computed above into the target object
569 Status = AcpiExStore (ReturnDesc, Operand[1], WalkState);
574 if (!WalkState->ResultObj)
576 WalkState->ResultObj = ReturnDesc;
579 /* Delete return object on error */
581 if (ACPI_FAILURE (Status))
583 AcpiUtRemoveReference (ReturnDesc);
586 return_ACPI_STATUS (Status);
590 /*******************************************************************************
592 * FUNCTION: AcpiExOpcode_1A_0T_1R
594 * PARAMETERS: WalkState - Current state (contains AML opcode)
598 * DESCRIPTION: Execute opcode with one argument, no target, and a return value
600 ******************************************************************************/
603 AcpiExOpcode_1A_0T_1R (
604 ACPI_WALK_STATE *WalkState)
606 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
607 ACPI_OPERAND_OBJECT *TempDesc;
608 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
609 ACPI_STATUS Status = AE_OK;
614 ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_0R", AcpiPsGetOpcodeName (WalkState->Opcode));
617 /* Examine the AML opcode */
619 switch (WalkState->Opcode)
621 case AML_LNOT_OP: /* LNot (Operand) */
623 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
626 Status = AE_NO_MEMORY;
630 ReturnDesc->Integer.Value = !Operand[0]->Integer.Value;
634 case AML_DECREMENT_OP: /* Decrement (Operand) */
635 case AML_INCREMENT_OP: /* Increment (Operand) */
638 * Since we are expecting a Reference operand, it
639 * can be either a NS Node or an internal object.
641 ReturnDesc = Operand[0];
642 if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_OPERAND)
644 /* Internal reference object - prevent deletion */
646 AcpiUtAddReference (ReturnDesc);
650 * Convert the ReturnDesc Reference to a Number
651 * (This removes a reference on the ReturnDesc object)
653 Status = AcpiExResolveOperands (AML_LNOT_OP, &ReturnDesc, WalkState);
654 if (ACPI_FAILURE (Status))
656 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s: bad operand(s) %s\n",
657 AcpiPsGetOpcodeName (WalkState->Opcode), AcpiFormatException(Status)));
663 * ReturnDesc is now guaranteed to be an Integer object
664 * Do the actual increment or decrement
666 if (AML_INCREMENT_OP == WalkState->Opcode)
668 ReturnDesc->Integer.Value++;
672 ReturnDesc->Integer.Value--;
675 /* Store the result back in the original descriptor */
677 Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
681 case AML_TYPE_OP: /* ObjectType (SourceObject) */
683 /* Get the type of the base object */
685 Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL);
686 if (ACPI_FAILURE (Status))
691 /* Allocate a descriptor to hold the type. */
693 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
696 Status = AE_NO_MEMORY;
700 ReturnDesc->Integer.Value = Type;
704 case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */
706 /* Get the base object */
708 Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, &TempDesc);
709 if (ACPI_FAILURE (Status))
715 * Type is guaranteed to be a buffer, string, or package at this
716 * point (even if the original operand was an object reference, it
717 * will be resolved and typechecked during operand resolution.)
721 case ACPI_TYPE_BUFFER:
722 Value = TempDesc->Buffer.Length;
725 case ACPI_TYPE_STRING:
726 Value = TempDesc->String.Length;
729 case ACPI_TYPE_PACKAGE:
730 Value = TempDesc->Package.Count;
734 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "SizeOf, Not Buf/Str/Pkg - found type %s\n",
735 AcpiUtGetTypeName (Type)));
736 Status = AE_AML_OPERAND_TYPE;
741 * Now that we have the size of the object, create a result
742 * object to hold the value
744 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
747 Status = AE_NO_MEMORY;
751 ReturnDesc->Integer.Value = Value;
755 case AML_REF_OF_OP: /* RefOf (SourceObject) */
757 Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc, WalkState);
758 if (ACPI_FAILURE (Status))
765 case AML_DEREF_OF_OP: /* DerefOf (ObjReference | String) */
767 /* Check for a method local or argument, or standalone String */
769 if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED)
771 switch (ACPI_GET_OBJECT_TYPE (Operand[0]))
773 case ACPI_TYPE_LOCAL_REFERENCE:
775 * This is a DerefOf (LocalX | ArgX)
777 * Must resolve/dereference the local/arg reference first
779 switch (Operand[0]->Reference.Opcode)
784 /* Set Operand[0] to the value of the local/arg */
786 Status = AcpiDsMethodDataGetValue (Operand[0]->Reference.Opcode,
787 Operand[0]->Reference.Offset, WalkState, &TempDesc);
788 if (ACPI_FAILURE (Status))
794 * Delete our reference to the input object and
795 * point to the object just retrieved
797 AcpiUtRemoveReference (Operand[0]);
798 Operand[0] = TempDesc;
803 /* Get the object to which the reference refers */
805 TempDesc = Operand[0]->Reference.Object;
806 AcpiUtRemoveReference (Operand[0]);
807 Operand[0] = TempDesc;
812 /* Must be an Index op - handled below */
818 case ACPI_TYPE_STRING:
821 * This is a DerefOf (String). The string is a reference to a named ACPI object.
823 * 1) Find the owning Node
824 * 2) Dereference the node to an actual object. Could be a Field, so we nee
825 * to resolve the node to a value.
827 Status = AcpiNsGetNodeByPath (Operand[0]->String.Pointer,
828 WalkState->ScopeInfo->Scope.Node, ACPI_NS_SEARCH_PARENT,
829 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ReturnDesc));
830 if (ACPI_FAILURE (Status))
835 Status = AcpiExResolveNodeToValue (
836 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ReturnDesc), WalkState);
842 Status = AE_AML_OPERAND_TYPE;
847 /* Operand[0] may have changed from the code above */
849 if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
852 * This is a DerefOf (ObjectReference)
853 * Get the actual object from the Node (This is the dereference).
854 * -- This case may only happen when a LocalX or ArgX is dereferenced above.
856 ReturnDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) Operand[0]);
861 * This must be a reference object produced by either the Index() or
864 switch (Operand[0]->Reference.Opcode)
869 * The target type for the Index operator must be
870 * either a Buffer or a Package
872 switch (Operand[0]->Reference.TargetType)
874 case ACPI_TYPE_BUFFER_FIELD:
876 TempDesc = Operand[0]->Reference.Object;
879 * Create a new object that contains one element of the
880 * buffer -- the element pointed to by the index.
882 * NOTE: index into a buffer is NOT a pointer to a
883 * sub-buffer of the main buffer, it is only a pointer to a
884 * single element (byte) of the buffer!
886 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
889 Status = AE_NO_MEMORY;
894 * Since we are returning the value of the buffer at the
895 * indexed location, we don't need to add an additional
896 * reference to the buffer itself.
898 ReturnDesc->Integer.Value =
899 TempDesc->Buffer.Pointer[Operand[0]->Reference.Offset];
903 case ACPI_TYPE_PACKAGE:
906 * Return the referenced element of the package. We must add
907 * another reference to the referenced object, however.
909 ReturnDesc = *(Operand[0]->Reference.Where);
913 * We can't return a NULL dereferenced value. This is
914 * an uninitialized package element and is thus a
917 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "NULL package element obj %p\n",
919 Status = AE_AML_UNINITIALIZED_ELEMENT;
923 AcpiUtAddReference (ReturnDesc);
929 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Index TargetType %X in obj %p\n",
930 Operand[0]->Reference.TargetType, Operand[0]));
931 Status = AE_AML_OPERAND_TYPE;
939 ReturnDesc = Operand[0]->Reference.Object;
941 if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) == ACPI_DESC_TYPE_NAMED)
944 ReturnDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ReturnDesc);
947 /* Add another reference to the object! */
949 AcpiUtAddReference (ReturnDesc);
954 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode in ref(%p) - %X\n",
955 Operand[0], Operand[0]->Reference.Opcode));
966 ACPI_REPORT_ERROR (("AcpiExOpcode_1A_0T_1R: Unknown opcode %X\n",
968 Status = AE_AML_BAD_OPCODE;
975 /* Delete return object on error */
977 if (ACPI_FAILURE (Status))
979 AcpiUtRemoveReference (ReturnDesc);
982 WalkState->ResultObj = ReturnDesc;
983 return_ACPI_STATUS (Status);