diff --git a/source/components/events/evregion.c b/source/components/events/evregion.c index f2b2f227e6..375651a8be 100644 --- a/source/components/events/evregion.c +++ b/source/components/events/evregion.c @@ -623,6 +623,58 @@ AcpiEvAttachRegion ( } +/******************************************************************************* + * + * FUNCTION: AcpiEvAssociateRegMethod + * + * PARAMETERS: RegionObj - Region object + * + * RETURN: Status + * + * DESCRIPTION: Find and associate _REG method to a region + * + ******************************************************************************/ + +void +AcpiEvAssociateRegMethod ( + ACPI_OPERAND_OBJECT *RegionObj) +{ + ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG; + ACPI_NAMESPACE_NODE *MethodNode; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *RegionObj2; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvAssociateRegMethod); + + + RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); + if (!RegionObj2) + { + return_VOID; + } + + Node = RegionObj->Region.Node->Parent; + + /* Find any "_REG" method associated with this region definition */ + + Status = AcpiNsSearchOneScope ( + *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode); + if (ACPI_SUCCESS (Status)) + { + /* + * The _REG method is optional and there can be only one per region + * definition. This will be executed when the handler is attached + * or removed + */ + RegionObj2->Extra.Method_REG = MethodNode; + } + + return_VOID; +} + + /******************************************************************************* * * FUNCTION: AcpiEvExecuteRegMethod diff --git a/source/components/events/evrgnini.c b/source/components/events/evrgnini.c index c935526871..63479e749c 100644 --- a/source/components/events/evrgnini.c +++ b/source/components/events/evrgnini.c @@ -639,9 +639,6 @@ AcpiEvInitializeRegion ( ACPI_ADR_SPACE_TYPE SpaceId; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *MethodNode; - ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG; - ACPI_OPERAND_OBJECT *RegionObj2; ACPI_FUNCTION_TRACE_U32 (EvInitializeRegion, AcpiNsLocked); @@ -657,36 +654,12 @@ AcpiEvInitializeRegion ( return_ACPI_STATUS (AE_OK); } - RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); - if (!RegionObj2) - { - return_ACPI_STATUS (AE_NOT_EXIST); - } + AcpiEvAssociateRegMethod (RegionObj); + RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED; Node = RegionObj->Region.Node->Parent; SpaceId = RegionObj->Region.SpaceId; - /* Setup defaults */ - - RegionObj->Region.Handler = NULL; - RegionObj2->Extra.Method_REG = NULL; - RegionObj->Common.Flags &= ~(AOPOBJ_SETUP_COMPLETE); - RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED; - - /* Find any "_REG" method associated with this region definition */ - - Status = AcpiNsSearchOneScope ( - *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode); - if (ACPI_SUCCESS (Status)) - { - /* - * The _REG method is optional and there can be only one per region - * definition. This will be executed when the handler is attached - * or removed - */ - RegionObj2->Extra.Method_REG = MethodNode; - } - /* * The following loop depends upon the root Node having no parent * ie: AcpiGbl_RootNode->Parent being set to NULL diff --git a/source/components/executer/excreate.c b/source/components/executer/excreate.c index fc369564f3..ac99e77e3d 100644 --- a/source/components/executer/excreate.c +++ b/source/components/executer/excreate.c @@ -423,9 +423,10 @@ AcpiExCreateRegion ( * Remember location in AML stream of address & length * operands since they need to be evaluated at run time. */ - RegionObj2 = ObjDesc->Common.NextObject; + RegionObj2 = AcpiNsGetSecondaryObject (ObjDesc); RegionObj2->Extra.AmlStart = AmlStart; RegionObj2->Extra.AmlLength = AmlLength; + RegionObj2->Extra.Method_REG = NULL; if (WalkState->ScopeInfo) { RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node; @@ -441,6 +442,9 @@ AcpiExCreateRegion ( ObjDesc->Region.Address = 0; ObjDesc->Region.Length = 0; ObjDesc->Region.Node = Node; + ObjDesc->Region.Handler = NULL; + ObjDesc->Common.Flags &= + ~(AOPOBJ_SETUP_COMPLETE | AOPOBJ_OBJECT_INITIALIZED); /* Install the new region object in the parent Node */ diff --git a/source/include/acevents.h b/source/include/acevents.h index 2b034c6753..b26e9df0c6 100644 --- a/source/include/acevents.h +++ b/source/include/acevents.h @@ -344,6 +344,10 @@ AcpiEvDetachRegion ( ACPI_OPERAND_OBJECT *RegionObj, BOOLEAN AcpiNsIsLocked); +void +AcpiEvAssociateRegMethod ( + ACPI_OPERAND_OBJECT *RegionObj); + ACPI_STATUS AcpiEvExecuteRegMethods ( ACPI_NAMESPACE_NODE *Node,