1 /******************************************************************************
3 * Module Name: exoparg1 - AML execution - opcodes with 1 argument
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2015, 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 *****************************************************************************/
117 #include "accommon.h"
118 #include "acparser.h"
119 #include "acdispat.h"
120 #include "acinterp.h"
122 #include "acnamesp.h"
125 #define _COMPONENT ACPI_EXECUTER
126 ACPI_MODULE_NAME ("exoparg1")
130 * Naming convention for AML interpreter execution routines.
132 * The routines that begin execution of AML opcodes are named with a common
133 * convention based upon the number of arguments, the number of target operands,
134 * and whether or not a value is returned:
136 * AcpiExOpcode_xA_yT_zR
140 * xA - ARGUMENTS: The number of arguments (input operands) that are
141 * required for this opcode type (0 through 6 args).
142 * yT - TARGETS: The number of targets (output operands) that are required
143 * for this opcode type (0, 1, or 2 targets).
144 * zR - RETURN VALUE: Indicates whether this opcode type returns a value
145 * as the function return (0 or 1).
147 * The AcpiExOpcode* functions are called via the Dispatcher component with
148 * fully resolved operands.
151 /*******************************************************************************
153 * FUNCTION: AcpiExOpcode_0A_0T_1R
155 * PARAMETERS: WalkState - Current state (contains AML opcode)
159 * DESCRIPTION: Execute operator with no operands, one return value
161 ******************************************************************************/
164 AcpiExOpcode_0A_0T_1R (
165 ACPI_WALK_STATE
*WalkState
)
167 ACPI_STATUS Status
= AE_OK
;
168 ACPI_OPERAND_OBJECT
*ReturnDesc
= NULL
;
171 ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R
,
172 AcpiPsGetOpcodeName (WalkState
->Opcode
));
175 /* Examine the AML opcode */
177 switch (WalkState
->Opcode
)
179 case AML_TIMER_OP
: /* Timer () */
181 /* Create a return object of type Integer */
183 ReturnDesc
= AcpiUtCreateIntegerObject (AcpiOsGetTimer ());
186 Status
= AE_NO_MEMORY
;
191 default: /* Unknown opcode */
193 ACPI_ERROR ((AE_INFO
, "Unknown AML opcode 0x%X",
195 Status
= AE_AML_BAD_OPCODE
;
201 /* Delete return object on error */
203 if ((ACPI_FAILURE (Status
)) || WalkState
->ResultObj
)
205 AcpiUtRemoveReference (ReturnDesc
);
206 WalkState
->ResultObj
= NULL
;
210 /* Save the return value */
212 WalkState
->ResultObj
= ReturnDesc
;
215 return_ACPI_STATUS (Status
);
219 /*******************************************************************************
221 * FUNCTION: AcpiExOpcode_1A_0T_0R
223 * PARAMETERS: WalkState - Current state (contains AML opcode)
227 * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
230 ******************************************************************************/
233 AcpiExOpcode_1A_0T_0R (
234 ACPI_WALK_STATE
*WalkState
)
236 ACPI_OPERAND_OBJECT
**Operand
= &WalkState
->Operands
[0];
237 ACPI_STATUS Status
= AE_OK
;
240 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R
,
241 AcpiPsGetOpcodeName (WalkState
->Opcode
));
244 /* Examine the AML opcode */
246 switch (WalkState
->Opcode
)
248 case AML_RELEASE_OP
: /* Release (MutexObject) */
250 Status
= AcpiExReleaseMutex (Operand
[0], WalkState
);
253 case AML_RESET_OP
: /* Reset (EventObject) */
255 Status
= AcpiExSystemResetEvent (Operand
[0]);
258 case AML_SIGNAL_OP
: /* Signal (EventObject) */
260 Status
= AcpiExSystemSignalEvent (Operand
[0]);
263 case AML_SLEEP_OP
: /* Sleep (MsecTime) */
265 Status
= AcpiExSystemDoSleep (Operand
[0]->Integer
.Value
);
268 case AML_STALL_OP
: /* Stall (UsecTime) */
270 Status
= AcpiExSystemDoStall ((UINT32
) Operand
[0]->Integer
.Value
);
273 case AML_UNLOAD_OP
: /* Unload (Handle) */
275 Status
= AcpiExUnloadTable (Operand
[0]);
278 default: /* Unknown opcode */
280 ACPI_ERROR ((AE_INFO
, "Unknown AML opcode 0x%X",
282 Status
= AE_AML_BAD_OPCODE
;
286 return_ACPI_STATUS (Status
);
290 /*******************************************************************************
292 * FUNCTION: AcpiExOpcode_1A_1T_0R
294 * PARAMETERS: WalkState - Current state (contains AML opcode)
298 * DESCRIPTION: Execute opcode with one argument, one target, and no
301 ******************************************************************************/
304 AcpiExOpcode_1A_1T_0R (
305 ACPI_WALK_STATE
*WalkState
)
307 ACPI_STATUS Status
= AE_OK
;
308 ACPI_OPERAND_OBJECT
**Operand
= &WalkState
->Operands
[0];
311 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_0R
,
312 AcpiPsGetOpcodeName (WalkState
->Opcode
));
315 /* Examine the AML opcode */
317 switch (WalkState
->Opcode
)
321 Status
= AcpiExLoadOp (Operand
[0], Operand
[1], WalkState
);
324 default: /* Unknown opcode */
326 ACPI_ERROR ((AE_INFO
, "Unknown AML opcode 0x%X",
328 Status
= AE_AML_BAD_OPCODE
;
335 return_ACPI_STATUS (Status
);
339 /*******************************************************************************
341 * FUNCTION: AcpiExOpcode_1A_1T_1R
343 * PARAMETERS: WalkState - Current state (contains AML opcode)
347 * DESCRIPTION: Execute opcode with one argument, one target, and a
350 ******************************************************************************/
353 AcpiExOpcode_1A_1T_1R (
354 ACPI_WALK_STATE
*WalkState
)
356 ACPI_STATUS Status
= AE_OK
;
357 ACPI_OPERAND_OBJECT
**Operand
= &WalkState
->Operands
[0];
358 ACPI_OPERAND_OBJECT
*ReturnDesc
= NULL
;
359 ACPI_OPERAND_OBJECT
*ReturnDesc2
= NULL
;
366 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R
,
367 AcpiPsGetOpcodeName (WalkState
->Opcode
));
370 /* Examine the AML opcode */
372 switch (WalkState
->Opcode
)
375 case AML_FIND_SET_LEFT_BIT_OP
:
376 case AML_FIND_SET_RIGHT_BIT_OP
:
377 case AML_FROM_BCD_OP
:
379 case AML_COND_REF_OF_OP
:
381 /* Create a return object of type Integer for these opcodes */
383 ReturnDesc
= AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER
);
386 Status
= AE_NO_MEMORY
;
390 switch (WalkState
->Opcode
)
392 case AML_BIT_NOT_OP
: /* Not (Operand, Result) */
394 ReturnDesc
->Integer
.Value
= ~Operand
[0]->Integer
.Value
;
397 case AML_FIND_SET_LEFT_BIT_OP
: /* FindSetLeftBit (Operand, Result) */
399 ReturnDesc
->Integer
.Value
= Operand
[0]->Integer
.Value
;
402 * Acpi specification describes Integer type as a little
403 * endian unsigned value, so this boundary condition is valid.
405 for (Temp32
= 0; ReturnDesc
->Integer
.Value
&&
406 Temp32
< ACPI_INTEGER_BIT_SIZE
; ++Temp32
)
408 ReturnDesc
->Integer
.Value
>>= 1;
411 ReturnDesc
->Integer
.Value
= Temp32
;
414 case AML_FIND_SET_RIGHT_BIT_OP
: /* FindSetRightBit (Operand, Result) */
416 ReturnDesc
->Integer
.Value
= Operand
[0]->Integer
.Value
;
419 * The Acpi specification describes Integer type as a little
420 * endian unsigned value, so this boundary condition is valid.
422 for (Temp32
= 0; ReturnDesc
->Integer
.Value
&&
423 Temp32
< ACPI_INTEGER_BIT_SIZE
; ++Temp32
)
425 ReturnDesc
->Integer
.Value
<<= 1;
428 /* Since the bit position is one-based, subtract from 33 (65) */
430 ReturnDesc
->Integer
.Value
=
431 Temp32
== 0 ? 0 : (ACPI_INTEGER_BIT_SIZE
+ 1) - Temp32
;
434 case AML_FROM_BCD_OP
: /* FromBcd (BCDValue, Result) */
436 * The 64-bit ACPI integer can hold 16 4-bit BCD characters
437 * (if table is 32-bit, integer can hold 8 BCD characters)
438 * Convert each 4-bit BCD value
441 ReturnDesc
->Integer
.Value
= 0;
442 Digit
= Operand
[0]->Integer
.Value
;
444 /* Convert each BCD digit (each is one nybble wide) */
446 for (i
= 0; (i
< AcpiGbl_IntegerNybbleWidth
) && (Digit
> 0); i
++)
448 /* Get the least significant 4-bit BCD digit */
450 Temp32
= ((UINT32
) Digit
) & 0xF;
452 /* Check the range of the digit */
456 ACPI_ERROR ((AE_INFO
,
457 "BCD digit too large (not decimal): 0x%X",
460 Status
= AE_AML_NUMERIC_OVERFLOW
;
464 /* Sum the digit into the result with the current power of 10 */
466 ReturnDesc
->Integer
.Value
+=
467 (((UINT64
) Temp32
) * PowerOfTen
);
469 /* Shift to next BCD digit */
473 /* Next power of 10 */
479 case AML_TO_BCD_OP
: /* ToBcd (Operand, Result) */
481 ReturnDesc
->Integer
.Value
= 0;
482 Digit
= Operand
[0]->Integer
.Value
;
484 /* Each BCD digit is one nybble wide */
486 for (i
= 0; (i
< AcpiGbl_IntegerNybbleWidth
) && (Digit
> 0); i
++)
488 (void) AcpiUtShortDivide (Digit
, 10, &Digit
, &Temp32
);
491 * Insert the BCD digit that resides in the
492 * remainder from above
494 ReturnDesc
->Integer
.Value
|=
495 (((UINT64
) Temp32
) << ACPI_MUL_4 (i
));
498 /* Overflow if there is any data left in Digit */
502 ACPI_ERROR ((AE_INFO
,
503 "Integer too large to convert to BCD: 0x%8.8X%8.8X",
504 ACPI_FORMAT_UINT64 (Operand
[0]->Integer
.Value
)));
505 Status
= AE_AML_NUMERIC_OVERFLOW
;
510 case AML_COND_REF_OF_OP
: /* CondRefOf (SourceObject, Result) */
512 * This op is a little strange because the internal return value is
513 * different than the return value stored in the result descriptor
514 * (There are really two return values)
516 if ((ACPI_NAMESPACE_NODE
*) Operand
[0] == AcpiGbl_RootNode
)
519 * This means that the object does not exist in the namespace,
522 ReturnDesc
->Integer
.Value
= 0;
526 /* Get the object reference, store it, and remove our reference */
528 Status
= AcpiExGetObjectReference (Operand
[0],
529 &ReturnDesc2
, WalkState
);
530 if (ACPI_FAILURE (Status
))
535 Status
= AcpiExStore (ReturnDesc2
, Operand
[1], WalkState
);
536 AcpiUtRemoveReference (ReturnDesc2
);
538 /* The object exists in the namespace, return TRUE */
540 ReturnDesc
->Integer
.Value
= ACPI_UINT64_MAX
;
546 /* No other opcodes get here */
552 case AML_STORE_OP
: /* Store (Source, Target) */
554 * A store operand is typically a number, string, buffer or lvalue
555 * Be careful about deleting the source object,
556 * since the object itself may have been stored.
558 Status
= AcpiExStore (Operand
[0], Operand
[1], WalkState
);
559 if (ACPI_FAILURE (Status
))
561 return_ACPI_STATUS (Status
);
564 /* It is possible that the Store already produced a return object */
566 if (!WalkState
->ResultObj
)
569 * Normally, we would remove a reference on the Operand[0]
570 * parameter; But since it is being used as the internal return
571 * object (meaning we would normally increment it), the two
572 * cancel out, and we simply don't do anything.
574 WalkState
->ResultObj
= Operand
[0];
575 WalkState
->Operands
[0] = NULL
; /* Prevent deletion */
577 return_ACPI_STATUS (Status
);
582 case AML_COPY_OP
: /* Copy (Source, Target) */
584 Status
= AcpiUtCopyIobjectToIobject (
585 Operand
[0], &ReturnDesc
, WalkState
);
588 case AML_TO_DECSTRING_OP
: /* ToDecimalString (Data, Result) */
590 Status
= AcpiExConvertToString (
591 Operand
[0], &ReturnDesc
, ACPI_EXPLICIT_CONVERT_DECIMAL
);
592 if (ReturnDesc
== Operand
[0])
594 /* No conversion performed, add ref to handle return value */
596 AcpiUtAddReference (ReturnDesc
);
600 case AML_TO_HEXSTRING_OP
: /* ToHexString (Data, Result) */
602 Status
= AcpiExConvertToString (
603 Operand
[0], &ReturnDesc
, ACPI_EXPLICIT_CONVERT_HEX
);
604 if (ReturnDesc
== Operand
[0])
606 /* 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 */
619 AcpiUtAddReference (ReturnDesc
);
623 case AML_TO_INTEGER_OP
: /* ToInteger (Data, Result) */
625 Status
= AcpiExConvertToInteger (
626 Operand
[0], &ReturnDesc
, ACPI_ANY_BASE
);
627 if (ReturnDesc
== Operand
[0])
629 /* No conversion performed, add ref to handle return value */
631 AcpiUtAddReference (ReturnDesc
);
635 case AML_SHIFT_LEFT_BIT_OP
: /* ShiftLeftBit (Source, BitNum) */
636 case AML_SHIFT_RIGHT_BIT_OP
: /* ShiftRightBit (Source, BitNum) */
638 /* These are two obsolete opcodes */
640 ACPI_ERROR ((AE_INFO
,
641 "%s is obsolete and not implemented",
642 AcpiPsGetOpcodeName (WalkState
->Opcode
)));
646 default: /* Unknown opcode */
648 ACPI_ERROR ((AE_INFO
, "Unknown AML opcode 0x%X",
650 Status
= AE_AML_BAD_OPCODE
;
654 if (ACPI_SUCCESS (Status
))
656 /* Store the return value computed above into the target object */
658 Status
= AcpiExStore (ReturnDesc
, Operand
[1], WalkState
);
664 /* Delete return object on error */
666 if (ACPI_FAILURE (Status
))
668 AcpiUtRemoveReference (ReturnDesc
);
671 /* Save return object on success */
673 else if (!WalkState
->ResultObj
)
675 WalkState
->ResultObj
= ReturnDesc
;
678 return_ACPI_STATUS (Status
);
682 /*******************************************************************************
684 * FUNCTION: AcpiExOpcode_1A_0T_1R
686 * PARAMETERS: WalkState - Current state (contains AML opcode)
690 * DESCRIPTION: Execute opcode with one argument, no target, and a return value
692 ******************************************************************************/
695 AcpiExOpcode_1A_0T_1R (
696 ACPI_WALK_STATE
*WalkState
)
698 ACPI_OPERAND_OBJECT
**Operand
= &WalkState
->Operands
[0];
699 ACPI_OPERAND_OBJECT
*TempDesc
;
700 ACPI_OPERAND_OBJECT
*ReturnDesc
= NULL
;
701 ACPI_STATUS Status
= AE_OK
;
706 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R
,
707 AcpiPsGetOpcodeName (WalkState
->Opcode
));
710 /* Examine the AML opcode */
712 switch (WalkState
->Opcode
)
714 case AML_LNOT_OP
: /* LNot (Operand) */
716 ReturnDesc
= AcpiUtCreateIntegerObject ((UINT64
) 0);
719 Status
= AE_NO_MEMORY
;
724 * Set result to ONES (TRUE) if Value == 0. Note:
725 * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above.
727 if (!Operand
[0]->Integer
.Value
)
729 ReturnDesc
->Integer
.Value
= ACPI_UINT64_MAX
;
733 case AML_DECREMENT_OP
: /* Decrement (Operand) */
734 case AML_INCREMENT_OP
: /* Increment (Operand) */
736 * Create a new integer. Can't just get the base integer and
737 * increment it because it may be an Arg or Field.
739 ReturnDesc
= AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER
);
742 Status
= AE_NO_MEMORY
;
747 * Since we are expecting a Reference operand, it can be either a
748 * NS Node or an internal object.
750 TempDesc
= Operand
[0];
751 if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc
) == ACPI_DESC_TYPE_OPERAND
)
753 /* Internal reference object - prevent deletion */
755 AcpiUtAddReference (TempDesc
);
759 * Convert the Reference operand to an Integer (This removes a
760 * reference on the Operand[0] object)
762 * NOTE: We use LNOT_OP here in order to force resolution of the
763 * reference operand to an actual integer.
765 Status
= AcpiExResolveOperands (AML_LNOT_OP
, &TempDesc
, WalkState
);
766 if (ACPI_FAILURE (Status
))
768 ACPI_EXCEPTION ((AE_INFO
, Status
,
769 "While resolving operands for [%s]",
770 AcpiPsGetOpcodeName (WalkState
->Opcode
)));
776 * TempDesc is now guaranteed to be an Integer object --
777 * Perform the actual increment or decrement
779 if (WalkState
->Opcode
== AML_INCREMENT_OP
)
781 ReturnDesc
->Integer
.Value
= TempDesc
->Integer
.Value
+ 1;
785 ReturnDesc
->Integer
.Value
= TempDesc
->Integer
.Value
- 1;
788 /* Finished with this Integer object */
790 AcpiUtRemoveReference (TempDesc
);
793 * Store the result back (indirectly) through the original
796 Status
= AcpiExStore (ReturnDesc
, Operand
[0], WalkState
);
799 case AML_OBJECT_TYPE_OP
: /* ObjectType (SourceObject) */
801 * Note: The operand is not resolved at this point because we want to
802 * get the associated object, not its value. For example, we don't
803 * want to resolve a FieldUnit to its value, we want the actual
807 /* Get the type of the base object */
809 Status
= AcpiExResolveMultiple (WalkState
, Operand
[0], &Type
, NULL
);
810 if (ACPI_FAILURE (Status
))
815 /* Allocate a descriptor to hold the type. */
817 ReturnDesc
= AcpiUtCreateIntegerObject ((UINT64
) Type
);
820 Status
= AE_NO_MEMORY
;
825 case AML_SIZE_OF_OP
: /* SizeOf (SourceObject) */
827 * Note: The operand is not resolved at this point because we want to
828 * get the associated object, not its value.
831 /* Get the base object */
833 Status
= AcpiExResolveMultiple (
834 WalkState
, Operand
[0], &Type
, &TempDesc
);
835 if (ACPI_FAILURE (Status
))
841 * The type of the base object must be integer, buffer, string, or
842 * package. All others are not supported.
844 * NOTE: Integer is not specifically supported by the ACPI spec,
845 * but is supported implicitly via implicit operand conversion.
846 * rather than bother with conversion, we just use the byte width
847 * global (4 or 8 bytes).
851 case ACPI_TYPE_INTEGER
:
853 Value
= AcpiGbl_IntegerByteWidth
;
856 case ACPI_TYPE_STRING
:
858 Value
= TempDesc
->String
.Length
;
861 case ACPI_TYPE_BUFFER
:
863 /* Buffer arguments may not be evaluated at this point */
865 Status
= AcpiDsGetBufferArguments (TempDesc
);
866 Value
= TempDesc
->Buffer
.Length
;
869 case ACPI_TYPE_PACKAGE
:
871 /* Package arguments may not be evaluated at this point */
873 Status
= AcpiDsGetPackageArguments (TempDesc
);
874 Value
= TempDesc
->Package
.Count
;
879 ACPI_ERROR ((AE_INFO
,
880 "Operand must be Buffer/Integer/String/Package"
882 AcpiUtGetTypeName (Type
)));
884 Status
= AE_AML_OPERAND_TYPE
;
888 if (ACPI_FAILURE (Status
))
894 * Now that we have the size of the object, create a result
895 * object to hold the value
897 ReturnDesc
= AcpiUtCreateIntegerObject (Value
);
900 Status
= AE_NO_MEMORY
;
906 case AML_REF_OF_OP
: /* RefOf (SourceObject) */
908 Status
= AcpiExGetObjectReference (
909 Operand
[0], &ReturnDesc
, WalkState
);
910 if (ACPI_FAILURE (Status
))
917 case AML_DEREF_OF_OP
: /* DerefOf (ObjReference | String) */
919 /* Check for a method local or argument, or standalone String */
921 if (ACPI_GET_DESCRIPTOR_TYPE (Operand
[0]) == ACPI_DESC_TYPE_NAMED
)
923 TempDesc
= AcpiNsGetAttachedObject (
924 (ACPI_NAMESPACE_NODE
*) Operand
[0]);
926 ((TempDesc
->Common
.Type
== ACPI_TYPE_STRING
) ||
927 (TempDesc
->Common
.Type
== ACPI_TYPE_LOCAL_REFERENCE
)))
929 Operand
[0] = TempDesc
;
930 AcpiUtAddReference (TempDesc
);
934 Status
= AE_AML_OPERAND_TYPE
;
940 switch ((Operand
[0])->Common
.Type
)
942 case ACPI_TYPE_LOCAL_REFERENCE
:
944 * This is a DerefOf (LocalX | ArgX)
946 * Must resolve/dereference the local/arg reference first
948 switch (Operand
[0]->Reference
.Class
)
950 case ACPI_REFCLASS_LOCAL
:
951 case ACPI_REFCLASS_ARG
:
953 /* Set Operand[0] to the value of the local/arg */
955 Status
= AcpiDsMethodDataGetValue (
956 Operand
[0]->Reference
.Class
,
957 Operand
[0]->Reference
.Value
,
958 WalkState
, &TempDesc
);
959 if (ACPI_FAILURE (Status
))
965 * Delete our reference to the input object and
966 * point to the object just retrieved
968 AcpiUtRemoveReference (Operand
[0]);
969 Operand
[0] = TempDesc
;
972 case ACPI_REFCLASS_REFOF
:
974 /* Get the object to which the reference refers */
976 TempDesc
= Operand
[0]->Reference
.Object
;
977 AcpiUtRemoveReference (Operand
[0]);
978 Operand
[0] = TempDesc
;
983 /* Must be an Index op - handled below */
988 case ACPI_TYPE_STRING
:
994 Status
= AE_AML_OPERAND_TYPE
;
999 if (ACPI_GET_DESCRIPTOR_TYPE (Operand
[0]) != ACPI_DESC_TYPE_NAMED
)
1001 if ((Operand
[0])->Common
.Type
== ACPI_TYPE_STRING
)
1004 * This is a DerefOf (String). The string is a reference
1005 * to a named ACPI object.
1007 * 1) Find the owning Node
1008 * 2) Dereference the node to an actual object. Could be a
1009 * Field, so we need to resolve the node to a value.
1011 Status
= AcpiNsGetNode (WalkState
->ScopeInfo
->Scope
.Node
,
1012 Operand
[0]->String
.Pointer
,
1013 ACPI_NS_SEARCH_PARENT
,
1014 ACPI_CAST_INDIRECT_PTR (
1015 ACPI_NAMESPACE_NODE
, &ReturnDesc
));
1016 if (ACPI_FAILURE (Status
))
1021 Status
= AcpiExResolveNodeToValue (
1022 ACPI_CAST_INDIRECT_PTR (
1023 ACPI_NAMESPACE_NODE
, &ReturnDesc
),
1029 /* Operand[0] may have changed from the code above */
1031 if (ACPI_GET_DESCRIPTOR_TYPE (Operand
[0]) == ACPI_DESC_TYPE_NAMED
)
1034 * This is a DerefOf (ObjectReference)
1035 * Get the actual object from the Node (This is the dereference).
1036 * This case may only happen when a LocalX or ArgX is
1037 * dereferenced above.
1039 ReturnDesc
= AcpiNsGetAttachedObject (
1040 (ACPI_NAMESPACE_NODE
*) Operand
[0]);
1041 AcpiUtAddReference (ReturnDesc
);
1046 * This must be a reference object produced by either the
1047 * Index() or RefOf() operator
1049 switch (Operand
[0]->Reference
.Class
)
1051 case ACPI_REFCLASS_INDEX
:
1053 * The target type for the Index operator must be
1054 * either a Buffer or a Package
1056 switch (Operand
[0]->Reference
.TargetType
)
1058 case ACPI_TYPE_BUFFER_FIELD
:
1060 TempDesc
= Operand
[0]->Reference
.Object
;
1063 * Create a new object that contains one element of the
1064 * buffer -- the element pointed to by the index.
1066 * NOTE: index into a buffer is NOT a pointer to a
1067 * sub-buffer of the main buffer, it is only a pointer to a
1068 * single element (byte) of the buffer!
1070 * Since we are returning the value of the buffer at the
1071 * indexed location, we don't need to add an additional
1072 * reference to the buffer itself.
1074 ReturnDesc
= AcpiUtCreateIntegerObject ((UINT64
)
1075 TempDesc
->Buffer
.Pointer
[Operand
[0]->Reference
.Value
]);
1078 Status
= AE_NO_MEMORY
;
1083 case ACPI_TYPE_PACKAGE
:
1085 * Return the referenced element of the package. We must
1086 * add another reference to the referenced object, however.
1088 ReturnDesc
= *(Operand
[0]->Reference
.Where
);
1092 * Element is NULL, do not allow the dereference.
1093 * This provides compatibility with other ACPI
1096 return_ACPI_STATUS (AE_AML_UNINITIALIZED_ELEMENT
);
1099 AcpiUtAddReference (ReturnDesc
);
1104 ACPI_ERROR ((AE_INFO
,
1105 "Unknown Index TargetType 0x%X in reference object %p",
1106 Operand
[0]->Reference
.TargetType
, Operand
[0]));
1108 Status
= AE_AML_OPERAND_TYPE
;
1113 case ACPI_REFCLASS_REFOF
:
1115 ReturnDesc
= Operand
[0]->Reference
.Object
;
1117 if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc
) ==
1118 ACPI_DESC_TYPE_NAMED
)
1120 ReturnDesc
= AcpiNsGetAttachedObject (
1121 (ACPI_NAMESPACE_NODE
*) ReturnDesc
);
1129 * BufferFields/FieldUnits require additional resolution
1131 switch (ReturnDesc
->Common
.Type
)
1133 case ACPI_TYPE_BUFFER_FIELD
:
1134 case ACPI_TYPE_LOCAL_REGION_FIELD
:
1135 case ACPI_TYPE_LOCAL_BANK_FIELD
:
1136 case ACPI_TYPE_LOCAL_INDEX_FIELD
:
1138 Status
= AcpiExReadDataFromField (
1139 WalkState
, ReturnDesc
, &TempDesc
);
1140 if (ACPI_FAILURE (Status
))
1145 ReturnDesc
= TempDesc
;
1150 /* Add another reference to the object */
1152 AcpiUtAddReference (ReturnDesc
);
1160 ACPI_ERROR ((AE_INFO
,
1161 "Unknown class in reference(%p) - 0x%2.2X",
1162 Operand
[0], Operand
[0]->Reference
.Class
));
1172 ACPI_ERROR ((AE_INFO
, "Unknown AML opcode 0x%X",
1173 WalkState
->Opcode
));
1175 Status
= AE_AML_BAD_OPCODE
;
1182 /* Delete return object on error */
1184 if (ACPI_FAILURE (Status
))
1186 AcpiUtRemoveReference (ReturnDesc
);
1189 /* Save return object on success */
1193 WalkState
->ResultObj
= ReturnDesc
;
1196 return_ACPI_STATUS (Status
);