1 /******************************************************************************
3 * Module Name: dswload - Dispatcher namespace load callbacks
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2009, 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 __DSWLOAD_C__
119 #include "accommon.h"
120 #include "acparser.h"
122 #include "acdispat.h"
123 #include "acinterp.h"
124 #include "acnamesp.h"
125 #include "acevents.h"
127 #ifdef ACPI_ASL_COMPILER
128 #include "acdisasm.h"
131 #define _COMPONENT ACPI_DISPATCHER
132 ACPI_MODULE_NAME ("dswload")
135 /*******************************************************************************
137 * FUNCTION: AcpiDsInitCallbacks
139 * PARAMETERS: WalkState - Current state of the parse tree walk
140 * PassNumber - 1, 2, or 3
144 * DESCRIPTION: Init walk state callbacks
146 ******************************************************************************/
149 AcpiDsInitCallbacks (
150 ACPI_WALK_STATE
*WalkState
,
157 WalkState
->ParseFlags
= ACPI_PARSE_LOAD_PASS1
|
158 ACPI_PARSE_DELETE_TREE
;
159 WalkState
->DescendingCallback
= AcpiDsLoad1BeginOp
;
160 WalkState
->AscendingCallback
= AcpiDsLoad1EndOp
;
164 WalkState
->ParseFlags
= ACPI_PARSE_LOAD_PASS1
|
165 ACPI_PARSE_DELETE_TREE
;
166 WalkState
->DescendingCallback
= AcpiDsLoad2BeginOp
;
167 WalkState
->AscendingCallback
= AcpiDsLoad2EndOp
;
171 #ifndef ACPI_NO_METHOD_EXECUTION
172 WalkState
->ParseFlags
|= ACPI_PARSE_EXECUTE
|
173 ACPI_PARSE_DELETE_TREE
;
174 WalkState
->DescendingCallback
= AcpiDsExecBeginOp
;
175 WalkState
->AscendingCallback
= AcpiDsExecEndOp
;
180 return (AE_BAD_PARAMETER
);
187 /*******************************************************************************
189 * FUNCTION: AcpiDsLoad1BeginOp
191 * PARAMETERS: WalkState - Current state of the parse tree walk
192 * OutOp - Where to return op if a new one is created
196 * DESCRIPTION: Descending callback used during the loading of ACPI tables.
198 ******************************************************************************/
202 ACPI_WALK_STATE
*WalkState
,
203 ACPI_PARSE_OBJECT
**OutOp
)
205 ACPI_PARSE_OBJECT
*Op
;
206 ACPI_NAMESPACE_NODE
*Node
;
208 ACPI_OBJECT_TYPE ObjectType
;
213 ACPI_FUNCTION_TRACE (DsLoad1BeginOp
);
217 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
, "Op=%p State=%p\n", Op
, WalkState
));
219 /* We are only interested in opcodes that have an associated name */
223 if (!(WalkState
->OpInfo
->Flags
& AML_NAMED
))
226 return_ACPI_STATUS (AE_OK
);
229 /* Check if this object has already been installed in the namespace */
234 return_ACPI_STATUS (AE_OK
);
238 Path
= AcpiPsGetNextNamestring (&WalkState
->ParserState
);
240 /* Map the raw opcode into an internal object type */
242 ObjectType
= WalkState
->OpInfo
->ObjectType
;
244 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
,
245 "State=%p Op=%p [%s]\n", WalkState
, Op
, AcpiUtGetTypeName (ObjectType
)));
247 switch (WalkState
->Opcode
)
252 * The target name of the Scope() operator must exist at this point so
253 * that we can actually open the scope to enter new names underneath it.
254 * Allow search-to-root for single namesegs.
256 Status
= AcpiNsLookup (WalkState
->ScopeInfo
, Path
, ObjectType
,
257 ACPI_IMODE_EXECUTE
, ACPI_NS_SEARCH_PARENT
, WalkState
, &(Node
));
258 #ifdef ACPI_ASL_COMPILER
259 if (Status
== AE_NOT_FOUND
)
263 * Target of Scope() not found. Generate an External for it, and
264 * insert the name into the namespace.
266 AcpiDmAddToExternalList (Path
, ACPI_TYPE_DEVICE
, 0);
267 Status
= AcpiNsLookup (WalkState
->ScopeInfo
, Path
, ObjectType
,
268 ACPI_IMODE_LOAD_PASS1
, ACPI_NS_SEARCH_PARENT
,
272 if (ACPI_FAILURE (Status
))
274 ACPI_ERROR_NAMESPACE (Path
, Status
);
275 return_ACPI_STATUS (Status
);
279 * Check to make sure that the target is
280 * one of the opcodes that actually opens a scope
285 case ACPI_TYPE_LOCAL_SCOPE
: /* Scope */
286 case ACPI_TYPE_DEVICE
:
287 case ACPI_TYPE_POWER
:
288 case ACPI_TYPE_PROCESSOR
:
289 case ACPI_TYPE_THERMAL
:
291 /* These are acceptable types */
294 case ACPI_TYPE_INTEGER
:
295 case ACPI_TYPE_STRING
:
296 case ACPI_TYPE_BUFFER
:
299 * These types we will allow, but we will change the type. This
300 * enables some existing code of the form:
303 * Scope (DEB) { ... }
305 * Note: silently change the type here. On the second pass, we will report
308 ACPI_DEBUG_PRINT ((ACPI_DB_INFO
,
309 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
310 Path
, AcpiUtGetTypeName (Node
->Type
)));
312 Node
->Type
= ACPI_TYPE_ANY
;
313 WalkState
->ScopeInfo
->Common
.Value
= ACPI_TYPE_ANY
;
318 /* All other types are an error */
320 ACPI_ERROR ((AE_INFO
,
321 "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)",
322 AcpiUtGetTypeName (Node
->Type
), Path
));
324 return_ACPI_STATUS (AE_AML_OPERAND_TYPE
);
331 * For all other named opcodes, we will enter the name into
334 * Setup the search flags.
335 * Since we are entering a name into the namespace, we do not want to
336 * enable the search-to-root upsearch.
338 * There are only two conditions where it is acceptable that the name
340 * 1) the Scope() operator can reopen a scoping object that was
341 * previously defined (Scope, Method, Device, etc.)
342 * 2) Whenever we are parsing a deferred opcode (OpRegion, Buffer,
343 * BufferField, or Package), the name of the object is already
346 if (WalkState
->DeferredNode
)
348 /* This name is already in the namespace, get the node */
350 Node
= WalkState
->DeferredNode
;
356 * If we are executing a method, do not create any namespace objects
357 * during the load phase, only during execution.
359 if (WalkState
->MethodNode
)
366 Flags
= ACPI_NS_NO_UPSEARCH
;
367 if ((WalkState
->Opcode
!= AML_SCOPE_OP
) &&
368 (!(WalkState
->ParseFlags
& ACPI_PARSE_DEFERRED_OP
)))
370 Flags
|= ACPI_NS_ERROR_IF_FOUND
;
371 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
, "[%s] Cannot already exist\n",
372 AcpiUtGetTypeName (ObjectType
)));
376 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
,
377 "[%s] Both Find or Create allowed\n",
378 AcpiUtGetTypeName (ObjectType
)));
382 * Enter the named type into the internal namespace. We enter the name
383 * as we go downward in the parse tree. Any necessary subobjects that
384 * involve arguments to the opcode must be created as we go back up the
387 Status
= AcpiNsLookup (WalkState
->ScopeInfo
, Path
, ObjectType
,
388 ACPI_IMODE_LOAD_PASS1
, Flags
, WalkState
, &Node
);
389 if (ACPI_FAILURE (Status
))
391 if (Status
== AE_ALREADY_EXISTS
)
393 /* The name already exists in this scope */
395 if (Node
->Flags
& ANOBJ_IS_EXTERNAL
)
398 * Allow one create on an object or segment that was
399 * previously declared External
401 Node
->Flags
&= ~ANOBJ_IS_EXTERNAL
;
402 Node
->Type
= (UINT8
) ObjectType
;
404 /* Just retyped a node, probably will need to open a scope */
406 if (AcpiNsOpensScope (ObjectType
))
408 Status
= AcpiDsScopeStackPush (Node
, ObjectType
, WalkState
);
409 if (ACPI_FAILURE (Status
))
411 return_ACPI_STATUS (Status
);
419 if (ACPI_FAILURE (Status
))
421 ACPI_ERROR_NAMESPACE (Path
, Status
);
422 return_ACPI_STATUS (Status
);
432 /* Create a new op */
434 Op
= AcpiPsAllocOp (WalkState
->Opcode
);
437 return_ACPI_STATUS (AE_NO_MEMORY
);
441 /* Initialize the op */
443 #if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY))
444 Op
->Named
.Path
= ACPI_CAST_PTR (UINT8
, Path
);
450 * Put the Node in the "op" object that the parser uses, so we
451 * can get it again quickly when this scope is closed
453 Op
->Common
.Node
= Node
;
454 Op
->Named
.Name
= Node
->Name
.Integer
;
457 AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState
->ParserState
), Op
);
459 return_ACPI_STATUS (Status
);
463 /*******************************************************************************
465 * FUNCTION: AcpiDsLoad1EndOp
467 * PARAMETERS: WalkState - Current state of the parse tree walk
471 * DESCRIPTION: Ascending callback used during the loading of the namespace,
472 * both control methods and everything else.
474 ******************************************************************************/
478 ACPI_WALK_STATE
*WalkState
)
480 ACPI_PARSE_OBJECT
*Op
;
481 ACPI_OBJECT_TYPE ObjectType
;
482 ACPI_STATUS Status
= AE_OK
;
485 ACPI_FUNCTION_TRACE (DsLoad1EndOp
);
489 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
, "Op=%p State=%p\n", Op
, WalkState
));
491 /* We are only interested in opcodes that have an associated name */
493 if (!(WalkState
->OpInfo
->Flags
& (AML_NAMED
| AML_FIELD
)))
495 return_ACPI_STATUS (AE_OK
);
498 /* Get the object type to determine if we should pop the scope */
500 ObjectType
= WalkState
->OpInfo
->ObjectType
;
502 #ifndef ACPI_NO_METHOD_EXECUTION
503 if (WalkState
->OpInfo
->Flags
& AML_FIELD
)
506 * If we are executing a method, do not create any namespace objects
507 * during the load phase, only during execution.
509 if (!WalkState
->MethodNode
)
511 if (WalkState
->Opcode
== AML_FIELD_OP
||
512 WalkState
->Opcode
== AML_BANK_FIELD_OP
||
513 WalkState
->Opcode
== AML_INDEX_FIELD_OP
)
515 Status
= AcpiDsInitFieldObjects (Op
, WalkState
);
518 return_ACPI_STATUS (Status
);
522 * If we are executing a method, do not create any namespace objects
523 * during the load phase, only during execution.
525 if (!WalkState
->MethodNode
)
527 if (Op
->Common
.AmlOpcode
== AML_REGION_OP
)
529 Status
= AcpiExCreateRegion (Op
->Named
.Data
, Op
->Named
.Length
,
530 (ACPI_ADR_SPACE_TYPE
) ((Op
->Common
.Value
.Arg
)->Common
.Value
.Integer
),
532 if (ACPI_FAILURE (Status
))
534 return_ACPI_STATUS (Status
);
537 else if (Op
->Common
.AmlOpcode
== AML_DATA_REGION_OP
)
539 Status
= AcpiExCreateRegion (Op
->Named
.Data
, Op
->Named
.Length
,
540 REGION_DATA_TABLE
, WalkState
);
541 if (ACPI_FAILURE (Status
))
543 return_ACPI_STATUS (Status
);
549 if (Op
->Common
.AmlOpcode
== AML_NAME_OP
)
551 /* For Name opcode, get the object type from the argument */
553 if (Op
->Common
.Value
.Arg
)
555 ObjectType
= (AcpiPsGetOpcodeInfo (
556 (Op
->Common
.Value
.Arg
)->Common
.AmlOpcode
))->ObjectType
;
558 /* Set node type if we have a namespace node */
562 Op
->Common
.Node
->Type
= (UINT8
) ObjectType
;
568 * If we are executing a method, do not create any namespace objects
569 * during the load phase, only during execution.
571 if (!WalkState
->MethodNode
)
573 if (Op
->Common
.AmlOpcode
== AML_METHOD_OP
)
576 * MethodOp PkgLength NameString MethodFlags TermList
578 * Note: We must create the method node/object pair as soon as we
579 * see the method declaration. This allows later pass1 parsing
580 * of invocations of the method (need to know the number of
583 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
,
584 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
585 WalkState
, Op
, Op
->Named
.Node
));
587 if (!AcpiNsGetAttachedObject (Op
->Named
.Node
))
589 WalkState
->Operands
[0] = ACPI_CAST_PTR (void, Op
->Named
.Node
);
590 WalkState
->NumOperands
= 1;
592 Status
= AcpiDsCreateOperands (WalkState
, Op
->Common
.Value
.Arg
);
593 if (ACPI_SUCCESS (Status
))
595 Status
= AcpiExCreateMethod (Op
->Named
.Data
,
596 Op
->Named
.Length
, WalkState
);
599 WalkState
->Operands
[0] = NULL
;
600 WalkState
->NumOperands
= 0;
602 if (ACPI_FAILURE (Status
))
604 return_ACPI_STATUS (Status
);
610 /* Pop the scope stack (only if loading a table) */
612 if (!WalkState
->MethodNode
&&
613 AcpiNsOpensScope (ObjectType
))
615 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
, "(%s): Popping scope for Op %p\n",
616 AcpiUtGetTypeName (ObjectType
), Op
));
618 Status
= AcpiDsScopeStackPop (WalkState
);
621 return_ACPI_STATUS (Status
);
625 /*******************************************************************************
627 * FUNCTION: AcpiDsLoad2BeginOp
629 * PARAMETERS: WalkState - Current state of the parse tree walk
630 * OutOp - Wher to return op if a new one is created
634 * DESCRIPTION: Descending callback used during the loading of ACPI tables.
636 ******************************************************************************/
640 ACPI_WALK_STATE
*WalkState
,
641 ACPI_PARSE_OBJECT
**OutOp
)
643 ACPI_PARSE_OBJECT
*Op
;
644 ACPI_NAMESPACE_NODE
*Node
;
646 ACPI_OBJECT_TYPE ObjectType
;
651 ACPI_FUNCTION_TRACE (DsLoad2BeginOp
);
655 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
, "Op=%p State=%p\n", Op
, WalkState
));
659 if ((WalkState
->ControlState
) &&
660 (WalkState
->ControlState
->Common
.State
==
661 ACPI_CONTROL_CONDITIONAL_EXECUTING
))
663 /* We are executing a while loop outside of a method */
665 Status
= AcpiDsExecBeginOp (WalkState
, OutOp
);
666 return_ACPI_STATUS (Status
);
669 /* We only care about Namespace opcodes here */
671 if ((!(WalkState
->OpInfo
->Flags
& AML_NSOPCODE
) &&
672 (WalkState
->Opcode
!= AML_INT_NAMEPATH_OP
)) ||
673 (!(WalkState
->OpInfo
->Flags
& AML_NAMED
)))
675 return_ACPI_STATUS (AE_OK
);
678 /* Get the name we are going to enter or lookup in the namespace */
680 if (WalkState
->Opcode
== AML_INT_NAMEPATH_OP
)
682 /* For Namepath op, get the path string */
684 BufferPtr
= Op
->Common
.Value
.String
;
687 /* No name, just exit */
689 return_ACPI_STATUS (AE_OK
);
694 /* Get name from the op */
696 BufferPtr
= ACPI_CAST_PTR (char, &Op
->Named
.Name
);
701 /* Get the namestring from the raw AML */
703 BufferPtr
= AcpiPsGetNextNamestring (&WalkState
->ParserState
);
706 /* Map the opcode into an internal object type */
708 ObjectType
= WalkState
->OpInfo
->ObjectType
;
710 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
,
711 "State=%p Op=%p Type=%X\n", WalkState
, Op
, ObjectType
));
713 switch (WalkState
->Opcode
)
716 case AML_BANK_FIELD_OP
:
717 case AML_INDEX_FIELD_OP
:
723 case AML_INT_NAMEPATH_OP
:
725 * The NamePath is an object reference to an existing object.
726 * Don't enter the name into the namespace, but look it up
729 Status
= AcpiNsLookup (WalkState
->ScopeInfo
, BufferPtr
, ObjectType
,
730 ACPI_IMODE_EXECUTE
, ACPI_NS_SEARCH_PARENT
,
736 * The Path is an object reference to an existing object.
737 * Don't enter the name into the namespace, but look it up
740 Status
= AcpiNsLookup (WalkState
->ScopeInfo
, BufferPtr
, ObjectType
,
741 ACPI_IMODE_EXECUTE
, ACPI_NS_SEARCH_PARENT
,
743 if (ACPI_FAILURE (Status
))
745 #ifdef ACPI_ASL_COMPILER
746 if (Status
== AE_NOT_FOUND
)
752 ACPI_ERROR_NAMESPACE (BufferPtr
, Status
);
755 ACPI_ERROR_NAMESPACE (BufferPtr
, Status
);
757 return_ACPI_STATUS (Status
);
761 * We must check to make sure that the target is
762 * one of the opcodes that actually opens a scope
767 case ACPI_TYPE_LOCAL_SCOPE
: /* Scope */
768 case ACPI_TYPE_DEVICE
:
769 case ACPI_TYPE_POWER
:
770 case ACPI_TYPE_PROCESSOR
:
771 case ACPI_TYPE_THERMAL
:
773 /* These are acceptable types */
776 case ACPI_TYPE_INTEGER
:
777 case ACPI_TYPE_STRING
:
778 case ACPI_TYPE_BUFFER
:
781 * These types we will allow, but we will change the type. This
782 * enables some existing code of the form:
785 * Scope (DEB) { ... }
787 ACPI_WARNING ((AE_INFO
,
788 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)",
789 BufferPtr
, AcpiUtGetTypeName (Node
->Type
)));
791 Node
->Type
= ACPI_TYPE_ANY
;
792 WalkState
->ScopeInfo
->Common
.Value
= ACPI_TYPE_ANY
;
797 /* All other types are an error */
799 ACPI_ERROR ((AE_INFO
,
800 "Invalid type (%s) for target of Scope operator [%4.4s]",
801 AcpiUtGetTypeName (Node
->Type
), BufferPtr
));
803 return (AE_AML_OPERAND_TYPE
);
809 /* All other opcodes */
811 if (Op
&& Op
->Common
.Node
)
813 /* This op/node was previously entered into the namespace */
815 Node
= Op
->Common
.Node
;
817 if (AcpiNsOpensScope (ObjectType
))
819 Status
= AcpiDsScopeStackPush (Node
, ObjectType
, WalkState
);
820 if (ACPI_FAILURE (Status
))
822 return_ACPI_STATUS (Status
);
826 return_ACPI_STATUS (AE_OK
);
830 * Enter the named type into the internal namespace. We enter the name
831 * as we go downward in the parse tree. Any necessary subobjects that
832 * involve arguments to the opcode must be created as we go back up the
835 * Note: Name may already exist if we are executing a deferred opcode.
837 if (WalkState
->DeferredNode
)
839 /* This name is already in the namespace, get the node */
841 Node
= WalkState
->DeferredNode
;
846 Flags
= ACPI_NS_NO_UPSEARCH
;
847 if (WalkState
->PassNumber
== ACPI_IMODE_EXECUTE
)
849 /* Execution mode, node cannot already exist, node is temporary */
851 Flags
|= ACPI_NS_ERROR_IF_FOUND
;
853 if (!(WalkState
->ParseFlags
& ACPI_PARSE_MODULE_LEVEL
))
855 Flags
|= ACPI_NS_TEMPORARY
;
859 /* Add new entry or lookup existing entry */
861 Status
= AcpiNsLookup (WalkState
->ScopeInfo
, BufferPtr
, ObjectType
,
862 ACPI_IMODE_LOAD_PASS2
, Flags
, WalkState
, &Node
);
864 if (ACPI_SUCCESS (Status
) && (Flags
& ACPI_NS_TEMPORARY
))
866 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
,
867 "***New Node [%4.4s] %p is temporary\n",
868 AcpiUtGetNodeName (Node
), Node
));
873 if (ACPI_FAILURE (Status
))
875 ACPI_ERROR_NAMESPACE (BufferPtr
, Status
);
876 return_ACPI_STATUS (Status
);
881 /* Create a new op */
883 Op
= AcpiPsAllocOp (WalkState
->Opcode
);
886 return_ACPI_STATUS (AE_NO_MEMORY
);
889 /* Initialize the new op */
893 Op
->Named
.Name
= Node
->Name
.Integer
;
899 * Put the Node in the "op" object that the parser uses, so we
900 * can get it again quickly when this scope is closed
902 Op
->Common
.Node
= Node
;
903 return_ACPI_STATUS (Status
);
907 /*******************************************************************************
909 * FUNCTION: AcpiDsLoad2EndOp
911 * PARAMETERS: WalkState - Current state of the parse tree walk
915 * DESCRIPTION: Ascending callback used during the loading of the namespace,
916 * both control methods and everything else.
918 ******************************************************************************/
922 ACPI_WALK_STATE
*WalkState
)
924 ACPI_PARSE_OBJECT
*Op
;
925 ACPI_STATUS Status
= AE_OK
;
926 ACPI_OBJECT_TYPE ObjectType
;
927 ACPI_NAMESPACE_NODE
*Node
;
928 ACPI_PARSE_OBJECT
*Arg
;
929 ACPI_NAMESPACE_NODE
*NewNode
;
930 #ifndef ACPI_NO_METHOD_EXECUTION
936 ACPI_FUNCTION_TRACE (DsLoad2EndOp
);
939 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
, "Opcode [%s] Op %p State %p\n",
940 WalkState
->OpInfo
->Name
, Op
, WalkState
));
942 /* Check if opcode had an associated namespace object */
944 if (!(WalkState
->OpInfo
->Flags
& AML_NSOBJECT
))
946 return_ACPI_STATUS (AE_OK
);
949 if (Op
->Common
.AmlOpcode
== AML_SCOPE_OP
)
951 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
,
952 "Ending scope Op=%p State=%p\n", Op
, WalkState
));
955 ObjectType
= WalkState
->OpInfo
->ObjectType
;
958 * Get the Node/name from the earlier lookup
959 * (It was saved in the *op structure)
961 Node
= Op
->Common
.Node
;
964 * Put the Node on the object stack (Contains the ACPI Name of
967 WalkState
->Operands
[0] = (void *) Node
;
968 WalkState
->NumOperands
= 1;
970 /* Pop the scope stack */
972 if (AcpiNsOpensScope (ObjectType
) &&
973 (Op
->Common
.AmlOpcode
!= AML_INT_METHODCALL_OP
))
975 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
, "(%s) Popping scope for Op %p\n",
976 AcpiUtGetTypeName (ObjectType
), Op
));
978 Status
= AcpiDsScopeStackPop (WalkState
);
979 if (ACPI_FAILURE (Status
))
986 * Named operations are as follows:
991 * AML_CREATEBYTEFIELD
992 * AML_CREATEDWORDFIELD
994 * AML_CREATEQWORDFIELD
995 * AML_CREATEWORDFIELD
1013 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
,
1014 "Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
1015 AcpiPsGetOpcodeName (Op
->Common
.AmlOpcode
), WalkState
, Op
, Node
));
1017 /* Decode the opcode */
1019 Arg
= Op
->Common
.Value
.Arg
;
1021 switch (WalkState
->OpInfo
->Type
)
1023 #ifndef ACPI_NO_METHOD_EXECUTION
1025 case AML_TYPE_CREATE_FIELD
:
1027 * Create the field object, but the field buffer and index must
1028 * be evaluated later during the execution phase
1030 Status
= AcpiDsCreateBufferField (Op
, WalkState
);
1034 case AML_TYPE_NAMED_FIELD
:
1036 * If we are executing a method, initialize the field
1038 if (WalkState
->MethodNode
)
1040 Status
= AcpiDsInitFieldObjects (Op
, WalkState
);
1043 switch (Op
->Common
.AmlOpcode
)
1045 case AML_INDEX_FIELD_OP
:
1047 Status
= AcpiDsCreateIndexField (Op
, (ACPI_HANDLE
) Arg
->Common
.Node
,
1051 case AML_BANK_FIELD_OP
:
1053 Status
= AcpiDsCreateBankField (Op
, Arg
->Common
.Node
, WalkState
);
1058 Status
= AcpiDsCreateField (Op
, Arg
->Common
.Node
, WalkState
);
1062 /* All NAMED_FIELD opcodes must be handled above */
1068 case AML_TYPE_NAMED_SIMPLE
:
1070 Status
= AcpiDsCreateOperands (WalkState
, Arg
);
1071 if (ACPI_FAILURE (Status
))
1076 switch (Op
->Common
.AmlOpcode
)
1078 case AML_PROCESSOR_OP
:
1080 Status
= AcpiExCreateProcessor (WalkState
);
1083 case AML_POWER_RES_OP
:
1085 Status
= AcpiExCreatePowerResource (WalkState
);
1090 Status
= AcpiExCreateMutex (WalkState
);
1095 Status
= AcpiExCreateEvent (WalkState
);
1101 Status
= AcpiExCreateAlias (WalkState
);
1105 /* Unknown opcode */
1111 /* Delete operands */
1113 for (i
= 1; i
< WalkState
->NumOperands
; i
++)
1115 AcpiUtRemoveReference (WalkState
->Operands
[i
]);
1116 WalkState
->Operands
[i
] = NULL
;
1120 #endif /* ACPI_NO_METHOD_EXECUTION */
1122 case AML_TYPE_NAMED_COMPLEX
:
1124 switch (Op
->Common
.AmlOpcode
)
1126 #ifndef ACPI_NO_METHOD_EXECUTION
1128 case AML_DATA_REGION_OP
:
1130 if (Op
->Common
.AmlOpcode
== AML_REGION_OP
)
1132 RegionSpace
= (ACPI_ADR_SPACE_TYPE
)
1133 ((Op
->Common
.Value
.Arg
)->Common
.Value
.Integer
);
1137 RegionSpace
= REGION_DATA_TABLE
;
1141 * If we are executing a method, initialize the region
1143 if (WalkState
->MethodNode
)
1145 Status
= AcpiExCreateRegion (Op
->Named
.Data
, Op
->Named
.Length
,
1146 RegionSpace
, WalkState
);
1147 if (ACPI_FAILURE (Status
))
1154 * The OpRegion is not fully parsed at this time. Only valid
1155 * argument is the SpaceId. (We must save the address of the
1156 * AML of the address and length operands)
1160 * If we have a valid region, initialize it
1161 * Namespace is NOT locked at this point.
1163 * TBD: need to unlock interpreter if it is locked, in order
1164 * to allow _REG methods to be run.
1166 Status
= AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node
),
1168 if (ACPI_FAILURE (Status
))
1171 * If AE_NOT_EXIST is returned, it is not fatal
1172 * because many regions get created before a handler
1173 * is installed for said region.
1175 if (AE_NOT_EXIST
== Status
)
1185 Status
= AcpiDsCreateNode (WalkState
, Node
, Op
);
1191 * MethodOp PkgLength NameString MethodFlags TermList
1193 * Note: We must create the method node/object pair as soon as we
1194 * see the method declaration. This allows later pass1 parsing
1195 * of invocations of the method (need to know the number of
1198 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
,
1199 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
1200 WalkState
, Op
, Op
->Named
.Node
));
1202 if (!AcpiNsGetAttachedObject (Op
->Named
.Node
))
1204 WalkState
->Operands
[0] = ACPI_CAST_PTR (void, Op
->Named
.Node
);
1205 WalkState
->NumOperands
= 1;
1207 Status
= AcpiDsCreateOperands (WalkState
, Op
->Common
.Value
.Arg
);
1208 if (ACPI_SUCCESS (Status
))
1210 Status
= AcpiExCreateMethod (Op
->Named
.Data
,
1211 Op
->Named
.Length
, WalkState
);
1213 WalkState
->Operands
[0] = NULL
;
1214 WalkState
->NumOperands
= 0;
1216 if (ACPI_FAILURE (Status
))
1218 return_ACPI_STATUS (Status
);
1223 #endif /* ACPI_NO_METHOD_EXECUTION */
1226 /* All NAMED_COMPLEX opcodes must be handled above */
1232 case AML_CLASS_INTERNAL
:
1234 /* case AML_INT_NAMEPATH_OP: */
1238 case AML_CLASS_METHOD_CALL
:
1240 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
,
1241 "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
1242 WalkState
, Op
, Node
));
1245 * Lookup the method name and save the Node
1247 Status
= AcpiNsLookup (WalkState
->ScopeInfo
, Arg
->Common
.Value
.String
,
1248 ACPI_TYPE_ANY
, ACPI_IMODE_LOAD_PASS2
,
1249 ACPI_NS_SEARCH_PARENT
| ACPI_NS_DONT_OPEN_SCOPE
,
1250 WalkState
, &(NewNode
));
1251 if (ACPI_SUCCESS (Status
))
1254 * Make sure that what we found is indeed a method
1255 * We didn't search for a method on purpose, to see if the name
1258 if (NewNode
->Type
!= ACPI_TYPE_METHOD
)
1260 Status
= AE_AML_OPERAND_TYPE
;
1263 /* We could put the returned object (Node) on the object stack for
1264 * later, but for now, we will put it in the "op" object that the
1265 * parser uses, so we can get it again at the end of this scope
1267 Op
->Common
.Node
= NewNode
;
1271 ACPI_ERROR_NAMESPACE (Arg
->Common
.Value
.String
, Status
);
1282 /* Remove the Node pushed at the very beginning */
1284 WalkState
->Operands
[0] = NULL
;
1285 WalkState
->NumOperands
= 0;
1286 return_ACPI_STATUS (Status
);