summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/compiler/aslanalyze.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/compiler/aslanalyze.c')
-rw-r--r--sys/contrib/dev/acpica/compiler/aslanalyze.c323
1 files changed, 208 insertions, 115 deletions
diff --git a/sys/contrib/dev/acpica/compiler/aslanalyze.c b/sys/contrib/dev/acpica/compiler/aslanalyze.c
index 93bcca1..42f2247 100644
--- a/sys/contrib/dev/acpica/compiler/aslanalyze.c
+++ b/sys/contrib/dev/acpica/compiler/aslanalyze.c
@@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: aslanalyze.c - check for semantic errors
- * $Revision: 84 $
+ * $Revision: 1.96 $
*
*****************************************************************************/
@@ -10,7 +10,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
@@ -116,16 +116,61 @@
*****************************************************************************/
-#include "aslcompiler.h"
+#include <contrib/dev/acpica/compiler/aslcompiler.h>
#include "aslcompiler.y.h"
-#include "acparser.h"
-#include "amlcode.h"
+#include <contrib/dev/acpica/acparser.h>
+#include <contrib/dev/acpica/amlcode.h>
#include <ctype.h>
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslanalyze")
+/* Local prototypes */
+
+static UINT32
+AnMapArgTypeToBtype (
+ UINT32 ArgType);
+
+static UINT32
+AnMapEtypeToBtype (
+ UINT32 Etype);
+
+static void
+AnFormatBtype (
+ char *Buffer,
+ UINT32 Btype);
+
+static UINT32
+AnGetBtype (
+ ACPI_PARSE_OBJECT *Op);
+
+static UINT32
+AnCheckForReservedName (
+ ACPI_PARSE_OBJECT *Op,
+ char *Name);
+
+static void
+AnCheckForReservedMethod (
+ ACPI_PARSE_OBJECT *Op,
+ ASL_METHOD_INFO *MethodInfo);
+
+static UINT32
+AnMapObjTypeToBtype (
+ ACPI_PARSE_OBJECT *Op);
+
+static BOOLEAN
+AnLastStatementIsReturn (
+ ACPI_PARSE_OBJECT *Op);
+
+static void
+AnCheckMethodReturnValue (
+ ACPI_PARSE_OBJECT *Op,
+ const ACPI_OPCODE_INFO *OpInfo,
+ ACPI_PARSE_OBJECT *ArgOp,
+ UINT32 RequiredBtypes,
+ UINT32 ThisNodeBtype);
+
/*******************************************************************************
*
@@ -142,7 +187,7 @@
*
******************************************************************************/
-UINT32
+static UINT32
AnMapArgTypeToBtype (
UINT32 ArgType)
{
@@ -202,9 +247,12 @@ AnMapArgTypeToBtype (
case ARGI_DATAOBJECT:
- /* Buffer, string, package or reference to a Op - Used only by SizeOf operator*/
-
- return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE);
+ /*
+ * Buffer, string, package or reference to a Op -
+ * Used only by SizeOf operator
+ */
+ return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER |
+ ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE);
case ARGI_COMPLEXOBJ:
@@ -218,6 +266,10 @@ AnMapArgTypeToBtype (
case ARGI_REGION_OR_FIELD:
return (ACPI_BTYPE_REGION | ACPI_BTYPE_FIELD_UNIT);
+ case ARGI_DATAREFOBJ:
+ return (ACPI_BTYPE_INTEGER |ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER |
+ ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE);
+
default:
break;
}
@@ -240,9 +292,9 @@ AnMapArgTypeToBtype (
*
******************************************************************************/
-UINT32
+static UINT32
AnMapEtypeToBtype (
- UINT32 Etype)
+ UINT32 Etype)
{
@@ -323,41 +375,6 @@ AnMapEtypeToBtype (
/*******************************************************************************
*
- * FUNCTION: AnMapBtypeToEtype
- *
- * PARAMETERS: Btype - Bitfield of ACPI types
- *
- * RETURN: The Etype corresponding the the Btype
- *
- * DESCRIPTION: Convert a bitfield type to an encoded type
- *
- ******************************************************************************/
-
-UINT32
-AnMapBtypeToEtype (
- UINT32 Btype)
-{
- UINT32 i;
- UINT32 Etype;
-
-
- if (Btype == 0)
- {
- return 0;
- }
-
- Etype = 1;
- for (i = 1; i < Btype; i *= 2)
- {
- Etype++;
- }
-
- return (Etype);
-}
-
-
-/*******************************************************************************
- *
* FUNCTION: AnFormatBtype
*
* PARAMETERS: Btype - Bitfield of ACPI types
@@ -369,13 +386,13 @@ AnMapBtypeToEtype (
*
******************************************************************************/
-void
+static void
AnFormatBtype (
- char *Buffer,
- UINT32 Btype)
+ char *Buffer,
+ UINT32 Btype)
{
- UINT32 Type;
- BOOLEAN First = TRUE;
+ UINT32 Type;
+ BOOLEAN First = TRUE;
*Buffer = 0;
@@ -386,7 +403,7 @@ AnFormatBtype (
return;
}
- for (Type = 1; Type < ACPI_TYPE_EXTERNAL_MAX; Type++)
+ for (Type = 1; Type <= ACPI_TYPE_EXTERNAL_MAX; Type++)
{
if (Btype & 0x00000001)
{
@@ -437,7 +454,7 @@ AnFormatBtype (
*
******************************************************************************/
-UINT32
+static UINT32
AnGetBtype (
ACPI_PARSE_OBJECT *Op)
{
@@ -461,6 +478,10 @@ AnGetBtype (
}
ThisNodeBtype = AnMapEtypeToBtype (Node->Type);
+ if (!ThisNodeBtype)
+ {
+ AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, NULL);
+ }
/*
* Since it was a named reference, enable the
@@ -470,7 +491,7 @@ AnGetBtype (
if (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)
{
- ReferencedNode = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Node->Object);
+ ReferencedNode = Node->Op;
if (!ReferencedNode)
{
printf ("No back ptr to Op: type %X\n", Node->Type);
@@ -509,13 +530,7 @@ AnGetBtype (
*
******************************************************************************/
-#define ACPI_VALID_RESERVED_NAME_MAX 0x80000000
-#define ACPI_NOT_RESERVED_NAME ACPI_UINT32_MAX
-#define ACPI_PREDEFINED_NAME (ACPI_UINT32_MAX - 1)
-#define ACPI_EVENT_RESERVED_NAME (ACPI_UINT32_MAX - 2)
-#define ACPI_COMPILER_RESERVED_NAME (ACPI_UINT32_MAX - 3)
-
-UINT32
+static UINT32
AnCheckForReservedName (
ACPI_PARSE_OBJECT *Op,
char *Name)
@@ -525,7 +540,8 @@ AnCheckForReservedName (
if (Name[0] == 0)
{
- AcpiOsPrintf ("Found a null name, external = %s\n", Op->Asl.ExternalName);
+ AcpiOsPrintf ("Found a null name, external = %s\n",
+ Op->Asl.ExternalName);
}
/* All reserved names are prefixed with a single underscore */
@@ -543,12 +559,14 @@ AnCheckForReservedName (
{
if (ReservedMethods[i].Flags & ASL_RSVD_SCOPE)
{
- AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op, Op->Asl.ExternalName);
+ AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op,
+ Op->Asl.ExternalName);
return (ACPI_PREDEFINED_NAME);
}
else if (ReservedMethods[i].Flags & ASL_RSVD_RESOURCE_NAME)
{
- AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op, Op->Asl.ExternalName);
+ AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op,
+ Op->Asl.ExternalName);
return (ACPI_PREDEFINED_NAME);
}
@@ -599,7 +617,8 @@ AnCheckForReservedName (
* warning, since the entire namespace starting with an underscore is
* reserved by the ACPI spec.
*/
- AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, Op, Op->Asl.ExternalName);
+ AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, Op,
+ Op->Asl.ExternalName);
return (ACPI_NOT_RESERVED_NAME);
}
@@ -619,7 +638,7 @@ AnCheckForReservedName (
*
******************************************************************************/
-void
+static void
AnCheckForReservedMethod (
ACPI_PARSE_OBJECT *Op,
ASL_METHOD_INFO *MethodInfo)
@@ -671,11 +690,13 @@ AnCheckForReservedMethod (
if (MethodInfo->NumArguments > ReservedMethods[Index].NumArguments)
{
- AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, MsgBuffer);
+ AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op,
+ MsgBuffer);
}
else
{
- AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op, MsgBuffer);
+ AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op,
+ MsgBuffer);
}
}
@@ -691,7 +712,19 @@ AnCheckForReservedMethod (
}
-UINT32
+/*******************************************************************************
+ *
+ * FUNCTION: AnMapObjTypeToBtype
+ *
+ * PARAMETERS: Op - A parse node
+ *
+ * RETURN: A Btype
+ *
+ * DESCRIPTION: Map object to the associated "Btype"
+ *
+ ******************************************************************************/
+
+static UINT32
AnMapObjTypeToBtype (
ACPI_PARSE_OBJECT *Op)
{
@@ -780,7 +813,7 @@ AnMethodAnalysisWalkBegin (
ACPI_PARSE_OBJECT *ArgNode;
ACPI_PARSE_OBJECT *NextType;
ACPI_PARSE_OBJECT *NextParamType;
- char ActualArgs = 0;
+ UINT8 ActualArgs = 0;
ACPI_FUNCTION_NAME ("AnMethodAnalysisWalkBegin");
@@ -792,9 +825,8 @@ AnMethodAnalysisWalkBegin (
TotalMethods++;
- /*
- * Create and init method info
- */
+ /* Create and init method info */
+
MethodInfo = UtLocalCalloc (sizeof (ASL_METHOD_INFO));
MethodInfo->Next = WalkInfo->MethodStack;
MethodInfo->Op = Op;
@@ -808,7 +840,8 @@ AnMethodAnalysisWalkBegin (
/* Get the NumArguments node */
Next = Next->Asl.Next;
- MethodInfo->NumArguments = (UINT8) (((UINT8) Next->Asl.Value.Integer) & 0x07);
+ MethodInfo->NumArguments = (UINT8)
+ (((UINT8) Next->Asl.Value.Integer) & 0x07);
/* Get the SerializeRule and SyncLevel nodes, ignored here */
@@ -849,7 +882,8 @@ AnMethodAnalysisWalkBegin (
}
else
{
- MethodInfo->ValidArgTypes[ActualArgs] = AnMapObjTypeToBtype (NextType);
+ MethodInfo->ValidArgTypes[ActualArgs] =
+ AnMapObjTypeToBtype (NextType);
NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
}
@@ -904,8 +938,10 @@ AnMethodAnalysisWalkBegin (
if (!MethodInfo)
{
- /* Probably was an error in the method declaration, no additional error here */
-
+ /*
+ * Probably was an error in the method declaration,
+ * no additional error here
+ */
ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%p, No parent method\n", Op));
return (AE_ERROR);
}
@@ -946,8 +982,10 @@ AnMethodAnalysisWalkBegin (
if (!MethodInfo)
{
- /* Probably was an error in the method declaration, no additional error here */
-
+ /*
+ * Probably was an error in the method declaration,
+ * no additional error here
+ */
ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%p, No parent method\n", Op));
return (AE_ERROR);
}
@@ -989,8 +1027,10 @@ AnMethodAnalysisWalkBegin (
if (!MethodInfo)
{
- /* Probably was an error in the method declaration, no additional error here */
-
+ /*
+ * Probably was an error in the method declaration,
+ * no additional error here
+ */
ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%p, No parent method\n", Op));
return (AE_ERROR);
}
@@ -1031,7 +1071,10 @@ AnMethodAnalysisWalkBegin (
case PARSEOP_STALL:
- if (Op->Asl.Child->Asl.Value.Integer > ACPI_UINT8_MAX)
+ /* We can range check if the argument is an integer */
+
+ if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) &&
+ (Op->Asl.Child->Asl.Value.Integer > ACPI_UINT8_MAX))
{
AslError (ASL_ERROR, ASL_MSG_INVALID_TIME, Op, NULL);
}
@@ -1069,12 +1112,12 @@ AnMethodAnalysisWalkBegin (
* This reserved name must be a control method because
* it must have arguments
*/
- AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, "with arguments");
+ AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op,
+ "with arguments");
}
- /*
- * Typechecking for _HID
- */
+ /* Typechecking for _HID */
+
else if (!ACPI_STRCMP (METHOD_NAME__HID, ReservedMethods[i].Name))
{
/* Examine the second operand to typecheck it */
@@ -1086,7 +1129,8 @@ AnMethodAnalysisWalkBegin (
{
/* _HID must be a string or an integer */
- AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Next, "String or Integer");
+ AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Next,
+ "String or Integer");
}
if (Next->Asl.ParseOpcode == PARSEOP_STRING_LITERAL)
@@ -1100,7 +1144,8 @@ AnMethodAnalysisWalkBegin (
{
if (!isalnum (Next->Asl.Value.String[i]))
{
- AslError (ASL_ERROR, ASL_MSG_ALPHANUMERIC_STRING, Next, Next->Asl.Value.String);
+ AslError (ASL_ERROR, ASL_MSG_ALPHANUMERIC_STRING,
+ Next, Next->Asl.Value.String);
break;
}
}
@@ -1133,7 +1178,7 @@ AnMethodAnalysisWalkBegin (
*
******************************************************************************/
-BOOLEAN
+static BOOLEAN
AnLastStatementIsReturn (
ACPI_PARSE_OBJECT *Op)
{
@@ -1189,7 +1234,8 @@ AnMethodAnalysisWalkEnd (
if (!MethodInfo)
{
printf ("No method info for method! [%s]\n", Op->Asl.Namepath);
- AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, "No method info for this method");
+ AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
+ "No method info for this method");
CmCleanupAndExit ();
return (AE_AML_INTERNAL);
}
@@ -1228,7 +1274,8 @@ AnMethodAnalysisWalkEnd (
if (MethodInfo->NumReturnNoValue &&
MethodInfo->NumReturnWithValue)
{
- AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op, Op->Asl.ExternalName);
+ AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op,
+ Op->Asl.ExternalName);
}
/*
@@ -1266,12 +1313,15 @@ AnMethodAnalysisWalkEnd (
* method is terminated here with the Return() statement.
*/
Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT;
- Op->Asl.ParentMethod = MethodInfo->Op; /* Used in the "typing" pass later */
+
+ /* Used in the "typing" pass later */
+
+ Op->Asl.ParentMethod = MethodInfo->Op;
/*
* If there is a peer node after the return statement, then this
- * node is unreachable code -- i.e., it won't be executed because of the
- * preceeding Return() statement.
+ * node is unreachable code -- i.e., it won't be executed because of
+ * thepreceeding Return() statement.
*/
if (Op->Asl.Next)
{
@@ -1392,12 +1442,12 @@ AnMethodTypingWalkEnd (
(ThisNodeBtype == (ACPI_UINT32_MAX -1)))
{
/*
- * The method is untyped at this time (typically a forward reference).
- * We must recursively type the method here
+ * The method is untyped at this time (typically a forward
+ * reference). We must recursively type the method here
*/
- TrWalkParseTree (ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Op->Asl.Child->Asl.Node->Object),
- ASL_WALK_VISIT_TWICE, AnMethodTypingWalkBegin,
- AnMethodTypingWalkEnd, NULL);
+ TrWalkParseTree (Op->Asl.Child->Asl.Node->Op,
+ ASL_WALK_VISIT_TWICE, AnMethodTypingWalkBegin,
+ AnMethodTypingWalkEnd, NULL);
ThisNodeBtype = AnGetBtype (Op->Asl.Child);
}
@@ -1436,7 +1486,7 @@ AnMethodTypingWalkEnd (
*
******************************************************************************/
-void
+static void
AnCheckMethodReturnValue (
ACPI_PARSE_OBJECT *Op,
const ACPI_OPCODE_INFO *OpInfo,
@@ -1453,26 +1503,23 @@ AnCheckMethodReturnValue (
/* Examine the parent op of this method */
- OwningOp = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Node->Object);
+ OwningOp = Node->Op;
if (OwningOp->Asl.CompileFlags & NODE_METHOD_NO_RETVAL)
{
- /*
- * Method NEVER returns a value
- */
+ /* Method NEVER returns a value */
+
AslError (ASL_ERROR, ASL_MSG_NO_RETVAL, Op, Op->Asl.ExternalName);
}
else if (OwningOp->Asl.CompileFlags & NODE_METHOD_SOME_NO_RETVAL)
{
- /*
- * Method SOMETIMES returns a value, SOMETIMES not
- */
+ /* Method SOMETIMES returns a value, SOMETIMES not */
+
AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL, Op, Op->Asl.ExternalName);
}
else if (!(ThisNodeBtype & RequiredBtypes))
{
- /*
- * Method returns a value, but the type is wrong
- */
+ /* Method returns a value, but the type is wrong */
+
AnFormatBtype (StringBuffer, ThisNodeBtype);
AnFormatBtype (StringBuffer2, RequiredBtypes);
@@ -1485,8 +1532,9 @@ AnCheckMethodReturnValue (
*/
if (ThisNodeBtype != 0)
{
- sprintf (MsgBuffer, "Method returns [%s], %s operator requires [%s]",
- StringBuffer, OpInfo->Name, StringBuffer2);
+ sprintf (MsgBuffer,
+ "Method returns [%s], %s operator requires [%s]",
+ StringBuffer, OpInfo->Name, StringBuffer2);
AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, MsgBuffer);
}
@@ -1502,7 +1550,7 @@ AnCheckMethodReturnValue (
*
* RETURN: Status
*
- * DESCRIPTION: Descending callback for the analysis walk. Check methods for :
+ * DESCRIPTION: Descending callback for the analysis walk. Check methods for:
* 1) Initialized local variables
* 2) Valid arguments
* 3) Return types
@@ -1593,6 +1641,11 @@ AnOperandTypecheckWalkEnd (
if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL)
{
+ if (!ACPI_STRCMP (ArgOp->Asl.ExternalName, "\\_OSI"))
+ {
+ return (AE_OK);
+ }
+
/* The lone arg is a method call, check it */
RequiredBtypes = AnMapArgTypeToBtype (ARGI_INTEGER);
@@ -1606,7 +1659,8 @@ AnOperandTypecheckWalkEnd (
{
return (AE_OK);
}
- AnCheckMethodReturnValue (Op, OpInfo, ArgOp, RequiredBtypes, ThisNodeBtype);
+ AnCheckMethodReturnValue (Op, OpInfo, ArgOp,
+ RequiredBtypes, ThisNodeBtype);
}
return (AE_OK);
@@ -1760,7 +1814,8 @@ AnOperandTypecheckWalkEnd (
{
/* Check a method call for a valid return value */
- AnCheckMethodReturnValue (Op, OpInfo, ArgOp, RequiredBtypes, ThisNodeBtype);
+ AnCheckMethodReturnValue (Op, OpInfo, ArgOp,
+ RequiredBtypes, ThisNodeBtype);
}
/*
@@ -1843,3 +1898,41 @@ AnOtherSemanticAnalysisWalkEnd (
return AE_OK;
}
+
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+/*******************************************************************************
+ *
+ * FUNCTION: AnMapBtypeToEtype
+ *
+ * PARAMETERS: Btype - Bitfield of ACPI types
+ *
+ * RETURN: The Etype corresponding the the Btype
+ *
+ * DESCRIPTION: Convert a bitfield type to an encoded type
+ *
+ ******************************************************************************/
+
+UINT32
+AnMapBtypeToEtype (
+ UINT32 Btype)
+{
+ UINT32 i;
+ UINT32 Etype;
+
+
+ if (Btype == 0)
+ {
+ return 0;
+ }
+
+ Etype = 1;
+ for (i = 1; i < Btype; i *= 2)
+ {
+ Etype++;
+ }
+
+ return (Etype);
+}
+#endif
+
OpenPOWER on IntegriCloud