Deleted Added
full compact
dsmthdat.c (99146) dsmthdat.c (99679)
1/*******************************************************************************
2 *
3 * Module Name: dsmthdat - control method arguments and local variables
1/*******************************************************************************
2 *
3 * Module Name: dsmthdat - control method arguments and local variables
4 * $Revision: 59 $
4 * $Revision: 62 $
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117#define __DSMTHDAT_C__
118
119#include "acpi.h"
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117#define __DSMTHDAT_C__
118
119#include "acpi.h"
120#include "acparser.h"
121#include "acdispat.h"
120#include "acdispat.h"
122#include "acinterp.h"
123#include "amlcode.h"
124#include "acnamesp.h"
125
126
127#define _COMPONENT ACPI_DISPATCHER
128 ACPI_MODULE_NAME ("dsmthdat")
129
130
131/*******************************************************************************
132 *
133 * FUNCTION: AcpiDsMethodDataInit
134 *
135 * PARAMETERS: WalkState - Current walk state object
136 *
137 * RETURN: Status
138 *
139 * DESCRIPTION: Initialize the data structures that hold the method's arguments
140 * and locals. The data struct is an array of NTEs for each.
141 * This allows RefOf and DeRefOf to work properly for these
142 * special data types.
143 *
144 * NOTES: WalkState fields are initialized to zero by the
145 * ACPI_MEM_CALLOCATE().
146 *
147 * A pseudo-Namespace Node is assigned to each argument and local
148 * so that RefOf() can return a pointer to the Node.
149 *
150 ******************************************************************************/
151
121#include "amlcode.h"
122#include "acnamesp.h"
123
124
125#define _COMPONENT ACPI_DISPATCHER
126 ACPI_MODULE_NAME ("dsmthdat")
127
128
129/*******************************************************************************
130 *
131 * FUNCTION: AcpiDsMethodDataInit
132 *
133 * PARAMETERS: WalkState - Current walk state object
134 *
135 * RETURN: Status
136 *
137 * DESCRIPTION: Initialize the data structures that hold the method's arguments
138 * and locals. The data struct is an array of NTEs for each.
139 * This allows RefOf and DeRefOf to work properly for these
140 * special data types.
141 *
142 * NOTES: WalkState fields are initialized to zero by the
143 * ACPI_MEM_CALLOCATE().
144 *
145 * A pseudo-Namespace Node is assigned to each argument and local
146 * so that RefOf() can return a pointer to the Node.
147 *
148 ******************************************************************************/
149
152ACPI_STATUS
150void
153AcpiDsMethodDataInit (
154 ACPI_WALK_STATE *WalkState)
155{
156 UINT32 i;
157
158
159 ACPI_FUNCTION_TRACE ("DsMethodDataInit");
160
161
162 /* Init the method arguments */
163
164 for (i = 0; i < MTH_NUM_ARGS; i++)
165 {
166 ACPI_MOVE_UNALIGNED32_TO_32 (&WalkState->Arguments[i].Name,
167 NAMEOF_ARG_NTE);
168 WalkState->Arguments[i].Name.Integer |= (i << 24);
169 WalkState->Arguments[i].Descriptor = ACPI_DESC_TYPE_NAMED;
170 WalkState->Arguments[i].Type = ACPI_TYPE_ANY;
171 WalkState->Arguments[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG;
172 }
173
174 /* Init the method locals */
175
176 for (i = 0; i < MTH_NUM_LOCALS; i++)
177 {
178 ACPI_MOVE_UNALIGNED32_TO_32 (&WalkState->LocalVariables[i].Name,
179 NAMEOF_LOCAL_NTE);
180
181 WalkState->LocalVariables[i].Name.Integer |= (i << 24);
182 WalkState->LocalVariables[i].Descriptor = ACPI_DESC_TYPE_NAMED;
183 WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY;
184 WalkState->LocalVariables[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL;
185 }
186
151AcpiDsMethodDataInit (
152 ACPI_WALK_STATE *WalkState)
153{
154 UINT32 i;
155
156
157 ACPI_FUNCTION_TRACE ("DsMethodDataInit");
158
159
160 /* Init the method arguments */
161
162 for (i = 0; i < MTH_NUM_ARGS; i++)
163 {
164 ACPI_MOVE_UNALIGNED32_TO_32 (&WalkState->Arguments[i].Name,
165 NAMEOF_ARG_NTE);
166 WalkState->Arguments[i].Name.Integer |= (i << 24);
167 WalkState->Arguments[i].Descriptor = ACPI_DESC_TYPE_NAMED;
168 WalkState->Arguments[i].Type = ACPI_TYPE_ANY;
169 WalkState->Arguments[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG;
170 }
171
172 /* Init the method locals */
173
174 for (i = 0; i < MTH_NUM_LOCALS; i++)
175 {
176 ACPI_MOVE_UNALIGNED32_TO_32 (&WalkState->LocalVariables[i].Name,
177 NAMEOF_LOCAL_NTE);
178
179 WalkState->LocalVariables[i].Name.Integer |= (i << 24);
180 WalkState->LocalVariables[i].Descriptor = ACPI_DESC_TYPE_NAMED;
181 WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY;
182 WalkState->LocalVariables[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL;
183 }
184
187 return_ACPI_STATUS (AE_OK);
185 return_VOID;
188}
189
190
191/*******************************************************************************
192 *
193 * FUNCTION: AcpiDsMethodDataDeleteAll
194 *
195 * PARAMETERS: WalkState - Current walk state object
196 *
186}
187
188
189/*******************************************************************************
190 *
191 * FUNCTION: AcpiDsMethodDataDeleteAll
192 *
193 * PARAMETERS: WalkState - Current walk state object
194 *
197 * RETURN: Status
195 * RETURN: None
198 *
199 * DESCRIPTION: Delete method locals and arguments. Arguments are only
200 * deleted if this method was called from another method.
201 *
202 ******************************************************************************/
203
196 *
197 * DESCRIPTION: Delete method locals and arguments. Arguments are only
198 * deleted if this method was called from another method.
199 *
200 ******************************************************************************/
201
204ACPI_STATUS
202void
205AcpiDsMethodDataDeleteAll (
206 ACPI_WALK_STATE *WalkState)
207{
208 UINT32 Index;
209
210
211 ACPI_FUNCTION_TRACE ("DsMethodDataDeleteAll");
212
213
214 /* Detach the locals */
215
216 for (Index = 0; Index < MTH_NUM_LOCALS; Index++)
217 {
218 if (WalkState->LocalVariables[Index].Object)
219 {
220 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n",
221 Index, WalkState->LocalVariables[Index].Object));
222
223 /* Detach object (if present) and remove a reference */
224
225 AcpiNsDetachObject (&WalkState->LocalVariables[Index]);
203AcpiDsMethodDataDeleteAll (
204 ACPI_WALK_STATE *WalkState)
205{
206 UINT32 Index;
207
208
209 ACPI_FUNCTION_TRACE ("DsMethodDataDeleteAll");
210
211
212 /* Detach the locals */
213
214 for (Index = 0; Index < MTH_NUM_LOCALS; Index++)
215 {
216 if (WalkState->LocalVariables[Index].Object)
217 {
218 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n",
219 Index, WalkState->LocalVariables[Index].Object));
220
221 /* Detach object (if present) and remove a reference */
222
223 AcpiNsDetachObject (&WalkState->LocalVariables[Index]);
226 }
224 }
227 }
228
229 /* Detach the arguments */
230
231 for (Index = 0; Index < MTH_NUM_ARGS; Index++)
232 {
233 if (WalkState->Arguments[Index].Object)
234 {
235 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n",
236 Index, WalkState->Arguments[Index].Object));
237
238 /* Detach object (if present) and remove a reference */
239
240 AcpiNsDetachObject (&WalkState->Arguments[Index]);
241 }
242 }
243
225 }
226
227 /* Detach the arguments */
228
229 for (Index = 0; Index < MTH_NUM_ARGS; Index++)
230 {
231 if (WalkState->Arguments[Index].Object)
232 {
233 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n",
234 Index, WalkState->Arguments[Index].Object));
235
236 /* Detach object (if present) and remove a reference */
237
238 AcpiNsDetachObject (&WalkState->Arguments[Index]);
239 }
240 }
241
244 return_ACPI_STATUS (AE_OK);
242 return_VOID;
245}
246
247
248/*******************************************************************************
249 *
250 * FUNCTION: AcpiDsMethodDataInitArgs
251 *
252 * PARAMETERS: *Params - Pointer to a parameter list for the method
253 * MaxParamCount - The arg count for this method
254 * WalkState - Current walk state object
255 *
256 * RETURN: Status
257 *
258 * DESCRIPTION: Initialize arguments for a method. The parameter list is a list
259 * of ACPI operand objects, either null terminated or whose length
260 * is defined by MaxParamCount.
261 *
262 ******************************************************************************/
263
264ACPI_STATUS
265AcpiDsMethodDataInitArgs (
266 ACPI_OPERAND_OBJECT **Params,
267 UINT32 MaxParamCount,
268 ACPI_WALK_STATE *WalkState)
269{
270 ACPI_STATUS Status;
271 UINT32 Index = 0;
272
273
274 ACPI_FUNCTION_TRACE_PTR ("DsMethodDataInitArgs", Params);
275
276
277 if (!Params)
278 {
279 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n"));
280 return_ACPI_STATUS (AE_OK);
281 }
282
283 /* Copy passed parameters into the new method stack frame */
284
285 while ((Index < MTH_NUM_ARGS) && (Index < MaxParamCount) && Params[Index])
286 {
287 /*
288 * A valid parameter.
289 * Store the argument in the method/walk descriptor
290 */
291 Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, Params[Index],
292 WalkState);
293 if (ACPI_FAILURE (Status))
294 {
295 return_ACPI_STATUS (Status);
296 }
297
298 Index++;
299 }
300
301 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", Index));
302 return_ACPI_STATUS (AE_OK);
303}
304
305
306/*******************************************************************************
307 *
308 * FUNCTION: AcpiDsMethodDataGetNode
309 *
310 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
311 * Index - Which localVar or argument whose type
312 * to get
313 * WalkState - Current walk state object
314 *
315 * RETURN: Get the Node associated with a local or arg.
316 *
317 ******************************************************************************/
318
319ACPI_STATUS
320AcpiDsMethodDataGetNode (
321 UINT16 Opcode,
322 UINT32 Index,
323 ACPI_WALK_STATE *WalkState,
324 ACPI_NAMESPACE_NODE **Node)
325{
326 ACPI_FUNCTION_TRACE ("DsMethodDataGetNode");
327
328
329 /*
330 * Method Locals and Arguments are supported
331 */
332 switch (Opcode)
333 {
334 case AML_LOCAL_OP:
335
336 if (Index > MTH_MAX_LOCAL)
337 {
338 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n",
339 Index, MTH_MAX_LOCAL));
340 return_ACPI_STATUS (AE_AML_INVALID_INDEX);
341 }
342
343 /* Return a pointer to the pseudo-node */
344
345 *Node = &WalkState->LocalVariables[Index];
346 break;
347
348 case AML_ARG_OP:
349
350 if (Index > MTH_MAX_ARG)
351 {
352 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n",
353 Index, MTH_MAX_ARG));
354 return_ACPI_STATUS (AE_AML_INVALID_INDEX);
355 }
356
357 /* Return a pointer to the pseudo-node */
358
359 *Node = &WalkState->Arguments[Index];
360 break;
361
362 default:
363 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", Opcode));
364 return_ACPI_STATUS (AE_AML_BAD_OPCODE);
365 }
366
367 return_ACPI_STATUS (AE_OK);
368}
369
370
371/*******************************************************************************
372 *
373 * FUNCTION: AcpiDsMethodDataSetValue
374 *
375 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
376 * Index - Which localVar or argument to get
377 * Object - Object to be inserted into the stack entry
378 * WalkState - Current walk state object
379 *
380 * RETURN: Status
381 *
382 * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index.
383 *
384 ******************************************************************************/
385
386ACPI_STATUS
387AcpiDsMethodDataSetValue (
388 UINT16 Opcode,
389 UINT32 Index,
390 ACPI_OPERAND_OBJECT *Object,
391 ACPI_WALK_STATE *WalkState)
392{
393 ACPI_STATUS Status;
394 ACPI_NAMESPACE_NODE *Node;
395
396
397 ACPI_FUNCTION_TRACE ("DsMethodDataSetValue");
398
399
400 /* Get the namespace node for the arg/local */
401
402 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
403 if (ACPI_FAILURE (Status))
404 {
405 return_ACPI_STATUS (Status);
406 }
407
408 /* Increment ref count so object can't be deleted while installed */
409
410 AcpiUtAddReference (Object);
411
412 /* Install the object into the stack entry */
413
414 Node->Object = Object;
415 return_ACPI_STATUS (AE_OK);
416}
417
418
419/*******************************************************************************
420 *
421 * FUNCTION: AcpiDsMethodDataGetType
422 *
423 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
424 * Index - Which localVar or argument whose type
425 * to get
426 * WalkState - Current walk state object
427 *
428 * RETURN: Data type of current value of the selected Arg or Local
429 *
430 ******************************************************************************/
431
432ACPI_OBJECT_TYPE
433AcpiDsMethodDataGetType (
434 UINT16 Opcode,
435 UINT32 Index,
436 ACPI_WALK_STATE *WalkState)
437{
438 ACPI_STATUS Status;
439 ACPI_NAMESPACE_NODE *Node;
440 ACPI_OPERAND_OBJECT *Object;
441
442
443 ACPI_FUNCTION_TRACE ("DsMethodDataGetType");
444
445
446 /* Get the namespace node for the arg/local */
447
448 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
449 if (ACPI_FAILURE (Status))
450 {
451 return_VALUE ((ACPI_TYPE_NOT_FOUND));
452 }
453
454 /* Get the object */
455
456 Object = AcpiNsGetAttachedObject (Node);
457 if (!Object)
458 {
459 /* Uninitialized local/arg, return TYPE_ANY */
460
461 return_VALUE (ACPI_TYPE_ANY);
462 }
463
464 /* Get the object type */
465
243}
244
245
246/*******************************************************************************
247 *
248 * FUNCTION: AcpiDsMethodDataInitArgs
249 *
250 * PARAMETERS: *Params - Pointer to a parameter list for the method
251 * MaxParamCount - The arg count for this method
252 * WalkState - Current walk state object
253 *
254 * RETURN: Status
255 *
256 * DESCRIPTION: Initialize arguments for a method. The parameter list is a list
257 * of ACPI operand objects, either null terminated or whose length
258 * is defined by MaxParamCount.
259 *
260 ******************************************************************************/
261
262ACPI_STATUS
263AcpiDsMethodDataInitArgs (
264 ACPI_OPERAND_OBJECT **Params,
265 UINT32 MaxParamCount,
266 ACPI_WALK_STATE *WalkState)
267{
268 ACPI_STATUS Status;
269 UINT32 Index = 0;
270
271
272 ACPI_FUNCTION_TRACE_PTR ("DsMethodDataInitArgs", Params);
273
274
275 if (!Params)
276 {
277 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n"));
278 return_ACPI_STATUS (AE_OK);
279 }
280
281 /* Copy passed parameters into the new method stack frame */
282
283 while ((Index < MTH_NUM_ARGS) && (Index < MaxParamCount) && Params[Index])
284 {
285 /*
286 * A valid parameter.
287 * Store the argument in the method/walk descriptor
288 */
289 Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, Params[Index],
290 WalkState);
291 if (ACPI_FAILURE (Status))
292 {
293 return_ACPI_STATUS (Status);
294 }
295
296 Index++;
297 }
298
299 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", Index));
300 return_ACPI_STATUS (AE_OK);
301}
302
303
304/*******************************************************************************
305 *
306 * FUNCTION: AcpiDsMethodDataGetNode
307 *
308 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
309 * Index - Which localVar or argument whose type
310 * to get
311 * WalkState - Current walk state object
312 *
313 * RETURN: Get the Node associated with a local or arg.
314 *
315 ******************************************************************************/
316
317ACPI_STATUS
318AcpiDsMethodDataGetNode (
319 UINT16 Opcode,
320 UINT32 Index,
321 ACPI_WALK_STATE *WalkState,
322 ACPI_NAMESPACE_NODE **Node)
323{
324 ACPI_FUNCTION_TRACE ("DsMethodDataGetNode");
325
326
327 /*
328 * Method Locals and Arguments are supported
329 */
330 switch (Opcode)
331 {
332 case AML_LOCAL_OP:
333
334 if (Index > MTH_MAX_LOCAL)
335 {
336 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n",
337 Index, MTH_MAX_LOCAL));
338 return_ACPI_STATUS (AE_AML_INVALID_INDEX);
339 }
340
341 /* Return a pointer to the pseudo-node */
342
343 *Node = &WalkState->LocalVariables[Index];
344 break;
345
346 case AML_ARG_OP:
347
348 if (Index > MTH_MAX_ARG)
349 {
350 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n",
351 Index, MTH_MAX_ARG));
352 return_ACPI_STATUS (AE_AML_INVALID_INDEX);
353 }
354
355 /* Return a pointer to the pseudo-node */
356
357 *Node = &WalkState->Arguments[Index];
358 break;
359
360 default:
361 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", Opcode));
362 return_ACPI_STATUS (AE_AML_BAD_OPCODE);
363 }
364
365 return_ACPI_STATUS (AE_OK);
366}
367
368
369/*******************************************************************************
370 *
371 * FUNCTION: AcpiDsMethodDataSetValue
372 *
373 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
374 * Index - Which localVar or argument to get
375 * Object - Object to be inserted into the stack entry
376 * WalkState - Current walk state object
377 *
378 * RETURN: Status
379 *
380 * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index.
381 *
382 ******************************************************************************/
383
384ACPI_STATUS
385AcpiDsMethodDataSetValue (
386 UINT16 Opcode,
387 UINT32 Index,
388 ACPI_OPERAND_OBJECT *Object,
389 ACPI_WALK_STATE *WalkState)
390{
391 ACPI_STATUS Status;
392 ACPI_NAMESPACE_NODE *Node;
393
394
395 ACPI_FUNCTION_TRACE ("DsMethodDataSetValue");
396
397
398 /* Get the namespace node for the arg/local */
399
400 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
401 if (ACPI_FAILURE (Status))
402 {
403 return_ACPI_STATUS (Status);
404 }
405
406 /* Increment ref count so object can't be deleted while installed */
407
408 AcpiUtAddReference (Object);
409
410 /* Install the object into the stack entry */
411
412 Node->Object = Object;
413 return_ACPI_STATUS (AE_OK);
414}
415
416
417/*******************************************************************************
418 *
419 * FUNCTION: AcpiDsMethodDataGetType
420 *
421 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
422 * Index - Which localVar or argument whose type
423 * to get
424 * WalkState - Current walk state object
425 *
426 * RETURN: Data type of current value of the selected Arg or Local
427 *
428 ******************************************************************************/
429
430ACPI_OBJECT_TYPE
431AcpiDsMethodDataGetType (
432 UINT16 Opcode,
433 UINT32 Index,
434 ACPI_WALK_STATE *WalkState)
435{
436 ACPI_STATUS Status;
437 ACPI_NAMESPACE_NODE *Node;
438 ACPI_OPERAND_OBJECT *Object;
439
440
441 ACPI_FUNCTION_TRACE ("DsMethodDataGetType");
442
443
444 /* Get the namespace node for the arg/local */
445
446 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
447 if (ACPI_FAILURE (Status))
448 {
449 return_VALUE ((ACPI_TYPE_NOT_FOUND));
450 }
451
452 /* Get the object */
453
454 Object = AcpiNsGetAttachedObject (Node);
455 if (!Object)
456 {
457 /* Uninitialized local/arg, return TYPE_ANY */
458
459 return_VALUE (ACPI_TYPE_ANY);
460 }
461
462 /* Get the object type */
463
466 return_VALUE (Object->Common.Type);
464 return_VALUE (ACPI_GET_OBJECT_TYPE (Object));
467}
468
469
470/*******************************************************************************
471 *
472 * FUNCTION: AcpiDsMethodDataGetValue
473 *
474 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
475 * Index - Which localVar or argument to get
476 * WalkState - Current walk state object
477 * *DestDesc - Ptr to Descriptor into which selected Arg
478 * or Local value should be copied
479 *
480 * RETURN: Status
481 *
482 * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame
483 * at the current top of the method stack.
484 * Used only in AcpiExResolveToValue().
485 *
486 ******************************************************************************/
487
488ACPI_STATUS
489AcpiDsMethodDataGetValue (
490 UINT16 Opcode,
491 UINT32 Index,
492 ACPI_WALK_STATE *WalkState,
493 ACPI_OPERAND_OBJECT **DestDesc)
494{
495 ACPI_STATUS Status;
496 ACPI_NAMESPACE_NODE *Node;
497 ACPI_OPERAND_OBJECT *Object;
498
499
500 ACPI_FUNCTION_TRACE ("DsMethodDataGetValue");
501
502
503 /* Validate the object descriptor */
504
505 if (!DestDesc)
506 {
507 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null object descriptor pointer\n"));
508 return_ACPI_STATUS (AE_BAD_PARAMETER);
509 }
510
511 /* Get the namespace node for the arg/local */
512
513 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
514 if (ACPI_FAILURE (Status))
515 {
516 return_ACPI_STATUS (Status);
517 }
518
519 /* Get the object from the node */
520
521 Object = Node->Object;
522
523 /* Examine the returned object, it must be valid. */
524
525 if (!Object)
526 {
527 /*
528 * Index points to uninitialized object.
529 * This means that either 1) The expected argument was
530 * not passed to the method, or 2) A local variable
531 * was referenced by the method (via the ASL)
532 * before it was initialized. Either case is an error.
533 */
534 switch (Opcode)
535 {
536 case AML_ARG_OP:
537
538 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at node %p\n",
539 Index, Node));
540
541 return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
542
543 case AML_LOCAL_OP:
544
545 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at node %p\n",
546 Index, Node));
547
548 return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
465}
466
467
468/*******************************************************************************
469 *
470 * FUNCTION: AcpiDsMethodDataGetValue
471 *
472 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
473 * Index - Which localVar or argument to get
474 * WalkState - Current walk state object
475 * *DestDesc - Ptr to Descriptor into which selected Arg
476 * or Local value should be copied
477 *
478 * RETURN: Status
479 *
480 * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame
481 * at the current top of the method stack.
482 * Used only in AcpiExResolveToValue().
483 *
484 ******************************************************************************/
485
486ACPI_STATUS
487AcpiDsMethodDataGetValue (
488 UINT16 Opcode,
489 UINT32 Index,
490 ACPI_WALK_STATE *WalkState,
491 ACPI_OPERAND_OBJECT **DestDesc)
492{
493 ACPI_STATUS Status;
494 ACPI_NAMESPACE_NODE *Node;
495 ACPI_OPERAND_OBJECT *Object;
496
497
498 ACPI_FUNCTION_TRACE ("DsMethodDataGetValue");
499
500
501 /* Validate the object descriptor */
502
503 if (!DestDesc)
504 {
505 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null object descriptor pointer\n"));
506 return_ACPI_STATUS (AE_BAD_PARAMETER);
507 }
508
509 /* Get the namespace node for the arg/local */
510
511 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
512 if (ACPI_FAILURE (Status))
513 {
514 return_ACPI_STATUS (Status);
515 }
516
517 /* Get the object from the node */
518
519 Object = Node->Object;
520
521 /* Examine the returned object, it must be valid. */
522
523 if (!Object)
524 {
525 /*
526 * Index points to uninitialized object.
527 * This means that either 1) The expected argument was
528 * not passed to the method, or 2) A local variable
529 * was referenced by the method (via the ASL)
530 * before it was initialized. Either case is an error.
531 */
532 switch (Opcode)
533 {
534 case AML_ARG_OP:
535
536 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at node %p\n",
537 Index, Node));
538
539 return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
540
541 case AML_LOCAL_OP:
542
543 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at node %p\n",
544 Index, Node));
545
546 return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
547
548 default:
549 return_ACPI_STATUS (AE_AML_INTERNAL);
549 }
550 }
551
552 /*
553 * The Index points to an initialized and valid object.
554 * Return an additional reference to the object
555 */
556 *DestDesc = Object;
557 AcpiUtAddReference (Object);
558
559 return_ACPI_STATUS (AE_OK);
560}
561
562
563/*******************************************************************************
564 *
565 * FUNCTION: AcpiDsMethodDataDeleteValue
566 *
567 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
568 * Index - Which localVar or argument to delete
569 * WalkState - Current walk state object
570 *
550 }
551 }
552
553 /*
554 * The Index points to an initialized and valid object.
555 * Return an additional reference to the object
556 */
557 *DestDesc = Object;
558 AcpiUtAddReference (Object);
559
560 return_ACPI_STATUS (AE_OK);
561}
562
563
564/*******************************************************************************
565 *
566 * FUNCTION: AcpiDsMethodDataDeleteValue
567 *
568 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
569 * Index - Which localVar or argument to delete
570 * WalkState - Current walk state object
571 *
571 * RETURN: Status
572 * RETURN: None
572 *
573 * DESCRIPTION: Delete the entry at Opcode:Index on the method stack. Inserts
574 * a null into the stack slot after the object is deleted.
575 *
576 ******************************************************************************/
577
573 *
574 * DESCRIPTION: Delete the entry at Opcode:Index on the method stack. Inserts
575 * a null into the stack slot after the object is deleted.
576 *
577 ******************************************************************************/
578
578ACPI_STATUS
579void
579AcpiDsMethodDataDeleteValue (
580 UINT16 Opcode,
581 UINT32 Index,
582 ACPI_WALK_STATE *WalkState)
583{
584 ACPI_STATUS Status;
585 ACPI_NAMESPACE_NODE *Node;
586 ACPI_OPERAND_OBJECT *Object;
587
588
589 ACPI_FUNCTION_TRACE ("DsMethodDataDeleteValue");
590
591
592 /* Get the namespace node for the arg/local */
593
594 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
595 if (ACPI_FAILURE (Status))
596 {
580AcpiDsMethodDataDeleteValue (
581 UINT16 Opcode,
582 UINT32 Index,
583 ACPI_WALK_STATE *WalkState)
584{
585 ACPI_STATUS Status;
586 ACPI_NAMESPACE_NODE *Node;
587 ACPI_OPERAND_OBJECT *Object;
588
589
590 ACPI_FUNCTION_TRACE ("DsMethodDataDeleteValue");
591
592
593 /* Get the namespace node for the arg/local */
594
595 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
596 if (ACPI_FAILURE (Status))
597 {
597 return_ACPI_STATUS (Status);
598 return_VOID;
598 }
599
600 /* Get the associated object */
601
602 Object = AcpiNsGetAttachedObject (Node);
603
604 /*
605 * Undefine the Arg or Local by setting its descriptor
606 * pointer to NULL. Locals/Args can contain both
607 * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
608 */
609 Node->Object = NULL;
610
611 if ((Object) &&
599 }
600
601 /* Get the associated object */
602
603 Object = AcpiNsGetAttachedObject (Node);
604
605 /*
606 * Undefine the Arg or Local by setting its descriptor
607 * pointer to NULL. Locals/Args can contain both
608 * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
609 */
610 Node->Object = NULL;
611
612 if ((Object) &&
612 (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_INTERNAL))
613 (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_OPERAND))
613 {
614 /*
615 * There is a valid object.
616 * Decrement the reference count by one to balance the
617 * increment when the object was stored.
618 */
619 AcpiUtRemoveReference (Object);
620 }
621
614 {
615 /*
616 * There is a valid object.
617 * Decrement the reference count by one to balance the
618 * increment when the object was stored.
619 */
620 AcpiUtRemoveReference (Object);
621 }
622
622 return_ACPI_STATUS (AE_OK);
623 return_VOID;
623}
624
625
626/*******************************************************************************
627 *
628 * FUNCTION: AcpiDsStoreObjectToLocal
629 *
630 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
631 * Index - Which localVar or argument to set
632 * ObjDesc - Value to be stored
633 * WalkState - Current walk state
634 *
635 * RETURN: Status
636 *
637 * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed
638 * as the new value for the Arg or Local and the reference count
639 * for ObjDesc is incremented.
640 *
641 ******************************************************************************/
642
643ACPI_STATUS
644AcpiDsStoreObjectToLocal (
645 UINT16 Opcode,
646 UINT32 Index,
647 ACPI_OPERAND_OBJECT *ObjDesc,
648 ACPI_WALK_STATE *WalkState)
649{
650 ACPI_STATUS Status;
651 ACPI_NAMESPACE_NODE *Node;
652 ACPI_OPERAND_OBJECT *CurrentObjDesc;
653
654
655 ACPI_FUNCTION_TRACE ("DsStoreObjectToLocal");
656 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n",
657 Opcode, Index, ObjDesc));
658
659
660 /* Parameter validation */
661
662 if (!ObjDesc)
663 {
664 return_ACPI_STATUS (AE_BAD_PARAMETER);
665 }
666
667 /* Get the namespace node for the arg/local */
668
669 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
670 if (ACPI_FAILURE (Status))
671 {
672 return_ACPI_STATUS (Status);
673 }
674
675 CurrentObjDesc = AcpiNsGetAttachedObject (Node);
676 if (CurrentObjDesc == ObjDesc)
677 {
678 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", ObjDesc));
679 return_ACPI_STATUS (Status);
680 }
681
682 /*
683 * If there is an object already in this slot, we either
684 * have to delete it, or if this is an argument and there
685 * is an object reference stored there, we have to do
686 * an indirect store!
687 */
688 if (CurrentObjDesc)
689 {
690 /*
691 * Check for an indirect store if an argument
692 * contains an object reference (stored as an Node).
693 * We don't allow this automatic dereferencing for
694 * locals, since a store to a local should overwrite
695 * anything there, including an object reference.
696 *
697 * If both Arg0 and Local0 contain RefOf (Local4):
698 *
699 * Store (1, Arg0) - Causes indirect store to local4
700 * Store (1, Local0) - Stores 1 in local0, overwriting
701 * the reference to local4
702 * Store (1, DeRefof (Local0)) - Causes indirect store to local4
703 *
704 * Weird, but true.
705 */
706 if ((Opcode == AML_ARG_OP) &&
707 (ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) == ACPI_DESC_TYPE_NAMED))
708 {
709 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
710 "Arg (%p) is an ObjRef(Node), storing in node %p\n",
711 ObjDesc, CurrentObjDesc));
712
713 /* Detach an existing object from the Node */
714
715 AcpiNsDetachObject ((ACPI_NAMESPACE_NODE *) CurrentObjDesc);
716
717 /*
718 * Store this object into the Node
719 * (perform the indirect store)
720 */
721 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) CurrentObjDesc,
624}
625
626
627/*******************************************************************************
628 *
629 * FUNCTION: AcpiDsStoreObjectToLocal
630 *
631 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
632 * Index - Which localVar or argument to set
633 * ObjDesc - Value to be stored
634 * WalkState - Current walk state
635 *
636 * RETURN: Status
637 *
638 * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed
639 * as the new value for the Arg or Local and the reference count
640 * for ObjDesc is incremented.
641 *
642 ******************************************************************************/
643
644ACPI_STATUS
645AcpiDsStoreObjectToLocal (
646 UINT16 Opcode,
647 UINT32 Index,
648 ACPI_OPERAND_OBJECT *ObjDesc,
649 ACPI_WALK_STATE *WalkState)
650{
651 ACPI_STATUS Status;
652 ACPI_NAMESPACE_NODE *Node;
653 ACPI_OPERAND_OBJECT *CurrentObjDesc;
654
655
656 ACPI_FUNCTION_TRACE ("DsStoreObjectToLocal");
657 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n",
658 Opcode, Index, ObjDesc));
659
660
661 /* Parameter validation */
662
663 if (!ObjDesc)
664 {
665 return_ACPI_STATUS (AE_BAD_PARAMETER);
666 }
667
668 /* Get the namespace node for the arg/local */
669
670 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
671 if (ACPI_FAILURE (Status))
672 {
673 return_ACPI_STATUS (Status);
674 }
675
676 CurrentObjDesc = AcpiNsGetAttachedObject (Node);
677 if (CurrentObjDesc == ObjDesc)
678 {
679 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", ObjDesc));
680 return_ACPI_STATUS (Status);
681 }
682
683 /*
684 * If there is an object already in this slot, we either
685 * have to delete it, or if this is an argument and there
686 * is an object reference stored there, we have to do
687 * an indirect store!
688 */
689 if (CurrentObjDesc)
690 {
691 /*
692 * Check for an indirect store if an argument
693 * contains an object reference (stored as an Node).
694 * We don't allow this automatic dereferencing for
695 * locals, since a store to a local should overwrite
696 * anything there, including an object reference.
697 *
698 * If both Arg0 and Local0 contain RefOf (Local4):
699 *
700 * Store (1, Arg0) - Causes indirect store to local4
701 * Store (1, Local0) - Stores 1 in local0, overwriting
702 * the reference to local4
703 * Store (1, DeRefof (Local0)) - Causes indirect store to local4
704 *
705 * Weird, but true.
706 */
707 if ((Opcode == AML_ARG_OP) &&
708 (ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) == ACPI_DESC_TYPE_NAMED))
709 {
710 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
711 "Arg (%p) is an ObjRef(Node), storing in node %p\n",
712 ObjDesc, CurrentObjDesc));
713
714 /* Detach an existing object from the Node */
715
716 AcpiNsDetachObject ((ACPI_NAMESPACE_NODE *) CurrentObjDesc);
717
718 /*
719 * Store this object into the Node
720 * (perform the indirect store)
721 */
722 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) CurrentObjDesc,
722 ObjDesc, ObjDesc->Common.Type);
723 ObjDesc, ACPI_GET_OBJECT_TYPE (ObjDesc));
723 return_ACPI_STATUS (Status);
724 }
725
726 /*
727 * Delete the existing object
728 * before storing the new one
729 */
730 AcpiDsMethodDataDeleteValue (Opcode, Index, WalkState);
731 }
732
733 /*
734 * Install the ObjStack descriptor (*ObjDesc) into
735 * the descriptor for the Arg or Local.
736 * Install the new object in the stack entry
737 * (increments the object reference count by one)
738 */
739 Status = AcpiDsMethodDataSetValue (Opcode, Index, ObjDesc, WalkState);
740 return_ACPI_STATUS (Status);
741}
742
743
724 return_ACPI_STATUS (Status);
725 }
726
727 /*
728 * Delete the existing object
729 * before storing the new one
730 */
731 AcpiDsMethodDataDeleteValue (Opcode, Index, WalkState);
732 }
733
734 /*
735 * Install the ObjStack descriptor (*ObjDesc) into
736 * the descriptor for the Arg or Local.
737 * Install the new object in the stack entry
738 * (increments the object reference count by one)
739 */
740 Status = AcpiDsMethodDataSetValue (Opcode, Index, ObjDesc, WalkState);
741 return_ACPI_STATUS (Status);
742}
743
744