1 /******************************************************************************
3 * Module Name: exoparg1 - AML execution - opcodes with 1 argument
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2014, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************/
116 #define __EXOPARG1_C__
119 #include "accommon.h"
120 #include "acparser.h"
121 #include "acdispat.h"
122 #include "acinterp.h"
124 #include "acnamesp.h"
127 #define _COMPONENT ACPI_EXECUTER
128 ACPI_MODULE_NAME ("exoparg1")
132 * Naming convention for AML interpreter execution routines.
134 * The routines that begin execution of AML opcodes are named with a common
135 * convention based upon the number of arguments, the number of target operands,
136 * and whether or not a value is returned:
138 * AcpiExOpcode_xA_yT_zR
142 * xA - ARGUMENTS: The number of arguments (input operands) that are
143 * required for this opcode type (0 through 6 args).
144 * yT - TARGETS: The number of targets (output operands) that are required
145 * for this opcode type (0, 1, or 2 targets).
146 * zR - RETURN VALUE: Indicates whether this opcode type returns a value
147 * as the function return (0 or 1).
149 * The AcpiExOpcode* functions are called via the Dispatcher component with
150 * fully resolved operands.
153 /*******************************************************************************
155 * FUNCTION: AcpiExOpcode_0A_0T_1R
157 * PARAMETERS: WalkState - Current state (contains AML opcode)
161 * DESCRIPTION: Execute operator with no operands, one return value
163 ******************************************************************************/
166 AcpiExOpcode_0A_0T_1R (
167 ACPI_WALK_STATE
*WalkState
)
169 ACPI_STATUS Status
= AE_OK
;
170 ACPI_OPERAND_OBJECT
*ReturnDesc
= NULL
;
173 ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R
,
174 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
= AcpiUtCreateIntegerObject (AcpiOsGetTimer ());
188 Status
= AE_NO_MEMORY
;
193 default: /* Unknown opcode */
195 ACPI_ERROR ((AE_INFO
, "Unknown AML opcode 0x%X",
197 Status
= AE_AML_BAD_OPCODE
;
203 /* Delete return object on error */
205 if ((ACPI_FAILURE (Status
)) || WalkState
->ResultObj
)
207 AcpiUtRemoveReference (ReturnDesc
);
208 WalkState
->ResultObj
= NULL
;
212 /* Save the return value */
214 WalkState
->ResultObj
= 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
,
243 AcpiPsGetOpcodeName (WalkState
->Opcode
));
246 /* Examine the AML opcode */
248 switch (WalkState
->Opcode
)
250 case AML_RELEASE_OP
: /* Release (MutexObject) */
252 Status
= AcpiExReleaseMutex (Operand
[0], WalkState
);
255 case AML_RESET_OP
: /* Reset (EventObject) */
257 Status
= AcpiExSystemResetEvent (Operand
[0]);
260 case AML_SIGNAL_OP
: /* Signal (EventObject) */
262 Status
= AcpiExSystemSignalEvent (Operand
[0]);
265 case AML_SLEEP_OP
: /* Sleep (MsecTime) */
267 Status
= AcpiExSystemDoSleep (Operand
[0]->Integer
.Value
);
270 case AML_STALL_OP
: /* Stall (UsecTime) */
272 Status
= AcpiExSystemDoStall ((UINT32
) Operand
[0]->Integer
.Value
);
275 case AML_UNLOAD_OP
: /* Unload (Handle) */
277 Status
= AcpiExUnloadTable (Operand
[0]);
280 default: /* Unknown opcode */
282 ACPI_ERROR ((AE_INFO
, "Unknown AML opcode 0x%X",
284 Status
= AE_AML_BAD_OPCODE
;
288 return_ACPI_STATUS (Status
);
292 /*******************************************************************************
294 * FUNCTION: AcpiExOpcode_1A_1T_0R
296 * PARAMETERS: WalkState - Current state (contains AML opcode)
300 * DESCRIPTION: Execute opcode with one argument, one target, and no
303 ******************************************************************************/
306 AcpiExOpcode_1A_1T_0R (
307 ACPI_WALK_STATE
*WalkState
)
309 ACPI_STATUS Status
= AE_OK
;
310 ACPI_OPERAND_OBJECT
**Operand
= &WalkState
->Operands
[0];
313 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_0R
,
314 AcpiPsGetOpcodeName (WalkState
->Opcode
));
317 /* Examine the AML opcode */
319 switch (WalkState
->Opcode
)
323 Status
= AcpiExLoadOp (Operand
[0], Operand
[1], WalkState
);
326 default: /* Unknown opcode */
328 ACPI_ERROR ((AE_INFO
, "Unknown AML opcode 0x%X",
330 Status
= AE_AML_BAD_OPCODE
;
337 return_ACPI_STATUS (Status
);
341 /*******************************************************************************
343 * FUNCTION: AcpiExOpcode_1A_1T_1R
345 * PARAMETERS: WalkState - Current state (contains AML opcode)
349 * DESCRIPTION: Execute opcode with one argument, one target, and a
352 ******************************************************************************/
355 AcpiExOpcode_1A_1T_1R (
356 ACPI_WALK_STATE
*WalkState
)
358 ACPI_STATUS Status
= AE_OK
;
359 ACPI_OPERAND_OBJECT
**Operand
= &WalkState
->Operands
[0];
360 ACPI_OPERAND_OBJECT
*ReturnDesc
= NULL
;
361 ACPI_OPERAND_OBJECT
*ReturnDesc2
= NULL
;
368 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R
,
369 AcpiPsGetOpcodeName (WalkState
->Opcode
));
372 /* Examine the AML opcode */
374 switch (WalkState
->Opcode
)
377 case AML_FIND_SET_LEFT_BIT_OP
:
378 case AML_FIND_SET_RIGHT_BIT_OP
:
379 case AML_FROM_BCD_OP
:
381 case AML_COND_REF_OF_OP
:
383 /* Create a return object of type Integer for these opcodes */
385 ReturnDesc
= AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER
);
388 Status
= AE_NO_MEMORY
;
392 switch (WalkState
->Opcode
)
394 case AML_BIT_NOT_OP
: /* Not (Operand, Result) */
396 ReturnDesc
->Integer
.Value
= ~Operand
[0]->Integer
.Value
;
399 case AML_FIND_SET_LEFT_BIT_OP
: /* FindSetLeftBit (Operand, Result) */
401 ReturnDesc
->Integer
.Value
= Operand
[0]->Integer
.Value
;
404 * Acpi specification describes Integer type as a little
405 * endian unsigned value, so this boundary condition is valid.
407 for (Temp32
= 0; ReturnDesc
->Integer
.Value
&&
408 Temp32
< ACPI_INTEGER_BIT_SIZE
; ++Temp32
)
410 ReturnDesc
->Integer
.Value
>>= 1;
413 ReturnDesc
->Integer
.Value
= Temp32
;
416 case AML_FIND_SET_RIGHT_BIT_OP
: /* FindSetRightBit (Operand, Result) */
418 ReturnDesc
->Integer
.Value
= Operand
[0]->Integer
.Value
;
421 * The Acpi specification describes Integer type as a little
422 * endian unsigned value, so this boundary condition is valid.
424 for (Temp32
= 0; ReturnDesc
->Integer
.Value
&&
425 Temp32
< ACPI_INTEGER_BIT_SIZE
; ++Temp32
)
427 ReturnDesc
->Integer
.Value
<<= 1;
430 /* Since the bit position is one-based, subtract from 33 (65) */
432 ReturnDesc
->Integer
.Value
=
433 Temp32
== 0 ? 0 : (ACPI_INTEGER_BIT_SIZE
+ 1) - Temp32
;
436 case AML_FROM_BCD_OP
: /* FromBcd (BCDValue, Result) */
438 * The 64-bit ACPI integer can hold 16 4-bit BCD characters
439 * (if table is 32-bit, integer can hold 8 BCD characters)
440 * Convert each 4-bit BCD value
443 ReturnDesc
->Integer
.Value
= 0;
444 Digit
= Operand
[0]->Integer
.Value
;
446 /* Convert each BCD digit (each is one nybble wide) */
448 for (i
= 0; (i
< AcpiGbl_IntegerNybbleWidth
) && (Digit
> 0); i
++)
450 /* Get the least significant 4-bit BCD digit */
452 Temp32
= ((UINT32
) Digit
) & 0xF;
454 /* Check the range of the digit */
458 ACPI_ERROR ((AE_INFO
,
459 "BCD digit too large (not decimal): 0x%X",
462 Status
= AE_AML_NUMERIC_OVERFLOW
;
466 /* Sum the digit into the result with the current power of 10 */
468 ReturnDesc
->Integer
.Value
+=
469 (((UINT64
) Temp32
) * PowerOfTen
);
471 /* Shift to next BCD digit */
475 /* Next power of 10 */
481 case AML_TO_BCD_OP
: /* ToBcd (Operand, Result) */
483 ReturnDesc
->Integer
.Value
= 0;
484 Digit
= Operand
[0]->Integer
.Value
;
486 /* Each BCD digit is one nybble wide */
488 for (i
= 0; (i
< AcpiGbl_IntegerNybbleWidth
) && (Digit
> 0); i
++)
490 (void) AcpiUtShortDivide (Digit
, 10, &Digit
, &Temp32
);
493 * Insert the BCD digit that resides in the
494 * remainder from above
496 ReturnDesc
->Integer
.Value
|=
497 (((UINT64
) Temp32
) << ACPI_MUL_4 (i
));
500 /* Overflow if there is any data left in Digit */
504 ACPI_ERROR ((AE_INFO
,
505 "Integer too large to convert to BCD: 0x%8.8X%8.8X",
506 ACPI_FORMAT_UINT64 (Operand
[0]->Integer
.Value
)));
507 Status
= AE_AML_NUMERIC_OVERFLOW
;
512 case AML_COND_REF_OF_OP
: /* CondRefOf (SourceObject, Result) */
514 * This op is a little strange because the internal return value is
515 * different than the return value stored in the result descriptor
516 * (There are really two return values)
518 if ((ACPI_NAMESPACE_NODE
*) Operand
[0] == AcpiGbl_RootNode
)
521 * This means that the object does not exist in the namespace,
524 ReturnDesc
->Integer
.Value
= 0;
528 /* Get the object reference, store it, and remove our reference */
530 Status
= AcpiExGetObjectReference (Operand
[0],
531 &ReturnDesc2
, WalkState
);
532 if (ACPI_FAILURE (Status
))
537 Status
= AcpiExStore (ReturnDesc2
, Operand
[1], WalkState
);
538 AcpiUtRemoveReference (ReturnDesc2
);
540 /* The object exists in the namespace, return TRUE */
542 ReturnDesc
->Integer
.Value
= ACPI_UINT64_MAX
;
548 /* No other opcodes get here */
554 case AML_STORE_OP
: /* Store (Source, Target) */
556 * A store operand is typically a number, string, buffer or lvalue
557 * Be careful about deleting the source object,
558 * since the object itself may have been stored.
560 Status
= AcpiExStore (Operand
[0], Operand
[1], WalkState
);
561 if (ACPI_FAILURE (Status
))
563 return_ACPI_STATUS (Status
);
566 /* It is possible that the Store already produced a return object */
568 if (!WalkState
->ResultObj
)
571 * Normally, we would remove a reference on the Operand[0]
572 * parameter; But since it is being used as the internal return
573 * object (meaning we would normally increment it), the two
574 * cancel out, and we simply don't do anything.
576 WalkState
->ResultObj
= Operand
[0];
577 WalkState
->Operands
[0] = NULL
; /* Prevent deletion */
579 return_ACPI_STATUS (Status
);
584 case AML_COPY_OP
: /* Copy (Source, Target) */
586 Status
= AcpiUtCopyIobjectToIobject (Operand
[0], &ReturnDesc
,
590 case AML_TO_DECSTRING_OP
: /* ToDecimalString (Data, Result) */
592 Status
= AcpiExConvertToString (Operand
[0], &ReturnDesc
,
593 ACPI_EXPLICIT_CONVERT_DECIMAL
);
594 if (ReturnDesc
== Operand
[0])
596 /* No conversion performed, add ref to handle return value */
597 AcpiUtAddReference (ReturnDesc
);
601 case AML_TO_HEXSTRING_OP
: /* ToHexString (Data, Result) */
603 Status
= AcpiExConvertToString (Operand
[0], &ReturnDesc
,
604 ACPI_EXPLICIT_CONVERT_HEX
);
605 if (ReturnDesc
== Operand
[0])
607 /* No conversion performed, add ref to handle return value */
608 AcpiUtAddReference (ReturnDesc
);
612 case AML_TO_BUFFER_OP
: /* ToBuffer (Data, Result) */
614 Status
= AcpiExConvertToBuffer (Operand
[0], &ReturnDesc
);
615 if (ReturnDesc
== Operand
[0])
617 /* No conversion performed, add ref to handle return value */
618 AcpiUtAddReference (ReturnDesc
);
622 case AML_TO_INTEGER_OP
: /* ToInteger (Data, Result) */
624 Status
= AcpiExConvertToInteger (Operand
[0], &ReturnDesc
,
626 if (ReturnDesc
== Operand
[0])
628 /* No conversion performed, add ref to handle return value */
629 AcpiUtAddReference (ReturnDesc
);
633 case AML_SHIFT_LEFT_BIT_OP
: /* ShiftLeftBit (Source, BitNum) */
634 case AML_SHIFT_RIGHT_BIT_OP
: /* ShiftRightBit (Source, BitNum) */
636 /* These are two obsolete opcodes */
638 ACPI_ERROR ((AE_INFO
,
639 "%s is obsolete and not implemented",
640 AcpiPsGetOpcodeName (WalkState
->Opcode
)));
644 default: /* Unknown opcode */
646 ACPI_ERROR ((AE_INFO
, "Unknown AML opcode 0x%X",
648 Status
= AE_AML_BAD_OPCODE
;
652 if (ACPI_SUCCESS (Status
))
654 /* Store the return value computed above into the target object */
656 Status
= AcpiExStore (ReturnDesc
, Operand
[1], WalkState
);
662 /* Delete return object on error */
664 if (ACPI_FAILURE (Status
))
666 AcpiUtRemoveReference (ReturnDesc
);
669 /* Save return object on success */
671 else if (!WalkState
->ResultObj
)
673 WalkState
->ResultObj
= ReturnDesc
;
676 return_ACPI_STATUS (Status
);
680 /*******************************************************************************
682 * FUNCTION: AcpiExOpcode_1A_0T_1R
684 * PARAMETERS: WalkState - Current state (contains AML opcode)
688 * DESCRIPTION: Execute opcode with one argument, no target, and a return value
690 ******************************************************************************/
693 AcpiExOpcode_1A_0T_1R (
694 ACPI_WALK_STATE
*WalkState
)
696 ACPI_OPERAND_OBJECT
**Operand
= &WalkState
->Operands
[0];
697 ACPI_OPERAND_OBJECT
*TempDesc
;
698 ACPI_OPERAND_OBJECT
*ReturnDesc
= NULL
;
699 ACPI_STATUS Status
= AE_OK
;
704 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R
,
705 AcpiPsGetOpcodeName (WalkState
->Opcode
));
708 /* Examine the AML opcode */
710 switch (WalkState
->Opcode
)
712 case AML_LNOT_OP
: /* LNot (Operand) */
714 ReturnDesc
= AcpiUtCreateIntegerObject ((UINT64
) 0);
717 Status
= AE_NO_MEMORY
;
722 * Set result to ONES (TRUE) if Value == 0. Note:
723 * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above.
725 if (!Operand
[0]->Integer
.Value
)
727 ReturnDesc
->Integer
.Value
= ACPI_UINT64_MAX
;
731 case AML_DECREMENT_OP
: /* Decrement (Operand) */
732 case AML_INCREMENT_OP
: /* Increment (Operand) */
734 * Create a new integer. Can't just get the base integer and
735 * increment it because it may be an Arg or Field.
737 ReturnDesc
= AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER
);
740 Status
= AE_NO_MEMORY
;
745 * Since we are expecting a Reference operand, it can be either a
746 * NS Node or an internal object.
748 TempDesc
= Operand
[0];
749 if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc
) == ACPI_DESC_TYPE_OPERAND
)
751 /* Internal reference object - prevent deletion */
753 AcpiUtAddReference (TempDesc
);
757 * Convert the Reference operand to an Integer (This removes a
758 * reference on the Operand[0] object)
760 * NOTE: We use LNOT_OP here in order to force resolution of the
761 * reference operand to an actual integer.
763 Status
= AcpiExResolveOperands (AML_LNOT_OP
, &TempDesc
, WalkState
);
764 if (ACPI_FAILURE (Status
))
766 ACPI_EXCEPTION ((AE_INFO
, Status
,
767 "While resolving operands for [%s]",
768 AcpiPsGetOpcodeName (WalkState
->Opcode
)));
774 * TempDesc is now guaranteed to be an Integer object --
775 * Perform the actual increment or decrement
777 if (WalkState
->Opcode
== AML_INCREMENT_OP
)
779 ReturnDesc
->Integer
.Value
= TempDesc
->Integer
.Value
+1;
783 ReturnDesc
->Integer
.Value
= TempDesc
->Integer
.Value
-1;
786 /* Finished with this Integer object */
788 AcpiUtRemoveReference (TempDesc
);
791 * Store the result back (indirectly) through the original
794 Status
= AcpiExStore (ReturnDesc
, Operand
[0], WalkState
);
797 case AML_TYPE_OP
: /* ObjectType (SourceObject) */
799 * Note: The operand is not resolved at this point because we want to
800 * get the associated object, not its value. For example, we don't
801 * want to resolve a FieldUnit to its value, we want the actual
805 /* Get the type of the base object */
807 Status
= AcpiExResolveMultiple (WalkState
, Operand
[0], &Type
, NULL
);
808 if (ACPI_FAILURE (Status
))
813 /* Allocate a descriptor to hold the type. */
815 ReturnDesc
= AcpiUtCreateIntegerObject ((UINT64
) Type
);
818 Status
= AE_NO_MEMORY
;
823 case AML_SIZE_OF_OP
: /* SizeOf (SourceObject) */
825 * Note: The operand is not resolved at this point because we want to
826 * get the associated object, not its value.
829 /* Get the base object */
831 Status
= AcpiExResolveMultiple (WalkState
,
832 Operand
[0], &Type
, &TempDesc
);
833 if (ACPI_FAILURE (Status
))
839 * The type of the base object must be integer, buffer, string, or
840 * package. All others are not supported.
842 * NOTE: Integer is not specifically supported by the ACPI spec,
843 * but is supported implicitly via implicit operand conversion.
844 * rather than bother with conversion, we just use the byte width
845 * global (4 or 8 bytes).
849 case ACPI_TYPE_INTEGER
:
851 Value
= AcpiGbl_IntegerByteWidth
;
854 case ACPI_TYPE_STRING
:
856 Value
= TempDesc
->String
.Length
;
859 case ACPI_TYPE_BUFFER
:
861 /* Buffer arguments may not be evaluated at this point */
863 Status
= AcpiDsGetBufferArguments (TempDesc
);
864 Value
= TempDesc
->Buffer
.Length
;
867 case ACPI_TYPE_PACKAGE
:
869 /* Package arguments may not be evaluated at this point */
871 Status
= AcpiDsGetPackageArguments (TempDesc
);
872 Value
= TempDesc
->Package
.Count
;
877 ACPI_ERROR ((AE_INFO
,
878 "Operand must be Buffer/Integer/String/Package - found type %s",
879 AcpiUtGetTypeName (Type
)));
880 Status
= AE_AML_OPERAND_TYPE
;
884 if (ACPI_FAILURE (Status
))
890 * Now that we have the size of the object, create a result
891 * object to hold the value
893 ReturnDesc
= AcpiUtCreateIntegerObject (Value
);
896 Status
= AE_NO_MEMORY
;
902 case AML_REF_OF_OP
: /* RefOf (SourceObject) */
904 Status
= AcpiExGetObjectReference (Operand
[0], &ReturnDesc
, WalkState
);
905 if (ACPI_FAILURE (Status
))
912 case AML_DEREF_OF_OP
: /* DerefOf (ObjReference | String) */
914 /* Check for a method local or argument, or standalone String */
916 if (ACPI_GET_DESCRIPTOR_TYPE (Operand
[0]) == ACPI_DESC_TYPE_NAMED
)
918 TempDesc
= AcpiNsGetAttachedObject (
919 (ACPI_NAMESPACE_NODE
*) Operand
[0]);
921 ((TempDesc
->Common
.Type
== ACPI_TYPE_STRING
) ||
922 (TempDesc
->Common
.Type
== ACPI_TYPE_LOCAL_REFERENCE
)))
924 Operand
[0] = TempDesc
;
925 AcpiUtAddReference (TempDesc
);
929 Status
= AE_AML_OPERAND_TYPE
;
935 switch ((Operand
[0])->Common
.Type
)
937 case ACPI_TYPE_LOCAL_REFERENCE
:
939 * This is a DerefOf (LocalX | ArgX)
941 * Must resolve/dereference the local/arg reference first
943 switch (Operand
[0]->Reference
.Class
)
945 case ACPI_REFCLASS_LOCAL
:
946 case ACPI_REFCLASS_ARG
:
948 /* Set Operand[0] to the value of the local/arg */
950 Status
= AcpiDsMethodDataGetValue (
951 Operand
[0]->Reference
.Class
,
952 Operand
[0]->Reference
.Value
,
953 WalkState
, &TempDesc
);
954 if (ACPI_FAILURE (Status
))
960 * Delete our reference to the input object and
961 * point to the object just retrieved
963 AcpiUtRemoveReference (Operand
[0]);
964 Operand
[0] = TempDesc
;
967 case ACPI_REFCLASS_REFOF
:
969 /* Get the object to which the reference refers */
971 TempDesc
= Operand
[0]->Reference
.Object
;
972 AcpiUtRemoveReference (Operand
[0]);
973 Operand
[0] = TempDesc
;
978 /* Must be an Index op - handled below */
983 case ACPI_TYPE_STRING
:
989 Status
= AE_AML_OPERAND_TYPE
;
994 if (ACPI_GET_DESCRIPTOR_TYPE (Operand
[0]) != ACPI_DESC_TYPE_NAMED
)
996 if ((Operand
[0])->Common
.Type
== ACPI_TYPE_STRING
)
999 * This is a DerefOf (String). The string is a reference
1000 * to a named ACPI object.
1002 * 1) Find the owning Node
1003 * 2) Dereference the node to an actual object. Could be a
1004 * Field, so we need to resolve the node to a value.
1006 Status
= AcpiNsGetNode (WalkState
->ScopeInfo
->Scope
.Node
,
1007 Operand
[0]->String
.Pointer
,
1008 ACPI_NS_SEARCH_PARENT
,
1009 ACPI_CAST_INDIRECT_PTR (
1010 ACPI_NAMESPACE_NODE
, &ReturnDesc
));
1011 if (ACPI_FAILURE (Status
))
1016 Status
= AcpiExResolveNodeToValue (
1017 ACPI_CAST_INDIRECT_PTR (
1018 ACPI_NAMESPACE_NODE
, &ReturnDesc
),
1024 /* Operand[0] may have changed from the code above */
1026 if (ACPI_GET_DESCRIPTOR_TYPE (Operand
[0]) == ACPI_DESC_TYPE_NAMED
)
1029 * This is a DerefOf (ObjectReference)
1030 * Get the actual object from the Node (This is the dereference).
1031 * This case may only happen when a LocalX or ArgX is
1032 * dereferenced above.
1034 ReturnDesc
= AcpiNsGetAttachedObject (
1035 (ACPI_NAMESPACE_NODE
*) Operand
[0]);
1036 AcpiUtAddReference (ReturnDesc
);
1041 * This must be a reference object produced by either the
1042 * Index() or RefOf() operator
1044 switch (Operand
[0]->Reference
.Class
)
1046 case ACPI_REFCLASS_INDEX
:
1048 * The target type for the Index operator must be
1049 * either a Buffer or a Package
1051 switch (Operand
[0]->Reference
.TargetType
)
1053 case ACPI_TYPE_BUFFER_FIELD
:
1055 TempDesc
= Operand
[0]->Reference
.Object
;
1058 * Create a new object that contains one element of the
1059 * buffer -- the element pointed to by the index.
1061 * NOTE: index into a buffer is NOT a pointer to a
1062 * sub-buffer of the main buffer, it is only a pointer to a
1063 * single element (byte) of the buffer!
1065 * Since we are returning the value of the buffer at the
1066 * indexed location, we don't need to add an additional
1067 * reference to the buffer itself.
1069 ReturnDesc
= AcpiUtCreateIntegerObject ((UINT64
)
1070 TempDesc
->Buffer
.Pointer
[Operand
[0]->Reference
.Value
]);
1073 Status
= AE_NO_MEMORY
;
1078 case ACPI_TYPE_PACKAGE
:
1080 * Return the referenced element of the package. We must
1081 * add another reference to the referenced object, however.
1083 ReturnDesc
= *(Operand
[0]->Reference
.Where
);
1087 * Element is NULL, do not allow the dereference.
1088 * This provides compatibility with other ACPI
1091 return_ACPI_STATUS (AE_AML_UNINITIALIZED_ELEMENT
);
1094 AcpiUtAddReference (ReturnDesc
);
1099 ACPI_ERROR ((AE_INFO
,
1100 "Unknown Index TargetType 0x%X in reference object %p",
1101 Operand
[0]->Reference
.TargetType
, Operand
[0]));
1102 Status
= AE_AML_OPERAND_TYPE
;
1107 case ACPI_REFCLASS_REFOF
:
1109 ReturnDesc
= Operand
[0]->Reference
.Object
;
1111 if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc
) ==
1112 ACPI_DESC_TYPE_NAMED
)
1114 ReturnDesc
= AcpiNsGetAttachedObject (
1115 (ACPI_NAMESPACE_NODE
*) ReturnDesc
);
1123 * BufferFields/FieldUnits require additional resolution
1125 switch (ReturnDesc
->Common
.Type
)
1127 case ACPI_TYPE_BUFFER_FIELD
:
1128 case ACPI_TYPE_LOCAL_REGION_FIELD
:
1129 case ACPI_TYPE_LOCAL_BANK_FIELD
:
1130 case ACPI_TYPE_LOCAL_INDEX_FIELD
:
1132 Status
= AcpiExReadDataFromField (WalkState
,
1133 ReturnDesc
, &TempDesc
);
1134 if (ACPI_FAILURE (Status
))
1139 ReturnDesc
= TempDesc
;
1144 /* Add another reference to the object */
1146 AcpiUtAddReference (ReturnDesc
);
1154 ACPI_ERROR ((AE_INFO
,
1155 "Unknown class in reference(%p) - 0x%2.2X",
1156 Operand
[0], Operand
[0]->Reference
.Class
));
1166 ACPI_ERROR ((AE_INFO
, "Unknown AML opcode 0x%X",
1167 WalkState
->Opcode
));
1168 Status
= AE_AML_BAD_OPCODE
;
1175 /* Delete return object on error */
1177 if (ACPI_FAILURE (Status
))
1179 AcpiUtRemoveReference (ReturnDesc
);
1182 /* Save return object on success */
1186 WalkState
->ResultObj
= ReturnDesc
;
1189 return_ACPI_STATUS (Status
);