checkdirs() was being passed the wrong mount point, resulting in a panic
[dragonfly.git] / sys / contrib / dev / acpica-unix-20050309 / interpreter / dispatcher / dswload.c
blob1838c47ca801cc686e3a6ece8e2552b733b16df3
1 /******************************************************************************
3 * Module Name: dswload - Dispatcher namespace load callbacks
4 * $Revision: 89 $
6 *****************************************************************************/
8 /******************************************************************************
10 * 1. Copyright Notice
12 * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
13 * All rights reserved.
15 * 2. License
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
41 * 3. Conditions
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************/
117 #define __DSWLOAD_C__
119 #include "acpi.h"
120 #include "acparser.h"
121 #include "amlcode.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"
129 #endif
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
142 * RETURN: Status
144 * DESCRIPTION: Init walk state callbacks
146 ******************************************************************************/
148 ACPI_STATUS
149 AcpiDsInitCallbacks (
150 ACPI_WALK_STATE *WalkState,
151 UINT32 PassNumber)
154 switch (PassNumber)
156 case 1:
157 WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE;
158 WalkState->DescendingCallback = AcpiDsLoad1BeginOp;
159 WalkState->AscendingCallback = AcpiDsLoad1EndOp;
160 break;
162 case 2:
163 WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE;
164 WalkState->DescendingCallback = AcpiDsLoad2BeginOp;
165 WalkState->AscendingCallback = AcpiDsLoad2EndOp;
166 break;
168 case 3:
169 #ifndef ACPI_NO_METHOD_EXECUTION
170 WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE;
171 WalkState->DescendingCallback = AcpiDsExecBeginOp;
172 WalkState->AscendingCallback = AcpiDsExecEndOp;
173 #endif
174 break;
176 default:
177 return (AE_BAD_PARAMETER);
180 return (AE_OK);
184 /*******************************************************************************
186 * FUNCTION: AcpiDsLoad1BeginOp
188 * PARAMETERS: WalkState - Current state of the parse tree walk
189 * Op - Op that has been just been reached in the
190 * walk; Arguments have not been evaluated yet.
192 * RETURN: Status
194 * DESCRIPTION: Descending callback used during the loading of ACPI tables.
196 ******************************************************************************/
198 ACPI_STATUS
199 AcpiDsLoad1BeginOp (
200 ACPI_WALK_STATE *WalkState,
201 ACPI_PARSE_OBJECT **OutOp)
203 ACPI_PARSE_OBJECT *Op;
204 ACPI_NAMESPACE_NODE *Node;
205 ACPI_STATUS Status;
206 ACPI_OBJECT_TYPE ObjectType;
207 char *Path;
208 UINT32 Flags;
211 ACPI_FUNCTION_NAME ("DsLoad1BeginOp");
214 Op = WalkState->Op;
215 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
217 /* We are only interested in opcodes that have an associated name */
219 if (Op)
221 if (!(WalkState->OpInfo->Flags & AML_NAMED))
223 #if 0
224 if ((WalkState->OpInfo->Class == AML_CLASS_EXECUTE) ||
225 (WalkState->OpInfo->Class == AML_CLASS_CONTROL))
227 AcpiOsPrintf ("\n\n***EXECUTABLE OPCODE %s***\n\n", WalkState->OpInfo->Name);
228 *OutOp = Op;
229 return (AE_CTRL_SKIP);
231 #endif
232 *OutOp = Op;
233 return (AE_OK);
236 /* Check if this object has already been installed in the namespace */
238 if (Op->Common.Node)
240 *OutOp = Op;
241 return (AE_OK);
245 Path = AcpiPsGetNextNamestring (&WalkState->ParserState);
247 /* Map the raw opcode into an internal object type */
249 ObjectType = WalkState->OpInfo->ObjectType;
251 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
252 "State=%p Op=%p [%s]\n", WalkState, Op, AcpiUtGetTypeName (ObjectType)));
254 switch (WalkState->Opcode)
256 case AML_SCOPE_OP:
259 * The target name of the Scope() operator must exist at this point so
260 * that we can actually open the scope to enter new names underneath it.
261 * Allow search-to-root for single namesegs.
263 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
264 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
265 #ifdef _ACPI_ASL_COMPILER
266 if (Status == AE_NOT_FOUND)
269 * Table disassembly:
270 * Target of Scope() not found. Generate an External for it, and
271 * insert the name into the namespace.
273 AcpiDmAddToExternalList (Path);
274 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
275 ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
277 #endif
278 if (ACPI_FAILURE (Status))
280 ACPI_REPORT_NSERROR (Path, Status);
281 return (Status);
285 * Check to make sure that the target is
286 * one of the opcodes that actually opens a scope
288 switch (Node->Type)
290 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
291 case ACPI_TYPE_DEVICE:
292 case ACPI_TYPE_POWER:
293 case ACPI_TYPE_PROCESSOR:
294 case ACPI_TYPE_THERMAL:
296 /* These are acceptable types */
297 break;
299 case ACPI_TYPE_INTEGER:
300 case ACPI_TYPE_STRING:
301 case ACPI_TYPE_BUFFER:
304 * These types we will allow, but we will change the type. This
305 * enables some existing code of the form:
307 * Name (DEB, 0)
308 * Scope (DEB) { ... }
310 * Note: silently change the type here. On the second pass, we will report a warning
313 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
314 Path, AcpiUtGetTypeName (Node->Type)));
316 Node->Type = ACPI_TYPE_ANY;
317 WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
318 break;
320 default:
322 /* All other types are an error */
324 ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n",
325 AcpiUtGetTypeName (Node->Type), Path));
327 return (AE_AML_OPERAND_TYPE);
329 break;
332 default:
335 * For all other named opcodes, we will enter the name into the namespace.
337 * Setup the search flags.
338 * Since we are entering a name into the namespace, we do not want to
339 * enable the search-to-root upsearch.
341 * There are only two conditions where it is acceptable that the name
342 * already exists:
343 * 1) the Scope() operator can reopen a scoping object that was
344 * previously defined (Scope, Method, Device, etc.)
345 * 2) Whenever we are parsing a deferred opcode (OpRegion, Buffer,
346 * BufferField, or Package), the name of the object is already
347 * in the namespace.
349 if (WalkState->DeferredNode)
351 /* This name is already in the namespace, get the node */
353 Node = WalkState->DeferredNode;
354 Status = AE_OK;
355 break;
358 Flags = ACPI_NS_NO_UPSEARCH;
359 if ((WalkState->Opcode != AML_SCOPE_OP) &&
360 (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP)))
362 Flags |= ACPI_NS_ERROR_IF_FOUND;
363 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n",
364 AcpiUtGetTypeName (ObjectType)));
366 else
368 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Both Find or Create allowed\n",
369 AcpiUtGetTypeName (ObjectType)));
373 * Enter the named type into the internal namespace. We enter the name
374 * as we go downward in the parse tree. Any necessary subobjects that involve
375 * arguments to the opcode must be created as we go back up the parse tree later.
377 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
378 ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node));
379 if (ACPI_FAILURE (Status))
381 ACPI_REPORT_NSERROR (Path, Status);
382 return (Status);
384 break;
388 /* Common exit */
390 if (!Op)
392 /* Create a new op */
394 Op = AcpiPsAllocOp (WalkState->Opcode);
395 if (!Op)
397 return (AE_NO_MEMORY);
401 /* Initialize */
403 Op->Named.Name = Node->Name.Integer;
405 #if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY))
406 Op->Named.Path = (UINT8 *) Path;
407 #endif
411 * Put the Node in the "op" object that the parser uses, so we
412 * can get it again quickly when this scope is closed
414 Op->Common.Node = Node;
415 AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op);
417 *OutOp = Op;
418 return (Status);
422 /*******************************************************************************
424 * FUNCTION: AcpiDsLoad1EndOp
426 * PARAMETERS: WalkState - Current state of the parse tree walk
427 * Op - Op that has been just been completed in the
428 * walk; Arguments have now been evaluated.
430 * RETURN: Status
432 * DESCRIPTION: Ascending callback used during the loading of the namespace,
433 * both control methods and everything else.
435 ******************************************************************************/
437 ACPI_STATUS
438 AcpiDsLoad1EndOp (
439 ACPI_WALK_STATE *WalkState)
441 ACPI_PARSE_OBJECT *Op;
442 ACPI_OBJECT_TYPE ObjectType;
443 ACPI_STATUS Status = AE_OK;
446 ACPI_FUNCTION_NAME ("DsLoad1EndOp");
449 Op = WalkState->Op;
450 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
452 /* We are only interested in opcodes that have an associated name */
454 if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD)))
456 return (AE_OK);
459 /* Get the object type to determine if we should pop the scope */
461 ObjectType = WalkState->OpInfo->ObjectType;
463 #ifndef ACPI_NO_METHOD_EXECUTION
464 if (WalkState->OpInfo->Flags & AML_FIELD)
466 if (WalkState->Opcode == AML_FIELD_OP ||
467 WalkState->Opcode == AML_BANK_FIELD_OP ||
468 WalkState->Opcode == AML_INDEX_FIELD_OP)
470 Status = AcpiDsInitFieldObjects (Op, WalkState);
472 return (Status);
476 if (Op->Common.AmlOpcode == AML_REGION_OP)
478 Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length,
479 (ACPI_ADR_SPACE_TYPE) ((Op->Common.Value.Arg)->Common.Value.Integer), WalkState);
480 if (ACPI_FAILURE (Status))
482 return (Status);
485 #endif
487 if (Op->Common.AmlOpcode == AML_NAME_OP)
489 /* For Name opcode, get the object type from the argument */
491 if (Op->Common.Value.Arg)
493 ObjectType = (AcpiPsGetOpcodeInfo ((Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType;
494 Op->Common.Node->Type = (UINT8) ObjectType;
498 if (Op->Common.AmlOpcode == AML_METHOD_OP)
501 * MethodOp PkgLength NameString MethodFlags TermList
503 * Note: We must create the method node/object pair as soon as we
504 * see the method declaration. This allows later pass1 parsing
505 * of invocations of the method (need to know the number of
506 * arguments.)
508 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
509 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
510 WalkState, Op, Op->Named.Node));
512 if (!AcpiNsGetAttachedObject (Op->Named.Node))
514 WalkState->Operands[0] = (void *) Op->Named.Node;
515 WalkState->NumOperands = 1;
517 Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
518 if (ACPI_SUCCESS (Status))
520 Status = AcpiExCreateMethod (Op->Named.Data,
521 Op->Named.Length, WalkState);
523 WalkState->Operands[0] = NULL;
524 WalkState->NumOperands = 0;
526 if (ACPI_FAILURE (Status))
528 return (Status);
533 /* Pop the scope stack */
535 if (AcpiNsOpensScope (ObjectType))
537 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n",
538 AcpiUtGetTypeName (ObjectType), Op));
540 Status = AcpiDsScopeStackPop (WalkState);
543 return (Status);
547 /*******************************************************************************
549 * FUNCTION: AcpiDsLoad2BeginOp
551 * PARAMETERS: WalkState - Current state of the parse tree walk
552 * Op - Op that has been just been reached in the
553 * walk; Arguments have not been evaluated yet.
555 * RETURN: Status
557 * DESCRIPTION: Descending callback used during the loading of ACPI tables.
559 ******************************************************************************/
561 ACPI_STATUS
562 AcpiDsLoad2BeginOp (
563 ACPI_WALK_STATE *WalkState,
564 ACPI_PARSE_OBJECT **OutOp)
566 ACPI_PARSE_OBJECT *Op;
567 ACPI_NAMESPACE_NODE *Node;
568 ACPI_STATUS Status;
569 ACPI_OBJECT_TYPE ObjectType;
570 char *BufferPtr;
573 ACPI_FUNCTION_TRACE ("DsLoad2BeginOp");
576 Op = WalkState->Op;
577 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
579 if (Op)
581 /* We only care about Namespace opcodes here */
583 if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) && (WalkState->Opcode != AML_INT_NAMEPATH_OP)) ||
584 (!(WalkState->OpInfo->Flags & AML_NAMED)))
586 return_ACPI_STATUS (AE_OK);
590 * Get the name we are going to enter or lookup in the namespace
592 if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
594 /* For Namepath op, get the path string */
596 BufferPtr = Op->Common.Value.String;
597 if (!BufferPtr)
599 /* No name, just exit */
601 return_ACPI_STATUS (AE_OK);
604 else
606 /* Get name from the op */
608 BufferPtr = (char *) &Op->Named.Name;
611 else
613 /* Get the namestring from the raw AML */
615 BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState);
618 /* Map the opcode into an internal object type */
620 ObjectType = WalkState->OpInfo->ObjectType;
622 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
623 "State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType));
626 switch (WalkState->Opcode)
628 case AML_FIELD_OP:
629 case AML_BANK_FIELD_OP:
630 case AML_INDEX_FIELD_OP:
632 Node = NULL;
633 Status = AE_OK;
634 break;
636 case AML_INT_NAMEPATH_OP:
639 * The NamePath is an object reference to an existing object. Don't enter the
640 * name into the namespace, but look it up for use later
642 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
643 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
644 break;
646 case AML_SCOPE_OP:
649 * The Path is an object reference to an existing object. Don't enter the
650 * name into the namespace, but look it up for use later
652 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
653 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
654 if (ACPI_FAILURE (Status))
656 #ifdef _ACPI_ASL_COMPILER
657 if (Status == AE_NOT_FOUND)
659 Status = AE_OK;
661 else
663 ACPI_REPORT_NSERROR (BufferPtr, Status);
665 #else
666 ACPI_REPORT_NSERROR (BufferPtr, Status);
667 #endif
668 return_ACPI_STATUS (Status);
671 * We must check to make sure that the target is
672 * one of the opcodes that actually opens a scope
674 switch (Node->Type)
676 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
677 case ACPI_TYPE_DEVICE:
678 case ACPI_TYPE_POWER:
679 case ACPI_TYPE_PROCESSOR:
680 case ACPI_TYPE_THERMAL:
682 /* These are acceptable types */
683 break;
685 case ACPI_TYPE_INTEGER:
686 case ACPI_TYPE_STRING:
687 case ACPI_TYPE_BUFFER:
690 * These types we will allow, but we will change the type. This
691 * enables some existing code of the form:
693 * Name (DEB, 0)
694 * Scope (DEB) { ... }
697 ACPI_REPORT_WARNING (("Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
698 BufferPtr, AcpiUtGetTypeName (Node->Type)));
700 Node->Type = ACPI_TYPE_ANY;
701 WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
702 break;
704 default:
706 /* All other types are an error */
708 ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s]\n",
709 AcpiUtGetTypeName (Node->Type), BufferPtr));
711 return (AE_AML_OPERAND_TYPE);
713 break;
715 default:
717 /* All other opcodes */
719 if (Op && Op->Common.Node)
721 /* This op/node was previously entered into the namespace */
723 Node = Op->Common.Node;
725 if (AcpiNsOpensScope (ObjectType))
727 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
728 if (ACPI_FAILURE (Status))
730 return_ACPI_STATUS (Status);
734 return_ACPI_STATUS (AE_OK);
738 * Enter the named type into the internal namespace. We enter the name
739 * as we go downward in the parse tree. Any necessary subobjects that involve
740 * arguments to the opcode must be created as we go back up the parse tree later.
742 * Note: Name may already exist if we are executing a deferred opcode.
744 if (WalkState->DeferredNode)
746 /* This name is already in the namespace, get the node */
748 Node = WalkState->DeferredNode;
749 Status = AE_OK;
750 break;
753 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
754 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, WalkState, &(Node));
755 break;
758 if (ACPI_FAILURE (Status))
760 ACPI_REPORT_NSERROR (BufferPtr, Status);
761 return_ACPI_STATUS (Status);
765 if (!Op)
767 /* Create a new op */
769 Op = AcpiPsAllocOp (WalkState->Opcode);
770 if (!Op)
772 return_ACPI_STATUS (AE_NO_MEMORY);
775 /* Initialize the new op */
777 if (Node)
779 Op->Named.Name = Node->Name.Integer;
781 if (OutOp)
783 *OutOp = Op;
788 * Put the Node in the "op" object that the parser uses, so we
789 * can get it again quickly when this scope is closed
791 Op->Common.Node = Node;
793 return_ACPI_STATUS (Status);
797 /*******************************************************************************
799 * FUNCTION: AcpiDsLoad2EndOp
801 * PARAMETERS: WalkState - Current state of the parse tree walk
802 * Op - Op that has been just been completed in the
803 * walk; Arguments have now been evaluated.
805 * RETURN: Status
807 * DESCRIPTION: Ascending callback used during the loading of the namespace,
808 * both control methods and everything else.
810 ******************************************************************************/
812 ACPI_STATUS
813 AcpiDsLoad2EndOp (
814 ACPI_WALK_STATE *WalkState)
816 ACPI_PARSE_OBJECT *Op;
817 ACPI_STATUS Status = AE_OK;
818 ACPI_OBJECT_TYPE ObjectType;
819 ACPI_NAMESPACE_NODE *Node;
820 ACPI_PARSE_OBJECT *Arg;
821 ACPI_NAMESPACE_NODE *NewNode;
822 #ifndef ACPI_NO_METHOD_EXECUTION
823 UINT32 i;
824 #endif
827 ACPI_FUNCTION_TRACE ("DsLoad2EndOp");
829 Op = WalkState->Op;
830 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
831 WalkState->OpInfo->Name, Op, WalkState));
833 /* Only interested in opcodes that have namespace objects */
835 if (!(WalkState->OpInfo->Flags & AML_NSOBJECT))
837 return_ACPI_STATUS (AE_OK);
840 if (Op->Common.AmlOpcode == AML_SCOPE_OP)
842 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
843 "Ending scope Op=%p State=%p\n", Op, WalkState));
847 ObjectType = WalkState->OpInfo->ObjectType;
850 * Get the Node/name from the earlier lookup
851 * (It was saved in the *op structure)
853 Node = Op->Common.Node;
856 * Put the Node on the object stack (Contains the ACPI Name of
857 * this object)
859 WalkState->Operands[0] = (void *) Node;
860 WalkState->NumOperands = 1;
862 /* Pop the scope stack */
864 if (AcpiNsOpensScope (ObjectType) && (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP))
866 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
867 AcpiUtGetTypeName (ObjectType), Op));
869 Status = AcpiDsScopeStackPop (WalkState);
870 if (ACPI_FAILURE (Status))
872 goto Cleanup;
877 * Named operations are as follows:
879 * AML_ALIAS
880 * AML_BANKFIELD
881 * AML_CREATEBITFIELD
882 * AML_CREATEBYTEFIELD
883 * AML_CREATEDWORDFIELD
884 * AML_CREATEFIELD
885 * AML_CREATEQWORDFIELD
886 * AML_CREATEWORDFIELD
887 * AML_DATA_REGION
888 * AML_DEVICE
889 * AML_EVENT
890 * AML_FIELD
891 * AML_INDEXFIELD
892 * AML_METHOD
893 * AML_METHODCALL
894 * AML_MUTEX
895 * AML_NAME
896 * AML_NAMEDFIELD
897 * AML_OPREGION
898 * AML_POWERRES
899 * AML_PROCESSOR
900 * AML_SCOPE
901 * AML_THERMALZONE
904 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
905 "Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
906 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node));
908 /* Decode the opcode */
910 Arg = Op->Common.Value.Arg;
912 switch (WalkState->OpInfo->Type)
914 #ifndef ACPI_NO_METHOD_EXECUTION
916 case AML_TYPE_CREATE_FIELD:
919 * Create the field object, but the field buffer and index must
920 * be evaluated later during the execution phase
922 Status = AcpiDsCreateBufferField (Op, WalkState);
923 break;
926 case AML_TYPE_NAMED_FIELD:
928 switch (Op->Common.AmlOpcode)
930 case AML_INDEX_FIELD_OP:
932 Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node,
933 WalkState);
934 break;
936 case AML_BANK_FIELD_OP:
938 Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState);
939 break;
941 case AML_FIELD_OP:
943 Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState);
944 break;
946 default:
947 /* All NAMED_FIELD opcodes must be handled above */
948 break;
950 break;
953 case AML_TYPE_NAMED_SIMPLE:
955 Status = AcpiDsCreateOperands (WalkState, Arg);
956 if (ACPI_FAILURE (Status))
958 goto Cleanup;
961 switch (Op->Common.AmlOpcode)
963 case AML_PROCESSOR_OP:
965 Status = AcpiExCreateProcessor (WalkState);
966 break;
968 case AML_POWER_RES_OP:
970 Status = AcpiExCreatePowerResource (WalkState);
971 break;
973 case AML_MUTEX_OP:
975 Status = AcpiExCreateMutex (WalkState);
976 break;
978 case AML_EVENT_OP:
980 Status = AcpiExCreateEvent (WalkState);
981 break;
983 case AML_DATA_REGION_OP:
985 Status = AcpiExCreateTableRegion (WalkState);
986 break;
988 case AML_ALIAS_OP:
990 Status = AcpiExCreateAlias (WalkState);
991 break;
993 default:
994 /* Unknown opcode */
996 Status = AE_OK;
997 goto Cleanup;
1000 /* Delete operands */
1002 for (i = 1; i < WalkState->NumOperands; i++)
1004 AcpiUtRemoveReference (WalkState->Operands[i]);
1005 WalkState->Operands[i] = NULL;
1008 break;
1009 #endif /* ACPI_NO_METHOD_EXECUTION */
1011 case AML_TYPE_NAMED_COMPLEX:
1013 switch (Op->Common.AmlOpcode)
1015 #ifndef ACPI_NO_METHOD_EXECUTION
1016 case AML_REGION_OP:
1018 * The OpRegion is not fully parsed at this time. Only valid argument is the SpaceId.
1019 * (We must save the address of the AML of the address and length operands)
1022 * If we have a valid region, initialize it
1023 * Namespace is NOT locked at this point.
1025 Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), FALSE);
1026 if (ACPI_FAILURE (Status))
1029 * If AE_NOT_EXIST is returned, it is not fatal
1030 * because many regions get created before a handler
1031 * is installed for said region.
1033 if (AE_NOT_EXIST == Status)
1035 Status = AE_OK;
1038 break;
1041 case AML_NAME_OP:
1043 Status = AcpiDsCreateNode (WalkState, Node, Op);
1044 break;
1045 #endif /* ACPI_NO_METHOD_EXECUTION */
1048 default:
1049 /* All NAMED_COMPLEX opcodes must be handled above */
1050 /* Note: Method objects were already created in Pass 1 */
1051 break;
1053 break;
1056 case AML_CLASS_INTERNAL:
1058 /* case AML_INT_NAMEPATH_OP: */
1059 break;
1062 case AML_CLASS_METHOD_CALL:
1064 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
1065 "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
1066 WalkState, Op, Node));
1069 * Lookup the method name and save the Node
1071 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
1072 ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,
1073 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
1074 WalkState, &(NewNode));
1075 if (ACPI_SUCCESS (Status))
1078 * Make sure that what we found is indeed a method
1079 * We didn't search for a method on purpose, to see if the name would resolve
1081 if (NewNode->Type != ACPI_TYPE_METHOD)
1083 Status = AE_AML_OPERAND_TYPE;
1086 /* We could put the returned object (Node) on the object stack for later, but
1087 * for now, we will put it in the "op" object that the parser uses, so we
1088 * can get it again at the end of this scope
1090 Op->Common.Node = NewNode;
1092 else
1094 ACPI_REPORT_NSERROR (Arg->Common.Value.String, Status);
1096 break;
1099 default:
1100 break;
1103 Cleanup:
1105 /* Remove the Node pushed at the very beginning */
1107 WalkState->Operands[0] = NULL;
1108 WalkState->NumOperands = 0;
1109 return_ACPI_STATUS (Status);