kernel/acpica/components/events/evrgnini.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiEvInitializeRegion
 *
 * PARAMETERS:  RegionObj       - Region we are initializing
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Initializes the region, finds any _REG methods and saves them
 *              for execution at a later time
 *
 *              Get the appropriate address space handler for a newly
 *              created region.
 *
 *              This also performs address space specific initialization. For
 *              example, PCI regions must have an _ADR object that contains
 *              a PCI address in the scope of the definition. This address is
 *              required to perform an access to PCI config space.
 *
 * MUTEX:       Interpreter should be unlocked, because we may run the _REG
 *              method for this region.
 *
 * NOTE:        Possible incompliance:
 *              There is a behavior conflict in automatic _REG execution:
 *              1. When the interpreter is evaluating a method, we can only
 *                 automatically run _REG for the following case:
 *                   Method(_REG, 2) {}
 *                   OperationRegion (OPR1, 0x80, 0x1000010, 0x4)
 *              2. When the interpreter is loading a table, we can also
 *                 automatically run _REG for the following case:
 *                   OperationRegion (OPR1, 0x80, 0x1000010, 0x4)
 *                   Method(_REG, 2) {}
 *              Though this may not be compliant to the de-facto standard, the
 *              logic is kept in order not to trigger regressions. And keeping
 *              this logic should be taken care by the caller of this function.
 *
 ******************************************************************************/
AcpiEvInitializeRegion
PARAMETERS:  RegionObj       - Region we are initializing

Status

Initializes the region, finds any _REG methods and saves them
for execution at a later time

Get the appropriate address space handler for a newly
created region.

This also performs address space specific initialization. For
example, PCI regions must have an _ADR object that contains
a PCI address in the scope of the definition. This address is
required to perform an access to PCI config space.

Interpreter should be unlocked, because we may run the _REG
method for this region.

