|
||||
Warning, cross-references for /kernel/drivers/acpica/nseval.c need to be fixed.
0001 /******************************************************************************* 0002 * 0003 * Module Name: nseval - Object evaluation, includes control method execution 0004 * 0005 ******************************************************************************/ 0006 0007 /****************************************************************************** 0008 * 0009 * 1. Copyright Notice 0010 * 0011 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 0012 * All rights reserved. 0013 * 0014 * 2. License 0015 * 0016 * 2.1. This is your license from Intel Corp. under its intellectual property 0017 * rights. You may have additional license terms from the party that provided 0018 * you this software, covering your right to use that party's intellectual 0019 * property rights. 0020 * 0021 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 0022 * copy of the source code appearing in this file ("Covered Code") an 0023 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 0024 * base code distributed originally by Intel ("Original Intel Code") to copy, 0025 * make derivatives, distribute, use and display any portion of the Covered 0026 * Code in any form, with the right to sublicense such rights; and 0027 * 0028 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 0029 * license (with the right to sublicense), under only those claims of Intel 0030 * patents that are infringed by the Original Intel Code, to make, use, sell, 0031 * offer to sell, and import the Covered Code and derivative works thereof 0032 * solely to the minimum extent necessary to exercise the above copyright 0033 * license, and in no event shall the patent license extend to any additions 0034 * to or modifications of the Original Intel Code. No other license or right 0035 * is granted directly or by implication, estoppel or otherwise; 0036 * 0037 * The above copyright and patent license is granted only if the following 0038 * conditions are met: 0039 * 0040 * 3. Conditions 0041 * 0042 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 0043 * Redistribution of source code of any substantial portion of the Covered 0044 * Code or modification with rights to further distribute source must include 0045 * the above Copyright Notice, the above License, this list of Conditions, 0046 * and the following Disclaimer and Export Compliance provision. In addition, 0047 * Licensee must cause all Covered Code to which Licensee contributes to 0048 * contain a file documenting the changes Licensee made to create that Covered 0049 * Code and the date of any change. Licensee must include in that file the 0050 * documentation of any changes made by any predecessor Licensee. Licensee 0051 * must include a prominent statement that the modification is derived, 0052 * directly or indirectly, from Original Intel Code. 0053 * 0054 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 0055 * Redistribution of source code of any substantial portion of the Covered 0056 * Code or modification without rights to further distribute source must 0057 * include the following Disclaimer and Export Compliance provision in the 0058 * documentation and/or other materials provided with distribution. In 0059 * addition, Licensee may not authorize further sublicense of source of any 0060 * portion of the Covered Code, and must include terms to the effect that the 0061 * license from Licensee to its licensee is limited to the intellectual 0062 * property embodied in the software Licensee provides to its licensee, and 0063 * not to intellectual property embodied in modifications its licensee may 0064 * make. 0065 0066 * 0067 * 3.3. Redistribution of Executable. Redistribution in executable form of any 0068 * substantial portion of the Covered Code or modification must reproduce the 0069 * above Copyright Notice, and the following Disclaimer and Export Compliance 0070 * provision in the documentation and/or other materials provided with the 0071 * distribution. 0072 * 0073 * 3.4. Intel retains all right, title, and interest in and to the Original 0074 * Intel Code. 0075 * 0076 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 0077 * Intel shall be used in advertising or otherwise to promote the sale, use or 0078 * other dealings in products derived from or relating to the Covered Code 0079 * without prior written authorization from Intel. 0080 * 0081 * 4. Disclaimer and Export Compliance 0082 * 0083 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 0084 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 0085 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 0086 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 0087 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 0088 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 0089 * PARTICULAR PURPOSE. 0090 * 0091 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 0092 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 0093 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 0094 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 0095 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 0096 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 0097 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 0098 * LIMITED REMEDY. 0099 * 0100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 0101 * software or system incorporating such software without first obtaining any 0102 * required license or other approval from the U. S. Department of Commerce or 0103 * any other agency or department of the United States Government. In the 0104 * event Licensee exports any such software from the United States or 0105 * re-exports any such software from a foreign destination, Licensee shall 0106 * ensure that the distribution and export/re-export of the software is in 0107 * compliance with all laws, regulations, orders, or other restrictions of the 0108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 0109 * any of its subsidiaries will export/re-export any technical data, process, 0110 * software, or service, directly or indirectly, to any country for which the 0111 * United States government or any agency thereof requires an export license, 0112 * other governmental approval, or letter of assurance, without first obtaining 0113 * such license, approval or letter. 0114 * 0115 *****************************************************************************/ 0116 0117 #define __NSEVAL_C__ 0118 0119 #include "acpi.h" 0120 #include "accommon.h" 0121 #include "acparser.h" 0122 #include "acinterp.h" 0123 #include "acnamesp.h" 0124 0125 0126 #define _COMPONENT ACPI_NAMESPACE 0127 ACPI_MODULE_NAME ("nseval") 0128 0129 0130 /******************************************************************************* 0131 * 0132 * FUNCTION: AcpiNsEvaluate 0133 * 0134 * PARAMETERS: Info - Evaluation info block, contains: 0135 * PrefixNode - Prefix or Method/Object Node to execute 0136 * Pathname - Name of method to execute, If NULL, the 0137 * Node is the object to execute 0138 * Parameters - List of parameters to pass to the method, 0139 * terminated by NULL. Params itself may be 0140 * NULL if no parameters are being passed. 0141 * ReturnObject - Where to put method's return value (if 0142 * any). If NULL, no value is returned. 0143 * ParameterType - Type of Parameter list 0144 * ReturnObject - Where to put method's return value (if 0145 * any). If NULL, no value is returned. 0146 * Flags - ACPI_IGNORE_RETURN_VALUE to delete return 0147 * 0148 * RETURN: Status 0149 * 0150 * DESCRIPTION: Execute a control method or return the current value of an 0151 * ACPI namespace object. 0152 * 0153 * MUTEX: Locks interpreter 0154 * 0155 ******************************************************************************/ 0156 0157 ACPI_STATUS 0158 AcpiNsEvaluate ( 0159 ACPI_EVALUATE_INFO *Info) 0160 { 0161 ACPI_STATUS Status; 0162 ACPI_NAMESPACE_NODE *Node; 0163 0164 0165 ACPI_FUNCTION_TRACE (NsEvaluate); 0166 0167 0168 if (!Info) 0169 { 0170 return_ACPI_STATUS (AE_BAD_PARAMETER); 0171 } 0172 0173 /* Initialize the return value to an invalid object */ 0174 0175 Info->ReturnObject = NULL; 0176 Info->ParamCount = 0; 0177 0178 /* 0179 * Get the actual namespace node for the target object. Handles these cases: 0180 * 0181 * 1) Null node, Pathname (absolute path) 0182 * 2) Node, Pathname (path relative to Node) 0183 * 3) Node, Null Pathname 0184 */ 0185 Status = AcpiNsGetNode (Info->PrefixNode, Info->Pathname, 0186 ACPI_NS_NO_UPSEARCH, &Info->ResolvedNode); 0187 if (ACPI_FAILURE (Status)) 0188 { 0189 return_ACPI_STATUS (Status); 0190 } 0191 0192 /* 0193 * For a method alias, we must grab the actual method node so that proper 0194 * scoping context will be established before execution. 0195 */ 0196 if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_LOCAL_METHOD_ALIAS) 0197 { 0198 Info->ResolvedNode = 0199 ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Info->ResolvedNode->Object); 0200 } 0201 0202 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Info->Pathname, 0203 Info->ResolvedNode, AcpiNsGetAttachedObject (Info->ResolvedNode))); 0204 0205 Node = Info->ResolvedNode; 0206 0207 /* 0208 * Two major cases here: 0209 * 0210 * 1) The object is a control method -- execute it 0211 * 2) The object is not a method -- just return it's current value 0212 */ 0213 if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_METHOD) 0214 { 0215 /* 0216 * 1) Object is a control method - execute it 0217 */ 0218 0219 /* Verify that there is a method object associated with this node */ 0220 0221 Info->ObjDesc = AcpiNsGetAttachedObject (Info->ResolvedNode); 0222 if (!Info->ObjDesc) 0223 { 0224 ACPI_ERROR ((AE_INFO, "Control method has no attached sub-object")); 0225 return_ACPI_STATUS (AE_NULL_OBJECT); 0226 } 0227 0228 /* Count the number of arguments being passed to the method */ 0229 0230 if (Info->Parameters) 0231 { 0232 while (Info->Parameters[Info->ParamCount]) 0233 { 0234 if (Info->ParamCount > ACPI_METHOD_MAX_ARG) 0235 { 0236 return_ACPI_STATUS (AE_LIMIT); 0237 } 0238 Info->ParamCount++; 0239 } 0240 } 0241 0242 ACPI_DUMP_PATHNAME (Info->ResolvedNode, "ACPI: Execute Method", 0243 ACPI_LV_INFO, _COMPONENT); 0244 0245 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 0246 "Method at AML address %p Length %X\n", 0247 Info->ObjDesc->Method.AmlStart + 1, 0248 Info->ObjDesc->Method.AmlLength - 1)); 0249 0250 /* 0251 * Any namespace deletion must acquire both the namespace and 0252 * interpreter locks to ensure that no thread is using the portion of 0253 * the namespace that is being deleted. 0254 * 0255 * Execute the method via the interpreter. The interpreter is locked 0256 * here before calling into the AML parser 0257 */ 0258 AcpiExEnterInterpreter (); 0259 Status = AcpiPsExecuteMethod (Info); 0260 AcpiExExitInterpreter (); 0261 } 0262 else 0263 { 0264 /* 0265 * 2) Object is not a method, return its current value 0266 * 0267 * Disallow certain object types. For these, "evaluation" is undefined. 0268 */ 0269 switch (Info->ResolvedNode->Type) 0270 { 0271 case ACPI_TYPE_DEVICE: 0272 case ACPI_TYPE_EVENT: 0273 case ACPI_TYPE_MUTEX: 0274 case ACPI_TYPE_REGION: 0275 case ACPI_TYPE_THERMAL: 0276 case ACPI_TYPE_LOCAL_SCOPE: 0277 0278 ACPI_ERROR ((AE_INFO, 0279 "[%4.4s] Evaluation of object type [%s] is not supported", 0280 Info->ResolvedNode->Name.Ascii, 0281 AcpiUtGetTypeName (Info->ResolvedNode->Type))); 0282 0283 return_ACPI_STATUS (AE_TYPE); 0284 0285 default: 0286 break; 0287 } 0288 0289 /* 0290 * Objects require additional resolution steps (e.g., the Node may be 0291 * a field that must be read, etc.) -- we can't just grab the object 0292 * out of the node. 0293 * 0294 * Use ResolveNodeToValue() to get the associated value. 0295 * 0296 * NOTE: we can get away with passing in NULL for a walk state because 0297 * ResolvedNode is guaranteed to not be a reference to either a method 0298 * local or a method argument (because this interface is never called 0299 * from a running method.) 0300 * 0301 * Even though we do not directly invoke the interpreter for object 0302 * resolution, we must lock it because we could access an opregion. 0303 * The opregion access code assumes that the interpreter is locked. 0304 */ 0305 AcpiExEnterInterpreter (); 0306 0307 /* Function has a strange interface */ 0308 0309 Status = AcpiExResolveNodeToValue (&Info->ResolvedNode, NULL); 0310 AcpiExExitInterpreter (); 0311 0312 /* 0313 * If AcpiExResolveNodeToValue() succeeded, the return value was placed 0314 * in ResolvedNode. 0315 */ 0316 if (ACPI_SUCCESS (Status)) 0317 { 0318 Status = AE_CTRL_RETURN_VALUE; 0319 Info->ReturnObject = 0320 ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Info->ResolvedNode); 0321 0322 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n", 0323 Info->ReturnObject, 0324 AcpiUtGetObjectTypeName (Info->ReturnObject))); 0325 } 0326 } 0327 0328 /* 0329 * Check input argument count against the ASL-defined count for a method. 0330 * Also check predefined names: argument count and return value against 0331 * the ACPI specification. Some incorrect return value types are repaired. 0332 */ 0333 (void) AcpiNsCheckPredefinedNames (Node, Info->ParamCount, 0334 Status, &Info->ReturnObject); 0335 0336 /* Check if there is a return value that must be dealt with */ 0337 0338 if (Status == AE_CTRL_RETURN_VALUE) 0339 { 0340 /* If caller does not want the return value, delete it */ 0341 0342 if (Info->Flags & ACPI_IGNORE_RETURN_VALUE) 0343 { 0344 AcpiUtRemoveReference (Info->ReturnObject); 0345 Info->ReturnObject = NULL; 0346 } 0347 0348 /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */ 0349 0350 Status = AE_OK; 0351 } 0352 0353 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0354 "*** Completed evaluation of object %s ***\n", Info->Pathname)); 0355 0356 /* 0357 * Namespace was unlocked by the handling AcpiNs* function, so we 0358 * just return 0359 */ 0360 return_ACPI_STATUS (Status); 0361 } 0362
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 1.2.0 LXR engine. |