diff options
author | Jung-uk Kim <jkim@FreeBSD.org> | 2016-09-30 19:46:13 +0000 |
---|---|---|
committer | Jung-uk Kim <jkim@FreeBSD.org> | 2016-09-30 19:46:13 +0000 |
commit | 7600ac2283596bd000a29b9347e95346d3b740d7 (patch) | |
tree | 71816608dca5b2fd7445b5bd4cba161b0b293fe1 /source/components/disassembler/dmopcode.c | |
parent | be99e84498e91a5930864ef7b92b1a7ceb815e44 (diff) |
Notes
Diffstat (limited to 'source/components/disassembler/dmopcode.c')
-rw-r--r-- | source/components/disassembler/dmopcode.c | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/source/components/disassembler/dmopcode.c b/source/components/disassembler/dmopcode.c index 7ca171cbbbeb9..35fa5945bc19c 100644 --- a/source/components/disassembler/dmopcode.c +++ b/source/components/disassembler/dmopcode.c @@ -64,6 +64,10 @@ static void AcpiDmConvertToElseIf ( ACPI_PARSE_OBJECT *Op); +static void +AcpiDmPromoteSubtree ( + ACPI_PARSE_OBJECT *StartOp); + /******************************************************************************* * @@ -1067,12 +1071,22 @@ AcpiDmConvertToElseIf ( * be the only blocks under the original Else. */ IfOp = OriginalElseOp->Common.Value.Arg; + if (!IfOp || (IfOp->Common.AmlOpcode != AML_IF_OP) || (IfOp->Asl.Next && (IfOp->Asl.Next->Common.AmlOpcode != AML_ELSE_OP))) { - /* Not an Else..If sequence, cannot convert to ElseIf */ + /* Not a proper Else..If sequence, cannot convert to ElseIf */ + + AcpiOsPrintf ("%s", "Else"); + return; + } + + /* Cannot have anything following the If...Else block */ + ElseOp = IfOp->Common.Next; + if (ElseOp && ElseOp->Common.Next) + { AcpiOsPrintf ("%s", "Else"); return; } @@ -1100,7 +1114,10 @@ AcpiDmConvertToElseIf ( /* If an ELSE matches the IF, promote it also */ ElseOp->Common.Parent = OriginalElseOp->Common.Parent; - ElseOp->Common.Next = OriginalElseOp->Common.Next; + + /* Promote the entire block under the ElseIf (All Next OPs) */ + + AcpiDmPromoteSubtree (OriginalElseOp); } else { @@ -1122,3 +1139,48 @@ AcpiDmConvertToElseIf ( OriginalElseOp->Common.Next = IfOp; } + + +/******************************************************************************* + * + * FUNCTION: AcpiDmPromoteSubtree + * + * PARAMETERS: StartOpOp - Original parent of the entire subtree + * + * RETURN: None + * + * DESCRIPTION: Promote an entire parse subtree up one level. + * + ******************************************************************************/ + +static void +AcpiDmPromoteSubtree ( + ACPI_PARSE_OBJECT *StartOp) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *ParentOp; + + + /* New parent for subtree elements */ + + ParentOp = StartOp->Common.Parent; + + /* First child starts the subtree */ + + Op = StartOp->Common.Value.Arg; + + /* Walk the top-level elements of the subtree */ + + while (Op) + { + Op->Common.Parent = ParentOp; + if (!Op->Common.Next) + { + /* Last Op in list, update its next field */ + + Op->Common.Next = StartOp->Common.Next; + break; + } + Op = Op->Common.Next; + } +} |