nseval.c revision 197104
167754Smsmith/******************************************************************************* 267754Smsmith * 3167802Sjkim * Module Name: nseval - Object evaluation, includes control method execution 467754Smsmith * 567754Smsmith ******************************************************************************/ 667754Smsmith 767754Smsmith/****************************************************************************** 867754Smsmith * 967754Smsmith * 1. Copyright Notice 1067754Smsmith * 11193267Sjkim * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 1270243Smsmith * All rights reserved. 1367754Smsmith * 1467754Smsmith * 2. License 1567754Smsmith * 1667754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 1767754Smsmith * rights. You may have additional license terms from the party that provided 1867754Smsmith * you this software, covering your right to use that party's intellectual 1967754Smsmith * property rights. 2067754Smsmith * 2167754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2267754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2367754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2467754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2567754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2667754Smsmith * Code in any form, with the right to sublicense such rights; and 2767754Smsmith * 2867754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 2967754Smsmith * license (with the right to sublicense), under only those claims of Intel 3067754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3167754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3267754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3367754Smsmith * license, and in no event shall the patent license extend to any additions 3467754Smsmith * to or modifications of the Original Intel Code. No other license or right 3567754Smsmith * is granted directly or by implication, estoppel or otherwise; 3667754Smsmith * 3767754Smsmith * The above copyright and patent license is granted only if the following 3867754Smsmith * conditions are met: 3967754Smsmith * 4067754Smsmith * 3. Conditions 4167754Smsmith * 4267754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4367754Smsmith * Redistribution of source code of any substantial portion of the Covered 4467754Smsmith * Code or modification with rights to further distribute source must include 4567754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4667754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 4767754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 4867754Smsmith * contain a file documenting the changes Licensee made to create that Covered 4967754Smsmith * Code and the date of any change. Licensee must include in that file the 5067754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5167754Smsmith * must include a prominent statement that the modification is derived, 5267754Smsmith * directly or indirectly, from Original Intel Code. 5367754Smsmith * 5467754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5567754Smsmith * Redistribution of source code of any substantial portion of the Covered 5667754Smsmith * Code or modification without rights to further distribute source must 5767754Smsmith * include the following Disclaimer and Export Compliance provision in the 5867754Smsmith * documentation and/or other materials provided with distribution. In 5967754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6067754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6167754Smsmith * license from Licensee to its licensee is limited to the intellectual 6267754Smsmith * property embodied in the software Licensee provides to its licensee, and 6367754Smsmith * not to intellectual property embodied in modifications its licensee may 6467754Smsmith * make. 6567754Smsmith 6667754Smsmith * 6767754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 6867754Smsmith * substantial portion of the Covered Code or modification must reproduce the 6967754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 7067754Smsmith * provision in the documentation and/or other materials provided with the 7167754Smsmith * distribution. 7267754Smsmith * 7367754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7467754Smsmith * Intel Code. 7567754Smsmith * 7667754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7767754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 7867754Smsmith * other dealings in products derived from or relating to the Covered Code 7967754Smsmith * without prior written authorization from Intel. 8067754Smsmith * 8167754Smsmith * 4. Disclaimer and Export Compliance 8267754Smsmith * 8367754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8467754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8567754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8667754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8767754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8867754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 8967754Smsmith * PARTICULAR PURPOSE. 9067754Smsmith * 9167754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9267754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9367754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9467754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9567754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9667754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9767754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9867754Smsmith * LIMITED REMEDY. 9967754Smsmith * 10067754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10167754Smsmith * software or system incorporating such software without first obtaining any 10267754Smsmith * required license or other approval from the U. S. Department of Commerce or 10367754Smsmith * any other agency or department of the United States Government. In the 10467754Smsmith * event Licensee exports any such software from the United States or 10567754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10667754Smsmith * ensure that the distribution and export/re-export of the software is in 10767754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 10867754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 10967754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 11067754Smsmith * software, or service, directly or indirectly, to any country for which the 11167754Smsmith * United States government or any agency thereof requires an export license, 11267754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11367754Smsmith * such license, approval or letter. 11467754Smsmith * 11567754Smsmith *****************************************************************************/ 11667754Smsmith 11767754Smsmith#define __NSEVAL_C__ 11867754Smsmith 119193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 120193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 121193341Sjkim#include <contrib/dev/acpica/include/acparser.h> 122193341Sjkim#include <contrib/dev/acpica/include/acinterp.h> 123193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h> 12467754Smsmith 12567754Smsmith 12677424Smsmith#define _COMPONENT ACPI_NAMESPACE 12791116Smsmith ACPI_MODULE_NAME ("nseval") 12867754Smsmith 129197104Sjkim/* Local prototypes */ 13067754Smsmith 131197104Sjkimstatic void 132197104SjkimAcpiNsExecModuleCode ( 133197104Sjkim ACPI_OPERAND_OBJECT *MethodObj, 134197104Sjkim ACPI_EVALUATE_INFO *Info); 135197104Sjkim 136197104Sjkim 13767754Smsmith/******************************************************************************* 13867754Smsmith * 139167802Sjkim * FUNCTION: AcpiNsEvaluate 14067754Smsmith * 141167802Sjkim * PARAMETERS: Info - Evaluation info block, contains: 142167802Sjkim * PrefixNode - Prefix or Method/Object Node to execute 143167802Sjkim * Pathname - Name of method to execute, If NULL, the 144167802Sjkim * Node is the object to execute 145151937Sjkim * Parameters - List of parameters to pass to the method, 146151937Sjkim * terminated by NULL. Params itself may be 14767754Smsmith * NULL if no parameters are being passed. 148151937Sjkim * ReturnObject - Where to put method's return value (if 149151937Sjkim * any). If NULL, no value is returned. 150151937Sjkim * ParameterType - Type of Parameter list 151151937Sjkim * ReturnObject - Where to put method's return value (if 152151937Sjkim * any). If NULL, no value is returned. 153167802Sjkim * Flags - ACPI_IGNORE_RETURN_VALUE to delete return 15467754Smsmith * 15567754Smsmith * RETURN: Status 15667754Smsmith * 157167802Sjkim * DESCRIPTION: Execute a control method or return the current value of an 158167802Sjkim * ACPI namespace object. 15967754Smsmith * 160167802Sjkim * MUTEX: Locks interpreter 16167754Smsmith * 16267754Smsmith ******************************************************************************/ 16367754Smsmith 16467754SmsmithACPI_STATUS 165167802SjkimAcpiNsEvaluate ( 166167802Sjkim ACPI_EVALUATE_INFO *Info) 16767754Smsmith{ 16867754Smsmith ACPI_STATUS Status; 169193267Sjkim ACPI_NAMESPACE_NODE *Node; 17067754Smsmith 17167754Smsmith 172167802Sjkim ACPI_FUNCTION_TRACE (NsEvaluate); 17367754Smsmith 17467754Smsmith 175129684Snjl if (!Info) 17667754Smsmith { 17767754Smsmith return_ACPI_STATUS (AE_BAD_PARAMETER); 17867754Smsmith } 17967754Smsmith 180129684Snjl /* Initialize the return value to an invalid object */ 18167754Smsmith 182129684Snjl Info->ReturnObject = NULL; 183193267Sjkim Info->ParamCount = 0; 18467754Smsmith 185167802Sjkim /* 186167802Sjkim * Get the actual namespace node for the target object. Handles these cases: 187167802Sjkim * 188167802Sjkim * 1) Null node, Pathname (absolute path) 189167802Sjkim * 2) Node, Pathname (path relative to Node) 190167802Sjkim * 3) Node, Null Pathname 191167802Sjkim */ 192167802Sjkim Status = AcpiNsGetNode (Info->PrefixNode, Info->Pathname, 193167802Sjkim ACPI_NS_NO_UPSEARCH, &Info->ResolvedNode); 19491116Smsmith if (ACPI_FAILURE (Status)) 19591116Smsmith { 19691116Smsmith return_ACPI_STATUS (Status); 19791116Smsmith } 19867754Smsmith 19967754Smsmith /* 200138287Smarks * For a method alias, we must grab the actual method node so that proper 201138287Smarks * scoping context will be established before execution. 202128212Snjl */ 203167802Sjkim if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_LOCAL_METHOD_ALIAS) 204128212Snjl { 205167802Sjkim Info->ResolvedNode = 206167802Sjkim ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Info->ResolvedNode->Object); 207128212Snjl } 208128212Snjl 209167802Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Info->Pathname, 210167802Sjkim Info->ResolvedNode, AcpiNsGetAttachedObject (Info->ResolvedNode))); 211167802Sjkim 212193267Sjkim Node = Info->ResolvedNode; 213193267Sjkim 214128212Snjl /* 21567754Smsmith * Two major cases here: 216167802Sjkim * 217167802Sjkim * 1) The object is a control method -- execute it 218138287Smarks * 2) The object is not a method -- just return it's current value 21967754Smsmith */ 220167802Sjkim if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_METHOD) 22167754Smsmith { 22267754Smsmith /* 223167802Sjkim * 1) Object is a control method - execute it 22467754Smsmith */ 22567754Smsmith 226167802Sjkim /* Verify that there is a method object associated with this node */ 22767754Smsmith 228167802Sjkim Info->ObjDesc = AcpiNsGetAttachedObject (Info->ResolvedNode); 229167802Sjkim if (!Info->ObjDesc) 230167802Sjkim { 231167802Sjkim ACPI_ERROR ((AE_INFO, "Control method has no attached sub-object")); 232167802Sjkim return_ACPI_STATUS (AE_NULL_OBJECT); 233167802Sjkim } 23467754Smsmith 235193267Sjkim /* Count the number of arguments being passed to the method */ 236193267Sjkim 237193267Sjkim if (Info->Parameters) 238193267Sjkim { 239193267Sjkim while (Info->Parameters[Info->ParamCount]) 240193267Sjkim { 241193267Sjkim if (Info->ParamCount > ACPI_METHOD_MAX_ARG) 242193267Sjkim { 243193267Sjkim return_ACPI_STATUS (AE_LIMIT); 244193267Sjkim } 245193267Sjkim Info->ParamCount++; 246193267Sjkim } 247193267Sjkim } 248193267Sjkim 249193267Sjkim ACPI_DUMP_PATHNAME (Info->ResolvedNode, "ACPI: Execute Method", 250167802Sjkim ACPI_LV_INFO, _COMPONENT); 25167754Smsmith 252167802Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 253167802Sjkim "Method at AML address %p Length %X\n", 254167802Sjkim Info->ObjDesc->Method.AmlStart + 1, 255167802Sjkim Info->ObjDesc->Method.AmlLength - 1)); 25667754Smsmith 257167802Sjkim /* 258167802Sjkim * Any namespace deletion must acquire both the namespace and 259167802Sjkim * interpreter locks to ensure that no thread is using the portion of 260167802Sjkim * the namespace that is being deleted. 261167802Sjkim * 262167802Sjkim * Execute the method via the interpreter. The interpreter is locked 263167802Sjkim * here before calling into the AML parser 264167802Sjkim */ 265167802Sjkim AcpiExEnterInterpreter (); 266167802Sjkim Status = AcpiPsExecuteMethod (Info); 267167802Sjkim AcpiExExitInterpreter (); 26867754Smsmith } 269167802Sjkim else 27091116Smsmith { 271167802Sjkim /* 272167802Sjkim * 2) Object is not a method, return its current value 273193267Sjkim * 274193267Sjkim * Disallow certain object types. For these, "evaluation" is undefined. 275167802Sjkim */ 276193267Sjkim switch (Info->ResolvedNode->Type) 277193267Sjkim { 278193267Sjkim case ACPI_TYPE_DEVICE: 279193267Sjkim case ACPI_TYPE_EVENT: 280193267Sjkim case ACPI_TYPE_MUTEX: 281193267Sjkim case ACPI_TYPE_REGION: 282193267Sjkim case ACPI_TYPE_THERMAL: 283193267Sjkim case ACPI_TYPE_LOCAL_SCOPE: 28477424Smsmith 285193267Sjkim ACPI_ERROR ((AE_INFO, 286193267Sjkim "[%4.4s] Evaluation of object type [%s] is not supported", 287193267Sjkim Info->ResolvedNode->Name.Ascii, 288193267Sjkim AcpiUtGetTypeName (Info->ResolvedNode->Type))); 289193267Sjkim 290193267Sjkim return_ACPI_STATUS (AE_TYPE); 291193267Sjkim 292193267Sjkim default: 293193267Sjkim break; 294193267Sjkim } 295193267Sjkim 296167802Sjkim /* 297167802Sjkim * Objects require additional resolution steps (e.g., the Node may be 298167802Sjkim * a field that must be read, etc.) -- we can't just grab the object 299167802Sjkim * out of the node. 300167802Sjkim * 301167802Sjkim * Use ResolveNodeToValue() to get the associated value. 302167802Sjkim * 303167802Sjkim * NOTE: we can get away with passing in NULL for a walk state because 304167802Sjkim * ResolvedNode is guaranteed to not be a reference to either a method 305167802Sjkim * local or a method argument (because this interface is never called 306167802Sjkim * from a running method.) 307167802Sjkim * 308167802Sjkim * Even though we do not directly invoke the interpreter for object 309167802Sjkim * resolution, we must lock it because we could access an opregion. 310167802Sjkim * The opregion access code assumes that the interpreter is locked. 311167802Sjkim */ 312167802Sjkim AcpiExEnterInterpreter (); 31367754Smsmith 314167802Sjkim /* Function has a strange interface */ 31583174Smsmith 316167802Sjkim Status = AcpiExResolveNodeToValue (&Info->ResolvedNode, NULL); 317167802Sjkim AcpiExExitInterpreter (); 31867754Smsmith 31967754Smsmith /* 320138287Smarks * If AcpiExResolveNodeToValue() succeeded, the return value was placed 321138287Smarks * in ResolvedNode. 32267754Smsmith */ 32377424Smsmith if (ACPI_SUCCESS (Status)) 32477424Smsmith { 32591116Smsmith Status = AE_CTRL_RETURN_VALUE; 326167802Sjkim Info->ReturnObject = 327167802Sjkim ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Info->ResolvedNode); 328167802Sjkim 329102550Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n", 330138287Smarks Info->ReturnObject, 331138287Smarks AcpiUtGetObjectTypeName (Info->ReturnObject))); 33277424Smsmith } 33367754Smsmith } 33467754Smsmith 335167802Sjkim /* 336193267Sjkim * Check input argument count against the ASL-defined count for a method. 337193267Sjkim * Also check predefined names: argument count and return value against 338193267Sjkim * the ACPI specification. Some incorrect return value types are repaired. 339167802Sjkim */ 340193267Sjkim (void) AcpiNsCheckPredefinedNames (Node, Info->ParamCount, 341193267Sjkim Status, &Info->ReturnObject); 342193267Sjkim 343193267Sjkim /* Check if there is a return value that must be dealt with */ 344193267Sjkim 345167802Sjkim if (Status == AE_CTRL_RETURN_VALUE) 346167802Sjkim { 347167802Sjkim /* If caller does not want the return value, delete it */ 34867754Smsmith 349167802Sjkim if (Info->Flags & ACPI_IGNORE_RETURN_VALUE) 350167802Sjkim { 351167802Sjkim AcpiUtRemoveReference (Info->ReturnObject); 352167802Sjkim Info->ReturnObject = NULL; 353167802Sjkim } 354167802Sjkim 355167802Sjkim /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */ 356167802Sjkim 357167802Sjkim Status = AE_OK; 358167802Sjkim } 359167802Sjkim 360167802Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 361167802Sjkim "*** Completed evaluation of object %s ***\n", Info->Pathname)); 362167802Sjkim 363167802Sjkim /* 364167802Sjkim * Namespace was unlocked by the handling AcpiNs* function, so we 365167802Sjkim * just return 366167802Sjkim */ 36777424Smsmith return_ACPI_STATUS (Status); 36891116Smsmith} 36977424Smsmith 370197104Sjkim 371197104Sjkim/******************************************************************************* 372197104Sjkim * 373197104Sjkim * FUNCTION: AcpiNsExecModuleCodeList 374197104Sjkim * 375197104Sjkim * PARAMETERS: None 376197104Sjkim * 377197104Sjkim * RETURN: None. Exceptions during method execution are ignored, since 378197104Sjkim * we cannot abort a table load. 379197104Sjkim * 380197104Sjkim * DESCRIPTION: Execute all elements of the global module-level code list. 381197104Sjkim * Each element is executed as a single control method. 382197104Sjkim * 383197104Sjkim ******************************************************************************/ 384197104Sjkim 385197104Sjkimvoid 386197104SjkimAcpiNsExecModuleCodeList ( 387197104Sjkim void) 388197104Sjkim{ 389197104Sjkim ACPI_OPERAND_OBJECT *Prev; 390197104Sjkim ACPI_OPERAND_OBJECT *Next; 391197104Sjkim ACPI_EVALUATE_INFO *Info; 392197104Sjkim UINT32 MethodCount = 0; 393197104Sjkim 394197104Sjkim 395197104Sjkim ACPI_FUNCTION_TRACE (NsExecModuleCodeList); 396197104Sjkim 397197104Sjkim 398197104Sjkim /* Exit now if the list is empty */ 399197104Sjkim 400197104Sjkim Next = AcpiGbl_ModuleCodeList; 401197104Sjkim if (!Next) 402197104Sjkim { 403197104Sjkim return_VOID; 404197104Sjkim } 405197104Sjkim 406197104Sjkim /* Allocate the evaluation information block */ 407197104Sjkim 408197104Sjkim Info = ACPI_ALLOCATE (sizeof (ACPI_EVALUATE_INFO)); 409197104Sjkim if (!Info) 410197104Sjkim { 411197104Sjkim return_VOID; 412197104Sjkim } 413197104Sjkim 414197104Sjkim /* Walk the list, executing each "method" */ 415197104Sjkim 416197104Sjkim while (Next) 417197104Sjkim { 418197104Sjkim Prev = Next; 419197104Sjkim Next = Next->Method.Mutex; 420197104Sjkim 421197104Sjkim /* Clear the link field and execute the method */ 422197104Sjkim 423197104Sjkim Prev->Method.Mutex = NULL; 424197104Sjkim AcpiNsExecModuleCode (Prev, Info); 425197104Sjkim MethodCount++; 426197104Sjkim 427197104Sjkim /* Delete the (temporary) method object */ 428197104Sjkim 429197104Sjkim AcpiUtRemoveReference (Prev); 430197104Sjkim } 431197104Sjkim 432197104Sjkim ACPI_INFO ((AE_INFO, 433197104Sjkim "Executed %u blocks of module-level executable AML code", 434197104Sjkim MethodCount)); 435197104Sjkim 436197104Sjkim ACPI_FREE (Info); 437197104Sjkim AcpiGbl_ModuleCodeList = NULL; 438197104Sjkim return_VOID; 439197104Sjkim} 440197104Sjkim 441197104Sjkim 442197104Sjkim/******************************************************************************* 443197104Sjkim * 444197104Sjkim * FUNCTION: AcpiNsExecModuleCode 445197104Sjkim * 446197104Sjkim * PARAMETERS: MethodObj - Object container for the module-level code 447197104Sjkim * Info - Info block for method evaluation 448197104Sjkim * 449197104Sjkim * RETURN: None. Exceptions during method execution are ignored, since 450197104Sjkim * we cannot abort a table load. 451197104Sjkim * 452197104Sjkim * DESCRIPTION: Execute a control method containing a block of module-level 453197104Sjkim * executable AML code. The control method is temporarily 454197104Sjkim * installed to the root node, then evaluated. 455197104Sjkim * 456197104Sjkim ******************************************************************************/ 457197104Sjkim 458197104Sjkimstatic void 459197104SjkimAcpiNsExecModuleCode ( 460197104Sjkim ACPI_OPERAND_OBJECT *MethodObj, 461197104Sjkim ACPI_EVALUATE_INFO *Info) 462197104Sjkim{ 463197104Sjkim ACPI_OPERAND_OBJECT *RootObj; 464197104Sjkim ACPI_STATUS Status; 465197104Sjkim 466197104Sjkim 467197104Sjkim ACPI_FUNCTION_TRACE (NsExecModuleCode); 468197104Sjkim 469197104Sjkim 470197104Sjkim /* Initialize the evaluation information block */ 471197104Sjkim 472197104Sjkim ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO)); 473197104Sjkim Info->PrefixNode = AcpiGbl_RootNode; 474197104Sjkim 475197104Sjkim /* 476197104Sjkim * Get the currently attached root object. Add a reference, because the 477197104Sjkim * ref count will be decreased when the method object is installed to 478197104Sjkim * the root node. 479197104Sjkim */ 480197104Sjkim RootObj = AcpiNsGetAttachedObject (AcpiGbl_RootNode); 481197104Sjkim AcpiUtAddReference (RootObj); 482197104Sjkim 483197104Sjkim /* Install the method (module-level code) in the root node */ 484197104Sjkim 485197104Sjkim Status = AcpiNsAttachObject (AcpiGbl_RootNode, MethodObj, 486197104Sjkim ACPI_TYPE_METHOD); 487197104Sjkim if (ACPI_FAILURE (Status)) 488197104Sjkim { 489197104Sjkim goto Exit; 490197104Sjkim } 491197104Sjkim 492197104Sjkim /* Execute the root node as a control method */ 493197104Sjkim 494197104Sjkim Status = AcpiNsEvaluate (Info); 495197104Sjkim 496197104Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Executed module-level code at %p\n", 497197104Sjkim MethodObj->Method.AmlStart)); 498197104Sjkim 499197104Sjkim /* Detach the temporary method object */ 500197104Sjkim 501197104Sjkim AcpiNsDetachObject (AcpiGbl_RootNode); 502197104Sjkim 503197104Sjkim /* Restore the original root object */ 504197104Sjkim 505197104Sjkim Status = AcpiNsAttachObject (AcpiGbl_RootNode, RootObj, ACPI_TYPE_DEVICE); 506197104Sjkim 507197104SjkimExit: 508197104Sjkim AcpiUtRemoveReference (RootObj); 509197104Sjkim return_VOID; 510197104Sjkim} 511197104Sjkim 512