Subversion Repositories Kolibri OS

Rev

Rev 1498 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1498 Rev 2216
1
/******************************************************************************
1
/******************************************************************************
2
 *
2
 *
3
 * Module Name: psparse - Parser top level AML parse routines
3
 * Module Name: psparse - Parser top level AML parse routines
4
 *
4
 *
5
 *****************************************************************************/
5
 *****************************************************************************/
6
 
6
 
7
/******************************************************************************
7
/******************************************************************************
8
 *
8
 *
9
 * 1. Copyright Notice
9
 * 1. Copyright Notice
10
 *
10
 *
11
 * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
11
 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
12
 * All rights reserved.
12
 * All rights reserved.
13
 *
13
 *
14
 * 2. License
14
 * 2. License
15
 *
15
 *
16
 * 2.1. This is your license from Intel Corp. under its intellectual property
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
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
18
 * you this software, covering your right to use that party's intellectual
19
 * property rights.
19
 * property rights.
20
 *
20
 *
21
 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
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
22
 * copy of the source code appearing in this file ("Covered Code") an
23
 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
23
 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24
 * base code distributed originally by Intel ("Original Intel Code") to copy,
24
 * base code distributed originally by Intel ("Original Intel Code") to copy,
25
 * make derivatives, distribute, use and display any portion of the Covered
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
26
 * Code in any form, with the right to sublicense such rights; and
27
 *
27
 *
28
 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
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
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,
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
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
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
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
34
 * to or modifications of the Original Intel Code.  No other license or right
35
 * is granted directly or by implication, estoppel or otherwise;
35
 * is granted directly or by implication, estoppel or otherwise;
36
 *
36
 *
37
 * The above copyright and patent license is granted only if the following
37
 * The above copyright and patent license is granted only if the following
38
 * conditions are met:
38
 * conditions are met:
39
 *
39
 *
40
 * 3. Conditions
40
 * 3. Conditions
41
 *
41
 *
42
 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
42
 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43
 * Redistribution of source code of any substantial portion of the Covered
43
 * Redistribution of source code of any substantial portion of the Covered
44
 * Code or modification with rights to further distribute source must include
44
 * Code or modification with rights to further distribute source must include
45
 * the above Copyright Notice, the above License, this list of Conditions,
45
 * the above Copyright Notice, the above License, this list of Conditions,
46
 * and the following Disclaimer and Export Compliance provision.  In addition,
46
 * and the following Disclaimer and Export Compliance provision.  In addition,
47
 * Licensee must cause all Covered Code to which Licensee contributes to
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
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
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
50
 * documentation of any changes made by any predecessor Licensee.  Licensee
51
 * must include a prominent statement that the modification is derived,
51
 * must include a prominent statement that the modification is derived,
52
 * directly or indirectly, from Original Intel Code.
52
 * directly or indirectly, from Original Intel Code.
53
 *
53
 *
54
 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
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
55
 * Redistribution of source code of any substantial portion of the Covered
56
 * Code or modification without rights to further distribute source must
56
 * Code or modification without rights to further distribute source must
57
 * include the following Disclaimer and Export Compliance provision in the
57
 * include the following Disclaimer and Export Compliance provision in the
58
 * documentation and/or other materials provided with distribution.  In
58
 * documentation and/or other materials provided with distribution.  In
59
 * addition, Licensee may not authorize further sublicense of source of any
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
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
61
 * license from Licensee to its licensee is limited to the intellectual
62
 * property embodied in the software Licensee provides to its licensee, and
62
 * property embodied in the software Licensee provides to its licensee, and
63
 * not to intellectual property embodied in modifications its licensee may
63
 * not to intellectual property embodied in modifications its licensee may
64
 * make.
64
 * make.
65
 *
65
 *
66
 * 3.3. Redistribution of Executable. Redistribution in executable form of any
66
 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67
 * substantial portion of the Covered Code or modification must reproduce the
67
 * substantial portion of the Covered Code or modification must reproduce the
68
 * above Copyright Notice, and the following Disclaimer and Export Compliance
68
 * above Copyright Notice, and the following Disclaimer and Export Compliance
69
 * provision in the documentation and/or other materials provided with the
69
 * provision in the documentation and/or other materials provided with the
70
 * distribution.
70
 * distribution.
71
 *
71
 *
72
 * 3.4. Intel retains all right, title, and interest in and to the Original
72
 * 3.4. Intel retains all right, title, and interest in and to the Original
73
 * Intel Code.
73
 * Intel Code.
74
 *
74
 *
75
 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
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
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
77
 * other dealings in products derived from or relating to the Covered Code
78
 * without prior written authorization from Intel.
78
 * without prior written authorization from Intel.
79
 *
79
 *
80
 * 4. Disclaimer and Export Compliance
80
 * 4. Disclaimer and Export Compliance
81
 *
81
 *
82
 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
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
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,
84
 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
85
 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
85
 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
86
 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
86
 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
87
 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
87
 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88
 * PARTICULAR PURPOSE.
88
 * PARTICULAR PURPOSE.
89
 *
89
 *
90
 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
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
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,
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
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
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
95
 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
96
 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
96
 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97
 * LIMITED REMEDY.
97
 * LIMITED REMEDY.
98
 *
98
 *
99
 * 4.3. Licensee shall not export, either directly or indirectly, any of this
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
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
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
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
103
 * event Licensee exports any such software from the United States or
104
 * re-exports any such software from a foreign destination, Licensee shall
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
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
106
 * compliance with all laws, regulations, orders, or other restrictions of the
107
 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
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,
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
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,
110
 * United States government or any agency thereof requires an export license,
111
 * other governmental approval, or letter of assurance, without first obtaining
111
 * other governmental approval, or letter of assurance, without first obtaining
112
 * such license, approval or letter.
112
 * such license, approval or letter.
113
 *
113
 *
114
 *****************************************************************************/
114
 *****************************************************************************/
115
 
115
 
116
 
116
 
