nseval.c revision 151937
167754Smsmith/******************************************************************************* 267754Smsmith * 367754Smsmith * Module Name: nseval - Object evaluation interfaces -- includes control 467754Smsmith * method lookup and execution. 5151937Sjkim * $Revision: 1.134 $ 667754Smsmith * 767754Smsmith ******************************************************************************/ 867754Smsmith 967754Smsmith/****************************************************************************** 1067754Smsmith * 1167754Smsmith * 1. Copyright Notice 1267754Smsmith * 13151937Sjkim * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. 1470243Smsmith * All rights reserved. 1567754Smsmith * 1667754Smsmith * 2. License 1767754Smsmith * 1867754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 1967754Smsmith * rights. You may have additional license terms from the party that provided 2067754Smsmith * you this software, covering your right to use that party's intellectual 2167754Smsmith * property rights. 2267754Smsmith * 2367754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2467754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2567754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2667754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2767754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2867754Smsmith * Code in any form, with the right to sublicense such rights; and 2967754Smsmith * 3067754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3167754Smsmith * license (with the right to sublicense), under only those claims of Intel 3267754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3367754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3467754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3567754Smsmith * license, and in no event shall the patent license extend to any additions 3667754Smsmith * to or modifications of the Original Intel Code. No other license or right 3767754Smsmith * is granted directly or by implication, estoppel or otherwise; 3867754Smsmith * 3967754Smsmith * The above copyright and patent license is granted only if the following 4067754Smsmith * conditions are met: 4167754Smsmith * 4267754Smsmith * 3. Conditions 4367754Smsmith * 4467754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4567754Smsmith * Redistribution of source code of any substantial portion of the Covered 4667754Smsmith * Code or modification with rights to further distribute source must include 4767754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4867754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 4967754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 5067754Smsmith * contain a file documenting the changes Licensee made to create that Covered 5167754Smsmith * Code and the date of any change. Licensee must include in that file the 5267754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5367754Smsmith * must include a prominent statement that the modification is derived, 5467754Smsmith * directly or indirectly, from Original Intel Code. 5567754Smsmith * 5667754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5767754Smsmith * Redistribution of source code of any substantial portion of the Covered 5867754Smsmith * Code or modification without rights to further distribute source must 5967754Smsmith * include the following Disclaimer and Export Compliance provision in the 6067754Smsmith * documentation and/or other materials provided with distribution. In 6167754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6267754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6367754Smsmith * license from Licensee to its licensee is limited to the intellectual 6467754Smsmith * property embodied in the software Licensee provides to its licensee, and 6567754Smsmith * not to intellectual property embodied in modifications its licensee may 6667754Smsmith * make. 6767754Smsmith 6867754Smsmith * 6967754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 7067754Smsmith * substantial portion of the Covered Code or modification must reproduce the 7167754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 7267754Smsmith * provision in the documentation and/or other materials provided with the 7367754Smsmith * distribution. 7467754Smsmith * 7567754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7667754Smsmith * Intel Code. 7767754Smsmith * 7867754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7967754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 8067754Smsmith * other dealings in products derived from or relating to the Covered Code 8167754Smsmith * without prior written authorization from Intel. 8267754Smsmith * 8367754Smsmith * 4. Disclaimer and Export Compliance 8467754Smsmith * 8567754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8667754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8767754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8867754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8967754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 9067754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 9167754Smsmith * PARTICULAR PURPOSE. 9267754Smsmith * 9367754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9467754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9567754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9667754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9767754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9867754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9967754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 10067754Smsmith * LIMITED REMEDY. 10167754Smsmith * 10267754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10367754Smsmith * software or system incorporating such software without first obtaining any 10467754Smsmith * required license or other approval from the U. S. Department of Commerce or 10567754Smsmith * any other agency or department of the United States Government. In the 10667754Smsmith * event Licensee exports any such software from the United States or 10767754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10867754Smsmith * ensure that the distribution and export/re-export of the software is in 10967754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 11067754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 11167754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 11267754Smsmith * software, or service, directly or indirectly, to any country for which the 11367754Smsmith * United States government or any agency thereof requires an export license, 11467754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11567754Smsmith * such license, approval or letter. 11667754Smsmith * 11767754Smsmith *****************************************************************************/ 11867754Smsmith 11967754Smsmith#define __NSEVAL_C__ 12067754Smsmith 121151600Sobrien#include <contrib/dev/acpica/acpi.h> 122151600Sobrien#include <contrib/dev/acpica/acparser.h> 123151600Sobrien#include <contrib/dev/acpica/acinterp.h> 124151600Sobrien#include <contrib/dev/acpica/acnamesp.h> 12567754Smsmith 12667754Smsmith 12777424Smsmith#define _COMPONENT ACPI_NAMESPACE 12891116Smsmith ACPI_MODULE_NAME ("nseval") 12967754Smsmith 130151937Sjkim/* Local prototypes */ 13167754Smsmith 132151937Sjkimstatic ACPI_STATUS 133151937SjkimAcpiNsExecuteControlMethod ( 134151937Sjkim ACPI_PARAMETER_INFO *Info); 135151937Sjkim 136151937Sjkimstatic ACPI_STATUS 137151937SjkimAcpiNsGetObjectValue ( 138151937Sjkim ACPI_PARAMETER_INFO *Info); 139151937Sjkim 140151937Sjkim 14167754Smsmith/******************************************************************************* 14267754Smsmith * 14367754Smsmith * FUNCTION: AcpiNsEvaluateRelative 14467754Smsmith * 145151937Sjkim * PARAMETERS: Pathname - Name of method to execute, If NULL, the 146151937Sjkim * handle is the object to execute 147151937Sjkim * Info - Method info block, contains: 148151937Sjkim * ReturnObject - Where to put method's return value (if 149151937Sjkim * any). If NULL, no value is returned. 150151937Sjkim * Params - List of parameters to pass to the method, 151151937Sjkim * terminated by NULL. Params itself may be 152151937Sjkim * NULL if no parameters are being passed. 15367754Smsmith * 15467754Smsmith * RETURN: Status 15567754Smsmith * 156151937Sjkim * DESCRIPTION: Evaluate the object or find and execute the requested method 15767754Smsmith * 15867754Smsmith * MUTEX: Locks Namespace 15967754Smsmith * 16067754Smsmith ******************************************************************************/ 16167754Smsmith 16267754SmsmithACPI_STATUS 16367754SmsmithAcpiNsEvaluateRelative ( 164114237Snjl char *Pathname, 165129684Snjl ACPI_PARAMETER_INFO *Info) 16667754Smsmith{ 167127175Snjl ACPI_STATUS Status; 16867754Smsmith ACPI_NAMESPACE_NODE *Node = NULL; 169127175Snjl ACPI_GENERIC_STATE *ScopeInfo; 170114237Snjl char *InternalPath = NULL; 17167754Smsmith 17267754Smsmith 17391116Smsmith ACPI_FUNCTION_TRACE ("NsEvaluateRelative"); 17467754Smsmith 17567754Smsmith 17667754Smsmith /* 17767754Smsmith * Must have a valid object handle 17867754Smsmith */ 179129684Snjl if (!Info || !Info->Node) 18067754Smsmith { 18167754Smsmith return_ACPI_STATUS (AE_BAD_PARAMETER); 18267754Smsmith } 18367754Smsmith 18467754Smsmith /* Build an internal name string for the method */ 18567754Smsmith 18667754Smsmith Status = AcpiNsInternalizeName (Pathname, &InternalPath); 18767754Smsmith if (ACPI_FAILURE (Status)) 18867754Smsmith { 18967754Smsmith return_ACPI_STATUS (Status); 19067754Smsmith } 19167754Smsmith 192127175Snjl ScopeInfo = AcpiUtCreateGenericState (); 193127175Snjl if (!ScopeInfo) 194127175Snjl { 195127175Snjl goto Cleanup1; 196127175Snjl } 197127175Snjl 19867754Smsmith /* Get the prefix handle and Node */ 19967754Smsmith 20091116Smsmith Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 20191116Smsmith if (ACPI_FAILURE (Status)) 20291116Smsmith { 203126372Snjl goto Cleanup; 20491116Smsmith } 20567754Smsmith 206129684Snjl Info->Node = AcpiNsMapHandleToNode (Info->Node); 207129684Snjl if (!Info->Node) 20867754Smsmith { 20991116Smsmith (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 21067754Smsmith Status = AE_BAD_PARAMETER; 21167754Smsmith goto Cleanup; 21267754Smsmith } 21367754Smsmith 21467754Smsmith /* Lookup the name in the namespace */ 21567754Smsmith 216129684Snjl ScopeInfo->Scope.Node = Info->Node; 217127175Snjl Status = AcpiNsLookup (ScopeInfo, InternalPath, ACPI_TYPE_ANY, 21891116Smsmith ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, 21967754Smsmith &Node); 22067754Smsmith 22191116Smsmith (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 22267754Smsmith 22367754Smsmith if (ACPI_FAILURE (Status)) 22467754Smsmith { 22599146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Object [%s] not found [%s]\n", 22680062Smsmith Pathname, AcpiFormatException (Status))); 22767754Smsmith goto Cleanup; 22867754Smsmith } 22967754Smsmith 23067754Smsmith /* 231138287Smarks * Now that we have a handle to the object, we can attempt to evaluate it. 23267754Smsmith */ 23399146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", 23487031Smsmith Pathname, Node, AcpiNsGetAttachedObject (Node))); 23567754Smsmith 236129684Snjl Info->Node = Node; 237129684Snjl Status = AcpiNsEvaluateByHandle (Info); 23867754Smsmith 23999146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", 24067754Smsmith Pathname)); 24167754Smsmith 24267754SmsmithCleanup: 243127175Snjl AcpiUtDeleteGenericState (ScopeInfo); 24467754Smsmith 245127175SnjlCleanup1: 24680062Smsmith ACPI_MEM_FREE (InternalPath); 24767754Smsmith return_ACPI_STATUS (Status); 24867754Smsmith} 24967754Smsmith 25067754Smsmith 25167754Smsmith/******************************************************************************* 25267754Smsmith * 25367754Smsmith * FUNCTION: AcpiNsEvaluateByName 25467754Smsmith * 255151937Sjkim * PARAMETERS: Pathname - Fully qualified pathname to the object 256151937Sjkim * Info - Method info block, contains: 257138287Smarks * ReturnObject - Where to put method's return value (if 25867754Smsmith * any). If NULL, no value is returned. 259138287Smarks * Params - List of parameters to pass to the method, 26067754Smsmith * terminated by NULL. Params itself may be 26167754Smsmith * NULL if no parameters are being passed. 26267754Smsmith * 26367754Smsmith * RETURN: Status 26467754Smsmith * 265151937Sjkim * DESCRIPTION: Evaluate the object or rind and execute the requested method 266151937Sjkim * passing the given parameters 26767754Smsmith * 26867754Smsmith * MUTEX: Locks Namespace 26967754Smsmith * 27067754Smsmith ******************************************************************************/ 27167754Smsmith 27267754SmsmithACPI_STATUS 27367754SmsmithAcpiNsEvaluateByName ( 274114237Snjl char *Pathname, 275129684Snjl ACPI_PARAMETER_INFO *Info) 27667754Smsmith{ 27767754Smsmith ACPI_STATUS Status; 278114237Snjl char *InternalPath = NULL; 27967754Smsmith 28067754Smsmith 28191116Smsmith ACPI_FUNCTION_TRACE ("NsEvaluateByName"); 28267754Smsmith 28367754Smsmith 28467754Smsmith /* Build an internal name string for the method */ 28567754Smsmith 28667754Smsmith Status = AcpiNsInternalizeName (Pathname, &InternalPath); 28767754Smsmith if (ACPI_FAILURE (Status)) 28867754Smsmith { 28967754Smsmith return_ACPI_STATUS (Status); 29067754Smsmith } 29167754Smsmith 29291116Smsmith Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 29391116Smsmith if (ACPI_FAILURE (Status)) 29491116Smsmith { 295126372Snjl goto Cleanup; 29691116Smsmith } 29767754Smsmith 29867754Smsmith /* Lookup the name in the namespace */ 29967754Smsmith 30067754Smsmith Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, 30191116Smsmith ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, 302129684Snjl &Info->Node); 30367754Smsmith 30491116Smsmith (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 30567754Smsmith 30667754Smsmith if (ACPI_FAILURE (Status)) 30767754Smsmith { 308138287Smarks ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 309138287Smarks "Object at [%s] was not found, status=%.4X\n", 31067754Smsmith Pathname, Status)); 31167754Smsmith goto Cleanup; 31267754Smsmith } 31367754Smsmith 31467754Smsmith /* 315138287Smarks * Now that we have a handle to the object, we can attempt to evaluate it. 31667754Smsmith */ 31799146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", 318129684Snjl Pathname, Info->Node, AcpiNsGetAttachedObject (Info->Node))); 31967754Smsmith 320129684Snjl Status = AcpiNsEvaluateByHandle (Info); 32167754Smsmith 32299146Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", 32367754Smsmith Pathname)); 32467754Smsmith 32567754Smsmith 32667754SmsmithCleanup: 32767754Smsmith 32867754Smsmith /* Cleanup */ 32967754Smsmith 33067754Smsmith if (InternalPath) 33167754Smsmith { 33280062Smsmith ACPI_MEM_FREE (InternalPath); 33367754Smsmith } 33467754Smsmith 33567754Smsmith return_ACPI_STATUS (Status); 33667754Smsmith} 33767754Smsmith 33867754Smsmith 33967754Smsmith/******************************************************************************* 34067754Smsmith * 34167754Smsmith * FUNCTION: AcpiNsEvaluateByHandle 34267754Smsmith * 343151937Sjkim * PARAMETERS: Info - Method info block, contains: 344151937Sjkim * Node - Method/Object Node to execute 345151937Sjkim * Parameters - List of parameters to pass to the method, 346151937Sjkim * terminated by NULL. Params itself may be 34767754Smsmith * NULL if no parameters are being passed. 348151937Sjkim * ReturnObject - Where to put method's return value (if 349151937Sjkim * any). If NULL, no value is returned. 350151937Sjkim * ParameterType - Type of Parameter list 351151937Sjkim * ReturnObject - Where to put method's return value (if 352151937Sjkim * any). If NULL, no value is returned. 35367754Smsmith * 35467754Smsmith * RETURN: Status 35567754Smsmith * 356151937Sjkim * DESCRIPTION: Evaluate object or execute the requested method passing the 357151937Sjkim * given parameters 35867754Smsmith * 35967754Smsmith * MUTEX: Locks Namespace 36067754Smsmith * 36167754Smsmith ******************************************************************************/ 36267754Smsmith 36367754SmsmithACPI_STATUS 36467754SmsmithAcpiNsEvaluateByHandle ( 365129684Snjl ACPI_PARAMETER_INFO *Info) 36667754Smsmith{ 36767754Smsmith ACPI_STATUS Status; 36867754Smsmith 36967754Smsmith 37091116Smsmith ACPI_FUNCTION_TRACE ("NsEvaluateByHandle"); 37167754Smsmith 37267754Smsmith 37367754Smsmith /* Check if namespace has been initialized */ 37467754Smsmith 37567754Smsmith if (!AcpiGbl_RootNode) 37667754Smsmith { 37767754Smsmith return_ACPI_STATUS (AE_NO_NAMESPACE); 37867754Smsmith } 37967754Smsmith 38067754Smsmith /* Parameter Validation */ 38167754Smsmith 382129684Snjl if (!Info) 38367754Smsmith { 38467754Smsmith return_ACPI_STATUS (AE_BAD_PARAMETER); 38567754Smsmith } 38667754Smsmith 387129684Snjl /* Initialize the return value to an invalid object */ 38867754Smsmith 389129684Snjl Info->ReturnObject = NULL; 39067754Smsmith 39167754Smsmith /* Get the prefix handle and Node */ 39267754Smsmith 39391116Smsmith Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 39491116Smsmith if (ACPI_FAILURE (Status)) 39591116Smsmith { 39691116Smsmith return_ACPI_STATUS (Status); 39791116Smsmith } 39867754Smsmith 399129684Snjl Info->Node = AcpiNsMapHandleToNode (Info->Node); 400129684Snjl if (!Info->Node) 40167754Smsmith { 40291116Smsmith (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 40373561Smsmith return_ACPI_STATUS (AE_BAD_PARAMETER); 40467754Smsmith } 40567754Smsmith 40667754Smsmith /* 407138287Smarks * For a method alias, we must grab the actual method node so that proper 408138287Smarks * scoping context will be established before execution. 409128212Snjl */ 410129684Snjl if (AcpiNsGetType (Info->Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) 411128212Snjl { 412129684Snjl Info->Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Info->Node->Object); 413128212Snjl } 414128212Snjl 415128212Snjl /* 41667754Smsmith * Two major cases here: 41767754Smsmith * 1) The object is an actual control method -- execute it. 418138287Smarks * 2) The object is not a method -- just return it's current value 41967754Smsmith * 420138287Smarks * In both cases, the namespace is unlocked by the AcpiNs* procedure 42167754Smsmith */ 422129684Snjl if (AcpiNsGetType (Info->Node) == ACPI_TYPE_METHOD) 42367754Smsmith { 42467754Smsmith /* 42567754Smsmith * Case 1) We have an actual control method to execute 42667754Smsmith */ 427129684Snjl Status = AcpiNsExecuteControlMethod (Info); 42867754Smsmith } 42967754Smsmith else 43067754Smsmith { 43167754Smsmith /* 432138287Smarks * Case 2) Object is NOT a method, just return its current value 43367754Smsmith */ 434129684Snjl Status = AcpiNsGetObjectValue (Info); 43567754Smsmith } 43667754Smsmith 43767754Smsmith /* 438138287Smarks * Check if there is a return value on the stack that must be dealt with 43967754Smsmith */ 44067754Smsmith if (Status == AE_CTRL_RETURN_VALUE) 44167754Smsmith { 44299679Siwasaki /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */ 44367754Smsmith 44499679Siwasaki Status = AE_OK; 44567754Smsmith } 44667754Smsmith 44767754Smsmith /* 448138287Smarks * Namespace was unlocked by the handling AcpiNs* function, so we 449138287Smarks * just return 45067754Smsmith */ 45167754Smsmith return_ACPI_STATUS (Status); 45267754Smsmith} 45367754Smsmith 45467754Smsmith 45567754Smsmith/******************************************************************************* 45667754Smsmith * 45767754Smsmith * FUNCTION: AcpiNsExecuteControlMethod 45867754Smsmith * 459151937Sjkim * PARAMETERS: Info - Method info block, contains: 460151937Sjkim * Node - Method Node to execute 461151937Sjkim * ObjDesc - Method object 462151937Sjkim * Parameters - List of parameters to pass to the method, 463151937Sjkim * terminated by NULL. Params itself may be 464151937Sjkim * NULL if no parameters are being passed. 465151937Sjkim * ReturnObject - Where to put method's return value (if 466151937Sjkim * any). If NULL, no value is returned. 467151937Sjkim * ParameterType - Type of Parameter list 468151937Sjkim * ReturnObject - Where to put method's return value (if 469151937Sjkim * any). If NULL, no value is returned. 47067754Smsmith * 47167754Smsmith * RETURN: Status 47267754Smsmith * 47367754Smsmith * DESCRIPTION: Execute the requested method passing the given parameters 47467754Smsmith * 47567754Smsmith * MUTEX: Assumes namespace is locked 47667754Smsmith * 47767754Smsmith ******************************************************************************/ 47867754Smsmith 479151937Sjkimstatic ACPI_STATUS 48067754SmsmithAcpiNsExecuteControlMethod ( 481129684Snjl ACPI_PARAMETER_INFO *Info) 48267754Smsmith{ 48367754Smsmith ACPI_STATUS Status; 48467754Smsmith 48567754Smsmith 48691116Smsmith ACPI_FUNCTION_TRACE ("NsExecuteControlMethod"); 48767754Smsmith 48867754Smsmith 48967754Smsmith /* Verify that there is a method associated with this object */ 49067754Smsmith 491151937Sjkim Info->ObjDesc = AcpiNsGetAttachedObject (Info->Node); 492151937Sjkim if (!Info->ObjDesc) 49367754Smsmith { 49482367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No attached method object\n")); 49577424Smsmith 49691116Smsmith (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 49784491Smsmith return_ACPI_STATUS (AE_NULL_OBJECT); 49867754Smsmith } 49967754Smsmith 500129684Snjl ACPI_DUMP_PATHNAME (Info->Node, "Execute Method:", 50199146Siwasaki ACPI_LV_INFO, _COMPONENT); 50267754Smsmith 50399679Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Method at AML address %p Length %X\n", 504151937Sjkim Info->ObjDesc->Method.AmlStart + 1, Info->ObjDesc->Method.AmlLength - 1)); 50567754Smsmith 50667754Smsmith /* 50777424Smsmith * Unlock the namespace before execution. This allows namespace access 50877424Smsmith * via the external Acpi* interfaces while a method is being executed. 50977424Smsmith * However, any namespace deletion must acquire both the namespace and 51077424Smsmith * interpreter locks to ensure that no thread is using the portion of the 51177424Smsmith * namespace that is being deleted. 51277424Smsmith */ 51391116Smsmith Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 51491116Smsmith if (ACPI_FAILURE (Status)) 51591116Smsmith { 51691116Smsmith return_ACPI_STATUS (Status); 51791116Smsmith } 51877424Smsmith 51977424Smsmith /* 52083174Smsmith * Execute the method via the interpreter. The interpreter is locked 52183174Smsmith * here before calling into the AML parser 52267754Smsmith */ 52383174Smsmith Status = AcpiExEnterInterpreter (); 52483174Smsmith if (ACPI_FAILURE (Status)) 52583174Smsmith { 52683174Smsmith return_ACPI_STATUS (Status); 52783174Smsmith } 52867754Smsmith 529151937Sjkim Status = AcpiPsExecuteMethod (Info); 53083174Smsmith AcpiExExitInterpreter (); 53183174Smsmith 53267754Smsmith return_ACPI_STATUS (Status); 53367754Smsmith} 53467754Smsmith 53567754Smsmith 53667754Smsmith/******************************************************************************* 53767754Smsmith * 53867754Smsmith * FUNCTION: AcpiNsGetObjectValue 53967754Smsmith * 540151937Sjkim * PARAMETERS: Info - Method info block, contains: 541151937Sjkim * Node - Object's NS node 542151937Sjkim * ReturnObject - Where to put object value (if 543151937Sjkim * any). If NULL, no value is returned. 54467754Smsmith * 54567754Smsmith * RETURN: Status 54667754Smsmith * 54767754Smsmith * DESCRIPTION: Return the current value of the object 54867754Smsmith * 54991116Smsmith * MUTEX: Assumes namespace is locked, leaves namespace unlocked 55067754Smsmith * 55167754Smsmith ******************************************************************************/ 55267754Smsmith 553151937Sjkimstatic ACPI_STATUS 55467754SmsmithAcpiNsGetObjectValue ( 555129684Snjl ACPI_PARAMETER_INFO *Info) 55667754Smsmith{ 55767754Smsmith ACPI_STATUS Status = AE_OK; 558129684Snjl ACPI_NAMESPACE_NODE *ResolvedNode = Info->Node; 55967754Smsmith 56067754Smsmith 56191116Smsmith ACPI_FUNCTION_TRACE ("NsGetObjectValue"); 56267754Smsmith 56367754Smsmith 56467754Smsmith /* 565138287Smarks * Objects require additional resolution steps (e.g., the Node may be a 566138287Smarks * field that must be read, etc.) -- we can't just grab the object out of 567138287Smarks * the node. 56867754Smsmith */ 56967754Smsmith 57067754Smsmith /* 571138287Smarks * Use ResolveNodeToValue() to get the associated value. This call always 572138287Smarks * deletes ObjDesc (allocated above). 57391116Smsmith * 574138287Smarks * NOTE: we can get away with passing in NULL for a walk state because 575138287Smarks * ObjDesc is guaranteed to not be a reference to either a method local or 576138287Smarks * a method argument (because this interface can only be called from the 577138287Smarks * AcpiEvaluate external interface, never called from a running method.) 57891116Smsmith * 579138287Smarks * Even though we do not directly invoke the interpreter for this, we must 580138287Smarks * enter it because we could access an opregion. The opregion access code 581138287Smarks * assumes that the interpreter is locked. 58291116Smsmith * 583138287Smarks * We must release the namespace lock before entering the intepreter. 58467754Smsmith */ 58591116Smsmith Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 58691116Smsmith if (ACPI_FAILURE (Status)) 58767754Smsmith { 58891116Smsmith return_ACPI_STATUS (Status); 58991116Smsmith } 59067754Smsmith 59191116Smsmith Status = AcpiExEnterInterpreter (); 59291116Smsmith if (ACPI_SUCCESS (Status)) 59391116Smsmith { 59499679Siwasaki Status = AcpiExResolveNodeToValue (&ResolvedNode, NULL); 59567754Smsmith /* 596138287Smarks * If AcpiExResolveNodeToValue() succeeded, the return value was placed 597138287Smarks * in ResolvedNode. 59867754Smsmith */ 59991116Smsmith AcpiExExitInterpreter (); 60091116Smsmith 60177424Smsmith if (ACPI_SUCCESS (Status)) 60277424Smsmith { 60391116Smsmith Status = AE_CTRL_RETURN_VALUE; 604138287Smarks Info->ReturnObject = ACPI_CAST_PTR 605138287Smarks (ACPI_OPERAND_OBJECT, ResolvedNode); 606102550Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n", 607138287Smarks Info->ReturnObject, 608138287Smarks AcpiUtGetObjectTypeName (Info->ReturnObject))); 60977424Smsmith } 61067754Smsmith } 61167754Smsmith 61277424Smsmith /* Namespace is unlocked */ 61367754Smsmith 61477424Smsmith return_ACPI_STATUS (Status); 61591116Smsmith} 61677424Smsmith 617