aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/dev/acpica/compiler/asltransform.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/compiler/asltransform.c')
-rw-r--r--sys/contrib/dev/acpica/compiler/asltransform.c75
1 files changed, 49 insertions, 26 deletions
diff --git a/sys/contrib/dev/acpica/compiler/asltransform.c b/sys/contrib/dev/acpica/compiler/asltransform.c
index 9ff4925f26c7..b76a26675426 100644
--- a/sys/contrib/dev/acpica/compiler/asltransform.c
+++ b/sys/contrib/dev/acpica/compiler/asltransform.c
@@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: asltransform - Parse tree transforms
- * $Revision: 1.35 $
+ * $Revision: 1.42 $
*
*****************************************************************************/
@@ -10,7 +10,7 @@
*
* 1. Copyright Notice
*
- * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
+ * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp.
* All rights reserved.
*
* 2. License
@@ -429,7 +429,7 @@ TrDoDefinitionBlock (
* to be at the root of the namespace; Therefore, namepath
* optimization can only be performed on the DSDT.
*/
- if (ACPI_STRNCMP (Next->Asl.Value.String, "DSDT", 4))
+ if (!ACPI_COMPARE_NAME (Next->Asl.Value.String, ACPI_SIG_DSDT))
{
Gbl_ReferenceOptimizationFlag = FALSE;
}
@@ -661,15 +661,16 @@ TrDoSwitch (
{
/*
* More than one Default
- * (Parser should catch this, should not get here)
+ * (Parser does not catch this, must check here)
*/
- AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Next,
- "Found more than one Default()");
+ AslError (ASL_ERROR, ASL_MSG_MULTIPLE_DEFAULT, Next, NULL);
}
+ else
+ {
+ /* Save the DEFAULT node for later, after CASEs */
- /* Save the DEFAULT node for later, after CASEs */
-
- DefaultOp = Next;
+ DefaultOp = Next;
+ }
}
else
{
@@ -708,28 +709,55 @@ TrDoSwitch (
AslError (ASL_ERROR, ASL_MSG_NO_CASES, StartNode, NULL);
}
+
/*
- * Add a NAME node for the temp integer:
- * Change the SWITCH node to a Name (_T_x, Type)
+ * Create a Name(_T_x, ...) statement. This statement must appear at the
+ * method level, in case a loop surrounds the switch statement and could
+ * cause the name to be created twice (error).
*/
+
+ /* Create the Name node */
+
Predicate = StartNode->Asl.Child;
- TrAmlInitNode (StartNode, PARSEOP_NAME);
+ NewOp = TrCreateLeafNode (PARSEOP_NAME);
- NewOp = StartNode;
+ /* Find the parent method */
+
+ Next = StartNode;
+ while ((Next->Asl.ParseOpcode != PARSEOP_METHOD) &&
+ (Next->Asl.ParseOpcode != PARSEOP_DEFINITIONBLOCK))
+ {
+ Next = Next->Asl.Parent;
+ }
NewOp->Asl.CompileFlags |= NODE_COMPILER_EMITTED;
+ NewOp->Asl.Parent = Next;
+
+ /* Insert name after the method name and arguments */
+
+ Next = Next->Asl.Child;
+ Next = Next->Asl.Next;
+ Next = Next->Asl.Next;
+ Next = Next->Asl.Next;
+ Next = Next->Asl.Next;
+ Next = Next->Asl.Next;
+
+ TrAmlInsertPeer (Next, NewOp);
+ TrAmlInitLineNumbers (NewOp, Next);
+
+ /* Create the NameSeg child for the Name node */
NewOp2 = TrCreateValuedLeafNode (PARSEOP_NAMESEG,
(ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName));
NewOp2->Asl.CompileFlags |= NODE_IS_NAME_DECLARATION;
NewOp->Asl.Child = NewOp2;
- /* Btype was already validated above */
+ /* Create the initial value for the Name. Btype was already validated above */
switch (Btype)
{
case ACPI_BTYPE_INTEGER:
- NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_ZERO,
+ NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_ZERO,
(ACPI_INTEGER) 0);
break;
@@ -757,26 +785,21 @@ TrDoSwitch (
TrAmlSetSubtreeParent (NewOp2, NewOp);
/*
- * Create and insert a new Store() node which will be used to save the
+ * Transform the Switch() into a Store() node which will be used to save the
* Switch() value. The store is of the form: Store (Value, _T_x)
* where _T_x is the temp variable.
*/
- Next = TrCreateLeafNode (PARSEOP_STORE);
- TrAmlInsertPeer (StartNode, Next);
- TrAmlSetSubtreeParent (Next, StartNode->Asl.Parent);
-
- TrAmlInitLineNumbers (Next, StartNode);
- TrAmlInitLineNumbers (NewOp2, StartNode);
- TrAmlInitLineNumbers (NewOp2->Asl.Next, StartNode);
+ TrAmlInitNode (StartNode, PARSEOP_STORE);
+ StartNode->Asl.Child = NULL;
/* Complete the Store subtree */
- Next->Asl.Child = Predicate;
- Predicate->Asl.Parent = Next;
+ StartNode->Asl.Child = Predicate;
+ Predicate->Asl.Parent = StartNode;
NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESEG,
(ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName));
- NewOp->Asl.Parent = Next;
+ NewOp->Asl.Parent = StartNode;
Predicate->Asl.Next = NewOp;
}