117
/*
117
/*
118
 * Parse the AML and build an operation tree as most interpreters,
118
 * Parse the AML and build an operation tree as most interpreters,
119
 * like Perl, do.  Parsing is done by hand rather than with a YACC
119
 * like Perl, do.  Parsing is done by hand rather than with a YACC
120
 * generated parser to tightly constrain stack and dynamic memory
120
 * generated parser to tightly constrain stack and dynamic memory
121
 * usage.  At the same time, parsing is kept flexible and the code
121
 * usage.  At the same time, parsing is kept flexible and the code
122
 * fairly compact by parsing based on a list of AML opcode
122
 * fairly compact by parsing based on a list of AML opcode
123
 * templates in AmlOpInfo[]
123
 * templates in AmlOpInfo[]
124
 */
124
 */
125
 
125
 
126
#include "acpi.h"
126
#include "acpi.h"
127
#include "accommon.h"
127
#include "accommon.h"
128
#include "acparser.h"
128
#include "acparser.h"
129
#include "acdispat.h"
129
#include "acdispat.h"
130
#include "amlcode.h"
130
#include "amlcode.h"
131
#include "acnamesp.h"
-
 
132
#include "acinterp.h"
131
#include "acinterp.h"
133
 
132
 
134
#define _COMPONENT          ACPI_PARSER
133
#define _COMPONENT          ACPI_PARSER
135
        ACPI_MODULE_NAME    ("psparse")
134
        ACPI_MODULE_NAME    ("psparse")
136
 
135
 
137
 
136
 
138
/*******************************************************************************
137
/*******************************************************************************
139
 *
138
 *
140
 * FUNCTION:    AcpiPsGetOpcodeSize
139
 * FUNCTION:    AcpiPsGetOpcodeSize
141
 *
140
 *
142
 * PARAMETERS:  Opcode          - An AML opcode
141
 * PARAMETERS:  Opcode          - An AML opcode
143
 *
142
 *
144
 * RETURN:      Size of the opcode, in bytes (1 or 2)
143
 * RETURN:      Size of the opcode, in bytes (1 or 2)
145
 *
144
 *
146
 * DESCRIPTION: Get the size of the current opcode.
145
 * DESCRIPTION: Get the size of the current opcode.
147
 *
146
 *
148
 ******************************************************************************/
147
 ******************************************************************************/
149
 
148
 
150
UINT32
149
UINT32
151
AcpiPsGetOpcodeSize (
150
AcpiPsGetOpcodeSize (
152
    UINT32                  Opcode)
151
    UINT32                  Opcode)
153
{
152
{
154
 
153
 
155
    /* Extended (2-byte) opcode if > 255 */
154
    /* Extended (2-byte) opcode if > 255 */
156
 
155
 
157
    if (Opcode > 0x00FF)
156
    if (Opcode > 0x00FF)
158
    {
157
    {
159
        return (2);
158
        return (2);
160
    }
159
    }
161
 
160
 
162
    /* Otherwise, just a single byte opcode */
161
    /* Otherwise, just a single byte opcode */
163
 
162
 
164
    return (1);
163
    return (1);
165
}
164
}
166
 
165
 
167
 
166
 
168
/*******************************************************************************
167
/*******************************************************************************
169
 *
168
 *
170
 * FUNCTION:    AcpiPsPeekOpcode
169
 * FUNCTION:    AcpiPsPeekOpcode
171
 *
170
 *
172
 * PARAMETERS:  ParserState         - A parser state object
171
 * PARAMETERS:  ParserState         - A parser state object
173
 *
172
 *
174
 * RETURN:      Next AML opcode
173
 * RETURN:      Next AML opcode
175
 *
174
 *
176
 * DESCRIPTION: Get next AML opcode (without incrementing AML pointer)
175
 * DESCRIPTION: Get next AML opcode (without incrementing AML pointer)
177
 *
176
 *
178
 ******************************************************************************/
177
 ******************************************************************************/
179
 
178
 
180
UINT16
179
UINT16
181
AcpiPsPeekOpcode (
180
AcpiPsPeekOpcode (
182
    ACPI_PARSE_STATE        *ParserState)
181
    ACPI_PARSE_STATE        *ParserState)
183
{
182
{
184
    UINT8                   *Aml;
183
    UINT8                   *Aml;
185
    UINT16                  Opcode;
184
    UINT16                  Opcode;
186
 
185
 
187
 
186
 
188
    Aml = ParserState->Aml;
187
    Aml = ParserState->Aml;
189
    Opcode = (UINT16) ACPI_GET8 (Aml);
188
    Opcode = (UINT16) ACPI_GET8 (Aml);
190
 
189
 
191
    if (Opcode == AML_EXTENDED_OP_PREFIX)
190
    if (Opcode == AML_EXTENDED_OP_PREFIX)
192
    {
191
    {
193
        /* Extended opcode, get the second opcode byte */
192
        /* Extended opcode, get the second opcode byte */
194
 
193
 
195
        Aml++;
194
        Aml++;
196
        Opcode = (UINT16) ((Opcode << 8) | ACPI_GET8 (Aml));
195
        Opcode = (UINT16) ((Opcode << 8) | ACPI_GET8 (Aml));
197
    }
196
    }
198
 
197
 
199
    return (Opcode);
198
    return (Opcode);
200
}
199
}
201
 
200
 
202
 
201
 
203
/*******************************************************************************
202
/*******************************************************************************
204
 *
203
 *
205
 * FUNCTION:    AcpiPsCompleteThisOp
204
 * FUNCTION:    AcpiPsCompleteThisOp
206
 *
205
 *
207
 * PARAMETERS:  WalkState       - Current State
206
 * PARAMETERS:  WalkState       - Current State
208
 *              Op              - Op to complete
207
 *              Op              - Op to complete
209
 *
208
 *
210
 * RETURN:      Status
209
 * RETURN:      Status
211
 *
210
 *
212
 * DESCRIPTION: Perform any cleanup at the completion of an Op.
211
 * DESCRIPTION: Perform any cleanup at the completion of an Op.
213
 *
212
 *
214
 ******************************************************************************/
213
 ******************************************************************************/
215
 
214
 
216
ACPI_STATUS
215
ACPI_STATUS
217
AcpiPsCompleteThisOp (
216
AcpiPsCompleteThisOp (
218
    ACPI_WALK_STATE         *WalkState,
217
    ACPI_WALK_STATE         *WalkState,
219
    ACPI_PARSE_OBJECT       *Op)
218
    ACPI_PARSE_OBJECT       *Op)