Possible incompliance:
There is a behavior conflict in automatic _REG execution:
1. When the interpreter is evaluating a method, we can only
automatically run _REG for the following case:
Method(_REG, 2) {}
OperationRegion (OPR1, 0x80, 0x1000010, 0x4)
2. When the interpreter is loading a table, we can also
automatically run _REG for the following case:
OperationRegion (OPR1, 0x80, 0x1000010, 0x4)
Method(_REG, 2) {}
Though this may not be compliant to the de-facto standard, the
logic is kept in order not to trigger regressions. And keeping
this logic should be taken care by the caller of this function.
AcpiEvInitializeRegion PARAMETERS : RegionObj - Region we are initializing Status Initializes the region finds any _REG methods and saves them for execution at a later time Get the appropriate address space handler for a newly created region . This also performs address space specific initialization . For example PCI regions must have an _ADR object that contains a PCI address in the scope of the definition . This address is required to perform an access to PCI config space . Interpreter should be unlocked because we may run the _REG method for this region . Possible incompliance : There is a behavior conflict in automatic _REG execution : 1 . When the interpreter is evaluating a method we can only automatically run _REG for the following case : Method ( _REG 2 ) {} OperationRegion ( OPR1 0x80 0x1000010 0x4 ) 2 . When the interpreter is loading a table we can also automatically run _REG for the following case : OperationRegion ( OPR1 0x80 0x1000010 0x4 ) Method ( _REG 2 ) {} Though this may not be compliant to the de - facto standard the logic is kept in order not to trigger regressions . And keeping this logic should be taken care by the caller of this function .
ACPI_STATUS
AcpiEvInitializeRegion (
    ACPI_OPERAND_OBJECT     *RegionObj)
{
    ACPI_OPERAND_OBJECT     *HandlerObj;
    ACPI_OPERAND_OBJECT     *ObjDesc;
    ACPI_ADR_SPACE_TYPE     SpaceId;
    ACPI_NAMESPACE_NODE     *Node;
    ACPI_FUNCTION_TRACE (EvInitializeRegion);
    if (!RegionObj)
    {
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }
    if (RegionObj->Common.Flags & AOPOBJ_OBJECT_INITIALIZED)
    {
        return_ACPI_STATUS (AE_OK);
    }
    RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED;
    Node = RegionObj->Region.Node->Parent;
    SpaceId = RegionObj->Region.SpaceId;
    while (Node)
    {
        HandlerObj = NULL;
        ObjDesc = AcpiNsGetAttachedObject (Node);
        if (ObjDesc)
        {
            switch (Node->Type)
            {
            case ACPI_TYPE_DEVICE:
            case ACPI_TYPE_PROCESSOR:
            case ACPI_TYPE_THERMAL:
                HandlerObj = ObjDesc->CommonNotify.Handler;
                break;
            case ACPI_TYPE_METHOD:
                if (!AcpiGbl_ParseTableAsTermList &&
                    ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL)
                {
                    HandlerObj = ObjDesc->Method.Dispatch.Handler;
                }
                break;
            default:
                break;
            }
            HandlerObj = AcpiEvFindRegionHandler (SpaceId, HandlerObj);
            if (HandlerObj)
            {
                ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
                    "Found handler %p for region %p in obj %p\n",
                    HandlerObj, RegionObj, ObjDesc));
                (void) AcpiEvAttachRegion (HandlerObj, RegionObj, FALSE);
                AcpiExExitInterpreter ();
                (void) AcpiEvExecuteRegMethod (RegionObj, ACPI_REG_CONNECT);
                AcpiExEnterInterpreter ();
                return_ACPI_STATUS (AE_OK);
            }
        }
        Node = Node->Parent;
    }
    ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
        "No handler for RegionType %s(%X) (RegionObj %p)\n",
        AcpiUtGetRegionName (SpaceId), SpaceId, RegionObj));
    return_ACPI_STATUS (AE_OK);
}
ACPI_STATUS AcpiEvInitializeRegion ( ACPI_OPERAND_OBJECT * RegionObj ) { ACPI_OPERAND_OBJECT * HandlerObj ; ACPI_OPERAND_OBJECT * ObjDesc ; ACPI_ADR_SPACE_TYPE SpaceId ; ACPI_NAMESPACE_NODE * Node ; ACPI_FUNCTION_TRACE ( EvInitializeRegion ) ; if ( ! RegionObj ) { return_ACPI_STATUS ( AE_BAD_PARAMETER ) ; } if ( RegionObj -> Common . Flags & AOPOBJ_OBJECT_INITIALIZED ) { return_ACPI_STATUS ( AE_OK ) ; } RegionObj -> Common . Flags |= AOPOBJ_OBJECT_INITIALIZED ; Node = RegionObj -> Region . Node -> Parent ; SpaceId = RegionObj -> Region . SpaceId ; while ( Node ) { HandlerObj = NULL ; ObjDesc = AcpiNsGetAttachedObject ( Node ) ; if ( ObjDesc ) { switch ( Node -> Type ) { case ACPI_TYPE_DEVICE : case ACPI_TYPE_PROCESSOR : case ACPI_TYPE_THERMAL : HandlerObj = ObjDesc -> CommonNotify . Handler ; break ; case ACPI_TYPE_METHOD : if ( ! AcpiGbl_ParseTableAsTermList && ObjDesc -> Method . InfoFlags & ACPI_METHOD_MODULE_LEVEL ) { HandlerObj = ObjDesc -> Method . Dispatch . Handler ; } break ; default : break ; } HandlerObj = AcpiEvFindRegionHandler ( SpaceId , HandlerObj ) ; if ( HandlerObj ) { ACPI_DEBUG_PRINT ( ( ACPI_DB_OPREGION , " \n " , HandlerObj , RegionObj , ObjDesc ) ) ; ( void ) AcpiEvAttachRegion ( HandlerObj , RegionObj , FALSE ) ; AcpiExExitInterpreter ( ) ; ( void ) AcpiEvExecuteRegMethod ( RegionObj , ACPI_REG_CONNECT ) ; AcpiExEnterInterpreter ( ) ; return_ACPI_STATUS ( AE_OK ) ; } } Node = Node -> Parent ; } ACPI_DEBUG_PRINT ( ( ACPI_DB_OPREGION , " \n " , AcpiUtGetRegionName ( SpaceId ) , SpaceId , RegionObj ) ) ; return_ACPI_STATUS ( AE_OK ) ; }
FUNCTION:    AcpiEvInitializeRegion
 PARAMETERS:  RegionObj       - Region we are initializing
FUNCTION : AcpiEvInitializeRegion PARAMETERS : RegionObj - Region we are initializing
/*
     * The following loop depends upon the root Node having no parent
     * ie: AcpiGbl_RootNode->Parent being set to NULL
     */ /* Check to see if a handler exists */ /* Can only be a handler if the object exists */ /*
                 * If we are executing module level code, the original
                 * Node's object was replaced by this Method object and we
                 * saved the handler in the method object.
                 *
                 * See AcpiNsExecModuleCode
                 */ /* Ignore other objects */ /* Found correct handler */ /*
                 * Tell all users that this region is usable by
                 * running the _REG method
                 */ /* This node does not have the handler we need; Pop up one level */ /*
     * If we get here, there is no handler for this region. This is not
     * fatal because many regions get created before a handler is installed
     * for said region.
     */