2 /******************************************************************************
4 * Module Name: exoparg1 - AML execution - opcodes with 1 argument
7 *****************************************************************************/
9 /******************************************************************************
13 * Some or all of this work - Copyright (c) 1999 - 2006, 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 *****************************************************************************/
118 #define __EXOPARG1_C__
121 #include "acparser.h"
122 #include "acdispat.h"
123 #include "acinterp.h"
125 #include "acnamesp.h"
128 #define _COMPONENT ACPI_EXECUTER
129 ACPI_MODULE_NAME ("exoparg1")
133 * Naming convention for AML interpreter execution routines.
135 * The routines that begin execution of AML opcodes are named with a common
136 * convention based upon the number of arguments, the number of target operands,
137 * and whether or not a value is returned:
139 * AcpiExOpcode_xA_yT_zR
143 * xA - ARGUMENTS: The number of arguments (input operands) that are
144 * required for this opcode type (0 through 6 args).
145 * yT - TARGETS: The number of targets (output operands) that are required
146 * for this opcode type (0, 1, or 2 targets).
147 * zR - RETURN VALUE: Indicates whether this opcode type returns a value
148 * as the function return (0 or 1).
150 * The AcpiExOpcode* functions are called via the Dispatcher component with
151 * fully resolved operands.
154 /*******************************************************************************
156 * FUNCTION: AcpiExOpcode_0A_0T_1R
158 * PARAMETERS: WalkState - Current state (contains AML opcode)
162 * DESCRIPTION: Execute operator with no operands, one return value
164 ******************************************************************************/
167 AcpiExOpcode_0A_0T_1R (
168 ACPI_WALK_STATE *WalkState)
170 ACPI_STATUS Status = AE_OK;
171 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
174 ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R,
175 AcpiPsGetOpcodeName (WalkState->Opcode));
178 /* Examine the AML opcode */
180 switch (WalkState->Opcode)
182 case AML_TIMER_OP: /* Timer () */
184 /* Create a return object of type Integer */
186 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
189 Status = AE_NO_MEMORY;
192 #if ACPI_MACHINE_WIDTH != 16
193 ReturnDesc->Integer.Value = AcpiOsGetTimer ();
197 default: /* Unknown opcode */
199 ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X",
201 Status = AE_AML_BAD_OPCODE;
207 /* Delete return object on error */
209 if ((ACPI_FAILURE (Status)) || WalkState->ResultObj)
211 AcpiUtRemoveReference (ReturnDesc);
215 /* Save the return value */
217 WalkState->ResultObj = ReturnDesc;
220 return_ACPI_STATUS (Status);
224 /*******************************************************************************
226 * FUNCTION: AcpiExOpcode_1A_0T_0R
228 * PARAMETERS: WalkState - Current state (contains AML opcode)
232 * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
235 ******************************************************************************/
238 AcpiExOpcode_1A_0T_0R (
239 ACPI_WALK_STATE *WalkState)
241 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
242 ACPI_STATUS Status = AE_OK;
245 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R,
246 AcpiPsGetOpcodeName (WalkState->Opcode));
249 /* Examine the AML opcode */
251 switch (WalkState->Opcode)
253 case AML_RELEASE_OP: /* Release (MutexObject) */
255 Status = AcpiExReleaseMutex (Operand[0], WalkState);
259 case AML_RESET_OP: /* Reset (EventObject) */
261 Status = AcpiExSystemResetEvent (Operand[0]);
265 case AML_SIGNAL_OP: /* Signal (EventObject) */
267 Status = AcpiExSystemSignalEvent (Operand[0]);
271 case AML_SLEEP_OP: /* Sleep (MsecTime) */
273 Status = AcpiExSystemDoSuspend (Operand[0]->Integer.Value);
277 case AML_STALL_OP: /* Stall (UsecTime) */
279 Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value);
283 case AML_UNLOAD_OP: /* Unload (Handle) */
285 Status = AcpiExUnloadTable (Operand[0]);
289 default: /* Unknown opcode */
291 ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X",
293 Status = AE_AML_BAD_OPCODE;
297 return_ACPI_STATUS (Status);
301 /*******************************************************************************
303 * FUNCTION: AcpiExOpcode_1A_1T_0R
305 * PARAMETERS: WalkState - Current state (contains AML opcode)
309 * DESCRIPTION: Execute opcode with one argument, one target, and no
312 ******************************************************************************/
315 AcpiExOpcode_1A_1T_0R (
316 ACPI_WALK_STATE *WalkState)
318 ACPI_STATUS Status = AE_OK;
319 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
322 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_0R,
323 AcpiPsGetOpcodeName (WalkState->Opcode));
326 /* Examine the AML opcode */
328 switch (WalkState->Opcode)
332 Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState);
335 default: /* Unknown opcode */
337 ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X",
339 Status = AE_AML_BAD_OPCODE;
346 return_ACPI_STATUS (Status);
350 /*******************************************************************************
352 * FUNCTION: AcpiExOpcode_1A_1T_1R
354 * PARAMETERS: WalkState - Current state (contains AML opcode)
358 * DESCRIPTION: Execute opcode with one argument, one target, and a
361 ******************************************************************************/
364 AcpiExOpcode_1A_1T_1R (
365 ACPI_WALK_STATE *WalkState)
367 ACPI_STATUS Status = AE_OK;
368 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
369 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
370 ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL;
373 ACPI_INTEGER PowerOfTen;
377 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R,
378 AcpiPsGetOpcodeName (WalkState->Opcode));
381 /* Examine the AML opcode */
383 switch (WalkState->Opcode)
386 case AML_FIND_SET_LEFT_BIT_OP:
387 case AML_FIND_SET_RIGHT_BIT_OP:
388 case AML_FROM_BCD_OP:
390 case AML_COND_REF_OF_OP:
392 /* Create a return object of type Integer for these opcodes */
394 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
397 Status = AE_NO_MEMORY;
401 switch (WalkState->Opcode)
403 case AML_BIT_NOT_OP: /* Not (Operand, Result) */
405 ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value;
409 case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */
411 ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
414 * Acpi specification describes Integer type as a little
415 * endian unsigned value, so this boundary condition is valid.
417 for (Temp32 = 0; ReturnDesc->Integer.Value &&
418 Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
420 ReturnDesc->Integer.Value >>= 1;
423 ReturnDesc->Integer.Value = Temp32;
427 case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */
429 ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
432 * The Acpi specification describes Integer type as a little
433 * endian unsigned value, so this boundary condition is valid.
435 for (Temp32 = 0; ReturnDesc->Integer.Value &&
436 Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
438 ReturnDesc->Integer.Value <<= 1;
441 /* Since the bit position is one-based, subtract from 33 (65) */
443 ReturnDesc->Integer.Value =
444 Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32;
448 case AML_FROM_BCD_OP: /* FromBcd (BCDValue, Result) */
451 * The 64-bit ACPI integer can hold 16 4-bit BCD characters
452 * (if table is 32-bit, integer can hold 8 BCD characters)
453 * Convert each 4-bit BCD value
456 ReturnDesc->Integer.Value = 0;
457 Digit = Operand[0]->Integer.Value;
459 /* Convert each BCD digit (each is one nybble wide) */
461 for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
463 /* Get the least significant 4-bit BCD digit */
465 Temp32 = ((UINT32) Digit) & 0xF;
467 /* Check the range of the digit */
471 ACPI_ERROR ((AE_INFO,
472 "BCD digit too large (not decimal): 0x%X",
475 Status = AE_AML_NUMERIC_OVERFLOW;
479 /* Sum the digit into the result with the current power of 10 */
481 ReturnDesc->Integer.Value +=
482 (((ACPI_INTEGER) Temp32) * PowerOfTen);
484 /* Shift to next BCD digit */
488 /* Next power of 10 */
495 case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */
497 ReturnDesc->Integer.Value = 0;
498 Digit = Operand[0]->Integer.Value;
500 /* Each BCD digit is one nybble wide */
502 for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
504 (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32);
507 * Insert the BCD digit that resides in the
508 * remainder from above
510 ReturnDesc->Integer.Value |=
511 (((ACPI_INTEGER) Temp32) << ACPI_MUL_4 (i));
514 /* Overflow if there is any data left in Digit */
518 ACPI_ERROR ((AE_INFO,
519 "Integer too large to convert to BCD: %8.8X%8.8X",
520 ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value)));
521 Status = AE_AML_NUMERIC_OVERFLOW;
527 case AML_COND_REF_OF_OP: /* CondRefOf (SourceObject, Result) */
530 * This op is a little strange because the internal return value is
531 * different than the return value stored in the result descriptor
532 * (There are really two return values)
534 if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode)
537 * This means that the object does not exist in the namespace,
540 ReturnDesc->Integer.Value = 0;
544 /* Get the object reference, store it, and remove our reference */
546 Status = AcpiExGetObjectReference (Operand[0],
547 &ReturnDesc2, WalkState);
548 if (ACPI_FAILURE (Status))
553 Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState);
554 AcpiUtRemoveReference (ReturnDesc2);
556 /* The object exists in the namespace, return TRUE */
558 ReturnDesc->Integer.Value = ACPI_INTEGER_MAX;
563 /* No other opcodes get here */
569 case AML_STORE_OP: /* Store (Source, Target) */
572 * A store operand is typically a number, string, buffer or lvalue
573 * Be careful about deleting the source object,
574 * since the object itself may have been stored.
576 Status = AcpiExStore (Operand[0], Operand[1], WalkState);
577 if (ACPI_FAILURE (Status))
579 return_ACPI_STATUS (Status);
582 /* It is possible that the Store already produced a return object */
584 if (!WalkState->ResultObj)
587 * Normally, we would remove a reference on the Operand[0]
588 * parameter; But since it is being used as the internal return
589 * object (meaning we would normally increment it), the two
590 * cancel out, and we simply don't do anything.
592 WalkState->ResultObj = Operand[0];
593 WalkState->Operands[0] = NULL; /* Prevent deletion */
595 return_ACPI_STATUS (Status);
601 case AML_COPY_OP: /* Copy (Source, Target) */
603 Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc,
608 case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */
610 Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
611 ACPI_EXPLICIT_CONVERT_DECIMAL);
612 if (ReturnDesc == Operand[0])
614 /* No conversion performed, add ref to handle return value */
615 AcpiUtAddReference (ReturnDesc);
620 case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */
622 Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
623 ACPI_EXPLICIT_CONVERT_HEX);
624 if (ReturnDesc == Operand[0])
626 /* No conversion performed, add ref to handle return value */
627 AcpiUtAddReference (ReturnDesc);
632 case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */
634 Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc);
635 if (ReturnDesc == Operand[0])
637 /* No conversion performed, add ref to handle return value */
638 AcpiUtAddReference (ReturnDesc);
643 case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */
645 Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc,
647 if (ReturnDesc == Operand[0])
649 /* No conversion performed, add ref to handle return value */
650 AcpiUtAddReference (ReturnDesc);
655 case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */
656 case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */
658 /* These are two obsolete opcodes */
660 ACPI_ERROR ((AE_INFO,
661 "%s is obsolete and not implemented",
662 AcpiPsGetOpcodeName (WalkState->Opcode)));
667 default: /* Unknown opcode */
669 ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X",
671 Status = AE_AML_BAD_OPCODE;
675 if (ACPI_SUCCESS (Status))
677 /* Store the return value computed above into the target object */
679 Status = AcpiExStore (ReturnDesc, Operand[1], WalkState);
685 /* Delete return object on error */
687 if (ACPI_FAILURE (Status))
689 AcpiUtRemoveReference (ReturnDesc);
692 /* Save return object on success */
694 else if (!WalkState->ResultObj)
696 WalkState->ResultObj = ReturnDesc;
699 return_ACPI_STATUS (Status);
703 /*******************************************************************************
705 * FUNCTION: AcpiExOpcode_1A_0T_1R
707 * PARAMETERS: WalkState - Current state (contains AML opcode)
711 * DESCRIPTION: Execute opcode with one argument, no target, and a return value
713 ******************************************************************************/
716 AcpiExOpcode_1A_0T_1R (
717 ACPI_WALK_STATE *WalkState)
719 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
720 ACPI_OPERAND_OBJECT *TempDesc;
721 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
722 ACPI_STATUS Status = AE_OK;
727 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R,
728 AcpiPsGetOpcodeName (WalkState->Opcode));
731 /* Examine the AML opcode */
733 switch (WalkState->Opcode)
735 case AML_LNOT_OP: /* LNot (Operand) */
737 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
740 Status = AE_NO_MEMORY;
745 * Set result to ONES (TRUE) if Value == 0. Note:
746 * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above.
748 if (!Operand[0]->Integer.Value)
750 ReturnDesc->Integer.Value = ACPI_INTEGER_MAX;
755 case AML_DECREMENT_OP: /* Decrement (Operand) */
756 case AML_INCREMENT_OP: /* Increment (Operand) */
759 * Create a new integer. Can't just get the base integer and
760 * increment it because it may be an Arg or Field.
762 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
765 Status = AE_NO_MEMORY;
770 * Since we are expecting a Reference operand, it can be either a
771 * NS Node or an internal object.
773 TempDesc = Operand[0];
774 if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND)
776 /* Internal reference object - prevent deletion */
778 AcpiUtAddReference (TempDesc);
782 * Convert the Reference operand to an Integer (This removes a
783 * reference on the Operand[0] object)
785 * NOTE: We use LNOT_OP here in order to force resolution of the
786 * reference operand to an actual integer.
788 Status = AcpiExResolveOperands (AML_LNOT_OP, &TempDesc, WalkState);
789 if (ACPI_FAILURE (Status))
791 ACPI_EXCEPTION ((AE_INFO, Status,
792 "While resolving operands for [%s]",
793 AcpiPsGetOpcodeName (WalkState->Opcode)));
799 * TempDesc is now guaranteed to be an Integer object --
800 * Perform the actual increment or decrement
802 if (WalkState->Opcode == AML_INCREMENT_OP)
804 ReturnDesc->Integer.Value = TempDesc->Integer.Value +1;
808 ReturnDesc->Integer.Value = TempDesc->Integer.Value -1;
811 /* Finished with this Integer object */
813 AcpiUtRemoveReference (TempDesc);
816 * Store the result back (indirectly) through the original
819 Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
823 case AML_TYPE_OP: /* ObjectType (SourceObject) */
826 * Note: The operand is not resolved at this point because we want to
827 * get the associated object, not its value. For example, we don't
828 * want to resolve a FieldUnit to its value, we want the actual
832 /* Get the type of the base object */
834 Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL);
835 if (ACPI_FAILURE (Status))
840 /* Allocate a descriptor to hold the type. */
842 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
845 Status = AE_NO_MEMORY;
849 ReturnDesc->Integer.Value = Type;
853 case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */
856 * Note: The operand is not resolved at this point because we want to
857 * get the associated object, not its value.
860 /* Get the base object */
862 Status = AcpiExResolveMultiple (WalkState,
863 Operand[0], &Type, &TempDesc);
864 if (ACPI_FAILURE (Status))
870 * The type of the base object must be integer, buffer, string, or
871 * package. All others are not supported.
873 * NOTE: Integer is not specifically supported by the ACPI spec,
874 * but is supported implicitly via implicit operand conversion.
875 * rather than bother with conversion, we just use the byte width
876 * global (4 or 8 bytes).
880 case ACPI_TYPE_INTEGER:
881 Value = AcpiGbl_IntegerByteWidth;
884 case ACPI_TYPE_BUFFER:
885 Value = TempDesc->Buffer.Length;
888 case ACPI_TYPE_STRING:
889 Value = TempDesc->String.Length;
892 case ACPI_TYPE_PACKAGE:
893 Value = TempDesc->Package.Count;
897 ACPI_ERROR ((AE_INFO,
898 "Operand is not Buf/Int/Str/Pkg - found type %s",
899 AcpiUtGetTypeName (Type)));
900 Status = AE_AML_OPERAND_TYPE;
905 * Now that we have the size of the object, create a result
906 * object to hold the value
908 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
911 Status = AE_NO_MEMORY;
915 ReturnDesc->Integer.Value = Value;
919 case AML_REF_OF_OP: /* RefOf (SourceObject) */
921 Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc, WalkState);
922 if (ACPI_FAILURE (Status))
929 case AML_DEREF_OF_OP: /* DerefOf (ObjReference | String) */
931 /* Check for a method local or argument, or standalone String */
933 if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
935 TempDesc = AcpiNsGetAttachedObject (
936 (ACPI_NAMESPACE_NODE *) Operand[0]);
938 ((ACPI_GET_OBJECT_TYPE (TempDesc) == ACPI_TYPE_STRING) ||
939 (ACPI_GET_OBJECT_TYPE (TempDesc) == ACPI_TYPE_LOCAL_REFERENCE)))
941 Operand[0] = TempDesc;
942 AcpiUtAddReference (TempDesc);
946 Status = AE_AML_OPERAND_TYPE;
952 switch (ACPI_GET_OBJECT_TYPE (Operand[0]))
954 case ACPI_TYPE_LOCAL_REFERENCE:
956 * This is a DerefOf (LocalX | ArgX)
958 * Must resolve/dereference the local/arg reference first
960 switch (Operand[0]->Reference.Opcode)
965 /* Set Operand[0] to the value of the local/arg */
967 Status = AcpiDsMethodDataGetValue (
968 Operand[0]->Reference.Opcode,
969 Operand[0]->Reference.Offset,
970 WalkState, &TempDesc);
971 if (ACPI_FAILURE (Status))
977 * Delete our reference to the input object and
978 * point to the object just retrieved
980 AcpiUtRemoveReference (Operand[0]);
981 Operand[0] = TempDesc;
986 /* Get the object to which the reference refers */
988 TempDesc = Operand[0]->Reference.Object;
989 AcpiUtRemoveReference (Operand[0]);
990 Operand[0] = TempDesc;
995 /* Must be an Index op - handled below */
1000 case ACPI_TYPE_STRING:
1004 Status = AE_AML_OPERAND_TYPE;
1009 if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED)
1011 if (ACPI_GET_OBJECT_TYPE (Operand[0]) == ACPI_TYPE_STRING)
1014 * This is a DerefOf (String). The string is a reference
1015 * to a named ACPI object.
1017 * 1) Find the owning Node
1018 * 2) Dereference the node to an actual object. Could be a
1019 * Field, so we need to resolve the node to a value.
1021 Status = AcpiNsGetNode (WalkState->ScopeInfo->Scope.Node,
1022 Operand[0]->String.Pointer,
1023 ACPI_NS_SEARCH_PARENT,
1024 ACPI_CAST_INDIRECT_PTR (
1025 ACPI_NAMESPACE_NODE, &ReturnDesc));
1026 if (ACPI_FAILURE (Status))
1031 Status = AcpiExResolveNodeToValue (
1032 ACPI_CAST_INDIRECT_PTR (
1033 ACPI_NAMESPACE_NODE, &ReturnDesc),
1039 /* Operand[0] may have changed from the code above */
1041 if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
1044 * This is a DerefOf (ObjectReference)
1045 * Get the actual object from the Node (This is the dereference).
1046 * This case may only happen when a LocalX or ArgX is
1047 * dereferenced above.
1049 ReturnDesc = AcpiNsGetAttachedObject (
1050 (ACPI_NAMESPACE_NODE *) Operand[0]);
1051 AcpiUtAddReference (ReturnDesc);
1056 * This must be a reference object produced by either the
1057 * Index() or RefOf() operator
1059 switch (Operand[0]->Reference.Opcode)
1064 * The target type for the Index operator must be
1065 * either a Buffer or a Package
1067 switch (Operand[0]->Reference.TargetType)
1069 case ACPI_TYPE_BUFFER_FIELD:
1071 TempDesc = Operand[0]->Reference.Object;
1074 * Create a new object that contains one element of the
1075 * buffer -- the element pointed to by the index.
1077 * NOTE: index into a buffer is NOT a pointer to a
1078 * sub-buffer of the main buffer, it is only a pointer to a
1079 * single element (byte) of the buffer!
1081 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
1084 Status = AE_NO_MEMORY;
1089 * Since we are returning the value of the buffer at the
1090 * indexed location, we don't need to add an additional
1091 * reference to the buffer itself.
1093 ReturnDesc->Integer.Value =
1094 TempDesc->Buffer.Pointer[Operand[0]->Reference.Offset];
1098 case ACPI_TYPE_PACKAGE:
1101 * Return the referenced element of the package. We must
1102 * add another reference to the referenced object, however.
1104 ReturnDesc = *(Operand[0]->Reference.Where);
1107 AcpiUtAddReference (ReturnDesc);
1114 ACPI_ERROR ((AE_INFO,
1115 "Unknown Index TargetType %X in obj %p",
1116 Operand[0]->Reference.TargetType, Operand[0]));
1117 Status = AE_AML_OPERAND_TYPE;
1125 ReturnDesc = Operand[0]->Reference.Object;
1127 if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) ==
1128 ACPI_DESC_TYPE_NAMED)
1130 ReturnDesc = AcpiNsGetAttachedObject (
1131 (ACPI_NAMESPACE_NODE *) ReturnDesc);
1134 /* Add another reference to the object! */
1136 AcpiUtAddReference (ReturnDesc);
1141 ACPI_ERROR ((AE_INFO,
1142 "Unknown opcode in reference(%p) - %X",
1143 Operand[0], Operand[0]->Reference.Opcode));
1154 ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X",
1155 WalkState->Opcode));
1156 Status = AE_AML_BAD_OPCODE;
1163 /* Delete return object on error */
1165 if (ACPI_FAILURE (Status))
1167 AcpiUtRemoveReference (ReturnDesc);
1170 /* Save return object on success */
1174 WalkState->ResultObj = ReturnDesc;
1177 return_ACPI_STATUS (Status);