220
{
219
{
221
    ACPI_PARSE_OBJECT       *Prev;
220
    ACPI_PARSE_OBJECT       *Prev;
222
    ACPI_PARSE_OBJECT       *Next;
221
    ACPI_PARSE_OBJECT       *Next;
223
    const ACPI_OPCODE_INFO  *ParentInfo;
222
    const ACPI_OPCODE_INFO  *ParentInfo;
224
    ACPI_PARSE_OBJECT       *ReplacementOp = NULL;
223
    ACPI_PARSE_OBJECT       *ReplacementOp = NULL;
225
    ACPI_STATUS             Status = AE_OK;
224
    ACPI_STATUS             Status = AE_OK;
226
 
225
 
227
 
226
 
228
    ACPI_FUNCTION_TRACE_PTR (PsCompleteThisOp, Op);
227
    ACPI_FUNCTION_TRACE_PTR (PsCompleteThisOp, Op);
229
 
228
 
230
 
229
 
231
    /* Check for null Op, can happen if AML code is corrupt */
230
    /* Check for null Op, can happen if AML code is corrupt */
232
 
231
 
233
    if (!Op)
232
    if (!Op)
234
    {
233
    {
235
        return_ACPI_STATUS (AE_OK);  /* OK for now */
234
        return_ACPI_STATUS (AE_OK);  /* OK for now */
236
    }
235
    }
237
 
236
 
238
    /* Delete this op and the subtree below it if asked to */
237
    /* Delete this op and the subtree below it if asked to */
239
 
238
 
240
    if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) ||
239
    if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) ||
241
         (WalkState->OpInfo->Class == AML_CLASS_ARGUMENT))
240
         (WalkState->OpInfo->Class == AML_CLASS_ARGUMENT))
242
    {
241
    {
243
        return_ACPI_STATUS (AE_OK);
242
        return_ACPI_STATUS (AE_OK);
244
    }
243
    }
245
 
244
 
246
    /* Make sure that we only delete this subtree */
245
    /* Make sure that we only delete this subtree */
247
 
246
 
248
    if (Op->Common.Parent)
247
    if (Op->Common.Parent)
249
    {
248
    {
250
        Prev = Op->Common.Parent->Common.Value.Arg;
249
        Prev = Op->Common.Parent->Common.Value.Arg;
251
        if (!Prev)
250
        if (!Prev)
252
        {
251
        {
253
            /* Nothing more to do */
252
            /* Nothing more to do */
254
 
253
 
255
            goto Cleanup;
254
            goto Cleanup;
256
        }
255
        }
257
 
256
 
258
        /*
257
        /*
259
         * Check if we need to replace the operator and its subtree
258
         * Check if we need to replace the operator and its subtree
260
         * with a return value op (placeholder op)
259
         * with a return value op (placeholder op)
261
         */
260
         */
262
        ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode);
261
        ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode);
263
 
262
 
264
        switch (ParentInfo->Class)
263
        switch (ParentInfo->Class)
265
        {
264
        {
266
        case AML_CLASS_CONTROL:
265
        case AML_CLASS_CONTROL:
267
            break;
266
            break;
268
 
267
 
269
        case AML_CLASS_CREATE:
268
        case AML_CLASS_CREATE:
270
 
269
 
271
            /*
270
            /*
272
             * These opcodes contain TermArg operands.  The current
271
             * These opcodes contain TermArg operands.  The current
273
             * op must be replaced by a placeholder return op
272
             * op must be replaced by a placeholder return op
274
             */
273
             */
275
            ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
274
            ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
276
            if (!ReplacementOp)
275
            if (!ReplacementOp)
277
            {
276
            {
278
                Status = AE_NO_MEMORY;
277
                Status = AE_NO_MEMORY;
279
            }
278
            }
280
            break;
279
            break;
281
 
280
 
282
        case AML_CLASS_NAMED_OBJECT:
281
        case AML_CLASS_NAMED_OBJECT:
283
 
282
 
284
            /*
283
            /*
285
             * These opcodes contain TermArg operands.  The current
284
             * These opcodes contain TermArg operands.  The current
286
             * op must be replaced by a placeholder return op
285
             * op must be replaced by a placeholder return op
287
             */
286
             */
288
            if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP)       ||
287
            if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP)       ||
289
                (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP)  ||
288
                (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP)  ||
290
                (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP)       ||
289
                (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP)       ||
291
                (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP)      ||
290
                (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP)      ||
292
                (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP)   ||
291
                (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP)   ||
293
                (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
292
                (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
294
            {
293
            {
295
                ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
294
                ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
296
                if (!ReplacementOp)
295
                if (!ReplacementOp)
297
                {
296
                {
298
                    Status = AE_NO_MEMORY;
297
                    Status = AE_NO_MEMORY;
299
                }
298
                }
300
            }
299
            }
301
            else if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) &&
300
            else if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) &&
302
                     (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2))
301
                     (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2))
303
            {
302
            {
304
                if ((Op->Common.AmlOpcode == AML_BUFFER_OP) ||
303
                if ((Op->Common.AmlOpcode == AML_BUFFER_OP) ||
305
                    (Op->Common.AmlOpcode == AML_PACKAGE_OP) ||
304
                    (Op->Common.AmlOpcode == AML_PACKAGE_OP) ||
306
                    (Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
305
                    (Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
307
                {
306
                {
308
                    ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode);
307
                    ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode);
309
                    if (!ReplacementOp)
308
                    if (!ReplacementOp)
310
                    {
309
                    {
311
                        Status = AE_NO_MEMORY;
310
                        Status = AE_NO_MEMORY;
312
                    }
311
                    }
313
                    else
312
                    else
314
                    {
313
                    {
315
                        ReplacementOp->Named.Data = Op->Named.Data;
314
                        ReplacementOp->Named.Data = Op->Named.Data;
316
                        ReplacementOp->Named.Length = Op->Named.Length;
315
                        ReplacementOp->Named.Length = Op->Named.Length;
317
                    }
316
                    }
318
                }
317
                }
319
            }
318
            }
320
            break;
319
            break;
321
 
320
 
322
        default:
321
        default:
323
 
322
 
324
            ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
323
            ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
325
            if (!ReplacementOp)
324
            if (!ReplacementOp)
326
            {
325
            {
327
                Status = AE_NO_MEMORY;
326
                Status = AE_NO_MEMORY;
328
            }
327
            }
329
        }
328
        }
