1 /******************************************************************************
3 * Module Name: dswload - Dispatcher namespace load callbacks
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, 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 *****************************************************************************/
117 #define __DSWLOAD_C__
120 #include "acparser.h"
122 #include "acdispat.h"
123 #include "acinterp.h"
124 #include "acnamesp.h"
125 #include "acevents.h"
128 #define _COMPONENT DISPATCHER
129 MODULE_NAME ("dswload")
132 /*****************************************************************************
134 * FUNCTION: AcpiDsLoad1BeginOp
136 * PARAMETERS: WalkState - Current state of the parse tree walk
137 * Op - Op that has been just been reached in the
138 * walk; Arguments have not been evaluated yet.
142 * DESCRIPTION: Descending callback used during the loading of ACPI tables.
144 ****************************************************************************/
149 ACPI_PARSE_OBJECT *Op,
150 ACPI_WALK_STATE *WalkState,
151 ACPI_PARSE_OBJECT **OutOp)
153 ACPI_NAMESPACE_NODE *Node;
155 OBJECT_TYPE_INTERNAL DataType;
159 DEBUG_PRINT (TRACE_DISPATCH,
160 ("Load1BeginOp: Op=%p State=%p\n", Op, WalkState));
163 /* We are only interested in opcodes that have an associated name */
165 if (!AcpiPsIsNamedOp (Opcode))
172 /* Check if this object has already been installed in the namespace */
180 Path = AcpiPsGetNextNamestring (WalkState->ParserState);
182 /* Map the raw opcode into an internal object type */
184 DataType = AcpiDsMapNamedOpcodeToDataType (Opcode);
187 DEBUG_PRINT (TRACE_DISPATCH,
188 ("Load1BeginOp: State=%p Op=%p Type=%x\n", WalkState, Op, DataType));
191 if (Opcode == AML_SCOPE_OP)
193 DEBUG_PRINT (TRACE_DISPATCH,
194 ("Load1BeginOp: State=%p Op=%p Type=%x\n", WalkState, Op, DataType));
198 * Enter the named type into the internal namespace. We enter the name
199 * as we go downward in the parse tree. Any necessary subobjects that involve
200 * arguments to the opcode must be created as we go back up the parse tree later.
202 Status = AcpiNsLookup (WalkState->ScopeInfo, Path,
203 DataType, IMODE_LOAD_PASS1,
204 NS_NO_UPSEARCH, WalkState, &(Node));
206 if (ACPI_FAILURE (Status))
213 /* Create a new op */
215 Op = AcpiPsAllocOp (Opcode);
218 return (AE_NO_MEMORY);
224 ((ACPI_PARSE2_OBJECT *)Op)->Name = Node->Name;
227 * Put the Node in the "op" object that the parser uses, so we
228 * can get it again quickly when this scope is closed
233 AcpiPsAppendArg (AcpiPsGetParentScope (WalkState->ParserState), Op);
241 /*****************************************************************************
243 * FUNCTION: AcpiDsLoad1EndOp
245 * PARAMETERS: WalkState - Current state of the parse tree walk
246 * Op - Op that has been just been completed in the
247 * walk; Arguments have now been evaluated.
251 * DESCRIPTION: Ascending callback used during the loading of the namespace,
252 * both control methods and everything else.
254 ****************************************************************************/
258 ACPI_WALK_STATE *WalkState,
259 ACPI_PARSE_OBJECT *Op)
261 OBJECT_TYPE_INTERNAL DataType;
264 DEBUG_PRINT (TRACE_DISPATCH,
265 ("Load1EndOp: Op=%p State=%p\n", Op, WalkState));
267 /* We are only interested in opcodes that have an associated name */
269 if (!AcpiPsIsNamedOp (Op->Opcode))
275 /* Get the type to determine if we should pop the scope */
277 DataType = AcpiDsMapNamedOpcodeToDataType (Op->Opcode);
279 if (Op->Opcode == AML_NAME_OP)
281 /* For Name opcode, check the argument */
285 DataType = AcpiDsMapOpcodeToDataType (
286 (Op->Value.Arg)->Opcode, NULL);
287 ((ACPI_NAMESPACE_NODE *)Op->Node)->Type =
293 /* Pop the scope stack */
295 if (AcpiNsOpensScope (DataType))
298 DEBUG_PRINT (TRACE_DISPATCH,
299 ("Load1EndOp/%s: Popping scope for Op %p\n",
300 AcpiCmGetTypeName (DataType), Op));
301 AcpiDsScopeStackPop (WalkState);
309 /*****************************************************************************
311 * FUNCTION: AcpiDsLoad2BeginOp
313 * PARAMETERS: WalkState - Current state of the parse tree walk
314 * Op - Op that has been just been reached in the
315 * walk; Arguments have not been evaluated yet.
319 * DESCRIPTION: Descending callback used during the loading of ACPI tables.
321 ****************************************************************************/
326 ACPI_PARSE_OBJECT *Op,
327 ACPI_WALK_STATE *WalkState,
328 ACPI_PARSE_OBJECT **OutOp)
330 ACPI_NAMESPACE_NODE *Node;
332 OBJECT_TYPE_INTERNAL DataType;
333 NATIVE_CHAR *BufferPtr;
334 void *Original = NULL;
337 DEBUG_PRINT (TRACE_DISPATCH,
338 ("Load2BeginOp: Op=%p State=%p\n", Op, WalkState));
341 /* We only care about Namespace opcodes here */
343 if (!AcpiPsIsNamespaceOp (Opcode) &&
344 Opcode != AML_NAMEPATH_OP)
350 /* Temp! same code as in psparse */
352 if (!AcpiPsIsNamedOp (Opcode))
360 * Get the name we are going to enter or lookup in the namespace
362 if (Opcode == AML_NAMEPATH_OP)
364 /* For Namepath op, get the path string */
366 BufferPtr = Op->Value.String;
369 /* No name, just exit */
377 /* Get name from the op */
379 BufferPtr = (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)Op)->Name;
385 BufferPtr = AcpiPsGetNextNamestring (WalkState->ParserState);
389 /* Map the raw opcode into an internal object type */
391 DataType = AcpiDsMapNamedOpcodeToDataType (Opcode);
393 DEBUG_PRINT (TRACE_DISPATCH,
394 ("Load2BeginOp: State=%p Op=%p Type=%x\n", WalkState, Op, DataType));
397 if (Opcode == AML_DEF_FIELD_OP ||
398 Opcode == AML_BANK_FIELD_OP ||
399 Opcode == AML_INDEX_FIELD_OP)
405 else if (Opcode == AML_NAMEPATH_OP)
408 * The NamePath is an object reference to an existing object. Don't enter the
409 * name into the namespace, but look it up for use later
411 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr,
412 DataType, IMODE_EXECUTE,
413 NS_SEARCH_PARENT, WalkState,
424 if (AcpiNsOpensScope (DataType))
426 Status = AcpiDsScopeStackPush (Node,
429 if (ACPI_FAILURE (Status))
439 * Enter the named type into the internal namespace. We enter the name
440 * as we go downward in the parse tree. Any necessary subobjects that involve
441 * arguments to the opcode must be created as we go back up the parse tree later.
443 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr,
444 DataType, IMODE_EXECUTE,
445 NS_NO_UPSEARCH, WalkState,
449 if (ACPI_SUCCESS (Status))
453 /* Create a new op */
455 Op = AcpiPsAllocOp (Opcode);
458 return (AE_NO_MEMORY);
463 ((ACPI_PARSE2_OBJECT *)Op)->Name = Node->Name;
469 * Put the Node in the "op" object that the parser uses, so we
470 * can get it again quickly when this scope is closed
476 DEBUG_PRINT (ACPI_INFO,
477 ("Lookup: old %p new %p\n", Original, Node));
479 if (Original != Node)
481 DEBUG_PRINT (ACPI_INFO,
482 ("Lookup match error: old %p new %p\n", Original, Node));
492 /*****************************************************************************
494 * FUNCTION: AcpiDsLoad2EndOp
496 * PARAMETERS: WalkState - Current state of the parse tree walk
497 * Op - Op that has been just been completed in the
498 * walk; Arguments have now been evaluated.
502 * DESCRIPTION: Ascending callback used during the loading of the namespace,
503 * both control methods and everything else.
505 ****************************************************************************/
509 ACPI_WALK_STATE *WalkState,
510 ACPI_PARSE_OBJECT *Op)
512 ACPI_STATUS Status = AE_OK;
513 OBJECT_TYPE_INTERNAL DataType;
514 ACPI_NAMESPACE_NODE *Node;
515 ACPI_PARSE_OBJECT *Arg;
516 ACPI_NAMESPACE_NODE *NewNode;
519 DEBUG_PRINT (TRACE_DISPATCH, ("Load2EndOp: Op=%p State=%p\n", Op, WalkState));
521 if (!AcpiPsIsNamespaceObjectOp (Op->Opcode))
526 if (Op->Opcode == AML_SCOPE_OP)
528 DEBUG_PRINT (TRACE_DISPATCH,
529 ("Load2EndOp: ending scope Op=%p State=%p\n", Op, WalkState));
531 if (((ACPI_PARSE2_OBJECT *)Op)->Name == -1)
533 DEBUG_PRINT (ACPI_ERROR,
534 ("Load2EndOp: Un-named scope! Op=%p State=%p\n", Op,
541 DataType = AcpiDsMapNamedOpcodeToDataType (Op->Opcode);
544 * Get the Node/name from the earlier lookup
545 * (It was saved in the *op structure)
550 * Put the Node on the object stack (Contains the ACPI Name of
554 WalkState->Operands[0] = (void *) Node;
555 WalkState->NumOperands = 1;
557 /* Pop the scope stack */
559 if (AcpiNsOpensScope (DataType))
562 DEBUG_PRINT (TRACE_DISPATCH,
563 ("AmlEndNamespaceScope/%s: Popping scope for Op %p\n",
564 AcpiCmGetTypeName (DataType), Op));
565 AcpiDsScopeStackPop (WalkState);
570 * Named operations are as follows:
589 * AML_CREATEBYTEFIELD
590 * AML_CREATEWORDFIELD
591 * AML_CREATEDWORDFIELD
596 /* Decode the opcode */
603 case AML_CREATE_FIELD_OP:
604 case AML_BIT_FIELD_OP:
605 case AML_BYTE_FIELD_OP:
606 case AML_WORD_FIELD_OP:
607 case AML_DWORD_FIELD_OP:
610 * Create the field object, but the field buffer and index must
611 * be evaluated later during the execution phase
614 DEBUG_PRINT (TRACE_DISPATCH,
615 ("LOADING-CreateXxxField: State=%p Op=%p NamedObj=%p\n",
616 WalkState, Op, Node));
618 /* Get the NameString argument */
620 if (Op->Opcode == AML_CREATE_FIELD_OP)
622 Arg = AcpiPsGetArg (Op, 3);
626 /* Create Bit/Byte/Word/Dword field */
628 Arg = AcpiPsGetArg (Op, 2);
632 * Enter the NameString into the namespace
635 Status = AcpiNsLookup (WalkState->ScopeInfo,
637 INTERNAL_TYPE_DEF_ANY,
639 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
640 WalkState, &(NewNode));
642 if (ACPI_SUCCESS (Status))
644 /* We could put the returned object (Node) on the object stack for later, but
645 * for now, we will put it in the "op" object that the parser uses, so we
646 * can get it again at the end of this scope
651 * If there is no object attached to the node, this node was just created and
652 * we need to create the field object. Otherwise, this was a lookup of an
653 * existing node and we don't want to create the field object again.
655 if (!NewNode->Object)
658 * The Field definition is not fully parsed at this time.
659 * (We must save the address of the AML for the buffer and index operands)
661 Status = AcpiAmlExecCreateField (((ACPI_PARSE2_OBJECT *) Op)->Data,
662 ((ACPI_PARSE2_OBJECT *) Op)->Length,
671 case AML_METHODCALL_OP:
673 DEBUG_PRINT (TRACE_DISPATCH,
674 ("RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
675 WalkState, Op, Node));
678 * Lookup the method name and save the Node
681 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String,
682 ACPI_TYPE_ANY, IMODE_LOAD_PASS2,
683 NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE,
684 WalkState, &(NewNode));
686 if (ACPI_SUCCESS (Status))
689 /* has name already been resolved by here ??*/
691 /* TBD: [Restructure] Make sure that what we found is indeed a method! */
692 /* We didn't search for a method on purpose, to see if the name would resolve! */
694 /* We could put the returned object (Node) on the object stack for later, but
695 * for now, we will put it in the "op" object that the parser uses, so we
696 * can get it again at the end of this scope
705 case AML_PROCESSOR_OP:
707 /* Nothing to do other than enter object into namespace */
709 DEBUG_PRINT (TRACE_DISPATCH,
710 ("LOADING-Processor: State=%p Op=%p NamedObj=%p\n",
711 WalkState, Op, Node));
713 Status = AcpiAmlExecCreateProcessor (Op, (ACPI_HANDLE) Node);
714 if (ACPI_FAILURE (Status))
719 DEBUG_PRINT (TRACE_DISPATCH,
720 ("Completed Processor Init, Op=%p State=%p entry=%p\n",
721 Op, WalkState, Node));
725 case AML_POWER_RES_OP:
727 /* Nothing to do other than enter object into namespace */
729 DEBUG_PRINT (TRACE_DISPATCH,
730 ("LOADING-PowerResource: State=%p Op=%p NamedObj=%p\n",
731 WalkState, Op, Node));
733 Status = AcpiAmlExecCreatePowerResource (Op, (ACPI_HANDLE) Node);
734 if (ACPI_FAILURE (Status))
739 DEBUG_PRINT (TRACE_DISPATCH,
740 ("Completed PowerResource Init, Op=%p State=%p entry=%p\n",
741 Op, WalkState, Node));
745 case AML_THERMAL_ZONE_OP:
747 /* Nothing to do other than enter object into namespace */
749 DEBUG_PRINT (TRACE_DISPATCH,
750 ("LOADING-ThermalZone: State=%p Op=%p NamedObj=%p\n",
751 WalkState, Op, Node));
755 case AML_DEF_FIELD_OP:
757 DEBUG_PRINT (TRACE_DISPATCH,
758 ("LOADING-Field: State=%p Op=%p NamedObj=%p\n",
759 WalkState, Op, Node));
763 Status = AcpiDsCreateField (Op,
769 case AML_INDEX_FIELD_OP:
771 DEBUG_PRINT (TRACE_DISPATCH,
772 ("LOADING-IndexField: State=%p Op=%p NamedObj=%p\n",
773 WalkState, Op, Node));
777 Status = AcpiDsCreateIndexField (Op,
778 (ACPI_HANDLE) Arg->Node,
783 case AML_BANK_FIELD_OP:
785 DEBUG_PRINT (TRACE_DISPATCH,
786 ("LOADING-BankField: State=%p Op=%p NamedObj=%p\n",
787 WalkState, Op, Node));
790 Status = AcpiDsCreateBankField (Op,
797 * MethodOp PkgLength NamesString MethodFlags TermList
801 DEBUG_PRINT (TRACE_DISPATCH,
802 ("LOADING-Method: State=%p Op=%p NamedObj=%p\n",
803 WalkState, Op, Node));
807 Status = AcpiAmlExecCreateMethod (((ACPI_PARSE2_OBJECT *) Op)->Data,
808 ((ACPI_PARSE2_OBJECT *) Op)->Length,
809 Arg->Value.Integer, (ACPI_HANDLE) Node);
817 DEBUG_PRINT (TRACE_DISPATCH,
818 ("LOADING-Mutex: Op=%p State=%p\n", Op, WalkState));
820 Status = AcpiDsCreateOperands (WalkState, Arg);
821 if (ACPI_FAILURE (Status))
826 Status = AcpiAmlExecCreateMutex (WalkState);
832 DEBUG_PRINT (TRACE_DISPATCH,
833 ("LOADING-Event: Op=%p State=%p\n", Op, WalkState));
835 Status = AcpiDsCreateOperands (WalkState, Arg);
836 if (ACPI_FAILURE (Status))
841 Status = AcpiAmlExecCreateEvent (WalkState);
852 DEBUG_PRINT (TRACE_DISPATCH,
853 ("LOADING-Opregion: Op=%p State=%p NamedObj=%p\n", Op, WalkState, Node));
857 * The OpRegion is not fully parsed at this time. Only valid argument is the SpaceId.
858 * (We must save the address of the AML of the address and length operands)
861 Status = AcpiAmlExecCreateRegion (((ACPI_PARSE2_OBJECT *) Op)->Data,
862 ((ACPI_PARSE2_OBJECT *) Op)->Length,
863 (ACPI_ADDRESS_SPACE_TYPE) Arg->Value.Integer,
866 DEBUG_PRINT (TRACE_DISPATCH,
867 ("Completed OpRegion Init, Op=%p State=%p entry=%p\n",
868 Op, WalkState, Node));
872 /* Namespace Modifier Opcodes */
876 DEBUG_PRINT (TRACE_DISPATCH,
877 ("LOADING-Alias: Op=%p State=%p\n", Op, WalkState));
879 Status = AcpiDsCreateOperands (WalkState, Arg);
880 if (ACPI_FAILURE (Status))
885 Status = AcpiAmlExecCreateAlias (WalkState);
891 DEBUG_PRINT (TRACE_DISPATCH,
892 ("LOADING-Name: Op=%p State=%p\n", Op, WalkState));
895 * Because of the execution pass through the non-control-method
896 * parts of the table, we can arrive here twice. Only init
897 * the named object node the first time through
902 Status = AcpiDsCreateNode (WalkState, Node, Op);
908 case AML_NAMEPATH_OP:
910 DEBUG_PRINT (TRACE_DISPATCH,
911 ("LOADING-NamePath object: State=%p Op=%p NamedObj=%p\n",
912 WalkState, Op, Node));
923 /* Remove the Node pushed at the very beginning */
925 AcpiDsObjStackPop (1, WalkState);