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