330
 
329
 
331
        /* We must unlink this op from the parent tree */
330
        /* We must unlink this op from the parent tree */
332
 
331
 
333
        if (Prev == Op)
332
        if (Prev == Op)
334
        {
333
        {
335
            /* This op is the first in the list */
334
            /* This op is the first in the list */
336
 
335
 
337
            if (ReplacementOp)
336
            if (ReplacementOp)
338
            {
337
            {
339
                ReplacementOp->Common.Parent        = Op->Common.Parent;
338
                ReplacementOp->Common.Parent        = Op->Common.Parent;
340
                ReplacementOp->Common.Value.Arg     = NULL;
339
                ReplacementOp->Common.Value.Arg     = NULL;
341
                ReplacementOp->Common.Node          = Op->Common.Node;
340
                ReplacementOp->Common.Node          = Op->Common.Node;
342
                Op->Common.Parent->Common.Value.Arg = ReplacementOp;
341
                Op->Common.Parent->Common.Value.Arg = ReplacementOp;
343
                ReplacementOp->Common.Next          = Op->Common.Next;
342
                ReplacementOp->Common.Next          = Op->Common.Next;
344
            }
343
            }
345
            else
344
            else
346
            {
345
            {
347
                Op->Common.Parent->Common.Value.Arg = Op->Common.Next;
346
                Op->Common.Parent->Common.Value.Arg = Op->Common.Next;
348
            }
347
            }
349
        }
348
        }
350
 
349
 
351
        /* Search the parent list */
350
        /* Search the parent list */
352
 
351
 
353
        else while (Prev)
352
        else while (Prev)
354
        {
353
        {
355
            /* Traverse all siblings in the parent's argument list */
354
            /* Traverse all siblings in the parent's argument list */
356
 
355
 
357
            Next = Prev->Common.Next;
356
            Next = Prev->Common.Next;
358
            if (Next == Op)
357
            if (Next == Op)
359
            {
358
            {
360
                if (ReplacementOp)
359
                if (ReplacementOp)
361
                {
360
                {
362
                    ReplacementOp->Common.Parent    = Op->Common.Parent;
361
                    ReplacementOp->Common.Parent    = Op->Common.Parent;
363
                    ReplacementOp->Common.Value.Arg = NULL;
362
                    ReplacementOp->Common.Value.Arg = NULL;
364
                    ReplacementOp->Common.Node      = Op->Common.Node;
363
                    ReplacementOp->Common.Node      = Op->Common.Node;
365
                    Prev->Common.Next               = ReplacementOp;
364
                    Prev->Common.Next               = ReplacementOp;
366
                    ReplacementOp->Common.Next      = Op->Common.Next;
365
                    ReplacementOp->Common.Next      = Op->Common.Next;
367
                    Next = NULL;
366
                    Next = NULL;
368
                }
367
                }
369
                else
368
                else
370
                {
369
                {
371
                    Prev->Common.Next = Op->Common.Next;
370
                    Prev->Common.Next = Op->Common.Next;
372
                    Next = NULL;
371
                    Next = NULL;
373
                }
372
                }
374
            }
373
            }
375
            Prev = Next;
374
            Prev = Next;
376
        }
375
        }
377
    }
376
    }
378
 
377
 
379
 
378
 
380
Cleanup:
379
Cleanup:
381
 
380
 
382
    /* Now we can actually delete the subtree rooted at Op */
381
    /* Now we can actually delete the subtree rooted at Op */
383
 
382
 
384
    AcpiPsDeleteParseTree (Op);
383
    AcpiPsDeleteParseTree (Op);
385
    return_ACPI_STATUS (Status);
384
    return_ACPI_STATUS (Status);
386
}
385
}
387
 
386
 
388
 
387
 
389
/*******************************************************************************
388
/*******************************************************************************
390
 *
389
 *
391
 * FUNCTION:    AcpiPsNextParseState
390
 * FUNCTION:    AcpiPsNextParseState
392
 *
391
 *
393
 * PARAMETERS:  WalkState           - Current state
392
 * PARAMETERS:  WalkState           - Current state
394
 *              Op                  - Current parse op
393
 *              Op                  - Current parse op
395
 *              CallbackStatus      - Status from previous operation
394
 *              CallbackStatus      - Status from previous operation
396
 *
395
 *
397
 * RETURN:      Status
396
 * RETURN:      Status
398
 *
397
 *
399
 * DESCRIPTION: Update the parser state based upon the return exception from
398
 * DESCRIPTION: Update the parser state based upon the return exception from
400
 *              the parser callback.
399
 *              the parser callback.
401
 *
400
 *
402
 ******************************************************************************/
401
 ******************************************************************************/
403
 
402
 
404
ACPI_STATUS
403
ACPI_STATUS
405
AcpiPsNextParseState (
404
AcpiPsNextParseState (
406
    ACPI_WALK_STATE         *WalkState,
405
    ACPI_WALK_STATE         *WalkState,
407
    ACPI_PARSE_OBJECT       *Op,
406
    ACPI_PARSE_OBJECT       *Op,
408
    ACPI_STATUS             CallbackStatus)
407
    ACPI_STATUS             CallbackStatus)
