[ACPI] ACPICA 20060127
[deliverable/linux.git] / drivers / acpi / dispatcher / dsmthdat.c
CommitLineData
1da177e4
LT
1/*******************************************************************************
2 *
3 * Module Name: dsmthdat - control method arguments and local variables
4 *
5 ******************************************************************************/
6
7/*
4a90c7e8 8 * Copyright (C) 2000 - 2006, R. Byron Moore
1da177e4
LT
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
1da177e4
LT
44#include <acpi/acpi.h>
45#include <acpi/acdispat.h>
46#include <acpi/amlcode.h>
47#include <acpi/acnamesp.h>
48#include <acpi/acinterp.h>
49
1da177e4 50#define _COMPONENT ACPI_DISPATCHER
4be44fcd 51ACPI_MODULE_NAME("dsmthdat")
1da177e4 52
44f6c012 53/* Local prototypes */
44f6c012 54static void
4be44fcd
LB
55acpi_ds_method_data_delete_value(u16 opcode,
56 u32 index, struct acpi_walk_state *walk_state);
44f6c012
RM
57
58static acpi_status
4be44fcd
LB
59acpi_ds_method_data_set_value(u16 opcode,
60 u32 index,
61 union acpi_operand_object *object,
62 struct acpi_walk_state *walk_state);
44f6c012
RM
63
64#ifdef ACPI_OBSOLETE_FUNCTIONS
65acpi_object_type
4be44fcd
LB
66acpi_ds_method_data_get_type(u16 opcode,
67 u32 index, struct acpi_walk_state *walk_state);
44f6c012
RM
68#endif
69
1da177e4
LT
70/*******************************************************************************
71 *
72 * FUNCTION: acpi_ds_method_data_init
73 *
74 * PARAMETERS: walk_state - Current walk state object
75 *
76 * RETURN: Status
77 *
78 * DESCRIPTION: Initialize the data structures that hold the method's arguments
44f6c012
RM
79 * and locals. The data struct is an array of namespace nodes for
80 * each - this allows ref_of and de_ref_of to work properly for these
1da177e4
LT
81 * special data types.
82 *
83 * NOTES: walk_state fields are initialized to zero by the
84 * ACPI_MEM_CALLOCATE().
85 *
86 * A pseudo-Namespace Node is assigned to each argument and local
87 * so that ref_of() can return a pointer to the Node.
88 *
89 ******************************************************************************/
90
4be44fcd 91void acpi_ds_method_data_init(struct acpi_walk_state *walk_state)
1da177e4 92{
4be44fcd 93 u32 i;
1da177e4 94
4be44fcd 95 ACPI_FUNCTION_TRACE("ds_method_data_init");
1da177e4
LT
96
97 /* Init the method arguments */
98
99 for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) {
4be44fcd 100 ACPI_MOVE_32_TO_32(&walk_state->arguments[i].name,
1da177e4
LT
101 NAMEOF_ARG_NTE);
102 walk_state->arguments[i].name.integer |= (i << 24);
4be44fcd
LB
103 walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED;
104 walk_state->arguments[i].type = ACPI_TYPE_ANY;
105 walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST |
106 ANOBJ_METHOD_ARG;
1da177e4
LT
107 }
108
109 /* Init the method locals */
110
111 for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) {
4be44fcd 112 ACPI_MOVE_32_TO_32(&walk_state->local_variables[i].name,
1da177e4
LT
113 NAMEOF_LOCAL_NTE);
114
115 walk_state->local_variables[i].name.integer |= (i << 24);
4be44fcd
LB
116 walk_state->local_variables[i].descriptor =
117 ACPI_DESC_TYPE_NAMED;
118 walk_state->local_variables[i].type = ACPI_TYPE_ANY;
119 walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST |
120 ANOBJ_METHOD_LOCAL;
1da177e4
LT
121 }
122
123 return_VOID;
124}
125
1da177e4
LT
126/*******************************************************************************
127 *
128 * FUNCTION: acpi_ds_method_data_delete_all
129 *
130 * PARAMETERS: walk_state - Current walk state object
131 *
132 * RETURN: None
133 *
134 * DESCRIPTION: Delete method locals and arguments. Arguments are only
135 * deleted if this method was called from another method.
136 *
137 ******************************************************************************/
138
4be44fcd 139void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state)
1da177e4 140{
4be44fcd 141 u32 index;
1da177e4 142
4be44fcd 143 ACPI_FUNCTION_TRACE("ds_method_data_delete_all");
1da177e4
LT
144
145 /* Detach the locals */
146
147 for (index = 0; index < ACPI_METHOD_NUM_LOCALS; index++) {
148 if (walk_state->local_variables[index].object) {
4be44fcd
LB
149 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Local%d=%p\n",
150 index,
151 walk_state->local_variables[index].
152 object));
1da177e4
LT
153
154 /* Detach object (if present) and remove a reference */
155
4be44fcd
LB
156 acpi_ns_detach_object(&walk_state->
157 local_variables[index]);
1da177e4
LT
158 }
159 }
160
161 /* Detach the arguments */
162
163 for (index = 0; index < ACPI_METHOD_NUM_ARGS; index++) {
164 if (walk_state->arguments[index].object) {
4be44fcd
LB
165 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Arg%d=%p\n",
166 index,
167 walk_state->arguments[index].object));
1da177e4
LT
168
169 /* Detach object (if present) and remove a reference */
170
4be44fcd 171 acpi_ns_detach_object(&walk_state->arguments[index]);
1da177e4
LT
172 }
173 }
174
175 return_VOID;
176}
177
1da177e4
LT
178/*******************************************************************************
179 *
180 * FUNCTION: acpi_ds_method_data_init_args
181 *
182 * PARAMETERS: *Params - Pointer to a parameter list for the method
183 * max_param_count - The arg count for this method
184 * walk_state - Current walk state object
185 *
186 * RETURN: Status
187 *
188 * DESCRIPTION: Initialize arguments for a method. The parameter list is a list
189 * of ACPI operand objects, either null terminated or whose length
190 * is defined by max_param_count.
191 *
192 ******************************************************************************/
193
194acpi_status
4be44fcd
LB
195acpi_ds_method_data_init_args(union acpi_operand_object **params,
196 u32 max_param_count,
197 struct acpi_walk_state *walk_state)
1da177e4 198{
4be44fcd
LB
199 acpi_status status;
200 u32 index = 0;
1da177e4 201
4be44fcd 202 ACPI_FUNCTION_TRACE_PTR("ds_method_data_init_args", params);
1da177e4
LT
203
204 if (!params) {
4be44fcd
LB
205 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
206 "No param list passed to method\n"));
207 return_ACPI_STATUS(AE_OK);
1da177e4
LT
208 }
209
44f6c012 210 /* Copy passed parameters into the new method stack frame */
1da177e4 211
44f6c012 212 while ((index < ACPI_METHOD_NUM_ARGS) &&
4be44fcd 213 (index < max_param_count) && params[index]) {
1da177e4
LT
214 /*
215 * A valid parameter.
216 * Store the argument in the method/walk descriptor.
217 * Do not copy the arg in order to implement call by reference
218 */
4be44fcd
LB
219 status = acpi_ds_method_data_set_value(AML_ARG_OP, index,
220 params[index],
221 walk_state);
222 if (ACPI_FAILURE(status)) {
223 return_ACPI_STATUS(status);
1da177e4
LT
224 }
225
226 index++;
227 }
228
4be44fcd
LB
229 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%d args passed to method\n", index));
230 return_ACPI_STATUS(AE_OK);
1da177e4
LT
231}
232
1da177e4
LT
233/*******************************************************************************
234 *
235 * FUNCTION: acpi_ds_method_data_get_node
236 *
237 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
44f6c012 238 * Index - Which Local or Arg whose type to get
1da177e4 239 * walk_state - Current walk state object
44f6c012 240 * Node - Where the node is returned.
1da177e4 241 *
44f6c012
RM
242 * RETURN: Status and node
243 *
244 * DESCRIPTION: Get the Node associated with a local or arg.
1da177e4
LT
245 *
246 ******************************************************************************/
247
248acpi_status
4be44fcd
LB
249acpi_ds_method_data_get_node(u16 opcode,
250 u32 index,
251 struct acpi_walk_state *walk_state,
252 struct acpi_namespace_node **node)
1da177e4 253{
4be44fcd 254 ACPI_FUNCTION_TRACE("ds_method_data_get_node");
1da177e4
LT
255
256 /*
257 * Method Locals and Arguments are supported
258 */
259 switch (opcode) {
260 case AML_LOCAL_OP:
261
262 if (index > ACPI_METHOD_MAX_LOCAL) {
b8e4d893
BM
263 ACPI_ERROR((AE_INFO,
264 "Local index %d is invalid (max %d)",
265 index, ACPI_METHOD_MAX_LOCAL));
4be44fcd 266 return_ACPI_STATUS(AE_AML_INVALID_INDEX);
1da177e4
LT
267 }
268
269 /* Return a pointer to the pseudo-node */
270
271 *node = &walk_state->local_variables[index];
272 break;
273
274 case AML_ARG_OP:
275
276 if (index > ACPI_METHOD_MAX_ARG) {
b8e4d893
BM
277 ACPI_ERROR((AE_INFO,
278 "Arg index %d is invalid (max %d)",
279 index, ACPI_METHOD_MAX_ARG));
4be44fcd 280 return_ACPI_STATUS(AE_AML_INVALID_INDEX);
1da177e4
LT
281 }
282
283 /* Return a pointer to the pseudo-node */
284
285 *node = &walk_state->arguments[index];
286 break;
287
288 default:
b8e4d893 289 ACPI_ERROR((AE_INFO, "Opcode %d is invalid", opcode));
4be44fcd 290 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
1da177e4
LT
291 }
292
4be44fcd 293 return_ACPI_STATUS(AE_OK);
1da177e4
LT
294}
295
1da177e4
LT
296/*******************************************************************************
297 *
298 * FUNCTION: acpi_ds_method_data_set_value
299 *
300 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
44f6c012 301 * Index - Which Local or Arg to get
1da177e4
LT
302 * Object - Object to be inserted into the stack entry
303 * walk_state - Current walk state object
304 *
305 * RETURN: Status
306 *
307 * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index.
308 * Note: There is no "implicit conversion" for locals.
309 *
310 ******************************************************************************/
311
44f6c012 312static acpi_status
4be44fcd
LB
313acpi_ds_method_data_set_value(u16 opcode,
314 u32 index,
315 union acpi_operand_object *object,
316 struct acpi_walk_state *walk_state)
1da177e4 317{
4be44fcd
LB
318 acpi_status status;
319 struct acpi_namespace_node *node;
1da177e4 320
4be44fcd 321 ACPI_FUNCTION_TRACE("ds_method_data_set_value");
1da177e4 322
4be44fcd
LB
323 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
324 "new_obj %p Opcode %X, Refs=%d [%s]\n", object,
325 opcode, object->common.reference_count,
326 acpi_ut_get_type_name(object->common.type)));
1da177e4
LT
327
328 /* Get the namespace node for the arg/local */
329
4be44fcd
LB
330 status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
331 if (ACPI_FAILURE(status)) {
332 return_ACPI_STATUS(status);
1da177e4
LT
333 }
334
335 /*
336 * Increment ref count so object can't be deleted while installed.
337 * NOTE: We do not copy the object in order to preserve the call by
338 * reference semantics of ACPI Control Method invocation.
339 * (See ACPI specification 2.0_c)
340 */
4be44fcd 341 acpi_ut_add_reference(object);
1da177e4
LT
342
343 /* Install the object */
344
345 node->object = object;
4be44fcd 346 return_ACPI_STATUS(status);
1da177e4
LT
347}
348
1da177e4
LT
349/*******************************************************************************
350 *
351 * FUNCTION: acpi_ds_method_data_get_value
352 *
353 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
354 * Index - which local_var or argument to get
355 * walk_state - Current walk state object
44f6c012 356 * dest_desc - Where Arg or Local value is returned
1da177e4
LT
357 *
358 * RETURN: Status
359 *
44f6c012 360 * DESCRIPTION: Retrieve value of selected Arg or Local for this method
1da177e4
LT
361 * Used only in acpi_ex_resolve_to_value().
362 *
363 ******************************************************************************/
364
365acpi_status
4be44fcd
LB
366acpi_ds_method_data_get_value(u16 opcode,
367 u32 index,
368 struct acpi_walk_state *walk_state,
369 union acpi_operand_object **dest_desc)
1da177e4 370{
4be44fcd
LB
371 acpi_status status;
372 struct acpi_namespace_node *node;
373 union acpi_operand_object *object;
1da177e4 374
4be44fcd 375 ACPI_FUNCTION_TRACE("ds_method_data_get_value");
1da177e4
LT
376
377 /* Validate the object descriptor */
378
379 if (!dest_desc) {
b8e4d893 380 ACPI_ERROR((AE_INFO, "Null object descriptor pointer"));
4be44fcd 381 return_ACPI_STATUS(AE_BAD_PARAMETER);
1da177e4
LT
382 }
383
384 /* Get the namespace node for the arg/local */
385
4be44fcd
LB
386 status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
387 if (ACPI_FAILURE(status)) {
388 return_ACPI_STATUS(status);
1da177e4
LT
389 }
390
391 /* Get the object from the node */
392
393 object = node->object;
394
395 /* Examine the returned object, it must be valid. */
396
397 if (!object) {
398 /*
399 * Index points to uninitialized object.
400 * This means that either 1) The expected argument was
401 * not passed to the method, or 2) A local variable
402 * was referenced by the method (via the ASL)
403 * before it was initialized. Either case is an error.
404 */
405
406 /* If slack enabled, init the local_x/arg_x to an Integer of value zero */
407
408 if (acpi_gbl_enable_interpreter_slack) {
4be44fcd
LB
409 object =
410 acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
1da177e4 411 if (!object) {
4be44fcd 412 return_ACPI_STATUS(AE_NO_MEMORY);
1da177e4
LT
413 }
414
415 object->integer.value = 0;
416 node->object = object;
417 }
418
419 /* Otherwise, return the error */
420
4be44fcd
LB
421 else
422 switch (opcode) {
423 case AML_ARG_OP:
1da177e4 424
b8e4d893
BM
425 ACPI_ERROR((AE_INFO,
426 "Uninitialized Arg[%d] at node %p",
427 index, node));
1da177e4 428
4be44fcd 429 return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG);
1da177e4 430
4be44fcd 431 case AML_LOCAL_OP:
1da177e4 432
b8e4d893
BM
433 ACPI_ERROR((AE_INFO,
434 "Uninitialized Local[%d] at node %p",
435 index, node));
1da177e4 436
4be44fcd 437 return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL);
1da177e4 438
4be44fcd 439 default:
b8e4d893
BM
440 ACPI_ERROR((AE_INFO,
441 "Not a Arg/Local opcode: %X",
442 opcode));
4be44fcd
LB
443 return_ACPI_STATUS(AE_AML_INTERNAL);
444 }
1da177e4
LT
445 }
446
447 /*
448 * The Index points to an initialized and valid object.
449 * Return an additional reference to the object
450 */
451 *dest_desc = object;
4be44fcd 452 acpi_ut_add_reference(object);
1da177e4 453
4be44fcd 454 return_ACPI_STATUS(AE_OK);
1da177e4
LT
455}
456
1da177e4
LT
457/*******************************************************************************
458 *
459 * FUNCTION: acpi_ds_method_data_delete_value
460 *
461 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
462 * Index - which local_var or argument to delete
463 * walk_state - Current walk state object
464 *
465 * RETURN: None
466 *
44f6c012 467 * DESCRIPTION: Delete the entry at Opcode:Index. Inserts
1da177e4
LT
468 * a null into the stack slot after the object is deleted.
469 *
470 ******************************************************************************/
471
44f6c012 472static void
4be44fcd
LB
473acpi_ds_method_data_delete_value(u16 opcode,
474 u32 index, struct acpi_walk_state *walk_state)
1da177e4 475{
4be44fcd
LB
476 acpi_status status;
477 struct acpi_namespace_node *node;
478 union acpi_operand_object *object;
1da177e4 479
4be44fcd 480 ACPI_FUNCTION_TRACE("ds_method_data_delete_value");
1da177e4
LT
481
482 /* Get the namespace node for the arg/local */
483
4be44fcd
LB
484 status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
485 if (ACPI_FAILURE(status)) {
1da177e4
LT
486 return_VOID;
487 }
488
489 /* Get the associated object */
490
4be44fcd 491 object = acpi_ns_get_attached_object(node);
1da177e4
LT
492
493 /*
494 * Undefine the Arg or Local by setting its descriptor
495 * pointer to NULL. Locals/Args can contain both
496 * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
497 */
498 node->object = NULL;
499
500 if ((object) &&
4be44fcd 501 (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_OPERAND)) {
1da177e4
LT
502 /*
503 * There is a valid object.
504 * Decrement the reference count by one to balance the
505 * increment when the object was stored.
506 */
4be44fcd 507 acpi_ut_remove_reference(object);
1da177e4
LT
508 }
509
510 return_VOID;
511}
512
1da177e4
LT
513/*******************************************************************************
514 *
515 * FUNCTION: acpi_ds_store_object_to_local
516 *
517 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
44f6c012 518 * Index - Which Local or Arg to set
1da177e4
LT
519 * obj_desc - Value to be stored
520 * walk_state - Current walk state
521 *
522 * RETURN: Status
523 *
524 * DESCRIPTION: Store a value in an Arg or Local. The obj_desc is installed
525 * as the new value for the Arg or Local and the reference count
526 * for obj_desc is incremented.
527 *
528 ******************************************************************************/
529
530acpi_status
4be44fcd
LB
531acpi_ds_store_object_to_local(u16 opcode,
532 u32 index,
533 union acpi_operand_object *obj_desc,
534 struct acpi_walk_state *walk_state)
1da177e4 535{
4be44fcd
LB
536 acpi_status status;
537 struct acpi_namespace_node *node;
538 union acpi_operand_object *current_obj_desc;
539 union acpi_operand_object *new_obj_desc;
1da177e4 540
4be44fcd
LB
541 ACPI_FUNCTION_TRACE("ds_store_object_to_local");
542 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n",
543 opcode, index, obj_desc));
1da177e4
LT
544
545 /* Parameter validation */
546
547 if (!obj_desc) {
4be44fcd 548 return_ACPI_STATUS(AE_BAD_PARAMETER);
1da177e4
LT
549 }
550
551 /* Get the namespace node for the arg/local */
552
4be44fcd
LB
553 status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
554 if (ACPI_FAILURE(status)) {
555 return_ACPI_STATUS(status);
1da177e4
LT
556 }
557
4be44fcd 558 current_obj_desc = acpi_ns_get_attached_object(node);
1da177e4 559 if (current_obj_desc == obj_desc) {
4be44fcd
LB
560 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p already installed!\n",
561 obj_desc));
562 return_ACPI_STATUS(status);
1da177e4
LT
563 }
564
565 /*
566 * If the reference count on the object is more than one, we must
567 * take a copy of the object before we store. A reference count
568 * of exactly 1 means that the object was just created during the
569 * evaluation of an expression, and we can safely use it since it
570 * is not used anywhere else.
571 */
572 new_obj_desc = obj_desc;
573 if (obj_desc->common.reference_count > 1) {
4be44fcd
LB
574 status =
575 acpi_ut_copy_iobject_to_iobject(obj_desc, &new_obj_desc,
576 walk_state);
577 if (ACPI_FAILURE(status)) {
578 return_ACPI_STATUS(status);
1da177e4
LT
579 }
580 }
581
582 /*
583 * If there is an object already in this slot, we either
584 * have to delete it, or if this is an argument and there
585 * is an object reference stored there, we have to do
586 * an indirect store!
587 */
588 if (current_obj_desc) {
589 /*
590 * Check for an indirect store if an argument
591 * contains an object reference (stored as an Node).
592 * We don't allow this automatic dereferencing for
593 * locals, since a store to a local should overwrite
594 * anything there, including an object reference.
595 *
596 * If both Arg0 and Local0 contain ref_of (Local4):
597 *
598 * Store (1, Arg0) - Causes indirect store to local4
599 * Store (1, Local0) - Stores 1 in local0, overwriting
600 * the reference to local4
601 * Store (1, de_refof (Local0)) - Causes indirect store to local4
602 *
603 * Weird, but true.
604 */
605 if (opcode == AML_ARG_OP) {
1da177e4 606 /*
44f6c012
RM
607 * If we have a valid reference object that came from ref_of(),
608 * do the indirect store
1da177e4 609 */
4be44fcd
LB
610 if ((ACPI_GET_DESCRIPTOR_TYPE(current_obj_desc) ==
611 ACPI_DESC_TYPE_OPERAND)
612 && (current_obj_desc->common.type ==
613 ACPI_TYPE_LOCAL_REFERENCE)
614 && (current_obj_desc->reference.opcode ==
615 AML_REF_OF_OP)) {
616 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
617 "Arg (%p) is an obj_ref(Node), storing in node %p\n",
618 new_obj_desc,
619 current_obj_desc));
1da177e4
LT
620
621 /*
622 * Store this object to the Node (perform the indirect store)
623 * NOTE: No implicit conversion is performed, as per the ACPI
624 * specification rules on storing to Locals/Args.
625 */
4be44fcd
LB
626 status =
627 acpi_ex_store_object_to_node(new_obj_desc,
628 current_obj_desc->
629 reference.
630 object,
631 walk_state,
632 ACPI_NO_IMPLICIT_CONVERSION);
1da177e4
LT
633
634 /* Remove local reference if we copied the object above */
635
636 if (new_obj_desc != obj_desc) {
4be44fcd 637 acpi_ut_remove_reference(new_obj_desc);
1da177e4 638 }
4be44fcd 639 return_ACPI_STATUS(status);
1da177e4
LT
640 }
641 }
642
643 /*
644 * Delete the existing object
645 * before storing the new one
646 */
4be44fcd 647 acpi_ds_method_data_delete_value(opcode, index, walk_state);
1da177e4
LT
648 }
649
650 /*
651 * Install the Obj descriptor (*new_obj_desc) into
652 * the descriptor for the Arg or Local.
653 * (increments the object reference count by one)
654 */
4be44fcd
LB
655 status =
656 acpi_ds_method_data_set_value(opcode, index, new_obj_desc,
657 walk_state);
1da177e4
LT
658
659 /* Remove local reference if we copied the object above */
660
661 if (new_obj_desc != obj_desc) {
4be44fcd 662 acpi_ut_remove_reference(new_obj_desc);
1da177e4
LT
663 }
664
4be44fcd 665 return_ACPI_STATUS(status);
1da177e4
LT
666}
667
44f6c012
RM
668#ifdef ACPI_OBSOLETE_FUNCTIONS
669/*******************************************************************************
670 *
671 * FUNCTION: acpi_ds_method_data_get_type
672 *
673 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
674 * Index - Which Local or Arg whose type to get
675 * walk_state - Current walk state object
676 *
677 * RETURN: Data type of current value of the selected Arg or Local
678 *
679 * DESCRIPTION: Get the type of the object stored in the Local or Arg
680 *
681 ******************************************************************************/
682
683acpi_object_type
4be44fcd
LB
684acpi_ds_method_data_get_type(u16 opcode,
685 u32 index, struct acpi_walk_state *walk_state)
44f6c012 686{
4be44fcd
LB
687 acpi_status status;
688 struct acpi_namespace_node *node;
689 union acpi_operand_object *object;
44f6c012 690
4be44fcd 691 ACPI_FUNCTION_TRACE("ds_method_data_get_type");
44f6c012
RM
692
693 /* Get the namespace node for the arg/local */
694
4be44fcd
LB
695 status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
696 if (ACPI_FAILURE(status)) {
697 return_VALUE((ACPI_TYPE_NOT_FOUND));
44f6c012
RM
698 }
699
700 /* Get the object */
701
4be44fcd 702 object = acpi_ns_get_attached_object(node);
44f6c012
RM
703 if (!object) {
704 /* Uninitialized local/arg, return TYPE_ANY */
705
4be44fcd 706 return_VALUE(ACPI_TYPE_ANY);
44f6c012
RM
707 }
708
709 /* Get the object type */
710
4be44fcd 711 return_VALUE(ACPI_GET_OBJECT_TYPE(object));
44f6c012
RM
712}
713#endif
This page took 0.078894 seconds and 5 git commands to generate.