xref: /minix3/minix/drivers/power/acpi/dispatcher/dsmthdat.c (revision 29492bb71c7148a089a5afafa0c99409161218df)
1433d6423SLionel Sambuc /*******************************************************************************
2433d6423SLionel Sambuc  *
3433d6423SLionel Sambuc  * Module Name: dsmthdat - control method arguments and local variables
4433d6423SLionel Sambuc  *
5433d6423SLionel Sambuc  ******************************************************************************/
6433d6423SLionel Sambuc 
7*29492bb7SDavid van Moolenbroek /*
8*29492bb7SDavid van Moolenbroek  * Copyright (C) 2000 - 2014, Intel Corp.
9433d6423SLionel Sambuc  * All rights reserved.
10433d6423SLionel Sambuc  *
11*29492bb7SDavid van Moolenbroek  * Redistribution and use in source and binary forms, with or without
12*29492bb7SDavid van Moolenbroek  * modification, are permitted provided that the following conditions
13*29492bb7SDavid van Moolenbroek  * are met:
14*29492bb7SDavid van Moolenbroek  * 1. Redistributions of source code must retain the above copyright
15*29492bb7SDavid van Moolenbroek  *    notice, this list of conditions, and the following disclaimer,
16*29492bb7SDavid van Moolenbroek  *    without modification.
17*29492bb7SDavid van Moolenbroek  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18*29492bb7SDavid van Moolenbroek  *    substantially similar to the "NO WARRANTY" disclaimer below
19*29492bb7SDavid van Moolenbroek  *    ("Disclaimer") and any redistribution must be conditioned upon
20*29492bb7SDavid van Moolenbroek  *    including a substantially similar Disclaimer requirement for further
21*29492bb7SDavid van Moolenbroek  *    binary redistribution.
22*29492bb7SDavid van Moolenbroek  * 3. Neither the names of the above-listed copyright holders nor the names
23*29492bb7SDavid van Moolenbroek  *    of any contributors may be used to endorse or promote products derived
24*29492bb7SDavid van Moolenbroek  *    from this software without specific prior written permission.
25433d6423SLionel Sambuc  *
26*29492bb7SDavid van Moolenbroek  * Alternatively, this software may be distributed under the terms of the
27*29492bb7SDavid van Moolenbroek  * GNU General Public License ("GPL") version 2 as published by the Free
28*29492bb7SDavid van Moolenbroek  * Software Foundation.
29433d6423SLionel Sambuc  *
30*29492bb7SDavid van Moolenbroek  * NO WARRANTY
31*29492bb7SDavid van Moolenbroek  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32*29492bb7SDavid van Moolenbroek  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33*29492bb7SDavid van Moolenbroek  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34*29492bb7SDavid van Moolenbroek  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35*29492bb7SDavid van Moolenbroek  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36*29492bb7SDavid van Moolenbroek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37*29492bb7SDavid van Moolenbroek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38*29492bb7SDavid van Moolenbroek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39*29492bb7SDavid van Moolenbroek  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40*29492bb7SDavid van Moolenbroek  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41*29492bb7SDavid van Moolenbroek  * POSSIBILITY OF SUCH DAMAGES.
42*29492bb7SDavid van Moolenbroek  */
43433d6423SLionel Sambuc 
44433d6423SLionel Sambuc #include "acpi.h"
45433d6423SLionel Sambuc #include "accommon.h"
46433d6423SLionel Sambuc #include "acdispat.h"
47433d6423SLionel Sambuc #include "acnamesp.h"
48433d6423SLionel Sambuc #include "acinterp.h"
49433d6423SLionel Sambuc 
50433d6423SLionel Sambuc 
51433d6423SLionel Sambuc #define _COMPONENT          ACPI_DISPATCHER
52433d6423SLionel Sambuc         ACPI_MODULE_NAME    ("dsmthdat")
53433d6423SLionel Sambuc 
54433d6423SLionel Sambuc /* Local prototypes */
55433d6423SLionel Sambuc 
56433d6423SLionel Sambuc static void
57433d6423SLionel Sambuc AcpiDsMethodDataDeleteValue (
58433d6423SLionel Sambuc     UINT8                   Type,
59433d6423SLionel Sambuc     UINT32                  Index,
60433d6423SLionel Sambuc     ACPI_WALK_STATE         *WalkState);
61433d6423SLionel Sambuc 
62433d6423SLionel Sambuc static ACPI_STATUS
63433d6423SLionel Sambuc AcpiDsMethodDataSetValue (
64433d6423SLionel Sambuc     UINT8                   Type,
65433d6423SLionel Sambuc     UINT32                  Index,
66433d6423SLionel Sambuc     ACPI_OPERAND_OBJECT     *Object,
67433d6423SLionel Sambuc     ACPI_WALK_STATE         *WalkState);
68433d6423SLionel Sambuc 
69433d6423SLionel Sambuc #ifdef ACPI_OBSOLETE_FUNCTIONS
70433d6423SLionel Sambuc ACPI_OBJECT_TYPE
71433d6423SLionel Sambuc AcpiDsMethodDataGetType (
72433d6423SLionel Sambuc     UINT16                  Opcode,
73433d6423SLionel Sambuc     UINT32                  Index,
74433d6423SLionel Sambuc     ACPI_WALK_STATE         *WalkState);
75433d6423SLionel Sambuc #endif
76433d6423SLionel Sambuc 
77433d6423SLionel Sambuc 
78433d6423SLionel Sambuc /*******************************************************************************
79433d6423SLionel Sambuc  *
80433d6423SLionel Sambuc  * FUNCTION:    AcpiDsMethodDataInit
81433d6423SLionel Sambuc  *
82433d6423SLionel Sambuc  * PARAMETERS:  WalkState           - Current walk state object
83433d6423SLionel Sambuc  *
84433d6423SLionel Sambuc  * RETURN:      Status
85433d6423SLionel Sambuc  *
86433d6423SLionel Sambuc  * DESCRIPTION: Initialize the data structures that hold the method's arguments
87433d6423SLionel Sambuc  *              and locals. The data struct is an array of namespace nodes for
88433d6423SLionel Sambuc  *              each - this allows RefOf and DeRefOf to work properly for these
89433d6423SLionel Sambuc  *              special data types.
90433d6423SLionel Sambuc  *
91433d6423SLionel Sambuc  * NOTES:       WalkState fields are initialized to zero by the
92433d6423SLionel Sambuc  *              ACPI_ALLOCATE_ZEROED().
93433d6423SLionel Sambuc  *
94433d6423SLionel Sambuc  *              A pseudo-Namespace Node is assigned to each argument and local
95433d6423SLionel Sambuc  *              so that RefOf() can return a pointer to the Node.
96433d6423SLionel Sambuc  *
97433d6423SLionel Sambuc  ******************************************************************************/
98433d6423SLionel Sambuc 
99433d6423SLionel Sambuc void
AcpiDsMethodDataInit(ACPI_WALK_STATE * WalkState)100433d6423SLionel Sambuc AcpiDsMethodDataInit (
101433d6423SLionel Sambuc     ACPI_WALK_STATE         *WalkState)
102433d6423SLionel Sambuc {
103433d6423SLionel Sambuc     UINT32                  i;
104433d6423SLionel Sambuc 
105433d6423SLionel Sambuc 
106433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (DsMethodDataInit);
107433d6423SLionel Sambuc 
108433d6423SLionel Sambuc 
109433d6423SLionel Sambuc     /* Init the method arguments */
110433d6423SLionel Sambuc 
111433d6423SLionel Sambuc     for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
112433d6423SLionel Sambuc     {
113433d6423SLionel Sambuc         ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name, NAMEOF_ARG_NTE);
114433d6423SLionel Sambuc         WalkState->Arguments[i].Name.Integer |= (i << 24);
115433d6423SLionel Sambuc         WalkState->Arguments[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
116433d6423SLionel Sambuc         WalkState->Arguments[i].Type = ACPI_TYPE_ANY;
117433d6423SLionel Sambuc         WalkState->Arguments[i].Flags = ANOBJ_METHOD_ARG;
118433d6423SLionel Sambuc     }
119433d6423SLionel Sambuc 
120433d6423SLionel Sambuc     /* Init the method locals */
121433d6423SLionel Sambuc 
122433d6423SLionel Sambuc     for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
123433d6423SLionel Sambuc     {
124433d6423SLionel Sambuc         ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name, NAMEOF_LOCAL_NTE);
125433d6423SLionel Sambuc 
126433d6423SLionel Sambuc         WalkState->LocalVariables[i].Name.Integer |= (i << 24);
127433d6423SLionel Sambuc         WalkState->LocalVariables[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
128433d6423SLionel Sambuc         WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY;
129433d6423SLionel Sambuc         WalkState->LocalVariables[i].Flags = ANOBJ_METHOD_LOCAL;
130433d6423SLionel Sambuc     }
131433d6423SLionel Sambuc 
132433d6423SLionel Sambuc     return_VOID;
133433d6423SLionel Sambuc }
134433d6423SLionel Sambuc 
135433d6423SLionel Sambuc 
136433d6423SLionel Sambuc /*******************************************************************************
137433d6423SLionel Sambuc  *
138433d6423SLionel Sambuc  * FUNCTION:    AcpiDsMethodDataDeleteAll
139433d6423SLionel Sambuc  *
140433d6423SLionel Sambuc  * PARAMETERS:  WalkState           - Current walk state object
141433d6423SLionel Sambuc  *
142433d6423SLionel Sambuc  * RETURN:      None
143433d6423SLionel Sambuc  *
144433d6423SLionel Sambuc  * DESCRIPTION: Delete method locals and arguments. Arguments are only
145433d6423SLionel Sambuc  *              deleted if this method was called from another method.
146433d6423SLionel Sambuc  *
147433d6423SLionel Sambuc  ******************************************************************************/
148433d6423SLionel Sambuc 
149433d6423SLionel Sambuc void
AcpiDsMethodDataDeleteAll(ACPI_WALK_STATE * WalkState)150433d6423SLionel Sambuc AcpiDsMethodDataDeleteAll (
151433d6423SLionel Sambuc     ACPI_WALK_STATE         *WalkState)
152433d6423SLionel Sambuc {
153433d6423SLionel Sambuc     UINT32                  Index;
154433d6423SLionel Sambuc 
155433d6423SLionel Sambuc 
156433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (DsMethodDataDeleteAll);
157433d6423SLionel Sambuc 
158433d6423SLionel Sambuc 
159433d6423SLionel Sambuc     /* Detach the locals */
160433d6423SLionel Sambuc 
161433d6423SLionel Sambuc     for (Index = 0; Index < ACPI_METHOD_NUM_LOCALS; Index++)
162433d6423SLionel Sambuc     {
163433d6423SLionel Sambuc         if (WalkState->LocalVariables[Index].Object)
164433d6423SLionel Sambuc         {
165433d6423SLionel Sambuc             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%u=%p\n",
166433d6423SLionel Sambuc                     Index, WalkState->LocalVariables[Index].Object));
167433d6423SLionel Sambuc 
168433d6423SLionel Sambuc             /* Detach object (if present) and remove a reference */
169433d6423SLionel Sambuc 
170433d6423SLionel Sambuc             AcpiNsDetachObject (&WalkState->LocalVariables[Index]);
171433d6423SLionel Sambuc         }
172433d6423SLionel Sambuc     }
173433d6423SLionel Sambuc 
174433d6423SLionel Sambuc     /* Detach the arguments */
175433d6423SLionel Sambuc 
176433d6423SLionel Sambuc     for (Index = 0; Index < ACPI_METHOD_NUM_ARGS; Index++)
177433d6423SLionel Sambuc     {
178433d6423SLionel Sambuc         if (WalkState->Arguments[Index].Object)
179433d6423SLionel Sambuc         {
180433d6423SLionel Sambuc             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%u=%p\n",
181433d6423SLionel Sambuc                     Index, WalkState->Arguments[Index].Object));
182433d6423SLionel Sambuc 
183433d6423SLionel Sambuc             /* Detach object (if present) and remove a reference */
184433d6423SLionel Sambuc 
185433d6423SLionel Sambuc             AcpiNsDetachObject (&WalkState->Arguments[Index]);
186433d6423SLionel Sambuc         }
187433d6423SLionel Sambuc     }
188433d6423SLionel Sambuc 
189433d6423SLionel Sambuc     return_VOID;
190433d6423SLionel Sambuc }
191433d6423SLionel Sambuc 
192433d6423SLionel Sambuc 
193433d6423SLionel Sambuc /*******************************************************************************
194433d6423SLionel Sambuc  *
195433d6423SLionel Sambuc  * FUNCTION:    AcpiDsMethodDataInitArgs
196433d6423SLionel Sambuc  *
197433d6423SLionel Sambuc  * PARAMETERS:  *Params         - Pointer to a parameter list for the method
198433d6423SLionel Sambuc  *              MaxParamCount   - The arg count for this method
199433d6423SLionel Sambuc  *              WalkState       - Current walk state object
200433d6423SLionel Sambuc  *
201433d6423SLionel Sambuc  * RETURN:      Status
202433d6423SLionel Sambuc  *
203433d6423SLionel Sambuc  * DESCRIPTION: Initialize arguments for a method. The parameter list is a list
204433d6423SLionel Sambuc  *              of ACPI operand objects, either null terminated or whose length
205433d6423SLionel Sambuc  *              is defined by MaxParamCount.
206433d6423SLionel Sambuc  *
207433d6423SLionel Sambuc  ******************************************************************************/
208433d6423SLionel Sambuc 
209433d6423SLionel Sambuc ACPI_STATUS
AcpiDsMethodDataInitArgs(ACPI_OPERAND_OBJECT ** Params,UINT32 MaxParamCount,ACPI_WALK_STATE * WalkState)210433d6423SLionel Sambuc AcpiDsMethodDataInitArgs (
211433d6423SLionel Sambuc     ACPI_OPERAND_OBJECT     **Params,
212433d6423SLionel Sambuc     UINT32                  MaxParamCount,
213433d6423SLionel Sambuc     ACPI_WALK_STATE         *WalkState)
214433d6423SLionel Sambuc {
215433d6423SLionel Sambuc     ACPI_STATUS             Status;
216433d6423SLionel Sambuc     UINT32                  Index = 0;
217433d6423SLionel Sambuc 
218433d6423SLionel Sambuc 
219433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE_PTR (DsMethodDataInitArgs, Params);
220433d6423SLionel Sambuc 
221433d6423SLionel Sambuc 
222433d6423SLionel Sambuc     if (!Params)
223433d6423SLionel Sambuc     {
224433d6423SLionel Sambuc         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n"));
225433d6423SLionel Sambuc         return_ACPI_STATUS (AE_OK);
226433d6423SLionel Sambuc     }
227433d6423SLionel Sambuc 
228433d6423SLionel Sambuc     /* Copy passed parameters into the new method stack frame */
229433d6423SLionel Sambuc 
230433d6423SLionel Sambuc     while ((Index < ACPI_METHOD_NUM_ARGS) &&
231433d6423SLionel Sambuc            (Index < MaxParamCount)        &&
232433d6423SLionel Sambuc             Params[Index])
233433d6423SLionel Sambuc     {
234433d6423SLionel Sambuc         /*
235433d6423SLionel Sambuc          * A valid parameter.
236433d6423SLionel Sambuc          * Store the argument in the method/walk descriptor.
237433d6423SLionel Sambuc          * Do not copy the arg in order to implement call by reference
238433d6423SLionel Sambuc          */
239433d6423SLionel Sambuc         Status = AcpiDsMethodDataSetValue (ACPI_REFCLASS_ARG, Index,
240433d6423SLionel Sambuc                     Params[Index], WalkState);
241433d6423SLionel Sambuc         if (ACPI_FAILURE (Status))
242433d6423SLionel Sambuc         {
243433d6423SLionel Sambuc             return_ACPI_STATUS (Status);
244433d6423SLionel Sambuc         }
245433d6423SLionel Sambuc 
246433d6423SLionel Sambuc         Index++;
247433d6423SLionel Sambuc     }
248433d6423SLionel Sambuc 
249433d6423SLionel Sambuc     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%u args passed to method\n", Index));
250433d6423SLionel Sambuc     return_ACPI_STATUS (AE_OK);
251433d6423SLionel Sambuc }
252433d6423SLionel Sambuc 
253433d6423SLionel Sambuc 
254433d6423SLionel Sambuc /*******************************************************************************
255433d6423SLionel Sambuc  *
256433d6423SLionel Sambuc  * FUNCTION:    AcpiDsMethodDataGetNode
257433d6423SLionel Sambuc  *
258433d6423SLionel Sambuc  * PARAMETERS:  Type                - Either ACPI_REFCLASS_LOCAL or
259433d6423SLionel Sambuc  *                                    ACPI_REFCLASS_ARG
260433d6423SLionel Sambuc  *              Index               - Which Local or Arg whose type to get
261433d6423SLionel Sambuc  *              WalkState           - Current walk state object
262433d6423SLionel Sambuc  *              Node                - Where the node is returned.
263433d6423SLionel Sambuc  *
264433d6423SLionel Sambuc  * RETURN:      Status and node
265433d6423SLionel Sambuc  *
266433d6423SLionel Sambuc  * DESCRIPTION: Get the Node associated with a local or arg.
267433d6423SLionel Sambuc  *
268433d6423SLionel Sambuc  ******************************************************************************/
269433d6423SLionel Sambuc 
270433d6423SLionel Sambuc ACPI_STATUS
AcpiDsMethodDataGetNode(UINT8 Type,UINT32 Index,ACPI_WALK_STATE * WalkState,ACPI_NAMESPACE_NODE ** Node)271433d6423SLionel Sambuc AcpiDsMethodDataGetNode (
272433d6423SLionel Sambuc     UINT8                   Type,
273433d6423SLionel Sambuc     UINT32                  Index,
274433d6423SLionel Sambuc     ACPI_WALK_STATE         *WalkState,
275433d6423SLionel Sambuc     ACPI_NAMESPACE_NODE     **Node)
276433d6423SLionel Sambuc {
277433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (DsMethodDataGetNode);
278433d6423SLionel Sambuc 
279433d6423SLionel Sambuc 
280433d6423SLionel Sambuc     /*
281433d6423SLionel Sambuc      * Method Locals and Arguments are supported
282433d6423SLionel Sambuc      */
283433d6423SLionel Sambuc     switch (Type)
284433d6423SLionel Sambuc     {
285433d6423SLionel Sambuc     case ACPI_REFCLASS_LOCAL:
286433d6423SLionel Sambuc 
287433d6423SLionel Sambuc         if (Index > ACPI_METHOD_MAX_LOCAL)
288433d6423SLionel Sambuc         {
289433d6423SLionel Sambuc             ACPI_ERROR ((AE_INFO,
290433d6423SLionel Sambuc                 "Local index %u is invalid (max %u)",
291433d6423SLionel Sambuc                 Index, ACPI_METHOD_MAX_LOCAL));
292433d6423SLionel Sambuc             return_ACPI_STATUS (AE_AML_INVALID_INDEX);
293433d6423SLionel Sambuc         }
294433d6423SLionel Sambuc 
295433d6423SLionel Sambuc         /* Return a pointer to the pseudo-node */
296433d6423SLionel Sambuc 
297433d6423SLionel Sambuc         *Node = &WalkState->LocalVariables[Index];
298433d6423SLionel Sambuc         break;
299433d6423SLionel Sambuc 
300433d6423SLionel Sambuc     case ACPI_REFCLASS_ARG:
301433d6423SLionel Sambuc 
302433d6423SLionel Sambuc         if (Index > ACPI_METHOD_MAX_ARG)
303433d6423SLionel Sambuc         {
304433d6423SLionel Sambuc             ACPI_ERROR ((AE_INFO,
305433d6423SLionel Sambuc                 "Arg index %u is invalid (max %u)",
306433d6423SLionel Sambuc                 Index, ACPI_METHOD_MAX_ARG));
307433d6423SLionel Sambuc             return_ACPI_STATUS (AE_AML_INVALID_INDEX);
308433d6423SLionel Sambuc         }
309433d6423SLionel Sambuc 
310433d6423SLionel Sambuc         /* Return a pointer to the pseudo-node */
311433d6423SLionel Sambuc 
312433d6423SLionel Sambuc         *Node = &WalkState->Arguments[Index];
313433d6423SLionel Sambuc         break;
314433d6423SLionel Sambuc 
315433d6423SLionel Sambuc     default:
316*29492bb7SDavid van Moolenbroek 
317433d6423SLionel Sambuc         ACPI_ERROR ((AE_INFO, "Type %u is invalid", Type));
318433d6423SLionel Sambuc         return_ACPI_STATUS (AE_TYPE);
319433d6423SLionel Sambuc     }
320433d6423SLionel Sambuc 
321433d6423SLionel Sambuc     return_ACPI_STATUS (AE_OK);
322433d6423SLionel Sambuc }
323433d6423SLionel Sambuc 
324433d6423SLionel Sambuc 
325433d6423SLionel Sambuc /*******************************************************************************
326433d6423SLionel Sambuc  *
327433d6423SLionel Sambuc  * FUNCTION:    AcpiDsMethodDataSetValue
328433d6423SLionel Sambuc  *
329433d6423SLionel Sambuc  * PARAMETERS:  Type                - Either ACPI_REFCLASS_LOCAL or
330433d6423SLionel Sambuc  *                                    ACPI_REFCLASS_ARG
331433d6423SLionel Sambuc  *              Index               - Which Local or Arg to get
332433d6423SLionel Sambuc  *              Object              - Object to be inserted into the stack entry
333433d6423SLionel Sambuc  *              WalkState           - Current walk state object
334433d6423SLionel Sambuc  *
335433d6423SLionel Sambuc  * RETURN:      Status
336433d6423SLionel Sambuc  *
337433d6423SLionel Sambuc  * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index.
338433d6423SLionel Sambuc  *              Note: There is no "implicit conversion" for locals.
339433d6423SLionel Sambuc  *
340433d6423SLionel Sambuc  ******************************************************************************/
341433d6423SLionel Sambuc 
342433d6423SLionel Sambuc static ACPI_STATUS
AcpiDsMethodDataSetValue(UINT8 Type,UINT32 Index,ACPI_OPERAND_OBJECT * Object,ACPI_WALK_STATE * WalkState)343433d6423SLionel Sambuc AcpiDsMethodDataSetValue (
344433d6423SLionel Sambuc     UINT8                   Type,
345433d6423SLionel Sambuc     UINT32                  Index,
346433d6423SLionel Sambuc     ACPI_OPERAND_OBJECT     *Object,
347433d6423SLionel Sambuc     ACPI_WALK_STATE         *WalkState)
348433d6423SLionel Sambuc {
349433d6423SLionel Sambuc     ACPI_STATUS             Status;
350433d6423SLionel Sambuc     ACPI_NAMESPACE_NODE     *Node;
351433d6423SLionel Sambuc 
352433d6423SLionel Sambuc 
353433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (DsMethodDataSetValue);
354433d6423SLionel Sambuc 
355433d6423SLionel Sambuc 
356433d6423SLionel Sambuc     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
357433d6423SLionel Sambuc         "NewObj %p Type %2.2X, Refs=%u [%s]\n", Object,
358433d6423SLionel Sambuc         Type, Object->Common.ReferenceCount,
359433d6423SLionel Sambuc         AcpiUtGetTypeName (Object->Common.Type)));
360433d6423SLionel Sambuc 
361433d6423SLionel Sambuc     /* Get the namespace node for the arg/local */
362433d6423SLionel Sambuc 
363433d6423SLionel Sambuc     Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
364433d6423SLionel Sambuc     if (ACPI_FAILURE (Status))
365433d6423SLionel Sambuc     {
366433d6423SLionel Sambuc         return_ACPI_STATUS (Status);
367433d6423SLionel Sambuc     }
368433d6423SLionel Sambuc 
369433d6423SLionel Sambuc     /*
370433d6423SLionel Sambuc      * Increment ref count so object can't be deleted while installed.
371433d6423SLionel Sambuc      * NOTE: We do not copy the object in order to preserve the call by
372433d6423SLionel Sambuc      * reference semantics of ACPI Control Method invocation.
373433d6423SLionel Sambuc      * (See ACPI Specification 2.0C)
374433d6423SLionel Sambuc      */
375433d6423SLionel Sambuc     AcpiUtAddReference (Object);
376433d6423SLionel Sambuc 
377433d6423SLionel Sambuc     /* Install the object */
378433d6423SLionel Sambuc 
379433d6423SLionel Sambuc     Node->Object = Object;
380433d6423SLionel Sambuc     return_ACPI_STATUS (Status);
381433d6423SLionel Sambuc }
382433d6423SLionel Sambuc 
383433d6423SLionel Sambuc 
384433d6423SLionel Sambuc /*******************************************************************************
385433d6423SLionel Sambuc  *
386433d6423SLionel Sambuc  * FUNCTION:    AcpiDsMethodDataGetValue
387433d6423SLionel Sambuc  *
388433d6423SLionel Sambuc  * PARAMETERS:  Type                - Either ACPI_REFCLASS_LOCAL or
389433d6423SLionel Sambuc  *                                    ACPI_REFCLASS_ARG
390433d6423SLionel Sambuc  *              Index               - Which localVar or argument to get
391433d6423SLionel Sambuc  *              WalkState           - Current walk state object
392433d6423SLionel Sambuc  *              DestDesc            - Where Arg or Local value is returned
393433d6423SLionel Sambuc  *
394433d6423SLionel Sambuc  * RETURN:      Status
395433d6423SLionel Sambuc  *
396433d6423SLionel Sambuc  * DESCRIPTION: Retrieve value of selected Arg or Local for this method
397433d6423SLionel Sambuc  *              Used only in AcpiExResolveToValue().
398433d6423SLionel Sambuc  *
399433d6423SLionel Sambuc  ******************************************************************************/
400433d6423SLionel Sambuc 
401433d6423SLionel Sambuc ACPI_STATUS
AcpiDsMethodDataGetValue(UINT8 Type,UINT32 Index,ACPI_WALK_STATE * WalkState,ACPI_OPERAND_OBJECT ** DestDesc)402433d6423SLionel Sambuc AcpiDsMethodDataGetValue (
403433d6423SLionel Sambuc     UINT8                   Type,
404433d6423SLionel Sambuc     UINT32                  Index,
405433d6423SLionel Sambuc     ACPI_WALK_STATE         *WalkState,
406433d6423SLionel Sambuc     ACPI_OPERAND_OBJECT     **DestDesc)
407433d6423SLionel Sambuc {
408433d6423SLionel Sambuc     ACPI_STATUS             Status;
409433d6423SLionel Sambuc     ACPI_NAMESPACE_NODE     *Node;
410433d6423SLionel Sambuc     ACPI_OPERAND_OBJECT     *Object;
411433d6423SLionel Sambuc 
412433d6423SLionel Sambuc 
413433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (DsMethodDataGetValue);
414433d6423SLionel Sambuc 
415433d6423SLionel Sambuc 
416433d6423SLionel Sambuc     /* Validate the object descriptor */
417433d6423SLionel Sambuc 
418433d6423SLionel Sambuc     if (!DestDesc)
419433d6423SLionel Sambuc     {
420433d6423SLionel Sambuc         ACPI_ERROR ((AE_INFO, "Null object descriptor pointer"));
421433d6423SLionel Sambuc         return_ACPI_STATUS (AE_BAD_PARAMETER);
422433d6423SLionel Sambuc     }
423433d6423SLionel Sambuc 
424433d6423SLionel Sambuc     /* Get the namespace node for the arg/local */
425433d6423SLionel Sambuc 
426433d6423SLionel Sambuc     Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
427433d6423SLionel Sambuc     if (ACPI_FAILURE (Status))
428433d6423SLionel Sambuc     {
429433d6423SLionel Sambuc         return_ACPI_STATUS (Status);
430433d6423SLionel Sambuc     }
431433d6423SLionel Sambuc 
432433d6423SLionel Sambuc     /* Get the object from the node */
433433d6423SLionel Sambuc 
434433d6423SLionel Sambuc     Object = Node->Object;
435433d6423SLionel Sambuc 
436433d6423SLionel Sambuc     /* Examine the returned object, it must be valid. */
437433d6423SLionel Sambuc 
438433d6423SLionel Sambuc     if (!Object)
439433d6423SLionel Sambuc     {
440433d6423SLionel Sambuc         /*
441433d6423SLionel Sambuc          * Index points to uninitialized object.
442433d6423SLionel Sambuc          * This means that either 1) The expected argument was
443433d6423SLionel Sambuc          * not passed to the method, or 2) A local variable
444433d6423SLionel Sambuc          * was referenced by the method (via the ASL)
445433d6423SLionel Sambuc          * before it was initialized. Either case is an error.
446433d6423SLionel Sambuc          */
447433d6423SLionel Sambuc 
448433d6423SLionel Sambuc         /* If slack enabled, init the LocalX/ArgX to an Integer of value zero */
449433d6423SLionel Sambuc 
450433d6423SLionel Sambuc         if (AcpiGbl_EnableInterpreterSlack)
451433d6423SLionel Sambuc         {
452433d6423SLionel Sambuc             Object = AcpiUtCreateIntegerObject ((UINT64) 0);
453433d6423SLionel Sambuc             if (!Object)
454433d6423SLionel Sambuc             {
455433d6423SLionel Sambuc                 return_ACPI_STATUS (AE_NO_MEMORY);
456433d6423SLionel Sambuc             }
457433d6423SLionel Sambuc 
458433d6423SLionel Sambuc             Node->Object = Object;
459433d6423SLionel Sambuc         }
460433d6423SLionel Sambuc 
461433d6423SLionel Sambuc         /* Otherwise, return the error */
462433d6423SLionel Sambuc 
463433d6423SLionel Sambuc         else switch (Type)
464433d6423SLionel Sambuc         {
465433d6423SLionel Sambuc         case ACPI_REFCLASS_ARG:
466433d6423SLionel Sambuc 
467433d6423SLionel Sambuc             ACPI_ERROR ((AE_INFO,
468433d6423SLionel Sambuc                 "Uninitialized Arg[%u] at node %p",
469433d6423SLionel Sambuc                 Index, Node));
470433d6423SLionel Sambuc 
471433d6423SLionel Sambuc             return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
472433d6423SLionel Sambuc 
473433d6423SLionel Sambuc         case ACPI_REFCLASS_LOCAL:
474433d6423SLionel Sambuc             /*
475433d6423SLionel Sambuc              * No error message for this case, will be trapped again later to
476433d6423SLionel Sambuc              * detect and ignore cases of Store(LocalX,LocalX)
477433d6423SLionel Sambuc              */
478433d6423SLionel Sambuc             return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
479433d6423SLionel Sambuc 
480433d6423SLionel Sambuc         default:
481433d6423SLionel Sambuc 
482433d6423SLionel Sambuc             ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: 0x%X", Type));
483433d6423SLionel Sambuc             return_ACPI_STATUS (AE_AML_INTERNAL);
484433d6423SLionel Sambuc         }
485433d6423SLionel Sambuc     }
486433d6423SLionel Sambuc 
487433d6423SLionel Sambuc     /*
488433d6423SLionel Sambuc      * The Index points to an initialized and valid object.
489433d6423SLionel Sambuc      * Return an additional reference to the object
490433d6423SLionel Sambuc      */
491433d6423SLionel Sambuc     *DestDesc = Object;
492433d6423SLionel Sambuc     AcpiUtAddReference (Object);
493433d6423SLionel Sambuc 
494433d6423SLionel Sambuc     return_ACPI_STATUS (AE_OK);
495433d6423SLionel Sambuc }
496433d6423SLionel Sambuc 
497433d6423SLionel Sambuc 
498433d6423SLionel Sambuc /*******************************************************************************
499433d6423SLionel Sambuc  *
500433d6423SLionel Sambuc  * FUNCTION:    AcpiDsMethodDataDeleteValue
501433d6423SLionel Sambuc  *
502433d6423SLionel Sambuc  * PARAMETERS:  Type                - Either ACPI_REFCLASS_LOCAL or
503433d6423SLionel Sambuc  *                                    ACPI_REFCLASS_ARG
504433d6423SLionel Sambuc  *              Index               - Which localVar or argument to delete
505433d6423SLionel Sambuc  *              WalkState           - Current walk state object
506433d6423SLionel Sambuc  *
507433d6423SLionel Sambuc  * RETURN:      None
508433d6423SLionel Sambuc  *
509433d6423SLionel Sambuc  * DESCRIPTION: Delete the entry at Opcode:Index. Inserts
510433d6423SLionel Sambuc  *              a null into the stack slot after the object is deleted.
511433d6423SLionel Sambuc  *
512433d6423SLionel Sambuc  ******************************************************************************/
513433d6423SLionel Sambuc 
514433d6423SLionel Sambuc static void
AcpiDsMethodDataDeleteValue(UINT8 Type,UINT32 Index,ACPI_WALK_STATE * WalkState)515433d6423SLionel Sambuc AcpiDsMethodDataDeleteValue (
516433d6423SLionel Sambuc     UINT8                   Type,
517433d6423SLionel Sambuc     UINT32                  Index,
518433d6423SLionel Sambuc     ACPI_WALK_STATE         *WalkState)
519433d6423SLionel Sambuc {
520433d6423SLionel Sambuc     ACPI_STATUS             Status;
521433d6423SLionel Sambuc     ACPI_NAMESPACE_NODE     *Node;
522433d6423SLionel Sambuc     ACPI_OPERAND_OBJECT     *Object;
523433d6423SLionel Sambuc 
524433d6423SLionel Sambuc 
525433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (DsMethodDataDeleteValue);
526433d6423SLionel Sambuc 
527433d6423SLionel Sambuc 
528433d6423SLionel Sambuc     /* Get the namespace node for the arg/local */
529433d6423SLionel Sambuc 
530433d6423SLionel Sambuc     Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
531433d6423SLionel Sambuc     if (ACPI_FAILURE (Status))
532433d6423SLionel Sambuc     {
533433d6423SLionel Sambuc         return_VOID;
534433d6423SLionel Sambuc     }
535433d6423SLionel Sambuc 
536433d6423SLionel Sambuc     /* Get the associated object */
537433d6423SLionel Sambuc 
538433d6423SLionel Sambuc     Object = AcpiNsGetAttachedObject (Node);
539433d6423SLionel Sambuc 
540433d6423SLionel Sambuc     /*
541433d6423SLionel Sambuc      * Undefine the Arg or Local by setting its descriptor
542433d6423SLionel Sambuc      * pointer to NULL. Locals/Args can contain both
543433d6423SLionel Sambuc      * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
544433d6423SLionel Sambuc      */
545433d6423SLionel Sambuc     Node->Object = NULL;
546433d6423SLionel Sambuc 
547433d6423SLionel Sambuc     if ((Object) &&
548433d6423SLionel Sambuc         (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_OPERAND))
549433d6423SLionel Sambuc     {
550433d6423SLionel Sambuc         /*
551433d6423SLionel Sambuc          * There is a valid object.
552433d6423SLionel Sambuc          * Decrement the reference count by one to balance the
553433d6423SLionel Sambuc          * increment when the object was stored.
554433d6423SLionel Sambuc          */
555433d6423SLionel Sambuc         AcpiUtRemoveReference (Object);
556433d6423SLionel Sambuc     }
557433d6423SLionel Sambuc 
558433d6423SLionel Sambuc     return_VOID;
559433d6423SLionel Sambuc }
560433d6423SLionel Sambuc 
561433d6423SLionel Sambuc 
562433d6423SLionel Sambuc /*******************************************************************************
563433d6423SLionel Sambuc  *
564433d6423SLionel Sambuc  * FUNCTION:    AcpiDsStoreObjectToLocal
565433d6423SLionel Sambuc  *
566433d6423SLionel Sambuc  * PARAMETERS:  Type                - Either ACPI_REFCLASS_LOCAL or
567433d6423SLionel Sambuc  *                                    ACPI_REFCLASS_ARG
568433d6423SLionel Sambuc  *              Index               - Which Local or Arg to set
569433d6423SLionel Sambuc  *              ObjDesc             - Value to be stored
570433d6423SLionel Sambuc  *              WalkState           - Current walk state
571433d6423SLionel Sambuc  *
572433d6423SLionel Sambuc  * RETURN:      Status
573433d6423SLionel Sambuc  *
574433d6423SLionel Sambuc  * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed
575433d6423SLionel Sambuc  *              as the new value for the Arg or Local and the reference count
576433d6423SLionel Sambuc  *              for ObjDesc is incremented.
577433d6423SLionel Sambuc  *
578433d6423SLionel Sambuc  ******************************************************************************/
579433d6423SLionel Sambuc 
580433d6423SLionel Sambuc ACPI_STATUS
AcpiDsStoreObjectToLocal(UINT8 Type,UINT32 Index,ACPI_OPERAND_OBJECT * ObjDesc,ACPI_WALK_STATE * WalkState)581433d6423SLionel Sambuc AcpiDsStoreObjectToLocal (
582433d6423SLionel Sambuc     UINT8                   Type,
583433d6423SLionel Sambuc     UINT32                  Index,
584433d6423SLionel Sambuc     ACPI_OPERAND_OBJECT     *ObjDesc,
585433d6423SLionel Sambuc     ACPI_WALK_STATE         *WalkState)
586433d6423SLionel Sambuc {
587433d6423SLionel Sambuc     ACPI_STATUS             Status;
588433d6423SLionel Sambuc     ACPI_NAMESPACE_NODE     *Node;
589433d6423SLionel Sambuc     ACPI_OPERAND_OBJECT     *CurrentObjDesc;
590433d6423SLionel Sambuc     ACPI_OPERAND_OBJECT     *NewObjDesc;
591433d6423SLionel Sambuc 
592433d6423SLionel Sambuc 
593433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (DsStoreObjectToLocal);
594433d6423SLionel Sambuc     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%u Obj=%p\n",
595433d6423SLionel Sambuc         Type, Index, ObjDesc));
596433d6423SLionel Sambuc 
597433d6423SLionel Sambuc     /* Parameter validation */
598433d6423SLionel Sambuc 
599433d6423SLionel Sambuc     if (!ObjDesc)
600433d6423SLionel Sambuc     {
601433d6423SLionel Sambuc         return_ACPI_STATUS (AE_BAD_PARAMETER);
602433d6423SLionel Sambuc     }
603433d6423SLionel Sambuc 
604433d6423SLionel Sambuc     /* Get the namespace node for the arg/local */
605433d6423SLionel Sambuc 
606433d6423SLionel Sambuc     Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
607433d6423SLionel Sambuc     if (ACPI_FAILURE (Status))
608433d6423SLionel Sambuc     {
609433d6423SLionel Sambuc         return_ACPI_STATUS (Status);
610433d6423SLionel Sambuc     }
611433d6423SLionel Sambuc 
612433d6423SLionel Sambuc     CurrentObjDesc = AcpiNsGetAttachedObject (Node);
613433d6423SLionel Sambuc     if (CurrentObjDesc == ObjDesc)
614433d6423SLionel Sambuc     {
615433d6423SLionel Sambuc         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n",
616433d6423SLionel Sambuc             ObjDesc));
617433d6423SLionel Sambuc         return_ACPI_STATUS (Status);
618433d6423SLionel Sambuc     }
619433d6423SLionel Sambuc 
620433d6423SLionel Sambuc     /*
621433d6423SLionel Sambuc      * If the reference count on the object is more than one, we must
622433d6423SLionel Sambuc      * take a copy of the object before we store. A reference count
623433d6423SLionel Sambuc      * of exactly 1 means that the object was just created during the
624433d6423SLionel Sambuc      * evaluation of an expression, and we can safely use it since it
625433d6423SLionel Sambuc      * is not used anywhere else.
626433d6423SLionel Sambuc      */
627433d6423SLionel Sambuc     NewObjDesc = ObjDesc;
628433d6423SLionel Sambuc     if (ObjDesc->Common.ReferenceCount > 1)
629433d6423SLionel Sambuc     {
630433d6423SLionel Sambuc         Status = AcpiUtCopyIobjectToIobject (ObjDesc, &NewObjDesc, WalkState);
631433d6423SLionel Sambuc         if (ACPI_FAILURE (Status))
632433d6423SLionel Sambuc         {
633433d6423SLionel Sambuc             return_ACPI_STATUS (Status);
634433d6423SLionel Sambuc         }
635433d6423SLionel Sambuc     }
636433d6423SLionel Sambuc 
637433d6423SLionel Sambuc     /*
638433d6423SLionel Sambuc      * If there is an object already in this slot, we either
639433d6423SLionel Sambuc      * have to delete it, or if this is an argument and there
640433d6423SLionel Sambuc      * is an object reference stored there, we have to do
641433d6423SLionel Sambuc      * an indirect store!
642433d6423SLionel Sambuc      */
643433d6423SLionel Sambuc     if (CurrentObjDesc)
644433d6423SLionel Sambuc     {
645433d6423SLionel Sambuc         /*
646433d6423SLionel Sambuc          * Check for an indirect store if an argument
647433d6423SLionel Sambuc          * contains an object reference (stored as an Node).
648433d6423SLionel Sambuc          * We don't allow this automatic dereferencing for
649433d6423SLionel Sambuc          * locals, since a store to a local should overwrite
650433d6423SLionel Sambuc          * anything there, including an object reference.
651433d6423SLionel Sambuc          *
652433d6423SLionel Sambuc          * If both Arg0 and Local0 contain RefOf (Local4):
653433d6423SLionel Sambuc          *
654433d6423SLionel Sambuc          * Store (1, Arg0)             - Causes indirect store to local4
655433d6423SLionel Sambuc          * Store (1, Local0)           - Stores 1 in local0, overwriting
656433d6423SLionel Sambuc          *                                  the reference to local4
657433d6423SLionel Sambuc          * Store (1, DeRefof (Local0)) - Causes indirect store to local4
658433d6423SLionel Sambuc          *
659433d6423SLionel Sambuc          * Weird, but true.
660433d6423SLionel Sambuc          */
661433d6423SLionel Sambuc         if (Type == ACPI_REFCLASS_ARG)
662433d6423SLionel Sambuc         {
663433d6423SLionel Sambuc             /*
664433d6423SLionel Sambuc              * If we have a valid reference object that came from RefOf(),
665433d6423SLionel Sambuc              * do the indirect store
666433d6423SLionel Sambuc              */
667433d6423SLionel Sambuc             if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) == ACPI_DESC_TYPE_OPERAND) &&
668433d6423SLionel Sambuc                 (CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
669433d6423SLionel Sambuc                 (CurrentObjDesc->Reference.Class == ACPI_REFCLASS_REFOF))
670433d6423SLionel Sambuc             {
671433d6423SLionel Sambuc                 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
672433d6423SLionel Sambuc                         "Arg (%p) is an ObjRef(Node), storing in node %p\n",
673433d6423SLionel Sambuc                         NewObjDesc, CurrentObjDesc));
674433d6423SLionel Sambuc 
675433d6423SLionel Sambuc                 /*
676433d6423SLionel Sambuc                  * Store this object to the Node (perform the indirect store)
677433d6423SLionel Sambuc                  * NOTE: No implicit conversion is performed, as per the ACPI
678433d6423SLionel Sambuc                  * specification rules on storing to Locals/Args.
679433d6423SLionel Sambuc                  */
680433d6423SLionel Sambuc                 Status = AcpiExStoreObjectToNode (NewObjDesc,
681433d6423SLionel Sambuc                             CurrentObjDesc->Reference.Object, WalkState,
682433d6423SLionel Sambuc                             ACPI_NO_IMPLICIT_CONVERSION);
683433d6423SLionel Sambuc 
684433d6423SLionel Sambuc                 /* Remove local reference if we copied the object above */
685433d6423SLionel Sambuc 
686433d6423SLionel Sambuc                 if (NewObjDesc != ObjDesc)
687433d6423SLionel Sambuc                 {
688433d6423SLionel Sambuc                     AcpiUtRemoveReference (NewObjDesc);
689433d6423SLionel Sambuc                 }
690433d6423SLionel Sambuc                 return_ACPI_STATUS (Status);
691433d6423SLionel Sambuc             }
692433d6423SLionel Sambuc         }
693433d6423SLionel Sambuc 
694433d6423SLionel Sambuc         /* Delete the existing object before storing the new one */
695433d6423SLionel Sambuc 
696433d6423SLionel Sambuc         AcpiDsMethodDataDeleteValue (Type, Index, WalkState);
697433d6423SLionel Sambuc     }
698433d6423SLionel Sambuc 
699433d6423SLionel Sambuc     /*
700433d6423SLionel Sambuc      * Install the Obj descriptor (*NewObjDesc) into
701433d6423SLionel Sambuc      * the descriptor for the Arg or Local.
702433d6423SLionel Sambuc      * (increments the object reference count by one)
703433d6423SLionel Sambuc      */
704433d6423SLionel Sambuc     Status = AcpiDsMethodDataSetValue (Type, Index, NewObjDesc, WalkState);
705433d6423SLionel Sambuc 
706433d6423SLionel Sambuc     /* Remove local reference if we copied the object above */
707433d6423SLionel Sambuc 
708433d6423SLionel Sambuc     if (NewObjDesc != ObjDesc)
709433d6423SLionel Sambuc     {
710433d6423SLionel Sambuc         AcpiUtRemoveReference (NewObjDesc);
711433d6423SLionel Sambuc     }
712433d6423SLionel Sambuc 
713433d6423SLionel Sambuc     return_ACPI_STATUS (Status);
714433d6423SLionel Sambuc }
715433d6423SLionel Sambuc 
716433d6423SLionel Sambuc 
717433d6423SLionel Sambuc #ifdef ACPI_OBSOLETE_FUNCTIONS
718433d6423SLionel Sambuc /*******************************************************************************
719433d6423SLionel Sambuc  *
720433d6423SLionel Sambuc  * FUNCTION:    AcpiDsMethodDataGetType
721433d6423SLionel Sambuc  *
722433d6423SLionel Sambuc  * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
723433d6423SLionel Sambuc  *              Index               - Which Local or Arg whose type to get
724433d6423SLionel Sambuc  *              WalkState           - Current walk state object
725433d6423SLionel Sambuc  *
726433d6423SLionel Sambuc  * RETURN:      Data type of current value of the selected Arg or Local
727433d6423SLionel Sambuc  *
728433d6423SLionel Sambuc  * DESCRIPTION: Get the type of the object stored in the Local or Arg
729433d6423SLionel Sambuc  *
730433d6423SLionel Sambuc  ******************************************************************************/
731433d6423SLionel Sambuc 
732433d6423SLionel Sambuc ACPI_OBJECT_TYPE
AcpiDsMethodDataGetType(UINT16 Opcode,UINT32 Index,ACPI_WALK_STATE * WalkState)733433d6423SLionel Sambuc AcpiDsMethodDataGetType (
734433d6423SLionel Sambuc     UINT16                  Opcode,
735433d6423SLionel Sambuc     UINT32                  Index,
736433d6423SLionel Sambuc     ACPI_WALK_STATE         *WalkState)
737433d6423SLionel Sambuc {
738433d6423SLionel Sambuc     ACPI_STATUS             Status;
739433d6423SLionel Sambuc     ACPI_NAMESPACE_NODE     *Node;
740433d6423SLionel Sambuc     ACPI_OPERAND_OBJECT     *Object;
741433d6423SLionel Sambuc 
742433d6423SLionel Sambuc 
743433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (DsMethodDataGetType);
744433d6423SLionel Sambuc 
745433d6423SLionel Sambuc 
746433d6423SLionel Sambuc     /* Get the namespace node for the arg/local */
747433d6423SLionel Sambuc 
748433d6423SLionel Sambuc     Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
749433d6423SLionel Sambuc     if (ACPI_FAILURE (Status))
750433d6423SLionel Sambuc     {
751433d6423SLionel Sambuc         return_VALUE ((ACPI_TYPE_NOT_FOUND));
752433d6423SLionel Sambuc     }
753433d6423SLionel Sambuc 
754433d6423SLionel Sambuc     /* Get the object */
755433d6423SLionel Sambuc 
756433d6423SLionel Sambuc     Object = AcpiNsGetAttachedObject (Node);
757433d6423SLionel Sambuc     if (!Object)
758433d6423SLionel Sambuc     {
759433d6423SLionel Sambuc         /* Uninitialized local/arg, return TYPE_ANY */
760433d6423SLionel Sambuc 
761433d6423SLionel Sambuc         return_VALUE (ACPI_TYPE_ANY);
762433d6423SLionel Sambuc     }
763433d6423SLionel Sambuc 
764433d6423SLionel Sambuc     /* Get the object type */
765433d6423SLionel Sambuc 
766433d6423SLionel Sambuc     return_VALUE (Object->Type);
767433d6423SLionel Sambuc }
768433d6423SLionel Sambuc #endif
769