Skip to content

Commit

Permalink
iASL: Add symbolic operator support for Index() operator.
Browse files Browse the repository at this point in the history
Index (XXXX, 2) is now supported by XXXX [2]
  • Loading branch information
acpibob committed Aug 20, 2015
1 parent 114cc42 commit fbe67c4
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 9 deletions.
3 changes: 3 additions & 0 deletions source/compiler/aslcompiler.l
Expand Up @@ -228,6 +228,9 @@ NamePathTail [.]{NameSeg}
"^=" { count (3); return (PARSEOP_EXP_XOR_EQ); }
"|=" { count (3); return (PARSEOP_EXP_OR_EQ); }

"[" { count (3); return(PARSEOP_EXP_INDEX_LEFT); }
"]" { count (0); return(PARSEOP_EXP_INDEX_RIGHT); }


/*
* Begin standard ASL grammar
Expand Down
18 changes: 17 additions & 1 deletion source/compiler/aslrules.y
Expand Up @@ -253,9 +253,24 @@ Expression
| TermArg PARSEOP_EXP_LOGICAL_OR {$<n>$ = TrCreateLeafNode (PARSEOP_LOR);}
TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);}

/* Parentheses */
/* Parentheses */

| '(' TermArg ')' { $$ = $2;}

/* Index term -- "= BUF1[5]" on right-hand side of an equals (source) */

| SuperName PARSEOP_EXP_INDEX_LEFT TermArg PARSEOP_EXP_INDEX_RIGHT
{$$ = TrCreateLeafNode (PARSEOP_INDEX);
TrLinkChildren ($$,3,$1,$3,TrCreateNullTarget ());}
;

/* Index term -- "BUF1[5] = " on left-hand side of an equals (target) */

IndexExpTerm

: SuperName PARSEOP_EXP_INDEX_LEFT TermArg PARSEOP_EXP_INDEX_RIGHT
{$$ = TrCreateLeafNode (PARSEOP_INDEX);
TrLinkChildren ($$,3,$1,$3,TrCreateNullTarget ());}
;

EqualsTerm
Expand Down Expand Up @@ -614,6 +629,7 @@ Type6Opcode
: RefOfTerm {}
| DerefOfTerm {}
| IndexTerm {}
| IndexExpTerm {}
| MethodInvocationTerm {}
;

Expand Down
6 changes: 6 additions & 0 deletions source/compiler/asltokens.y
Expand Up @@ -524,8 +524,14 @@ NoEcho('
%left <i> PARSEOP_EXP_INCREMENT
PARSEOP_EXP_DECREMENT
/* Brackets for Index() support */
%left <i> PARSEOP_EXP_INDEX_LEFT
%right <i> PARSEOP_EXP_INDEX_RIGHT
%token <i> PARSEOP_PRINTF
%token <i> PARSEOP_FPRINTF
/* Specific parentheses tokens are not used at this time */
/* PARSEOP_EXP_PAREN_OPEN */
/* PARSEOP_EXP_PAREN_CLOSE */
Expand Down
1 change: 1 addition & 0 deletions source/compiler/asltree.c
Expand Up @@ -610,6 +610,7 @@ TrCreateAssignmentNode (
case PARSEOP_ADD:
case PARSEOP_AND:
case PARSEOP_DIVIDE:
case PARSEOP_INDEX:
case PARSEOP_MOD:
case PARSEOP_MULTIPLY:
case PARSEOP_NOT:
Expand Down
1 change: 1 addition & 0 deletions source/compiler/asltypes.y
Expand Up @@ -463,3 +463,4 @@ NoEcho('
*/
%type <n> Expression
%type <n> EqualsTerm
%type <n> IndexExpTerm
33 changes: 26 additions & 7 deletions source/components/disassembler/dmcstyle.c
Expand Up @@ -299,12 +299,27 @@ AcpiDmCheckForSymbolicOpcode (
Child2->Common.OperatorSymbol = OperatorSymbol;
return (TRUE);

#ifdef INDEX_SUPPORT
case AML_INDEX_OP:
/*
* Check for constant source operand. Note: although technically
* legal syntax, the iASL compiler does not support this with
* the symbolic operators for Index(). It doesn't make sense to
* use Index() with a constant anyway.
*/
if ((Child1->Common.AmlOpcode == AML_STRING_OP) ||
(Child1->Common.AmlOpcode == AML_BUFFER_OP) ||
(Child1->Common.AmlOpcode == AML_PACKAGE_OP) ||
(Child1->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
{
Op->Common.DisasmFlags |= ACPI_PARSEOP_CLOSING_PAREN;
return (FALSE);
}

/* Index operator is [] */

Child1->Common.OperatorSymbol = " [";
Child2->Common.OperatorSymbol = "]";
break;
#endif

/* Unary operators */

Expand Down Expand Up @@ -514,7 +529,6 @@ AcpiDmCheckForSymbolicOpcode (
case AML_INCREMENT_OP:
return (TRUE);

#ifdef INDEX_SUPPORT
case AML_INDEX_OP:

/* Target is optional, 3rd operand */
Expand All @@ -530,7 +544,6 @@ AcpiDmCheckForSymbolicOpcode (
}
}
return (TRUE);
#endif

case AML_STORE_OP:
/*
Expand Down Expand Up @@ -650,12 +663,18 @@ AcpiDmCloseOperator (
}
break;

case AML_INDEX_OP:

/* This is case for unsupported Index() source constants */

if (Op->Common.DisasmFlags & ACPI_PARSEOP_CLOSING_PAREN)
{
AcpiOsPrintf (")");
}
return;

/* No need for parens for these */

#ifdef INDEX_SUPPORT
case AML_INDEX_OP:
#endif
case AML_DECREMENT_OP:
case AML_INCREMENT_OP:
case AML_LNOT_OP:
Expand Down
2 changes: 1 addition & 1 deletion source/include/aclocal.h
Expand Up @@ -1089,7 +1089,7 @@ typedef struct acpi_parse_state
#define ACPI_PARSEOP_PARAMLIST 0x02
#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04
#define ACPI_PARSEOP_PREDEF_CHECKED 0x08
#define ACPI_PARSEOP_SPECIAL 0x10
#define ACPI_PARSEOP_CLOSING_PAREN 0x10
#define ACPI_PARSEOP_COMPOUND 0x20
#define ACPI_PARSEOP_ASSIGNMENT 0x40

Expand Down

0 comments on commit fbe67c4

Please sign in to comment.