nseval.c revision 70243
167754Smsmith/******************************************************************************* 267754Smsmith * 367754Smsmith * Module Name: nseval - Object evaluation interfaces -- includes control 467754Smsmith * method lookup and execution. 570243Smsmith * $Revision: 80 $ 667754Smsmith * 767754Smsmith ******************************************************************************/ 867754Smsmith 967754Smsmith/****************************************************************************** 1067754Smsmith * 1167754Smsmith * 1. Copyright Notice 1267754Smsmith * 1370243Smsmith * Some or all of this work - Copyright (c) 1999, 2000, 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 12167754Smsmith#include "acpi.h" 12267754Smsmith#include "amlcode.h" 12367754Smsmith#include "acparser.h" 12467754Smsmith#include "acinterp.h" 12567754Smsmith#include "acnamesp.h" 12667754Smsmith 12767754Smsmith 12867754Smsmith#define _COMPONENT NAMESPACE 12967754Smsmith MODULE_NAME ("nseval") 13067754Smsmith 13167754Smsmith 13267754Smsmith/******************************************************************************* 13367754Smsmith * 13467754Smsmith * FUNCTION: AcpiNsEvaluateRelative 13567754Smsmith * 13667754Smsmith * PARAMETERS: Handle - The relative containing object 13767754Smsmith * *Pathname - Name of method to execute, If NULL, the 13867754Smsmith * handle is the object to execute 13967754Smsmith * **Params - List of parameters to pass to the method, 14067754Smsmith * terminated by NULL. Params itself may be 14167754Smsmith * NULL if no parameters are being passed. 14267754Smsmith * *ReturnObject - Where to put method's return value (if 14367754Smsmith * any). If NULL, no value is returned. 14467754Smsmith * 14567754Smsmith * RETURN: Status 14667754Smsmith * 14767754Smsmith * DESCRIPTION: Find and execute the requested method using the handle as a 14867754Smsmith * scope 14967754Smsmith * 15067754Smsmith * MUTEX: Locks Namespace 15167754Smsmith * 15267754Smsmith ******************************************************************************/ 15367754Smsmith 15467754SmsmithACPI_STATUS 15567754SmsmithAcpiNsEvaluateRelative ( 15667754Smsmith ACPI_NAMESPACE_NODE *Handle, 15767754Smsmith NATIVE_CHAR *Pathname, 15867754Smsmith ACPI_OPERAND_OBJECT **Params, 15967754Smsmith ACPI_OPERAND_OBJECT **ReturnObject) 16067754Smsmith{ 16167754Smsmith ACPI_NAMESPACE_NODE *PrefixNode; 16267754Smsmith ACPI_STATUS Status; 16367754Smsmith ACPI_NAMESPACE_NODE *Node = NULL; 16467754Smsmith NATIVE_CHAR *InternalPath = NULL; 16567754Smsmith ACPI_GENERIC_STATE ScopeInfo; 16667754Smsmith 16767754Smsmith 16867754Smsmith FUNCTION_TRACE ("NsEvaluateRelative"); 16967754Smsmith 17067754Smsmith 17167754Smsmith /* 17267754Smsmith * Must have a valid object handle 17367754Smsmith */ 17467754Smsmith if (!Handle) 17567754Smsmith { 17667754Smsmith return_ACPI_STATUS (AE_BAD_PARAMETER); 17767754Smsmith } 17867754Smsmith 17967754Smsmith /* Build an internal name string for the method */ 18067754Smsmith 18167754Smsmith Status = AcpiNsInternalizeName (Pathname, &InternalPath); 18267754Smsmith if (ACPI_FAILURE (Status)) 18367754Smsmith { 18467754Smsmith return_ACPI_STATUS (Status); 18567754Smsmith } 18667754Smsmith 18767754Smsmith /* Get the prefix handle and Node */ 18867754Smsmith 18967754Smsmith AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); 19067754Smsmith 19167754Smsmith PrefixNode = AcpiNsConvertHandleToEntry (Handle); 19267754Smsmith if (!PrefixNode) 19367754Smsmith { 19467754Smsmith AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); 19567754Smsmith Status = AE_BAD_PARAMETER; 19667754Smsmith goto Cleanup; 19767754Smsmith } 19867754Smsmith 19967754Smsmith /* Lookup the name in the namespace */ 20067754Smsmith 20167754Smsmith ScopeInfo.Scope.Node = PrefixNode; 20267754Smsmith Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY, 20367754Smsmith IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, 20467754Smsmith &Node); 20567754Smsmith 20667754Smsmith AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); 20767754Smsmith 20867754Smsmith if (ACPI_FAILURE (Status)) 20967754Smsmith { 21067754Smsmith DEBUG_PRINT (ACPI_INFO, 21167754Smsmith ("NsEvaluateRelative: Object [%s] not found [%.4X]\n", 21267754Smsmith Pathname, AcpiCmFormatException (Status))); 21367754Smsmith goto Cleanup; 21467754Smsmith } 21567754Smsmith 21667754Smsmith /* 21767754Smsmith * Now that we have a handle to the object, we can attempt 21867754Smsmith * to evaluate it. 21967754Smsmith */ 22067754Smsmith 22167754Smsmith DEBUG_PRINT (ACPI_INFO, 22267754Smsmith ("NsEvaluateRelative: %s [%p] Value %p\n", 22367754Smsmith Pathname, Node, Node->Object)); 22467754Smsmith 22567754Smsmith Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject); 22667754Smsmith 22767754Smsmith DEBUG_PRINT (ACPI_INFO, 22867754Smsmith ("NsEvaluateRelative: *** Completed eval of object %s ***\n", 22967754Smsmith Pathname)); 23067754Smsmith 23167754SmsmithCleanup: 23267754Smsmith 23367754Smsmith /* Cleanup */ 23467754Smsmith 23567754Smsmith AcpiCmFree (InternalPath); 23667754Smsmith 23767754Smsmith return_ACPI_STATUS (Status); 23867754Smsmith} 23967754Smsmith 24067754Smsmith 24167754Smsmith/******************************************************************************* 24267754Smsmith * 24367754Smsmith * FUNCTION: AcpiNsEvaluateByName 24467754Smsmith * 24567754Smsmith * PARAMETERS: Pathname - Fully qualified pathname to the object 24667754Smsmith * *ReturnObject - Where to put method's return value (if 24767754Smsmith * any). If NULL, no value is returned. 24867754Smsmith * **Params - List of parameters to pass to the method, 24967754Smsmith * terminated by NULL. Params itself may be 25067754Smsmith * NULL if no parameters are being passed. 25167754Smsmith * 25267754Smsmith * RETURN: Status 25367754Smsmith * 25467754Smsmith * DESCRIPTION: Find and execute the requested method passing the given 25567754Smsmith * parameters 25667754Smsmith * 25767754Smsmith * MUTEX: Locks Namespace 25867754Smsmith * 25967754Smsmith ******************************************************************************/ 26067754Smsmith 26167754SmsmithACPI_STATUS 26267754SmsmithAcpiNsEvaluateByName ( 26367754Smsmith NATIVE_CHAR *Pathname, 26467754Smsmith ACPI_OPERAND_OBJECT **Params, 26567754Smsmith ACPI_OPERAND_OBJECT **ReturnObject) 26667754Smsmith{ 26767754Smsmith ACPI_STATUS Status; 26867754Smsmith ACPI_NAMESPACE_NODE *Node = NULL; 26967754Smsmith NATIVE_CHAR *InternalPath = NULL; 27067754Smsmith 27167754Smsmith 27267754Smsmith FUNCTION_TRACE ("NsEvaluateByName"); 27367754Smsmith 27467754Smsmith 27567754Smsmith /* Build an internal name string for the method */ 27667754Smsmith 27767754Smsmith Status = AcpiNsInternalizeName (Pathname, &InternalPath); 27867754Smsmith if (ACPI_FAILURE (Status)) 27967754Smsmith { 28067754Smsmith return_ACPI_STATUS (Status); 28167754Smsmith } 28267754Smsmith 28367754Smsmith AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); 28467754Smsmith 28567754Smsmith /* Lookup the name in the namespace */ 28667754Smsmith 28767754Smsmith Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, 28867754Smsmith IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, 28967754Smsmith &Node); 29067754Smsmith 29167754Smsmith AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); 29267754Smsmith 29367754Smsmith if (ACPI_FAILURE (Status)) 29467754Smsmith { 29567754Smsmith DEBUG_PRINT (ACPI_INFO, 29667754Smsmith ("NsEvaluateByName: Object at [%s] was not found, status=%.4X\n", 29767754Smsmith Pathname, Status)); 29867754Smsmith goto Cleanup; 29967754Smsmith } 30067754Smsmith 30167754Smsmith /* 30267754Smsmith * Now that we have a handle to the object, we can attempt 30367754Smsmith * to evaluate it. 30467754Smsmith */ 30567754Smsmith 30667754Smsmith DEBUG_PRINT (ACPI_INFO, 30767754Smsmith ("NsEvaluateByName: %s [%p] Value %p\n", 30867754Smsmith Pathname, Node, Node->Object)); 30967754Smsmith 31067754Smsmith Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject); 31167754Smsmith 31267754Smsmith DEBUG_PRINT (ACPI_INFO, 31367754Smsmith ("NsEvaluateByName: *** Completed eval of object %s ***\n", 31467754Smsmith Pathname)); 31567754Smsmith 31667754Smsmith 31767754SmsmithCleanup: 31867754Smsmith 31967754Smsmith /* Cleanup */ 32067754Smsmith 32167754Smsmith if (InternalPath) 32267754Smsmith { 32367754Smsmith AcpiCmFree (InternalPath); 32467754Smsmith } 32567754Smsmith 32667754Smsmith return_ACPI_STATUS (Status); 32767754Smsmith} 32867754Smsmith 32967754Smsmith 33067754Smsmith/******************************************************************************* 33167754Smsmith * 33267754Smsmith * FUNCTION: AcpiNsEvaluateByHandle 33367754Smsmith * 33467754Smsmith * PARAMETERS: Handle - Method Node to execute 33567754Smsmith * **Params - List of parameters to pass to the method, 33667754Smsmith * terminated by NULL. Params itself may be 33767754Smsmith * NULL if no parameters are being passed. 33867754Smsmith * *ReturnObject - Where to put method's return value (if 33967754Smsmith * any). If NULL, no value is returned. 34067754Smsmith * 34167754Smsmith * RETURN: Status 34267754Smsmith * 34367754Smsmith * DESCRIPTION: Execute the requested method passing the given parameters 34467754Smsmith * 34567754Smsmith * MUTEX: Locks Namespace 34667754Smsmith * 34767754Smsmith ******************************************************************************/ 34867754Smsmith 34967754SmsmithACPI_STATUS 35067754SmsmithAcpiNsEvaluateByHandle ( 35167754Smsmith ACPI_NAMESPACE_NODE *Handle, 35267754Smsmith ACPI_OPERAND_OBJECT **Params, 35367754Smsmith ACPI_OPERAND_OBJECT **ReturnObject) 35467754Smsmith{ 35567754Smsmith ACPI_NAMESPACE_NODE *Node; 35667754Smsmith ACPI_STATUS Status; 35767754Smsmith ACPI_OPERAND_OBJECT *LocalReturnObject; 35867754Smsmith 35967754Smsmith 36067754Smsmith FUNCTION_TRACE ("NsEvaluateByHandle"); 36167754Smsmith 36267754Smsmith 36367754Smsmith /* Check if namespace has been initialized */ 36467754Smsmith 36567754Smsmith if (!AcpiGbl_RootNode) 36667754Smsmith { 36767754Smsmith return_ACPI_STATUS (AE_NO_NAMESPACE); 36867754Smsmith } 36967754Smsmith 37067754Smsmith /* Parameter Validation */ 37167754Smsmith 37267754Smsmith if (!Handle) 37367754Smsmith { 37467754Smsmith return_ACPI_STATUS (AE_BAD_PARAMETER); 37567754Smsmith } 37667754Smsmith 37767754Smsmith if (ReturnObject) 37867754Smsmith { 37967754Smsmith /* Initialize the return value to an invalid object */ 38067754Smsmith 38167754Smsmith *ReturnObject = NULL; 38267754Smsmith } 38367754Smsmith 38467754Smsmith /* Get the prefix handle and Node */ 38567754Smsmith 38667754Smsmith AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); 38767754Smsmith 38867754Smsmith Node = AcpiNsConvertHandleToEntry (Handle); 38967754Smsmith if (!Node) 39067754Smsmith { 39167754Smsmith Status = AE_BAD_PARAMETER; 39267754Smsmith goto UnlockAndExit; 39367754Smsmith } 39467754Smsmith 39567754Smsmith 39667754Smsmith /* 39767754Smsmith * Two major cases here: 39867754Smsmith * 1) The object is an actual control method -- execute it. 39967754Smsmith * 2) The object is not a method -- just return it's current 40067754Smsmith * value 40167754Smsmith * 40267754Smsmith * In both cases, the namespace is unlocked by the 40367754Smsmith * AcpiNs* procedure 40467754Smsmith */ 40567754Smsmith if (AcpiNsGetType (Node) == ACPI_TYPE_METHOD) 40667754Smsmith { 40767754Smsmith /* 40867754Smsmith * Case 1) We have an actual control method to execute 40967754Smsmith */ 41067754Smsmith Status = AcpiNsExecuteControlMethod (Node, Params, 41167754Smsmith &LocalReturnObject); 41267754Smsmith } 41367754Smsmith 41467754Smsmith else 41567754Smsmith { 41667754Smsmith /* 41767754Smsmith * Case 2) Object is NOT a method, just return its 41867754Smsmith * current value 41967754Smsmith */ 42067754Smsmith Status = AcpiNsGetObjectValue (Node, &LocalReturnObject); 42167754Smsmith } 42267754Smsmith 42367754Smsmith 42467754Smsmith /* 42567754Smsmith * Check if there is a return value on the stack that must 42667754Smsmith * be dealt with 42767754Smsmith */ 42867754Smsmith if (Status == AE_CTRL_RETURN_VALUE) 42967754Smsmith { 43067754Smsmith /* 43167754Smsmith * If the Method returned a value and the caller 43267754Smsmith * provided a place to store a returned value, Copy 43367754Smsmith * the returned value to the object descriptor provided 43467754Smsmith * by the caller. 43567754Smsmith */ 43667754Smsmith if (ReturnObject) 43767754Smsmith { 43867754Smsmith /* 43967754Smsmith * Valid return object, copy the pointer to 44067754Smsmith * the returned object 44167754Smsmith */ 44267754Smsmith *ReturnObject = LocalReturnObject; 44367754Smsmith } 44467754Smsmith 44567754Smsmith 44667754Smsmith /* Map AE_RETURN_VALUE to AE_OK, we are done with it */ 44767754Smsmith 44867754Smsmith if (Status == AE_CTRL_RETURN_VALUE) 44967754Smsmith { 45067754Smsmith Status = AE_OK; 45167754Smsmith } 45267754Smsmith } 45367754Smsmith 45467754Smsmith /* 45567754Smsmith * Namespace was unlocked by the handling AcpiNs* function, 45667754Smsmith * so we just return 45767754Smsmith */ 45867754Smsmith return_ACPI_STATUS (Status); 45967754Smsmith 46067754Smsmith 46167754SmsmithUnlockAndExit: 46267754Smsmith 46367754Smsmith AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); 46467754Smsmith return_ACPI_STATUS (Status); 46567754Smsmith} 46667754Smsmith 46767754Smsmith 46867754Smsmith/******************************************************************************* 46967754Smsmith * 47067754Smsmith * FUNCTION: AcpiNsExecuteControlMethod 47167754Smsmith * 47267754Smsmith * PARAMETERS: MethodNode - The object/method 47367754Smsmith * **Params - List of parameters to pass to the method, 47467754Smsmith * terminated by NULL. Params itself may be 47567754Smsmith * NULL if no parameters are being passed. 47667754Smsmith * **ReturnObjDesc - List of result objects to be returned 47767754Smsmith * from the method. 47867754Smsmith * 47967754Smsmith * RETURN: Status 48067754Smsmith * 48167754Smsmith * DESCRIPTION: Execute the requested method passing the given parameters 48267754Smsmith * 48367754Smsmith * MUTEX: Assumes namespace is locked 48467754Smsmith * 48567754Smsmith ******************************************************************************/ 48667754Smsmith 48767754SmsmithACPI_STATUS 48867754SmsmithAcpiNsExecuteControlMethod ( 48967754Smsmith ACPI_NAMESPACE_NODE *MethodNode, 49067754Smsmith ACPI_OPERAND_OBJECT **Params, 49167754Smsmith ACPI_OPERAND_OBJECT **ReturnObjDesc) 49267754Smsmith{ 49367754Smsmith ACPI_STATUS Status; 49467754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 49567754Smsmith 49667754Smsmith 49767754Smsmith FUNCTION_TRACE ("NsExecuteControlMethod"); 49867754Smsmith 49967754Smsmith 50067754Smsmith /* Verify that there is a method associated with this object */ 50167754Smsmith 50267754Smsmith ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) MethodNode); 50367754Smsmith if (!ObjDesc) 50467754Smsmith { 50567754Smsmith DEBUG_PRINT (ACPI_ERROR, 50667754Smsmith ("Control method is undefined (nil value)\n")); 50767754Smsmith return_ACPI_STATUS (AE_ERROR); 50867754Smsmith } 50967754Smsmith 51067754Smsmith 51167754Smsmith DEBUG_PRINT (ACPI_INFO, ("Control method at Offset %x Length %lx]\n", 51267754Smsmith ObjDesc->Method.Pcode + 1, 51367754Smsmith ObjDesc->Method.PcodeLength - 1)); 51467754Smsmith 51567754Smsmith DUMP_PATHNAME (MethodNode, "NsExecuteControlMethod: Executing", 51667754Smsmith TRACE_NAMES, _COMPONENT); 51767754Smsmith 51867754Smsmith DEBUG_PRINT (TRACE_NAMES, 51967754Smsmith ("At offset %8XH\n", ObjDesc->Method.Pcode + 1)); 52067754Smsmith 52167754Smsmith 52267754Smsmith /* 52367754Smsmith * Unlock the namespace before execution. This allows namespace access 52467754Smsmith * via the external Acpi* interfaces while a method is being executed. 52567754Smsmith * However, any namespace deletion must acquire both the namespace and 52667754Smsmith * interpreter locks to ensure that no thread is using the portion of the 52767754Smsmith * namespace that is being deleted. 52867754Smsmith */ 52967754Smsmith 53067754Smsmith AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); 53167754Smsmith 53267754Smsmith /* 53367754Smsmith * Excecute the method via the interpreter 53467754Smsmith */ 53567754Smsmith Status = AcpiAmlExecuteMethod (MethodNode, Params, ReturnObjDesc); 53667754Smsmith 53767754Smsmith return_ACPI_STATUS (Status); 53867754Smsmith} 53967754Smsmith 54067754Smsmith 54167754Smsmith/******************************************************************************* 54267754Smsmith * 54367754Smsmith * FUNCTION: AcpiNsGetObjectValue 54467754Smsmith * 54567754Smsmith * PARAMETERS: Node - The object 54667754Smsmith * 54767754Smsmith * RETURN: Status 54867754Smsmith * 54967754Smsmith * DESCRIPTION: Return the current value of the object 55067754Smsmith * 55167754Smsmith * MUTEX: Assumes namespace is locked 55267754Smsmith * 55367754Smsmith ******************************************************************************/ 55467754Smsmith 55567754SmsmithACPI_STATUS 55667754SmsmithAcpiNsGetObjectValue ( 55767754Smsmith ACPI_NAMESPACE_NODE *Node, 55867754Smsmith ACPI_OPERAND_OBJECT **ReturnObjDesc) 55967754Smsmith{ 56067754Smsmith ACPI_STATUS Status = AE_OK; 56167754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 56267754Smsmith ACPI_OPERAND_OBJECT *ValDesc; 56367754Smsmith 56467754Smsmith 56567754Smsmith FUNCTION_TRACE ("NsGetObjectValue"); 56667754Smsmith 56767754Smsmith 56867754Smsmith /* 56967754Smsmith * We take the value from certain objects directly 57067754Smsmith */ 57167754Smsmith 57267754Smsmith if ((Node->Type == ACPI_TYPE_PROCESSOR) || 57367754Smsmith (Node->Type == ACPI_TYPE_POWER)) 57467754Smsmith { 57567754Smsmith /* 57667754Smsmith * Create a Reference object to contain the object 57767754Smsmith */ 57867754Smsmith ObjDesc = AcpiCmCreateInternalObject (Node->Type); 57967754Smsmith if (!ObjDesc) 58067754Smsmith { 58167754Smsmith Status = AE_NO_MEMORY; 58267754Smsmith goto UnlockAndExit; 58367754Smsmith } 58467754Smsmith 58567754Smsmith /* 58667754Smsmith * Get the attached object 58767754Smsmith */ 58867754Smsmith 58967754Smsmith ValDesc = AcpiNsGetAttachedObject (Node); 59067754Smsmith if (!ValDesc) 59167754Smsmith { 59267754Smsmith Status = AE_NULL_OBJECT; 59367754Smsmith goto UnlockAndExit; 59467754Smsmith } 59567754Smsmith 59667754Smsmith /* 59767754Smsmith * Just copy from the original to the return object 59867754Smsmith * 59967754Smsmith * TBD: [Future] - need a low-level object copy that handles 60067754Smsmith * the reference count automatically. (Don't want to copy it) 60167754Smsmith */ 60267754Smsmith 60367754Smsmith MEMCPY (ObjDesc, ValDesc, sizeof (ACPI_OPERAND_OBJECT)); 60467754Smsmith ObjDesc->Common.ReferenceCount = 1; 60567754Smsmith } 60667754Smsmith 60767754Smsmith 60867754Smsmith /* 60967754Smsmith * Other objects require a reference object wrapper which we 61067754Smsmith * then attempt to resolve. 61167754Smsmith */ 61267754Smsmith else 61367754Smsmith { 61467754Smsmith /* Create an Reference object to contain the object */ 61567754Smsmith 61667754Smsmith ObjDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE); 61767754Smsmith if (!ObjDesc) 61867754Smsmith { 61967754Smsmith Status = AE_NO_MEMORY; 62067754Smsmith goto UnlockAndExit; 62167754Smsmith } 62267754Smsmith 62367754Smsmith /* Construct a descriptor pointing to the name */ 62467754Smsmith 62567754Smsmith ObjDesc->Reference.OpCode = (UINT8) AML_NAME_OP; 62667754Smsmith ObjDesc->Reference.Object = (void *) Node; 62767754Smsmith 62867754Smsmith /* 62967754Smsmith * Use AcpiAmlResolveToValue() to get the associated value. 63067754Smsmith * The call to AcpiAmlResolveToValue causes 63167754Smsmith * ObjDesc (allocated above) to always be deleted. 63267754Smsmith * 63367754Smsmith * NOTE: we can get away with passing in NULL for a walk state 63467754Smsmith * because ObjDesc is guaranteed to not be a reference to either 63567754Smsmith * a method local or a method argument 63667754Smsmith * 63767754Smsmith * Even though we do not technically need to use the interpreter 63867754Smsmith * for this, we must enter it because we could hit an opregion. 63967754Smsmith * The opregion access code assumes it is in the interpreter. 64067754Smsmith */ 64167754Smsmith 64267754Smsmith AcpiAmlEnterInterpreter(); 64367754Smsmith 64467754Smsmith Status = AcpiAmlResolveToValue (&ObjDesc, NULL); 64567754Smsmith 64667754Smsmith AcpiAmlExitInterpreter(); 64767754Smsmith } 64867754Smsmith 64967754Smsmith /* 65067754Smsmith * If AcpiAmlResolveToValue() succeeded, the return value was 65167754Smsmith * placed in ObjDesc. 65267754Smsmith */ 65367754Smsmith 65467754Smsmith if (ACPI_SUCCESS (Status)) 65567754Smsmith { 65667754Smsmith Status = AE_CTRL_RETURN_VALUE; 65767754Smsmith 65867754Smsmith *ReturnObjDesc = ObjDesc; 65967754Smsmith DEBUG_PRINT (ACPI_INFO, 66067754Smsmith ("NsGetObjectValue: Returning obj %p\n", *ReturnObjDesc)); 66167754Smsmith } 66267754Smsmith 66367754Smsmith 66467754SmsmithUnlockAndExit: 66567754Smsmith 66667754Smsmith /* Unlock the namespace */ 66767754Smsmith 66867754Smsmith AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); 66967754Smsmith return_ACPI_STATUS (Status); 67067754Smsmith} 671