409
{
408
{
410
    ACPI_PARSE_STATE        *ParserState = &WalkState->ParserState;
409
    ACPI_PARSE_STATE        *ParserState = &WalkState->ParserState;
411
    ACPI_STATUS             Status = AE_CTRL_PENDING;
410
    ACPI_STATUS             Status = AE_CTRL_PENDING;
412
 
411
 
413
 
412
 
414
    ACPI_FUNCTION_TRACE_PTR (PsNextParseState, Op);
413
    ACPI_FUNCTION_TRACE_PTR (PsNextParseState, Op);
415
 
414
 
416
 
415
 
417
    switch (CallbackStatus)
416
    switch (CallbackStatus)
418
    {
417
    {
419
    case AE_CTRL_TERMINATE:
418
    case AE_CTRL_TERMINATE:
420
        /*
419
        /*
421
         * A control method was terminated via a RETURN statement.
420
         * A control method was terminated via a RETURN statement.
422
         * The walk of this method is complete.
421
         * The walk of this method is complete.
423
         */
422
         */
424
        ParserState->Aml = ParserState->AmlEnd;
423
        ParserState->Aml = ParserState->AmlEnd;
425
        Status = AE_CTRL_TERMINATE;
424
        Status = AE_CTRL_TERMINATE;
426
        break;
425
        break;
427
 
426
 
428
 
427
 
429
    case AE_CTRL_BREAK:
428
    case AE_CTRL_BREAK:
430
 
429
 
431
        ParserState->Aml = WalkState->AmlLastWhile;
430
        ParserState->Aml = WalkState->AmlLastWhile;
432
        WalkState->ControlState->Common.Value = FALSE;
431
        WalkState->ControlState->Common.Value = FALSE;
433
        Status = AE_CTRL_BREAK;
432
        Status = AE_CTRL_BREAK;
434
        break;
433
        break;
435
 
434
 
436
 
435
 
437
    case AE_CTRL_CONTINUE:
436
    case AE_CTRL_CONTINUE:
438
 
437
 
439
        ParserState->Aml = WalkState->AmlLastWhile;
438
        ParserState->Aml = WalkState->AmlLastWhile;
440
        Status = AE_CTRL_CONTINUE;
439
        Status = AE_CTRL_CONTINUE;
441
        break;
440
        break;
442
 
441
 
443
 
442
 
444
    case AE_CTRL_PENDING:
443
    case AE_CTRL_PENDING:
445
 
444
 
446
        ParserState->Aml = WalkState->AmlLastWhile;
445
        ParserState->Aml = WalkState->AmlLastWhile;
447
        break;
446
        break;
448
 
447
 
449
#if 0
448
#if 0
450
    case AE_CTRL_SKIP:
449
    case AE_CTRL_SKIP:
451
 
450
 
452
        ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
451
        ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
453
        Status = AE_OK;
452
        Status = AE_OK;
454
        break;
453
        break;
455
#endif
454
#endif
456
 
455
 
457
    case AE_CTRL_TRUE:
456
    case AE_CTRL_TRUE:
458
        /*
457
        /*
459
         * Predicate of an IF was true, and we are at the matching ELSE.
458
         * Predicate of an IF was true, and we are at the matching ELSE.
460
         * Just close out this package
459
         * Just close out this package
461
         */
460
         */
462
        ParserState->Aml = AcpiPsGetNextPackageEnd (ParserState);
461
        ParserState->Aml = AcpiPsGetNextPackageEnd (ParserState);
463
        Status = AE_CTRL_PENDING;
462
        Status = AE_CTRL_PENDING;
464
        break;
463
        break;
465
 
464
 
466
 
465
 
467
    case AE_CTRL_FALSE:
466
    case AE_CTRL_FALSE:
468
        /*
467
        /*
469
         * Either an IF/WHILE Predicate was false or we encountered a BREAK
468
         * Either an IF/WHILE Predicate was false or we encountered a BREAK
470
         * opcode.  In both cases, we do not execute the rest of the
469
         * opcode.  In both cases, we do not execute the rest of the
471
         * package;  We simply close out the parent (finishing the walk of
470
         * package;  We simply close out the parent (finishing the walk of
472
         * this branch of the tree) and continue execution at the parent
471
         * this branch of the tree) and continue execution at the parent
473
         * level.
472
         * level.
474
         */
473
         */
475
        ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
474
        ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
476
 
475
 
477
        /* In the case of a BREAK, just force a predicate (if any) to FALSE */
476
        /* In the case of a BREAK, just force a predicate (if any) to FALSE */
478
 
477
 
479
        WalkState->ControlState->Common.Value = FALSE;
478
        WalkState->ControlState->Common.Value = FALSE;
480
        Status = AE_CTRL_END;
479
        Status = AE_CTRL_END;
481
        break;
480
        break;
482
 
481
 
483
 
482
 
484
    case AE_CTRL_TRANSFER:
483
    case AE_CTRL_TRANSFER:
485
 
484
 
486
        /* A method call (invocation) -- transfer control */
485
        /* A method call (invocation) -- transfer control */
487
 
486
 
488
        Status = AE_CTRL_TRANSFER;
487
        Status = AE_CTRL_TRANSFER;
489
        WalkState->PrevOp = Op;
488
        WalkState->PrevOp = Op;
490
        WalkState->MethodCallOp = Op;
489
        WalkState->MethodCallOp = Op;
491
        WalkState->MethodCallNode = (Op->Common.Value.Arg)->Common.Node;
490
        WalkState->MethodCallNode = (Op->Common.Value.Arg)->Common.Node;
492
 
491
 
493
        /* Will return value (if any) be used by the caller? */
492
        /* Will return value (if any) be used by the caller? */
494
 
493
 
495
        WalkState->ReturnUsed = AcpiDsIsResultUsed (Op, WalkState);
494
        WalkState->ReturnUsed = AcpiDsIsResultUsed (Op, WalkState);
496
        break;
495
        break;
497
 
496
 
498
 
497
 
499
    default:
498
    default:
500
 
499
 
501
        Status = CallbackStatus;
500
        Status = CallbackStatus;
502
        if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL)
501
        if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL)
503
        {
502
        {
504
            Status = AE_OK;
503
            Status = AE_OK;
505
        }
504
        }
506
        break;
505
        break;
507
    }
506
    }
508
 
507
 
509
    return_ACPI_STATUS (Status);
508
    return_ACPI_STATUS (Status);
510
}
509
}
511
 
510
 
512
 
511
 
