13446Smrj /****************************************************************************** 23446Smrj * 33446Smrj * Module Name: nsinit - namespace initialization 43446Smrj * 53446Smrj *****************************************************************************/ 63446Smrj 73446Smrj /****************************************************************************** 83446Smrj * 93446Smrj * 1. Copyright Notice 103446Smrj * 11*9980SDana.Myers@Sun.COM * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 123446Smrj * All rights reserved. 133446Smrj * 143446Smrj * 2. License 153446Smrj * 163446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property 173446Smrj * rights. You may have additional license terms from the party that provided 183446Smrj * you this software, covering your right to use that party's intellectual 193446Smrj * property rights. 203446Smrj * 213446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 223446Smrj * copy of the source code appearing in this file ("Covered Code") an 233446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the 243446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy, 253446Smrj * make derivatives, distribute, use and display any portion of the Covered 263446Smrj * Code in any form, with the right to sublicense such rights; and 273446Smrj * 283446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 293446Smrj * license (with the right to sublicense), under only those claims of Intel 303446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell, 313446Smrj * offer to sell, and import the Covered Code and derivative works thereof 323446Smrj * solely to the minimum extent necessary to exercise the above copyright 333446Smrj * license, and in no event shall the patent license extend to any additions 343446Smrj * to or modifications of the Original Intel Code. No other license or right 353446Smrj * is granted directly or by implication, estoppel or otherwise; 363446Smrj * 373446Smrj * The above copyright and patent license is granted only if the following 383446Smrj * conditions are met: 393446Smrj * 403446Smrj * 3. Conditions 413446Smrj * 423446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source. 433446Smrj * Redistribution of source code of any substantial portion of the Covered 443446Smrj * Code or modification with rights to further distribute source must include 453446Smrj * the above Copyright Notice, the above License, this list of Conditions, 463446Smrj * and the following Disclaimer and Export Compliance provision. In addition, 473446Smrj * Licensee must cause all Covered Code to which Licensee contributes to 483446Smrj * contain a file documenting the changes Licensee made to create that Covered 493446Smrj * Code and the date of any change. Licensee must include in that file the 503446Smrj * documentation of any changes made by any predecessor Licensee. Licensee 513446Smrj * must include a prominent statement that the modification is derived, 523446Smrj * directly or indirectly, from Original Intel Code. 533446Smrj * 543446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 553446Smrj * Redistribution of source code of any substantial portion of the Covered 563446Smrj * Code or modification without rights to further distribute source must 573446Smrj * include the following Disclaimer and Export Compliance provision in the 583446Smrj * documentation and/or other materials provided with distribution. In 593446Smrj * addition, Licensee may not authorize further sublicense of source of any 603446Smrj * portion of the Covered Code, and must include terms to the effect that the 613446Smrj * license from Licensee to its licensee is limited to the intellectual 623446Smrj * property embodied in the software Licensee provides to its licensee, and 633446Smrj * not to intellectual property embodied in modifications its licensee may 643446Smrj * make. 653446Smrj * 663446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any 673446Smrj * substantial portion of the Covered Code or modification must reproduce the 683446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance 693446Smrj * provision in the documentation and/or other materials provided with the 703446Smrj * distribution. 713446Smrj * 723446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original 733446Smrj * Intel Code. 743446Smrj * 753446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by 763446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or 773446Smrj * other dealings in products derived from or relating to the Covered Code 783446Smrj * without prior written authorization from Intel. 793446Smrj * 803446Smrj * 4. Disclaimer and Export Compliance 813446Smrj * 823446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 833446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 843446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 853446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 863446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 873446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 883446Smrj * PARTICULAR PURPOSE. 893446Smrj * 903446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 913446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 923446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 933446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 943446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 953446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 963446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 973446Smrj * LIMITED REMEDY. 983446Smrj * 993446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this 1003446Smrj * software or system incorporating such software without first obtaining any 1013446Smrj * required license or other approval from the U. S. Department of Commerce or 1023446Smrj * any other agency or department of the United States Government. In the 1033446Smrj * event Licensee exports any such software from the United States or 1043446Smrj * re-exports any such software from a foreign destination, Licensee shall 1053446Smrj * ensure that the distribution and export/re-export of the software is in 1063446Smrj * compliance with all laws, regulations, orders, or other restrictions of the 1073446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor 1083446Smrj * any of its subsidiaries will export/re-export any technical data, process, 1093446Smrj * software, or service, directly or indirectly, to any country for which the 1103446Smrj * United States government or any agency thereof requires an export license, 1113446Smrj * other governmental approval, or letter of assurance, without first obtaining 1123446Smrj * such license, approval or letter. 1133446Smrj * 1143446Smrj *****************************************************************************/ 1153446Smrj 1163446Smrj 1173446Smrj #define __NSXFINIT_C__ 1183446Smrj 1193446Smrj #include "acpi.h" 120*9980SDana.Myers@Sun.COM #include "accommon.h" 1213446Smrj #include "acnamesp.h" 1223446Smrj #include "acdispat.h" 1233446Smrj #include "acinterp.h" 1243446Smrj 1253446Smrj #define _COMPONENT ACPI_NAMESPACE 1263446Smrj ACPI_MODULE_NAME ("nsinit") 1273446Smrj 1283446Smrj /* Local prototypes */ 1293446Smrj 1303446Smrj static ACPI_STATUS 1313446Smrj AcpiNsInitOneObject ( 1323446Smrj ACPI_HANDLE ObjHandle, 1333446Smrj UINT32 Level, 1343446Smrj void *Context, 1353446Smrj void **ReturnValue); 1363446Smrj 1373446Smrj static ACPI_STATUS 1383446Smrj AcpiNsInitOneDevice ( 1393446Smrj ACPI_HANDLE ObjHandle, 1403446Smrj UINT32 NestingLevel, 1413446Smrj void *Context, 1423446Smrj void **ReturnValue); 1433446Smrj 1443446Smrj static ACPI_STATUS 1453446Smrj AcpiNsFindIniMethods ( 1463446Smrj ACPI_HANDLE ObjHandle, 1473446Smrj UINT32 NestingLevel, 1483446Smrj void *Context, 1493446Smrj void **ReturnValue); 1503446Smrj 1513446Smrj 1523446Smrj /******************************************************************************* 1533446Smrj * 1543446Smrj * FUNCTION: AcpiNsInitializeObjects 1553446Smrj * 1563446Smrj * PARAMETERS: None 1573446Smrj * 1583446Smrj * RETURN: Status 1593446Smrj * 1603446Smrj * DESCRIPTION: Walk the entire namespace and perform any necessary 1613446Smrj * initialization on the objects found therein 1623446Smrj * 1633446Smrj ******************************************************************************/ 1643446Smrj 1653446Smrj ACPI_STATUS 1663446Smrj AcpiNsInitializeObjects ( 1673446Smrj void) 1683446Smrj { 1693446Smrj ACPI_STATUS Status; 1703446Smrj ACPI_INIT_WALK_INFO Info; 1713446Smrj 1723446Smrj 1733446Smrj ACPI_FUNCTION_TRACE (NsInitializeObjects); 1743446Smrj 1753446Smrj 1763446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1773446Smrj "**** Starting initialization of namespace objects ****\n")); 1783446Smrj ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 1793446Smrj "Completing Region/Field/Buffer/Package initialization:")); 1803446Smrj 1813446Smrj /* Set all init info to zero */ 1823446Smrj 1833446Smrj ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO)); 1843446Smrj 1853446Smrj /* Walk entire namespace from the supplied root */ 1863446Smrj 1873446Smrj Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 1883446Smrj ACPI_UINT32_MAX, AcpiNsInitOneObject, 1893446Smrj &Info, NULL); 1903446Smrj if (ACPI_FAILURE (Status)) 1913446Smrj { 1923446Smrj ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); 1933446Smrj } 1943446Smrj 1953446Smrj ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 196*9980SDana.Myers@Sun.COM "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd " 197*9980SDana.Myers@Sun.COM "Buffers %hd/%hd Packages (%hd nodes)\n", 1983446Smrj Info.OpRegionInit, Info.OpRegionCount, 1993446Smrj Info.FieldInit, Info.FieldCount, 2003446Smrj Info.BufferInit, Info.BufferCount, 2013446Smrj Info.PackageInit, Info.PackageCount, Info.ObjectCount)); 2023446Smrj 2033446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 2043446Smrj "%hd Control Methods found\n", Info.MethodCount)); 2053446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 2063446Smrj "%hd Op Regions found\n", Info.OpRegionCount)); 2073446Smrj 2083446Smrj return_ACPI_STATUS (AE_OK); 2093446Smrj } 2103446Smrj 2113446Smrj 2123446Smrj /******************************************************************************* 2133446Smrj * 2143446Smrj * FUNCTION: AcpiNsInitializeDevices 2153446Smrj * 2163446Smrj * PARAMETERS: None 2173446Smrj * 2183446Smrj * RETURN: ACPI_STATUS 2193446Smrj * 2203446Smrj * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices. 2213446Smrj * This means running _INI on all present devices. 2223446Smrj * 2233446Smrj * Note: We install PCI config space handler on region access, 2243446Smrj * not here. 2253446Smrj * 2263446Smrj ******************************************************************************/ 2273446Smrj 2283446Smrj ACPI_STATUS 2293446Smrj AcpiNsInitializeDevices ( 2303446Smrj void) 2313446Smrj { 2323446Smrj ACPI_STATUS Status; 2333446Smrj ACPI_DEVICE_WALK_INFO Info; 2343446Smrj 2353446Smrj 2363446Smrj ACPI_FUNCTION_TRACE (NsInitializeDevices); 2373446Smrj 2383446Smrj 2393446Smrj /* Init counters */ 2403446Smrj 2413446Smrj Info.DeviceCount = 0; 2423446Smrj Info.Num_STA = 0; 2433446Smrj Info.Num_INI = 0; 2443446Smrj 2453446Smrj ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 246*9980SDana.Myers@Sun.COM "Initializing Device/Processor/Thermal objects " 247*9980SDana.Myers@Sun.COM "by executing _INI methods:")); 2483446Smrj 2493446Smrj /* Tree analysis: find all subtrees that contain _INI methods */ 2503446Smrj 2513446Smrj Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 2523446Smrj ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, &Info, NULL); 2533446Smrj if (ACPI_FAILURE (Status)) 2543446Smrj { 2553446Smrj goto ErrorExit; 2563446Smrj } 2573446Smrj 2583446Smrj /* Allocate the evaluation information block */ 2593446Smrj 2603446Smrj Info.EvaluateInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); 2613446Smrj if (!Info.EvaluateInfo) 2623446Smrj { 2633446Smrj Status = AE_NO_MEMORY; 2643446Smrj goto ErrorExit; 2653446Smrj } 2663446Smrj 2673446Smrj /* Walk namespace to execute all _INIs on present devices */ 2683446Smrj 2693446Smrj Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 2703446Smrj ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, &Info, NULL); 2713446Smrj 2723446Smrj ACPI_FREE (Info.EvaluateInfo); 2733446Smrj if (ACPI_FAILURE (Status)) 2743446Smrj { 2753446Smrj goto ErrorExit; 2763446Smrj } 2773446Smrj 2783446Smrj ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 279*9980SDana.Myers@Sun.COM "\nExecuted %hd _INI methods requiring %hd _STA executions " 280*9980SDana.Myers@Sun.COM "(examined %hd objects)\n", 2813446Smrj Info.Num_INI, Info.Num_STA, Info.DeviceCount)); 2823446Smrj 2833446Smrj return_ACPI_STATUS (Status); 2843446Smrj 2853446Smrj 2863446Smrj ErrorExit: 2873446Smrj ACPI_EXCEPTION ((AE_INFO, Status, "During device initialization")); 2883446Smrj return_ACPI_STATUS (Status); 2893446Smrj } 2903446Smrj 2913446Smrj 2923446Smrj /******************************************************************************* 2933446Smrj * 2943446Smrj * FUNCTION: AcpiNsInitOneObject 2953446Smrj * 2963446Smrj * PARAMETERS: ObjHandle - Node 2973446Smrj * Level - Current nesting level 2983446Smrj * Context - Points to a init info struct 2993446Smrj * ReturnValue - Not used 3003446Smrj * 3013446Smrj * RETURN: Status 3023446Smrj * 3033446Smrj * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object 3043446Smrj * within the namespace. 3053446Smrj * 3063446Smrj * Currently, the only objects that require initialization are: 3073446Smrj * 1) Methods 3083446Smrj * 2) Op Regions 3093446Smrj * 3103446Smrj ******************************************************************************/ 3113446Smrj 3123446Smrj static ACPI_STATUS 3133446Smrj AcpiNsInitOneObject ( 3143446Smrj ACPI_HANDLE ObjHandle, 3153446Smrj UINT32 Level, 3163446Smrj void *Context, 3173446Smrj void **ReturnValue) 3183446Smrj { 3193446Smrj ACPI_OBJECT_TYPE Type; 3207851SDana.Myers@Sun.COM ACPI_STATUS Status = AE_OK; 3213446Smrj ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; 3223446Smrj ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 3233446Smrj ACPI_OPERAND_OBJECT *ObjDesc; 3243446Smrj 3253446Smrj 3263446Smrj ACPI_FUNCTION_NAME (NsInitOneObject); 3273446Smrj 3283446Smrj 3293446Smrj Info->ObjectCount++; 3303446Smrj 3313446Smrj /* And even then, we are only interested in a few object types */ 3323446Smrj 3333446Smrj Type = AcpiNsGetType (ObjHandle); 3343446Smrj ObjDesc = AcpiNsGetAttachedObject (Node); 3353446Smrj if (!ObjDesc) 3363446Smrj { 3373446Smrj return (AE_OK); 3383446Smrj } 3393446Smrj 3403446Smrj /* Increment counters for object types we are looking for */ 3413446Smrj 3423446Smrj switch (Type) 3433446Smrj { 3443446Smrj case ACPI_TYPE_REGION: 3453446Smrj Info->OpRegionCount++; 3463446Smrj break; 3473446Smrj 3483446Smrj case ACPI_TYPE_BUFFER_FIELD: 3493446Smrj Info->FieldCount++; 3503446Smrj break; 3513446Smrj 3527851SDana.Myers@Sun.COM case ACPI_TYPE_LOCAL_BANK_FIELD: 3537851SDana.Myers@Sun.COM Info->FieldCount++; 3547851SDana.Myers@Sun.COM break; 3557851SDana.Myers@Sun.COM 3563446Smrj case ACPI_TYPE_BUFFER: 3573446Smrj Info->BufferCount++; 3583446Smrj break; 3593446Smrj 3603446Smrj case ACPI_TYPE_PACKAGE: 3613446Smrj Info->PackageCount++; 3623446Smrj break; 3633446Smrj 3643446Smrj default: 3653446Smrj 3663446Smrj /* No init required, just exit now */ 3673446Smrj return (AE_OK); 3683446Smrj } 3693446Smrj 370*9980SDana.Myers@Sun.COM /* If the object is already initialized, nothing else to do */ 371*9980SDana.Myers@Sun.COM 3723446Smrj if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) 3733446Smrj { 3743446Smrj return (AE_OK); 3753446Smrj } 3763446Smrj 377*9980SDana.Myers@Sun.COM /* Must lock the interpreter before executing AML code */ 378*9980SDana.Myers@Sun.COM 3797851SDana.Myers@Sun.COM AcpiExEnterInterpreter (); 3803446Smrj 3813446Smrj /* 3823446Smrj * Each of these types can contain executable AML code within the 3833446Smrj * declaration. 3843446Smrj */ 3853446Smrj switch (Type) 3863446Smrj { 3873446Smrj case ACPI_TYPE_REGION: 3883446Smrj 3893446Smrj Info->OpRegionInit++; 3903446Smrj Status = AcpiDsGetRegionArguments (ObjDesc); 3913446Smrj break; 3923446Smrj 3933446Smrj case ACPI_TYPE_BUFFER_FIELD: 3943446Smrj 3953446Smrj Info->FieldInit++; 3963446Smrj Status = AcpiDsGetBufferFieldArguments (ObjDesc); 3973446Smrj break; 3983446Smrj 3997851SDana.Myers@Sun.COM case ACPI_TYPE_LOCAL_BANK_FIELD: 4007851SDana.Myers@Sun.COM 4017851SDana.Myers@Sun.COM Info->FieldInit++; 4027851SDana.Myers@Sun.COM Status = AcpiDsGetBankFieldArguments (ObjDesc); 4037851SDana.Myers@Sun.COM break; 4047851SDana.Myers@Sun.COM 4053446Smrj case ACPI_TYPE_BUFFER: 4063446Smrj 4073446Smrj Info->BufferInit++; 4083446Smrj Status = AcpiDsGetBufferArguments (ObjDesc); 4093446Smrj break; 4103446Smrj 4113446Smrj case ACPI_TYPE_PACKAGE: 4123446Smrj 4133446Smrj Info->PackageInit++; 4143446Smrj Status = AcpiDsGetPackageArguments (ObjDesc); 4153446Smrj break; 4163446Smrj 4173446Smrj default: 4183446Smrj /* No other types can get here */ 4193446Smrj break; 4203446Smrj } 4213446Smrj 4223446Smrj if (ACPI_FAILURE (Status)) 4233446Smrj { 4243446Smrj ACPI_EXCEPTION ((AE_INFO, Status, 4253446Smrj "Could not execute arguments for [%4.4s] (%s)", 4263446Smrj AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Type))); 4273446Smrj } 4283446Smrj 4293446Smrj /* 4303446Smrj * Print a dot for each object unless we are going to print the entire 4313446Smrj * pathname 4323446Smrj */ 4333446Smrj if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES)) 4343446Smrj { 4353446Smrj ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); 4363446Smrj } 4373446Smrj 4383446Smrj /* 4393446Smrj * We ignore errors from above, and always return OK, since we don't want 4403446Smrj * to abort the walk on any single error. 4413446Smrj */ 4423446Smrj AcpiExExitInterpreter (); 4433446Smrj return (AE_OK); 4443446Smrj } 4453446Smrj 4463446Smrj 4473446Smrj /******************************************************************************* 4483446Smrj * 4493446Smrj * FUNCTION: AcpiNsFindIniMethods 4503446Smrj * 4513446Smrj * PARAMETERS: ACPI_WALK_CALLBACK 4523446Smrj * 4533446Smrj * RETURN: ACPI_STATUS 4543446Smrj * 4553446Smrj * DESCRIPTION: Called during namespace walk. Finds objects named _INI under 4563446Smrj * device/processor/thermal objects, and marks the entire subtree 4573446Smrj * with a SUBTREE_HAS_INI flag. This flag is used during the 4583446Smrj * subsequent device initialization walk to avoid entire subtrees 4593446Smrj * that do not contain an _INI. 4603446Smrj * 4613446Smrj ******************************************************************************/ 4623446Smrj 4633446Smrj static ACPI_STATUS 4643446Smrj AcpiNsFindIniMethods ( 4653446Smrj ACPI_HANDLE ObjHandle, 4663446Smrj UINT32 NestingLevel, 4673446Smrj void *Context, 4683446Smrj void **ReturnValue) 4693446Smrj { 4703446Smrj ACPI_DEVICE_WALK_INFO *Info = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context); 4713446Smrj ACPI_NAMESPACE_NODE *Node; 4723446Smrj ACPI_NAMESPACE_NODE *ParentNode; 4733446Smrj 4743446Smrj 4753446Smrj /* Keep count of device/processor/thermal objects */ 4763446Smrj 4773446Smrj Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); 4783446Smrj if ((Node->Type == ACPI_TYPE_DEVICE) || 4793446Smrj (Node->Type == ACPI_TYPE_PROCESSOR) || 4803446Smrj (Node->Type == ACPI_TYPE_THERMAL)) 4813446Smrj { 4823446Smrj Info->DeviceCount++; 4833446Smrj return (AE_OK); 4843446Smrj } 4853446Smrj 4863446Smrj /* We are only looking for methods named _INI */ 4873446Smrj 4883446Smrj if (!ACPI_COMPARE_NAME (Node->Name.Ascii, METHOD_NAME__INI)) 4893446Smrj { 4903446Smrj return (AE_OK); 4913446Smrj } 4923446Smrj 4933446Smrj /* 4943446Smrj * The only _INI methods that we care about are those that are 4953446Smrj * present under Device, Processor, and Thermal objects. 4963446Smrj */ 4973446Smrj ParentNode = AcpiNsGetParentNode (Node); 4983446Smrj switch (ParentNode->Type) 4993446Smrj { 5003446Smrj case ACPI_TYPE_DEVICE: 5013446Smrj case ACPI_TYPE_PROCESSOR: 5023446Smrj case ACPI_TYPE_THERMAL: 5033446Smrj 5043446Smrj /* Mark parent and bubble up the INI present flag to the root */ 5053446Smrj 5063446Smrj while (ParentNode) 5073446Smrj { 5083446Smrj ParentNode->Flags |= ANOBJ_SUBTREE_HAS_INI; 5093446Smrj ParentNode = AcpiNsGetParentNode (ParentNode); 5103446Smrj } 5113446Smrj break; 5123446Smrj 5133446Smrj default: 5143446Smrj break; 5153446Smrj } 5163446Smrj 5173446Smrj return (AE_OK); 5183446Smrj } 5193446Smrj 5203446Smrj 5213446Smrj /******************************************************************************* 5223446Smrj * 5233446Smrj * FUNCTION: AcpiNsInitOneDevice 5243446Smrj * 5253446Smrj * PARAMETERS: ACPI_WALK_CALLBACK 5263446Smrj * 5273446Smrj * RETURN: ACPI_STATUS 5283446Smrj * 5293446Smrj * DESCRIPTION: This is called once per device soon after ACPI is enabled 5303446Smrj * to initialize each device. It determines if the device is 5313446Smrj * present, and if so, calls _INI. 5323446Smrj * 5333446Smrj ******************************************************************************/ 5343446Smrj 5353446Smrj static ACPI_STATUS 5363446Smrj AcpiNsInitOneDevice ( 5373446Smrj ACPI_HANDLE ObjHandle, 5383446Smrj UINT32 NestingLevel, 5393446Smrj void *Context, 5403446Smrj void **ReturnValue) 5413446Smrj { 5423446Smrj ACPI_DEVICE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context); 5433446Smrj ACPI_EVALUATE_INFO *Info = WalkInfo->EvaluateInfo; 5443446Smrj UINT32 Flags; 5453446Smrj ACPI_STATUS Status; 5463446Smrj ACPI_NAMESPACE_NODE *DeviceNode; 5473446Smrj 5483446Smrj 5493446Smrj ACPI_FUNCTION_TRACE (NsInitOneDevice); 5503446Smrj 5513446Smrj 5523446Smrj /* We are interested in Devices, Processors and ThermalZones only */ 5533446Smrj 5543446Smrj DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); 5553446Smrj if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && 5563446Smrj (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && 5573446Smrj (DeviceNode->Type != ACPI_TYPE_THERMAL)) 5583446Smrj { 5593446Smrj return_ACPI_STATUS (AE_OK); 5603446Smrj } 5613446Smrj 5623446Smrj /* 5633446Smrj * Because of an earlier namespace analysis, all subtrees that contain an 5643446Smrj * _INI method are tagged. 5653446Smrj * 5663446Smrj * If this device subtree does not contain any _INI methods, we 5673446Smrj * can exit now and stop traversing this entire subtree. 5683446Smrj */ 5693446Smrj if (!(DeviceNode->Flags & ANOBJ_SUBTREE_HAS_INI)) 5703446Smrj { 5713446Smrj return_ACPI_STATUS (AE_CTRL_DEPTH); 5723446Smrj } 5733446Smrj 5743446Smrj /* 5753446Smrj * Run _STA to determine if this device is present and functioning. We 5763446Smrj * must know this information for two important reasons (from ACPI spec): 5773446Smrj * 5783446Smrj * 1) We can only run _INI if the device is present. 5793446Smrj * 2) We must abort the device tree walk on this subtree if the device is 5803446Smrj * not present and is not functional (we will not examine the children) 5813446Smrj * 5823446Smrj * The _STA method is not required to be present under the device, we 5833446Smrj * assume the device is present if _STA does not exist. 5843446Smrj */ 5853446Smrj ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( 5863446Smrj ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__STA)); 5873446Smrj 5883446Smrj Status = AcpiUtExecute_STA (DeviceNode, &Flags); 5893446Smrj if (ACPI_FAILURE (Status)) 5903446Smrj { 5913446Smrj /* Ignore error and move on to next device */ 5923446Smrj 5933446Smrj return_ACPI_STATUS (AE_OK); 5943446Smrj } 5953446Smrj 5963446Smrj /* 5973446Smrj * Flags == -1 means that _STA was not found. In this case, we assume that 5983446Smrj * the device is both present and functional. 5993446Smrj * 6003446Smrj * From the ACPI spec, description of _STA: 6013446Smrj * 6023446Smrj * "If a device object (including the processor object) does not have an 6033446Smrj * _STA object, then OSPM assumes that all of the above bits are set (in 6043446Smrj * other words, the device is present, ..., and functioning)" 6053446Smrj */ 6063446Smrj if (Flags != ACPI_UINT32_MAX) 6073446Smrj { 6083446Smrj WalkInfo->Num_STA++; 6093446Smrj } 6103446Smrj 6113446Smrj /* 6123446Smrj * Examine the PRESENT and FUNCTIONING status bits 6133446Smrj * 6143446Smrj * Note: ACPI spec does not seem to specify behavior for the present but 6153446Smrj * not functioning case, so we assume functioning if present. 6163446Smrj */ 6173446Smrj if (!(Flags & ACPI_STA_DEVICE_PRESENT)) 6183446Smrj { 6193446Smrj /* Device is not present, we must examine the Functioning bit */ 6203446Smrj 6213446Smrj if (Flags & ACPI_STA_DEVICE_FUNCTIONING) 6223446Smrj { 6233446Smrj /* 6243446Smrj * Device is not present but is "functioning". In this case, 6253446Smrj * we will not run _INI, but we continue to examine the children 6263446Smrj * of this device. 6273446Smrj * 6283446Smrj * From the ACPI spec, description of _STA: (Note - no mention 6293446Smrj * of whether to run _INI or not on the device in question) 6303446Smrj * 6313446Smrj * "_STA may return bit 0 clear (not present) with bit 3 set 6323446Smrj * (device is functional). This case is used to indicate a valid 6333446Smrj * device for which no device driver should be loaded (for example, 6343446Smrj * a bridge device.) Children of this device may be present and 6353446Smrj * valid. OSPM should continue enumeration below a device whose 6363446Smrj * _STA returns this bit combination" 6373446Smrj */ 6383446Smrj return_ACPI_STATUS (AE_OK); 6393446Smrj } 6403446Smrj else 6413446Smrj { 6423446Smrj /* 6433446Smrj * Device is not present and is not functioning. We must abort the 6443446Smrj * walk of this subtree immediately -- don't look at the children 6453446Smrj * of such a device. 6463446Smrj * 6473446Smrj * From the ACPI spec, description of _INI: 6483446Smrj * 6493446Smrj * "If the _STA method indicates that the device is not present, 6503446Smrj * OSPM will not run the _INI and will not examine the children 6513446Smrj * of the device for _INI methods" 6523446Smrj */ 6533446Smrj return_ACPI_STATUS (AE_CTRL_DEPTH); 6543446Smrj } 6553446Smrj } 6563446Smrj 6573446Smrj /* 6583446Smrj * The device is present or is assumed present if no _STA exists. 6593446Smrj * Run the _INI if it exists (not required to exist) 6603446Smrj * 6613446Smrj * Note: We know there is an _INI within this subtree, but it may not be 6623446Smrj * under this particular device, it may be lower in the branch. 6633446Smrj */ 6643446Smrj ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( 6653446Smrj ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI)); 6663446Smrj 6673446Smrj Info->PrefixNode = DeviceNode; 6683446Smrj Info->Pathname = METHOD_NAME__INI; 6693446Smrj Info->Parameters = NULL; 6703446Smrj Info->Flags = ACPI_IGNORE_RETURN_VALUE; 6713446Smrj 6723446Smrj Status = AcpiNsEvaluate (Info); 6733446Smrj if (ACPI_SUCCESS (Status)) 6743446Smrj { 6753446Smrj WalkInfo->Num_INI++; 6763446Smrj 6773446Smrj if ((AcpiDbgLevel <= ACPI_LV_ALL_EXCEPTIONS) && 6783446Smrj (!(AcpiDbgLevel & ACPI_LV_INFO))) 6793446Smrj { 6803446Smrj ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); 6813446Smrj } 6823446Smrj } 6833446Smrj 6843446Smrj #ifdef ACPI_DEBUG_OUTPUT 6853446Smrj else if (Status != AE_NOT_FOUND) 6863446Smrj { 6873446Smrj /* Ignore error and move on to next device */ 6883446Smrj 6893446Smrj char *ScopeName = AcpiNsGetExternalPathname (Info->ResolvedNode); 6903446Smrj 6913446Smrj ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution", 6923446Smrj ScopeName)); 6933446Smrj ACPI_FREE (ScopeName); 6943446Smrj } 6953446Smrj #endif 6963446Smrj 6973446Smrj /* Ignore errors from above */ 6983446Smrj 6993446Smrj Status = AE_OK; 7003446Smrj 7013446Smrj /* 7023446Smrj * The _INI method has been run if present; call the Global Initialization 7033446Smrj * Handler for this device. 7043446Smrj */ 7053446Smrj if (AcpiGbl_InitHandler) 7063446Smrj { 7073446Smrj Status = AcpiGbl_InitHandler (DeviceNode, ACPI_INIT_DEVICE_INI); 7083446Smrj } 7093446Smrj 7103446Smrj return_ACPI_STATUS (Status); 7113446Smrj } 712