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.c124
1 files changed, 91 insertions, 33 deletions
diff --git a/sys/contrib/dev/acpica/compiler/aslopt.c b/sys/contrib/dev/acpica/compiler/aslopt.c
index f0416d8..e406abb 100644
--- a/sys/contrib/dev/acpica/compiler/aslopt.c
+++ b/sys/contrib/dev/acpica/compiler/aslopt.c
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: aslopt- Compiler optimizations
- * $Revision: 16 $
+ * $Revision: 1.21 $
*
*****************************************************************************/
@@ -9,7 +9,7 @@
*
* 1. Copyright Notice
*
- * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
+ * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
* All rights reserved.
*
* 2. License
@@ -115,19 +115,51 @@
*****************************************************************************/
-#include "aslcompiler.h"
+#include <contrib/dev/acpica/compiler/aslcompiler.h>
#include "aslcompiler.y.h"
-#include "acparser.h"
-#include "amlcode.h"
-#include "acnamesp.h"
+#include <contrib/dev/acpica/acparser.h>
+#include <contrib/dev/acpica/amlcode.h>
+#include <contrib/dev/acpica/acnamesp.h>
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslopt")
-UINT32 OptTotal = 0;
+static UINT32 OptTotal = 0;
+
+/* Local prototypes */
+
+static ACPI_STATUS
+OptSearchToRoot (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_NAMESPACE_NODE *CurrentNode,
+ ACPI_NAMESPACE_NODE *TargetNode,
+ ACPI_BUFFER *TargetPath,
+ char **NewPath);
+
+static ACPI_STATUS
+OptBuildShortestPath (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_NAMESPACE_NODE *CurrentNode,
+ ACPI_NAMESPACE_NODE *TargetNode,
+ ACPI_BUFFER *CurrentPath,
+ ACPI_BUFFER *TargetPath,
+ ACPI_SIZE AmlNameStringLength,
+ UINT8 IsDeclaration,
+ char **ReturnNewPath);
+
+static ACPI_STATUS
+OptOptimizeNameDeclaration (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_NAMESPACE_NODE *CurrentNode,
+ ACPI_NAMESPACE_NODE *TargetNode,
+ char *AmlNameString,
+ char **NewPath);
/*******************************************************************************
@@ -149,7 +181,7 @@ UINT32 OptTotal = 0;
*
******************************************************************************/
-ACPI_STATUS
+static ACPI_STATUS
OptSearchToRoot (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState,
@@ -174,7 +206,8 @@ 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) */
@@ -241,7 +274,7 @@ OptSearchToRoot (
*
******************************************************************************/
-ACPI_STATUS
+static ACPI_STATUS
OptBuildShortestPath (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState,
@@ -295,8 +328,10 @@ OptBuildShortestPath (
/* Compare two single NameSegs */
if (ACPI_STRNCMP (
- &((char *) TargetPath->Pointer)[(NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1],
- &((char *) CurrentPath->Pointer)[(NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1],
+ &((char *) TargetPath->Pointer)[(NumCommonSegments *
+ ACPI_PATH_SEGMENT_LENGTH) + 1],
+ &((char *) CurrentPath->Pointer)[(NumCommonSegments *
+ ACPI_PATH_SEGMENT_LENGTH) + 1],
ACPI_NAME_SIZE))
{
/* Mismatch */
@@ -305,7 +340,8 @@ OptBuildShortestPath (
}
}
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " COMMON: %d", NumCommonSegments));
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " COMMON: %d",
+ NumCommonSegments));
/* There must be at least 1 common NameSeg in order to optimize */
@@ -330,12 +366,13 @@ OptBuildShortestPath (
/* Determine how many prefix Carats are required */
- NumCarats = (CurrentPath->Length / ACPI_PATH_SEGMENT_LENGTH) - NumCommonSegments;
+ NumCarats = (CurrentPath->Length / ACPI_PATH_SEGMENT_LENGTH) -
+ NumCommonSegments;
/*
* Construct a new target string
*/
- NewPathExternal = ACPI_MEM_CALLOCATE (TargetPath->Length + NumCarats);
+ NewPathExternal = ACPI_MEM_CALLOCATE (TargetPath->Length + NumCarats + 1);
/* Insert the Carats into the Target string */
@@ -344,8 +381,10 @@ OptBuildShortestPath (
NewPathExternal[i] = '^';
}
- /* Copy only the necessary (optimal) segments from the original target string */
-
+ /*
+ * Copy only the necessary (optimal) segments from the original
+ * target string
+ */
Index = (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1;
/* Special handling for exact subpath in a name declaration */
@@ -353,8 +392,9 @@ OptBuildShortestPath (
if (IsDeclaration && SubPath && (CurrentPath->Length > TargetPath->Length))
{
/*
- * The current path is longer than the target, and the target is a subpath
- * of the current path. We must include one more NameSeg of the target path
+ * The current path is longer than the target, and the target is a
+ * subpath of the current path. We must include one more NameSeg of
+ * the target path
*/
Index -= ACPI_PATH_SEGMENT_LENGTH;
@@ -368,26 +408,36 @@ OptBuildShortestPath (
}
}
+ /* Make sure we haven't gone off the end of the target path */
+
+ if (Index > TargetPath->Length)
+ {
+ Index = TargetPath->Length;
+ }
+
+
ACPI_STRCPY (&NewPathExternal[i], &((char *) TargetPath->Pointer)[Index]);
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " %-24s", NewPathExternal));
/*
- * Internalize the new target string and check it against the original string
- * to make sure that this is in fact an optimization. If the original string
- * is already optimal, there is no point in continuing.
+ * Internalize the new target string and check it against the original
+ * 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);
if (ACPI_FAILURE (Status))
{
- AslCoreSubsystemError (Op, Status, "Internalizing new NamePath", ASL_NO_ABORT);
+ AslCoreSubsystemError (Op, Status, "Internalizing new NamePath",
+ ASL_NO_ABORT);
ACPI_MEM_FREE (NewPathExternal);
return (Status);
}
if (ACPI_STRLEN (NewPath) >= AmlNameStringLength)
{
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " NOT SHORTER (New %d old %d)",
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
+ " NOT SHORTER (New %d old %d)",
ACPI_STRLEN (NewPath), AmlNameStringLength));
ACPI_MEM_FREE (NewPathExternal);
return (AE_NOT_FOUND);
@@ -454,7 +504,7 @@ OptBuildShortestPath (
*
******************************************************************************/
-ACPI_STATUS
+static ACPI_STATUS
OptOptimizeNameDeclaration (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState,
@@ -488,7 +538,8 @@ OptOptimizeNameDeclaration (
NULL, &NewPathExternal);
if (ACPI_FAILURE (Status))
{
- AslCoreSubsystemError (Op, Status, "Externalizing NamePath", ASL_NO_ABORT);
+ AslCoreSubsystemError (Op, Status, "Externalizing NamePath",
+ ASL_NO_ABORT);
return (Status);
}
@@ -520,7 +571,8 @@ OptOptimizeNameDeclaration (
/* Node is not correct, do not use this optimization */
Status = AE_NOT_FOUND;
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** WRONG NODE"));
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
+ " ***** WRONG NODE"));
AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
"Not using optimized name - found wrong node");
}
@@ -529,7 +581,8 @@ OptOptimizeNameDeclaration (
{
/* The lookup failed, we obviously cannot use this optimization */
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** NOT FOUND"));
+ 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");
}
@@ -644,8 +697,10 @@ OptOptimizeNamePath (
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAME"));
- /* The node of interest is the parent of this node (the containing scope) */
-
+ /*
+ * The node of interest is the parent of this node
+ * (the containing scope)
+ */
CurrentNode = Op->Asl.Parent->Asl.Node;
if (!CurrentNode)
{
@@ -668,7 +723,8 @@ OptOptimizeNamePath (
Status = AcpiNsHandleToPathname (TargetNode, &TargetPath);
if (ACPI_FAILURE (Status))
{
- AslCoreSubsystemError (Op, Status, "Getting Target NamePath", ASL_NO_ABORT);
+ AslCoreSubsystemError (Op, Status, "Getting Target NamePath",
+ ASL_NO_ABORT);
return_VOID;
}
TargetPath.Length--; /* Subtract one for null terminator */
@@ -679,7 +735,8 @@ OptOptimizeNamePath (
Status = AcpiNsHandleToPathname (CurrentNode, &CurrentPath);
if (ACPI_FAILURE (Status))
{
- AslCoreSubsystemError (Op, Status, "Getting Current NamePath", ASL_NO_ABORT);
+ AslCoreSubsystemError (Op, Status, "Getting Current NamePath",
+ ASL_NO_ABORT);
return_VOID;
}
CurrentPath.Length--; /* Subtract one for null terminator */
@@ -690,7 +747,8 @@ OptOptimizeNamePath (
NULL, &ExternalNameString);
if (ACPI_FAILURE (Status))
{
- AslCoreSubsystemError (Op, Status, "Externalizing NamePath", ASL_NO_ABORT);
+ AslCoreSubsystemError (Op, Status, "Externalizing NamePath",
+ ASL_NO_ABORT);
return_VOID;
}
OpenPOWER on IntegriCloud