513
/*******************************************************************************
512
/*******************************************************************************
514
 *
513
 *
515
 * FUNCTION:    AcpiPsParseAml
514
 * FUNCTION:    AcpiPsParseAml
516
 *
515
 *
517
 * PARAMETERS:  WalkState       - Current state
516
 * PARAMETERS:  WalkState       - Current state
518
 *
517
 *
519
 *
518
 *
520
 * RETURN:      Status
519
 * RETURN:      Status
521
 *
520
 *
522
 * DESCRIPTION: Parse raw AML and return a tree of ops
521
 * DESCRIPTION: Parse raw AML and return a tree of ops
523
 *
522
 *
524
 ******************************************************************************/
523
 ******************************************************************************/
525
 
524
 
526
ACPI_STATUS
525
ACPI_STATUS
527
AcpiPsParseAml (
526
AcpiPsParseAml (
528
    ACPI_WALK_STATE         *WalkState)
527
    ACPI_WALK_STATE         *WalkState)
529
{
528
{
530
    ACPI_STATUS             Status;
529
    ACPI_STATUS             Status;
531
    ACPI_THREAD_STATE       *Thread;
530
    ACPI_THREAD_STATE       *Thread;
532
    ACPI_THREAD_STATE       *PrevWalkList = AcpiGbl_CurrentWalkList;
531
    ACPI_THREAD_STATE       *PrevWalkList = AcpiGbl_CurrentWalkList;
533
    ACPI_WALK_STATE         *PreviousWalkState;
532
    ACPI_WALK_STATE         *PreviousWalkState;
534
 
533
 
535
 
534
 
536
    ACPI_FUNCTION_TRACE (PsParseAml);
535
    ACPI_FUNCTION_TRACE (PsParseAml);
537
 
536
 
538
    ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
537
    ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
539
        "Entered with WalkState=%p Aml=%p size=%X\n",
538
        "Entered with WalkState=%p Aml=%p size=%X\n",
540
        WalkState, WalkState->ParserState.Aml,
539
        WalkState, WalkState->ParserState.Aml,
541
        WalkState->ParserState.AmlSize));
540
        WalkState->ParserState.AmlSize));
542
 
541
 
543
    if (!WalkState->ParserState.Aml)
542
    if (!WalkState->ParserState.Aml)
544
    {
543
    {
545
        return_ACPI_STATUS (AE_NULL_OBJECT);
544
        return_ACPI_STATUS (AE_NULL_OBJECT);
546
    }
545
    }
547
 
546
 
548
    /* Create and initialize a new thread state */
547
    /* Create and initialize a new thread state */
549
 
548
 
550
    Thread = AcpiUtCreateThreadState ();
549
    Thread = AcpiUtCreateThreadState ();
551
    if (!Thread)
550
    if (!Thread)
552
    {
551
    {
553
        if (WalkState->MethodDesc)
552
        if (WalkState->MethodDesc)
554
        {
553
        {
555
            /* Executing a control method - additional cleanup */
554
            /* Executing a control method - additional cleanup */
556
 
555
 
557
            AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
556
            AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
558
        }
557
        }
559
 
558
 
560
        AcpiDsDeleteWalkState (WalkState);
559
        AcpiDsDeleteWalkState (WalkState);
561
        return_ACPI_STATUS (AE_NO_MEMORY);
560
        return_ACPI_STATUS (AE_NO_MEMORY);
562
    }
561
    }
563
 
562
 
564
    WalkState->Thread = Thread;
563
    WalkState->Thread = Thread;
565
 
564
 
566
    /*
565
    /*
567
     * If executing a method, the starting SyncLevel is this method's
566
     * If executing a method, the starting SyncLevel is this method's
568
     * SyncLevel
567
     * SyncLevel
569
     */
568
     */
570
    if (WalkState->MethodDesc)
569
    if (WalkState->MethodDesc)
571
    {
570
    {
572
        WalkState->Thread->CurrentSyncLevel = WalkState->MethodDesc->Method.SyncLevel;
571
        WalkState->Thread->CurrentSyncLevel = WalkState->MethodDesc->Method.SyncLevel;
573
    }
572
    }
574
 
573
 
575
    AcpiDsPushWalkState (WalkState, Thread);
574
    AcpiDsPushWalkState (WalkState, Thread);
576
 
575
 
577
    /*
576
    /*
578
     * This global allows the AML debugger to get a handle to the currently
577
     * This global allows the AML debugger to get a handle to the currently
579
     * executing control method.
578
     * executing control method.
580
     */
579
     */
581
    AcpiGbl_CurrentWalkList = Thread;
580
    AcpiGbl_CurrentWalkList = Thread;
582
 
581
 
583
    /*
582
    /*
584
     * Execute the walk loop as long as there is a valid Walk State.  This
583
     * Execute the walk loop as long as there is a valid Walk State.  This
585
     * handles nested control method invocations without recursion.
584
     * handles nested control method invocations without recursion.
586
     */
585
     */
587
    ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", WalkState));
586
    ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", WalkState));
588
 
587
 
589
    Status = AE_OK;
588
    Status = AE_OK;
590
    while (WalkState)
589
    while (WalkState)
591
    {
590
    {
592
        if (ACPI_SUCCESS (Status))
591
        if (ACPI_SUCCESS (Status))
593
        {
592
        {
594
            /*
593
            /*
595
             * The ParseLoop executes AML until the method terminates
594
             * The ParseLoop executes AML until the method terminates
596
             * or calls another method.
595
             * or calls another method.
597
             */
596
             */
598
            Status = AcpiPsParseLoop (WalkState);
597
            Status = AcpiPsParseLoop (WalkState);
599
        }
598
        }
600
 
599
 
601
        ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
600
        ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
602
            "Completed one call to walk loop, %s State=%p\n",
601
            "Completed one call to walk loop, %s State=%p\n",
603
            AcpiFormatException (Status), WalkState));
602
            AcpiFormatException (Status), WalkState));
604
 
603
 
605
        if (Status == AE_CTRL_TRANSFER)
604
        if (Status == AE_CTRL_TRANSFER)
