Skip to content

Commit

Permalink
Events: Split AcpiEvAssociateRegMethod() from region initialization code
Browse files Browse the repository at this point in the history
This patch introduces a new region initialization function
AcpiEvAssociateRegMethod(), which is invoked to associate the _REG method
to its related region object.

Region object's default value assignments are also sorted by cleaning up
the code using this new function. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
  • Loading branch information
Lv Zheng committed Dec 8, 2015
1 parent 6ebcb24 commit 87c8561
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 30 deletions.
52 changes: 52 additions & 0 deletions source/components/events/evregion.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 2 additions & 29 deletions source/components/events/evrgnini.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion source/components/executer/excreate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */

Expand Down
4 changes: 4 additions & 0 deletions source/include/acevents.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ AcpiEvDetachRegion (
ACPI_OPERAND_OBJECT *RegionObj,
BOOLEAN AcpiNsIsLocked);

void
AcpiEvAssociateRegMethod (
ACPI_OPERAND_OBJECT *RegionObj);

ACPI_STATUS
AcpiEvExecuteRegMethods (
ACPI_NAMESPACE_NODE *Node,
Expand Down

0 comments on commit 87c8561

Please sign in to comment.