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