606
        {
605
        {
607
            /*
606
            /*
608
             * A method call was detected.
607
             * A method call was detected.
609
             * Transfer control to the called control method
608
             * Transfer control to the called control method
610
             */
609
             */
611
            Status = AcpiDsCallControlMethod (Thread, WalkState, NULL);
610
            Status = AcpiDsCallControlMethod (Thread, WalkState, NULL);
612
            if (ACPI_FAILURE (Status))
611
            if (ACPI_FAILURE (Status))
613
            {
612
            {
614
                Status = AcpiDsMethodError (Status, WalkState);
613
                Status = AcpiDsMethodError (Status, WalkState);
615
            }
614
            }
616
 
615
 
617
            /*
616
            /*
618
             * If the transfer to the new method method call worked, a new walk
617
             * If the transfer to the new method method call worked, a new walk
619
             * state was created -- get it
618
             * state was created -- get it
620
             */
619
             */
621
            WalkState = AcpiDsGetCurrentWalkState (Thread);
620
            WalkState = AcpiDsGetCurrentWalkState (Thread);
622
            continue;
621
            continue;
623
        }
622
        }
624
        else if (Status == AE_CTRL_TERMINATE)
623
        else if (Status == AE_CTRL_TERMINATE)
625
        {
624
        {
626
            Status = AE_OK;
625
            Status = AE_OK;
627
        }
626
        }
628
        else if ((Status != AE_OK) && (WalkState->MethodDesc))
627
        else if ((Status != AE_OK) && (WalkState->MethodDesc))
629
        {
628
        {
630
            /* Either the method parse or actual execution failed */
629
            /* Either the method parse or actual execution failed */
631
 
630
 
632
            ACPI_ERROR_METHOD ("Method parse/execution failed",
631
            ACPI_ERROR_METHOD ("Method parse/execution failed",
633
                WalkState->MethodNode, NULL, Status);
632
                WalkState->MethodNode, NULL, Status);
634
 
633
 
635
            /* Check for possible multi-thread reentrancy problem */
634
            /* Check for possible multi-thread reentrancy problem */
636
 
635
 
637
            if ((Status == AE_ALREADY_EXISTS) &&
636
            if ((Status == AE_ALREADY_EXISTS) &&
638
                (!WalkState->MethodDesc->Method.Mutex))
637
                (!(WalkState->MethodDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED)))
639
            {
638
            {
640
                ACPI_INFO ((AE_INFO,
-
 
641
                    "Marking method %4.4s as Serialized because of AE_ALREADY_EXISTS error",
-
 
642
                    WalkState->MethodNode->Name.Ascii));
-
 
643
 
-
 
644
                /*
639
                /*
645
                 * Method tried to create an object twice. The probable cause is
640
                 * Method is not serialized and tried to create an object
646
                 * that the method cannot handle reentrancy.
641
                 * twice. The probable cause is that the method cannot
647
                 *
-
 
648
                 * The method is marked NotSerialized, but it tried to create
-
 
649
                 * a named object, causing the second thread entrance to fail.
642
                 * handle reentrancy. Mark as "pending serialized" now, and
650
                 * Workaround this problem by marking the method permanently
643
                 * then mark "serialized" when the last thread exits.
651
                 * as Serialized.
-
 
652
                 */
644
                 */
653
                WalkState->MethodDesc->Method.MethodFlags |= AML_METHOD_SERIALIZED;
645
                WalkState->MethodDesc->Method.InfoFlags |=
654
                WalkState->MethodDesc->Method.SyncLevel = 0;
646
                    ACPI_METHOD_SERIALIZED_PENDING;
655
            }
647
            }
656
        }
648
        }
657
 
649
 
658
        /* We are done with this walk, move on to the parent if any */
650
        /* We are done with this walk, move on to the parent if any */
659
 
651
 
660
        WalkState = AcpiDsPopWalkState (Thread);
652
        WalkState = AcpiDsPopWalkState (Thread);
661
 
653
 
662
        /* Reset the current scope to the beginning of scope stack */
654
        /* Reset the current scope to the beginning of scope stack */
663
 
655
 
664
        AcpiDsScopeStackClear (WalkState);
656
        AcpiDsScopeStackClear (WalkState);
665
 
657
 
666
        /*
658
        /*
667
         * If we just returned from the execution of a control method or if we
659
         * If we just returned from the execution of a control method or if we
668
         * encountered an error during the method parse phase, there's lots of
660
         * encountered an error during the method parse phase, there's lots of
669
         * cleanup to do
661
         * cleanup to do
670
         */
662
         */
671
        if (((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) ||
663
        if (((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) ||
672
            (ACPI_FAILURE (Status)))
664
            (ACPI_FAILURE (Status)))
673
        {
665
        {
674
            AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
666
            AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
675
        }
667
        }
676
 
668
 
677
        /* Delete this walk state and all linked control states */
669
        /* Delete this walk state and all linked control states */
678
 
670
 
679
        AcpiPsCleanupScope (&WalkState->ParserState);
671
        AcpiPsCleanupScope (&WalkState->ParserState);
680
        PreviousWalkState = WalkState;
672
        PreviousWalkState = WalkState;
681
 
673
 
682
        ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
674
        ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
683
            "ReturnValue=%p, ImplicitValue=%p State=%p\n",
675
            "ReturnValue=%p, ImplicitValue=%p State=%p\n",
684
            WalkState->ReturnDesc, WalkState->ImplicitReturnObj, WalkState));
676
            WalkState->ReturnDesc, WalkState->ImplicitReturnObj, WalkState));
685
 
677
 
686
        /* Check if we have restarted a preempted walk */
678
        /* Check if we have restarted a preempted walk */
687
 
679
 
688
        WalkState = AcpiDsGetCurrentWalkState (Thread);
680
        WalkState = AcpiDsGetCurrentWalkState (Thread);
689
        if (WalkState)
681
        if (WalkState)
