1 /******************************************************************************
3 * Module Name: exoparg1 - AML execution - opcodes with 1 argument
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2013, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #define __EXOPARG1_C__
46 #include <contrib/dev/acpica/include/acpi.h>
47 #include <contrib/dev/acpica/include/accommon.h>
48 #include <contrib/dev/acpica/include/acparser.h>
49 #include <contrib/dev/acpica/include/acdispat.h>
50 #include <contrib/dev/acpica/include/acinterp.h>
51 #include <contrib/dev/acpica/include/amlcode.h>
52 #include <contrib/dev/acpica/include/acnamesp.h>
55 #define _COMPONENT ACPI_EXECUTER
56 ACPI_MODULE_NAME ("exoparg1")
60 * Naming convention for AML interpreter execution routines.
62 * The routines that begin execution of AML opcodes are named with a common
63 * convention based upon the number of arguments, the number of target operands,
64 * and whether or not a value is returned:
66 * AcpiExOpcode_xA_yT_zR
70 * xA - ARGUMENTS: The number of arguments (input operands) that are
71 * required for this opcode type (0 through 6 args).
72 * yT - TARGETS: The number of targets (output operands) that are required
73 * for this opcode type (0, 1, or 2 targets).
74 * zR - RETURN VALUE: Indicates whether this opcode type returns a value
75 * as the function return (0 or 1).
77 * The AcpiExOpcode* functions are called via the Dispatcher component with
78 * fully resolved operands.
81 /*******************************************************************************
83 * FUNCTION: AcpiExOpcode_0A_0T_1R
85 * PARAMETERS: WalkState - Current state (contains AML opcode)
89 * DESCRIPTION: Execute operator with no operands, one return value
91 ******************************************************************************/
94 AcpiExOpcode_0A_0T_1R (
95 ACPI_WALK_STATE *WalkState)
97 ACPI_STATUS Status = AE_OK;
98 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
101 ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R,
102 AcpiPsGetOpcodeName (WalkState->Opcode));
105 /* Examine the AML opcode */
107 switch (WalkState->Opcode)
109 case AML_TIMER_OP: /* Timer () */
111 /* Create a return object of type Integer */
113 ReturnDesc = AcpiUtCreateIntegerObject (AcpiOsGetTimer ());
116 Status = AE_NO_MEMORY;
121 default: /* Unknown opcode */
123 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
125 Status = AE_AML_BAD_OPCODE;
131 /* Delete return object on error */
133 if ((ACPI_FAILURE (Status)) || WalkState->ResultObj)
135 AcpiUtRemoveReference (ReturnDesc);
136 WalkState->ResultObj = NULL;
140 /* Save the return value */
142 WalkState->ResultObj = ReturnDesc;
145 return_ACPI_STATUS (Status);
149 /*******************************************************************************
151 * FUNCTION: AcpiExOpcode_1A_0T_0R
153 * PARAMETERS: WalkState - Current state (contains AML opcode)
157 * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
160 ******************************************************************************/
163 AcpiExOpcode_1A_0T_0R (
164 ACPI_WALK_STATE *WalkState)
166 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
167 ACPI_STATUS Status = AE_OK;
170 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R,
171 AcpiPsGetOpcodeName (WalkState->Opcode));
174 /* Examine the AML opcode */
176 switch (WalkState->Opcode)
178 case AML_RELEASE_OP: /* Release (MutexObject) */
180 Status = AcpiExReleaseMutex (Operand[0], WalkState);
183 case AML_RESET_OP: /* Reset (EventObject) */
185 Status = AcpiExSystemResetEvent (Operand[0]);
188 case AML_SIGNAL_OP: /* Signal (EventObject) */
190 Status = AcpiExSystemSignalEvent (Operand[0]);
193 case AML_SLEEP_OP: /* Sleep (MsecTime) */
195 Status = AcpiExSystemDoSleep (Operand[0]->Integer.Value);
198 case AML_STALL_OP: /* Stall (UsecTime) */
200 Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value);
203 case AML_UNLOAD_OP: /* Unload (Handle) */
205 Status = AcpiExUnloadTable (Operand[0]);
208 default: /* Unknown opcode */
210 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
212 Status = AE_AML_BAD_OPCODE;
216 return_ACPI_STATUS (Status);
220 /*******************************************************************************
222 * FUNCTION: AcpiExOpcode_1A_1T_0R
224 * PARAMETERS: WalkState - Current state (contains AML opcode)
228 * DESCRIPTION: Execute opcode with one argument, one target, and no
231 ******************************************************************************/
234 AcpiExOpcode_1A_1T_0R (
235 ACPI_WALK_STATE *WalkState)
237 ACPI_STATUS Status = AE_OK;
238 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
241 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_0R,
242 AcpiPsGetOpcodeName (WalkState->Opcode));
245 /* Examine the AML opcode */
247 switch (WalkState->Opcode)
251 Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState);
254 default: /* Unknown opcode */
256 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
258 Status = AE_AML_BAD_OPCODE;
265 return_ACPI_STATUS (Status);
269 /*******************************************************************************
271 * FUNCTION: AcpiExOpcode_1A_1T_1R
273 * PARAMETERS: WalkState - Current state (contains AML opcode)
277 * DESCRIPTION: Execute opcode with one argument, one target, and a
280 ******************************************************************************/
283 AcpiExOpcode_1A_1T_1R (
284 ACPI_WALK_STATE *WalkState)
286 ACPI_STATUS Status = AE_OK;
287 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
288 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
289 ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL;
296 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R,
297 AcpiPsGetOpcodeName (WalkState->Opcode));
300 /* Examine the AML opcode */
302 switch (WalkState->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 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
316 Status = AE_NO_MEMORY;
320 switch (WalkState->Opcode)
322 case AML_BIT_NOT_OP: /* Not (Operand, Result) */
324 ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value;
327 case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */
329 ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
332 * Acpi specification describes Integer type as a little
333 * endian unsigned value, so this boundary condition is valid.
335 for (Temp32 = 0; ReturnDesc->Integer.Value &&
336 Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
338 ReturnDesc->Integer.Value >>= 1;
341 ReturnDesc->Integer.Value = Temp32;
344 case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */
346 ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
349 * The Acpi specification describes Integer type as a little
350 * endian unsigned value, so this boundary condition is valid.
352 for (Temp32 = 0; ReturnDesc->Integer.Value &&
353 Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
355 ReturnDesc->Integer.Value <<= 1;
358 /* Since the bit position is one-based, subtract from 33 (65) */
360 ReturnDesc->Integer.Value =
361 Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32;
364 case AML_FROM_BCD_OP: /* FromBcd (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 ReturnDesc->Integer.Value = 0;
372 Digit = Operand[0]->Integer.Value;
374 /* Convert each BCD digit (each is one nybble wide) */
376 for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
378 /* Get the least significant 4-bit BCD digit */
380 Temp32 = ((UINT32) Digit) & 0xF;
382 /* Check the range of the digit */
386 ACPI_ERROR ((AE_INFO,
387 "BCD digit too large (not decimal): 0x%X",
390 Status = AE_AML_NUMERIC_OVERFLOW;
394 /* Sum the digit into the result with the current power of 10 */
396 ReturnDesc->Integer.Value +=
397 (((UINT64) Temp32) * PowerOfTen);
399 /* Shift to next BCD digit */
403 /* Next power of 10 */
409 case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */
411 ReturnDesc->Integer.Value = 0;
412 Digit = Operand[0]->Integer.Value;
414 /* Each BCD digit is one nybble wide */
416 for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
418 (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32);
421 * Insert the BCD digit that resides in the
422 * remainder from above
424 ReturnDesc->Integer.Value |=
425 (((UINT64) Temp32) << ACPI_MUL_4 (i));
428 /* Overflow if there is any data left in Digit */
432 ACPI_ERROR ((AE_INFO,
433 "Integer too large to convert to BCD: 0x%8.8X%8.8X",
434 ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value)));
435 Status = AE_AML_NUMERIC_OVERFLOW;
440 case AML_COND_REF_OF_OP: /* CondRefOf (SourceObject, Result) */
442 * This op is a little strange because the internal return value is
443 * different than the return value stored in the result descriptor
444 * (There are really two return values)
446 if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode)
449 * This means that the object does not exist in the namespace,
452 ReturnDesc->Integer.Value = 0;
456 /* Get the object reference, store it, and remove our reference */
458 Status = AcpiExGetObjectReference (Operand[0],
459 &ReturnDesc2, WalkState);
460 if (ACPI_FAILURE (Status))
465 Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState);
466 AcpiUtRemoveReference (ReturnDesc2);
468 /* The object exists in the namespace, return TRUE */
470 ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
476 /* No other opcodes get here */
482 case AML_STORE_OP: /* Store (Source, Target) */
484 * A store operand is typically a number, string, buffer or lvalue
485 * Be careful about deleting the source object,
486 * since the object itself may have been stored.
488 Status = AcpiExStore (Operand[0], Operand[1], WalkState);
489 if (ACPI_FAILURE (Status))
491 return_ACPI_STATUS (Status);
494 /* It is possible that the Store already produced a return object */
496 if (!WalkState->ResultObj)
499 * Normally, we would remove a reference on the Operand[0]
500 * parameter; But since it is being used as the internal return
501 * object (meaning we would normally increment it), the two
502 * cancel out, and we simply don't do anything.
504 WalkState->ResultObj = Operand[0];
505 WalkState->Operands[0] = NULL; /* Prevent deletion */
507 return_ACPI_STATUS (Status);
512 case AML_COPY_OP: /* Copy (Source, Target) */
514 Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc,
518 case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */
520 Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
521 ACPI_EXPLICIT_CONVERT_DECIMAL);
522 if (ReturnDesc == Operand[0])
524 /* No conversion performed, add ref to handle return value */
525 AcpiUtAddReference (ReturnDesc);
529 case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */
531 Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
532 ACPI_EXPLICIT_CONVERT_HEX);
533 if (ReturnDesc == Operand[0])
535 /* No conversion performed, add ref to handle return value */
536 AcpiUtAddReference (ReturnDesc);
540 case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */
542 Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc);
543 if (ReturnDesc == Operand[0])
545 /* No conversion performed, add ref to handle return value */
546 AcpiUtAddReference (ReturnDesc);
550 case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */
552 Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc,
554 if (ReturnDesc == Operand[0])
556 /* No conversion performed, add ref to handle return value */
557 AcpiUtAddReference (ReturnDesc);
561 case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */
562 case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */
564 /* These are two obsolete opcodes */
566 ACPI_ERROR ((AE_INFO,
567 "%s is obsolete and not implemented",
568 AcpiPsGetOpcodeName (WalkState->Opcode)));
572 default: /* Unknown opcode */
574 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
576 Status = AE_AML_BAD_OPCODE;
580 if (ACPI_SUCCESS (Status))
582 /* Store the return value computed above into the target object */
584 Status = AcpiExStore (ReturnDesc, Operand[1], WalkState);
590 /* Delete return object on error */
592 if (ACPI_FAILURE (Status))
594 AcpiUtRemoveReference (ReturnDesc);
597 /* Save return object on success */
599 else if (!WalkState->ResultObj)
601 WalkState->ResultObj = ReturnDesc;
604 return_ACPI_STATUS (Status);
608 /*******************************************************************************
610 * FUNCTION: AcpiExOpcode_1A_0T_1R
612 * PARAMETERS: WalkState - Current state (contains AML opcode)
616 * DESCRIPTION: Execute opcode with one argument, no target, and a return value
618 ******************************************************************************/
621 AcpiExOpcode_1A_0T_1R (
622 ACPI_WALK_STATE *WalkState)
624 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
625 ACPI_OPERAND_OBJECT *TempDesc;
626 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
627 ACPI_STATUS Status = AE_OK;
632 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R,
633 AcpiPsGetOpcodeName (WalkState->Opcode));
636 /* Examine the AML opcode */
638 switch (WalkState->Opcode)
640 case AML_LNOT_OP: /* LNot (Operand) */
642 ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
645 Status = AE_NO_MEMORY;
650 * Set result to ONES (TRUE) if Value == 0. Note:
651 * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above.
653 if (!Operand[0]->Integer.Value)
655 ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
659 case AML_DECREMENT_OP: /* Decrement (Operand) */
660 case AML_INCREMENT_OP: /* Increment (Operand) */
662 * Create a new integer. Can't just get the base integer and
663 * increment it because it may be an Arg or Field.
665 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
668 Status = AE_NO_MEMORY;
673 * Since we are expecting a Reference operand, it can be either a
674 * NS Node or an internal object.
676 TempDesc = Operand[0];
677 if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND)
679 /* Internal reference object - prevent deletion */
681 AcpiUtAddReference (TempDesc);
685 * Convert the Reference operand to an Integer (This removes a
686 * reference on the Operand[0] object)
688 * NOTE: We use LNOT_OP here in order to force resolution of the
689 * reference operand to an actual integer.
691 Status = AcpiExResolveOperands (AML_LNOT_OP, &TempDesc, WalkState);
692 if (ACPI_FAILURE (Status))
694 ACPI_EXCEPTION ((AE_INFO, Status,
695 "While resolving operands for [%s]",
696 AcpiPsGetOpcodeName (WalkState->Opcode)));
702 * TempDesc is now guaranteed to be an Integer object --
703 * Perform the actual increment or decrement
705 if (WalkState->Opcode == AML_INCREMENT_OP)
707 ReturnDesc->Integer.Value = TempDesc->Integer.Value +1;
711 ReturnDesc->Integer.Value = TempDesc->Integer.Value -1;
714 /* Finished with this Integer object */
716 AcpiUtRemoveReference (TempDesc);
719 * Store the result back (indirectly) through the original
722 Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
725 case AML_TYPE_OP: /* ObjectType (SourceObject) */
727 * Note: The operand is not resolved at this point because we want to
728 * get the associated object, not its value. For example, we don't
729 * want to resolve a FieldUnit to its value, we want the actual
733 /* Get the type of the base object */
735 Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL);
736 if (ACPI_FAILURE (Status))
741 /* Allocate a descriptor to hold the type. */
743 ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) Type);
746 Status = AE_NO_MEMORY;
751 case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */
753 * Note: The operand is not resolved at this point because we want to
754 * get the associated object, not its value.
757 /* Get the base object */
759 Status = AcpiExResolveMultiple (WalkState,
760 Operand[0], &Type, &TempDesc);
761 if (ACPI_FAILURE (Status))
767 * The type of the base object must be integer, buffer, string, or
768 * package. All others are not supported.
770 * NOTE: Integer is not specifically supported by the ACPI spec,
771 * but is supported implicitly via implicit operand conversion.
772 * rather than bother with conversion, we just use the byte width
773 * global (4 or 8 bytes).
777 case ACPI_TYPE_INTEGER:
779 Value = AcpiGbl_IntegerByteWidth;
782 case ACPI_TYPE_STRING:
784 Value = TempDesc->String.Length;
787 case ACPI_TYPE_BUFFER:
789 /* Buffer arguments may not be evaluated at this point */
791 Status = AcpiDsGetBufferArguments (TempDesc);
792 Value = TempDesc->Buffer.Length;
795 case ACPI_TYPE_PACKAGE:
797 /* Package arguments may not be evaluated at this point */
799 Status = AcpiDsGetPackageArguments (TempDesc);
800 Value = TempDesc->Package.Count;
805 ACPI_ERROR ((AE_INFO,
806 "Operand must be Buffer/Integer/String/Package - found type %s",
807 AcpiUtGetTypeName (Type)));
808 Status = AE_AML_OPERAND_TYPE;
812 if (ACPI_FAILURE (Status))
818 * Now that we have the size of the object, create a result
819 * object to hold the value
821 ReturnDesc = AcpiUtCreateIntegerObject (Value);
824 Status = AE_NO_MEMORY;
830 case AML_REF_OF_OP: /* RefOf (SourceObject) */
832 Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc, WalkState);
833 if (ACPI_FAILURE (Status))
840 case AML_DEREF_OF_OP: /* DerefOf (ObjReference | String) */
842 /* Check for a method local or argument, or standalone String */
844 if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
846 TempDesc = AcpiNsGetAttachedObject (
847 (ACPI_NAMESPACE_NODE *) Operand[0]);
849 ((TempDesc->Common.Type == ACPI_TYPE_STRING) ||
850 (TempDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)))
852 Operand[0] = TempDesc;
853 AcpiUtAddReference (TempDesc);
857 Status = AE_AML_OPERAND_TYPE;
863 switch ((Operand[0])->Common.Type)
865 case ACPI_TYPE_LOCAL_REFERENCE:
867 * This is a DerefOf (LocalX | ArgX)
869 * Must resolve/dereference the local/arg reference first
871 switch (Operand[0]->Reference.Class)
873 case ACPI_REFCLASS_LOCAL:
874 case ACPI_REFCLASS_ARG:
876 /* Set Operand[0] to the value of the local/arg */
878 Status = AcpiDsMethodDataGetValue (
879 Operand[0]->Reference.Class,
880 Operand[0]->Reference.Value,
881 WalkState, &TempDesc);
882 if (ACPI_FAILURE (Status))
888 * Delete our reference to the input object and
889 * point to the object just retrieved
891 AcpiUtRemoveReference (Operand[0]);
892 Operand[0] = TempDesc;
895 case ACPI_REFCLASS_REFOF:
897 /* Get the object to which the reference refers */
899 TempDesc = Operand[0]->Reference.Object;
900 AcpiUtRemoveReference (Operand[0]);
901 Operand[0] = TempDesc;
906 /* Must be an Index op - handled below */
911 case ACPI_TYPE_STRING:
917 Status = AE_AML_OPERAND_TYPE;
922 if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED)
924 if ((Operand[0])->Common.Type == ACPI_TYPE_STRING)
927 * This is a DerefOf (String). The string is a reference
928 * to a named ACPI object.
930 * 1) Find the owning Node
931 * 2) Dereference the node to an actual object. Could be a
932 * Field, so we need to resolve the node to a value.
934 Status = AcpiNsGetNode (WalkState->ScopeInfo->Scope.Node,
935 Operand[0]->String.Pointer,
936 ACPI_NS_SEARCH_PARENT,
937 ACPI_CAST_INDIRECT_PTR (
938 ACPI_NAMESPACE_NODE, &ReturnDesc));
939 if (ACPI_FAILURE (Status))
944 Status = AcpiExResolveNodeToValue (
945 ACPI_CAST_INDIRECT_PTR (
946 ACPI_NAMESPACE_NODE, &ReturnDesc),
952 /* Operand[0] may have changed from the code above */
954 if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
957 * This is a DerefOf (ObjectReference)
958 * Get the actual object from the Node (This is the dereference).
959 * This case may only happen when a LocalX or ArgX is
960 * dereferenced above.
962 ReturnDesc = AcpiNsGetAttachedObject (
963 (ACPI_NAMESPACE_NODE *) Operand[0]);
964 AcpiUtAddReference (ReturnDesc);
969 * This must be a reference object produced by either the
970 * Index() or RefOf() operator
972 switch (Operand[0]->Reference.Class)
974 case ACPI_REFCLASS_INDEX:
976 * The target type for the Index operator must be
977 * either a Buffer or a Package
979 switch (Operand[0]->Reference.TargetType)
981 case ACPI_TYPE_BUFFER_FIELD:
983 TempDesc = Operand[0]->Reference.Object;
986 * Create a new object that contains one element of the
987 * buffer -- the element pointed to by the index.
989 * NOTE: index into a buffer is NOT a pointer to a
990 * sub-buffer of the main buffer, it is only a pointer to a
991 * single element (byte) of the buffer!
993 * Since we are returning the value of the buffer at the
994 * indexed location, we don't need to add an additional
995 * reference to the buffer itself.
997 ReturnDesc = AcpiUtCreateIntegerObject ((UINT64)
998 TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]);
1001 Status = AE_NO_MEMORY;
1006 case ACPI_TYPE_PACKAGE:
1008 * Return the referenced element of the package. We must
1009 * add another reference to the referenced object, however.
1011 ReturnDesc = *(Operand[0]->Reference.Where);
1015 * Element is NULL, do not allow the dereference.
1016 * This provides compatibility with other ACPI
1019 return_ACPI_STATUS (AE_AML_UNINITIALIZED_ELEMENT);
1022 AcpiUtAddReference (ReturnDesc);
1027 ACPI_ERROR ((AE_INFO,
1028 "Unknown Index TargetType 0x%X in reference object %p",
1029 Operand[0]->Reference.TargetType, Operand[0]));
1030 Status = AE_AML_OPERAND_TYPE;
1035 case ACPI_REFCLASS_REFOF:
1037 ReturnDesc = Operand[0]->Reference.Object;
1039 if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) ==
1040 ACPI_DESC_TYPE_NAMED)
1042 ReturnDesc = AcpiNsGetAttachedObject (
1043 (ACPI_NAMESPACE_NODE *) ReturnDesc);
1051 * BufferFields/FieldUnits require additional resolution
1053 switch (ReturnDesc->Common.Type)
1055 case ACPI_TYPE_BUFFER_FIELD:
1056 case ACPI_TYPE_LOCAL_REGION_FIELD:
1057 case ACPI_TYPE_LOCAL_BANK_FIELD:
1058 case ACPI_TYPE_LOCAL_INDEX_FIELD:
1060 Status = AcpiExReadDataFromField (WalkState,
1061 ReturnDesc, &TempDesc);
1062 if (ACPI_FAILURE (Status))
1067 ReturnDesc = TempDesc;
1072 /* Add another reference to the object */
1074 AcpiUtAddReference (ReturnDesc);
1082 ACPI_ERROR ((AE_INFO,
1083 "Unknown class in reference(%p) - 0x%2.2X",
1084 Operand[0], Operand[0]->Reference.Class));
1094 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
1095 WalkState->Opcode));
1096 Status = AE_AML_BAD_OPCODE;
1103 /* Delete return object on error */
1105 if (ACPI_FAILURE (Status))
1107 AcpiUtRemoveReference (ReturnDesc);
1110 /* Save return object on success */
1114 WalkState->ResultObj = ReturnDesc;
1117 return_ACPI_STATUS (Status);