2 /******************************************************************************
4 * Module Name: exoparg1 - AML execution - opcodes with 1 argument
6 *****************************************************************************/
9 * Copyright (C) 2000 - 2011, Intel Corp.
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.
45 #define __EXOPARG1_C__
47 #include <contrib/dev/acpica/include/acpi.h>
48 #include <contrib/dev/acpica/include/accommon.h>
49 #include <contrib/dev/acpica/include/acparser.h>
50 #include <contrib/dev/acpica/include/acdispat.h>
51 #include <contrib/dev/acpica/include/acinterp.h>
52 #include <contrib/dev/acpica/include/amlcode.h>
53 #include <contrib/dev/acpica/include/acnamesp.h>
56 #define _COMPONENT ACPI_EXECUTER
57 ACPI_MODULE_NAME ("exoparg1")
61 * Naming convention for AML interpreter execution routines.
63 * The routines that begin execution of AML opcodes are named with a common
64 * convention based upon the number of arguments, the number of target operands,
65 * and whether or not a value is returned:
67 * AcpiExOpcode_xA_yT_zR
71 * xA - ARGUMENTS: The number of arguments (input operands) that are
72 * required for this opcode type (0 through 6 args).
73 * yT - TARGETS: The number of targets (output operands) that are required
74 * for this opcode type (0, 1, or 2 targets).
75 * zR - RETURN VALUE: Indicates whether this opcode type returns a value
76 * as the function return (0 or 1).
78 * The AcpiExOpcode* functions are called via the Dispatcher component with
79 * fully resolved operands.
82 /*******************************************************************************
84 * FUNCTION: AcpiExOpcode_0A_0T_1R
86 * PARAMETERS: WalkState - Current state (contains AML opcode)
90 * DESCRIPTION: Execute operator with no operands, one return value
92 ******************************************************************************/
95 AcpiExOpcode_0A_0T_1R (
96 ACPI_WALK_STATE *WalkState)
98 ACPI_STATUS Status = AE_OK;
99 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
102 ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R,
103 AcpiPsGetOpcodeName (WalkState->Opcode));
106 /* Examine the AML opcode */
108 switch (WalkState->Opcode)
110 case AML_TIMER_OP: /* Timer () */
112 /* Create a return object of type Integer */
114 ReturnDesc = AcpiUtCreateIntegerObject (AcpiOsGetTimer ());
117 Status = AE_NO_MEMORY;
122 default: /* Unknown opcode */
124 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
126 Status = AE_AML_BAD_OPCODE;
132 /* Delete return object on error */
134 if ((ACPI_FAILURE (Status)) || WalkState->ResultObj)
136 AcpiUtRemoveReference (ReturnDesc);
137 WalkState->ResultObj = NULL;
141 /* Save the return value */
143 WalkState->ResultObj = ReturnDesc;
146 return_ACPI_STATUS (Status);
150 /*******************************************************************************
152 * FUNCTION: AcpiExOpcode_1A_0T_0R
154 * PARAMETERS: WalkState - Current state (contains AML opcode)
158 * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
161 ******************************************************************************/
164 AcpiExOpcode_1A_0T_0R (
165 ACPI_WALK_STATE *WalkState)
167 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
168 ACPI_STATUS Status = AE_OK;
171 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R,
172 AcpiPsGetOpcodeName (WalkState->Opcode));
175 /* Examine the AML opcode */
177 switch (WalkState->Opcode)
179 case AML_RELEASE_OP: /* Release (MutexObject) */
181 Status = AcpiExReleaseMutex (Operand[0], WalkState);
185 case AML_RESET_OP: /* Reset (EventObject) */
187 Status = AcpiExSystemResetEvent (Operand[0]);
191 case AML_SIGNAL_OP: /* Signal (EventObject) */
193 Status = AcpiExSystemSignalEvent (Operand[0]);
197 case AML_SLEEP_OP: /* Sleep (MsecTime) */
199 Status = AcpiExSystemDoSleep (Operand[0]->Integer.Value);
203 case AML_STALL_OP: /* Stall (UsecTime) */
205 Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value);
209 case AML_UNLOAD_OP: /* Unload (Handle) */
211 Status = AcpiExUnloadTable (Operand[0]);
215 default: /* Unknown opcode */
217 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
219 Status = AE_AML_BAD_OPCODE;
223 return_ACPI_STATUS (Status);
227 /*******************************************************************************
229 * FUNCTION: AcpiExOpcode_1A_1T_0R
231 * PARAMETERS: WalkState - Current state (contains AML opcode)
235 * DESCRIPTION: Execute opcode with one argument, one target, and no
238 ******************************************************************************/
241 AcpiExOpcode_1A_1T_0R (
242 ACPI_WALK_STATE *WalkState)
244 ACPI_STATUS Status = AE_OK;
245 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
248 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_0R,
249 AcpiPsGetOpcodeName (WalkState->Opcode));
252 /* Examine the AML opcode */
254 switch (WalkState->Opcode)
258 Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState);
261 default: /* Unknown opcode */
263 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
265 Status = AE_AML_BAD_OPCODE;
272 return_ACPI_STATUS (Status);
276 /*******************************************************************************
278 * FUNCTION: AcpiExOpcode_1A_1T_1R
280 * PARAMETERS: WalkState - Current state (contains AML opcode)
284 * DESCRIPTION: Execute opcode with one argument, one target, and a
287 ******************************************************************************/
290 AcpiExOpcode_1A_1T_1R (
291 ACPI_WALK_STATE *WalkState)
293 ACPI_STATUS Status = AE_OK;
294 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
295 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
296 ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL;
303 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R,
304 AcpiPsGetOpcodeName (WalkState->Opcode));
307 /* Examine the AML opcode */
309 switch (WalkState->Opcode)
312 case AML_FIND_SET_LEFT_BIT_OP:
313 case AML_FIND_SET_RIGHT_BIT_OP:
314 case AML_FROM_BCD_OP:
316 case AML_COND_REF_OF_OP:
318 /* Create a return object of type Integer for these opcodes */
320 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
323 Status = AE_NO_MEMORY;
327 switch (WalkState->Opcode)
329 case AML_BIT_NOT_OP: /* Not (Operand, Result) */
331 ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value;
335 case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */
337 ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
340 * Acpi specification describes Integer type as a little
341 * endian unsigned value, so this boundary condition is valid.
343 for (Temp32 = 0; ReturnDesc->Integer.Value &&
344 Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
346 ReturnDesc->Integer.Value >>= 1;
349 ReturnDesc->Integer.Value = Temp32;
353 case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */
355 ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
358 * The Acpi specification describes Integer type as a little
359 * endian unsigned value, so this boundary condition is valid.
361 for (Temp32 = 0; ReturnDesc->Integer.Value &&
362 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 =
370 Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32;
374 case AML_FROM_BCD_OP: /* FromBcd (BCDValue, Result) */
377 * The 64-bit ACPI integer can hold 16 4-bit BCD characters
378 * (if table is 32-bit, integer can hold 8 BCD characters)
379 * Convert each 4-bit BCD value
382 ReturnDesc->Integer.Value = 0;
383 Digit = Operand[0]->Integer.Value;
385 /* Convert each BCD digit (each is one nybble wide) */
387 for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
389 /* Get the least significant 4-bit BCD digit */
391 Temp32 = ((UINT32) Digit) & 0xF;
393 /* Check the range of the digit */
397 ACPI_ERROR ((AE_INFO,
398 "BCD digit too large (not decimal): 0x%X",
401 Status = AE_AML_NUMERIC_OVERFLOW;
405 /* Sum the digit into the result with the current power of 10 */
407 ReturnDesc->Integer.Value +=
408 (((UINT64) Temp32) * PowerOfTen);
410 /* Shift to next BCD digit */
414 /* Next power of 10 */
421 case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */
423 ReturnDesc->Integer.Value = 0;
424 Digit = Operand[0]->Integer.Value;
426 /* Each BCD digit is one nybble wide */
428 for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
430 (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32);
433 * Insert the BCD digit that resides in the
434 * remainder from above
436 ReturnDesc->Integer.Value |=
437 (((UINT64) Temp32) << ACPI_MUL_4 (i));
440 /* Overflow if there is any data left in Digit */
444 ACPI_ERROR ((AE_INFO,
445 "Integer too large to convert to BCD: 0x%8.8X%8.8X",
446 ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value)));
447 Status = AE_AML_NUMERIC_OVERFLOW;
453 case AML_COND_REF_OF_OP: /* CondRefOf (SourceObject, Result) */
456 * This op is a little strange because the internal return value is
457 * different than the return value stored in the result descriptor
458 * (There are really two return values)
460 if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode)
463 * This means that the object does not exist in the namespace,
466 ReturnDesc->Integer.Value = 0;
470 /* Get the object reference, store it, and remove our reference */
472 Status = AcpiExGetObjectReference (Operand[0],
473 &ReturnDesc2, WalkState);
474 if (ACPI_FAILURE (Status))
479 Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState);
480 AcpiUtRemoveReference (ReturnDesc2);
482 /* The object exists in the namespace, return TRUE */
484 ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
489 /* No other opcodes get here */
495 case AML_STORE_OP: /* Store (Source, Target) */
498 * A store operand is typically a number, string, buffer or lvalue
499 * Be careful about deleting the source object,
500 * since the object itself may have been stored.
502 Status = AcpiExStore (Operand[0], Operand[1], WalkState);
503 if (ACPI_FAILURE (Status))
505 return_ACPI_STATUS (Status);
508 /* It is possible that the Store already produced a return object */
510 if (!WalkState->ResultObj)
513 * Normally, we would remove a reference on the Operand[0]
514 * parameter; But since it is being used as the internal return
515 * object (meaning we would normally increment it), the two
516 * cancel out, and we simply don't do anything.
518 WalkState->ResultObj = Operand[0];
519 WalkState->Operands[0] = NULL; /* Prevent deletion */
521 return_ACPI_STATUS (Status);
527 case AML_COPY_OP: /* Copy (Source, Target) */
529 Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc,
534 case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */
536 Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
537 ACPI_EXPLICIT_CONVERT_DECIMAL);
538 if (ReturnDesc == Operand[0])
540 /* No conversion performed, add ref to handle return value */
541 AcpiUtAddReference (ReturnDesc);
546 case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */
548 Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
549 ACPI_EXPLICIT_CONVERT_HEX);
550 if (ReturnDesc == Operand[0])
552 /* No conversion performed, add ref to handle return value */
553 AcpiUtAddReference (ReturnDesc);
558 case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */
560 Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc);
561 if (ReturnDesc == Operand[0])
563 /* No conversion performed, add ref to handle return value */
564 AcpiUtAddReference (ReturnDesc);
569 case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */
571 Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc,
573 if (ReturnDesc == Operand[0])
575 /* No conversion performed, add ref to handle return value */
576 AcpiUtAddReference (ReturnDesc);
581 case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */
582 case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */
584 /* These are two obsolete opcodes */
586 ACPI_ERROR ((AE_INFO,
587 "%s is obsolete and not implemented",
588 AcpiPsGetOpcodeName (WalkState->Opcode)));
593 default: /* Unknown opcode */
595 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
597 Status = AE_AML_BAD_OPCODE;
601 if (ACPI_SUCCESS (Status))
603 /* Store the return value computed above into the target object */
605 Status = AcpiExStore (ReturnDesc, Operand[1], WalkState);
611 /* Delete return object on error */
613 if (ACPI_FAILURE (Status))
615 AcpiUtRemoveReference (ReturnDesc);
618 /* Save return object on success */
620 else if (!WalkState->ResultObj)
622 WalkState->ResultObj = ReturnDesc;
625 return_ACPI_STATUS (Status);
629 /*******************************************************************************
631 * FUNCTION: AcpiExOpcode_1A_0T_1R
633 * PARAMETERS: WalkState - Current state (contains AML opcode)
637 * DESCRIPTION: Execute opcode with one argument, no target, and a return value
639 ******************************************************************************/
642 AcpiExOpcode_1A_0T_1R (
643 ACPI_WALK_STATE *WalkState)
645 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
646 ACPI_OPERAND_OBJECT *TempDesc;
647 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
648 ACPI_STATUS Status = AE_OK;
653 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R,
654 AcpiPsGetOpcodeName (WalkState->Opcode));
657 /* Examine the AML opcode */
659 switch (WalkState->Opcode)
661 case AML_LNOT_OP: /* LNot (Operand) */
663 ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
666 Status = AE_NO_MEMORY;
671 * Set result to ONES (TRUE) if Value == 0. Note:
672 * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above.
674 if (!Operand[0]->Integer.Value)
676 ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
681 case AML_DECREMENT_OP: /* Decrement (Operand) */
682 case AML_INCREMENT_OP: /* Increment (Operand) */
685 * Create a new integer. Can't just get the base integer and
686 * increment it because it may be an Arg or Field.
688 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
691 Status = AE_NO_MEMORY;
696 * Since we are expecting a Reference operand, it can be either a
697 * NS Node or an internal object.
699 TempDesc = Operand[0];
700 if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND)
702 /* Internal reference object - prevent deletion */
704 AcpiUtAddReference (TempDesc);
708 * Convert the Reference operand to an Integer (This removes a
709 * reference on the Operand[0] object)
711 * NOTE: We use LNOT_OP here in order to force resolution of the
712 * reference operand to an actual integer.
714 Status = AcpiExResolveOperands (AML_LNOT_OP, &TempDesc, WalkState);
715 if (ACPI_FAILURE (Status))
717 ACPI_EXCEPTION ((AE_INFO, Status,
718 "While resolving operands for [%s]",
719 AcpiPsGetOpcodeName (WalkState->Opcode)));
725 * TempDesc is now guaranteed to be an Integer object --
726 * Perform the actual increment or decrement
728 if (WalkState->Opcode == AML_INCREMENT_OP)
730 ReturnDesc->Integer.Value = TempDesc->Integer.Value +1;
734 ReturnDesc->Integer.Value = TempDesc->Integer.Value -1;
737 /* Finished with this Integer object */
739 AcpiUtRemoveReference (TempDesc);
742 * Store the result back (indirectly) through the original
745 Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
749 case AML_TYPE_OP: /* ObjectType (SourceObject) */
752 * Note: The operand is not resolved at this point because we want to
753 * get the associated object, not its value. For example, we don't
754 * want to resolve a FieldUnit to its value, we want the actual
758 /* Get the type of the base object */
760 Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL);
761 if (ACPI_FAILURE (Status))
766 /* Allocate a descriptor to hold the type. */
768 ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) Type);
771 Status = AE_NO_MEMORY;
777 case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */
780 * Note: The operand is not resolved at this point because we want to
781 * get the associated object, not its value.
784 /* Get the base object */
786 Status = AcpiExResolveMultiple (WalkState,
787 Operand[0], &Type, &TempDesc);
788 if (ACPI_FAILURE (Status))
794 * The type of the base object must be integer, buffer, string, or
795 * package. All others are not supported.
797 * NOTE: Integer is not specifically supported by the ACPI spec,
798 * but is supported implicitly via implicit operand conversion.
799 * rather than bother with conversion, we just use the byte width
800 * global (4 or 8 bytes).
804 case ACPI_TYPE_INTEGER:
805 Value = AcpiGbl_IntegerByteWidth;
808 case ACPI_TYPE_STRING:
809 Value = TempDesc->String.Length;
812 case ACPI_TYPE_BUFFER:
814 /* Buffer arguments may not be evaluated at this point */
816 Status = AcpiDsGetBufferArguments (TempDesc);
817 Value = TempDesc->Buffer.Length;
820 case ACPI_TYPE_PACKAGE:
822 /* Package arguments may not be evaluated at this point */
824 Status = AcpiDsGetPackageArguments (TempDesc);
825 Value = TempDesc->Package.Count;
829 ACPI_ERROR ((AE_INFO,
830 "Operand must be Buffer/Integer/String/Package - found type %s",
831 AcpiUtGetTypeName (Type)));
832 Status = AE_AML_OPERAND_TYPE;
836 if (ACPI_FAILURE (Status))
842 * Now that we have the size of the object, create a result
843 * object to hold the value
845 ReturnDesc = AcpiUtCreateIntegerObject (Value);
848 Status = AE_NO_MEMORY;
854 case AML_REF_OF_OP: /* RefOf (SourceObject) */
856 Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc, WalkState);
857 if (ACPI_FAILURE (Status))
864 case AML_DEREF_OF_OP: /* DerefOf (ObjReference | String) */
866 /* Check for a method local or argument, or standalone String */
868 if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
870 TempDesc = AcpiNsGetAttachedObject (
871 (ACPI_NAMESPACE_NODE *) Operand[0]);
873 ((TempDesc->Common.Type == ACPI_TYPE_STRING) ||
874 (TempDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)))
876 Operand[0] = TempDesc;
877 AcpiUtAddReference (TempDesc);
881 Status = AE_AML_OPERAND_TYPE;
887 switch ((Operand[0])->Common.Type)
889 case ACPI_TYPE_LOCAL_REFERENCE:
891 * This is a DerefOf (LocalX | ArgX)
893 * Must resolve/dereference the local/arg reference first
895 switch (Operand[0]->Reference.Class)
897 case ACPI_REFCLASS_LOCAL:
898 case ACPI_REFCLASS_ARG:
900 /* Set Operand[0] to the value of the local/arg */
902 Status = AcpiDsMethodDataGetValue (
903 Operand[0]->Reference.Class,
904 Operand[0]->Reference.Value,
905 WalkState, &TempDesc);
906 if (ACPI_FAILURE (Status))
912 * Delete our reference to the input object and
913 * point to the object just retrieved
915 AcpiUtRemoveReference (Operand[0]);
916 Operand[0] = TempDesc;
919 case ACPI_REFCLASS_REFOF:
921 /* Get the object to which the reference refers */
923 TempDesc = Operand[0]->Reference.Object;
924 AcpiUtRemoveReference (Operand[0]);
925 Operand[0] = TempDesc;
930 /* Must be an Index op - handled below */
935 case ACPI_TYPE_STRING:
939 Status = AE_AML_OPERAND_TYPE;
944 if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED)
946 if ((Operand[0])->Common.Type == ACPI_TYPE_STRING)
949 * This is a DerefOf (String). The string is a reference
950 * to a named ACPI object.
952 * 1) Find the owning Node
953 * 2) Dereference the node to an actual object. Could be a
954 * Field, so we need to resolve the node to a value.
956 Status = AcpiNsGetNode (WalkState->ScopeInfo->Scope.Node,
957 Operand[0]->String.Pointer,
958 ACPI_NS_SEARCH_PARENT,
959 ACPI_CAST_INDIRECT_PTR (
960 ACPI_NAMESPACE_NODE, &ReturnDesc));
961 if (ACPI_FAILURE (Status))
966 Status = AcpiExResolveNodeToValue (
967 ACPI_CAST_INDIRECT_PTR (
968 ACPI_NAMESPACE_NODE, &ReturnDesc),
974 /* Operand[0] may have changed from the code above */
976 if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
979 * This is a DerefOf (ObjectReference)
980 * Get the actual object from the Node (This is the dereference).
981 * This case may only happen when a LocalX or ArgX is
982 * dereferenced above.
984 ReturnDesc = AcpiNsGetAttachedObject (
985 (ACPI_NAMESPACE_NODE *) Operand[0]);
986 AcpiUtAddReference (ReturnDesc);
991 * This must be a reference object produced by either the
992 * Index() or RefOf() operator
994 switch (Operand[0]->Reference.Class)
996 case ACPI_REFCLASS_INDEX:
999 * The target type for the Index operator must be
1000 * either a Buffer or a Package
1002 switch (Operand[0]->Reference.TargetType)
1004 case ACPI_TYPE_BUFFER_FIELD:
1006 TempDesc = Operand[0]->Reference.Object;
1009 * Create a new object that contains one element of the
1010 * buffer -- the element pointed to by the index.
1012 * NOTE: index into a buffer is NOT a pointer to a
1013 * sub-buffer of the main buffer, it is only a pointer to a
1014 * single element (byte) of the buffer!
1016 * Since we are returning the value of the buffer at the
1017 * indexed location, we don't need to add an additional
1018 * reference to the buffer itself.
1020 ReturnDesc = AcpiUtCreateIntegerObject ((UINT64)
1021 TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]);
1024 Status = AE_NO_MEMORY;
1030 case ACPI_TYPE_PACKAGE:
1033 * Return the referenced element of the package. We must
1034 * add another reference to the referenced object, however.
1036 ReturnDesc = *(Operand[0]->Reference.Where);
1039 AcpiUtAddReference (ReturnDesc);
1046 ACPI_ERROR ((AE_INFO,
1047 "Unknown Index TargetType 0x%X in reference object %p",
1048 Operand[0]->Reference.TargetType, Operand[0]));
1049 Status = AE_AML_OPERAND_TYPE;
1055 case ACPI_REFCLASS_REFOF:
1057 ReturnDesc = Operand[0]->Reference.Object;
1059 if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) ==
1060 ACPI_DESC_TYPE_NAMED)
1062 ReturnDesc = AcpiNsGetAttachedObject (
1063 (ACPI_NAMESPACE_NODE *) ReturnDesc);
1066 /* Add another reference to the object! */
1068 AcpiUtAddReference (ReturnDesc);
1073 ACPI_ERROR ((AE_INFO,
1074 "Unknown class in reference(%p) - 0x%2.2X",
1075 Operand[0], Operand[0]->Reference.Class));
1086 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
1087 WalkState->Opcode));
1088 Status = AE_AML_BAD_OPCODE;
1095 /* Delete return object on error */
1097 if (ACPI_FAILURE (Status))
1099 AcpiUtRemoveReference (ReturnDesc);
1102 /* Save return object on success */
1106 WalkState->ResultObj = ReturnDesc;
1109 return_ACPI_STATUS (Status);