Deleted Added
full compact
dsopcode.c (117521) dsopcode.c (123315)
1/******************************************************************************
2 *
3 * Module Name: dsopcode - Dispatcher Op Region support and handling of
4 * "control" opcodes
1/******************************************************************************
2 *
3 * Module Name: dsopcode - Dispatcher Op Region support and handling of
4 * "control" opcodes
5 * $Revision: 87 $
5 * $Revision: 91 $
6 *
7 *****************************************************************************/
8
9/******************************************************************************
10 *
11 * 1. Copyright Notice
12 *
13 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
14 * All rights reserved.
15 *
16 * 2. License
17 *
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
21 * property rights.
22 *
23 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24 * copy of the source code appearing in this file ("Covered Code") an
25 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26 * base code distributed originally by Intel ("Original Intel Code") to copy,
27 * make derivatives, distribute, use and display any portion of the Covered
28 * Code in any form, with the right to sublicense such rights; and
29 *
30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31 * license (with the right to sublicense), under only those claims of Intel
32 * patents that are infringed by the Original Intel Code, to make, use, sell,
33 * offer to sell, and import the Covered Code and derivative works thereof
34 * solely to the minimum extent necessary to exercise the above copyright
35 * license, and in no event shall the patent license extend to any additions
36 * to or modifications of the Original Intel Code. No other license or right
37 * is granted directly or by implication, estoppel or otherwise;
38 *
39 * The above copyright and patent license is granted only if the following
40 * conditions are met:
41 *
42 * 3. Conditions
43 *
44 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45 * Redistribution of source code of any substantial portion of the Covered
46 * Code or modification with rights to further distribute source must include
47 * the above Copyright Notice, the above License, this list of Conditions,
48 * and the following Disclaimer and Export Compliance provision. In addition,
49 * Licensee must cause all Covered Code to which Licensee contributes to
50 * contain a file documenting the changes Licensee made to create that Covered
51 * Code and the date of any change. Licensee must include in that file the
52 * documentation of any changes made by any predecessor Licensee. Licensee
53 * must include a prominent statement that the modification is derived,
54 * directly or indirectly, from Original Intel Code.
55 *
56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57 * Redistribution of source code of any substantial portion of the Covered
58 * Code or modification without rights to further distribute source must
59 * include the following Disclaimer and Export Compliance provision in the
60 * documentation and/or other materials provided with distribution. In
61 * addition, Licensee may not authorize further sublicense of source of any
62 * portion of the Covered Code, and must include terms to the effect that the
63 * license from Licensee to its licensee is limited to the intellectual
64 * property embodied in the software Licensee provides to its licensee, and
65 * not to intellectual property embodied in modifications its licensee may
66 * make.
67 *
68 * 3.3. Redistribution of Executable. Redistribution in executable form of any
69 * substantial portion of the Covered Code or modification must reproduce the
70 * above Copyright Notice, and the following Disclaimer and Export Compliance
71 * provision in the documentation and/or other materials provided with the
72 * distribution.
73 *
74 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * Intel Code.
76 *
77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78 * Intel shall be used in advertising or otherwise to promote the sale, use or
79 * other dealings in products derived from or relating to the Covered Code
80 * without prior written authorization from Intel.
81 *
82 * 4. Disclaimer and Export Compliance
83 *
84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * PARTICULAR PURPOSE.
91 *
92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * LIMITED REMEDY.
100 *
101 * 4.3. Licensee shall not export, either directly or indirectly, any of this
102 * software or system incorporating such software without first obtaining any
103 * required license or other approval from the U. S. Department of Commerce or
104 * any other agency or department of the United States Government. In the
105 * event Licensee exports any such software from the United States or
106 * re-exports any such software from a foreign destination, Licensee shall
107 * ensure that the distribution and export/re-export of the software is in
108 * compliance with all laws, regulations, orders, or other restrictions of the
109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110 * any of its subsidiaries will export/re-export any technical data, process,
111 * software, or service, directly or indirectly, to any country for which the
112 * United States government or any agency thereof requires an export license,
113 * other governmental approval, or letter of assurance, without first obtaining
114 * such license, approval or letter.
115 *
116 *****************************************************************************/
117
118#define __DSOPCODE_C__
119
120#include "acpi.h"
121#include "acparser.h"
122#include "amlcode.h"
123#include "acdispat.h"
124#include "acinterp.h"
125#include "acnamesp.h"
126#include "acevents.h"
127
128#define _COMPONENT ACPI_DISPATCHER
129 ACPI_MODULE_NAME ("dsopcode")
130
131
132/*****************************************************************************
133 *
134 * FUNCTION: AcpiDsExecuteArguments
135 *
136 * PARAMETERS: Node - Parent NS node
137 * AmlLength - Length of executable AML
138 * AmlStart - Pointer to the AML
139 *
140 * RETURN: Status.
141 *
6 *
7 *****************************************************************************/
8
9/******************************************************************************
10 *
11 * 1. Copyright Notice
12 *
13 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
14 * All rights reserved.
15 *
16 * 2. License
17 *
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
21 * property rights.
22 *
23 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24 * copy of the source code appearing in this file ("Covered Code") an
25 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26 * base code distributed originally by Intel ("Original Intel Code") to copy,
27 * make derivatives, distribute, use and display any portion of the Covered
28 * Code in any form, with the right to sublicense such rights; and
29 *
30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31 * license (with the right to sublicense), under only those claims of Intel
32 * patents that are infringed by the Original Intel Code, to make, use, sell,
33 * offer to sell, and import the Covered Code and derivative works thereof
34 * solely to the minimum extent necessary to exercise the above copyright
35 * license, and in no event shall the patent license extend to any additions
36 * to or modifications of the Original Intel Code. No other license or right
37 * is granted directly or by implication, estoppel or otherwise;
38 *
39 * The above copyright and patent license is granted only if the following
40 * conditions are met:
41 *
42 * 3. Conditions
43 *
44 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45 * Redistribution of source code of any substantial portion of the Covered
46 * Code or modification with rights to further distribute source must include
47 * the above Copyright Notice, the above License, this list of Conditions,
48 * and the following Disclaimer and Export Compliance provision. In addition,
49 * Licensee must cause all Covered Code to which Licensee contributes to
50 * contain a file documenting the changes Licensee made to create that Covered
51 * Code and the date of any change. Licensee must include in that file the
52 * documentation of any changes made by any predecessor Licensee. Licensee
53 * must include a prominent statement that the modification is derived,
54 * directly or indirectly, from Original Intel Code.
55 *
56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57 * Redistribution of source code of any substantial portion of the Covered
58 * Code or modification without rights to further distribute source must
59 * include the following Disclaimer and Export Compliance provision in the
60 * documentation and/or other materials provided with distribution. In
61 * addition, Licensee may not authorize further sublicense of source of any
62 * portion of the Covered Code, and must include terms to the effect that the
63 * license from Licensee to its licensee is limited to the intellectual
64 * property embodied in the software Licensee provides to its licensee, and
65 * not to intellectual property embodied in modifications its licensee may
66 * make.
67 *
68 * 3.3. Redistribution of Executable. Redistribution in executable form of any
69 * substantial portion of the Covered Code or modification must reproduce the
70 * above Copyright Notice, and the following Disclaimer and Export Compliance
71 * provision in the documentation and/or other materials provided with the
72 * distribution.
73 *
74 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * Intel Code.
76 *
77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78 * Intel shall be used in advertising or otherwise to promote the sale, use or
79 * other dealings in products derived from or relating to the Covered Code
80 * without prior written authorization from Intel.
81 *
82 * 4. Disclaimer and Export Compliance
83 *
84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * PARTICULAR PURPOSE.
91 *
92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * LIMITED REMEDY.
100 *
101 * 4.3. Licensee shall not export, either directly or indirectly, any of this
102 * software or system incorporating such software without first obtaining any
103 * required license or other approval from the U. S. Department of Commerce or
104 * any other agency or department of the United States Government. In the
105 * event Licensee exports any such software from the United States or
106 * re-exports any such software from a foreign destination, Licensee shall
107 * ensure that the distribution and export/re-export of the software is in
108 * compliance with all laws, regulations, orders, or other restrictions of the
109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110 * any of its subsidiaries will export/re-export any technical data, process,
111 * software, or service, directly or indirectly, to any country for which the
112 * United States government or any agency thereof requires an export license,
113 * other governmental approval, or letter of assurance, without first obtaining
114 * such license, approval or letter.
115 *
116 *****************************************************************************/
117
118#define __DSOPCODE_C__
119
120#include "acpi.h"
121#include "acparser.h"
122#include "amlcode.h"
123#include "acdispat.h"
124#include "acinterp.h"
125#include "acnamesp.h"
126#include "acevents.h"
127
128#define _COMPONENT ACPI_DISPATCHER
129 ACPI_MODULE_NAME ("dsopcode")
130
131
132/*****************************************************************************
133 *
134 * FUNCTION: AcpiDsExecuteArguments
135 *
136 * PARAMETERS: Node - Parent NS node
137 * AmlLength - Length of executable AML
138 * AmlStart - Pointer to the AML
139 *
140 * RETURN: Status.
141 *
142 * DESCRIPTION: Late execution of region or field arguments
142 * DESCRIPTION: Late (deferred) execution of region or field arguments
143 *
144 ****************************************************************************/
145
146ACPI_STATUS
147AcpiDsExecuteArguments (
148 ACPI_NAMESPACE_NODE *Node,
149 ACPI_NAMESPACE_NODE *ScopeNode,
150 UINT32 AmlLength,
151 UINT8 *AmlStart)
152{
153 ACPI_STATUS Status;
154 ACPI_PARSE_OBJECT *Op;
155 ACPI_WALK_STATE *WalkState;
156 ACPI_PARSE_OBJECT *Arg;
157
158
159 ACPI_FUNCTION_TRACE ("DsExecuteArguments");
160
161
162 /*
163 * Allocate a new parser op to be the root of the parsed tree
164 */
165 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP);
166 if (!Op)
167 {
168 return_ACPI_STATUS (AE_NO_MEMORY);
169 }
170
171 /* Save the Node for use in AcpiPsParseAml */
172
173 Op->Common.Node = ScopeNode;
174
175 /* Create and initialize a new parser state */
176
177 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
178 if (!WalkState)
179 {
180 return_ACPI_STATUS (AE_NO_MEMORY);
181 }
182
183 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart,
184 AmlLength, NULL, NULL, 1);
185 if (ACPI_FAILURE (Status))
186 {
187 AcpiDsDeleteWalkState (WalkState);
188 return_ACPI_STATUS (Status);
189 }
190
143 *
144 ****************************************************************************/
145
146ACPI_STATUS
147AcpiDsExecuteArguments (
148 ACPI_NAMESPACE_NODE *Node,
149 ACPI_NAMESPACE_NODE *ScopeNode,
150 UINT32 AmlLength,
151 UINT8 *AmlStart)
152{
153 ACPI_STATUS Status;
154 ACPI_PARSE_OBJECT *Op;
155 ACPI_WALK_STATE *WalkState;
156 ACPI_PARSE_OBJECT *Arg;
157
158
159 ACPI_FUNCTION_TRACE ("DsExecuteArguments");
160
161
162 /*
163 * Allocate a new parser op to be the root of the parsed tree
164 */
165 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP);
166 if (!Op)
167 {
168 return_ACPI_STATUS (AE_NO_MEMORY);
169 }
170
171 /* Save the Node for use in AcpiPsParseAml */
172
173 Op->Common.Node = ScopeNode;
174
175 /* Create and initialize a new parser state */
176
177 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
178 if (!WalkState)
179 {
180 return_ACPI_STATUS (AE_NO_MEMORY);
181 }
182
183 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart,
184 AmlLength, NULL, NULL, 1);
185 if (ACPI_FAILURE (Status))
186 {
187 AcpiDsDeleteWalkState (WalkState);
188 return_ACPI_STATUS (Status);
189 }
190
191 /* Mark this parse as a deferred opcode */
192
191 WalkState->ParseFlags = ACPI_PARSE_DEFERRED_OP;
193 WalkState->ParseFlags = ACPI_PARSE_DEFERRED_OP;
194 WalkState->DeferredNode = Node;
192
193 /* Pass1: Parse the entire declaration */
194
195 Status = AcpiPsParseAml (WalkState);
196 if (ACPI_FAILURE (Status))
197 {
198 AcpiPsDeleteParseTree (Op);
199 return_ACPI_STATUS (Status);
200 }
201
202 /* Get and init the Op created above */
203
204 Arg = Op->Common.Value.Arg;
205 Op->Common.Node = Node;
206 Arg->Common.Node = Node;
207 AcpiPsDeleteParseTree (Op);
208
195
196 /* Pass1: Parse the entire declaration */
197
198 Status = AcpiPsParseAml (WalkState);
199 if (ACPI_FAILURE (Status))
200 {
201 AcpiPsDeleteParseTree (Op);
202 return_ACPI_STATUS (Status);
203 }
204
205 /* Get and init the Op created above */
206
207 Arg = Op->Common.Value.Arg;
208 Op->Common.Node = Node;
209 Arg->Common.Node = Node;
210 AcpiPsDeleteParseTree (Op);
211
209 /* Evaluate the address and length arguments for the Buffer Field */
212 /* Evaluate the deferred arguments */
210
211 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP);
212 if (!Op)
213 {
214 return_ACPI_STATUS (AE_NO_MEMORY);
215 }
216
217 Op->Common.Node = ScopeNode;
218
219 /* Create and initialize a new parser state */
220
221 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
222 if (!WalkState)
223 {
224 return_ACPI_STATUS (AE_NO_MEMORY);
225 }
226
213
214 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP);
215 if (!Op)
216 {
217 return_ACPI_STATUS (AE_NO_MEMORY);
218 }
219
220 Op->Common.Node = ScopeNode;
221
222 /* Create and initialize a new parser state */
223
224 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
225 if (!WalkState)
226 {
227 return_ACPI_STATUS (AE_NO_MEMORY);
228 }
229
230 /* Execute the opcode and arguments */
231
227 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart,
228 AmlLength, NULL, NULL, 3);
229 if (ACPI_FAILURE (Status))
230 {
231 AcpiDsDeleteWalkState (WalkState);
232 return_ACPI_STATUS (Status);
233 }
234
232 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart,
233 AmlLength, NULL, NULL, 3);
234 if (ACPI_FAILURE (Status))
235 {
236 AcpiDsDeleteWalkState (WalkState);
237 return_ACPI_STATUS (Status);
238 }
239
240 /* Mark this execution as a deferred opcode */
241
242 WalkState->DeferredNode = Node;
235 Status = AcpiPsParseAml (WalkState);
236 AcpiPsDeleteParseTree (Op);
237 return_ACPI_STATUS (Status);
238}
239
240
241/*****************************************************************************
242 *
243 * FUNCTION: AcpiDsGetBufferFieldArguments
244 *
245 * PARAMETERS: ObjDesc - A valid BufferField object
246 *
247 * RETURN: Status.
248 *
249 * DESCRIPTION: Get BufferField Buffer and Index. This implements the late
250 * evaluation of these field attributes.
251 *
252 ****************************************************************************/
253
254ACPI_STATUS
255AcpiDsGetBufferFieldArguments (
256 ACPI_OPERAND_OBJECT *ObjDesc)
257{
258 ACPI_OPERAND_OBJECT *ExtraDesc;
259 ACPI_NAMESPACE_NODE *Node;
260 ACPI_STATUS Status;
261
262
263 ACPI_FUNCTION_TRACE_PTR ("DsGetBufferFieldArguments", ObjDesc);
264
265
266 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
267 {
268 return_ACPI_STATUS (AE_OK);
269 }
270
271 /* Get the AML pointer (method object) and BufferField node */
272
273 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
274 Node = ObjDesc->BufferField.Node;
275
276 ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_BUFFER_FIELD, Node, NULL));
243 Status = AcpiPsParseAml (WalkState);
244 AcpiPsDeleteParseTree (Op);
245 return_ACPI_STATUS (Status);
246}
247
248
249/*****************************************************************************
250 *
251 * FUNCTION: AcpiDsGetBufferFieldArguments
252 *
253 * PARAMETERS: ObjDesc - A valid BufferField object
254 *
255 * RETURN: Status.
256 *
257 * DESCRIPTION: Get BufferField Buffer and Index. This implements the late
258 * evaluation of these field attributes.
259 *
260 ****************************************************************************/
261
262ACPI_STATUS
263AcpiDsGetBufferFieldArguments (
264 ACPI_OPERAND_OBJECT *ObjDesc)
265{
266 ACPI_OPERAND_OBJECT *ExtraDesc;
267 ACPI_NAMESPACE_NODE *Node;
268 ACPI_STATUS Status;
269
270
271 ACPI_FUNCTION_TRACE_PTR ("DsGetBufferFieldArguments", ObjDesc);
272
273
274 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
275 {
276 return_ACPI_STATUS (AE_OK);
277 }
278
279 /* Get the AML pointer (method object) and BufferField node */
280
281 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
282 Node = ObjDesc->BufferField.Node;
283
284 ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_BUFFER_FIELD, Node, NULL));
277 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField JIT Init\n",
278 Node->Name.Ascii));
285 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n",
286 AcpiUtGetNodeName (Node)));
279
280 /* Execute the AML code for the TermArg arguments */
281
282 Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node),
283 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
284 return_ACPI_STATUS (Status);
285}
286
287
288/*****************************************************************************
289 *
290 * FUNCTION: AcpiDsGetBufferArguments
291 *
287
288 /* Execute the AML code for the TermArg arguments */
289
290 Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node),
291 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
292 return_ACPI_STATUS (Status);
293}
294
295
296/*****************************************************************************
297 *
298 * FUNCTION: AcpiDsGetBufferArguments
299 *
292 * PARAMETERS: ObjDesc - A valid Bufferobject
300 * PARAMETERS: ObjDesc - A valid Buffer object
293 *
294 * RETURN: Status.
295 *
296 * DESCRIPTION: Get Buffer length and initializer byte list. This implements
297 * the late evaluation of these attributes.
298 *
299 ****************************************************************************/
300
301ACPI_STATUS
302AcpiDsGetBufferArguments (
303 ACPI_OPERAND_OBJECT *ObjDesc)
304{
305 ACPI_NAMESPACE_NODE *Node;
306 ACPI_STATUS Status;
307
308
309 ACPI_FUNCTION_TRACE_PTR ("DsGetBufferArguments", ObjDesc);
310
311
312 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
313 {
314 return_ACPI_STATUS (AE_OK);
315 }
316
317 /* Get the Buffer node */
318
319 Node = ObjDesc->Buffer.Node;
320 if (!Node)
321 {
322 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
323 "No pointer back to NS node in buffer %p\n", ObjDesc));
324 return_ACPI_STATUS (AE_AML_INTERNAL);
325 }
326
301 *
302 * RETURN: Status.
303 *
304 * DESCRIPTION: Get Buffer length and initializer byte list. This implements
305 * the late evaluation of these attributes.
306 *
307 ****************************************************************************/
308
309ACPI_STATUS
310AcpiDsGetBufferArguments (
311 ACPI_OPERAND_OBJECT *ObjDesc)
312{
313 ACPI_NAMESPACE_NODE *Node;
314 ACPI_STATUS Status;
315
316
317 ACPI_FUNCTION_TRACE_PTR ("DsGetBufferArguments", ObjDesc);
318
319
320 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
321 {
322 return_ACPI_STATUS (AE_OK);
323 }
324
325 /* Get the Buffer node */
326
327 Node = ObjDesc->Buffer.Node;
328 if (!Node)
329 {
330 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
331 "No pointer back to NS node in buffer %p\n", ObjDesc));
332 return_ACPI_STATUS (AE_AML_INTERNAL);
333 }
334
327 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer JIT Init\n"));
335 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n"));
328
329 /* Execute the AML code for the TermArg arguments */
330
331 Status = AcpiDsExecuteArguments (Node, Node,
332 ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart);
333 return_ACPI_STATUS (Status);
334}
335
336
337/*****************************************************************************
338 *
339 * FUNCTION: AcpiDsGetPackageArguments
340 *
336
337 /* Execute the AML code for the TermArg arguments */
338
339 Status = AcpiDsExecuteArguments (Node, Node,
340 ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart);
341 return_ACPI_STATUS (Status);
342}
343
344
345/*****************************************************************************
346 *
347 * FUNCTION: AcpiDsGetPackageArguments
348 *
341 * PARAMETERS: ObjDesc - A valid Packageobject
349 * PARAMETERS: ObjDesc - A valid Package object
342 *
343 * RETURN: Status.
344 *
345 * DESCRIPTION: Get Package length and initializer byte list. This implements
346 * the late evaluation of these attributes.
347 *
348 ****************************************************************************/
349
350ACPI_STATUS
351AcpiDsGetPackageArguments (
352 ACPI_OPERAND_OBJECT *ObjDesc)
353{
354 ACPI_NAMESPACE_NODE *Node;
355 ACPI_STATUS Status;
356
357
358 ACPI_FUNCTION_TRACE_PTR ("DsGetPackageArguments", ObjDesc);
359
360
361 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
362 {
363 return_ACPI_STATUS (AE_OK);
364 }
365
366 /* Get the Package node */
367
368 Node = ObjDesc->Package.Node;
369 if (!Node)
370 {
371 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
372 "No pointer back to NS node in package %p\n", ObjDesc));
373 return_ACPI_STATUS (AE_AML_INTERNAL);
374 }
375
350 *
351 * RETURN: Status.
352 *
353 * DESCRIPTION: Get Package length and initializer byte list. This implements
354 * the late evaluation of these attributes.
355 *
356 ****************************************************************************/
357
358ACPI_STATUS
359AcpiDsGetPackageArguments (
360 ACPI_OPERAND_OBJECT *ObjDesc)
361{
362 ACPI_NAMESPACE_NODE *Node;
363 ACPI_STATUS Status;
364
365
366 ACPI_FUNCTION_TRACE_PTR ("DsGetPackageArguments", ObjDesc);
367
368
369 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
370 {
371 return_ACPI_STATUS (AE_OK);
372 }
373
374 /* Get the Package node */
375
376 Node = ObjDesc->Package.Node;
377 if (!Node)
378 {
379 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
380 "No pointer back to NS node in package %p\n", ObjDesc));
381 return_ACPI_STATUS (AE_AML_INTERNAL);
382 }
383
376 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package JIT Init\n"));
384 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n"));
377
378 /* Execute the AML code for the TermArg arguments */
379
380 Status = AcpiDsExecuteArguments (Node, Node,
381 ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart);
382 return_ACPI_STATUS (Status);
383}
384
385
386/*****************************************************************************
387 *
388 * FUNCTION: AcpiDsGetRegionArguments
389 *
390 * PARAMETERS: ObjDesc - A valid region object
391 *
392 * RETURN: Status.
393 *
394 * DESCRIPTION: Get region address and length. This implements the late
395 * evaluation of these region attributes.
396 *
397 ****************************************************************************/
398
399ACPI_STATUS
400AcpiDsGetRegionArguments (
401 ACPI_OPERAND_OBJECT *ObjDesc)
402{
403 ACPI_NAMESPACE_NODE *Node;
404 ACPI_STATUS Status;
405 ACPI_OPERAND_OBJECT *ExtraDesc;
406
407
408 ACPI_FUNCTION_TRACE_PTR ("DsGetRegionArguments", ObjDesc);
409
410
411 if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
412 {
413 return_ACPI_STATUS (AE_OK);
414 }
415
416 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
417 if (!ExtraDesc)
418 {
419 return_ACPI_STATUS (AE_NOT_EXIST);
420 }
421
422 /* Get the Region node */
423
424 Node = ObjDesc->Region.Node;
425
385
386 /* Execute the AML code for the TermArg arguments */
387
388 Status = AcpiDsExecuteArguments (Node, Node,
389 ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart);
390 return_ACPI_STATUS (Status);
391}
392
393
394/*****************************************************************************
395 *
396 * FUNCTION: AcpiDsGetRegionArguments
397 *
398 * PARAMETERS: ObjDesc - A valid region object
399 *
400 * RETURN: Status.
401 *
402 * DESCRIPTION: Get region address and length. This implements the late
403 * evaluation of these region attributes.
404 *
405 ****************************************************************************/
406
407ACPI_STATUS
408AcpiDsGetRegionArguments (
409 ACPI_OPERAND_OBJECT *ObjDesc)
410{
411 ACPI_NAMESPACE_NODE *Node;
412 ACPI_STATUS Status;
413 ACPI_OPERAND_OBJECT *ExtraDesc;
414
415
416 ACPI_FUNCTION_TRACE_PTR ("DsGetRegionArguments", ObjDesc);
417
418
419 if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
420 {
421 return_ACPI_STATUS (AE_OK);
422 }
423
424 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
425 if (!ExtraDesc)
426 {
427 return_ACPI_STATUS (AE_NOT_EXIST);
428 }
429
430 /* Get the Region node */
431
432 Node = ObjDesc->Region.Node;
433
426 ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_REGION, Node, NULL));
434 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_REGION, Node, NULL));
427
435
428 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Init at AML %p\n",
429 Node->Name.Ascii, ExtraDesc->Extra.AmlStart));
436 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n",
437 AcpiUtGetNodeName (Node), ExtraDesc->Extra.AmlStart));
430
438
439 /* Execute the argument AML */
431
432 Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node),
433 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
434 return_ACPI_STATUS (Status);
435}
436
437
438/*****************************************************************************
439 *
440 * FUNCTION: AcpiDsInitializeRegion
441 *
442 * PARAMETERS: Op - A valid region Op object
443 *
444 * RETURN: Status
445 *
446 * DESCRIPTION: Front end to EvInitializeRegion
447 *
448 ****************************************************************************/
449
450ACPI_STATUS
451AcpiDsInitializeRegion (
452 ACPI_HANDLE ObjHandle)
453{
454 ACPI_OPERAND_OBJECT *ObjDesc;
455 ACPI_STATUS Status;
456
457
458 ObjDesc = AcpiNsGetAttachedObject (ObjHandle);
459
460 /* Namespace is NOT locked */
461
462 Status = AcpiEvInitializeRegion (ObjDesc, FALSE);
463 return (Status);
464}
465
466
467/*****************************************************************************
468 *
469 * FUNCTION: AcpiDsInitBufferField
470 *
471 * PARAMETERS: AmlOpcode - CreateXxxField
472 * ObjDesc - BufferField object
473 * BufferDesc - Host Buffer
474 * OffsetDesc - Offset into buffer
475 * Length - Length of field (CREATE_FIELD_OP only)
476 * Result - Where to store the result
477 *
478 * RETURN: Status
479 *
480 * DESCRIPTION: Perform actual initialization of a buffer field
481 *
482 ****************************************************************************/
483
484ACPI_STATUS
485AcpiDsInitBufferField (
486 UINT16 AmlOpcode,
487 ACPI_OPERAND_OBJECT *ObjDesc,
488 ACPI_OPERAND_OBJECT *BufferDesc,
489 ACPI_OPERAND_OBJECT *OffsetDesc,
490 ACPI_OPERAND_OBJECT *LengthDesc,
491 ACPI_OPERAND_OBJECT *ResultDesc)
492{
493 UINT32 Offset;
494 UINT32 BitOffset;
495 UINT32 BitCount;
496 UINT8 FieldFlags;
497 ACPI_STATUS Status;
498
499
500 ACPI_FUNCTION_TRACE_PTR ("DsInitBufferField", ObjDesc);
501
502
503 /* Host object must be a Buffer */
504
505 if (ACPI_GET_OBJECT_TYPE (BufferDesc) != ACPI_TYPE_BUFFER)
506 {
507 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
508 "Target of Create Field is not a Buffer object - %s\n",
509 AcpiUtGetObjectTypeName (BufferDesc)));
510
511 Status = AE_AML_OPERAND_TYPE;
512 goto Cleanup;
513 }
514
515 /*
516 * The last parameter to all of these opcodes (ResultDesc) started
517 * out as a NameString, and should therefore now be a NS node
518 * after resolution in AcpiExResolveOperands().
519 */
520 if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED)
521 {
440
441 Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node),
442 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
443 return_ACPI_STATUS (Status);
444}
445
446
447/*****************************************************************************
448 *
449 * FUNCTION: AcpiDsInitializeRegion
450 *
451 * PARAMETERS: Op - A valid region Op object
452 *
453 * RETURN: Status
454 *
455 * DESCRIPTION: Front end to EvInitializeRegion
456 *
457 ****************************************************************************/
458
459ACPI_STATUS
460AcpiDsInitializeRegion (
461 ACPI_HANDLE ObjHandle)
462{
463 ACPI_OPERAND_OBJECT *ObjDesc;
464 ACPI_STATUS Status;
465
466
467 ObjDesc = AcpiNsGetAttachedObject (ObjHandle);
468
469 /* Namespace is NOT locked */
470
471 Status = AcpiEvInitializeRegion (ObjDesc, FALSE);
472 return (Status);
473}
474
475
476/*****************************************************************************
477 *
478 * FUNCTION: AcpiDsInitBufferField
479 *
480 * PARAMETERS: AmlOpcode - CreateXxxField
481 * ObjDesc - BufferField object
482 * BufferDesc - Host Buffer
483 * OffsetDesc - Offset into buffer
484 * Length - Length of field (CREATE_FIELD_OP only)
485 * Result - Where to store the result
486 *
487 * RETURN: Status
488 *
489 * DESCRIPTION: Perform actual initialization of a buffer field
490 *
491 ****************************************************************************/
492
493ACPI_STATUS
494AcpiDsInitBufferField (
495 UINT16 AmlOpcode,
496 ACPI_OPERAND_OBJECT *ObjDesc,
497 ACPI_OPERAND_OBJECT *BufferDesc,
498 ACPI_OPERAND_OBJECT *OffsetDesc,
499 ACPI_OPERAND_OBJECT *LengthDesc,
500 ACPI_OPERAND_OBJECT *ResultDesc)
501{
502 UINT32 Offset;
503 UINT32 BitOffset;
504 UINT32 BitCount;
505 UINT8 FieldFlags;
506 ACPI_STATUS Status;
507
508
509 ACPI_FUNCTION_TRACE_PTR ("DsInitBufferField", ObjDesc);
510
511
512 /* Host object must be a Buffer */
513
514 if (ACPI_GET_OBJECT_TYPE (BufferDesc) != ACPI_TYPE_BUFFER)
515 {
516 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
517 "Target of Create Field is not a Buffer object - %s\n",
518 AcpiUtGetObjectTypeName (BufferDesc)));
519
520 Status = AE_AML_OPERAND_TYPE;
521 goto Cleanup;
522 }
523
524 /*
525 * The last parameter to all of these opcodes (ResultDesc) started
526 * out as a NameString, and should therefore now be a NS node
527 * after resolution in AcpiExResolveOperands().
528 */
529 if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED)
530 {
522 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination must be a NS Node\n",
523 AcpiPsGetOpcodeName (AmlOpcode)));
531 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination not a NS Node [%s]\n",
532 AcpiPsGetOpcodeName (AmlOpcode), AcpiUtGetDescriptorName (ResultDesc)));
524
525 Status = AE_AML_OPERAND_TYPE;
526 goto Cleanup;
527 }
528
529 Offset = (UINT32) OffsetDesc->Integer.Value;
530
531 /*
532 * Setup the Bit offsets and counts, according to the opcode
533 */
534 switch (AmlOpcode)
535 {
536 case AML_CREATE_FIELD_OP:
537
538 /* Offset is in bits, count is in bits */
539
540 BitOffset = Offset;
541 BitCount = (UINT32) LengthDesc->Integer.Value;
542 FieldFlags = AML_FIELD_ACCESS_BYTE;
543 break;
544
545 case AML_CREATE_BIT_FIELD_OP:
546
547 /* Offset is in bits, Field is one bit */
548
549 BitOffset = Offset;
550 BitCount = 1;
551 FieldFlags = AML_FIELD_ACCESS_BYTE;
552 break;
553
554 case AML_CREATE_BYTE_FIELD_OP:
555
556 /* Offset is in bytes, field is one byte */
557
558 BitOffset = 8 * Offset;
559 BitCount = 8;
560 FieldFlags = AML_FIELD_ACCESS_BYTE;
561 break;
562
563 case AML_CREATE_WORD_FIELD_OP:
564
565 /* Offset is in bytes, field is one word */
566
567 BitOffset = 8 * Offset;
568 BitCount = 16;
569 FieldFlags = AML_FIELD_ACCESS_WORD;
570 break;
571
572 case AML_CREATE_DWORD_FIELD_OP:
573
574 /* Offset is in bytes, field is one dword */
575
576 BitOffset = 8 * Offset;
577 BitCount = 32;
578 FieldFlags = AML_FIELD_ACCESS_DWORD;
579 break;
580
581 case AML_CREATE_QWORD_FIELD_OP:
582
583 /* Offset is in bytes, field is one qword */
584
585 BitOffset = 8 * Offset;
586 BitCount = 64;
587 FieldFlags = AML_FIELD_ACCESS_QWORD;
588 break;
589
590 default:
591
592 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
593 "Unknown field creation opcode %02x\n",
594 AmlOpcode));
595 Status = AE_AML_BAD_OPCODE;
596 goto Cleanup;
597 }
598
533
534 Status = AE_AML_OPERAND_TYPE;
535 goto Cleanup;
536 }
537
538 Offset = (UINT32) OffsetDesc->Integer.Value;
539
540 /*
541 * Setup the Bit offsets and counts, according to the opcode
542 */
543 switch (AmlOpcode)
544 {
545 case AML_CREATE_FIELD_OP:
546
547 /* Offset is in bits, count is in bits */
548
549 BitOffset = Offset;
550 BitCount = (UINT32) LengthDesc->Integer.Value;
551 FieldFlags = AML_FIELD_ACCESS_BYTE;
552 break;
553
554 case AML_CREATE_BIT_FIELD_OP:
555
556 /* Offset is in bits, Field is one bit */
557
558 BitOffset = Offset;
559 BitCount = 1;
560 FieldFlags = AML_FIELD_ACCESS_BYTE;
561 break;
562
563 case AML_CREATE_BYTE_FIELD_OP:
564
565 /* Offset is in bytes, field is one byte */
566
567 BitOffset = 8 * Offset;
568 BitCount = 8;
569 FieldFlags = AML_FIELD_ACCESS_BYTE;
570 break;
571
572 case AML_CREATE_WORD_FIELD_OP:
573
574 /* Offset is in bytes, field is one word */
575
576 BitOffset = 8 * Offset;
577 BitCount = 16;
578 FieldFlags = AML_FIELD_ACCESS_WORD;
579 break;
580
581 case AML_CREATE_DWORD_FIELD_OP:
582
583 /* Offset is in bytes, field is one dword */
584
585 BitOffset = 8 * Offset;
586 BitCount = 32;
587 FieldFlags = AML_FIELD_ACCESS_DWORD;
588 break;
589
590 case AML_CREATE_QWORD_FIELD_OP:
591
592 /* Offset is in bytes, field is one qword */
593
594 BitOffset = 8 * Offset;
595 BitCount = 64;
596 FieldFlags = AML_FIELD_ACCESS_QWORD;
597 break;
598
599 default:
600
601 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
602 "Unknown field creation opcode %02x\n",
603 AmlOpcode));
604 Status = AE_AML_BAD_OPCODE;
605 goto Cleanup;
606 }
607
599
600 /* Entire field must fit within the current length of the buffer */
601
602 if ((BitOffset + BitCount) >
603 (8 * (UINT32) BufferDesc->Buffer.Length))
604 {
605 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
608 /* Entire field must fit within the current length of the buffer */
609
610 if ((BitOffset + BitCount) >
611 (8 * (UINT32) BufferDesc->Buffer.Length))
612 {
613 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
606 "Field size %d exceeds Buffer size %d (bits)\n",
607 BitOffset + BitCount, 8 * (UINT32) BufferDesc->Buffer.Length));
614 "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n",
615 AcpiUtGetNodeName (ResultDesc),
616 BitOffset + BitCount,
617 AcpiUtGetNodeName (BufferDesc->Buffer.Node),
618 8 * (UINT32) BufferDesc->Buffer.Length));
608 Status = AE_AML_BUFFER_LIMIT;
609 goto Cleanup;
610 }
611
612 /*
613 * Initialize areas of the field object that are common to all fields
614 * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE)
615 */
616 Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0,
617 BitOffset, BitCount);
618 if (ACPI_FAILURE (Status))
619 {
620 goto Cleanup;
621 }
622
623 ObjDesc->BufferField.BufferObj = BufferDesc;
624
625 /* Reference count for BufferDesc inherits ObjDesc count */
626
627 BufferDesc->Common.ReferenceCount = (UINT16) (BufferDesc->Common.ReferenceCount +
628 ObjDesc->Common.ReferenceCount);
629
630
631Cleanup:
632
633 /* Always delete the operands */
634
635 AcpiUtRemoveReference (OffsetDesc);
636 AcpiUtRemoveReference (BufferDesc);
637
638 if (AmlOpcode == AML_CREATE_FIELD_OP)
639 {
640 AcpiUtRemoveReference (LengthDesc);
641 }
642
643 /* On failure, delete the result descriptor */
644
645 if (ACPI_FAILURE (Status))
646 {
647 AcpiUtRemoveReference (ResultDesc); /* Result descriptor */
648 }
649 else
650 {
651 /* Now the address and length are valid for this BufferField */
652
653 ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID;
654 }
655
656 return_ACPI_STATUS (Status);
657}
658
659
660/*****************************************************************************
661 *
662 * FUNCTION: AcpiDsEvalBufferFieldOperands
663 *
664 * PARAMETERS: WalkState - Current walk
665 * Op - A valid BufferField Op object
666 *
667 * RETURN: Status
668 *
669 * DESCRIPTION: Get BufferField Buffer and Index
670 * Called from AcpiDsExecEndOp during BufferField parse tree walk
671 *
672 ****************************************************************************/
673
674ACPI_STATUS
675AcpiDsEvalBufferFieldOperands (
676 ACPI_WALK_STATE *WalkState,
677 ACPI_PARSE_OBJECT *Op)
678{
679 ACPI_STATUS Status;
680 ACPI_OPERAND_OBJECT *ObjDesc;
681 ACPI_NAMESPACE_NODE *Node;
682 ACPI_PARSE_OBJECT *NextOp;
683
684
685 ACPI_FUNCTION_TRACE_PTR ("DsEvalBufferFieldOperands", Op);
686
687
688 /*
689 * This is where we evaluate the address and length fields of the
690 * CreateXxxField declaration
691 */
692 Node = Op->Common.Node;
693
694 /* NextOp points to the op that holds the Buffer */
695
696 NextOp = Op->Common.Value.Arg;
697
698 /* Evaluate/create the address and length operands */
699
700 Status = AcpiDsCreateOperands (WalkState, NextOp);
701 if (ACPI_FAILURE (Status))
702 {
703 return_ACPI_STATUS (Status);
704 }
705
706 ObjDesc = AcpiNsGetAttachedObject (Node);
707 if (!ObjDesc)
708 {
709 return_ACPI_STATUS (AE_NOT_EXIST);
710 }
711
712 /* Resolve the operands */
713
714 Status = AcpiExResolveOperands (Op->Common.AmlOpcode,
715 ACPI_WALK_OPERANDS, WalkState);
716
717 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
718 AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
719 WalkState->NumOperands, "after AcpiExResolveOperands");
720
721 if (ACPI_FAILURE (Status))
722 {
723 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n",
724 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status));
725
726 return_ACPI_STATUS (Status);
727 }
728
729 /* Initialize the Buffer Field */
730
731 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
732 {
733 /* NOTE: Slightly different operands for this opcode */
734
735 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,
736 WalkState->Operands[0], WalkState->Operands[1],
737 WalkState->Operands[2], WalkState->Operands[3]);
738 }
739 else
740 {
741 /* All other, CreateXxxField opcodes */
742
743 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,
744 WalkState->Operands[0], WalkState->Operands[1],
745 NULL, WalkState->Operands[2]);
746 }
747
748 return_ACPI_STATUS (Status);
749}
750
751
752/*****************************************************************************
753 *
754 * FUNCTION: AcpiDsEvalRegionOperands
755 *
756 * PARAMETERS: WalkState - Current walk
757 * Op - A valid region Op object
758 *
759 * RETURN: Status
760 *
761 * DESCRIPTION: Get region address and length
762 * Called from AcpiDsExecEndOp during OpRegion parse tree walk
763 *
764 ****************************************************************************/
765
766ACPI_STATUS
767AcpiDsEvalRegionOperands (
768 ACPI_WALK_STATE *WalkState,
769 ACPI_PARSE_OBJECT *Op)
770{
771 ACPI_STATUS Status;
772 ACPI_OPERAND_OBJECT *ObjDesc;
773 ACPI_OPERAND_OBJECT *OperandDesc;
774 ACPI_NAMESPACE_NODE *Node;
775 ACPI_PARSE_OBJECT *NextOp;
776
777
778 ACPI_FUNCTION_TRACE_PTR ("DsEvalRegionOperands", Op);
779
780
781 /*
782 * This is where we evaluate the address and length fields of the OpRegion declaration
783 */
784 Node = Op->Common.Node;
785
786 /* NextOp points to the op that holds the SpaceID */
787
788 NextOp = Op->Common.Value.Arg;
789
790 /* NextOp points to address op */
791
792 NextOp = NextOp->Common.Next;
793
794 /* Evaluate/create the address and length operands */
795
796 Status = AcpiDsCreateOperands (WalkState, NextOp);
797 if (ACPI_FAILURE (Status))
798 {
799 return_ACPI_STATUS (Status);
800 }
801
802 /* Resolve the length and address operands to numbers */
803
804 Status = AcpiExResolveOperands (Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState);
805 if (ACPI_FAILURE (Status))
806 {
807 return_ACPI_STATUS (Status);
808 }
809
810 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
811 AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
812 1, "after AcpiExResolveOperands");
813
814 ObjDesc = AcpiNsGetAttachedObject (Node);
815 if (!ObjDesc)
816 {
817 return_ACPI_STATUS (AE_NOT_EXIST);
818 }
819
820 /*
821 * Get the length operand and save it
822 * (at Top of stack)
823 */
824 OperandDesc = WalkState->Operands[WalkState->NumOperands - 1];
825
826 ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value;
827 AcpiUtRemoveReference (OperandDesc);
828
829 /*
830 * Get the address and save it
831 * (at top of stack - 1)
832 */
833 OperandDesc = WalkState->Operands[WalkState->NumOperands - 2];
834
835 ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) OperandDesc->Integer.Value;
836 AcpiUtRemoveReference (OperandDesc);
837
838 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
839 ObjDesc,
619 Status = AE_AML_BUFFER_LIMIT;
620 goto Cleanup;
621 }
622
623 /*
624 * Initialize areas of the field object that are common to all fields
625 * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE)
626 */
627 Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0,
628 BitOffset, BitCount);
629 if (ACPI_FAILURE (Status))
630 {
631 goto Cleanup;
632 }
633
634 ObjDesc->BufferField.BufferObj = BufferDesc;
635
636 /* Reference count for BufferDesc inherits ObjDesc count */
637
638 BufferDesc->Common.ReferenceCount = (UINT16) (BufferDesc->Common.ReferenceCount +
639 ObjDesc->Common.ReferenceCount);
640
641
642Cleanup:
643
644 /* Always delete the operands */
645
646 AcpiUtRemoveReference (OffsetDesc);
647 AcpiUtRemoveReference (BufferDesc);
648
649 if (AmlOpcode == AML_CREATE_FIELD_OP)
650 {
651 AcpiUtRemoveReference (LengthDesc);
652 }
653
654 /* On failure, delete the result descriptor */
655
656 if (ACPI_FAILURE (Status))
657 {
658 AcpiUtRemoveReference (ResultDesc); /* Result descriptor */
659 }
660 else
661 {
662 /* Now the address and length are valid for this BufferField */
663
664 ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID;
665 }
666
667 return_ACPI_STATUS (Status);
668}
669
670
671/*****************************************************************************
672 *
673 * FUNCTION: AcpiDsEvalBufferFieldOperands
674 *
675 * PARAMETERS: WalkState - Current walk
676 * Op - A valid BufferField Op object
677 *
678 * RETURN: Status
679 *
680 * DESCRIPTION: Get BufferField Buffer and Index
681 * Called from AcpiDsExecEndOp during BufferField parse tree walk
682 *
683 ****************************************************************************/
684
685ACPI_STATUS
686AcpiDsEvalBufferFieldOperands (
687 ACPI_WALK_STATE *WalkState,
688 ACPI_PARSE_OBJECT *Op)
689{
690 ACPI_STATUS Status;
691 ACPI_OPERAND_OBJECT *ObjDesc;
692 ACPI_NAMESPACE_NODE *Node;
693 ACPI_PARSE_OBJECT *NextOp;
694
695
696 ACPI_FUNCTION_TRACE_PTR ("DsEvalBufferFieldOperands", Op);
697
698
699 /*
700 * This is where we evaluate the address and length fields of the
701 * CreateXxxField declaration
702 */
703 Node = Op->Common.Node;
704
705 /* NextOp points to the op that holds the Buffer */
706
707 NextOp = Op->Common.Value.Arg;
708
709 /* Evaluate/create the address and length operands */
710
711 Status = AcpiDsCreateOperands (WalkState, NextOp);
712 if (ACPI_FAILURE (Status))
713 {
714 return_ACPI_STATUS (Status);
715 }
716
717 ObjDesc = AcpiNsGetAttachedObject (Node);
718 if (!ObjDesc)
719 {
720 return_ACPI_STATUS (AE_NOT_EXIST);
721 }
722
723 /* Resolve the operands */
724
725 Status = AcpiExResolveOperands (Op->Common.AmlOpcode,
726 ACPI_WALK_OPERANDS, WalkState);
727
728 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
729 AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
730 WalkState->NumOperands, "after AcpiExResolveOperands");
731
732 if (ACPI_FAILURE (Status))
733 {
734 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n",
735 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status));
736
737 return_ACPI_STATUS (Status);
738 }
739
740 /* Initialize the Buffer Field */
741
742 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
743 {
744 /* NOTE: Slightly different operands for this opcode */
745
746 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,
747 WalkState->Operands[0], WalkState->Operands[1],
748 WalkState->Operands[2], WalkState->Operands[3]);
749 }
750 else
751 {
752 /* All other, CreateXxxField opcodes */
753
754 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,
755 WalkState->Operands[0], WalkState->Operands[1],
756 NULL, WalkState->Operands[2]);
757 }
758
759 return_ACPI_STATUS (Status);
760}
761
762
763/*****************************************************************************
764 *
765 * FUNCTION: AcpiDsEvalRegionOperands
766 *
767 * PARAMETERS: WalkState - Current walk
768 * Op - A valid region Op object
769 *
770 * RETURN: Status
771 *
772 * DESCRIPTION: Get region address and length
773 * Called from AcpiDsExecEndOp during OpRegion parse tree walk
774 *
775 ****************************************************************************/
776
777ACPI_STATUS
778AcpiDsEvalRegionOperands (
779 ACPI_WALK_STATE *WalkState,
780 ACPI_PARSE_OBJECT *Op)
781{
782 ACPI_STATUS Status;
783 ACPI_OPERAND_OBJECT *ObjDesc;
784 ACPI_OPERAND_OBJECT *OperandDesc;
785 ACPI_NAMESPACE_NODE *Node;
786 ACPI_PARSE_OBJECT *NextOp;
787
788
789 ACPI_FUNCTION_TRACE_PTR ("DsEvalRegionOperands", Op);
790
791
792 /*
793 * This is where we evaluate the address and length fields of the OpRegion declaration
794 */
795 Node = Op->Common.Node;
796
797 /* NextOp points to the op that holds the SpaceID */
798
799 NextOp = Op->Common.Value.Arg;
800
801 /* NextOp points to address op */
802
803 NextOp = NextOp->Common.Next;
804
805 /* Evaluate/create the address and length operands */
806
807 Status = AcpiDsCreateOperands (WalkState, NextOp);
808 if (ACPI_FAILURE (Status))
809 {
810 return_ACPI_STATUS (Status);
811 }
812
813 /* Resolve the length and address operands to numbers */
814
815 Status = AcpiExResolveOperands (Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState);
816 if (ACPI_FAILURE (Status))
817 {
818 return_ACPI_STATUS (Status);
819 }
820
821 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
822 AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
823 1, "after AcpiExResolveOperands");
824
825 ObjDesc = AcpiNsGetAttachedObject (Node);
826 if (!ObjDesc)
827 {
828 return_ACPI_STATUS (AE_NOT_EXIST);
829 }
830
831 /*
832 * Get the length operand and save it
833 * (at Top of stack)
834 */
835 OperandDesc = WalkState->Operands[WalkState->NumOperands - 1];
836
837 ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value;
838 AcpiUtRemoveReference (OperandDesc);
839
840 /*
841 * Get the address and save it
842 * (at top of stack - 1)
843 */
844 OperandDesc = WalkState->Operands[WalkState->NumOperands - 2];
845
846 ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) OperandDesc->Integer.Value;
847 AcpiUtRemoveReference (OperandDesc);
848
849 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
850 ObjDesc,
840 ACPI_HIDWORD (ObjDesc->Region.Address), ACPI_LODWORD (ObjDesc->Region.Address),
851 ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
841 ObjDesc->Region.Length));
842
843 /* Now the address and length are valid for this opregion */
844
845 ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID;
846
847 return_ACPI_STATUS (Status);
848}
849
850
851/*****************************************************************************
852 *
853 * FUNCTION: AcpiDsEvalDataObjectOperands
854 *
855 * PARAMETERS: WalkState - Current walk
856 * Op - A valid DataObject Op object
857 * ObjDesc - DataObject
858 *
859 * RETURN: Status
860 *
861 * DESCRIPTION: Get the operands and complete the following data objec types:
862 * Buffer
863 * Package
864 *
865 ****************************************************************************/
866
867ACPI_STATUS
868AcpiDsEvalDataObjectOperands (
869 ACPI_WALK_STATE *WalkState,
870 ACPI_PARSE_OBJECT *Op,
871 ACPI_OPERAND_OBJECT *ObjDesc)
872{
873 ACPI_STATUS Status;
874 ACPI_OPERAND_OBJECT *ArgDesc;
875 UINT32 Length;
876
877
878 ACPI_FUNCTION_TRACE ("DsEvalDataObjectOperands");
879
880
881 /* The first operand (for all of these data objects) is the length */
882
883 Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1);
884 if (ACPI_FAILURE (Status))
885 {
886 return_ACPI_STATUS (Status);
887 }
888
889 Status = AcpiExResolveOperands (WalkState->Opcode,
890 &(WalkState->Operands [WalkState->NumOperands -1]),
891 WalkState);
892 if (ACPI_FAILURE (Status))
893 {
894 return_ACPI_STATUS (Status);
895 }
896
897 /* Extract length operand */
898
899 ArgDesc = WalkState->Operands [WalkState->NumOperands - 1];
900 Length = (UINT32) ArgDesc->Integer.Value;
901
902 /* Cleanup for length operand */
903
904 Status = AcpiDsObjStackPop (1, WalkState);
905 if (ACPI_FAILURE (Status))
906 {
907 return_ACPI_STATUS (Status);
908 }
909
910 AcpiUtRemoveReference (ArgDesc);
911
912 /*
913 * Create the actual data object
914 */
915 switch (Op->Common.AmlOpcode)
916 {
917 case AML_BUFFER_OP:
918
919 Status = AcpiDsBuildInternalBufferObj (WalkState, Op, Length, &ObjDesc);
920 break;
921
922 case AML_PACKAGE_OP:
923 case AML_VAR_PACKAGE_OP:
924
925 Status = AcpiDsBuildInternalPackageObj (WalkState, Op, Length, &ObjDesc);
926 break;
927
928 default:
929 return_ACPI_STATUS (AE_AML_BAD_OPCODE);
930 }
931
932 if (ACPI_SUCCESS (Status))
933 {
934 /*
935 * Return the object in the WalkState, unless the parent is a package --
936 * in this case, the return object will be stored in the parse tree
937 * for the package.
938 */
939 if ((!Op->Common.Parent) ||
940 ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) &&
941 (Op->Common.Parent->Common.AmlOpcode != AML_VAR_PACKAGE_OP) &&
942 (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP)))
943 {
944 WalkState->ResultObj = ObjDesc;
945 }
946 }
947
948 return_ACPI_STATUS (Status);
949}
950
951
952/*******************************************************************************
953 *
954 * FUNCTION: AcpiDsExecBeginControlOp
955 *
956 * PARAMETERS: WalkList - The list that owns the walk stack
957 * Op - The control Op
958 *
959 * RETURN: Status
960 *
961 * DESCRIPTION: Handles all control ops encountered during control method
962 * execution.
963 *
964 ******************************************************************************/
965
966ACPI_STATUS
967AcpiDsExecBeginControlOp (
968 ACPI_WALK_STATE *WalkState,
969 ACPI_PARSE_OBJECT *Op)
970{
971 ACPI_STATUS Status = AE_OK;
972 ACPI_GENERIC_STATE *ControlState;
973
974
975 ACPI_FUNCTION_NAME ("DsExecBeginControlOp");
976
977
978 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op,
979 Op->Common.AmlOpcode, WalkState));
980
981 switch (Op->Common.AmlOpcode)
982 {
983 case AML_IF_OP:
984 case AML_WHILE_OP:
985
986 /*
987 * IF/WHILE: Create a new control state to manage these
988 * constructs. We need to manage these as a stack, in order
989 * to handle nesting.
990 */
991 ControlState = AcpiUtCreateControlState ();
992 if (!ControlState)
993 {
994 Status = AE_NO_MEMORY;
995 break;
996 }
997 /*
998 * Save a pointer to the predicate for multiple executions
999 * of a loop
1000 */
1001 ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1;
1002 ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd;
1003 ControlState->Control.Opcode = Op->Common.AmlOpcode;
1004
1005
1006 /* Push the control state on this walk's control stack */
1007
1008 AcpiUtPushGenericState (&WalkState->ControlState, ControlState);
1009 break;
1010
1011 case AML_ELSE_OP:
1012
1013 /* Predicate is in the state object */
1014 /* If predicate is true, the IF was executed, ignore ELSE part */
1015
1016 if (WalkState->LastPredicate)
1017 {
1018 Status = AE_CTRL_TRUE;
1019 }
1020
1021 break;
1022
1023 case AML_RETURN_OP:
1024
1025 break;
1026
1027 default:
1028 break;
1029 }
1030
1031 return (Status);
1032}
1033
1034
1035/*******************************************************************************
1036 *
1037 * FUNCTION: AcpiDsExecEndControlOp
1038 *
1039 * PARAMETERS: WalkList - The list that owns the walk stack
1040 * Op - The control Op
1041 *
1042 * RETURN: Status
1043 *
1044 * DESCRIPTION: Handles all control ops encountered during control method
1045 * execution.
1046 *
1047 ******************************************************************************/
1048
1049ACPI_STATUS
1050AcpiDsExecEndControlOp (
1051 ACPI_WALK_STATE *WalkState,
1052 ACPI_PARSE_OBJECT *Op)
1053{
1054 ACPI_STATUS Status = AE_OK;
1055 ACPI_GENERIC_STATE *ControlState;
1056
1057
1058 ACPI_FUNCTION_NAME ("DsExecEndControlOp");
1059
1060
1061 switch (Op->Common.AmlOpcode)
1062 {
1063 case AML_IF_OP:
1064
1065 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op));
1066
1067 /*
1068 * Save the result of the predicate in case there is an
1069 * ELSE to come
1070 */
1071 WalkState->LastPredicate =
1072 (BOOLEAN) WalkState->ControlState->Common.Value;
1073
1074 /*
1075 * Pop the control state that was created at the start
1076 * of the IF and free it
1077 */
1078 ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
1079 AcpiUtDeleteGenericState (ControlState);
1080 break;
1081
1082
1083 case AML_ELSE_OP:
1084
1085 break;
1086
1087
1088 case AML_WHILE_OP:
1089
1090 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op));
1091
1092 if (WalkState->ControlState->Common.Value)
1093 {
1094 /* Predicate was true, go back and evaluate it again! */
1095
1096 Status = AE_CTRL_PENDING;
1097 }
1098
1099 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] termination! Op=%p\n", Op));
1100
1101 /* Pop this control state and free it */
1102
1103 ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
1104
1105 WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart;
1106 AcpiUtDeleteGenericState (ControlState);
1107 break;
1108
1109
1110 case AML_RETURN_OP:
1111
1112 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
1113 "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg));
1114
1115 /*
1116 * One optional operand -- the return value
1117 * It can be either an immediate operand or a result that
1118 * has been bubbled up the tree
1119 */
1120 if (Op->Common.Value.Arg)
1121 {
1122 /* Return statement has an immediate operand */
1123
1124 Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
1125 if (ACPI_FAILURE (Status))
1126 {
1127 return (Status);
1128 }
1129
1130 /*
1131 * If value being returned is a Reference (such as
1132 * an arg or local), resolve it now because it may
1133 * cease to exist at the end of the method.
1134 */
1135 Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState);
1136 if (ACPI_FAILURE (Status))
1137 {
1138 return (Status);
1139 }
1140
1141 /*
1142 * Get the return value and save as the last result
1143 * value. This is the only place where WalkState->ReturnDesc
1144 * is set to anything other than zero!
1145 */
1146 WalkState->ReturnDesc = WalkState->Operands[0];
1147 }
1148 else if ((WalkState->Results) &&
1149 (WalkState->Results->Results.NumResults > 0))
1150 {
1151 /*
1152 * The return value has come from a previous calculation.
1153 *
1154 * If value being returned is a Reference (such as
1155 * an arg or local), resolve it now because it may
1156 * cease to exist at the end of the method.
1157 *
1158 * Allow references created by the Index operator to return unchanged.
1159 */
1160 if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) &&
1161 (ACPI_GET_OBJECT_TYPE (WalkState->Results->Results.ObjDesc [0]) == ACPI_TYPE_LOCAL_REFERENCE) &&
1162 ((WalkState->Results->Results.ObjDesc [0])->Reference.Opcode != AML_INDEX_OP))
1163 {
1164 Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState);
1165 if (ACPI_FAILURE (Status))
1166 {
1167 return (Status);
1168 }
1169 }
1170
1171 WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0];
1172 }
1173 else
1174 {
1175 /* No return operand */
1176
1177 if (WalkState->NumOperands)
1178 {
1179 AcpiUtRemoveReference (WalkState->Operands [0]);
1180 }
1181
1182 WalkState->Operands [0] = NULL;
1183 WalkState->NumOperands = 0;
1184 WalkState->ReturnDesc = NULL;
1185 }
1186
1187
1188 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
1189 "Completed RETURN_OP State=%p, RetVal=%p\n",
1190 WalkState, WalkState->ReturnDesc));
1191
1192 /* End the control method execution right now */
1193
1194 Status = AE_CTRL_TERMINATE;
1195 break;
1196
1197
1198 case AML_NOOP_OP:
1199
1200 /* Just do nothing! */
1201 break;
1202
1203
1204 case AML_BREAK_POINT_OP:
1205
1206 /* Call up to the OS service layer to handle this */
1207
1208 Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode");
1209
1210 /* If and when it returns, all done. */
1211
1212 break;
1213
1214
1215 case AML_BREAK_OP:
1216 case AML_CONTINUE_OP: /* ACPI 2.0 */
1217
1218
1219 /* Pop and delete control states until we find a while */
1220
1221 while (WalkState->ControlState &&
1222 (WalkState->ControlState->Control.Opcode != AML_WHILE_OP))
1223 {
1224 ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
1225 AcpiUtDeleteGenericState (ControlState);
1226 }
1227
1228 /* No while found? */
1229
1230 if (!WalkState->ControlState)
1231 {
1232 return (AE_AML_NO_WHILE);
1233 }
1234
1235 /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */
1236
1237 WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd;
1238
1239 /* Return status depending on opcode */
1240
1241 if (Op->Common.AmlOpcode == AML_BREAK_OP)
1242 {
1243 Status = AE_CTRL_BREAK;
1244 }
1245 else
1246 {
1247 Status = AE_CTRL_CONTINUE;
1248 }
1249 break;
1250
1251
1252 default:
1253
1254 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n",
1255 Op->Common.AmlOpcode, Op));
1256
1257 Status = AE_AML_BAD_OPCODE;
1258 break;
1259 }
1260
1261 return (Status);
1262}
1263
852 ObjDesc->Region.Length));
853
854 /* Now the address and length are valid for this opregion */
855
856 ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID;
857
858 return_ACPI_STATUS (Status);
859}
860
861
862/*****************************************************************************
863 *
864 * FUNCTION: AcpiDsEvalDataObjectOperands
865 *
866 * PARAMETERS: WalkState - Current walk
867 * Op - A valid DataObject Op object
868 * ObjDesc - DataObject
869 *
870 * RETURN: Status
871 *
872 * DESCRIPTION: Get the operands and complete the following data objec types:
873 * Buffer
874 * Package
875 *
876 ****************************************************************************/
877
878ACPI_STATUS
879AcpiDsEvalDataObjectOperands (
880 ACPI_WALK_STATE *WalkState,
881 ACPI_PARSE_OBJECT *Op,
882 ACPI_OPERAND_OBJECT *ObjDesc)
883{
884 ACPI_STATUS Status;
885 ACPI_OPERAND_OBJECT *ArgDesc;
886 UINT32 Length;
887
888
889 ACPI_FUNCTION_TRACE ("DsEvalDataObjectOperands");
890
891
892 /* The first operand (for all of these data objects) is the length */
893
894 Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1);
895 if (ACPI_FAILURE (Status))
896 {
897 return_ACPI_STATUS (Status);
898 }
899
900 Status = AcpiExResolveOperands (WalkState->Opcode,
901 &(WalkState->Operands [WalkState->NumOperands -1]),
902 WalkState);
903 if (ACPI_FAILURE (Status))
904 {
905 return_ACPI_STATUS (Status);
906 }
907
908 /* Extract length operand */
909
910 ArgDesc = WalkState->Operands [WalkState->NumOperands - 1];
911 Length = (UINT32) ArgDesc->Integer.Value;
912
913 /* Cleanup for length operand */
914
915 Status = AcpiDsObjStackPop (1, WalkState);
916 if (ACPI_FAILURE (Status))
917 {
918 return_ACPI_STATUS (Status);
919 }
920
921 AcpiUtRemoveReference (ArgDesc);
922
923 /*
924 * Create the actual data object
925 */
926 switch (Op->Common.AmlOpcode)
927 {
928 case AML_BUFFER_OP:
929
930 Status = AcpiDsBuildInternalBufferObj (WalkState, Op, Length, &ObjDesc);
931 break;
932
933 case AML_PACKAGE_OP:
934 case AML_VAR_PACKAGE_OP:
935
936 Status = AcpiDsBuildInternalPackageObj (WalkState, Op, Length, &ObjDesc);
937 break;
938
939 default:
940 return_ACPI_STATUS (AE_AML_BAD_OPCODE);
941 }
942
943 if (ACPI_SUCCESS (Status))
944 {
945 /*
946 * Return the object in the WalkState, unless the parent is a package --
947 * in this case, the return object will be stored in the parse tree
948 * for the package.
949 */
950 if ((!Op->Common.Parent) ||
951 ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) &&
952 (Op->Common.Parent->Common.AmlOpcode != AML_VAR_PACKAGE_OP) &&
953 (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP)))
954 {
955 WalkState->ResultObj = ObjDesc;
956 }
957 }
958
959 return_ACPI_STATUS (Status);
960}
961
962
963/*******************************************************************************
964 *
965 * FUNCTION: AcpiDsExecBeginControlOp
966 *
967 * PARAMETERS: WalkList - The list that owns the walk stack
968 * Op - The control Op
969 *
970 * RETURN: Status
971 *
972 * DESCRIPTION: Handles all control ops encountered during control method
973 * execution.
974 *
975 ******************************************************************************/
976
977ACPI_STATUS
978AcpiDsExecBeginControlOp (
979 ACPI_WALK_STATE *WalkState,
980 ACPI_PARSE_OBJECT *Op)
981{
982 ACPI_STATUS Status = AE_OK;
983 ACPI_GENERIC_STATE *ControlState;
984
985
986 ACPI_FUNCTION_NAME ("DsExecBeginControlOp");
987
988
989 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op,
990 Op->Common.AmlOpcode, WalkState));
991
992 switch (Op->Common.AmlOpcode)
993 {
994 case AML_IF_OP:
995 case AML_WHILE_OP:
996
997 /*
998 * IF/WHILE: Create a new control state to manage these
999 * constructs. We need to manage these as a stack, in order
1000 * to handle nesting.
1001 */
1002 ControlState = AcpiUtCreateControlState ();
1003 if (!ControlState)
1004 {
1005 Status = AE_NO_MEMORY;
1006 break;
1007 }
1008 /*
1009 * Save a pointer to the predicate for multiple executions
1010 * of a loop
1011 */
1012 ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1;
1013 ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd;
1014 ControlState->Control.Opcode = Op->Common.AmlOpcode;
1015
1016
1017 /* Push the control state on this walk's control stack */
1018
1019 AcpiUtPushGenericState (&WalkState->ControlState, ControlState);
1020 break;
1021
1022 case AML_ELSE_OP:
1023
1024 /* Predicate is in the state object */
1025 /* If predicate is true, the IF was executed, ignore ELSE part */
1026
1027 if (WalkState->LastPredicate)
1028 {
1029 Status = AE_CTRL_TRUE;
1030 }
1031
1032 break;
1033
1034 case AML_RETURN_OP:
1035
1036 break;
1037
1038 default:
1039 break;
1040 }
1041
1042 return (Status);
1043}
1044
1045
1046/*******************************************************************************
1047 *
1048 * FUNCTION: AcpiDsExecEndControlOp
1049 *
1050 * PARAMETERS: WalkList - The list that owns the walk stack
1051 * Op - The control Op
1052 *
1053 * RETURN: Status
1054 *
1055 * DESCRIPTION: Handles all control ops encountered during control method
1056 * execution.
1057 *
1058 ******************************************************************************/
1059
1060ACPI_STATUS
1061AcpiDsExecEndControlOp (
1062 ACPI_WALK_STATE *WalkState,
1063 ACPI_PARSE_OBJECT *Op)
1064{
1065 ACPI_STATUS Status = AE_OK;
1066 ACPI_GENERIC_STATE *ControlState;
1067
1068
1069 ACPI_FUNCTION_NAME ("DsExecEndControlOp");
1070
1071
1072 switch (Op->Common.AmlOpcode)
1073 {
1074 case AML_IF_OP:
1075
1076 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op));
1077
1078 /*
1079 * Save the result of the predicate in case there is an
1080 * ELSE to come
1081 */
1082 WalkState->LastPredicate =
1083 (BOOLEAN) WalkState->ControlState->Common.Value;
1084
1085 /*
1086 * Pop the control state that was created at the start
1087 * of the IF and free it
1088 */
1089 ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
1090 AcpiUtDeleteGenericState (ControlState);
1091 break;
1092
1093
1094 case AML_ELSE_OP:
1095
1096 break;
1097
1098
1099 case AML_WHILE_OP:
1100
1101 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op));
1102
1103 if (WalkState->ControlState->Common.Value)
1104 {
1105 /* Predicate was true, go back and evaluate it again! */
1106
1107 Status = AE_CTRL_PENDING;
1108 }
1109
1110 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] termination! Op=%p\n", Op));
1111
1112 /* Pop this control state and free it */
1113
1114 ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
1115
1116 WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart;
1117 AcpiUtDeleteGenericState (ControlState);
1118 break;
1119
1120
1121 case AML_RETURN_OP:
1122
1123 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
1124 "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg));
1125
1126 /*
1127 * One optional operand -- the return value
1128 * It can be either an immediate operand or a result that
1129 * has been bubbled up the tree
1130 */
1131 if (Op->Common.Value.Arg)
1132 {
1133 /* Return statement has an immediate operand */
1134
1135 Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
1136 if (ACPI_FAILURE (Status))
1137 {
1138 return (Status);
1139 }
1140
1141 /*
1142 * If value being returned is a Reference (such as
1143 * an arg or local), resolve it now because it may
1144 * cease to exist at the end of the method.
1145 */
1146 Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState);
1147 if (ACPI_FAILURE (Status))
1148 {
1149 return (Status);
1150 }
1151
1152 /*
1153 * Get the return value and save as the last result
1154 * value. This is the only place where WalkState->ReturnDesc
1155 * is set to anything other than zero!
1156 */
1157 WalkState->ReturnDesc = WalkState->Operands[0];
1158 }
1159 else if ((WalkState->Results) &&
1160 (WalkState->Results->Results.NumResults > 0))
1161 {
1162 /*
1163 * The return value has come from a previous calculation.
1164 *
1165 * If value being returned is a Reference (such as
1166 * an arg or local), resolve it now because it may
1167 * cease to exist at the end of the method.
1168 *
1169 * Allow references created by the Index operator to return unchanged.
1170 */
1171 if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) &&
1172 (ACPI_GET_OBJECT_TYPE (WalkState->Results->Results.ObjDesc [0]) == ACPI_TYPE_LOCAL_REFERENCE) &&
1173 ((WalkState->Results->Results.ObjDesc [0])->Reference.Opcode != AML_INDEX_OP))
1174 {
1175 Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState);
1176 if (ACPI_FAILURE (Status))
1177 {
1178 return (Status);
1179 }
1180 }
1181
1182 WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0];
1183 }
1184 else
1185 {
1186 /* No return operand */
1187
1188 if (WalkState->NumOperands)
1189 {
1190 AcpiUtRemoveReference (WalkState->Operands [0]);
1191 }
1192
1193 WalkState->Operands [0] = NULL;
1194 WalkState->NumOperands = 0;
1195 WalkState->ReturnDesc = NULL;
1196 }
1197
1198
1199 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
1200 "Completed RETURN_OP State=%p, RetVal=%p\n",
1201 WalkState, WalkState->ReturnDesc));
1202
1203 /* End the control method execution right now */
1204
1205 Status = AE_CTRL_TERMINATE;
1206 break;
1207
1208
1209 case AML_NOOP_OP:
1210
1211 /* Just do nothing! */
1212 break;
1213
1214
1215 case AML_BREAK_POINT_OP:
1216
1217 /* Call up to the OS service layer to handle this */
1218
1219 Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode");
1220
1221 /* If and when it returns, all done. */
1222
1223 break;
1224
1225
1226 case AML_BREAK_OP:
1227 case AML_CONTINUE_OP: /* ACPI 2.0 */
1228
1229
1230 /* Pop and delete control states until we find a while */
1231
1232 while (WalkState->ControlState &&
1233 (WalkState->ControlState->Control.Opcode != AML_WHILE_OP))
1234 {
1235 ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
1236 AcpiUtDeleteGenericState (ControlState);
1237 }
1238
1239 /* No while found? */
1240
1241 if (!WalkState->ControlState)
1242 {
1243 return (AE_AML_NO_WHILE);
1244 }
1245
1246 /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */
1247
1248 WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd;
1249
1250 /* Return status depending on opcode */
1251
1252 if (Op->Common.AmlOpcode == AML_BREAK_OP)
1253 {
1254 Status = AE_CTRL_BREAK;
1255 }
1256 else
1257 {
1258 Status = AE_CTRL_CONTINUE;
1259 }
1260 break;
1261
1262
1263 default:
1264
1265 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n",
1266 Op->Common.AmlOpcode, Op));
1267
1268 Status = AE_AML_BAD_OPCODE;
1269 break;
1270 }
1271
1272 return (Status);
1273}
1274