![]() |
|
|||
File indexing completed on 2025-05-11 08:24:03
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 - 2024, 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 * Alternatively, you may choose to be licensed under the terms of the 0118 * following license: 0119 * 0120 * Redistribution and use in source and binary forms, with or without 0121 * modification, are permitted provided that the following conditions 0122 * are met: 0123 * 1. Redistributions of source code must retain the above copyright 0124 * notice, this list of conditions, and the following disclaimer, 0125 * without modification. 0126 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 0127 * substantially similar to the "NO WARRANTY" disclaimer below 0128 * ("Disclaimer") and any redistribution must be conditioned upon 0129 * including a substantially similar Disclaimer requirement for further 0130 * binary redistribution. 0131 * 3. Neither the names of the above-listed copyright holders nor the names 0132 * of any contributors may be used to endorse or promote products derived 0133 * from this software without specific prior written permission. 0134 * 0135 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0136 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0137 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0138 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0139 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0140 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0141 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0142 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0143 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0144 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0145 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0146 * 0147 * Alternatively, you may choose to be licensed under the terms of the 0148 * GNU General Public License ("GPL") version 2 as published by the Free 0149 * Software Foundation. 0150 * 0151 *****************************************************************************/ 0152 0153 #include "acpi.h" 0154 #include "accommon.h" 0155 #include "acparser.h" 0156 #include "acinterp.h" 0157 #include "acnamesp.h" 0158 0159 0160 #define _COMPONENT ACPI_NAMESPACE 0161 ACPI_MODULE_NAME ("nseval") 0162 0163 0164 /******************************************************************************* 0165 * 0166 * FUNCTION: AcpiNsEvaluate 0167 * 0168 * PARAMETERS: Info - Evaluation info block, contains these fields 0169 * and more: 0170 * PrefixNode - Prefix or Method/Object Node to execute 0171 * RelativePath - Name of method to execute, If NULL, the 0172 * Node is the object to execute 0173 * Parameters - List of parameters to pass to the method, 0174 * terminated by NULL. Params itself may be 0175 * NULL if no parameters are being passed. 0176 * ParameterType - Type of Parameter list 0177 * ReturnObject - Where to put method's return value (if 0178 * any). If NULL, no value is returned. 0179 * Flags - ACPI_IGNORE_RETURN_VALUE to delete return 0180 * 0181 * RETURN: Status 0182 * 0183 * DESCRIPTION: Execute a control method or return the current value of an 0184 * ACPI namespace object. 0185 * 0186 * MUTEX: Locks interpreter 0187 * 0188 ******************************************************************************/ 0189 0190 ACPI_STATUS 0191 AcpiNsEvaluate ( 0192 ACPI_EVALUATE_INFO *Info) 0193 { 0194 ACPI_STATUS Status; 0195 0196 0197 ACPI_FUNCTION_TRACE (NsEvaluate); 0198 0199 0200 if (!Info) 0201 { 0202 return_ACPI_STATUS (AE_BAD_PARAMETER); 0203 } 0204 0205 if (!Info->Node) 0206 { 0207 /* 0208 * Get the actual namespace node for the target object if we 0209 * need to. Handles these cases: 0210 * 0211 * 1) Null node, valid pathname from root (absolute path) 0212 * 2) Node and valid pathname (path relative to Node) 0213 * 3) Node, Null pathname 0214 */ 0215 Status = AcpiNsGetNode (Info->PrefixNode, Info->RelativePathname, 0216 ACPI_NS_NO_UPSEARCH, &Info->Node); 0217 if (ACPI_FAILURE (Status)) 0218 { 0219 return_ACPI_STATUS (Status); 0220 } 0221 } 0222 0223 /* 0224 * For a method alias, we must grab the actual method node so that 0225 * proper scoping context will be established before execution. 0226 */ 0227 if (AcpiNsGetType (Info->Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) 0228 { 0229 Info->Node = ACPI_CAST_PTR ( 0230 ACPI_NAMESPACE_NODE, Info->Node->Object); 0231 } 0232 0233 /* Complete the info block initialization */ 0234 0235 Info->ReturnObject = NULL; 0236 Info->NodeFlags = Info->Node->Flags; 0237 Info->ObjDesc = AcpiNsGetAttachedObject (Info->Node); 0238 0239 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", 0240 Info->RelativePathname, Info->Node, 0241 AcpiNsGetAttachedObject (Info->Node))); 0242 0243 /* Get info if we have a predefined name (_HID, etc.) */ 0244 0245 Info->Predefined = AcpiUtMatchPredefinedMethod (Info->Node->Name.Ascii); 0246 0247 /* Get the full pathname to the object, for use in warning messages */ 0248 0249 Info->FullPathname = AcpiNsGetNormalizedPathname (Info->Node, TRUE); 0250 if (!Info->FullPathname) 0251 { 0252 return_ACPI_STATUS (AE_NO_MEMORY); 0253 } 0254 0255 /* Optional object evaluation log */ 0256 0257 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EVALUATION, 0258 "%-26s: %s (%s)\n", " Enter evaluation", 0259 &Info->FullPathname[1], AcpiUtGetTypeName (Info->Node->Type))); 0260 0261 /* Count the number of arguments being passed in */ 0262 0263 Info->ParamCount = 0; 0264 if (Info->Parameters) 0265 { 0266 while (Info->Parameters[Info->ParamCount]) 0267 { 0268 Info->ParamCount++; 0269 } 0270 0271 /* Warn on impossible argument count */ 0272 0273 if (Info->ParamCount > ACPI_METHOD_NUM_ARGS) 0274 { 0275 ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, ACPI_WARN_ALWAYS, 0276 "Excess arguments (%u) - using only %u", 0277 Info->ParamCount, ACPI_METHOD_NUM_ARGS)); 0278 0279 Info->ParamCount = ACPI_METHOD_NUM_ARGS; 0280 } 0281 } 0282 0283 /* 0284 * For predefined names: Check that the declared argument count 0285 * matches the ACPI spec -- otherwise this is a BIOS error. 0286 */ 0287 AcpiNsCheckAcpiCompliance (Info->FullPathname, Info->Node, 0288 Info->Predefined); 0289 0290 /* 0291 * For all names: Check that the incoming argument count for 0292 * this method/object matches the actual ASL/AML definition. 0293 */ 0294 AcpiNsCheckArgumentCount (Info->FullPathname, Info->Node, 0295 Info->ParamCount, Info->Predefined); 0296 0297 /* For predefined names: Typecheck all incoming arguments */ 0298 0299 AcpiNsCheckArgumentTypes (Info); 0300 0301 /* 0302 * Three major evaluation cases: 0303 * 0304 * 1) Object types that cannot be evaluated by definition 0305 * 2) The object is a control method -- execute it 0306 * 3) The object is not a method -- just return it's current value 0307 */ 0308 switch (AcpiNsGetType (Info->Node)) 0309 { 0310 case ACPI_TYPE_ANY: 0311 case ACPI_TYPE_DEVICE: 0312 case ACPI_TYPE_EVENT: 0313 case ACPI_TYPE_MUTEX: 0314 case ACPI_TYPE_REGION: 0315 case ACPI_TYPE_THERMAL: 0316 case ACPI_TYPE_LOCAL_SCOPE: 0317 /* 0318 * 1) Disallow evaluation of these object types. For these, 0319 * object evaluation is undefined. 0320 */ 0321 ACPI_ERROR ((AE_INFO, 0322 "%s: This object type [%s] " 0323 "never contains data and cannot be evaluated", 0324 Info->FullPathname, AcpiUtGetTypeName (Info->Node->Type))); 0325 0326 Status = AE_TYPE; 0327 goto Cleanup; 0328 0329 case ACPI_TYPE_METHOD: 0330 /* 0331 * 2) Object is a control method - execute it 0332 */ 0333 0334 /* Verify that there is a method object associated with this node */ 0335 0336 if (!Info->ObjDesc) 0337 { 0338 ACPI_ERROR ((AE_INFO, "%s: Method has no attached sub-object", 0339 Info->FullPathname)); 0340 Status = AE_NULL_OBJECT; 0341 goto Cleanup; 0342 } 0343 0344 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 0345 "**** Execute method [%s] at AML address %p length %X\n", 0346 Info->FullPathname, 0347 Info->ObjDesc->Method.AmlStart + 1, 0348 Info->ObjDesc->Method.AmlLength - 1)); 0349 0350 /* 0351 * Any namespace deletion must acquire both the namespace and 0352 * interpreter locks to ensure that no thread is using the portion of 0353 * the namespace that is being deleted. 0354 * 0355 * Execute the method via the interpreter. The interpreter is locked 0356 * here before calling into the AML parser 0357 */ 0358 AcpiExEnterInterpreter (); 0359 Status = AcpiPsExecuteMethod (Info); 0360 AcpiExExitInterpreter (); 0361 break; 0362 0363 default: 0364 /* 0365 * 3) All other non-method objects -- get the current object value 0366 */ 0367 0368 /* 0369 * Some objects require additional resolution steps (e.g., the Node 0370 * may be a field that must be read, etc.) -- we can't just grab 0371 * the object out of the node. 0372 * 0373 * Use ResolveNodeToValue() to get the associated value. 0374 * 0375 * NOTE: we can get away with passing in NULL for a walk state because 0376 * the Node is guaranteed to not be a reference to either a method 0377 * local or a method argument (because this interface is never called 0378 * from a running method.) 0379 * 0380 * Even though we do not directly invoke the interpreter for object 0381 * resolution, we must lock it because we could access an OpRegion. 0382 * The OpRegion access code assumes that the interpreter is locked. 0383 */ 0384 AcpiExEnterInterpreter (); 0385 0386 /* TBD: ResolveNodeToValue has a strange interface, fix */ 0387 0388 Info->ReturnObject = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Info->Node); 0389 0390 Status = AcpiExResolveNodeToValue (ACPI_CAST_INDIRECT_PTR ( 0391 ACPI_NAMESPACE_NODE, &Info->ReturnObject), NULL); 0392 AcpiExExitInterpreter (); 0393 0394 if (ACPI_FAILURE (Status)) 0395 { 0396 Info->ReturnObject = NULL; 0397 goto Cleanup; 0398 } 0399 0400 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returned object %p [%s]\n", 0401 Info->ReturnObject, 0402 AcpiUtGetObjectTypeName (Info->ReturnObject))); 0403 0404 Status = AE_CTRL_RETURN_VALUE; /* Always has a "return value" */ 0405 break; 0406 } 0407 0408 /* 0409 * For predefined names, check the return value against the ACPI 0410 * specification. Some incorrect return value types are repaired. 0411 */ 0412 (void) AcpiNsCheckReturnValue (Info->Node, Info, Info->ParamCount, 0413 Status, &Info->ReturnObject); 0414 0415 /* Check if there is a return value that must be dealt with */ 0416 0417 if (Status == AE_CTRL_RETURN_VALUE) 0418 { 0419 /* If caller does not want the return value, delete it */ 0420 0421 if (Info->Flags & ACPI_IGNORE_RETURN_VALUE) 0422 { 0423 AcpiUtRemoveReference (Info->ReturnObject); 0424 Info->ReturnObject = NULL; 0425 } 0426 0427 /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */ 0428 0429 Status = AE_OK; 0430 } 0431 else if (ACPI_FAILURE(Status)) 0432 { 0433 /* If ReturnObject exists, delete it */ 0434 0435 if (Info->ReturnObject) 0436 { 0437 AcpiUtRemoveReference (Info->ReturnObject); 0438 Info->ReturnObject = NULL; 0439 } 0440 } 0441 0442 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 0443 "*** Completed evaluation of object %s ***\n", 0444 Info->RelativePathname)); 0445 0446 Cleanup: 0447 /* Optional object evaluation log */ 0448 0449 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EVALUATION, 0450 "%-26s: %s\n", " Exit evaluation", 0451 &Info->FullPathname[1])); 0452 0453 /* 0454 * Namespace was unlocked by the handling AcpiNs* function, so we 0455 * just free the pathname and return 0456 */ 0457 ACPI_FREE (Info->FullPathname); 0458 Info->FullPathname = NULL; 0459 return_ACPI_STATUS (Status); 0460 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |