1 /******************************************************************************
3 * Module Name: dswload - Dispatcher namespace load callbacks
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2015, 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 #include "aslcompiler.h"
118 #include "acdispat.h"
119 #include "acnamesp.h"
121 #include "aslcompiler.y.h"
123 #define _COMPONENT ACPI_COMPILER
124 ACPI_MODULE_NAME ("aslload")
126 /* Local prototypes */
129 LdLoadFieldElements (
130 ACPI_PARSE_OBJECT *Op,
131 ACPI_WALK_STATE *WalkState);
134 LdLoadResourceElements (
135 ACPI_PARSE_OBJECT *Op,
136 ACPI_WALK_STATE *WalkState);
140 ACPI_PARSE_OBJECT *Op,
146 ACPI_PARSE_OBJECT *Op,
151 LdCommonNamespaceEnd (
152 ACPI_PARSE_OBJECT *Op,
157 /*******************************************************************************
159 * FUNCTION: LdLoadNamespace
161 * PARAMETERS: RootOp - Root of the parse tree
165 * DESCRIPTION: Perform a walk of the parse tree that in turn loads all of the
166 * named ASL/AML objects into the namespace. The namespace is
167 * constructed in order to resolve named references and references
168 * to named fields within resource templates/descriptors.
170 ******************************************************************************/
174 ACPI_PARSE_OBJECT *RootOp)
176 ACPI_WALK_STATE *WalkState;
179 DbgPrint (ASL_DEBUG_OUTPUT, "\nCreating namespace\n\n");
181 /* Create a new walk state */
183 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
186 return (AE_NO_MEMORY);
189 /* Walk the entire parse tree, first pass */
191 TrWalkParseTree (RootOp, ASL_WALK_VISIT_TWICE, LdNamespace1Begin,
192 LdCommonNamespaceEnd, WalkState);
194 /* Second pass to handle forward references */
196 TrWalkParseTree (RootOp, ASL_WALK_VISIT_TWICE, LdNamespace2Begin,
197 LdCommonNamespaceEnd, WalkState);
199 /* Dump the namespace if debug is enabled */
201 AcpiNsDumpTables (ACPI_NS_ALL, ACPI_UINT32_MAX);
202 ACPI_FREE (WalkState);
207 /*******************************************************************************
209 * FUNCTION: LdLoadFieldElements
211 * PARAMETERS: Op - Parent node (Field)
212 * WalkState - Current walk state
216 * DESCRIPTION: Enter the named elements of the field (children of the parent)
217 * into the namespace.
219 ******************************************************************************/
222 LdLoadFieldElements (
223 ACPI_PARSE_OBJECT *Op,
224 ACPI_WALK_STATE *WalkState)
226 ACPI_PARSE_OBJECT *Child = NULL;
227 ACPI_NAMESPACE_NODE *Node;
231 /* Get the first named field element */
233 switch (Op->Asl.AmlOpcode)
235 case AML_BANK_FIELD_OP:
237 Child = UtGetArg (Op, 6);
240 case AML_INDEX_FIELD_OP:
242 Child = UtGetArg (Op, 5);
247 Child = UtGetArg (Op, 4);
252 /* No other opcodes should arrive here */
254 return (AE_BAD_PARAMETER);
257 /* Enter all elements into the namespace */
261 switch (Child->Asl.AmlOpcode)
263 case AML_INT_RESERVEDFIELD_OP:
264 case AML_INT_ACCESSFIELD_OP:
265 case AML_INT_CONNECTION_OP:
270 Status = AcpiNsLookup (WalkState->ScopeInfo,
271 Child->Asl.Value.String,
272 ACPI_TYPE_LOCAL_REGION_FIELD,
273 ACPI_IMODE_LOAD_PASS1,
274 ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
275 ACPI_NS_ERROR_IF_FOUND,
277 if (ACPI_FAILURE (Status))
279 if (Status != AE_ALREADY_EXISTS)
281 AslError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Child,
282 Child->Asl.Value.String);
287 * The name already exists in this scope
288 * But continue processing the elements
290 AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Child,
291 Child->Asl.Value.String);
295 Child->Asl.Node = Node;
301 Child = Child->Asl.Next;
308 /*******************************************************************************
310 * FUNCTION: LdLoadResourceElements
312 * PARAMETERS: Op - Parent node (Resource Descriptor)
313 * WalkState - Current walk state
317 * DESCRIPTION: Enter the named elements of the resource descriptor (children
318 * of the parent) into the namespace.
320 * NOTE: In the real AML namespace, these named elements never exist. But
321 * we simply use the namespace here as a symbol table so we can look
322 * them up as they are referenced.
324 ******************************************************************************/
327 LdLoadResourceElements (
328 ACPI_PARSE_OBJECT *Op,
329 ACPI_WALK_STATE *WalkState)
331 ACPI_PARSE_OBJECT *InitializerOp = NULL;
332 ACPI_NAMESPACE_NODE *Node;
337 * Enter the resource name into the namespace. Name must not already exist.
338 * This opens a scope, so later field names are guaranteed to be new/unique.
340 Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Asl.Namepath,
341 ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1,
342 ACPI_NS_NO_UPSEARCH | ACPI_NS_ERROR_IF_FOUND,
344 if (ACPI_FAILURE (Status))
346 if (Status == AE_ALREADY_EXISTS)
348 /* Actual node causing the error was saved in ParentMethod */
350 AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS,
351 (ACPI_PARSE_OBJECT *) Op->Asl.ParentMethod, Op->Asl.Namepath);
357 Node->Value = (UINT32) Op->Asl.Value.Integer;
362 * Now enter the predefined fields, for easy lookup when referenced
365 InitializerOp = ASL_GET_CHILD_NODE (Op);
366 while (InitializerOp)
368 if (InitializerOp->Asl.ExternalName)
370 Status = AcpiNsLookup (WalkState->ScopeInfo,
371 InitializerOp->Asl.ExternalName,
372 ACPI_TYPE_LOCAL_RESOURCE_FIELD,
373 ACPI_IMODE_LOAD_PASS1,
374 ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE,
376 if (ACPI_FAILURE (Status))
382 * Store the field offset and length in the namespace node
383 * so it can be used when the field is referenced
385 Node->Value = InitializerOp->Asl.Value.Tag.BitOffset;
386 Node->Length = InitializerOp->Asl.Value.Tag.BitLength;
387 InitializerOp->Asl.Node = Node;
388 Node->Op = InitializerOp;
391 InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
398 /*******************************************************************************
400 * FUNCTION: LdNamespace1Begin
402 * PARAMETERS: ASL_WALK_CALLBACK
406 * DESCRIPTION: Descending callback used during the parse tree walk. If this
407 * is a named AML opcode, enter into the namespace
409 ******************************************************************************/
413 ACPI_PARSE_OBJECT *Op,
417 ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
418 ACPI_NAMESPACE_NODE *Node;
420 ACPI_OBJECT_TYPE ObjectType;
421 ACPI_OBJECT_TYPE ActualObjectType = ACPI_TYPE_ANY;
423 UINT32 Flags = ACPI_NS_NO_UPSEARCH;
424 ACPI_PARSE_OBJECT *Arg;
426 BOOLEAN ForceNewScope = FALSE;
429 ACPI_FUNCTION_NAME (LdNamespace1Begin);
430 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n",
431 Op, Op->Asl.ParseOpName));
434 * We are only interested in opcodes that have an associated name
435 * (or multiple names)
437 switch (Op->Asl.AmlOpcode)
439 case AML_BANK_FIELD_OP:
440 case AML_INDEX_FIELD_OP:
443 Status = LdLoadFieldElements (Op, WalkState);
446 case AML_INT_CONNECTION_OP:
449 if (Op->Asl.Child->Asl.AmlOpcode != AML_INT_NAMEPATH_OP)
455 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Asl.ExternalName,
456 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
458 if (ACPI_FAILURE (Status))
463 if (Node->Type == ACPI_TYPE_BUFFER)
465 Arg->Asl.Node = Node;
467 Arg = Node->Op->Asl.Child; /* Get namepath */
468 Arg = Arg->Asl.Next; /* Get actual buffer */
469 Arg = Arg->Asl.Child; /* Buffer length */
470 Arg = Arg->Asl.Next; /* RAW_DATA buffer */
476 /* All other opcodes go below */
481 /* Check if this object has already been installed in the namespace */
488 Path = Op->Asl.Namepath;
494 /* Map the raw opcode into an internal object type */
496 switch (Op->Asl.ParseOpcode)
500 Arg = Op->Asl.Child; /* Get the NameSeg/NameString node */
501 Arg = Arg->Asl.Next; /* First peer is the object to be associated with the name */
504 * If this name refers to a ResourceTemplate, we will need to open
505 * a new scope so that the resource subfield names can be entered into
506 * the namespace underneath this name
508 if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)
510 ForceNewScope = TRUE;
513 /* Get the data type associated with the named object, not the name itself */
515 /* Log2 loop to convert from Btype (binary) to Etype (encoded) */
518 for (i = 1; i < Arg->Asl.AcpiBtype; i *= 2)
525 case PARSEOP_EXTERNAL:
527 * "External" simply enters a name and type into the namespace.
528 * We must be careful to not open a new scope, however, no matter
529 * what type the external name refers to (e.g., a method)
531 * first child is name, next child is ObjectType
533 ActualObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer;
534 ObjectType = ACPI_TYPE_ANY;
537 * We will mark every new node along the path as "External". This
538 * allows some or all of the nodes to be created later in the ASL
539 * code. Handles cases like this:
541 * External (\_SB_.PCI0.ABCD, IntObj)
550 * Store (\_SB_.PCI0.ABCD, Local0)
553 Flags |= ACPI_NS_EXTERNAL;
556 case PARSEOP_DEFAULT_ARG:
558 if (Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC)
560 Status = LdLoadResourceElements (Op, WalkState);
561 return_ACPI_STATUS (Status);
564 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
569 * The name referenced by Scope(Name) must already exist at this point.
570 * In other words, forward references for Scope() are not supported.
571 * The only real reason for this is that the MS interpreter cannot
572 * handle this case. Perhaps someday this case can go away.
574 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY,
575 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
577 if (ACPI_FAILURE (Status))
579 if (Status == AE_NOT_FOUND)
581 /* The name was not found, go ahead and create it */
583 Status = AcpiNsLookup (WalkState->ScopeInfo, Path,
584 ACPI_TYPE_LOCAL_SCOPE,
585 ACPI_IMODE_LOAD_PASS1, Flags,
587 if (ACPI_FAILURE (Status))
589 return_ACPI_STATUS (Status);
593 * However, this is an error -- primarily because the MS
594 * interpreter can't handle a forward reference from the
597 AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op,
598 Op->Asl.ExternalName);
599 AslError (ASL_ERROR, ASL_MSG_SCOPE_FWD_REF, Op,
600 Op->Asl.ExternalName);
604 AslCoreSubsystemError (Op, Status,
605 "Failure from namespace lookup", FALSE);
607 return_ACPI_STATUS (Status);
610 /* We found a node with this name, now check the type */
614 case ACPI_TYPE_LOCAL_SCOPE:
615 case ACPI_TYPE_DEVICE:
616 case ACPI_TYPE_POWER:
617 case ACPI_TYPE_PROCESSOR:
618 case ACPI_TYPE_THERMAL:
620 /* These are acceptable types - they all open a new scope */
623 case ACPI_TYPE_INTEGER:
624 case ACPI_TYPE_STRING:
625 case ACPI_TYPE_BUFFER:
627 * These types we will allow, but we will change the type.
628 * This enables some existing code of the form:
631 * Scope (DEB) { ... }
633 * Which is used to workaround the fact that the MS interpreter
634 * does not allow Scope() forward references.
636 sprintf (MsgBuffer, "%s [%s], changing type to [Scope]",
637 Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type));
638 AslError (ASL_REMARK, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer);
640 /* Switch the type to scope, open the new scope */
642 Node->Type = ACPI_TYPE_LOCAL_SCOPE;
643 Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE,
645 if (ACPI_FAILURE (Status))
647 return_ACPI_STATUS (Status);
653 /* All other types are an error */
655 sprintf (MsgBuffer, "%s [%s]", Op->Asl.ExternalName,
656 AcpiUtGetTypeName (Node->Type));
657 AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer);
660 * However, switch the type to be an actual scope so
661 * that compilation can continue without generating a whole
662 * cascade of additional errors. Open the new scope.
664 Node->Type = ACPI_TYPE_LOCAL_SCOPE;
665 Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE,
667 if (ACPI_FAILURE (Status))
669 return_ACPI_STATUS (Status);
680 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
685 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Loading name: %s, (%s)\n",
686 Op->Asl.ExternalName, AcpiUtGetTypeName (ObjectType)));
688 /* The name must not already exist */
690 Flags |= ACPI_NS_ERROR_IF_FOUND;
693 * Enter the named type into the internal namespace. We enter the name
694 * as we go downward in the parse tree. Any necessary subobjects that
695 * involve arguments to the opcode must be created as we go back up the
698 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
699 ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node);
700 if (ACPI_FAILURE (Status))
702 if (Status == AE_ALREADY_EXISTS)
704 /* The name already exists in this scope */
706 if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
708 /* Allow multiple references to the same scope */
710 Node->Type = (UINT8) ObjectType;
713 else if ((Node->Flags & ANOBJ_IS_EXTERNAL) &&
714 (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL))
717 * Allow one create on an object or segment that was
718 * previously declared External
720 Node->Flags &= ~ANOBJ_IS_EXTERNAL;
721 Node->Type = (UINT8) ObjectType;
723 /* Just retyped a node, probably will need to open a scope */
725 if (AcpiNsOpensScope (ObjectType))
727 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
728 if (ACPI_FAILURE (Status))
730 return_ACPI_STATUS (Status);
737 /* Valid error, object already exists */
739 AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Op,
740 Op->Asl.ExternalName);
741 return_ACPI_STATUS (AE_OK);
746 AslCoreSubsystemError (Op, Status,
747 "Failure from namespace lookup", FALSE);
748 return_ACPI_STATUS (Status);
754 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
755 if (ACPI_FAILURE (Status))
757 return_ACPI_STATUS (Status);
763 * Point the parse node to the new namespace node, and point
764 * the Node back to the original Parse node
769 /* Set the actual data type if appropriate (EXTERNAL term only) */
771 if (ActualObjectType != ACPI_TYPE_ANY)
773 Node->Type = (UINT8) ActualObjectType;
774 Node->Value = ASL_EXTERNAL_METHOD;
777 if (Op->Asl.ParseOpcode == PARSEOP_METHOD)
780 * Get the method argument count from "Extra" and save
781 * it in the namespace node
783 Node->Value = (UINT32) Op->Asl.Extra;
786 return_ACPI_STATUS (Status);
790 /*******************************************************************************
792 * FUNCTION: LdNamespace2Begin
794 * PARAMETERS: ASL_WALK_CALLBACK
798 * DESCRIPTION: Descending callback used during the pass 2 parse tree walk.
799 * Second pass resolves some forward references.
802 * Currently only needs to handle the Alias operator.
803 * Could be used to allow forward references from the Scope() operator, but
804 * the MS interpreter does not allow this, so this compiler does not either.
806 ******************************************************************************/
810 ACPI_PARSE_OBJECT *Op,
814 ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
816 ACPI_NAMESPACE_NODE *Node;
817 ACPI_OBJECT_TYPE ObjectType;
818 BOOLEAN ForceNewScope = FALSE;
819 ACPI_PARSE_OBJECT *Arg;
821 ACPI_NAMESPACE_NODE *TargetNode;
824 ACPI_FUNCTION_NAME (LdNamespace2Begin);
825 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n",
826 Op, Op->Asl.ParseOpName));
829 /* Ignore Ops with no namespace node */
837 /* Get the type to determine if we should push the scope */
839 if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) &&
840 (Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC))
842 ObjectType = ACPI_TYPE_LOCAL_RESOURCE;
846 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
849 /* Push scope for Resource Templates */
851 if (Op->Asl.ParseOpcode == PARSEOP_NAME)
853 if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)
855 ForceNewScope = TRUE;
859 /* Push the scope stack */
861 if (ForceNewScope || AcpiNsOpensScope (ObjectType))
863 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
864 if (ACPI_FAILURE (Status))
866 return_ACPI_STATUS (Status);
870 if (Op->Asl.ParseOpcode == PARSEOP_ALIAS)
872 /* Complete the alias node by getting and saving the target node */
874 /* First child is the alias target */
878 /* Get the target pathname */
880 Path = Arg->Asl.Namepath;
883 Status = UtInternalizeName (Arg->Asl.ExternalName, &Path);
884 if (ACPI_FAILURE (Status))
890 /* Get the NS node associated with the target. It must exist. */
892 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY,
893 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
894 WalkState, &TargetNode);
895 if (ACPI_FAILURE (Status))
897 if (Status == AE_NOT_FOUND)
899 AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op,
900 Op->Asl.ExternalName);
903 * The name was not found, go ahead and create it.
904 * This prevents more errors later.
906 Status = AcpiNsLookup (WalkState->ScopeInfo, Path,
908 ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH,
913 AslCoreSubsystemError (Op, Status,
914 "Failure from namespace lookup", FALSE);
918 /* Save the target node within the alias node */
920 Node->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
927 /*******************************************************************************
929 * FUNCTION: LdCommonNamespaceEnd
931 * PARAMETERS: ASL_WALK_CALLBACK
935 * DESCRIPTION: Ascending callback used during the loading of the namespace,
936 * We only need to worry about managing the scope stack here.
938 ******************************************************************************/
941 LdCommonNamespaceEnd (
942 ACPI_PARSE_OBJECT *Op,
946 ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
947 ACPI_OBJECT_TYPE ObjectType;
948 BOOLEAN ForceNewScope = FALSE;
951 ACPI_FUNCTION_NAME (LdCommonNamespaceEnd);
954 /* We are only interested in opcodes that have an associated name */
956 if (!Op->Asl.Namepath)
961 /* Get the type to determine if we should pop the scope */
963 if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) &&
964 (Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC))
966 /* TBD: Merge into AcpiDsMapNamedOpcodeToDataType */
968 ObjectType = ACPI_TYPE_LOCAL_RESOURCE;
972 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
975 /* Pop scope that was pushed for Resource Templates */
977 if (Op->Asl.ParseOpcode == PARSEOP_NAME)
979 if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)
981 ForceNewScope = TRUE;
985 /* Pop the scope stack */
987 if (ForceNewScope || AcpiNsOpensScope (ObjectType))
989 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
990 "(%s): Popping scope for Op [%s] %p\n",
991 AcpiUtGetTypeName (ObjectType), Op->Asl.ParseOpName, Op));
993 (void) AcpiDsScopeStackPop (WalkState);