aslload.c revision 151937
1/******************************************************************************
2 *
3 * Module Name: dswload - Dispatcher namespace load callbacks
4 *              $Revision: 1.71 $
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
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.
21 *
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
28 *
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;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
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.
54 *
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.
66 *
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.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
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.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
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.
90 *
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.
99 *
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.
114 *
115 *****************************************************************************/
116
117#define __ASLLOAD_C__
118
119#include <contrib/dev/acpica/compiler/aslcompiler.h>
120#include <contrib/dev/acpica/amlcode.h>
121#include <contrib/dev/acpica/acdispat.h>
122#include <contrib/dev/acpica/acnamesp.h>
123
124#include "aslcompiler.y.h"
125
126#define _COMPONENT          ACPI_COMPILER
127        ACPI_MODULE_NAME    ("aslload")
128
129/* Local prototypes */
130
131static ACPI_STATUS
132LdLoadFieldElements (
133    ACPI_PARSE_OBJECT       *Op,
134    ACPI_WALK_STATE         *WalkState);
135
136static ACPI_STATUS
137LdLoadResourceElements (
138    ACPI_PARSE_OBJECT       *Op,
139    ACPI_WALK_STATE         *WalkState);
140
141static ACPI_STATUS
142LdNamespace1Begin (
143    ACPI_PARSE_OBJECT       *Op,
144    UINT32                  Level,
145    void                    *Context);
146
147static ACPI_STATUS
148LdNamespace1End (
149    ACPI_PARSE_OBJECT       *Op,
150    UINT32                  Level,
151    void                    *Context);
152
153
154/*******************************************************************************
155 *
156 * FUNCTION:    LdLoadNamespace
157 *
158 * PARAMETERS:  RootOp      - Root of the parse tree
159 *
160 * RETURN:      Status
161 *
162 * DESCRIPTION: Perform a walk of the parse tree that in turn loads all of the
163 *              named ASL/AML objects into the namespace.  The namespace is
164 *              constructed in order to resolve named references and references
165 *              to named fields within resource templates/descriptors.
166 *
167 ******************************************************************************/
168
169ACPI_STATUS
170LdLoadNamespace (
171    ACPI_PARSE_OBJECT       *RootOp)
172{
173    ACPI_WALK_STATE         *WalkState;
174
175
176    DbgPrint (ASL_DEBUG_OUTPUT, "\nCreating namespace\n\n");
177
178    /* Create a new walk state */
179
180    WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
181    if (!WalkState)
182    {
183        return AE_NO_MEMORY;
184    }
185
186    /* Perform the walk of the parse tree */
187
188    TrWalkParseTree (RootOp, ASL_WALK_VISIT_TWICE, LdNamespace1Begin,
189        LdNamespace1End, WalkState);
190
191    /* Dump the namespace if debug is enabled */
192
193    AcpiNsDumpTables (ACPI_NS_ALL, ACPI_UINT32_MAX);
194    return AE_OK;
195}
196
197
198/*******************************************************************************
199 *
200 * FUNCTION:    LdLoadFieldElements
201 *
202 * PARAMETERS:  Op              - Parent node (Field)
203 *              WalkState       - Current walk state
204 *
205 * RETURN:      Status
206 *
207 * DESCRIPTION: Enter the named elements of the field (children of the parent)
208 *              into the namespace.
209 *
210 ******************************************************************************/
211
212static ACPI_STATUS
213LdLoadFieldElements (
214    ACPI_PARSE_OBJECT       *Op,
215    ACPI_WALK_STATE         *WalkState)
216{
217    ACPI_PARSE_OBJECT       *Child = NULL;
218    ACPI_NAMESPACE_NODE     *Node;
219    ACPI_STATUS             Status;
220
221
222    /* Get the first named field element */
223
224    switch (Op->Asl.AmlOpcode)
225    {
226    case AML_BANK_FIELD_OP:
227
228        Child = UtGetArg (Op, 6);
229        break;
230
231    case AML_INDEX_FIELD_OP:
232
233        Child = UtGetArg (Op, 5);
234        break;
235
236    case AML_FIELD_OP:
237
238        Child = UtGetArg (Op, 4);
239        break;
240
241    default:
242        /* No other opcodes should arrive here */
243        return (AE_BAD_PARAMETER);
244    }
245
246    /* Enter all elements into the namespace */
247
248    while (Child)
249    {
250        switch (Child->Asl.AmlOpcode)
251        {
252        case AML_INT_RESERVEDFIELD_OP:
253        case AML_INT_ACCESSFIELD_OP:
254
255            break;
256
257        default:
258
259            Status = AcpiNsLookup (WalkState->ScopeInfo,
260                        Child->Asl.Value.String,
261                        ACPI_TYPE_LOCAL_REGION_FIELD,
262                        ACPI_IMODE_LOAD_PASS1,
263                        ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
264                            ACPI_NS_ERROR_IF_FOUND,
265                        NULL, &Node);
266            if (ACPI_FAILURE (Status))
267            {
268                if (Status != AE_ALREADY_EXISTS)
269                {
270                    AslError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Child,
271                        Child->Asl.Value.String);
272                    return (Status);
273                }
274
275                /*
276                 * The name already exists in this scope
277                 * But continue processing the elements
278                 */
279                AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Child,
280                    Child->Asl.Value.String);
281            }
282            else
283            {
284                Child->Asl.Node = Node;
285                Node->Op = Child;
286            }
287            break;
288        }
289        Child = Child->Asl.Next;
290    }
291    return (AE_OK);
292}
293
294
295/*******************************************************************************
296 *
297 * FUNCTION:    LdLoadResourceElements
298 *
299 * PARAMETERS:  Op              - Parent node (Resource Descriptor)
300 *              WalkState       - Current walk state
301 *
302 * RETURN:      Status
303 *
304 * DESCRIPTION: Enter the named elements of the resource descriptor (children
305 *              of the parent) into the namespace.
306 *
307 * NOTE: In the real AML namespace, these named elements never exist.  But
308 *       we simply use the namespace here as a symbol table so we can look
309 *       them up as they are referenced.
310 *
311 ******************************************************************************/
312
313static ACPI_STATUS
314LdLoadResourceElements (
315    ACPI_PARSE_OBJECT       *Op,
316    ACPI_WALK_STATE         *WalkState)
317{
318    ACPI_PARSE_OBJECT       *InitializerOp = NULL;
319    ACPI_NAMESPACE_NODE     *Node;
320    ACPI_STATUS             Status;
321
322
323    /*
324     * Enter the resource name into the namespace. Name must not already exist.
325     * This opens a scope, so later field names are guaranteed to be new/unique.
326     */
327    Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Asl.Namepath,
328                ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1,
329                ACPI_NS_NO_UPSEARCH | ACPI_NS_ERROR_IF_FOUND,
330                WalkState, &Node);
331    if (ACPI_FAILURE (Status))
332    {
333        if (Status == AE_ALREADY_EXISTS)
334        {
335            /* Actual node causing the error was saved in ParentMethod */
336
337            AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS,
338                (ACPI_PARSE_OBJECT *) Op->Asl.ParentMethod, Op->Asl.Namepath);
339            return (AE_OK);
340        }
341        return (Status);
342    }
343
344    /*
345     * Now enter the predefined fields, for easy lookup when referenced
346     * by the source ASL
347     */
348    InitializerOp = ASL_GET_CHILD_NODE (Op);
349    while (InitializerOp)
350    {
351
352        if (InitializerOp->Asl.ExternalName)
353        {
354            Status = AcpiNsLookup (WalkState->ScopeInfo,
355                        InitializerOp->Asl.ExternalName,
356                        ACPI_TYPE_LOCAL_RESOURCE_FIELD,
357                        ACPI_IMODE_LOAD_PASS1,
358                        ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE,
359                        NULL, &Node);
360            if (ACPI_FAILURE (Status))
361            {
362                return (Status);
363            }
364
365            /*
366             * Store the field offset in the namespace node so it
367             * can be used when the field is referenced
368             */
369            Node->Value = (UINT32) InitializerOp->Asl.Value.Integer;
370            InitializerOp->Asl.Node = Node;
371            Node->Op = InitializerOp;
372
373            /* Pass thru the field type (Bitfield or Bytefield) */
374
375            if (InitializerOp->Asl.CompileFlags & NODE_IS_BIT_OFFSET)
376            {
377                Node->Flags |= ANOBJ_IS_BIT_OFFSET;
378            }
379        }
380        InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
381    }
382
383    return (AE_OK);
384}
385
386
387/*******************************************************************************
388 *
389 * FUNCTION:    LdNamespace1Begin
390 *
391 * PARAMETERS:  ASL_WALK_CALLBACK
392 *
393 * RETURN:      Status
394 *
395 * DESCRIPTION: Descending callback used during the parse tree walk.  If this
396 *              is a named AML opcode, enter into the namespace
397 *
398 ******************************************************************************/
399
400static ACPI_STATUS
401LdNamespace1Begin (
402    ACPI_PARSE_OBJECT       *Op,
403    UINT32                  Level,
404    void                    *Context)
405{
406    ACPI_WALK_STATE         *WalkState = (ACPI_WALK_STATE *) Context;
407    ACPI_NAMESPACE_NODE     *Node;
408    ACPI_STATUS             Status;
409    ACPI_OBJECT_TYPE        ObjectType;
410    ACPI_OBJECT_TYPE        ActualObjectType = ACPI_TYPE_ANY;
411    char                    *Path;
412    UINT32                  Flags = ACPI_NS_NO_UPSEARCH;
413    ACPI_PARSE_OBJECT       *Arg;
414    UINT32                  i;
415
416
417    ACPI_FUNCTION_NAME ("LdNamespace1Begin");
418    ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n",
419        Op, Op->Asl.ParseOpName));
420
421
422    /*
423     * We are only interested in opcodes that have an associated name
424     * (or multiple names)
425     */
426    switch (Op->Asl.AmlOpcode)
427    {
428    case AML_BANK_FIELD_OP:
429    case AML_INDEX_FIELD_OP:
430    case AML_FIELD_OP:
431
432        Status = LdLoadFieldElements (Op, WalkState);
433        return (Status);
434
435    default:
436
437        /* All other opcodes go below */
438        break;
439    }
440
441    /* Check if this object has already been installed in the namespace */
442
443    if (Op->Asl.Node)
444    {
445        return (AE_OK);
446    }
447
448    Path = Op->Asl.Namepath;
449    if (!Path)
450    {
451        return (AE_OK);
452    }
453
454    /* Map the raw opcode into an internal object type */
455
456    switch (Op->Asl.ParseOpcode)
457    {
458    case PARSEOP_NAME:
459
460        Arg = Op->Asl.Child;  /* Get the NameSeg/NameString node */
461        Arg = Arg->Asl.Next;  /* First peer is the object to be associated with the name */
462
463        /* Get the data type associated with the named object, not the name itself */
464
465        /* Log2 loop to convert from Btype (binary) to Etype (encoded) */
466
467        ObjectType = 1;
468        for (i = 1; i < Arg->Asl.AcpiBtype; i *= 2)
469        {
470            ObjectType++;
471        }
472        break;
473
474
475    case PARSEOP_EXTERNAL:
476
477        /*
478         * "External" simply enters a name and type into the namespace.
479         * We must be careful to not open a new scope, however, no matter
480         * what type the external name refers to (e.g., a method)
481         *
482         * first child is name, next child is ObjectType
483         */
484        ActualObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer;
485        ObjectType = ACPI_TYPE_ANY;
486        break;
487
488
489    case PARSEOP_DEFAULT_ARG:
490
491        if(Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC)
492        {
493            Status = LdLoadResourceElements (Op, WalkState);
494            goto Exit;
495        }
496
497        ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
498        break;
499
500
501    case PARSEOP_SCOPE:
502
503        /*
504         * The name referenced by Scope(Name) must already exist at this point.
505         * In other words, forward references for Scope() are not supported.
506         * The only real reason for this is that the MS interpreter cannot
507         * handle this case.  Perhaps someday this case can go away.
508         */
509        Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY,
510                    ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
511                    WalkState, &(Node));
512        if (ACPI_FAILURE (Status))
513        {
514            if (Status == AE_NOT_FOUND)
515            {
516                /* The name was not found, go ahead and create it */
517
518                Status = AcpiNsLookup (WalkState->ScopeInfo, Path,
519                            ACPI_TYPE_LOCAL_SCOPE,
520                            ACPI_IMODE_LOAD_PASS1, Flags,
521                            WalkState, &(Node));
522
523                /*
524                 * However, this is an error -- primarily because the MS
525                 * interpreter can't handle a forward reference from the
526                 * Scope() operator.
527                 */
528                AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op,
529                    Op->Asl.ExternalName);
530                AslError (ASL_ERROR, ASL_MSG_SCOPE_FWD_REF, Op,
531                    Op->Asl.ExternalName);
532                goto FinishNode;
533            }
534
535            AslCoreSubsystemError (Op, Status, "Failure from lookup\n", FALSE);
536            goto Exit;
537        }
538
539        /* We found a node with this name, now check the type */
540
541        switch (Node->Type)
542        {
543        case ACPI_TYPE_LOCAL_SCOPE:
544        case ACPI_TYPE_DEVICE:
545        case ACPI_TYPE_POWER:
546        case ACPI_TYPE_PROCESSOR:
547        case ACPI_TYPE_THERMAL:
548
549            /* These are acceptable types - they all open a new scope */
550            break;
551
552        case ACPI_TYPE_INTEGER:
553        case ACPI_TYPE_STRING:
554        case ACPI_TYPE_BUFFER:
555
556            /*
557             * These types we will allow, but we will change the type.
558             * This enables some existing code of the form:
559             *
560             *  Name (DEB, 0)
561             *  Scope (DEB) { ... }
562             *
563             * Which is used to workaround the fact that the MS interpreter
564             * does not allow Scope() forward references.
565             */
566            sprintf (MsgBuffer, "%s [%s], changing type to [Scope]",
567                Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type));
568            AslError (ASL_REMARK, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer);
569
570            /* Switch the type to scope, open the new scope */
571
572            Node->Type = ACPI_TYPE_LOCAL_SCOPE;
573            Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE,
574                        WalkState);
575            if (ACPI_FAILURE (Status))
576            {
577                return_ACPI_STATUS (Status);
578            }
579            break;
580
581        default:
582
583            /* All other types are an error */
584
585            sprintf (MsgBuffer, "%s [%s]", Op->Asl.ExternalName,
586                AcpiUtGetTypeName (Node->Type));
587            AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer);
588
589            /*
590             * However, switch the type to be an actual scope so
591             * that compilation can continue without generating a whole
592             * cascade of additional errors.  Open the new scope.
593             */
594            Node->Type = ACPI_TYPE_LOCAL_SCOPE;
595            Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE,
596                        WalkState);
597            if (ACPI_FAILURE (Status))
598            {
599                return_ACPI_STATUS (Status);
600            }
601            break;
602        }
603
604        Status = AE_OK;
605        goto FinishNode;
606
607
608    default:
609
610        ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
611        break;
612    }
613
614
615    ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Loading name: %s, (%s)\n",
616            Op->Asl.ExternalName, AcpiUtGetTypeName (ObjectType)));
617
618    /* The name must not already exist */
619
620    Flags |= ACPI_NS_ERROR_IF_FOUND;
621
622    /*
623     * Enter the named type into the internal namespace.  We enter the name
624     * as we go downward in the parse tree.  Any necessary subobjects that
625     * involve arguments to the opcode must be created as we go back up the
626     * parse tree later.
627     */
628    Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
629                    ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node));
630    if (ACPI_FAILURE (Status))
631    {
632        if (Status == AE_ALREADY_EXISTS)
633        {
634            /* The name already exists in this scope */
635
636            if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
637            {
638                Node->Type = (UINT8) ObjectType;
639                Status = AE_OK;
640            }
641            else
642            {
643                AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Op,
644                    Op->Asl.ExternalName);
645                Status = AE_OK;
646                goto Exit;
647            }
648        }
649        else
650        {
651            AslCoreSubsystemError (Op, Status,
652                "Failure from lookup %s\n", FALSE);
653            goto Exit;
654        }
655    }
656
657
658FinishNode:
659    /*
660     * Point the parse node to the new namespace node, and point
661     * the Node back to the original Parse node
662     */
663    Op->Asl.Node = Node;
664    Node->Op = Op;
665
666    /* Set the actual data type if appropriate (EXTERNAL term only) */
667
668    if (ActualObjectType != ACPI_TYPE_ANY)
669    {
670        Node->Type = (UINT8) ActualObjectType;
671        Node->Value = ASL_EXTERNAL_METHOD;
672    }
673
674    if (Op->Asl.ParseOpcode == PARSEOP_METHOD)
675    {
676        /*
677         * Get the method argument count from "Extra" and save
678         * it in the namespace node
679         */
680        Node->Value = (UINT32) Op->Asl.Extra;
681    }
682
683Exit:
684    return (Status);
685}
686
687
688/*******************************************************************************
689 *
690 * FUNCTION:    LdNamespace1End
691 *
692 * PARAMETERS:  ASL_WALK_CALLBACK
693 *
694 * RETURN:      Status
695 *
696 * DESCRIPTION: Ascending callback used during the loading of the namespace,
697 *              We only need to worry about managing the scope stack here.
698 *
699 ******************************************************************************/
700
701static ACPI_STATUS
702LdNamespace1End (
703    ACPI_PARSE_OBJECT       *Op,
704    UINT32                  Level,
705    void                    *Context)
706{
707    ACPI_WALK_STATE         *WalkState = (ACPI_WALK_STATE *) Context;
708    ACPI_OBJECT_TYPE        ObjectType;
709
710
711    ACPI_FUNCTION_NAME ("LdNamespace1End");
712
713
714    /* We are only interested in opcodes that have an associated name */
715
716    if (!Op->Asl.Namepath)
717    {
718        return (AE_OK);
719    }
720
721    /* Get the type to determine if we should pop the scope */
722
723    if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) &&
724        (Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC))
725    {
726        /* TBD: Merge into AcpiDsMapNamedOpcodeToDataType */
727
728        ObjectType = ACPI_TYPE_LOCAL_RESOURCE;
729    }
730    else
731    {
732        ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
733    }
734
735    /* Pop the scope stack */
736
737    if (AcpiNsOpensScope (ObjectType))
738    {
739
740        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
741            "(%s): Popping scope for Op [%s] %p\n",
742            AcpiUtGetTypeName (ObjectType), Op->Asl.ParseOpName, Op));
743
744        (void) AcpiDsScopeStackPop (WalkState);
745    }
746
747    return (AE_OK);
748}
749
750
751