1 /******************************************************************************
3 * Module Name: dswload - Dispatcher namespace load callbacks
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
13 * All rights reserved.
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
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
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
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
73 * 3.4. Intel retains all right, title, and interest in and to the Original
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
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
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 *****************************************************************************/
116 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/dswload.c,v 1.1 2003/09/24 03:32:15 drhodus Exp $ */
118 #define __DSWLOAD_C__
121 #include "acparser.h"
123 #include "acdispat.h"
124 #include "acinterp.h"
125 #include "acnamesp.h"
126 #include "acevents.h"
129 #define _COMPONENT ACPI_DISPATCHER
130 ACPI_MODULE_NAME ("dswload")
133 /*******************************************************************************
135 * FUNCTION: AcpiDsInitCallbacks
137 * PARAMETERS: WalkState - Current state of the parse tree walk
138 * PassNumber - 1, 2, or 3
142 * DESCRIPTION: Init walk state callbacks
144 ******************************************************************************/
147 AcpiDsInitCallbacks (
148 ACPI_WALK_STATE *WalkState,
155 WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE;
156 WalkState->DescendingCallback = AcpiDsLoad1BeginOp;
157 WalkState->AscendingCallback = AcpiDsLoad1EndOp;
161 WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE;
162 WalkState->DescendingCallback = AcpiDsLoad2BeginOp;
163 WalkState->AscendingCallback = AcpiDsLoad2EndOp;
167 #ifndef ACPI_NO_METHOD_EXECUTION
168 WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE;
169 WalkState->DescendingCallback = AcpiDsExecBeginOp;
170 WalkState->AscendingCallback = AcpiDsExecEndOp;
175 return (AE_BAD_PARAMETER);
182 /*******************************************************************************
184 * FUNCTION: AcpiDsLoad1BeginOp
186 * PARAMETERS: WalkState - Current state of the parse tree walk
187 * Op - Op that has been just been reached in the
188 * walk; Arguments have not been evaluated yet.
192 * DESCRIPTION: Descending callback used during the loading of ACPI tables.
194 ******************************************************************************/
198 ACPI_WALK_STATE *WalkState,
199 ACPI_PARSE_OBJECT **OutOp)
201 ACPI_PARSE_OBJECT *Op;
202 ACPI_NAMESPACE_NODE *Node;
204 ACPI_OBJECT_TYPE ObjectType;
209 ACPI_FUNCTION_NAME ("DsLoad1BeginOp");
213 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
215 /* We are only interested in opcodes that have an associated name */
219 if (!(WalkState->OpInfo->Flags & AML_NAMED))
222 if ((WalkState->OpInfo->Class == AML_CLASS_EXECUTE) ||
223 (WalkState->OpInfo->Class == AML_CLASS_CONTROL))
225 AcpiOsPrintf ("\n\n***EXECUTABLE OPCODE %s***\n\n", WalkState->OpInfo->Name);
227 return (AE_CTRL_SKIP);
234 /* Check if this object has already been installed in the namespace */
243 Path = AcpiPsGetNextNamestring (&WalkState->ParserState);
245 /* Map the raw opcode into an internal object type */
247 ObjectType = WalkState->OpInfo->ObjectType;
249 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
250 "State=%p Op=%p [%s] ", WalkState, Op, AcpiUtGetTypeName (ObjectType)));
252 switch (WalkState->Opcode)
257 * The target name of the Scope() operator must exist at this point so
258 * that we can actually open the scope to enter new names underneath it.
259 * Allow search-to-root for single namesegs.
261 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
262 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
263 if (ACPI_FAILURE (Status))
265 ACPI_REPORT_NSERROR (Path, Status);
270 * Check to make sure that the target is
271 * one of the opcodes that actually opens a scope
275 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
276 case ACPI_TYPE_DEVICE:
277 case ACPI_TYPE_POWER:
278 case ACPI_TYPE_PROCESSOR:
279 case ACPI_TYPE_THERMAL:
281 /* These are acceptable types */
284 case ACPI_TYPE_INTEGER:
285 case ACPI_TYPE_STRING:
286 case ACPI_TYPE_BUFFER:
289 * These types we will allow, but we will change the type. This
290 * enables some existing code of the form:
293 * Scope (DEB) { ... }
295 * Note: silently change the type here. On the second pass, we will report a warning
298 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
299 Path, AcpiUtGetTypeName (Node->Type)));
301 Node->Type = ACPI_TYPE_ANY;
302 WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
307 /* All other types are an error */
309 ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n",
310 AcpiUtGetTypeName (Node->Type), Path));
312 return (AE_AML_OPERAND_TYPE);
320 * For all other named opcodes, we will enter the name into the namespace.
322 * Setup the search flags.
323 * Since we are entering a name into the namespace, we do not want to
324 * enable the search-to-root upsearch.
326 * There are only two conditions where it is acceptable that the name
328 * 1) the Scope() operator can reopen a scoping object that was
329 * previously defined (Scope, Method, Device, etc.)
330 * 2) Whenever we are parsing a deferred opcode (OpRegion, Buffer,
331 * BufferField, or Package), the name of the object is already
334 Flags = ACPI_NS_NO_UPSEARCH;
335 if ((WalkState->Opcode != AML_SCOPE_OP) &&
336 (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP)))
338 Flags |= ACPI_NS_ERROR_IF_FOUND;
339 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, "Cannot already exist\n"));
343 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, "Both Find or Create allowed\n"));
347 * Enter the named type into the internal namespace. We enter the name
348 * as we go downward in the parse tree. Any necessary subobjects that involve
349 * arguments to the opcode must be created as we go back up the parse tree later.
351 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
352 ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node));
353 if (ACPI_FAILURE (Status))
355 ACPI_REPORT_NSERROR (Path, Status);
366 /* Create a new op */
368 Op = AcpiPsAllocOp (WalkState->Opcode);
371 return (AE_NO_MEMORY);
377 Op->Named.Name = Node->Name.Integer;
379 #if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY))
380 Op->Named.Path = (UINT8 *) Path;
385 * Put the Node in the "op" object that the parser uses, so we
386 * can get it again quickly when this scope is closed
388 Op->Common.Node = Node;
389 AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op);
396 /*******************************************************************************
398 * FUNCTION: AcpiDsLoad1EndOp
400 * PARAMETERS: WalkState - Current state of the parse tree walk
401 * Op - Op that has been just been completed in the
402 * walk; Arguments have now been evaluated.
406 * DESCRIPTION: Ascending callback used during the loading of the namespace,
407 * both control methods and everything else.
409 ******************************************************************************/
413 ACPI_WALK_STATE *WalkState)
415 ACPI_PARSE_OBJECT *Op;
416 ACPI_OBJECT_TYPE ObjectType;
417 ACPI_STATUS Status = AE_OK;
420 ACPI_FUNCTION_NAME ("DsLoad1EndOp");
424 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
426 /* We are only interested in opcodes that have an associated name */
428 if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD)))
433 /* Get the object type to determine if we should pop the scope */
435 ObjectType = WalkState->OpInfo->ObjectType;
437 #ifndef ACPI_NO_METHOD_EXECUTION
438 if (WalkState->OpInfo->Flags & AML_FIELD)
440 if (WalkState->Opcode == AML_FIELD_OP ||
441 WalkState->Opcode == AML_BANK_FIELD_OP ||
442 WalkState->Opcode == AML_INDEX_FIELD_OP)
444 Status = AcpiDsInitFieldObjects (Op, WalkState);
450 if (Op->Common.AmlOpcode == AML_REGION_OP)
452 Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length,
453 (ACPI_ADR_SPACE_TYPE) ((Op->Common.Value.Arg)->Common.Value.Integer), WalkState);
454 if (ACPI_FAILURE (Status))
461 if (Op->Common.AmlOpcode == AML_NAME_OP)
463 /* For Name opcode, get the object type from the argument */
465 if (Op->Common.Value.Arg)
467 ObjectType = (AcpiPsGetOpcodeInfo ((Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType;
468 Op->Common.Node->Type = (UINT8) ObjectType;
472 if (Op->Common.AmlOpcode == AML_METHOD_OP)
475 * MethodOp PkgLength NameString MethodFlags TermList
477 * Note: We must create the method node/object pair as soon as we
478 * see the method declaration. This allows later pass1 parsing
479 * of invocations of the method (need to know the number of
482 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
483 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
484 WalkState, Op, Op->Named.Node));
486 if (!AcpiNsGetAttachedObject (Op->Named.Node))
488 WalkState->Operands[0] = (void *) Op->Named.Node;
489 WalkState->NumOperands = 1;
491 Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
492 if (ACPI_SUCCESS (Status))
494 Status = AcpiExCreateMethod (Op->Named.Data,
495 Op->Named.Length, WalkState);
497 WalkState->Operands[0] = NULL;
498 WalkState->NumOperands = 0;
500 if (ACPI_FAILURE (Status))
507 /* Pop the scope stack */
509 if (AcpiNsOpensScope (ObjectType))
511 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n",
512 AcpiUtGetTypeName (ObjectType), Op));
514 Status = AcpiDsScopeStackPop (WalkState);
521 /*******************************************************************************
523 * FUNCTION: AcpiDsLoad2BeginOp
525 * PARAMETERS: WalkState - Current state of the parse tree walk
526 * Op - Op that has been just been reached in the
527 * walk; Arguments have not been evaluated yet.
531 * DESCRIPTION: Descending callback used during the loading of ACPI tables.
533 ******************************************************************************/
537 ACPI_WALK_STATE *WalkState,
538 ACPI_PARSE_OBJECT **OutOp)
540 ACPI_PARSE_OBJECT *Op;
541 ACPI_NAMESPACE_NODE *Node;
543 ACPI_OBJECT_TYPE ObjectType;
547 ACPI_FUNCTION_TRACE ("DsLoad2BeginOp");
551 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
555 /* We only care about Namespace opcodes here */
557 if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) && (WalkState->Opcode != AML_INT_NAMEPATH_OP)) ||
558 (!(WalkState->OpInfo->Flags & AML_NAMED)))
560 return_ACPI_STATUS (AE_OK);
564 * Get the name we are going to enter or lookup in the namespace
566 if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
568 /* For Namepath op, get the path string */
570 BufferPtr = Op->Common.Value.String;
573 /* No name, just exit */
575 return_ACPI_STATUS (AE_OK);
580 /* Get name from the op */
582 BufferPtr = (char *) &Op->Named.Name;
587 /* Get the namestring from the raw AML */
589 BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState);
592 /* Map the opcode into an internal object type */
594 ObjectType = WalkState->OpInfo->ObjectType;
596 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
597 "State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType));
600 switch (WalkState->Opcode)
603 case AML_BANK_FIELD_OP:
604 case AML_INDEX_FIELD_OP:
610 case AML_INT_NAMEPATH_OP:
613 * The NamePath is an object reference to an existing object. Don't enter the
614 * name into the namespace, but look it up for use later
616 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
617 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
623 * The Path is an object reference to an existing object. Don't enter the
624 * name into the namespace, but look it up for use later
626 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
627 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
628 if (ACPI_FAILURE (Status))
630 ACPI_REPORT_NSERROR (BufferPtr, Status);
631 return_ACPI_STATUS (Status);
634 * We must check to make sure that the target is
635 * one of the opcodes that actually opens a scope
639 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
640 case ACPI_TYPE_DEVICE:
641 case ACPI_TYPE_POWER:
642 case ACPI_TYPE_PROCESSOR:
643 case ACPI_TYPE_THERMAL:
645 /* These are acceptable types */
648 case ACPI_TYPE_INTEGER:
649 case ACPI_TYPE_STRING:
650 case ACPI_TYPE_BUFFER:
653 * These types we will allow, but we will change the type. This
654 * enables some existing code of the form:
657 * Scope (DEB) { ... }
660 ACPI_REPORT_WARNING (("Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
661 BufferPtr, AcpiUtGetTypeName (Node->Type)));
663 Node->Type = ACPI_TYPE_ANY;
664 WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
669 /* All other types are an error */
671 ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s]\n",
672 AcpiUtGetTypeName (Node->Type), BufferPtr));
674 return (AE_AML_OPERAND_TYPE);
680 /* All other opcodes */
682 if (Op && Op->Common.Node)
684 /* This op/node was previously entered into the namespace */
686 Node = Op->Common.Node;
688 if (AcpiNsOpensScope (ObjectType))
690 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
691 if (ACPI_FAILURE (Status))
693 return_ACPI_STATUS (Status);
697 return_ACPI_STATUS (AE_OK);
701 * Enter the named type into the internal namespace. We enter the name
702 * as we go downward in the parse tree. Any necessary subobjects that involve
703 * arguments to the opcode must be created as we go back up the parse tree later.
705 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
706 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, WalkState, &(Node));
710 if (ACPI_FAILURE (Status))
712 ACPI_REPORT_NSERROR (BufferPtr, Status);
713 return_ACPI_STATUS (Status);
719 /* Create a new op */
721 Op = AcpiPsAllocOp (WalkState->Opcode);
724 return_ACPI_STATUS (AE_NO_MEMORY);
727 /* Initialize the new op */
731 Op->Named.Name = Node->Name.Integer;
740 * Put the Node in the "op" object that the parser uses, so we
741 * can get it again quickly when this scope is closed
743 Op->Common.Node = Node;
745 return_ACPI_STATUS (Status);
749 /*******************************************************************************
751 * FUNCTION: AcpiDsLoad2EndOp
753 * PARAMETERS: WalkState - Current state of the parse tree walk
754 * Op - Op that has been just been completed in the
755 * walk; Arguments have now been evaluated.
759 * DESCRIPTION: Ascending callback used during the loading of the namespace,
760 * both control methods and everything else.
762 ******************************************************************************/
766 ACPI_WALK_STATE *WalkState)
768 ACPI_PARSE_OBJECT *Op;
769 ACPI_STATUS Status = AE_OK;
770 ACPI_OBJECT_TYPE ObjectType;
771 ACPI_NAMESPACE_NODE *Node;
772 ACPI_PARSE_OBJECT *Arg;
773 ACPI_NAMESPACE_NODE *NewNode;
774 #ifndef ACPI_NO_METHOD_EXECUTION
779 ACPI_FUNCTION_TRACE ("DsLoad2EndOp");
782 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
783 WalkState->OpInfo->Name, Op, WalkState));
785 /* Only interested in opcodes that have namespace objects */
787 if (!(WalkState->OpInfo->Flags & AML_NSOBJECT))
789 return_ACPI_STATUS (AE_OK);
792 if (Op->Common.AmlOpcode == AML_SCOPE_OP)
794 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
795 "Ending scope Op=%p State=%p\n", Op, WalkState));
799 ObjectType = WalkState->OpInfo->ObjectType;
802 * Get the Node/name from the earlier lookup
803 * (It was saved in the *op structure)
805 Node = Op->Common.Node;
808 * Put the Node on the object stack (Contains the ACPI Name of
811 WalkState->Operands[0] = (void *) Node;
812 WalkState->NumOperands = 1;
814 /* Pop the scope stack */
816 if (AcpiNsOpensScope (ObjectType) && (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP))
818 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
819 AcpiUtGetTypeName (ObjectType), Op));
821 Status = AcpiDsScopeStackPop (WalkState);
822 if (ACPI_FAILURE (Status))
829 * Named operations are as follows:
834 * AML_CREATEBYTEFIELD
835 * AML_CREATEDWORDFIELD
837 * AML_CREATEQWORDFIELD
838 * AML_CREATEWORDFIELD
856 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
857 "Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
858 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node));
860 /* Decode the opcode */
862 Arg = Op->Common.Value.Arg;
864 switch (WalkState->OpInfo->Type)
866 #ifndef ACPI_NO_METHOD_EXECUTION
868 case AML_TYPE_CREATE_FIELD:
871 * Create the field object, but the field buffer and index must
872 * be evaluated later during the execution phase
874 Status = AcpiDsCreateBufferField (Op, WalkState);
878 case AML_TYPE_NAMED_FIELD:
880 switch (Op->Common.AmlOpcode)
882 case AML_INDEX_FIELD_OP:
884 Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node,
888 case AML_BANK_FIELD_OP:
890 Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState);
895 Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState);
899 /* All NAMED_FIELD opcodes must be handled above */
905 case AML_TYPE_NAMED_SIMPLE:
907 Status = AcpiDsCreateOperands (WalkState, Arg);
908 if (ACPI_FAILURE (Status))
913 switch (Op->Common.AmlOpcode)
915 case AML_PROCESSOR_OP:
917 Status = AcpiExCreateProcessor (WalkState);
920 case AML_POWER_RES_OP:
922 Status = AcpiExCreatePowerResource (WalkState);
927 Status = AcpiExCreateMutex (WalkState);
932 Status = AcpiExCreateEvent (WalkState);
935 case AML_DATA_REGION_OP:
937 Status = AcpiExCreateTableRegion (WalkState);
942 Status = AcpiExCreateAlias (WalkState);
952 /* Delete operands */
954 for (i = 1; i < WalkState->NumOperands; i++)
956 AcpiUtRemoveReference (WalkState->Operands[i]);
957 WalkState->Operands[i] = NULL;
961 #endif /* ACPI_NO_METHOD_EXECUTION */
963 case AML_TYPE_NAMED_COMPLEX:
965 switch (Op->Common.AmlOpcode)
967 #ifndef ACPI_NO_METHOD_EXECUTION
970 * The OpRegion is not fully parsed at this time. Only valid argument is the SpaceId.
971 * (We must save the address of the AML of the address and length operands)
974 * If we have a valid region, initialize it
975 * Namespace is NOT locked at this point.
977 Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), FALSE);
978 if (ACPI_FAILURE (Status))
981 * If AE_NOT_EXIST is returned, it is not fatal
982 * because many regions get created before a handler
983 * is installed for said region.
985 if (AE_NOT_EXIST == Status)
995 Status = AcpiDsCreateNode (WalkState, Node, Op);
997 #endif /* ACPI_NO_METHOD_EXECUTION */
1001 /* All NAMED_COMPLEX opcodes must be handled above */
1002 /* Note: Method objects were already created in Pass 1 */
1008 case AML_CLASS_INTERNAL:
1010 /* case AML_INT_NAMEPATH_OP: */
1014 case AML_CLASS_METHOD_CALL:
1016 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
1017 "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
1018 WalkState, Op, Node));
1021 * Lookup the method name and save the Node
1023 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
1024 ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,
1025 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
1026 WalkState, &(NewNode));
1027 if (ACPI_SUCCESS (Status))
1030 * Make sure that what we found is indeed a method
1031 * We didn't search for a method on purpose, to see if the name would resolve
1033 if (NewNode->Type != ACPI_TYPE_METHOD)
1035 Status = AE_AML_OPERAND_TYPE;
1038 /* We could put the returned object (Node) on the object stack for later, but
1039 * for now, we will put it in the "op" object that the parser uses, so we
1040 * can get it again at the end of this scope
1042 Op->Common.Node = NewNode;
1046 ACPI_REPORT_NSERROR (Arg->Common.Value.String, Status);
1057 /* Remove the Node pushed at the very beginning */
1059 WalkState->Operands[0] = NULL;
1060 WalkState->NumOperands = 0;
1061 return_ACPI_STATUS (Status);