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