summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/compiler/aslopt.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/compiler/aslopt.c')
-rw-r--r--sys/contrib/dev/acpica/compiler/aslopt.c111
1 files changed, 61 insertions, 50 deletions
diff --git a/sys/contrib/dev/acpica/compiler/aslopt.c b/sys/contrib/dev/acpica/compiler/aslopt.c
index 1079f9c..9c26d27 100644
--- a/sys/contrib/dev/acpica/compiler/aslopt.c
+++ b/sys/contrib/dev/acpica/compiler/aslopt.c
@@ -5,7 +5,7 @@
*****************************************************************************/
/*
- * Copyright (C) 2000 - 2015, Intel Corp.
+ * Copyright (C) 2000 - 2016, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -53,7 +53,7 @@
ACPI_MODULE_NAME ("aslopt")
-static UINT32 OptTotal = 0;
+static UINT32 OptTotal = 0;
/* Local prototypes */
@@ -132,15 +132,15 @@ OptSearchToRoot (
* name in the search path before the one we want, the nodes will
* not match, and we cannot use this optimization.
*/
- Path = &(((char *) TargetPath->Pointer)[TargetPath->Length -
- ACPI_NAME_SIZE]),
+ Path = &(((char *) TargetPath->Pointer)[
+ TargetPath->Length - ACPI_NAME_SIZE]),
ScopeInfo.Scope.Node = CurrentNode;
/* Lookup the NameSeg using SEARCH_PARENT (search-to-root) */
Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
- ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
- WalkState, &(Node));
+ ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
+ WalkState, &(Node));
if (ACPI_FAILURE (Status))
{
return (Status);
@@ -168,12 +168,12 @@ OptSearchToRoot (
/* We must allocate a new string for the name (TargetPath gets deleted) */
*NewPath = UtStringCacheCalloc (ACPI_NAME_SIZE + 1);
- ACPI_STRCPY (*NewPath, Path);
+ strcpy (*NewPath, Path);
- if (ACPI_STRNCMP (*NewPath, "_T_", 3))
+ if (strncmp (*NewPath, "_T_", 3))
{
- AslError (ASL_OPTIMIZATION, ASL_MSG_SINGLE_NAME_OPTIMIZATION, Op,
- *NewPath);
+ AslError (ASL_OPTIMIZATION, ASL_MSG_SINGLE_NAME_OPTIMIZATION,
+ Op, *NewPath);
}
return (AE_OK);
@@ -217,7 +217,7 @@ OptBuildShortestPath (
UINT32 Index;
UINT32 NumCarats;
UINT32 i;
- char *NewPath;
+ char *NewPathInternal;
char *NewPathExternal;
ACPI_NAMESPACE_NODE *Node;
ACPI_GENERIC_STATE ScopeInfo;
@@ -253,11 +253,11 @@ OptBuildShortestPath (
{
/* Compare two single NameSegs */
+ Index = (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1;
+
if (!ACPI_COMPARE_NAME (
- &((char *) TargetPath->Pointer)[
- (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1],
- &((char *) CurrentPath->Pointer)[
- (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1]))
+ &(ACPI_CAST_PTR (char, TargetPath->Pointer)) [Index],
+ &(ACPI_CAST_PTR (char, CurrentPath->Pointer)) [Index]))
{
/* Mismatch */
@@ -292,13 +292,13 @@ OptBuildShortestPath (
/* Determine how many prefix Carats are required */
NumCarats = (CurrentPath->Length / ACPI_PATH_SEGMENT_LENGTH) -
- NumCommonSegments;
+ NumCommonSegments;
/*
* Construct a new target string
*/
- NewPathExternal = ACPI_ALLOCATE_ZEROED (
- TargetPath->Length + NumCarats + 1);
+ NewPathExternal =
+ ACPI_ALLOCATE_ZEROED (TargetPath->Length + NumCarats + 1);
/* Insert the Carats into the Target string */
@@ -315,7 +315,8 @@ OptBuildShortestPath (
/* Special handling for exact subpath in a name declaration */
- if (IsDeclaration && SubPath && (CurrentPath->Length > TargetPath->Length))
+ if (IsDeclaration && SubPath &&
+ (CurrentPath->Length > TargetPath->Length))
{
/*
* The current path is longer than the target, and the target is a
@@ -341,7 +342,8 @@ OptBuildShortestPath (
Index = TargetPath->Length;
}
- ACPI_STRCPY (&NewPathExternal[i], &((char *) TargetPath->Pointer)[Index]);
+ strcpy (&NewPathExternal[i],
+ &(ACPI_CAST_PTR (char, TargetPath->Pointer))[Index]);
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " %-24s", NewPathExternal));
/*
@@ -349,22 +351,24 @@ OptBuildShortestPath (
* string to make sure that this is in fact an optimization. If the
* original string is already optimal, there is no point in continuing.
*/
- Status = AcpiNsInternalizeName (NewPathExternal, &NewPath);
+ Status = AcpiNsInternalizeName (NewPathExternal, &NewPathInternal);
if (ACPI_FAILURE (Status))
{
AslCoreSubsystemError (Op, Status, "Internalizing new NamePath",
ASL_NO_ABORT);
- ACPI_FREE (NewPathExternal);
- return (Status);
+ goto Cleanup;
}
- if (ACPI_STRLEN (NewPath) >= AmlNameStringLength)
+ if (strlen (NewPathInternal) >= AmlNameStringLength)
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
" NOT SHORTER (New %u old %u)",
- (UINT32) ACPI_STRLEN (NewPath), (UINT32) AmlNameStringLength));
- ACPI_FREE (NewPathExternal);
- return (AE_NOT_FOUND);
+ (UINT32) strlen (NewPathInternal),
+ (UINT32) AmlNameStringLength));
+
+ ACPI_FREE (NewPathInternal);
+ Status = AE_NOT_FOUND;
+ goto Cleanup;
}
/*
@@ -372,9 +376,9 @@ OptBuildShortestPath (
* looking for. This is simply a sanity check on the new
* path that has been created.
*/
- Status = AcpiNsLookup (&ScopeInfo, NewPath,
- ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
- ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node));
+ Status = AcpiNsLookup (&ScopeInfo, NewPathInternal,
+ ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+ ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node));
if (ACPI_SUCCESS (Status))
{
/* Found the namepath, but make sure the node is correct */
@@ -385,7 +389,7 @@ OptBuildShortestPath (
AslError (ASL_OPTIMIZATION, ASL_MSG_NAME_OPTIMIZATION,
Op, NewPathExternal);
- *ReturnNewPath = NewPath;
+ *ReturnNewPath = NewPathInternal;
}
else
{
@@ -401,11 +405,15 @@ OptBuildShortestPath (
{
/* The lookup failed, we obviously cannot use this optimization */
+ ACPI_FREE (NewPathInternal);
+
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** NOT FOUND"));
AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
"Not using optimized name - did not find node");
}
+Cleanup:
+
ACPI_FREE (NewPathExternal);
return (Status);
}
@@ -446,7 +454,7 @@ OptOptimizeNameDeclaration (
if (((CurrentNode == AcpiGbl_RootNode) ||
- (Op->Common.Parent->Asl.ParseOpcode == PARSEOP_DEFINITIONBLOCK)) &&
+ (Op->Common.Parent->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK)) &&
(ACPI_IS_ROOT_PREFIX (AmlNameString[0])))
{
/*
@@ -458,7 +466,7 @@ OptOptimizeNameDeclaration (
/* Debug output */
Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, *NewPath,
- NULL, &NewPathExternal);
+ NULL, &NewPathExternal);
if (ACPI_FAILURE (Status))
{
AslCoreSubsystemError (Op, Status, "Externalizing NamePath",
@@ -474,8 +482,8 @@ OptOptimizeNameDeclaration (
* We know that we are at the root, so NULL is used for the scope.
*/
Status = AcpiNsLookup (NULL, *NewPath,
- ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
- ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node));
+ ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+ ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node));
if (ACPI_SUCCESS (Status))
{
/* Found the namepath, but make sure the node is correct */
@@ -597,7 +605,7 @@ OptOptimizeNamePath (
* The original path must be longer than one NameSeg (4 chars) for there
* to be any possibility that it can be optimized to a shorter string
*/
- AmlNameStringLength = ACPI_STRLEN (AmlNameString);
+ AmlNameStringLength = strlen (AmlNameString);
if (AmlNameStringLength <= ACPI_NAME_SIZE)
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
@@ -633,6 +641,7 @@ OptOptimizeNamePath (
{
NextOp = NextOp->Asl.Parent;
}
+
if (NextOp && NextOp->Asl.Node)
{
CurrentNode = NextOp->Asl.Node;
@@ -655,31 +664,33 @@ OptOptimizeNamePath (
* format -- something we can easily manipulate
*/
TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
- Status = AcpiNsHandleToPathname (TargetNode, &TargetPath);
+ Status = AcpiNsHandleToPathname (TargetNode, &TargetPath, FALSE);
if (ACPI_FAILURE (Status))
{
AslCoreSubsystemError (Op, Status, "Getting Target NamePath",
ASL_NO_ABORT);
return_VOID;
}
+
TargetPath.Length--; /* Subtract one for null terminator */
/* CurrentPath is the path to this scope (where we are in the namespace) */
CurrentPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
- Status = AcpiNsHandleToPathname (CurrentNode, &CurrentPath);
+ Status = AcpiNsHandleToPathname (CurrentNode, &CurrentPath, FALSE);
if (ACPI_FAILURE (Status))
{
AslCoreSubsystemError (Op, Status, "Getting Current NamePath",
ASL_NO_ABORT);
return_VOID;
}
+
CurrentPath.Length--; /* Subtract one for null terminator */
/* Debug output only */
Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, AmlNameString,
- NULL, &ExternalNameString);
+ NULL, &ExternalNameString);
if (ACPI_FAILURE (Status))
{
AslCoreSubsystemError (Op, Status, "Externalizing NamePath",
@@ -705,7 +716,7 @@ OptOptimizeNamePath (
* a reference.
*/
Status = OptOptimizeNameDeclaration (Op, WalkState, CurrentNode,
- TargetNode, AmlNameString, &NewPath);
+ TargetNode, AmlNameString, &NewPath);
if (ACPI_FAILURE (Status))
{
/*
@@ -713,8 +724,8 @@ OptOptimizeNamePath (
* optimize the namestring with carats (up-arrow)
*/
Status = OptBuildShortestPath (Op, WalkState, CurrentNode,
- TargetNode, &CurrentPath, &TargetPath,
- AmlNameStringLength, 1, &NewPath);
+ TargetNode, &CurrentPath, &TargetPath,
+ AmlNameStringLength, 1, &NewPath);
}
}
else
@@ -726,7 +737,7 @@ OptOptimizeNamePath (
* NameSeg of the NamePath
*/
Status = OptSearchToRoot (Op, WalkState, CurrentNode,
- TargetNode, &TargetPath, &NewPath);
+ TargetNode, &TargetPath, &NewPath);
if (ACPI_FAILURE (Status))
{
/*
@@ -734,8 +745,8 @@ OptOptimizeNamePath (
* optimize the namestring with carats (up-arrow)
*/
Status = OptBuildShortestPath (Op, WalkState, CurrentNode,
- TargetNode, &CurrentPath, &TargetPath,
- AmlNameStringLength, 0, &NewPath);
+ TargetNode, &CurrentPath, &TargetPath,
+ AmlNameStringLength, 0, &NewPath);
}
}
@@ -745,7 +756,7 @@ OptOptimizeNamePath (
*/
if (ACPI_SUCCESS (Status))
{
- HowMuchShorter = (AmlNameStringLength - ACPI_STRLEN (NewPath));
+ HowMuchShorter = (AmlNameStringLength - strlen (NewPath));
OptTotal += HowMuchShorter;
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
@@ -761,12 +772,12 @@ OptOptimizeNamePath (
* (alias name) is the second operand
*/
Op->Asl.Child->Asl.Next->Asl.Value.String = NewPath;
- Op->Asl.Child->Asl.Next->Asl.AmlLength = ACPI_STRLEN (NewPath);
+ Op->Asl.Child->Asl.Next->Asl.AmlLength = strlen (NewPath);
}
else
{
Op->Asl.Child->Asl.Value.String = NewPath;
- Op->Asl.Child->Asl.AmlLength = ACPI_STRLEN (NewPath);
+ Op->Asl.Child->Asl.AmlLength = strlen (NewPath);
}
}
else if (Flags & AML_CREATE)
@@ -781,14 +792,14 @@ OptOptimizeNamePath (
/* Update the parse node with the new NamePath */
NextOp->Asl.Value.String = NewPath;
- NextOp->Asl.AmlLength = ACPI_STRLEN (NewPath);
+ NextOp->Asl.AmlLength = strlen (NewPath);
}
else
{
/* Update the parse node with the new NamePath */
Op->Asl.Value.String = NewPath;
- Op->Asl.AmlLength = ACPI_STRLEN (NewPath);
+ Op->Asl.AmlLength = strlen (NewPath);
}
}
else
OpenPOWER on IntegriCloud