1 /******************************************************************************
3 * Module Name: dsopcode - Dispatcher Op Region support and handling of
7 *****************************************************************************/
9 /******************************************************************************
13 * Some or all of this work - Copyright (c) 1999 - 2003, 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 *****************************************************************************/
117 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/dsopcode.c,v 1.1 2003/09/24 03:32:15 drhodus Exp $ */
119 #define __DSOPCODE_C__
122 #include "acparser.h"
124 #include "acdispat.h"
125 #include "acinterp.h"
126 #include "acnamesp.h"
127 #include "acevents.h"
129 #define _COMPONENT ACPI_DISPATCHER
130 ACPI_MODULE_NAME ("dsopcode")
133 /*****************************************************************************
135 * FUNCTION: AcpiDsExecuteArguments
137 * PARAMETERS: Node - Parent NS node
138 * AmlLength - Length of executable AML
139 * AmlStart - Pointer to the AML
143 * DESCRIPTION: Late execution of region or field arguments
145 ****************************************************************************/
148 AcpiDsExecuteArguments (
149 ACPI_NAMESPACE_NODE *Node,
150 ACPI_NAMESPACE_NODE *ScopeNode,
155 ACPI_PARSE_OBJECT *Op;
156 ACPI_WALK_STATE *WalkState;
157 ACPI_PARSE_OBJECT *Arg;
160 ACPI_FUNCTION_TRACE ("AcpiDsExecuteArguments");
164 * Allocate a new parser op to be the root of the parsed tree
166 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP);
169 return_ACPI_STATUS (AE_NO_MEMORY);
172 /* Save the Node for use in AcpiPsParseAml */
174 Op->Common.Node = ScopeNode;
176 /* Create and initialize a new parser state */
178 WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, NULL);
181 return_ACPI_STATUS (AE_NO_MEMORY);
184 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart,
185 AmlLength, NULL, NULL, 1);
186 if (ACPI_FAILURE (Status))
188 AcpiDsDeleteWalkState (WalkState);
189 return_ACPI_STATUS (Status);
192 WalkState->ParseFlags = ACPI_PARSE_DEFERRED_OP;
194 /* Pass1: Parse the entire declaration */
196 Status = AcpiPsParseAml (WalkState);
197 if (ACPI_FAILURE (Status))
199 AcpiPsDeleteParseTree (Op);
200 return_ACPI_STATUS (Status);
203 /* Get and init the Op created above */
205 Arg = Op->Common.Value.Arg;
206 Op->Common.Node = Node;
207 Arg->Common.Node = Node;
208 AcpiPsDeleteParseTree (Op);
210 /* Evaluate the address and length arguments for the Buffer Field */
212 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP);
215 return_ACPI_STATUS (AE_NO_MEMORY);
218 Op->Common.Node = ScopeNode;
220 /* Create and initialize a new parser state */
222 WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, NULL);
225 return_ACPI_STATUS (AE_NO_MEMORY);
228 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart,
229 AmlLength, NULL, NULL, 3);
230 if (ACPI_FAILURE (Status))
232 AcpiDsDeleteWalkState (WalkState);
233 return_ACPI_STATUS (Status);
236 Status = AcpiPsParseAml (WalkState);
237 AcpiPsDeleteParseTree (Op);
238 return_ACPI_STATUS (Status);
242 /*****************************************************************************
244 * FUNCTION: AcpiDsGetBufferFieldArguments
246 * PARAMETERS: ObjDesc - A valid BufferField object
250 * DESCRIPTION: Get BufferField Buffer and Index. This implements the late
251 * evaluation of these field attributes.
253 ****************************************************************************/
256 AcpiDsGetBufferFieldArguments (
257 ACPI_OPERAND_OBJECT *ObjDesc)
259 ACPI_OPERAND_OBJECT *ExtraDesc;
260 ACPI_NAMESPACE_NODE *Node;
264 ACPI_FUNCTION_TRACE_PTR ("DsGetBufferFieldArguments", ObjDesc);
267 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
269 return_ACPI_STATUS (AE_OK);
272 /* Get the AML pointer (method object) and BufferField node */
274 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
275 Node = ObjDesc->BufferField.Node;
277 ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_BUFFER_FIELD, Node, NULL));
278 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField JIT Init\n",
281 /* Execute the AML code for the TermArg arguments */
283 Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node),
284 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
285 return_ACPI_STATUS (Status);
289 /*****************************************************************************
291 * FUNCTION: AcpiDsGetBufferArguments
293 * PARAMETERS: ObjDesc - A valid Bufferobject
297 * DESCRIPTION: Get Buffer length and initializer byte list. This implements
298 * the late evaluation of these attributes.
300 ****************************************************************************/
303 AcpiDsGetBufferArguments (
304 ACPI_OPERAND_OBJECT *ObjDesc)
306 ACPI_NAMESPACE_NODE *Node;
310 ACPI_FUNCTION_TRACE_PTR ("DsGetBufferArguments", ObjDesc);
313 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
315 return_ACPI_STATUS (AE_OK);
318 /* Get the Buffer node */
320 Node = ObjDesc->Buffer.Node;
323 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
324 "No pointer back to NS node in buffer %p\n", ObjDesc));
325 return_ACPI_STATUS (AE_AML_INTERNAL);
328 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer JIT Init\n"));
330 /* Execute the AML code for the TermArg arguments */
332 Status = AcpiDsExecuteArguments (Node, Node,
333 ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart);
334 return_ACPI_STATUS (Status);
338 /*****************************************************************************
340 * FUNCTION: AcpiDsGetPackageArguments
342 * PARAMETERS: ObjDesc - A valid Packageobject
346 * DESCRIPTION: Get Package length and initializer byte list. This implements
347 * the late evaluation of these attributes.
349 ****************************************************************************/
352 AcpiDsGetPackageArguments (
353 ACPI_OPERAND_OBJECT *ObjDesc)
355 ACPI_NAMESPACE_NODE *Node;
359 ACPI_FUNCTION_TRACE_PTR ("DsGetPackageArguments", ObjDesc);
362 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
364 return_ACPI_STATUS (AE_OK);
367 /* Get the Package node */
369 Node = ObjDesc->Package.Node;
372 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
373 "No pointer back to NS node in package %p\n", ObjDesc));
374 return_ACPI_STATUS (AE_AML_INTERNAL);
377 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package JIT Init\n"));
379 /* Execute the AML code for the TermArg arguments */
381 Status = AcpiDsExecuteArguments (Node, Node,
382 ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart);
383 return_ACPI_STATUS (Status);
387 /*****************************************************************************
389 * FUNCTION: AcpiDsGetRegionArguments
391 * PARAMETERS: ObjDesc - A valid region object
395 * DESCRIPTION: Get region address and length. This implements the late
396 * evaluation of these region attributes.
398 ****************************************************************************/
401 AcpiDsGetRegionArguments (
402 ACPI_OPERAND_OBJECT *ObjDesc)
404 ACPI_NAMESPACE_NODE *Node;
406 ACPI_OPERAND_OBJECT *ExtraDesc;
409 ACPI_FUNCTION_TRACE_PTR ("DsGetRegionArguments", ObjDesc);
412 if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
414 return_ACPI_STATUS (AE_OK);
417 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
420 return_ACPI_STATUS (AE_NOT_EXIST);
423 /* Get the Region node */
425 Node = ObjDesc->Region.Node;
427 ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_REGION, Node, NULL));
429 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Init at AML %p\n",
430 Node->Name.Ascii, ExtraDesc->Extra.AmlStart));
433 Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node),
434 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
435 return_ACPI_STATUS (Status);
439 /*****************************************************************************
441 * FUNCTION: AcpiDsInitializeRegion
443 * PARAMETERS: Op - A valid region Op object
447 * DESCRIPTION: Front end to EvInitializeRegion
449 ****************************************************************************/
452 AcpiDsInitializeRegion (
453 ACPI_HANDLE ObjHandle)
455 ACPI_OPERAND_OBJECT *ObjDesc;
459 ObjDesc = AcpiNsGetAttachedObject (ObjHandle);
461 /* Namespace is NOT locked */
463 Status = AcpiEvInitializeRegion (ObjDesc, FALSE);
468 /*****************************************************************************
470 * FUNCTION: AcpiDsInitBufferField
472 * PARAMETERS: AmlOpcode - CreateXxxField
473 * ObjDesc - BufferField object
474 * BufferDesc - Host Buffer
475 * OffsetDesc - Offset into buffer
476 * Length - Length of field (CREATE_FIELD_OP only)
477 * Result - Where to store the result
481 * DESCRIPTION: Perform actual initialization of a buffer field
483 ****************************************************************************/
486 AcpiDsInitBufferField (
488 ACPI_OPERAND_OBJECT *ObjDesc,
489 ACPI_OPERAND_OBJECT *BufferDesc,
490 ACPI_OPERAND_OBJECT *OffsetDesc,
491 ACPI_OPERAND_OBJECT *LengthDesc,
492 ACPI_OPERAND_OBJECT *ResultDesc)
501 ACPI_FUNCTION_TRACE_PTR ("DsInitBufferField", ObjDesc);
504 /* Host object must be a Buffer */
506 if (ACPI_GET_OBJECT_TYPE (BufferDesc) != ACPI_TYPE_BUFFER)
508 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
509 "Target of Create Field is not a Buffer object - %s\n",
510 AcpiUtGetObjectTypeName (BufferDesc)));
512 Status = AE_AML_OPERAND_TYPE;
517 * The last parameter to all of these opcodes (ResultDesc) started
518 * out as a NameString, and should therefore now be a NS node
519 * after resolution in AcpiExResolveOperands().
521 if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED)
523 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination must be a NS Node\n",
524 AcpiPsGetOpcodeName (AmlOpcode)));
526 Status = AE_AML_OPERAND_TYPE;
530 Offset = (UINT32) OffsetDesc->Integer.Value;
533 * Setup the Bit offsets and counts, according to the opcode
537 case AML_CREATE_FIELD_OP:
539 /* Offset is in bits, count is in bits */
542 BitCount = (UINT32) LengthDesc->Integer.Value;
543 FieldFlags = AML_FIELD_ACCESS_BYTE;
546 case AML_CREATE_BIT_FIELD_OP:
548 /* Offset is in bits, Field is one bit */
552 FieldFlags = AML_FIELD_ACCESS_BYTE;
555 case AML_CREATE_BYTE_FIELD_OP:
557 /* Offset is in bytes, field is one byte */
559 BitOffset = 8 * Offset;
561 FieldFlags = AML_FIELD_ACCESS_BYTE;
564 case AML_CREATE_WORD_FIELD_OP:
566 /* Offset is in bytes, field is one word */
568 BitOffset = 8 * Offset;
570 FieldFlags = AML_FIELD_ACCESS_WORD;
573 case AML_CREATE_DWORD_FIELD_OP:
575 /* Offset is in bytes, field is one dword */
577 BitOffset = 8 * Offset;
579 FieldFlags = AML_FIELD_ACCESS_DWORD;
582 case AML_CREATE_QWORD_FIELD_OP:
584 /* Offset is in bytes, field is one qword */
586 BitOffset = 8 * Offset;
588 FieldFlags = AML_FIELD_ACCESS_QWORD;
593 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
594 "Unknown field creation opcode %02x\n",
596 Status = AE_AML_BAD_OPCODE;
601 /* Entire field must fit within the current length of the buffer */
603 if ((BitOffset + BitCount) >
604 (8 * (UINT32) BufferDesc->Buffer.Length))
606 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
607 "Field size %d exceeds Buffer size %d (bits)\n",
608 BitOffset + BitCount, 8 * (UINT32) BufferDesc->Buffer.Length));
609 Status = AE_AML_BUFFER_LIMIT;
614 * Initialize areas of the field object that are common to all fields
615 * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE)
617 Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0,
618 BitOffset, BitCount);
619 if (ACPI_FAILURE (Status))
624 ObjDesc->BufferField.BufferObj = BufferDesc;
626 /* Reference count for BufferDesc inherits ObjDesc count */
628 BufferDesc->Common.ReferenceCount = (UINT16) (BufferDesc->Common.ReferenceCount +
629 ObjDesc->Common.ReferenceCount);
634 /* Always delete the operands */
636 AcpiUtRemoveReference (OffsetDesc);
637 AcpiUtRemoveReference (BufferDesc);
639 if (AmlOpcode == AML_CREATE_FIELD_OP)
641 AcpiUtRemoveReference (LengthDesc);
644 /* On failure, delete the result descriptor */
646 if (ACPI_FAILURE (Status))
648 AcpiUtRemoveReference (ResultDesc); /* Result descriptor */
652 /* Now the address and length are valid for this BufferField */
654 ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID;
657 return_ACPI_STATUS (Status);
661 /*****************************************************************************
663 * FUNCTION: AcpiDsEvalBufferFieldOperands
665 * PARAMETERS: WalkState - Current walk
666 * Op - A valid BufferField Op object
670 * DESCRIPTION: Get BufferField Buffer and Index
671 * Called from AcpiDsExecEndOp during BufferField parse tree walk
673 ****************************************************************************/
676 AcpiDsEvalBufferFieldOperands (
677 ACPI_WALK_STATE *WalkState,
678 ACPI_PARSE_OBJECT *Op)
681 ACPI_OPERAND_OBJECT *ObjDesc;
682 ACPI_NAMESPACE_NODE *Node;
683 ACPI_PARSE_OBJECT *NextOp;
686 ACPI_FUNCTION_TRACE_PTR ("DsEvalBufferFieldOperands", Op);
690 * This is where we evaluate the address and length fields of the
691 * CreateXxxField declaration
693 Node = Op->Common.Node;
695 /* NextOp points to the op that holds the Buffer */
697 NextOp = Op->Common.Value.Arg;
699 /* Evaluate/create the address and length operands */
701 Status = AcpiDsCreateOperands (WalkState, NextOp);
702 if (ACPI_FAILURE (Status))
704 return_ACPI_STATUS (Status);
707 ObjDesc = AcpiNsGetAttachedObject (Node);
710 return_ACPI_STATUS (AE_NOT_EXIST);
713 /* Resolve the operands */
715 Status = AcpiExResolveOperands (Op->Common.AmlOpcode,
716 ACPI_WALK_OPERANDS, WalkState);
718 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
719 AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
720 WalkState->NumOperands, "after AcpiExResolveOperands");
722 if (ACPI_FAILURE (Status))
724 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n",
725 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status));
727 return_ACPI_STATUS (Status);
730 /* Initialize the Buffer Field */
732 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
734 /* NOTE: Slightly different operands for this opcode */
736 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,
737 WalkState->Operands[0], WalkState->Operands[1],
738 WalkState->Operands[2], WalkState->Operands[3]);
742 /* All other, CreateXxxField opcodes */
744 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,
745 WalkState->Operands[0], WalkState->Operands[1],
746 NULL, WalkState->Operands[2]);
749 return_ACPI_STATUS (Status);
753 /*****************************************************************************
755 * FUNCTION: AcpiDsEvalRegionOperands
757 * PARAMETERS: WalkState - Current walk
758 * Op - A valid region Op object
762 * DESCRIPTION: Get region address and length
763 * Called from AcpiDsExecEndOp during OpRegion parse tree walk
765 ****************************************************************************/
768 AcpiDsEvalRegionOperands (
769 ACPI_WALK_STATE *WalkState,
770 ACPI_PARSE_OBJECT *Op)
773 ACPI_OPERAND_OBJECT *ObjDesc;
774 ACPI_OPERAND_OBJECT *OperandDesc;
775 ACPI_NAMESPACE_NODE *Node;
776 ACPI_PARSE_OBJECT *NextOp;
779 ACPI_FUNCTION_TRACE_PTR ("DsEvalRegionOperands", Op);
783 * This is where we evaluate the address and length fields of the OpRegion declaration
785 Node = Op->Common.Node;
787 /* NextOp points to the op that holds the SpaceID */
789 NextOp = Op->Common.Value.Arg;
791 /* NextOp points to address op */
793 NextOp = NextOp->Common.Next;
795 /* Evaluate/create the address and length operands */
797 Status = AcpiDsCreateOperands (WalkState, NextOp);
798 if (ACPI_FAILURE (Status))
800 return_ACPI_STATUS (Status);
803 /* Resolve the length and address operands to numbers */
805 Status = AcpiExResolveOperands (Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState);
806 if (ACPI_FAILURE (Status))
808 return_ACPI_STATUS (Status);
811 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
812 AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
813 1, "after AcpiExResolveOperands");
815 ObjDesc = AcpiNsGetAttachedObject (Node);
818 return_ACPI_STATUS (AE_NOT_EXIST);
822 * Get the length operand and save it
825 OperandDesc = WalkState->Operands[WalkState->NumOperands - 1];
827 ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value;
828 AcpiUtRemoveReference (OperandDesc);
831 * Get the address and save it
832 * (at top of stack - 1)
834 OperandDesc = WalkState->Operands[WalkState->NumOperands - 2];
836 ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) OperandDesc->Integer.Value;
837 AcpiUtRemoveReference (OperandDesc);
839 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
841 ACPI_HIDWORD (ObjDesc->Region.Address), ACPI_LODWORD (ObjDesc->Region.Address),
842 ObjDesc->Region.Length));
844 /* Now the address and length are valid for this opregion */
846 ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID;
848 return_ACPI_STATUS (Status);
852 /*****************************************************************************
854 * FUNCTION: AcpiDsEvalDataObjectOperands
856 * PARAMETERS: WalkState - Current walk
857 * Op - A valid DataObject Op object
858 * ObjDesc - DataObject
862 * DESCRIPTION: Get the operands and complete the following data objec types:
866 ****************************************************************************/
869 AcpiDsEvalDataObjectOperands (
870 ACPI_WALK_STATE *WalkState,
871 ACPI_PARSE_OBJECT *Op,
872 ACPI_OPERAND_OBJECT *ObjDesc)
875 ACPI_OPERAND_OBJECT *ArgDesc;
879 ACPI_FUNCTION_TRACE ("DsEvalDataObjectOperands");
882 /* The first operand (for all of these data objects) is the length */
884 Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1);
885 if (ACPI_FAILURE (Status))
887 return_ACPI_STATUS (Status);
890 Status = AcpiExResolveOperands (WalkState->Opcode,
891 &(WalkState->Operands [WalkState->NumOperands -1]),
893 if (ACPI_FAILURE (Status))
895 return_ACPI_STATUS (Status);
898 /* Extract length operand */
900 ArgDesc = WalkState->Operands [WalkState->NumOperands - 1];
901 Length = (UINT32) ArgDesc->Integer.Value;
903 /* Cleanup for length operand */
905 Status = AcpiDsObjStackPop (1, WalkState);
906 if (ACPI_FAILURE (Status))
908 return_ACPI_STATUS (Status);
911 AcpiUtRemoveReference (ArgDesc);
914 * Create the actual data object
916 switch (Op->Common.AmlOpcode)
920 Status = AcpiDsBuildInternalBufferObj (WalkState, Op, Length, &ObjDesc);
924 case AML_VAR_PACKAGE_OP:
926 Status = AcpiDsBuildInternalPackageObj (WalkState, Op, Length, &ObjDesc);
930 return_ACPI_STATUS (AE_AML_BAD_OPCODE);
933 if (ACPI_SUCCESS (Status))
936 * Return the object in the WalkState, unless the parent is a package --
937 * in this case, the return object will be stored in the parse tree
940 if ((!Op->Common.Parent) ||
941 ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) &&
942 (Op->Common.Parent->Common.AmlOpcode != AML_VAR_PACKAGE_OP) &&
943 (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP)))
945 WalkState->ResultObj = ObjDesc;
949 return_ACPI_STATUS (Status);
953 /*******************************************************************************
955 * FUNCTION: AcpiDsExecBeginControlOp
957 * PARAMETERS: WalkList - The list that owns the walk stack
958 * Op - The control Op
962 * DESCRIPTION: Handles all control ops encountered during control method
965 ******************************************************************************/
968 AcpiDsExecBeginControlOp (
969 ACPI_WALK_STATE *WalkState,
970 ACPI_PARSE_OBJECT *Op)
972 ACPI_STATUS Status = AE_OK;
973 ACPI_GENERIC_STATE *ControlState;
976 ACPI_FUNCTION_NAME ("DsExecBeginControlOp");
979 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op,
980 Op->Common.AmlOpcode, WalkState));
982 switch (Op->Common.AmlOpcode)
988 * IF/WHILE: Create a new control state to manage these
989 * constructs. We need to manage these as a stack, in order
992 ControlState = AcpiUtCreateControlState ();
995 Status = AE_NO_MEMORY;
999 * Save a pointer to the predicate for multiple executions
1002 ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1;
1003 ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd;
1004 ControlState->Control.Opcode = Op->Common.AmlOpcode;
1007 /* Push the control state on this walk's control stack */
1009 AcpiUtPushGenericState (&WalkState->ControlState, ControlState);
1014 /* Predicate is in the state object */
1015 /* If predicate is true, the IF was executed, ignore ELSE part */
1017 if (WalkState->LastPredicate)
1019 Status = AE_CTRL_TRUE;
1036 /*******************************************************************************
1038 * FUNCTION: AcpiDsExecEndControlOp
1040 * PARAMETERS: WalkList - The list that owns the walk stack
1041 * Op - The control Op
1045 * DESCRIPTION: Handles all control ops encountered during control method
1048 ******************************************************************************/
1051 AcpiDsExecEndControlOp (
1052 ACPI_WALK_STATE *WalkState,
1053 ACPI_PARSE_OBJECT *Op)
1055 ACPI_STATUS Status = AE_OK;
1056 ACPI_GENERIC_STATE *ControlState;
1059 ACPI_FUNCTION_NAME ("DsExecEndControlOp");
1062 switch (Op->Common.AmlOpcode)
1066 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op));
1069 * Save the result of the predicate in case there is an
1072 WalkState->LastPredicate =
1073 (BOOLEAN) WalkState->ControlState->Common.Value;
1076 * Pop the control state that was created at the start
1077 * of the IF and free it
1079 ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
1080 AcpiUtDeleteGenericState (ControlState);
1091 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op));
1093 if (WalkState->ControlState->Common.Value)
1095 /* Predicate was true, go back and evaluate it again! */
1097 Status = AE_CTRL_PENDING;
1100 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] termination! Op=%p\n", Op));
1102 /* Pop this control state and free it */
1104 ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
1106 WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart;
1107 AcpiUtDeleteGenericState (ControlState);
1113 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
1114 "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg));
1117 * One optional operand -- the return value
1118 * It can be either an immediate operand or a result that
1119 * has been bubbled up the tree
1121 if (Op->Common.Value.Arg)
1123 /* Return statement has an immediate operand */
1125 Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
1126 if (ACPI_FAILURE (Status))
1132 * If value being returned is a Reference (such as
1133 * an arg or local), resolve it now because it may
1134 * cease to exist at the end of the method.
1136 Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState);
1137 if (ACPI_FAILURE (Status))
1143 * Get the return value and save as the last result
1144 * value. This is the only place where WalkState->ReturnDesc
1145 * is set to anything other than zero!
1147 WalkState->ReturnDesc = WalkState->Operands[0];
1149 else if ((WalkState->Results) &&
1150 (WalkState->Results->Results.NumResults > 0))
1153 * The return value has come from a previous calculation.
1155 * If value being returned is a Reference (such as
1156 * an arg or local), resolve it now because it may
1157 * cease to exist at the end of the method.
1159 * Allow references created by the Index operator to return unchanged.
1161 if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) &&
1162 (ACPI_GET_OBJECT_TYPE (WalkState->Results->Results.ObjDesc [0]) == ACPI_TYPE_LOCAL_REFERENCE) &&
1163 ((WalkState->Results->Results.ObjDesc [0])->Reference.Opcode != AML_INDEX_OP))
1165 Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState);
1166 if (ACPI_FAILURE (Status))
1172 WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0];
1176 /* No return operand */
1178 if (WalkState->NumOperands)
1180 AcpiUtRemoveReference (WalkState->Operands [0]);
1183 WalkState->Operands [0] = NULL;
1184 WalkState->NumOperands = 0;
1185 WalkState->ReturnDesc = NULL;
1189 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
1190 "Completed RETURN_OP State=%p, RetVal=%p\n",
1191 WalkState, WalkState->ReturnDesc));
1193 /* End the control method execution right now */
1195 Status = AE_CTRL_TERMINATE;
1201 /* Just do nothing! */
1205 case AML_BREAK_POINT_OP:
1207 /* Call up to the OS service layer to handle this */
1209 Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode");
1211 /* If and when it returns, all done. */
1217 case AML_CONTINUE_OP: /* ACPI 2.0 */
1220 /* Pop and delete control states until we find a while */
1222 while (WalkState->ControlState &&
1223 (WalkState->ControlState->Control.Opcode != AML_WHILE_OP))
1225 ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
1226 AcpiUtDeleteGenericState (ControlState);
1229 /* No while found? */
1231 if (!WalkState->ControlState)
1233 return (AE_AML_NO_WHILE);
1236 /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */
1238 WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd;
1240 /* Return status depending on opcode */
1242 if (Op->Common.AmlOpcode == AML_BREAK_OP)
1244 Status = AE_CTRL_BREAK;
1248 Status = AE_CTRL_CONTINUE;
1255 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n",
1256 Op->Common.AmlOpcode, Op));
1258 Status = AE_AML_BAD_OPCODE;