2 /******************************************************************************
4 * Module Name: exoparg1 - AML execution - opcodes with 1 argument
7 *****************************************************************************/
9 /******************************************************************************
13 * Some or all of this work - Copyright (c) 1999 - 2004, 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__
120 #include <contrib/dev/acpica/acpi.h>
121 #include <contrib/dev/acpica/acparser.h>
122 #include <contrib/dev/acpica/acdispat.h>
123 #include <contrib/dev/acpica/acinterp.h>
124 #include <contrib/dev/acpica/amlcode.h>
125 #include <contrib/dev/acpica/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", AcpiPsGetOpcodeName (WalkState->Opcode));
177 /* Examine the AML opcode */
179 switch (WalkState->Opcode)
181 case AML_TIMER_OP: /* Timer () */
183 /* Create a return object of type Integer */
185 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
188 Status = AE_NO_MEMORY;
192 ReturnDesc->Integer.Value = AcpiOsGetTimer ();
195 default: /* Unknown opcode */
197 ACPI_REPORT_ERROR (("AcpiExOpcode_0A_0T_1R: Unknown opcode %X\n",
199 Status = AE_AML_BAD_OPCODE;
205 if (!WalkState->ResultObj)
207 WalkState->ResultObj = ReturnDesc;
210 /* Delete return object on error */
212 if (ACPI_FAILURE (Status))
214 AcpiUtRemoveReference (ReturnDesc);
217 return_ACPI_STATUS (Status);
221 /*******************************************************************************
223 * FUNCTION: AcpiExOpcode_1A_0T_0R
225 * PARAMETERS: WalkState - Current state (contains AML opcode)
229 * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
232 ******************************************************************************/
235 AcpiExOpcode_1A_0T_0R (
236 ACPI_WALK_STATE *WalkState)
238 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
239 ACPI_STATUS Status = AE_OK;
242 ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_0R", AcpiPsGetOpcodeName (WalkState->Opcode));
245 /* Examine the AML opcode */
247 switch (WalkState->Opcode)
249 case AML_RELEASE_OP: /* Release (MutexObject) */
251 Status = AcpiExReleaseMutex (Operand[0], WalkState);
255 case AML_RESET_OP: /* Reset (EventObject) */
257 Status = AcpiExSystemResetEvent (Operand[0]);
261 case AML_SIGNAL_OP: /* Signal (EventObject) */
263 Status = AcpiExSystemSignalEvent (Operand[0]);
267 case AML_SLEEP_OP: /* Sleep (MsecTime) */
269 Status = AcpiExSystemDoSuspend (Operand[0]->Integer.Value);
273 case AML_STALL_OP: /* Stall (UsecTime) */
275 Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value);
279 case AML_UNLOAD_OP: /* Unload (Handle) */
281 Status = AcpiExUnloadTable (Operand[0]);
285 default: /* Unknown opcode */
287 ACPI_REPORT_ERROR (("AcpiExOpcode_1A_0T_0R: Unknown opcode %X\n",
289 Status = AE_AML_BAD_OPCODE;
293 return_ACPI_STATUS (Status);
297 /*******************************************************************************
299 * FUNCTION: AcpiExOpcode_1A_1T_0R
301 * PARAMETERS: WalkState - Current state (contains AML opcode)
305 * DESCRIPTION: Execute opcode with one argument, one target, and no
308 ******************************************************************************/
311 AcpiExOpcode_1A_1T_0R (
312 ACPI_WALK_STATE *WalkState)
314 ACPI_STATUS Status = AE_OK;
315 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
318 ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_0R", AcpiPsGetOpcodeName (WalkState->Opcode));
321 /* Examine the AML opcode */
323 switch (WalkState->Opcode)
327 Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState);
330 default: /* Unknown opcode */
332 ACPI_REPORT_ERROR (("AcpiExOpcode_1A_1T_0R: Unknown opcode %X\n",
334 Status = AE_AML_BAD_OPCODE;
341 return_ACPI_STATUS (Status);
345 /*******************************************************************************
347 * FUNCTION: AcpiExOpcode_1A_1T_1R
349 * PARAMETERS: WalkState - Current state (contains AML opcode)
353 * DESCRIPTION: Execute opcode with one argument, one target, and a
356 ******************************************************************************/
359 AcpiExOpcode_1A_1T_1R (
360 ACPI_WALK_STATE *WalkState)
362 ACPI_STATUS Status = AE_OK;
363 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
364 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
365 ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL;
368 ACPI_INTEGER PowerOfTen;
372 ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_1R", AcpiPsGetOpcodeName (WalkState->Opcode));
375 /* Examine the AML opcode */
377 switch (WalkState->Opcode)
380 case AML_FIND_SET_LEFT_BIT_OP:
381 case AML_FIND_SET_RIGHT_BIT_OP:
382 case AML_FROM_BCD_OP:
384 case AML_COND_REF_OF_OP:
386 /* Create a return object of type Integer for these opcodes */
388 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
391 Status = AE_NO_MEMORY;
395 switch (WalkState->Opcode)
397 case AML_BIT_NOT_OP: /* Not (Operand, Result) */
399 ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value;
403 case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */
405 ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
408 * Acpi specification describes Integer type as a little
409 * endian unsigned value, so this boundary condition is valid.
411 for (Temp32 = 0; ReturnDesc->Integer.Value &&
412 Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
414 ReturnDesc->Integer.Value >>= 1;
417 ReturnDesc->Integer.Value = Temp32;
421 case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */
423 ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
426 * The Acpi specification describes Integer type as a little
427 * endian unsigned value, so this boundary condition is valid.
429 for (Temp32 = 0; ReturnDesc->Integer.Value &&
430 Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
432 ReturnDesc->Integer.Value <<= 1;
435 /* Since the bit position is one-based, subtract from 33 (65) */
437 ReturnDesc->Integer.Value = Temp32 == 0 ? 0 :
438 (ACPI_INTEGER_BIT_SIZE + 1) - Temp32;
442 case AML_FROM_BCD_OP: /* FromBcd (BCDValue, Result) */
445 * The 64-bit ACPI integer can hold 16 4-bit BCD characters
446 * (if table is 32-bit, integer can hold 8 BCD characters)
447 * Convert each 4-bit BCD value
450 ReturnDesc->Integer.Value = 0;
451 Digit = Operand[0]->Integer.Value;
453 /* Convert each BCD digit (each is one nybble wide) */
455 for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
457 /* Get the least significant 4-bit BCD digit */
459 Temp32 = ((UINT32) Digit) & 0xF;
461 /* Check the range of the digit */
465 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
466 "BCD digit too large (not decimal): 0x%X\n",
469 Status = AE_AML_NUMERIC_OVERFLOW;
473 /* Sum the digit into the result with the current power of 10 */
475 ReturnDesc->Integer.Value += (((ACPI_INTEGER) Temp32) *
478 /* Shift to next BCD digit */
482 /* Next power of 10 */
489 case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */
491 ReturnDesc->Integer.Value = 0;
492 Digit = Operand[0]->Integer.Value;
494 /* Each BCD digit is one nybble wide */
496 for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
498 (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32);
500 /* Insert the BCD digit that resides in the remainder from above */
502 ReturnDesc->Integer.Value |= (((ACPI_INTEGER) Temp32) <<
506 /* Overflow if there is any data left in Digit */
510 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
511 "Integer too large to convert to BCD: %8.8X%8.8X\n",
512 ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value)));
513 Status = AE_AML_NUMERIC_OVERFLOW;
519 case AML_COND_REF_OF_OP: /* CondRefOf (SourceObject, Result) */
522 * This op is a little strange because the internal return value is
523 * different than the return value stored in the result descriptor
524 * (There are really two return values)
526 if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode)
529 * This means that the object does not exist in the namespace,
532 ReturnDesc->Integer.Value = 0;
536 /* Get the object reference, store it, and remove our reference */
538 Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc2, WalkState);
539 if (ACPI_FAILURE (Status))
544 Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState);
545 AcpiUtRemoveReference (ReturnDesc2);
547 /* The object exists in the namespace, return TRUE */
549 ReturnDesc->Integer.Value = ACPI_INTEGER_MAX;
554 /* No other opcodes get here */
560 case AML_STORE_OP: /* Store (Source, Target) */
563 * A store operand is typically a number, string, buffer or lvalue
564 * Be careful about deleting the source object,
565 * since the object itself may have been stored.
567 Status = AcpiExStore (Operand[0], Operand[1], WalkState);
568 if (ACPI_FAILURE (Status))
570 return_ACPI_STATUS (Status);
573 /* It is possible that the Store already produced a return object */
575 if (!WalkState->ResultObj)
578 * Normally, we would remove a reference on the Operand[0] parameter;
579 * But since it is being used as the internal return object
580 * (meaning we would normally increment it), the two cancel out,
581 * and we simply don't do anything.
583 WalkState->ResultObj = Operand[0];
584 WalkState->Operands[0] = NULL; /* Prevent deletion */
586 return_ACPI_STATUS (Status);
592 case AML_COPY_OP: /* Copy (Source, Target) */
594 Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc,
599 case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */
601 Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
602 ACPI_EXPLICIT_CONVERT_DECIMAL);
606 case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */
608 Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
609 ACPI_EXPLICIT_CONVERT_HEX);
613 case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */
615 Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc);
619 case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */
621 Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc,
626 case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */
627 case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */
630 * These are two obsolete opcodes
632 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
633 "%s is obsolete and not implemented\n",
634 AcpiPsGetOpcodeName (WalkState->Opcode)));
639 default: /* Unknown opcode */
641 ACPI_REPORT_ERROR (("AcpiExOpcode_1A_1T_1R: Unknown opcode %X\n",
643 Status = AE_AML_BAD_OPCODE;
648 * Store the return value computed above into the target object
650 Status = AcpiExStore (ReturnDesc, Operand[1], WalkState);
655 if (!WalkState->ResultObj)
657 WalkState->ResultObj = ReturnDesc;
660 /* Delete return object on error */
662 if (ACPI_FAILURE (Status))
664 AcpiUtRemoveReference (ReturnDesc);
667 return_ACPI_STATUS (Status);
671 /*******************************************************************************
673 * FUNCTION: AcpiExOpcode_1A_0T_1R
675 * PARAMETERS: WalkState - Current state (contains AML opcode)
679 * DESCRIPTION: Execute opcode with one argument, no target, and a return value
681 ******************************************************************************/
684 AcpiExOpcode_1A_0T_1R (
685 ACPI_WALK_STATE *WalkState)
687 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
688 ACPI_OPERAND_OBJECT *TempDesc;
689 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
690 ACPI_STATUS Status = AE_OK;
695 ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_1R", AcpiPsGetOpcodeName (WalkState->Opcode));
698 /* Examine the AML opcode */
700 switch (WalkState->Opcode)
702 case AML_LNOT_OP: /* LNot (Operand) */
704 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
707 Status = AE_NO_MEMORY;
712 * Set result to ONES (TRUE) if Value == 0. Note:
713 * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above.
715 if (!Operand[0]->Integer.Value)
717 ReturnDesc->Integer.Value = ACPI_INTEGER_MAX;
722 case AML_DECREMENT_OP: /* Decrement (Operand) */
723 case AML_INCREMENT_OP: /* Increment (Operand) */
726 * Create a new integer. Can't just get the base integer and
727 * increment it because it may be an Arg or Field.
729 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
732 Status = AE_NO_MEMORY;
737 * Since we are expecting a Reference operand, it can be either a
738 * NS Node or an internal object.
740 TempDesc = Operand[0];
741 if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND)
743 /* Internal reference object - prevent deletion */
745 AcpiUtAddReference (TempDesc);
749 * Convert the Reference operand to an Integer (This removes a
750 * reference on the Operand[0] object)
752 * NOTE: We use LNOT_OP here in order to force resolution of the
753 * reference operand to an actual integer.
755 Status = AcpiExResolveOperands (AML_LNOT_OP, &TempDesc, WalkState);
756 if (ACPI_FAILURE (Status))
758 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s: bad operand(s) %s\n",
759 AcpiPsGetOpcodeName (WalkState->Opcode),
760 AcpiFormatException(Status)));
766 * TempDesc is now guaranteed to be an Integer object --
767 * Perform the actual increment or decrement
769 if (WalkState->Opcode == AML_INCREMENT_OP)
771 ReturnDesc->Integer.Value = TempDesc->Integer.Value +1;
775 ReturnDesc->Integer.Value = TempDesc->Integer.Value -1;
778 /* Finished with this Integer object */
780 AcpiUtRemoveReference (TempDesc);
783 * Store the result back (indirectly) through the original
786 Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
790 case AML_TYPE_OP: /* ObjectType (SourceObject) */
793 * Note: The operand is not resolved at this point because we want to
794 * get the associated object, not its value. For example, we don't want
795 * to resolve a FieldUnit to its value, we want the actual FieldUnit
799 /* Get the type of the base object */
801 Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL);
802 if (ACPI_FAILURE (Status))
806 /* Allocate a descriptor to hold the type. */
808 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
811 Status = AE_NO_MEMORY;
815 ReturnDesc->Integer.Value = Type;
819 case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */
822 * Note: The operand is not resolved at this point because we want to
823 * get the associated object, not its value.
826 /* Get the base object */
828 Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, &TempDesc);
829 if (ACPI_FAILURE (Status))
835 * The type of the base object must be integer, buffer, string, or
836 * package. All others are not supported.
838 * NOTE: Integer is not specifically supported by the ACPI spec,
839 * but is supported implicitly via implicit operand conversion.
840 * rather than bother with conversion, we just use the byte width
841 * global (4 or 8 bytes).
845 case ACPI_TYPE_INTEGER:
846 Value = AcpiGbl_IntegerByteWidth;
849 case ACPI_TYPE_BUFFER:
850 Value = TempDesc->Buffer.Length;
853 case ACPI_TYPE_STRING:
854 Value = TempDesc->String.Length;
857 case ACPI_TYPE_PACKAGE:
858 Value = TempDesc->Package.Count;
862 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
863 "SizeOf - Operand is not Buf/Int/Str/Pkg - found type %s\n",
864 AcpiUtGetTypeName (Type)));
865 Status = AE_AML_OPERAND_TYPE;
870 * Now that we have the size of the object, create a result
871 * object to hold the value
873 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
876 Status = AE_NO_MEMORY;
880 ReturnDesc->Integer.Value = Value;
884 case AML_REF_OF_OP: /* RefOf (SourceObject) */
886 Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc, WalkState);
887 if (ACPI_FAILURE (Status))
894 case AML_DEREF_OF_OP: /* DerefOf (ObjReference | String) */
896 /* Check for a method local or argument, or standalone String */
898 if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED)
900 switch (ACPI_GET_OBJECT_TYPE (Operand[0]))
902 case ACPI_TYPE_LOCAL_REFERENCE:
904 * This is a DerefOf (LocalX | ArgX)
906 * Must resolve/dereference the local/arg reference first
908 switch (Operand[0]->Reference.Opcode)
913 /* Set Operand[0] to the value of the local/arg */
915 Status = AcpiDsMethodDataGetValue (Operand[0]->Reference.Opcode,
916 Operand[0]->Reference.Offset, WalkState, &TempDesc);
917 if (ACPI_FAILURE (Status))
923 * Delete our reference to the input object and
924 * point to the object just retrieved
926 AcpiUtRemoveReference (Operand[0]);
927 Operand[0] = TempDesc;
932 /* Get the object to which the reference refers */
934 TempDesc = Operand[0]->Reference.Object;
935 AcpiUtRemoveReference (Operand[0]);
936 Operand[0] = TempDesc;
941 /* Must be an Index op - handled below */
947 case ACPI_TYPE_STRING:
950 * This is a DerefOf (String). The string is a reference to a named ACPI object.
952 * 1) Find the owning Node
953 * 2) Dereference the node to an actual object. Could be a Field, so we nee
954 * to resolve the node to a value.
956 Status = AcpiNsGetNodeByPath (Operand[0]->String.Pointer,
957 WalkState->ScopeInfo->Scope.Node, ACPI_NS_SEARCH_PARENT,
958 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ReturnDesc));
959 if (ACPI_FAILURE (Status))
964 Status = AcpiExResolveNodeToValue (
965 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ReturnDesc), WalkState);
971 Status = AE_AML_OPERAND_TYPE;
976 /* Operand[0] may have changed from the code above */
978 if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
981 * This is a DerefOf (ObjectReference)
982 * Get the actual object from the Node (This is the dereference).
983 * -- This case may only happen when a LocalX or ArgX is dereferenced above.
985 ReturnDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) Operand[0]);
990 * This must be a reference object produced by either the Index() or
993 switch (Operand[0]->Reference.Opcode)
998 * The target type for the Index operator must be
999 * either a Buffer or a Package
1001 switch (Operand[0]->Reference.TargetType)
1003 case ACPI_TYPE_BUFFER_FIELD:
1005 TempDesc = Operand[0]->Reference.Object;
1008 * Create a new object that contains one element of the
1009 * buffer -- the element pointed to by the index.
1011 * NOTE: index into a buffer is NOT a pointer to a
1012 * sub-buffer of the main buffer, it is only a pointer to a
1013 * single element (byte) of the buffer!
1015 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
1018 Status = AE_NO_MEMORY;
1023 * Since we are returning the value of the buffer at the
1024 * indexed location, we don't need to add an additional
1025 * reference to the buffer itself.
1027 ReturnDesc->Integer.Value =
1028 TempDesc->Buffer.Pointer[Operand[0]->Reference.Offset];
1032 case ACPI_TYPE_PACKAGE:
1035 * Return the referenced element of the package. We must add
1036 * another reference to the referenced object, however.
1038 ReturnDesc = *(Operand[0]->Reference.Where);
1042 * We can't return a NULL dereferenced value. This is
1043 * an uninitialized package element and is thus a
1046 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
1047 "NULL package element obj %p\n",
1049 Status = AE_AML_UNINITIALIZED_ELEMENT;
1053 AcpiUtAddReference (ReturnDesc);
1059 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
1060 "Unknown Index TargetType %X in obj %p\n",
1061 Operand[0]->Reference.TargetType, Operand[0]));
1062 Status = AE_AML_OPERAND_TYPE;
1070 ReturnDesc = Operand[0]->Reference.Object;
1072 if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) == ACPI_DESC_TYPE_NAMED)
1075 ReturnDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ReturnDesc);
1078 /* Add another reference to the object! */
1080 AcpiUtAddReference (ReturnDesc);
1085 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
1086 "Unknown opcode in ref(%p) - %X\n",
1087 Operand[0], Operand[0]->Reference.Opcode));
1098 ACPI_REPORT_ERROR (("AcpiExOpcode_1A_0T_1R: Unknown opcode %X\n",
1099 WalkState->Opcode));
1100 Status = AE_AML_BAD_OPCODE;
1107 /* Delete return object on error */
1109 if (ACPI_FAILURE (Status))
1111 AcpiUtRemoveReference (ReturnDesc);
1114 WalkState->ResultObj = ReturnDesc;
1115 return_ACPI_STATUS (Status);