Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/drivers/acpica/nsinit.c need to be fixed.

0001 /******************************************************************************
0002  *
0003  * Module Name: nsinit - namespace initialization
0004  *
0005  *****************************************************************************/
0006 
0007 /******************************************************************************
0008  *
0009  * 1. Copyright Notice
0010  *
0011  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
0012  * All rights reserved.
0013  *
0014  * 2. License
0015  *
0016  * 2.1. This is your license from Intel Corp. under its intellectual property
0017  * rights.  You may have additional license terms from the party that provided
0018  * you this software, covering your right to use that party's intellectual
0019  * property rights.
0020  *
0021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0022  * copy of the source code appearing in this file ("Covered Code") an
0023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0024  * base code distributed originally by Intel ("Original Intel Code") to copy,
0025  * make derivatives, distribute, use and display any portion of the Covered
0026  * Code in any form, with the right to sublicense such rights; and
0027  *
0028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0029  * license (with the right to sublicense), under only those claims of Intel
0030  * patents that are infringed by the Original Intel Code, to make, use, sell,
0031  * offer to sell, and import the Covered Code and derivative works thereof
0032  * solely to the minimum extent necessary to exercise the above copyright
0033  * license, and in no event shall the patent license extend to any additions
0034  * to or modifications of the Original Intel Code.  No other license or right
0035  * is granted directly or by implication, estoppel or otherwise;
0036  *
0037  * The above copyright and patent license is granted only if the following
0038  * conditions are met:
0039  *
0040  * 3. Conditions
0041  *
0042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0043  * Redistribution of source code of any substantial portion of the Covered
0044  * Code or modification with rights to further distribute source must include
0045  * the above Copyright Notice, the above License, this list of Conditions,
0046  * and the following Disclaimer and Export Compliance provision.  In addition,
0047  * Licensee must cause all Covered Code to which Licensee contributes to
0048  * contain a file documenting the changes Licensee made to create that Covered
0049  * Code and the date of any change.  Licensee must include in that file the
0050  * documentation of any changes made by any predecessor Licensee.  Licensee
0051  * must include a prominent statement that the modification is derived,
0052  * directly or indirectly, from Original Intel Code.
0053  *
0054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0055  * Redistribution of source code of any substantial portion of the Covered
0056  * Code or modification without rights to further distribute source must
0057  * include the following Disclaimer and Export Compliance provision in the
0058  * documentation and/or other materials provided with distribution.  In
0059  * addition, Licensee may not authorize further sublicense of source of any
0060  * portion of the Covered Code, and must include terms to the effect that the
0061  * license from Licensee to its licensee is limited to the intellectual
0062  * property embodied in the software Licensee provides to its licensee, and
0063  * not to intellectual property embodied in modifications its licensee may
0064  * make.
0065  *
0066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0067  * substantial portion of the Covered Code or modification must reproduce the
0068  * above Copyright Notice, and the following Disclaimer and Export Compliance
0069  * provision in the documentation and/or other materials provided with the
0070  * distribution.
0071  *
0072  * 3.4. Intel retains all right, title, and interest in and to the Original
0073  * Intel Code.
0074  *
0075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0076  * Intel shall be used in advertising or otherwise to promote the sale, use or
0077  * other dealings in products derived from or relating to the Covered Code
0078  * without prior written authorization from Intel.
0079  *
0080  * 4. Disclaimer and Export Compliance
0081  *
0082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0083  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
0085  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
0086  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
0087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0088  * PARTICULAR PURPOSE.
0089  *
0090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
0096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0097  * LIMITED REMEDY.
0098  *
0099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0100  * software or system incorporating such software without first obtaining any
0101  * required license or other approval from the U. S. Department of Commerce or
0102  * any other agency or department of the United States Government.  In the
0103  * event Licensee exports any such software from the United States or
0104  * re-exports any such software from a foreign destination, Licensee shall
0105  * ensure that the distribution and export/re-export of the software is in
0106  * compliance with all laws, regulations, orders, or other restrictions of the
0107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0108  * any of its subsidiaries will export/re-export any technical data, process,
0109  * software, or service, directly or indirectly, to any country for which the
0110  * United States government or any agency thereof requires an export license,
0111  * other governmental approval, or letter of assurance, without first obtaining
0112  * such license, approval or letter.
0113  *
0114  *****************************************************************************/
0115 
0116 
0117 #define __NSXFINIT_C__
0118 
0119 #include "acpi.h"
0120 #include "accommon.h"
0121 #include "acnamesp.h"
0122 #include "acdispat.h"
0123 #include "acinterp.h"
0124 
0125 #define _COMPONENT          ACPI_NAMESPACE
0126         ACPI_MODULE_NAME    ("nsinit")
0127 
0128 /* Local prototypes */
0129 
0130 static ACPI_STATUS
0131 AcpiNsInitOneObject (
0132     ACPI_HANDLE             ObjHandle,
0133     UINT32                  Level,
0134     void                    *Context,
0135     void                    **ReturnValue);
0136 
0137 static ACPI_STATUS
0138 AcpiNsInitOneDevice (
0139     ACPI_HANDLE             ObjHandle,
0140     UINT32                  NestingLevel,
0141     void                    *Context,
0142     void                    **ReturnValue);
0143 
0144 static ACPI_STATUS
0145 AcpiNsFindIniMethods (
0146     ACPI_HANDLE             ObjHandle,
0147     UINT32                  NestingLevel,
0148     void                    *Context,
0149     void                    **ReturnValue);
0150 
0151 
0152 /*******************************************************************************
0153  *
0154  * FUNCTION:    AcpiNsInitializeObjects
0155  *
0156  * PARAMETERS:  None
0157  *
0158  * RETURN:      Status
0159  *
0160  * DESCRIPTION: Walk the entire namespace and perform any necessary
0161  *              initialization on the objects found therein
0162  *
0163  ******************************************************************************/
0164 
0165 ACPI_STATUS
0166 AcpiNsInitializeObjects (
0167     void)
0168 {
0169     ACPI_STATUS             Status;
0170     ACPI_INIT_WALK_INFO     Info;
0171 
0172 
0173     ACPI_FUNCTION_TRACE (NsInitializeObjects);
0174 
0175 
0176     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
0177         "**** Starting initialization of namespace objects ****\n"));
0178     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
0179         "Completing Region/Field/Buffer/Package initialization:"));
0180 
0181     /* Set all init info to zero */
0182 
0183     ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO));
0184 
0185     /* Walk entire namespace from the supplied root */
0186 
0187     Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
0188                                 ACPI_UINT32_MAX, AcpiNsInitOneObject,
0189                                 &Info, NULL);
0190     if (ACPI_FAILURE (Status))
0191     {
0192         ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace"));
0193     }
0194 
0195     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
0196         "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd "
0197         "Buffers %hd/%hd Packages (%hd nodes)\n",
0198         Info.OpRegionInit,  Info.OpRegionCount,
0199         Info.FieldInit,     Info.FieldCount,
0200         Info.BufferInit,    Info.BufferCount,
0201         Info.PackageInit,   Info.PackageCount, Info.ObjectCount));
0202 
0203     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
0204         "%hd Control Methods found\n", Info.MethodCount));
0205     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
0206         "%hd Op Regions found\n", Info.OpRegionCount));
0207 
0208     return_ACPI_STATUS (AE_OK);
0209 }
0210 
0211 
0212 /*******************************************************************************
0213  *
0214  * FUNCTION:    AcpiNsInitializeDevices
0215  *
0216  * PARAMETERS:  None
0217  *
0218  * RETURN:      ACPI_STATUS
0219  *
0220  * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices.
0221  *              This means running _INI on all present devices.
0222  *
0223  *              Note: We install PCI config space handler on region access,
0224  *              not here.
0225  *
0226  ******************************************************************************/
0227 
0228 ACPI_STATUS
0229 AcpiNsInitializeDevices (
0230     void)
0231 {
0232     ACPI_STATUS             Status;
0233     ACPI_DEVICE_WALK_INFO   Info;
0234 
0235 
0236     ACPI_FUNCTION_TRACE (NsInitializeDevices);
0237 
0238 
0239     /* Init counters */
0240 
0241     Info.DeviceCount = 0;
0242     Info.Num_STA = 0;
0243     Info.Num_INI = 0;
0244 
0245     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
0246         "Initializing Device/Processor/Thermal objects "
0247         "by executing _INI methods:"));
0248 
0249     /* Tree analysis: find all subtrees that contain _INI methods */
0250 
0251     Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
0252                 ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, &Info, NULL);
0253     if (ACPI_FAILURE (Status))
0254     {
0255         goto ErrorExit;
0256     }
0257 
0258     /* Allocate the evaluation information block */
0259 
0260     Info.EvaluateInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
0261     if (!Info.EvaluateInfo)
0262     {
0263         Status = AE_NO_MEMORY;
0264         goto ErrorExit;
0265     }
0266 
0267     /* Walk namespace to execute all _INIs on present devices */
0268 
0269     Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
0270                 ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, &Info, NULL);
0271 
0272     ACPI_FREE (Info.EvaluateInfo);
0273     if (ACPI_FAILURE (Status))
0274     {
0275         goto ErrorExit;
0276     }
0277 
0278     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
0279         "\nExecuted %hd _INI methods requiring %hd _STA executions "
0280         "(examined %hd objects)\n",
0281         Info.Num_INI, Info.Num_STA, Info.DeviceCount));
0282 
0283     return_ACPI_STATUS (Status);
0284 
0285 
0286 ErrorExit:
0287     ACPI_EXCEPTION ((AE_INFO, Status, "During device initialization"));
0288     return_ACPI_STATUS (Status);
0289 }
0290 
0291 
0292 /*******************************************************************************
0293  *
0294  * FUNCTION:    AcpiNsInitOneObject
0295  *
0296  * PARAMETERS:  ObjHandle       - Node
0297  *              Level           - Current nesting level
0298  *              Context         - Points to a init info struct
0299  *              ReturnValue     - Not used
0300  *
0301  * RETURN:      Status
0302  *
0303  * DESCRIPTION: Callback from AcpiWalkNamespace.  Invoked for every object
0304  *              within the  namespace.
0305  *
0306  *              Currently, the only objects that require initialization are:
0307  *              1) Methods
0308  *              2) Op Regions
0309  *
0310  ******************************************************************************/
0311 
0312 static ACPI_STATUS
0313 AcpiNsInitOneObject (
0314     ACPI_HANDLE             ObjHandle,
0315     UINT32                  Level,
0316     void                    *Context,
0317     void                    **ReturnValue)
0318 {
0319     ACPI_OBJECT_TYPE        Type;
0320     ACPI_STATUS             Status = AE_OK;
0321     ACPI_INIT_WALK_INFO     *Info = (ACPI_INIT_WALK_INFO *) Context;
0322     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
0323     ACPI_OPERAND_OBJECT     *ObjDesc;
0324 
0325 
0326     ACPI_FUNCTION_NAME (NsInitOneObject);
0327 
0328 
0329     Info->ObjectCount++;
0330 
0331     /* And even then, we are only interested in a few object types */
0332 
0333     Type = AcpiNsGetType (ObjHandle);
0334     ObjDesc = AcpiNsGetAttachedObject (Node);
0335     if (!ObjDesc)
0336     {
0337         return (AE_OK);
0338     }
0339 
0340     /* Increment counters for object types we are looking for */
0341 
0342     switch (Type)
0343     {
0344     case ACPI_TYPE_REGION:
0345         Info->OpRegionCount++;
0346         break;
0347 
0348     case ACPI_TYPE_BUFFER_FIELD:
0349         Info->FieldCount++;
0350         break;
0351 
0352     case ACPI_TYPE_LOCAL_BANK_FIELD:
0353         Info->FieldCount++;
0354         break;
0355 
0356     case ACPI_TYPE_BUFFER:
0357         Info->BufferCount++;
0358         break;
0359 
0360     case ACPI_TYPE_PACKAGE:
0361         Info->PackageCount++;
0362         break;
0363 
0364     default:
0365 
0366         /* No init required, just exit now */
0367         return (AE_OK);
0368     }
0369 
0370     /* If the object is already initialized, nothing else to do */
0371 
0372     if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
0373     {
0374         return (AE_OK);
0375     }
0376 
0377     /* Must lock the interpreter before executing AML code */
0378 
0379     AcpiExEnterInterpreter ();
0380 
0381     /*
0382      * Each of these types can contain executable AML code within the
0383      * declaration.
0384      */
0385     switch (Type)
0386     {
0387     case ACPI_TYPE_REGION:
0388 
0389         Info->OpRegionInit++;
0390         Status = AcpiDsGetRegionArguments (ObjDesc);
0391         break;
0392 
0393     case ACPI_TYPE_BUFFER_FIELD:
0394 
0395         Info->FieldInit++;
0396         Status = AcpiDsGetBufferFieldArguments (ObjDesc);
0397         break;
0398 
0399     case ACPI_TYPE_LOCAL_BANK_FIELD:
0400 
0401         Info->FieldInit++;
0402         Status = AcpiDsGetBankFieldArguments (ObjDesc);
0403         break;
0404 
0405     case ACPI_TYPE_BUFFER:
0406 
0407         Info->BufferInit++;
0408         Status = AcpiDsGetBufferArguments (ObjDesc);
0409         break;
0410 
0411     case ACPI_TYPE_PACKAGE:
0412 
0413         Info->PackageInit++;
0414         Status = AcpiDsGetPackageArguments (ObjDesc);
0415         break;
0416 
0417     default:
0418         /* No other types can get here */
0419         break;
0420     }
0421 
0422     if (ACPI_FAILURE (Status))
0423     {
0424         ACPI_EXCEPTION ((AE_INFO, Status,
0425             "Could not execute arguments for [%4.4s] (%s)",
0426             AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Type)));
0427     }
0428 
0429     /*
0430      * Print a dot for each object unless we are going to print the entire
0431      * pathname
0432      */
0433     if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
0434     {
0435         ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
0436     }
0437 
0438     /*
0439      * We ignore errors from above, and always return OK, since we don't want
0440      * to abort the walk on any single error.
0441      */
0442     AcpiExExitInterpreter ();
0443     return (AE_OK);
0444 }
0445 
0446 
0447 /*******************************************************************************
0448  *
0449  * FUNCTION:    AcpiNsFindIniMethods
0450  *
0451  * PARAMETERS:  ACPI_WALK_CALLBACK
0452  *
0453  * RETURN:      ACPI_STATUS
0454  *
0455  * DESCRIPTION: Called during namespace walk. Finds objects named _INI under
0456  *              device/processor/thermal objects, and marks the entire subtree
0457  *              with a SUBTREE_HAS_INI flag. This flag is used during the
0458  *              subsequent device initialization walk to avoid entire subtrees
0459  *              that do not contain an _INI.
0460  *
0461  ******************************************************************************/
0462 
0463 static ACPI_STATUS
0464 AcpiNsFindIniMethods (
0465     ACPI_HANDLE             ObjHandle,
0466     UINT32                  NestingLevel,
0467     void                    *Context,
0468     void                    **ReturnValue)
0469 {
0470     ACPI_DEVICE_WALK_INFO   *Info = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context);
0471     ACPI_NAMESPACE_NODE     *Node;
0472     ACPI_NAMESPACE_NODE     *ParentNode;
0473 
0474 
0475     /* Keep count of device/processor/thermal objects */
0476 
0477     Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
0478     if ((Node->Type == ACPI_TYPE_DEVICE)    ||
0479         (Node->Type == ACPI_TYPE_PROCESSOR) ||
0480         (Node->Type == ACPI_TYPE_THERMAL))
0481     {
0482         Info->DeviceCount++;
0483         return (AE_OK);
0484     }
0485 
0486     /* We are only looking for methods named _INI */
0487 
0488     if (!ACPI_COMPARE_NAME (Node->Name.Ascii, METHOD_NAME__INI))
0489     {
0490         return (AE_OK);
0491     }
0492 
0493     /*
0494      * The only _INI methods that we care about are those that are
0495      * present under Device, Processor, and Thermal objects.
0496      */
0497     ParentNode = AcpiNsGetParentNode (Node);
0498     switch (ParentNode->Type)
0499     {
0500     case ACPI_TYPE_DEVICE:
0501     case ACPI_TYPE_PROCESSOR:
0502     case ACPI_TYPE_THERMAL:
0503 
0504         /* Mark parent and bubble up the INI present flag to the root */
0505 
0506         while (ParentNode)
0507         {
0508             ParentNode->Flags |= ANOBJ_SUBTREE_HAS_INI;
0509             ParentNode = AcpiNsGetParentNode (ParentNode);
0510         }
0511         break;
0512 
0513     default:
0514         break;
0515     }
0516 
0517     return (AE_OK);
0518 }
0519 
0520 
0521 /*******************************************************************************
0522  *
0523  * FUNCTION:    AcpiNsInitOneDevice
0524  *
0525  * PARAMETERS:  ACPI_WALK_CALLBACK
0526  *
0527  * RETURN:      ACPI_STATUS
0528  *
0529  * DESCRIPTION: This is called once per device soon after ACPI is enabled
0530  *              to initialize each device. It determines if the device is
0531  *              present, and if so, calls _INI.
0532  *
0533  ******************************************************************************/
0534 
0535 static ACPI_STATUS
0536 AcpiNsInitOneDevice (
0537     ACPI_HANDLE             ObjHandle,
0538     UINT32                  NestingLevel,
0539     void                    *Context,
0540     void                    **ReturnValue)
0541 {
0542     ACPI_DEVICE_WALK_INFO   *WalkInfo = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context);
0543     ACPI_EVALUATE_INFO      *Info = WalkInfo->EvaluateInfo;
0544     UINT32                  Flags;
0545     ACPI_STATUS             Status;
0546     ACPI_NAMESPACE_NODE     *DeviceNode;
0547 
0548 
0549     ACPI_FUNCTION_TRACE (NsInitOneDevice);
0550 
0551 
0552     /* We are interested in Devices, Processors and ThermalZones only */
0553 
0554     DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
0555     if ((DeviceNode->Type != ACPI_TYPE_DEVICE)    &&
0556         (DeviceNode->Type != ACPI_TYPE_PROCESSOR) &&
0557         (DeviceNode->Type != ACPI_TYPE_THERMAL))
0558     {
0559         return_ACPI_STATUS (AE_OK);
0560     }
0561 
0562     /*
0563      * Because of an earlier namespace analysis, all subtrees that contain an
0564      * _INI method are tagged.
0565      *
0566      * If this device subtree does not contain any _INI methods, we
0567      * can exit now and stop traversing this entire subtree.
0568      */
0569     if (!(DeviceNode->Flags & ANOBJ_SUBTREE_HAS_INI))
0570     {
0571         return_ACPI_STATUS (AE_CTRL_DEPTH);
0572     }
0573 
0574     /*
0575      * Run _STA to determine if this device is present and functioning. We
0576      * must know this information for two important reasons (from ACPI spec):
0577      *
0578      * 1) We can only run _INI if the device is present.
0579      * 2) We must abort the device tree walk on this subtree if the device is
0580      *    not present and is not functional (we will not examine the children)
0581      *
0582      * The _STA method is not required to be present under the device, we
0583      * assume the device is present if _STA does not exist.
0584      */
0585     ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
0586         ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__STA));
0587 
0588     Status = AcpiUtExecute_STA (DeviceNode, &Flags);
0589     if (ACPI_FAILURE (Status))
0590     {
0591         /* Ignore error and move on to next device */
0592 
0593         return_ACPI_STATUS (AE_OK);
0594     }
0595 
0596     /*
0597      * Flags == -1 means that _STA was not found. In this case, we assume that
0598      * the device is both present and functional.
0599      *
0600      * From the ACPI spec, description of _STA:
0601      *
0602      * "If a device object (including the processor object) does not have an
0603      * _STA object, then OSPM assumes that all of the above bits are set (in
0604      * other words, the device is present, ..., and functioning)"
0605      */
0606     if (Flags != ACPI_UINT32_MAX)
0607     {
0608         WalkInfo->Num_STA++;
0609     }
0610 
0611     /*
0612      * Examine the PRESENT and FUNCTIONING status bits
0613      *
0614      * Note: ACPI spec does not seem to specify behavior for the present but
0615      * not functioning case, so we assume functioning if present.
0616      */
0617     if (!(Flags & ACPI_STA_DEVICE_PRESENT))
0618     {
0619         /* Device is not present, we must examine the Functioning bit */
0620 
0621         if (Flags & ACPI_STA_DEVICE_FUNCTIONING)
0622         {
0623             /*
0624              * Device is not present but is "functioning". In this case,
0625              * we will not run _INI, but we continue to examine the children
0626              * of this device.
0627              *
0628              * From the ACPI spec, description of _STA: (Note - no mention
0629              * of whether to run _INI or not on the device in question)
0630              *
0631              * "_STA may return bit 0 clear (not present) with bit 3 set
0632              * (device is functional). This case is used to indicate a valid
0633              * device for which no device driver should be loaded (for example,
0634              * a bridge device.) Children of this device may be present and
0635              * valid. OSPM should continue enumeration below a device whose
0636              * _STA returns this bit combination"
0637              */
0638             return_ACPI_STATUS (AE_OK);
0639         }
0640         else
0641         {
0642             /*
0643              * Device is not present and is not functioning. We must abort the
0644              * walk of this subtree immediately -- don't look at the children
0645              * of such a device.
0646              *
0647              * From the ACPI spec, description of _INI:
0648              *
0649              * "If the _STA method indicates that the device is not present,
0650              * OSPM will not run the _INI and will not examine the children
0651              * of the device for _INI methods"
0652              */
0653             return_ACPI_STATUS (AE_CTRL_DEPTH);
0654         }
0655     }
0656 
0657     /*
0658      * The device is present or is assumed present if no _STA exists.
0659      * Run the _INI if it exists (not required to exist)
0660      *
0661      * Note: We know there is an _INI within this subtree, but it may not be
0662      * under this particular device, it may be lower in the branch.
0663      */
0664     ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
0665         ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI));
0666 
0667     Info->PrefixNode = DeviceNode;
0668     Info->Pathname = METHOD_NAME__INI;
0669     Info->Parameters = NULL;
0670     Info->Flags = ACPI_IGNORE_RETURN_VALUE;
0671 
0672     Status = AcpiNsEvaluate (Info);
0673     if (ACPI_SUCCESS (Status))
0674     {
0675         WalkInfo->Num_INI++;
0676 
0677         if ((AcpiDbgLevel <= ACPI_LV_ALL_EXCEPTIONS) &&
0678             (!(AcpiDbgLevel & ACPI_LV_INFO)))
0679         {
0680             ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
0681         }
0682     }
0683 
0684 #ifdef ACPI_DEBUG_OUTPUT
0685     else if (Status != AE_NOT_FOUND)
0686     {
0687         /* Ignore error and move on to next device */
0688 
0689         char *ScopeName = AcpiNsGetExternalPathname (Info->ResolvedNode);
0690 
0691         ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution",
0692             ScopeName));
0693         ACPI_FREE (ScopeName);
0694     }
0695 #endif
0696 
0697     /* Ignore errors from above */
0698 
0699     Status = AE_OK;
0700 
0701     /*
0702      * The _INI method has been run if present; call the Global Initialization
0703      * Handler for this device.
0704      */
0705     if (AcpiGbl_InitHandler)
0706     {
0707         Status = AcpiGbl_InitHandler (DeviceNode, ACPI_INIT_DEVICE_INI);
0708     }
0709 
0710     return_ACPI_STATUS (Status);
0711 }