nseval.c revision 99679
1218885Sdim/*******************************************************************************
2218885Sdim *
3353358Sdim * Module Name: nseval - Object evaluation interfaces -- includes control
4353358Sdim *                       method lookup and execution.
5353358Sdim *              $Revision: 116 $
6218885Sdim *
7218885Sdim ******************************************************************************/
8218885Sdim
9321369Sdim/******************************************************************************
10226633Sdim *
11321369Sdim * 1. Copyright Notice
12218885Sdim *
13321369Sdim * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
14218885Sdim * All rights reserved.
15321369Sdim *
16276479Sdim * 2. License
17218885Sdim *
18321369Sdim * 2.1. This is your license from Intel Corp. under its intellectual property
19309124Sdim * rights.  You may have additional license terms from the party that provided
20226633Sdim * you this software, covering your right to use that party's intellectual
21218885Sdim * property rights.
22218885Sdim *
23321369Sdim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24321369Sdim * copy of the source code appearing in this file ("Covered Code") an
25321369Sdim * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26321369Sdim * base code distributed originally by Intel ("Original Intel Code") to copy,
27321369Sdim * make derivatives, distribute, use and display any portion of the Covered
28321369Sdim * Code in any form, with the right to sublicense such rights; and
29321369Sdim *
30218885Sdim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31218885Sdim * license (with the right to sublicense), under only those claims of Intel
32218885Sdim * patents that are infringed by the Original Intel Code, to make, use, sell,
33218885Sdim * offer to sell, and import the Covered Code and derivative works thereof
34218885Sdim * solely to the minimum extent necessary to exercise the above copyright
35249423Sdim * license, and in no event shall the patent license extend to any additions
36249423Sdim * to or modifications of the Original Intel Code.  No other license or right
37249423Sdim * is granted directly or by implication, estoppel or otherwise;
38249423Sdim *
39249423Sdim * The above copyright and patent license is granted only if the following
40218885Sdim * conditions are met:
41218885Sdim *
42218885Sdim * 3. Conditions
43218885Sdim *
44218885Sdim * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45218885Sdim * Redistribution of source code of any substantial portion of the Covered
46261991Sdim * Code or modification with rights to further distribute source must include
47261991Sdim * the above Copyright Notice, the above License, this list of Conditions,
48276479Sdim * and the following Disclaimer and Export Compliance provision.  In addition,
49261991Sdim * Licensee must cause all Covered Code to which Licensee contributes to
50261991Sdim * contain a file documenting the changes Licensee made to create that Covered
51314564Sdim * Code and the date of any change.  Licensee must include in that file the
52314564Sdim * documentation of any changes made by any predecessor Licensee.  Licensee
53261991Sdim * must include a prominent statement that the modification is derived,
54276479Sdim * directly or indirectly, from Original Intel Code.
55218885Sdim *
56218885Sdim * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57218885Sdim * Redistribution of source code of any substantial portion of the Covered
58249423Sdim * Code or modification without rights to further distribute source must
59249423Sdim * include the following Disclaimer and Export Compliance provision in the
60249423Sdim * documentation and/or other materials provided with distribution.  In
61261991Sdim * addition, Licensee may not authorize further sublicense of source of any
62249423Sdim * portion of the Covered Code, and must include terms to the effect that the
63249423Sdim * license from Licensee to its licensee is limited to the intellectual
64249423Sdim * property embodied in the software Licensee provides to its licensee, and
65249423Sdim * not to intellectual property embodied in modifications its licensee may
66249423Sdim * make.
67341825Sdim
68341825Sdim *
69276479Sdim * 3.3. Redistribution of Executable. Redistribution in executable form of any
70261991Sdim * substantial portion of the Covered Code or modification must reproduce the
71341825Sdim * above Copyright Notice, and the following Disclaimer and Export Compliance
72360784Sdim * provision in the documentation and/or other materials provided with the
73223017Sdim * distribution.
74223017Sdim *
75249423Sdim * 3.4. Intel retains all right, title, and interest in and to the Original
76223017Sdim * Intel Code.
77249423Sdim *
78223017Sdim * 3.5. Neither the name Intel nor any other trademark owned or controlled by
79249423Sdim * Intel shall be used in advertising or otherwise to promote the sale, use or
80223017Sdim * other dealings in products derived from or relating to the Covered Code
81249423Sdim * without prior written authorization from Intel.
82223017Sdim *
83249423Sdim * 4. Disclaimer and Export Compliance
84223017Sdim *
85249423Sdim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
86223017Sdim * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
87249423Sdim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
88223017Sdim * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
89249423Sdim * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
90223017Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
91218885Sdim * PARTICULAR PURPOSE.
92218885Sdim *
93218885Sdim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
94218885Sdim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
95218885Sdim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
96218885Sdim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
97218885Sdim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
98218885Sdim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
99218885Sdim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
100321369Sdim * LIMITED REMEDY.
101218885Sdim *
102296417Sdim * 4.3. Licensee shall not export, either directly or indirectly, any of this
103296417Sdim * software or system incorporating such software without first obtaining any
104296417Sdim * required license or other approval from the U. S. Department of Commerce or
105296417Sdim * any other agency or department of the United States Government.  In the
106218885Sdim * event Licensee exports any such software from the United States or
107321369Sdim * re-exports any such software from a foreign destination, Licensee shall
108218885Sdim * ensure that the distribution and export/re-export of the software is in
109218885Sdim * compliance with all laws, regulations, orders, or other restrictions of the
110218885Sdim * U.S. Export Administration Regulations. Licensee agrees that neither it nor
111218885Sdim * any of its subsidiaries will export/re-export any technical data, process,
112218885Sdim * software, or service, directly or indirectly, to any country for which the
113218885Sdim * United States government or any agency thereof requires an export license,
114218885Sdim * other governmental approval, or letter of assurance, without first obtaining
115218885Sdim * such license, approval or letter.
116261991Sdim *
117218885Sdim *****************************************************************************/
118218885Sdim
119218885Sdim#define __NSEVAL_C__
120218885Sdim
121234353Sdim#include "acpi.h"
122276479Sdim#include "acparser.h"
123288943Sdim#include "acinterp.h"
124341825Sdim#include "acnamesp.h"
125276479Sdim
126261991Sdim
127341825Sdim#define _COMPONENT          ACPI_NAMESPACE
128218885Sdim        ACPI_MODULE_NAME    ("nseval")
129223017Sdim
130223017Sdim
131223017Sdim/*******************************************************************************
132223017Sdim *
133223017Sdim * FUNCTION:    AcpiNsEvaluateRelative
134223017Sdim *
135223017Sdim * PARAMETERS:  Handle              - The relative containing object
136223017Sdim *              Pathname            - Name of method to execute, If NULL, the
137223017Sdim *                                    handle is the object to execute
138223017Sdim *              Params              - List of parameters to pass to the method,
139223017Sdim *                                    terminated by NULL.  Params itself may be
140223017Sdim *                                    NULL if no parameters are being passed.
141226633Sdim *              ReturnObject        - Where to put method's return value (if
142321369Sdim *                                    any).  If NULL, no value is returned.
143218885Sdim *
144321369Sdim * RETURN:      Status
145218885Sdim *
146218885Sdim * DESCRIPTION: Find and execute the requested method using the handle as a
147360784Sdim *              scope
148218885Sdim *
149261991Sdim * MUTEX:       Locks Namespace
150261991Sdim *
151261991Sdim ******************************************************************************/
152261991Sdim
153261991SdimACPI_STATUS
154261991SdimAcpiNsEvaluateRelative (
155296417Sdim    ACPI_NAMESPACE_NODE     *Handle,
156261991Sdim    NATIVE_CHAR             *Pathname,
157261991Sdim    ACPI_OPERAND_OBJECT     **Params,
158314564Sdim    ACPI_OPERAND_OBJECT     **ReturnObject)
159314564Sdim{
160261991Sdim    ACPI_NAMESPACE_NODE     *PrefixNode;
161314564Sdim    ACPI_STATUS             Status;
162314564Sdim    ACPI_NAMESPACE_NODE     *Node = NULL;
163314564Sdim    NATIVE_CHAR             *InternalPath = NULL;
164314564Sdim    ACPI_GENERIC_STATE      ScopeInfo;
165314564Sdim
166314564Sdim
167314564Sdim    ACPI_FUNCTION_TRACE ("NsEvaluateRelative");
168314564Sdim
169314564Sdim
170314564Sdim    /*
171261991Sdim     * Must have a valid object handle
172261991Sdim     */
173261991Sdim    if (!Handle)
174261991Sdim    {
175261991Sdim        return_ACPI_STATUS (AE_BAD_PARAMETER);
176276479Sdim    }
177276479Sdim
178261991Sdim    /* Build an internal name string for the method */
179261991Sdim
180261991Sdim    Status = AcpiNsInternalizeName (Pathname, &InternalPath);
181261991Sdim    if (ACPI_FAILURE (Status))
182261991Sdim    {
183261991Sdim        return_ACPI_STATUS (Status);
184261991Sdim    }
185261991Sdim
186261991Sdim    /* Get the prefix handle and Node */
187261991Sdim
188261991Sdim    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
189261991Sdim    if (ACPI_FAILURE (Status))
190261991Sdim    {
191261991Sdim        return_ACPI_STATUS (Status);
192261991Sdim    }
193261991Sdim
194261991Sdim    PrefixNode = AcpiNsMapHandleToNode (Handle);
195261991Sdim    if (!PrefixNode)
196261991Sdim    {
197261991Sdim        (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
198261991Sdim        Status = AE_BAD_PARAMETER;
199261991Sdim        goto Cleanup;
200261991Sdim    }
201261991Sdim
202261991Sdim    /* Lookup the name in the namespace */
203314564Sdim
204314564Sdim    ScopeInfo.Scope.Node = PrefixNode;
205314564Sdim    Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY,
206314564Sdim                            ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL,
207261991Sdim                            &Node);
208261991Sdim
209261991Sdim    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
210261991Sdim
211261991Sdim    if (ACPI_FAILURE (Status))
212261991Sdim    {
213261991Sdim        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Object [%s] not found [%s]\n",
214261991Sdim            Pathname, AcpiFormatException (Status)));
215261991Sdim        goto Cleanup;
216261991Sdim    }
217261991Sdim
218261991Sdim    /*
219261991Sdim     * Now that we have a handle to the object, we can attempt
220261991Sdim     * to evaluate it.
221261991Sdim     */
222261991Sdim    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n",
223261991Sdim        Pathname, Node, AcpiNsGetAttachedObject (Node)));
224261991Sdim
225261991Sdim    Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject);
226261991Sdim
227261991Sdim    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n",
228261991Sdim        Pathname));
229261991Sdim
230261991SdimCleanup:
231261991Sdim
232261991Sdim    ACPI_MEM_FREE (InternalPath);
233261991Sdim    return_ACPI_STATUS (Status);
234261991Sdim}
235261991Sdim
236261991Sdim
237261991Sdim/*******************************************************************************
238261991Sdim *
239261991Sdim * FUNCTION:    AcpiNsEvaluateByName
240261991Sdim *
241261991Sdim * PARAMETERS:  Pathname            - Fully qualified pathname to the object
242261991Sdim *              ReturnObject        - Where to put method's return value (if
243261991Sdim *                                    any).  If NULL, no value is returned.
244261991Sdim *              Params              - List of parameters to pass to the method,
245261991Sdim *                                    terminated by NULL.  Params itself may be
246261991Sdim *                                    NULL if no parameters are being passed.
247261991Sdim *
248261991Sdim * RETURN:      Status
249261991Sdim *
250261991Sdim * DESCRIPTION: Find and execute the requested method passing the given
251261991Sdim *              parameters
252261991Sdim *
253261991Sdim * MUTEX:       Locks Namespace
254261991Sdim *
255261991Sdim ******************************************************************************/
256261991Sdim
257261991SdimACPI_STATUS
258314564SdimAcpiNsEvaluateByName (
259314564Sdim    NATIVE_CHAR             *Pathname,
260314564Sdim    ACPI_OPERAND_OBJECT     **Params,
261261991Sdim    ACPI_OPERAND_OBJECT     **ReturnObject)
262261991Sdim{
263261991Sdim    ACPI_STATUS             Status;
264261991Sdim    ACPI_NAMESPACE_NODE     *Node = NULL;
265261991Sdim    NATIVE_CHAR             *InternalPath = NULL;
266261991Sdim
267261991Sdim
268261991Sdim    ACPI_FUNCTION_TRACE ("NsEvaluateByName");
269261991Sdim
270261991Sdim
271226633Sdim    /* Build an internal name string for the method */
272226633Sdim
273226633Sdim    Status = AcpiNsInternalizeName (Pathname, &InternalPath);
274226633Sdim    if (ACPI_FAILURE (Status))
275226633Sdim    {
276226633Sdim        return_ACPI_STATUS (Status);
277226633Sdim    }
278226633Sdim
279321369Sdim    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
280226633Sdim    if (ACPI_FAILURE (Status))
281226633Sdim    {
282249423Sdim        return_ACPI_STATUS (Status);
283226633Sdim    }
284226633Sdim
285288943Sdim    /* Lookup the name in the namespace */
286226633Sdim
287226633Sdim    Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY,
288226633Sdim                            ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL,
289226633Sdim                            &Node);
290226633Sdim
291226633Sdim    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
292226633Sdim
293226633Sdim    if (ACPI_FAILURE (Status))
294226633Sdim    {
295226633Sdim        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Object at [%s] was not found, status=%.4X\n",
296226633Sdim            Pathname, Status));
297226633Sdim        goto Cleanup;
298226633Sdim    }
299226633Sdim
300226633Sdim    /*
301226633Sdim     * Now that we have a handle to the object, we can attempt
302218885Sdim     * to evaluate it.
303218885Sdim     */
304218885Sdim    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n",
305276479Sdim        Pathname, Node, AcpiNsGetAttachedObject (Node)));
306261991Sdim
307261991Sdim    Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject);
308261991Sdim
309261991Sdim    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n",
310261991Sdim        Pathname));
311261991Sdim
312276479Sdim
313218885SdimCleanup:
314218885Sdim
315218885Sdim    /* Cleanup */
316218885Sdim
317218885Sdim    if (InternalPath)
318276479Sdim    {
319218885Sdim        ACPI_MEM_FREE (InternalPath);
320218885Sdim    }
321218885Sdim
322218885Sdim    return_ACPI_STATUS (Status);
323261991Sdim}
324261991Sdim
325261991Sdim
326261991Sdim/*******************************************************************************
327261991Sdim *
328261991Sdim * FUNCTION:    AcpiNsEvaluateByHandle
329261991Sdim *
330261991Sdim * PARAMETERS:  Handle              - Method Node to execute
331261991Sdim *              Params              - List of parameters to pass to the method,
332261991Sdim *                                    terminated by NULL.  Params itself may be
333261991Sdim *                                    NULL if no parameters are being passed.
334261991Sdim *              ReturnObject        - Where to put method's return value (if
335261991Sdim *                                    any).  If NULL, no value is returned.
336261991Sdim *
337261991Sdim * RETURN:      Status
338314564Sdim *
339314564Sdim * DESCRIPTION: Execute the requested method passing the given parameters
340261991Sdim *
341261991Sdim * MUTEX:       Locks Namespace
342261991Sdim *
343261991Sdim ******************************************************************************/
344261991Sdim
345261991SdimACPI_STATUS
346261991SdimAcpiNsEvaluateByHandle (
347261991Sdim    ACPI_NAMESPACE_NODE     *Handle,
348261991Sdim    ACPI_OPERAND_OBJECT     **Params,
349261991Sdim    ACPI_OPERAND_OBJECT     **ReturnObject)
350261991Sdim{
351261991Sdim    ACPI_NAMESPACE_NODE     *Node;
352261991Sdim    ACPI_STATUS             Status;
353261991Sdim    ACPI_OPERAND_OBJECT     *LocalReturnObject;
354261991Sdim
355261991Sdim
356261991Sdim    ACPI_FUNCTION_TRACE ("NsEvaluateByHandle");
357261991Sdim
358261991Sdim
359261991Sdim    /* Check if namespace has been initialized */
360261991Sdim
361261991Sdim    if (!AcpiGbl_RootNode)
362261991Sdim    {
363261991Sdim        return_ACPI_STATUS (AE_NO_NAMESPACE);
364261991Sdim    }
365261991Sdim
366314564Sdim    /* Parameter Validation */
367261991Sdim
368261991Sdim    if (!Handle)
369261991Sdim    {
370276479Sdim        return_ACPI_STATUS (AE_BAD_PARAMETER);
371261991Sdim    }
372261991Sdim
373288943Sdim    if (ReturnObject)
374261991Sdim    {
375261991Sdim        /* Initialize the return value to an invalid object */
376261991Sdim
377261991Sdim        *ReturnObject = NULL;
378280031Sdim    }
379280031Sdim
380280031Sdim    /* Get the prefix handle and Node */
381280031Sdim
382276479Sdim    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
383261991Sdim    if (ACPI_FAILURE (Status))
384261991Sdim    {
385261991Sdim        return_ACPI_STATUS (Status);
386261991Sdim    }
387261991Sdim
388261991Sdim    Node = AcpiNsMapHandleToNode (Handle);
389261991Sdim    if (!Node)
390261991Sdim    {
391261991Sdim        (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
392261991Sdim        return_ACPI_STATUS (AE_BAD_PARAMETER);
393261991Sdim    }
394261991Sdim
395261991Sdim    /*
396261991Sdim     * Two major cases here:
397276479Sdim     * 1) The object is an actual control method -- execute it.
398276479Sdim     * 2) The object is not a method -- just return it's current
399276479Sdim     *      value
400276479Sdim     *
401276479Sdim     * In both cases, the namespace is unlocked by the
402276479Sdim     *  AcpiNs* procedure
403261991Sdim     */
404261991Sdim    if (AcpiNsGetType (Node) == ACPI_TYPE_METHOD)
405261991Sdim    {
406218885Sdim        /*
407218885Sdim         * Case 1) We have an actual control method to execute
408218885Sdim         */
409249423Sdim        Status = AcpiNsExecuteControlMethod (Node, Params,
410218885Sdim                                            &LocalReturnObject);
411218885Sdim    }
412288943Sdim    else
413218885Sdim    {
414218885Sdim        /*
415218885Sdim         * Case 2) Object is NOT a method, just return its
416218885Sdim         * current value
417218885Sdim         */
418218885Sdim        Status = AcpiNsGetObjectValue (Node, &LocalReturnObject);
419218885Sdim    }
420218885Sdim
421218885Sdim    /*
422249423Sdim     * Check if there is a return value on the stack that must
423218885Sdim     * be dealt with
424218885Sdim     */
425218885Sdim    if (Status == AE_CTRL_RETURN_VALUE)
426218885Sdim    {
427218885Sdim        /*
428218885Sdim         * If the Method returned a value and the caller
429218885Sdim         * provided a place to store a returned value, Copy
430218885Sdim         * the returned value to the object descriptor provided
431218885Sdim         * by the caller.
432218885Sdim         */
433218885Sdim        if (ReturnObject)
434218885Sdim        {
435249423Sdim            /*
436218885Sdim             * Valid return object, copy the pointer to
437218885Sdim             * the returned object
438218885Sdim             */
439218885Sdim            *ReturnObject = LocalReturnObject;
440218885Sdim        }
441218885Sdim
442218885Sdim        /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */
443218885Sdim
444218885Sdim        Status = AE_OK;
445218885Sdim    }
446218885Sdim
447218885Sdim    /*
448218885Sdim     * Namespace was unlocked by the handling AcpiNs* function,
449218885Sdim     * so we just return
450218885Sdim     */
451218885Sdim    return_ACPI_STATUS (Status);
452234353Sdim}
453234353Sdim
454249423Sdim
455276479Sdim/*******************************************************************************
456234353Sdim *
457314564Sdim * FUNCTION:    AcpiNsExecuteControlMethod
458314564Sdim *
459314564Sdim * PARAMETERS:  MethodNode          - The method to execute
460314564Sdim *              Params              - List of parameters to pass to the method,
461314564Sdim *                                    terminated by NULL.  Params itself may be
462314564Sdim *                                    NULL if no parameters are being passed.
463314564Sdim *              ReturnObjDesc       - List of result objects to be returned
464314564Sdim *                                    from the method.
465234353Sdim *
466234353Sdim * RETURN:      Status
467234353Sdim *
468321369Sdim * DESCRIPTION: Execute the requested method passing the given parameters
469321369Sdim *
470321369Sdim * MUTEX:       Assumes namespace is locked
471321369Sdim *
472321369Sdim ******************************************************************************/
473314564Sdim
474288943SdimACPI_STATUS
475234353SdimAcpiNsExecuteControlMethod (
476234353Sdim    ACPI_NAMESPACE_NODE     *MethodNode,
477314564Sdim    ACPI_OPERAND_OBJECT     **Params,
478234353Sdim    ACPI_OPERAND_OBJECT     **ReturnObjDesc)
479234353Sdim{
480234353Sdim    ACPI_STATUS             Status;
481341825Sdim    ACPI_OPERAND_OBJECT     *ObjDesc;
482341825Sdim
483341825Sdim
484341825Sdim    ACPI_FUNCTION_TRACE ("NsExecuteControlMethod");
485341825Sdim
486341825Sdim
487341825Sdim    /* Verify that there is a method associated with this object */
488341825Sdim
489341825Sdim    ObjDesc = AcpiNsGetAttachedObject (MethodNode);
490341825Sdim    if (!ObjDesc)
491341825Sdim    {
492341825Sdim        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No attached method object\n"));
493341825Sdim
494341825Sdim        (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
495341825Sdim        return_ACPI_STATUS (AE_NULL_OBJECT);
496341825Sdim    }
497341825Sdim
498341825Sdim    ACPI_DUMP_PATHNAME (MethodNode, "NsExecuteControlMethod: Executing",
499341825Sdim        ACPI_LV_INFO, _COMPONENT);
500341825Sdim
501341825Sdim    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Method at AML address %p Length %X\n",
502341825Sdim        ObjDesc->Method.AmlStart + 1, ObjDesc->Method.AmlLength - 1));
503341825Sdim
504341825Sdim    /*
505341825Sdim     * Unlock the namespace before execution.  This allows namespace access
506341825Sdim     * via the external Acpi* interfaces while a method is being executed.
507341825Sdim     * However, any namespace deletion must acquire both the namespace and
508341825Sdim     * interpreter locks to ensure that no thread is using the portion of the
509341825Sdim     * namespace that is being deleted.
510341825Sdim     */
511341825Sdim    Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
512288943Sdim    if (ACPI_FAILURE (Status))
513288943Sdim    {
514288943Sdim        return_ACPI_STATUS (Status);
515288943Sdim    }
516288943Sdim
517288943Sdim    /*
518288943Sdim     * Execute the method via the interpreter.  The interpreter is locked
519288943Sdim     * here before calling into the AML parser
520288943Sdim     */
521288943Sdim    Status = AcpiExEnterInterpreter ();
522288943Sdim    if (ACPI_FAILURE (Status))
523288943Sdim    {
524288943Sdim        return_ACPI_STATUS (Status);
525288943Sdim    }
526288943Sdim
527276479Sdim    Status = AcpiPsxExecute (MethodNode, Params, ReturnObjDesc);
528276479Sdim    AcpiExExitInterpreter ();
529276479Sdim
530276479Sdim    return_ACPI_STATUS (Status);
531276479Sdim}
532276479Sdim
533276479Sdim
534276479Sdim/*******************************************************************************
535288943Sdim *
536276479Sdim * FUNCTION:    AcpiNsGetObjectValue
537276479Sdim *
538276479Sdim * PARAMETERS:  Node                - The object
539276479Sdim *              ReturnObjDesc       - Where the objects value is returned
540276479Sdim *
541276479Sdim * RETURN:      Status
542341825Sdim *
543341825Sdim * DESCRIPTION: Return the current value of the object
544341825Sdim *
545341825Sdim * MUTEX:       Assumes namespace is locked, leaves namespace unlocked
546341825Sdim *
547341825Sdim ******************************************************************************/
548341825Sdim
549341825SdimACPI_STATUS
550341825SdimAcpiNsGetObjectValue (
551341825Sdim    ACPI_NAMESPACE_NODE     *Node,
552341825Sdim    ACPI_OPERAND_OBJECT     **ReturnObjDesc)
553341825Sdim{
554341825Sdim    ACPI_STATUS             Status = AE_OK;
555341825Sdim    ACPI_NAMESPACE_NODE     *ResolvedNode = Node;
556341825Sdim
557276479Sdim
558276479Sdim    ACPI_FUNCTION_TRACE ("NsGetObjectValue");
559261991Sdim
560261991Sdim
561261991Sdim    /*
562261991Sdim     * Objects require additional resolution steps (e.g., the
563261991Sdim     * Node may be a field that must be read, etc.) -- we can't just grab
564261991Sdim     * the object out of the node.
565261991Sdim     */
566261991Sdim
567261991Sdim    /*
568261991Sdim     * Use ResolveNodeToValue() to get the associated value.  This call
569261991Sdim     * always deletes ObjDesc (allocated above).
570261991Sdim     *
571261991Sdim     * NOTE: we can get away with passing in NULL for a walk state
572261991Sdim     * because ObjDesc is guaranteed to not be a reference to either
573261991Sdim     * a method local or a method argument (because this interface can only be
574261991Sdim     * called from the AcpiEvaluate external interface, never called from
575261991Sdim     * a running control method.)
576261991Sdim     *
577261991Sdim     * Even though we do not directly invoke the interpreter
578261991Sdim     * for this, we must enter it because we could access an opregion.
579261991Sdim     * The opregion access code assumes that the interpreter
580276479Sdim     * is locked.
581261991Sdim     *
582261991Sdim     * We must release the namespace lock before entering the
583261991Sdim     * intepreter.
584276479Sdim     */
585261991Sdim    Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
586261991Sdim    if (ACPI_FAILURE (Status))
587314564Sdim    {
588314564Sdim        return_ACPI_STATUS (Status);
589261991Sdim    }
590276479Sdim
591276479Sdim    Status = AcpiExEnterInterpreter ();
592261991Sdim    if (ACPI_SUCCESS (Status))
593261991Sdim    {
594261991Sdim        Status = AcpiExResolveNodeToValue (&ResolvedNode, NULL);
595261991Sdim        /*
596261991Sdim         * If AcpiExResolveNodeToValue() succeeded, the return value was
597276479Sdim         * placed in ResolvedNode.
598261991Sdim         */
599261991Sdim        AcpiExExitInterpreter ();
600261991Sdim
601261991Sdim        if (ACPI_SUCCESS (Status))
602261991Sdim        {
603261991Sdim            Status = AE_CTRL_RETURN_VALUE;
604261991Sdim            *ReturnObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ResolvedNode);
605327952Sdim            ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning obj %p\n", ResolvedNode));
606223017Sdim        }
607249423Sdim    }
608223017Sdim
609223017Sdim    /* Namespace is unlocked */
610223017Sdim
611223017Sdim    return_ACPI_STATUS (Status);
612223017Sdim}
613288943Sdim
614223017Sdim