Skip to content

Commit

Permalink
Namespace: Add support to allow overriding objects.
Browse files Browse the repository at this point in the history
This patch adds an "NamespaceOverride" flag in ACPI_WALK_STATE, and allows
namespace objects to be overridden when this flag is set. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
  • Loading branch information
Lv Zheng committed Jun 1, 2015
1 parent 6005294 commit 6084e34
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 7 deletions.
15 changes: 12 additions & 3 deletions source/components/dispatcher/dswload.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,18 @@ AcpiDsLoad1BeginOp (
if ((WalkState->Opcode != AML_SCOPE_OP) &&
(!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP)))
{
Flags |= ACPI_NS_ERROR_IF_FOUND;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n",
AcpiUtGetTypeName (ObjectType)));
if (WalkState->NamespaceOverride)
{
Flags |= ACPI_NS_OVERRIDE_IF_FOUND;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Override allowed\n",
AcpiUtGetTypeName (ObjectType)));
}
else
{
Flags |= ACPI_NS_ERROR_IF_FOUND;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n",
AcpiUtGetTypeName (ObjectType)));
}
}
else
{
Expand Down
11 changes: 10 additions & 1 deletion source/components/namespace/nsaccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,9 @@ AcpiNsLookup (
return_ACPI_STATUS (AE_BAD_PARAMETER);
}

LocalFlags = Flags & ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_SEARCH_PARENT);
LocalFlags = Flags &
~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_OVERRIDE_IF_FOUND |
ACPI_NS_SEARCH_PARENT);
*ReturnNode = ACPI_ENTRY_NOT_FOUND;
AcpiGbl_NsLookupCount++;

Expand Down Expand Up @@ -643,6 +645,13 @@ AcpiNsLookup (
{
LocalFlags |= ACPI_NS_ERROR_IF_FOUND;
}

/* Set override flag according to caller */

if (Flags & ACPI_NS_OVERRIDE_IF_FOUND)
{
LocalFlags |= ACPI_NS_OVERRIDE_IF_FOUND;
}
}

/* Extract one ACPI name from the front of the pathname */
Expand Down
24 changes: 21 additions & 3 deletions source/components/namespace/nssearch.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,28 @@ AcpiNsSearchAndEnter (
* If we found it AND the request specifies that a find is an error,
* return the error
*/
if ((Status == AE_OK) &&
(Flags & ACPI_NS_ERROR_IF_FOUND))
if (Status == AE_OK)
{
Status = AE_ALREADY_EXISTS;
/* The node was found in the namespace */

/*
* If the namespace override feature is enabled for this node,
* delete any existing node. This can only happen during the
* boot stage, thus it is safe to remove the node here.
*/
if (Flags & ACPI_NS_OVERRIDE_IF_FOUND)
{
AcpiNsDeleteChildren (*ReturnNode);
AcpiNsRemoveNode (*ReturnNode);
*ReturnNode = ACPI_ENTRY_NOT_FOUND;
}

/* Return an error if we don't expect to find the object */

else if (Flags & ACPI_NS_ERROR_IF_FOUND)
{
Status = AE_ALREADY_EXISTS;
}
}

#ifdef ACPI_ASL_COMPILER
Expand Down
1 change: 1 addition & 0 deletions source/include/acnamesp.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
#define ACPI_NS_PREFIX_IS_SCOPE 0x10
#define ACPI_NS_EXTERNAL 0x20
#define ACPI_NS_TEMPORARY 0x40
#define ACPI_NS_OVERRIDE_IF_FOUND 0x80

/* Flags for AcpiNsWalkNamespace */

Expand Down
1 change: 1 addition & 0 deletions source/include/acstruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ typedef struct acpi_walk_state
UINT8 ReturnUsed;
UINT8 ScopeDepth;
UINT8 PassNumber; /* Parse pass during table load */
BOOLEAN NamespaceOverride; /* Override existing objects */
UINT8 ResultSize; /* Total elements for the result stack */
UINT8 ResultCount; /* Current number of occupied elements of result stack */
UINT32 AmlOffset;
Expand Down

0 comments on commit 6084e34

Please sign in to comment.