690
        {
682
        {
691
            if (ACPI_SUCCESS (Status))
683
            if (ACPI_SUCCESS (Status))
692
            {
684
            {
693
                /*
685
                /*
694
                 * There is another walk state, restart it.
686
                 * There is another walk state, restart it.
695
                 * If the method return value is not used by the parent,
687
                 * If the method return value is not used by the parent,
696
                 * The object is deleted
688
                 * The object is deleted
697
                 */
689
                 */
698
                if (!PreviousWalkState->ReturnDesc)
690
                if (!PreviousWalkState->ReturnDesc)
699
                {
691
                {
700
                    /*
692
                    /*
701
                     * In slack mode execution, if there is no return value
693
                     * In slack mode execution, if there is no return value
702
                     * we should implicitly return zero (0) as a default value.
694
                     * we should implicitly return zero (0) as a default value.
703
                     */
695
                     */
704
                    if (AcpiGbl_EnableInterpreterSlack &&
696
                    if (AcpiGbl_EnableInterpreterSlack &&
705
                        !PreviousWalkState->ImplicitReturnObj)
697
                        !PreviousWalkState->ImplicitReturnObj)
706
                    {
698
                    {
707
                        PreviousWalkState->ImplicitReturnObj =
699
                        PreviousWalkState->ImplicitReturnObj =
708
                            AcpiUtCreateIntegerObject ((UINT64) 0);
700
                            AcpiUtCreateIntegerObject ((UINT64) 0);
709
                        if (!PreviousWalkState->ImplicitReturnObj)
701
                        if (!PreviousWalkState->ImplicitReturnObj)
710
                        {
702
                        {
711
                            return_ACPI_STATUS (AE_NO_MEMORY);
703
                            return_ACPI_STATUS (AE_NO_MEMORY);
712
                        }
704
                        }
713
                    }
705
                    }
714
 
706
 
715
                    /* Restart the calling control method */
707
                    /* Restart the calling control method */
716
 
708
 
717
                    Status = AcpiDsRestartControlMethod (WalkState,
709
                    Status = AcpiDsRestartControlMethod (WalkState,
718
                                PreviousWalkState->ImplicitReturnObj);
710
                                PreviousWalkState->ImplicitReturnObj);
719
                }
711
                }
720
                else
712
                else
721
                {
713
                {
722
                    /*
714
                    /*
723
                     * We have a valid return value, delete any implicit
715
                     * We have a valid return value, delete any implicit
724
                     * return value.
716
                     * return value.
725
                     */
717
                     */
726
                    AcpiDsClearImplicitReturn (PreviousWalkState);
718
                    AcpiDsClearImplicitReturn (PreviousWalkState);
727
 
719
 
728
                    Status = AcpiDsRestartControlMethod (WalkState,
720
                    Status = AcpiDsRestartControlMethod (WalkState,
729
                                PreviousWalkState->ReturnDesc);
721
                                PreviousWalkState->ReturnDesc);
730
                }
722
                }
731
                if (ACPI_SUCCESS (Status))
723
                if (ACPI_SUCCESS (Status))
732
                {
724
                {
733
                    WalkState->WalkType |= ACPI_WALK_METHOD_RESTART;
725
                    WalkState->WalkType |= ACPI_WALK_METHOD_RESTART;
734
                }
726
                }
735
            }
727
            }
736
            else
728
            else
737
            {
729
            {
738
                /* On error, delete any return object or implicit return */
730
                /* On error, delete any return object or implicit return */
739
 
731
 
740
                AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
732
                AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
741
                AcpiDsClearImplicitReturn (PreviousWalkState);
733
                AcpiDsClearImplicitReturn (PreviousWalkState);
742
            }
734
            }
743
        }
735
        }
744
 
736
 
745
        /*
737
        /*
746
         * Just completed a 1st-level method, save the final internal return
738
         * Just completed a 1st-level method, save the final internal return
747
         * value (if any)
739
         * value (if any)
748
         */
740
         */
749
        else if (PreviousWalkState->CallerReturnDesc)
741
        else if (PreviousWalkState->CallerReturnDesc)
750
        {
742
        {
751
            if (PreviousWalkState->ImplicitReturnObj)
743
            if (PreviousWalkState->ImplicitReturnObj)
752
            {
744
            {
753
                *(PreviousWalkState->CallerReturnDesc) =
745
                *(PreviousWalkState->CallerReturnDesc) =
754
                    PreviousWalkState->ImplicitReturnObj;
746
                    PreviousWalkState->ImplicitReturnObj;
755
            }
747
            }
756
            else
748
            else
757
            {
749
            {
758
                 /* NULL if no return value */
750
                 /* NULL if no return value */
759
 
751
 
760
                *(PreviousWalkState->CallerReturnDesc) =
752
                *(PreviousWalkState->CallerReturnDesc) =
761
                    PreviousWalkState->ReturnDesc;
753
                    PreviousWalkState->ReturnDesc;
762
            }
754
            }
763
        }
755
        }
764
        else
756
        else
765
        {
757
        {
766
            if (PreviousWalkState->ReturnDesc)
758
            if (PreviousWalkState->ReturnDesc)
767
            {
759
            {
768
                /* Caller doesn't want it, must delete it */
760
                /* Caller doesn't want it, must delete it */
769
 
761
 
770
                AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
762
                AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
771
            }
763
            }
772
            if (PreviousWalkState->ImplicitReturnObj)
764
            if (PreviousWalkState->ImplicitReturnObj)
773
            {
765
            {
774
                /* Caller doesn't want it, must delete it */
766
                /* Caller doesn't want it, must delete it */
775
 
767
 
776
                AcpiUtRemoveReference (PreviousWalkState->ImplicitReturnObj);
768
                AcpiUtRemoveReference (PreviousWalkState->ImplicitReturnObj);
777
            }
769
            }
778
        }
770
        }
779
 
771
 
780
        AcpiDsDeleteWalkState (PreviousWalkState);
772
        AcpiDsDeleteWalkState (PreviousWalkState);
781
    }
773
    }
782
 
774
 
783
    /* Normal exit */
775
    /* Normal exit */
784
 
776
 
785
    AcpiExReleaseAllMutexes (Thread);
777
    AcpiExReleaseAllMutexes (Thread);
786
    AcpiUtDeleteGenericState (ACPI_CAST_PTR (ACPI_GENERIC_STATE, Thread));
778
    AcpiUtDeleteGenericState (ACPI_CAST_PTR (ACPI_GENERIC_STATE, Thread));
787
    AcpiGbl_CurrentWalkList = PrevWalkList;
779
    AcpiGbl_CurrentWalkList = PrevWalkList;
788
    return_ACPI_STATUS (Status);
780
    return_ACPI_STATUS (Status);
789
}
781
}