Merge pull request #212 from debox1/fix-acpica-bug-1358

Disassembler: Do not unconditionally remove temporary names
This commit is contained in:
David Box 2017-02-24 13:18:15 -08:00 committed by GitHub
commit 62473c346d
2 changed files with 30 additions and 14 deletions

View File

@ -142,7 +142,8 @@ AcpiDmPromoteSubtree (
static BOOLEAN
AcpiDmIsSwitchBlock (
ACPI_PARSE_OBJECT *Op);
ACPI_PARSE_OBJECT *Op,
char *Temp);
static BOOLEAN
AcpiDmIsCaseBlock (
@ -1049,7 +1050,7 @@ AcpiDmDisassembleOneOp (
case AML_WHILE_OP:
if (AcpiDmIsSwitchBlock(Op))
if (Op->Common.DisasmOpcode == ACPI_DASM_SWITCH)
{
AcpiOsPrintf ("%s", "Switch");
break;
@ -1325,11 +1326,13 @@ AcpiDmPromoteSubtree (
*
* PARAMETERS: Op - Object to be examined
*
* RETURN: TRUE if object is a temporary (_T_x) name
* RETURN: TRUE if object is a temporary (_T_x) name for a matching While
* loop that can be converted to a Switch.
*
* DESCRIPTION: Determine if an object is a temporary name and ignore it.
* Temporary names are only used for Switch statements. This
* function depends on this restriced usage.
* DESCRIPTION: _T_X objects are only used for Switch statements. If a temporary
* name exists, search the siblings for a matching While (One) loop
* that can be converted to a Switch. Return TRUE if a match was
* found, FALSE otherwise.
*
******************************************************************************/
@ -1337,6 +1340,7 @@ BOOLEAN
AcpiDmIsTempName (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *CurrentOp;
char *Temp;
if (Op->Common.AmlOpcode != AML_NAME_OP)
@ -1352,11 +1356,21 @@ AcpiDmIsTempName (
return (FALSE);
}
/* Ignore Op */
CurrentOp = Op->Common.Next;
while (CurrentOp)
{
if (CurrentOp->Common.AmlOpcode == AML_WHILE_OP &&
AcpiDmIsSwitchBlock(CurrentOp, Temp))
{
Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
CurrentOp->Common.DisasmOpcode = ACPI_DASM_SWITCH;
Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
return (TRUE);
}
CurrentOp = CurrentOp->Common.Next;
}
return (TRUE);
return (FALSE);
}
/*******************************************************************************
@ -1392,7 +1406,8 @@ AcpiDmIsTempName (
static BOOLEAN
AcpiDmIsSwitchBlock (
ACPI_PARSE_OBJECT *Op)
ACPI_PARSE_OBJECT *Op,
char *Temp)
{
ACPI_PARSE_OBJECT *OneOp;
ACPI_PARSE_OBJECT *StoreOp;
@ -1425,7 +1440,7 @@ AcpiDmIsSwitchBlock (
return (FALSE);
}
if (strncmp((char *)(NamePathOp->Common.Aml), "_T_", 3))
if (strncmp((char *)(NamePathOp->Common.Aml), Temp, 4))
{
return (FALSE);
}

View File

@ -1009,9 +1009,10 @@ typedef union acpi_parse_value
#define ACPI_DASM_LNOT_SUFFIX 0x09 /* End of a LNotEqual (etc.) pair of opcodes */
#define ACPI_DASM_HID_STRING 0x0A /* String is a _HID or _CID */
#define ACPI_DASM_IGNORE_SINGLE 0x0B /* Ignore the opcode but not it's children */
#define ACPI_DASM_SWITCH_PREDICATE 0x0C /* Object is a predicate for a Switch or Case block */
#define ACPI_DASM_CASE 0x0D /* If/Else is a Case in a Switch/Case block */
#define ACPI_DASM_DEFAULT 0x0E /* Else is a Default in a Switch/Case block */
#define ACPI_DASM_SWITCH 0x0C /* While is a Switch */
#define ACPI_DASM_SWITCH_PREDICATE 0x0D /* Object is a predicate for a Switch or Case block */
#define ACPI_DASM_CASE 0x0E /* If/Else is a Case in a Switch/Case block */
#define ACPI_DASM_DEFAULT 0x0F /* Else is a Default in a Switch/Case block */
/*
* Generic operation (for example: If, While, Store)