xref: /onnv-gate/usr/src/uts/intel/io/acpica/parser/psscope.c (revision 7851:e828bbb1689c)
1*7851SDana.Myers@Sun.COM /******************************************************************************
2*7851SDana.Myers@Sun.COM  *
3*7851SDana.Myers@Sun.COM  * Module Name: psscope - Parser scope stack management routines
4*7851SDana.Myers@Sun.COM  *              $Revision: 1.48 $
5*7851SDana.Myers@Sun.COM  *
6*7851SDana.Myers@Sun.COM  *****************************************************************************/
7*7851SDana.Myers@Sun.COM 
8*7851SDana.Myers@Sun.COM /******************************************************************************
9*7851SDana.Myers@Sun.COM  *
10*7851SDana.Myers@Sun.COM  * 1. Copyright Notice
11*7851SDana.Myers@Sun.COM  *
12*7851SDana.Myers@Sun.COM  * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp.
13*7851SDana.Myers@Sun.COM  * All rights reserved.
14*7851SDana.Myers@Sun.COM  *
15*7851SDana.Myers@Sun.COM  * 2. License
16*7851SDana.Myers@Sun.COM  *
17*7851SDana.Myers@Sun.COM  * 2.1. This is your license from Intel Corp. under its intellectual property
18*7851SDana.Myers@Sun.COM  * rights.  You may have additional license terms from the party that provided
19*7851SDana.Myers@Sun.COM  * you this software, covering your right to use that party's intellectual
20*7851SDana.Myers@Sun.COM  * property rights.
21*7851SDana.Myers@Sun.COM  *
22*7851SDana.Myers@Sun.COM  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23*7851SDana.Myers@Sun.COM  * copy of the source code appearing in this file ("Covered Code") an
24*7851SDana.Myers@Sun.COM  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25*7851SDana.Myers@Sun.COM  * base code distributed originally by Intel ("Original Intel Code") to copy,
26*7851SDana.Myers@Sun.COM  * make derivatives, distribute, use and display any portion of the Covered
27*7851SDana.Myers@Sun.COM  * Code in any form, with the right to sublicense such rights; and
28*7851SDana.Myers@Sun.COM  *
29*7851SDana.Myers@Sun.COM  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30*7851SDana.Myers@Sun.COM  * license (with the right to sublicense), under only those claims of Intel
31*7851SDana.Myers@Sun.COM  * patents that are infringed by the Original Intel Code, to make, use, sell,
32*7851SDana.Myers@Sun.COM  * offer to sell, and import the Covered Code and derivative works thereof
33*7851SDana.Myers@Sun.COM  * solely to the minimum extent necessary to exercise the above copyright
34*7851SDana.Myers@Sun.COM  * license, and in no event shall the patent license extend to any additions
35*7851SDana.Myers@Sun.COM  * to or modifications of the Original Intel Code.  No other license or right
36*7851SDana.Myers@Sun.COM  * is granted directly or by implication, estoppel or otherwise;
37*7851SDana.Myers@Sun.COM  *
38*7851SDana.Myers@Sun.COM  * The above copyright and patent license is granted only if the following
39*7851SDana.Myers@Sun.COM  * conditions are met:
40*7851SDana.Myers@Sun.COM  *
41*7851SDana.Myers@Sun.COM  * 3. Conditions
42*7851SDana.Myers@Sun.COM  *
43*7851SDana.Myers@Sun.COM  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44*7851SDana.Myers@Sun.COM  * Redistribution of source code of any substantial portion of the Covered
45*7851SDana.Myers@Sun.COM  * Code or modification with rights to further distribute source must include
46*7851SDana.Myers@Sun.COM  * the above Copyright Notice, the above License, this list of Conditions,
47*7851SDana.Myers@Sun.COM  * and the following Disclaimer and Export Compliance provision.  In addition,
48*7851SDana.Myers@Sun.COM  * Licensee must cause all Covered Code to which Licensee contributes to
49*7851SDana.Myers@Sun.COM  * contain a file documenting the changes Licensee made to create that Covered
50*7851SDana.Myers@Sun.COM  * Code and the date of any change.  Licensee must include in that file the
51*7851SDana.Myers@Sun.COM  * documentation of any changes made by any predecessor Licensee.  Licensee
52*7851SDana.Myers@Sun.COM  * must include a prominent statement that the modification is derived,
53*7851SDana.Myers@Sun.COM  * directly or indirectly, from Original Intel Code.
54*7851SDana.Myers@Sun.COM  *
55*7851SDana.Myers@Sun.COM  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56*7851SDana.Myers@Sun.COM  * Redistribution of source code of any substantial portion of the Covered
57*7851SDana.Myers@Sun.COM  * Code or modification without rights to further distribute source must
58*7851SDana.Myers@Sun.COM  * include the following Disclaimer and Export Compliance provision in the
59*7851SDana.Myers@Sun.COM  * documentation and/or other materials provided with distribution.  In
60*7851SDana.Myers@Sun.COM  * addition, Licensee may not authorize further sublicense of source of any
61*7851SDana.Myers@Sun.COM  * portion of the Covered Code, and must include terms to the effect that the
62*7851SDana.Myers@Sun.COM  * license from Licensee to its licensee is limited to the intellectual
63*7851SDana.Myers@Sun.COM  * property embodied in the software Licensee provides to its licensee, and
64*7851SDana.Myers@Sun.COM  * not to intellectual property embodied in modifications its licensee may
65*7851SDana.Myers@Sun.COM  * make.
66*7851SDana.Myers@Sun.COM  *
67*7851SDana.Myers@Sun.COM  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68*7851SDana.Myers@Sun.COM  * substantial portion of the Covered Code or modification must reproduce the
69*7851SDana.Myers@Sun.COM  * above Copyright Notice, and the following Disclaimer and Export Compliance
70*7851SDana.Myers@Sun.COM  * provision in the documentation and/or other materials provided with the
71*7851SDana.Myers@Sun.COM  * distribution.
72*7851SDana.Myers@Sun.COM  *
73*7851SDana.Myers@Sun.COM  * 3.4. Intel retains all right, title, and interest in and to the Original
74*7851SDana.Myers@Sun.COM  * Intel Code.
75*7851SDana.Myers@Sun.COM  *
76*7851SDana.Myers@Sun.COM  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77*7851SDana.Myers@Sun.COM  * Intel shall be used in advertising or otherwise to promote the sale, use or
78*7851SDana.Myers@Sun.COM  * other dealings in products derived from or relating to the Covered Code
79*7851SDana.Myers@Sun.COM  * without prior written authorization from Intel.
80*7851SDana.Myers@Sun.COM  *
81*7851SDana.Myers@Sun.COM  * 4. Disclaimer and Export Compliance
82*7851SDana.Myers@Sun.COM  *
83*7851SDana.Myers@Sun.COM  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84*7851SDana.Myers@Sun.COM  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85*7851SDana.Myers@Sun.COM  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86*7851SDana.Myers@Sun.COM  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87*7851SDana.Myers@Sun.COM  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88*7851SDana.Myers@Sun.COM  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89*7851SDana.Myers@Sun.COM  * PARTICULAR PURPOSE.
90*7851SDana.Myers@Sun.COM  *
91*7851SDana.Myers@Sun.COM  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92*7851SDana.Myers@Sun.COM  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93*7851SDana.Myers@Sun.COM  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94*7851SDana.Myers@Sun.COM  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95*7851SDana.Myers@Sun.COM  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96*7851SDana.Myers@Sun.COM  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97*7851SDana.Myers@Sun.COM  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98*7851SDana.Myers@Sun.COM  * LIMITED REMEDY.
99*7851SDana.Myers@Sun.COM  *
100*7851SDana.Myers@Sun.COM  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101*7851SDana.Myers@Sun.COM  * software or system incorporating such software without first obtaining any
102*7851SDana.Myers@Sun.COM  * required license or other approval from the U. S. Department of Commerce or
103*7851SDana.Myers@Sun.COM  * any other agency or department of the United States Government.  In the
104*7851SDana.Myers@Sun.COM  * event Licensee exports any such software from the United States or
105*7851SDana.Myers@Sun.COM  * re-exports any such software from a foreign destination, Licensee shall
106*7851SDana.Myers@Sun.COM  * ensure that the distribution and export/re-export of the software is in
107*7851SDana.Myers@Sun.COM  * compliance with all laws, regulations, orders, or other restrictions of the
108*7851SDana.Myers@Sun.COM  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109*7851SDana.Myers@Sun.COM  * any of its subsidiaries will export/re-export any technical data, process,
110*7851SDana.Myers@Sun.COM  * software, or service, directly or indirectly, to any country for which the
111*7851SDana.Myers@Sun.COM  * United States government or any agency thereof requires an export license,
112*7851SDana.Myers@Sun.COM  * other governmental approval, or letter of assurance, without first obtaining
113*7851SDana.Myers@Sun.COM  * such license, approval or letter.
114*7851SDana.Myers@Sun.COM  *
115*7851SDana.Myers@Sun.COM  *****************************************************************************/
116*7851SDana.Myers@Sun.COM 
117*7851SDana.Myers@Sun.COM 
118*7851SDana.Myers@Sun.COM #include "acpi.h"
119*7851SDana.Myers@Sun.COM #include "acparser.h"
120*7851SDana.Myers@Sun.COM 
121*7851SDana.Myers@Sun.COM #define _COMPONENT          ACPI_PARSER
122*7851SDana.Myers@Sun.COM         ACPI_MODULE_NAME    ("psscope")
123*7851SDana.Myers@Sun.COM 
124*7851SDana.Myers@Sun.COM 
125*7851SDana.Myers@Sun.COM /*******************************************************************************
126*7851SDana.Myers@Sun.COM  *
127*7851SDana.Myers@Sun.COM  * FUNCTION:    AcpiPsGetParentScope
128*7851SDana.Myers@Sun.COM  *
129*7851SDana.Myers@Sun.COM  * PARAMETERS:  ParserState         - Current parser state object
130*7851SDana.Myers@Sun.COM  *
131*7851SDana.Myers@Sun.COM  * RETURN:      Pointer to an Op object
132*7851SDana.Myers@Sun.COM  *
133*7851SDana.Myers@Sun.COM  * DESCRIPTION: Get parent of current op being parsed
134*7851SDana.Myers@Sun.COM  *
135*7851SDana.Myers@Sun.COM  ******************************************************************************/
136*7851SDana.Myers@Sun.COM 
137*7851SDana.Myers@Sun.COM ACPI_PARSE_OBJECT *
138*7851SDana.Myers@Sun.COM AcpiPsGetParentScope (
139*7851SDana.Myers@Sun.COM     ACPI_PARSE_STATE        *ParserState)
140*7851SDana.Myers@Sun.COM {
141*7851SDana.Myers@Sun.COM 
142*7851SDana.Myers@Sun.COM     return (ParserState->Scope->ParseScope.Op);
143*7851SDana.Myers@Sun.COM }
144*7851SDana.Myers@Sun.COM 
145*7851SDana.Myers@Sun.COM 
146*7851SDana.Myers@Sun.COM /*******************************************************************************
147*7851SDana.Myers@Sun.COM  *
148*7851SDana.Myers@Sun.COM  * FUNCTION:    AcpiPsHasCompletedScope
149*7851SDana.Myers@Sun.COM  *
150*7851SDana.Myers@Sun.COM  * PARAMETERS:  ParserState         - Current parser state object
151*7851SDana.Myers@Sun.COM  *
152*7851SDana.Myers@Sun.COM  * RETURN:      Boolean, TRUE = scope completed.
153*7851SDana.Myers@Sun.COM  *
154*7851SDana.Myers@Sun.COM  * DESCRIPTION: Is parsing of current argument complete?  Determined by
155*7851SDana.Myers@Sun.COM  *              1) AML pointer is at or beyond the end of the scope
156*7851SDana.Myers@Sun.COM  *              2) The scope argument count has reached zero.
157*7851SDana.Myers@Sun.COM  *
158*7851SDana.Myers@Sun.COM  ******************************************************************************/
159*7851SDana.Myers@Sun.COM 
160*7851SDana.Myers@Sun.COM BOOLEAN
161*7851SDana.Myers@Sun.COM AcpiPsHasCompletedScope (
162*7851SDana.Myers@Sun.COM     ACPI_PARSE_STATE        *ParserState)
163*7851SDana.Myers@Sun.COM {
164*7851SDana.Myers@Sun.COM 
165*7851SDana.Myers@Sun.COM     return ((BOOLEAN)
166*7851SDana.Myers@Sun.COM             ((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd ||
167*7851SDana.Myers@Sun.COM              !ParserState->Scope->ParseScope.ArgCount)));
168*7851SDana.Myers@Sun.COM }
169*7851SDana.Myers@Sun.COM 
170*7851SDana.Myers@Sun.COM 
171*7851SDana.Myers@Sun.COM /*******************************************************************************
172*7851SDana.Myers@Sun.COM  *
173*7851SDana.Myers@Sun.COM  * FUNCTION:    AcpiPsInitScope
174*7851SDana.Myers@Sun.COM  *
175*7851SDana.Myers@Sun.COM  * PARAMETERS:  ParserState         - Current parser state object
176*7851SDana.Myers@Sun.COM  *              Root                - the Root Node of this new scope
177*7851SDana.Myers@Sun.COM  *
178*7851SDana.Myers@Sun.COM  * RETURN:      Status
179*7851SDana.Myers@Sun.COM  *
180*7851SDana.Myers@Sun.COM  * DESCRIPTION: Allocate and init a new scope object
181*7851SDana.Myers@Sun.COM  *
182*7851SDana.Myers@Sun.COM  ******************************************************************************/
183*7851SDana.Myers@Sun.COM 
184*7851SDana.Myers@Sun.COM ACPI_STATUS
185*7851SDana.Myers@Sun.COM AcpiPsInitScope (
186*7851SDana.Myers@Sun.COM     ACPI_PARSE_STATE        *ParserState,
187*7851SDana.Myers@Sun.COM     ACPI_PARSE_OBJECT       *RootOp)
188*7851SDana.Myers@Sun.COM {
189*7851SDana.Myers@Sun.COM     ACPI_GENERIC_STATE      *Scope;
190*7851SDana.Myers@Sun.COM 
191*7851SDana.Myers@Sun.COM 
192*7851SDana.Myers@Sun.COM     ACPI_FUNCTION_TRACE_PTR (PsInitScope, RootOp);
193*7851SDana.Myers@Sun.COM 
194*7851SDana.Myers@Sun.COM 
195*7851SDana.Myers@Sun.COM     Scope = AcpiUtCreateGenericState ();
196*7851SDana.Myers@Sun.COM     if (!Scope)
197*7851SDana.Myers@Sun.COM     {
198*7851SDana.Myers@Sun.COM         return_ACPI_STATUS (AE_NO_MEMORY);
199*7851SDana.Myers@Sun.COM     }
200*7851SDana.Myers@Sun.COM 
201*7851SDana.Myers@Sun.COM     Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RPSCOPE;
202*7851SDana.Myers@Sun.COM     Scope->ParseScope.Op = RootOp;
203*7851SDana.Myers@Sun.COM     Scope->ParseScope.ArgCount = ACPI_VAR_ARGS;
204*7851SDana.Myers@Sun.COM     Scope->ParseScope.ArgEnd = ParserState->AmlEnd;
205*7851SDana.Myers@Sun.COM     Scope->ParseScope.PkgEnd = ParserState->AmlEnd;
206*7851SDana.Myers@Sun.COM 
207*7851SDana.Myers@Sun.COM     ParserState->Scope = Scope;
208*7851SDana.Myers@Sun.COM     ParserState->StartOp = RootOp;
209*7851SDana.Myers@Sun.COM 
210*7851SDana.Myers@Sun.COM     return_ACPI_STATUS (AE_OK);
211*7851SDana.Myers@Sun.COM }
212*7851SDana.Myers@Sun.COM 
213*7851SDana.Myers@Sun.COM 
214*7851SDana.Myers@Sun.COM /*******************************************************************************
215*7851SDana.Myers@Sun.COM  *
216*7851SDana.Myers@Sun.COM  * FUNCTION:    AcpiPsPushScope
217*7851SDana.Myers@Sun.COM  *
218*7851SDana.Myers@Sun.COM  * PARAMETERS:  ParserState         - Current parser state object
219*7851SDana.Myers@Sun.COM  *              Op                  - Current op to be pushed
220*7851SDana.Myers@Sun.COM  *              RemainingArgs       - List of args remaining
221*7851SDana.Myers@Sun.COM  *              ArgCount            - Fixed or variable number of args
222*7851SDana.Myers@Sun.COM  *
223*7851SDana.Myers@Sun.COM  * RETURN:      Status
224*7851SDana.Myers@Sun.COM  *
225*7851SDana.Myers@Sun.COM  * DESCRIPTION: Push current op to begin parsing its argument
226*7851SDana.Myers@Sun.COM  *
227*7851SDana.Myers@Sun.COM  ******************************************************************************/
228*7851SDana.Myers@Sun.COM 
229*7851SDana.Myers@Sun.COM ACPI_STATUS
230*7851SDana.Myers@Sun.COM AcpiPsPushScope (
231*7851SDana.Myers@Sun.COM     ACPI_PARSE_STATE        *ParserState,
232*7851SDana.Myers@Sun.COM     ACPI_PARSE_OBJECT       *Op,
233*7851SDana.Myers@Sun.COM     UINT32                  RemainingArgs,
234*7851SDana.Myers@Sun.COM     UINT32                  ArgCount)
235*7851SDana.Myers@Sun.COM {
236*7851SDana.Myers@Sun.COM     ACPI_GENERIC_STATE      *Scope;
237*7851SDana.Myers@Sun.COM 
238*7851SDana.Myers@Sun.COM 
239*7851SDana.Myers@Sun.COM     ACPI_FUNCTION_TRACE_PTR (PsPushScope, Op);
240*7851SDana.Myers@Sun.COM 
241*7851SDana.Myers@Sun.COM 
242*7851SDana.Myers@Sun.COM     Scope = AcpiUtCreateGenericState ();
243*7851SDana.Myers@Sun.COM     if (!Scope)
244*7851SDana.Myers@Sun.COM     {
245*7851SDana.Myers@Sun.COM         return_ACPI_STATUS (AE_NO_MEMORY);
246*7851SDana.Myers@Sun.COM     }
247*7851SDana.Myers@Sun.COM 
248*7851SDana.Myers@Sun.COM     Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PSCOPE;
249*7851SDana.Myers@Sun.COM     Scope->ParseScope.Op = Op;
250*7851SDana.Myers@Sun.COM     Scope->ParseScope.ArgList = RemainingArgs;
251*7851SDana.Myers@Sun.COM     Scope->ParseScope.ArgCount = ArgCount;
252*7851SDana.Myers@Sun.COM     Scope->ParseScope.PkgEnd = ParserState->PkgEnd;
253*7851SDana.Myers@Sun.COM 
254*7851SDana.Myers@Sun.COM     /* Push onto scope stack */
255*7851SDana.Myers@Sun.COM 
256*7851SDana.Myers@Sun.COM     AcpiUtPushGenericState (&ParserState->Scope, Scope);
257*7851SDana.Myers@Sun.COM 
258*7851SDana.Myers@Sun.COM     if (ArgCount == ACPI_VAR_ARGS)
259*7851SDana.Myers@Sun.COM     {
260*7851SDana.Myers@Sun.COM         /* Multiple arguments */
261*7851SDana.Myers@Sun.COM 
262*7851SDana.Myers@Sun.COM         Scope->ParseScope.ArgEnd = ParserState->PkgEnd;
263*7851SDana.Myers@Sun.COM     }
264*7851SDana.Myers@Sun.COM     else
265*7851SDana.Myers@Sun.COM     {
266*7851SDana.Myers@Sun.COM         /* Single argument */
267*7851SDana.Myers@Sun.COM 
268*7851SDana.Myers@Sun.COM         Scope->ParseScope.ArgEnd = ACPI_TO_POINTER (ACPI_MAX_PTR);
269*7851SDana.Myers@Sun.COM     }
270*7851SDana.Myers@Sun.COM 
271*7851SDana.Myers@Sun.COM     return_ACPI_STATUS (AE_OK);
272*7851SDana.Myers@Sun.COM }
273*7851SDana.Myers@Sun.COM 
274*7851SDana.Myers@Sun.COM 
275*7851SDana.Myers@Sun.COM /*******************************************************************************
276*7851SDana.Myers@Sun.COM  *
277*7851SDana.Myers@Sun.COM  * FUNCTION:    AcpiPsPopScope
278*7851SDana.Myers@Sun.COM  *
279*7851SDana.Myers@Sun.COM  * PARAMETERS:  ParserState         - Current parser state object
280*7851SDana.Myers@Sun.COM  *              Op                  - Where the popped op is returned
281*7851SDana.Myers@Sun.COM  *              ArgList             - Where the popped "next argument" is
282*7851SDana.Myers@Sun.COM  *                                    returned
283*7851SDana.Myers@Sun.COM  *              ArgCount            - Count of objects in ArgList
284*7851SDana.Myers@Sun.COM  *
285*7851SDana.Myers@Sun.COM  * RETURN:      Status
286*7851SDana.Myers@Sun.COM  *
287*7851SDana.Myers@Sun.COM  * DESCRIPTION: Return to parsing a previous op
288*7851SDana.Myers@Sun.COM  *
289*7851SDana.Myers@Sun.COM  ******************************************************************************/
290*7851SDana.Myers@Sun.COM 
291*7851SDana.Myers@Sun.COM void
292*7851SDana.Myers@Sun.COM AcpiPsPopScope (
293*7851SDana.Myers@Sun.COM     ACPI_PARSE_STATE        *ParserState,
294*7851SDana.Myers@Sun.COM     ACPI_PARSE_OBJECT       **Op,
295*7851SDana.Myers@Sun.COM     UINT32                  *ArgList,
296*7851SDana.Myers@Sun.COM     UINT32                  *ArgCount)
297*7851SDana.Myers@Sun.COM {
298*7851SDana.Myers@Sun.COM     ACPI_GENERIC_STATE      *Scope = ParserState->Scope;
299*7851SDana.Myers@Sun.COM 
300*7851SDana.Myers@Sun.COM 
301*7851SDana.Myers@Sun.COM     ACPI_FUNCTION_TRACE (PsPopScope);
302*7851SDana.Myers@Sun.COM 
303*7851SDana.Myers@Sun.COM 
304*7851SDana.Myers@Sun.COM     /* Only pop the scope if there is in fact a next scope */
305*7851SDana.Myers@Sun.COM 
306*7851SDana.Myers@Sun.COM     if (Scope->Common.Next)
307*7851SDana.Myers@Sun.COM     {
308*7851SDana.Myers@Sun.COM         Scope = AcpiUtPopGenericState (&ParserState->Scope);
309*7851SDana.Myers@Sun.COM 
310*7851SDana.Myers@Sun.COM         /* Return to parsing previous op */
311*7851SDana.Myers@Sun.COM 
312*7851SDana.Myers@Sun.COM         *Op                 = Scope->ParseScope.Op;
313*7851SDana.Myers@Sun.COM         *ArgList            = Scope->ParseScope.ArgList;
314*7851SDana.Myers@Sun.COM         *ArgCount           = Scope->ParseScope.ArgCount;
315*7851SDana.Myers@Sun.COM         ParserState->PkgEnd = Scope->ParseScope.PkgEnd;
316*7851SDana.Myers@Sun.COM 
317*7851SDana.Myers@Sun.COM         /* All done with this scope state structure */
318*7851SDana.Myers@Sun.COM 
319*7851SDana.Myers@Sun.COM         AcpiUtDeleteGenericState (Scope);
320*7851SDana.Myers@Sun.COM     }
321*7851SDana.Myers@Sun.COM     else
322*7851SDana.Myers@Sun.COM     {
323*7851SDana.Myers@Sun.COM         /* Empty parse stack, prepare to fetch next opcode */
324*7851SDana.Myers@Sun.COM 
325*7851SDana.Myers@Sun.COM         *Op       = NULL;
326*7851SDana.Myers@Sun.COM         *ArgList  = 0;
327*7851SDana.Myers@Sun.COM         *ArgCount = 0;
328*7851SDana.Myers@Sun.COM     }
329*7851SDana.Myers@Sun.COM 
330*7851SDana.Myers@Sun.COM     ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
331*7851SDana.Myers@Sun.COM         "Popped Op %p Args %X\n", *Op, *ArgCount));
332*7851SDana.Myers@Sun.COM     return_VOID;
333*7851SDana.Myers@Sun.COM }
334*7851SDana.Myers@Sun.COM 
335*7851SDana.Myers@Sun.COM 
336*7851SDana.Myers@Sun.COM /*******************************************************************************
337*7851SDana.Myers@Sun.COM  *
338*7851SDana.Myers@Sun.COM  * FUNCTION:    AcpiPsCleanupScope
339*7851SDana.Myers@Sun.COM  *
340*7851SDana.Myers@Sun.COM  * PARAMETERS:  ParserState         - Current parser state object
341*7851SDana.Myers@Sun.COM  *
342*7851SDana.Myers@Sun.COM  * RETURN:      None
343*7851SDana.Myers@Sun.COM  *
344*7851SDana.Myers@Sun.COM  * DESCRIPTION: Destroy available list, remaining stack levels, and return
345*7851SDana.Myers@Sun.COM  *              root scope
346*7851SDana.Myers@Sun.COM  *
347*7851SDana.Myers@Sun.COM  ******************************************************************************/
348*7851SDana.Myers@Sun.COM 
349*7851SDana.Myers@Sun.COM void
350*7851SDana.Myers@Sun.COM AcpiPsCleanupScope (
351*7851SDana.Myers@Sun.COM     ACPI_PARSE_STATE        *ParserState)
352*7851SDana.Myers@Sun.COM {
353*7851SDana.Myers@Sun.COM     ACPI_GENERIC_STATE      *Scope;
354*7851SDana.Myers@Sun.COM 
355*7851SDana.Myers@Sun.COM 
356*7851SDana.Myers@Sun.COM     ACPI_FUNCTION_TRACE_PTR (PsCleanupScope, ParserState);
357*7851SDana.Myers@Sun.COM 
358*7851SDana.Myers@Sun.COM 
359*7851SDana.Myers@Sun.COM     if (!ParserState)
360*7851SDana.Myers@Sun.COM     {
361*7851SDana.Myers@Sun.COM         return_VOID;
362*7851SDana.Myers@Sun.COM     }
363*7851SDana.Myers@Sun.COM 
364*7851SDana.Myers@Sun.COM     /* Delete anything on the scope stack */
365*7851SDana.Myers@Sun.COM 
366*7851SDana.Myers@Sun.COM     while (ParserState->Scope)
367*7851SDana.Myers@Sun.COM     {
368*7851SDana.Myers@Sun.COM         Scope = AcpiUtPopGenericState (&ParserState->Scope);
369*7851SDana.Myers@Sun.COM         AcpiUtDeleteGenericState (Scope);
370*7851SDana.Myers@Sun.COM     }
371*7851SDana.Myers@Sun.COM 
372*7851SDana.Myers@Sun.COM     return_VOID;
373*7851SDana.Myers@Sun.COM }
374*7851SDana.Myers@Sun.COM 
375