diff options
author | Jung-uk Kim <jkim@FreeBSD.org> | 2015-04-09 23:08:47 +0000 |
---|---|---|
committer | Jung-uk Kim <jkim@FreeBSD.org> | 2015-04-09 23:08:47 +0000 |
commit | d29c30140bd8ea81e0530ad3975c977891ab9275 (patch) | |
tree | 7a91c0da98a89b4b10beda84d027d2c779673064 /source/compiler | |
parent | 2872953d4a9c9c4e0fc0b9ab37d0e962909625a0 (diff) | |
download | src-d29c30140bd8ea81e0530ad3975c977891ab9275.tar.gz src-d29c30140bd8ea81e0530ad3975c977891ab9275.zip |
Import ACPICA 20150408.vendor/acpica/20150408
Notes
Notes:
svn path=/vendor-sys/acpica/dist/; revision=281344
svn path=/vendor-sys/acpica/20150408/; revision=281345; tag=vendor/acpica/20150408
Diffstat (limited to 'source/compiler')
-rw-r--r-- | source/compiler/aslcodegen.c | 2 | ||||
-rw-r--r-- | source/compiler/aslcompile.c | 12 | ||||
-rw-r--r-- | source/compiler/aslcompiler.h | 8 | ||||
-rw-r--r-- | source/compiler/asldefine.h | 1 | ||||
-rw-r--r-- | source/compiler/aslfold.c | 706 | ||||
-rw-r--r-- | source/compiler/asllisting.c | 5 | ||||
-rw-r--r-- | source/compiler/aslmain.c | 1 | ||||
-rw-r--r-- | source/compiler/aslmap.c | 2 | ||||
-rw-r--r-- | source/compiler/aslmapenter.c | 10 | ||||
-rw-r--r-- | source/compiler/asloptions.c | 5 | ||||
-rw-r--r-- | source/compiler/aslrules.y | 53 | ||||
-rw-r--r-- | source/compiler/aslstartup.c | 2 | ||||
-rw-r--r-- | source/compiler/asltree.c | 199 | ||||
-rw-r--r-- | source/compiler/asltypes.y | 2 | ||||
-rw-r--r-- | source/compiler/aslutils.c | 9 | ||||
-rw-r--r-- | source/compiler/aslwalks.c | 10 | ||||
-rw-r--r-- | source/compiler/dtcompile.c | 17 | ||||
-rw-r--r-- | source/compiler/dtcompiler.h | 20 | ||||
-rw-r--r-- | source/compiler/dtio.c | 6 | ||||
-rw-r--r-- | source/compiler/dttable.c | 35 | ||||
-rw-r--r-- | source/compiler/dttemplate.h | 17 | ||||
-rw-r--r-- | source/compiler/dtutils.c | 3 |
22 files changed, 725 insertions, 400 deletions
diff --git a/source/compiler/aslcodegen.c b/source/compiler/aslcodegen.c index 5bb79c8f9aef..38bf9cf237f6 100644 --- a/source/compiler/aslcodegen.c +++ b/source/compiler/aslcodegen.c @@ -460,7 +460,7 @@ CgWriteTableHeader ( /* Compiler version */ - TableHeader.AslCompilerRevision = ASL_REVISION; + TableHeader.AslCompilerRevision = ACPI_CA_VERSION; /* Table length. Checksum zero for now, will rewrite later */ diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index 47ef107e1943..47f92b44e4df 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -195,8 +195,16 @@ CmDoCompile ( Event = UtBeginEvent ("Constant folding via AML interpreter"); DbgPrint (ASL_DEBUG_OUTPUT, "\nInterpreting compile-time constant expressions\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, - OpcAmlConstantWalk, NULL, NULL); + + if (Gbl_FoldConstants) + { + TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + OpcAmlConstantWalk, NULL, NULL); + } + else + { + DbgPrint (ASL_PARSE_OUTPUT, " Optional folding disabled\n"); + } UtEndEvent (Event); /* Update AML opcodes if necessary, after constant folding */ diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h index 38b2f23e9a7b..898d651b4ab8 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -686,6 +686,10 @@ TrAllocateNode ( UINT32 ParseOpcode); void +TrPrintNodeCompileFlags ( + UINT32 Flags); + +void TrReleaseNode ( ACPI_PARSE_OBJECT *Op); @@ -705,6 +709,10 @@ TrCreateLeafNode ( UINT32 ParseOpcode); ACPI_PARSE_OBJECT * +TrCreateNullTarget ( + void); + +ACPI_PARSE_OBJECT * TrCreateAssignmentNode ( ACPI_PARSE_OBJECT *Target, ACPI_PARSE_OBJECT *Source); diff --git a/source/compiler/asldefine.h b/source/compiler/asldefine.h index f639eccf6129..14307c1bfb23 100644 --- a/source/compiler/asldefine.h +++ b/source/compiler/asldefine.h @@ -48,7 +48,6 @@ /* * Compiler versions and names */ -#define ASL_REVISION ACPI_CA_VERSION #define ASL_COMPILER_NAME "ASL+ Optimizing Compiler" #define AML_DISASSEMBLER_NAME "AML/ASL+ Disassembler" #define ASL_INVOCATION_NAME "iasl" diff --git a/source/compiler/aslfold.c b/source/compiler/aslfold.c index d1020bcac6ba..8c11860e6813 100644 --- a/source/compiler/aslfold.c +++ b/source/compiler/aslfold.c @@ -76,97 +76,125 @@ OpcUpdateIntegerNode ( ACPI_PARSE_OBJECT *Op, UINT64 Value); +static ACPI_STATUS +TrTransformToStoreOp ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +static ACPI_STATUS +TrSimpleConstantReduction ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +static void +TrInstallReducedConstant ( + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ObjDesc); + /******************************************************************************* * - * FUNCTION: OpcAmlEvaluationWalk1 + * FUNCTION: OpcAmlConstantWalk * * PARAMETERS: ASL_WALK_CALLBACK * * RETURN: Status * - * DESCRIPTION: Descending callback for AML execution of constant subtrees + * DESCRIPTION: Reduce an Op and its subtree to a constant if possible * ******************************************************************************/ -static ACPI_STATUS -OpcAmlEvaluationWalk1 ( +ACPI_STATUS +OpcAmlConstantWalk ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context) { - ACPI_WALK_STATE *WalkState = Context; - ACPI_STATUS Status; - ACPI_PARSE_OBJECT *OutOp; + ACPI_WALK_STATE *WalkState; + ACPI_STATUS Status = AE_OK; - WalkState->Op = Op; - WalkState->Opcode = Op->Common.AmlOpcode; - WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); - - /* Copy child pointer to Arg for compatibility with Interpreter */ + if (Op->Asl.CompileFlags == 0) + { + return (AE_OK); + } - if (Op->Asl.Child) + /* + * Only interested in subtrees that could possibly contain + * expressions that can be evaluated at this time + */ + if ((!(Op->Asl.CompileFlags & NODE_COMPILE_TIME_CONST)) || + (Op->Asl.CompileFlags & NODE_IS_TARGET)) { - Op->Common.Value.Arg = Op->Asl.Child; + return (AE_OK); } - /* Call AML dispatcher */ + /* Create a new walk state */ - Status = AcpiDsExecBeginOp (WalkState, &OutOp); - if (ACPI_FAILURE (Status)) + WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); + if (!WalkState) { - AcpiOsPrintf ("Constant interpretation failed - %s\n", - AcpiFormatException (Status)); + return (AE_NO_MEMORY); } - return (Status); -} + WalkState->NextOp = NULL; + WalkState->Params = NULL; + /* + * Examine the entire subtree -- all nodes must be constants + * or type 3/4/5 opcodes + */ + Status = TrWalkParseTree (Op, ASL_WALK_VISIT_DOWNWARD, + OpcAmlCheckForConstant, NULL, WalkState); -/******************************************************************************* - * - * FUNCTION: OpcAmlEvaluationWalk2 - * - * PARAMETERS: ASL_WALK_CALLBACK - * - * RETURN: Status - * - * DESCRIPTION: Ascending callback for AML execution of constant subtrees - * - ******************************************************************************/ + /* + * Did we find an entire subtree that contains all constants + * and type 3/4/5 opcodes? + */ + switch (Status) + { + case AE_OK: -static ACPI_STATUS -OpcAmlEvaluationWalk2 ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context) -{ - ACPI_WALK_STATE *WalkState = Context; - ACPI_STATUS Status; + /* Simple case, like Add(3,4) -> 7 */ + Status = TrSimpleConstantReduction (Op, WalkState); + break; - WalkState->Op = Op; - WalkState->Opcode = Op->Common.AmlOpcode; - WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + case AE_CTRL_RETURN_VALUE: - /* Copy child pointer to Arg for compatibility with Interpreter */ + /* More complex case, like Add(3,4,Local0) -> Store(7,Local0) */ - if (Op->Asl.Child) - { - Op->Common.Value.Arg = Op->Asl.Child; - } + Status = TrTransformToStoreOp (Op, WalkState); + break; - /* Call AML dispatcher */ + case AE_TYPE: + + AcpiDsDeleteWalkState (WalkState); + return (AE_OK); + + default: + AcpiDsDeleteWalkState (WalkState); + break; + } - Status = AcpiDsExecEndOp (WalkState); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Constant interpretation failed - %s\n", - AcpiFormatException (Status)); + DbgPrint (ASL_PARSE_OUTPUT, "Cannot resolve, %s\n", + AcpiFormatException (Status)); + + /* We could not resolve the subtree for some reason */ + + AslError (ASL_ERROR, ASL_MSG_CONSTANT_EVALUATION, Op, + (char *) AcpiFormatException (Status)); + + /* Set the subtree value to ZERO anyway. Eliminates further errors */ + + OpcUpdateIntegerNode (Op, 0); } - return (Status); + /* Abort the walk of this subtree, we are done with it */ + + return (AE_CTRL_DEPTH); } @@ -189,6 +217,7 @@ OpcAmlCheckForConstant ( void *Context) { ACPI_WALK_STATE *WalkState = Context; + ACPI_STATUS Status = AE_OK; WalkState->Op = Op; @@ -196,7 +225,20 @@ OpcAmlCheckForConstant ( WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); DbgPrint (ASL_PARSE_OUTPUT, "[%.4d] Opcode: %12.12s ", - Op->Asl.LogicalLineNumber, Op->Asl.ParseOpName); + Op->Asl.LogicalLineNumber, Op->Asl.ParseOpName); + + /* + * TBD: Ignore buffer constants for now. The problem is that these + * constants have been transformed into RAW_DATA at this point, from + * the parse tree transform process which currently happens before + * the constant folding process. We may need to defer this transform + * for buffer until after the constant folding. + */ + if (WalkState->Opcode == AML_BUFFER_OP) + { + Status = AE_TYPE; + goto CleanupAndExit; + } /* * These opcodes do not appear in the OpcodeInfo table, but @@ -207,50 +249,32 @@ OpcAmlCheckForConstant ( (WalkState->Opcode == AML_RAW_DATA_DWORD) || (WalkState->Opcode == AML_RAW_DATA_QWORD)) { - WalkState->WalkType = ACPI_WALK_CONST_OPTIONAL; - return (AE_TYPE); + DbgPrint (ASL_PARSE_OUTPUT, "RAW DATA"); + Status = AE_TYPE; + goto CleanupAndExit; } + /* Type 3/4/5 opcodes have the AML_CONSTANT flag set */ + if (!(WalkState->OpInfo->Flags & AML_CONSTANT)) { - /* The opcode is not a Type 3/4/5 opcode */ + /* Not 3/4/5 opcode, but maybe can convert to STORE */ if (Op->Asl.CompileFlags & NODE_IS_TARGET) { DbgPrint (ASL_PARSE_OUTPUT, - "**** Valid Target, cannot reduce ****\n"); - } - else - { - DbgPrint (ASL_PARSE_OUTPUT, - "**** Not a Type 3/4/5 opcode ****\n"); + "**** Valid Target, transform to Store ****\n"); + return (AE_CTRL_RETURN_VALUE); } - if (WalkState->WalkType == ACPI_WALK_CONST_OPTIONAL) - { - /* - * We are looking at at normal expression to see if it can be - * reduced. It can't. No error - */ - return (AE_TYPE); - } + /* Expression cannot be reduced */ - /* - * This is an expression that MUST reduce to a constant, and it - * can't be reduced. This is an error - */ - if (Op->Asl.CompileFlags & NODE_IS_TARGET) - { - AslError (ASL_ERROR, ASL_MSG_INVALID_TARGET, Op, - Op->Asl.ParseOpName); - } - else - { - AslError (ASL_ERROR, ASL_MSG_INVALID_CONSTANT_OP, Op, - Op->Asl.ParseOpName); - } + DbgPrint (ASL_PARSE_OUTPUT, + "**** Not a Type 3/4/5 opcode (%s) ****", + Op->Asl.ParseOpName); - return (AE_TYPE); + Status = AE_TYPE; + goto CleanupAndExit; } /* Debug output */ @@ -259,250 +283,346 @@ OpcAmlCheckForConstant ( if (Op->Asl.CompileFlags & NODE_IS_TARGET) { - DbgPrint (ASL_PARSE_OUTPUT, " TARGET"); + if (Op->Asl.ParseOpcode == PARSEOP_ZERO) + { + DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " NULL TARGET"); + } + else + { + DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " VALID TARGET"); + } } if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG) { - DbgPrint (ASL_PARSE_OUTPUT, " TERMARG"); + DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " TERMARG"); } +CleanupAndExit: + + /* Dump the node compile flags also */ + + TrPrintNodeCompileFlags (Op->Asl.CompileFlags); DbgPrint (ASL_PARSE_OUTPUT, "\n"); - return (AE_OK); + return (Status); } /******************************************************************************* * - * FUNCTION: OpcAmlConstantWalk + * FUNCTION: TrSimpleConstantReduction * - * PARAMETERS: ASL_WALK_CALLBACK + * PARAMETERS: Op - Parent operator to be transformed + * WalkState - Current walk state * * RETURN: Status * - * DESCRIPTION: Reduce an Op and its subtree to a constant if possible + * DESCRIPTION: Reduce an entire AML operation to a single constant. The + * operation must not have a target operand. + * + * Add (32,64) --> 96 * ******************************************************************************/ -ACPI_STATUS -OpcAmlConstantWalk ( +static ACPI_STATUS +TrSimpleConstantReduction ( ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context) + ACPI_WALK_STATE *WalkState) { - ACPI_WALK_STATE *WalkState; - ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT *ObjDesc; ACPI_PARSE_OBJECT *RootOp; ACPI_PARSE_OBJECT *OriginalParentOp; - UINT8 WalkType; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; - /* - * Only interested in subtrees that could possibly contain - * expressions that can be evaluated at this time - */ - if ((!(Op->Asl.CompileFlags & NODE_COMPILE_TIME_CONST)) || - (Op->Asl.CompileFlags & NODE_IS_TARGET)) + DbgPrint (ASL_PARSE_OUTPUT, + "Simple subtree constant reduction, operator to constant\n"); + + /* Allocate a new temporary root for this subtree */ + + RootOp = TrAllocateNode (PARSEOP_INTEGER); + if (!RootOp) { - return (AE_OK); + return (AE_NO_MEMORY); } - /* Set the walk type based on the reduction used for this op */ + RootOp->Common.AmlOpcode = AML_INT_EVAL_SUBTREE_OP; - if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG) - { - /* Op is a TermArg, constant folding is merely optional */ + OriginalParentOp = Op->Common.Parent; + Op->Common.Parent = RootOp; - if (!Gbl_FoldConstants) - { - return (AE_CTRL_DEPTH); - } + /* Hand off the subtree to the AML interpreter */ - WalkType = ACPI_WALK_CONST_OPTIONAL; - } - else - { - /* Op is a DataObject, the expression MUST reduced to a constant */ + WalkState->CallerReturnDesc = &ObjDesc; + + Status = TrWalkParseTree (Op, ASL_WALK_VISIT_TWICE, + OpcAmlEvaluationWalk1, OpcAmlEvaluationWalk2, WalkState); + + /* Restore original parse tree */ + + Op->Common.Parent = OriginalParentOp; - WalkType = ACPI_WALK_CONST_REQUIRED; + if (ACPI_FAILURE (Status)) + { + DbgPrint (ASL_PARSE_OUTPUT, + "Constant Subtree evaluation(1), %s\n", + AcpiFormatException (Status)); + return (Status); } - /* Create a new walk state */ + /* Get the final result */ - WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); - if (!WalkState) + Status = AcpiDsResultPop (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) { - return (AE_NO_MEMORY); + DbgPrint (ASL_PARSE_OUTPUT, + "Constant Subtree evaluation(2), %s\n", + AcpiFormatException (Status)); + return (Status); } - WalkState->NextOp = NULL; - WalkState->Params = NULL; - WalkState->WalkType = WalkType; - WalkState->CallerReturnDesc = &ObjDesc; + TrInstallReducedConstant (Op, ObjDesc); - /* - * Examine the entire subtree -- all nodes must be constants - * or type 3/4/5 opcodes - */ - Status = TrWalkParseTree (Op, ASL_WALK_VISIT_DOWNWARD, - OpcAmlCheckForConstant, NULL, WalkState); + UtSetParseOpName (Op); + Op->Asl.Child = NULL; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: TrTransformToStoreOp + * + * PARAMETERS: Op - Parent operator to be transformed + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Transforms a single AML operation with a constant and target + * to a simple store operation: + * + * Add (32,64,DATA) --> Store (96,DATA) + * + ******************************************************************************/ + +static ACPI_STATUS +TrTransformToStoreOp ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) +{ + ACPI_PARSE_OBJECT *OriginalTarget; + ACPI_PARSE_OBJECT *NewTarget; + ACPI_PARSE_OBJECT *Child1; + ACPI_PARSE_OBJECT *Child2; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARSE_OBJECT *NewParent; + ACPI_PARSE_OBJECT *OriginalParent; + ACPI_STATUS Status; + + + DbgPrint (ASL_PARSE_OUTPUT, + "Reduction/Transform to StoreOp: Store(Constant, Target)\n"); + + /* Extract the operands */ + + Child1 = Op->Asl.Child; + Child2 = Child1->Asl.Next; /* - * Did we find an entire subtree that contains all constants and type 3/4/5 - * opcodes? (Only AE_OK or AE_TYPE returned from above) + * Special case for DIVIDE -- it has two targets. The first + * is for the remainder and if present, we will not attempt + * to reduce the expression. */ - if (Status == AE_TYPE) + if (Op->Asl.ParseOpcode == PARSEOP_DIVIDE) { - /* Subtree cannot be reduced to a constant */ - - if (WalkState->WalkType == ACPI_WALK_CONST_OPTIONAL) + Child2 = Child2->Asl.Next; + if (Child2->Asl.ParseOpcode != PARSEOP_ZERO) { - AcpiDsDeleteWalkState (WalkState); + DbgPrint (ASL_PARSE_OUTPUT, + "Cannot reduce DIVIDE - has two targets\n\n"); return (AE_OK); } + } + + /* + * Create a NULL (zero) target so that we can use the + * interpreter to evaluate the expression. + */ + NewTarget = TrCreateNullTarget (); + NewTarget->Common.AmlOpcode = AML_INT_NAMEPATH_OP; - /* Don't descend any further, and use a default "constant" value */ + /* Handle one-operand cases (NOT, TOBCD, etc.) */ - Status = AE_CTRL_DEPTH; + if (!Child2->Asl.Next) + { + Child2 = Child1; } - else + + /* Link in new NULL target as the last operand */ + + OriginalTarget = Child2->Asl.Next; + Child2->Asl.Next = NewTarget; + NewTarget->Asl.Parent = OriginalTarget->Asl.Parent; + + NewParent = TrAllocateNode (PARSEOP_INTEGER); + NewParent->Common.AmlOpcode = AML_INT_EVAL_SUBTREE_OP; + + OriginalParent = Op->Common.Parent; + Op->Common.Parent = NewParent; + + /* Hand off the subtree to the AML interpreter */ + + WalkState->CallerReturnDesc = &ObjDesc; + + Status = TrWalkParseTree (Op, ASL_WALK_VISIT_TWICE, + OpcAmlEvaluationWalk1, OpcAmlEvaluationWalk2, WalkState); + if (ACPI_FAILURE (Status)) { - /* Subtree can be reduced */ + DbgPrint (ASL_PARSE_OUTPUT, + "Constant Subtree evaluation(3), %s\n", + AcpiFormatException (Status)); + goto EvalError; + } - /* Allocate a new temporary root for this subtree */ + /* Get the final result */ - RootOp = TrAllocateNode (PARSEOP_INTEGER); - if (!RootOp) - { - return (AE_NO_MEMORY); - } + Status = AcpiDsResultPop (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + DbgPrint (ASL_PARSE_OUTPUT, + "Constant Subtree evaluation(4), %s\n", + AcpiFormatException (Status)); + goto EvalError; + } - RootOp->Common.AmlOpcode = AML_INT_EVAL_SUBTREE_OP; + /* Folded constant is in ObjDesc, store into Child1 */ - OriginalParentOp = Op->Common.Parent; - Op->Common.Parent = RootOp; + TrInstallReducedConstant (Child1, ObjDesc); - /* Hand off the subtree to the AML interpreter */ + /* Convert operator to STORE */ - Status = TrWalkParseTree (Op, ASL_WALK_VISIT_TWICE, - OpcAmlEvaluationWalk1, OpcAmlEvaluationWalk2, WalkState); - Op->Common.Parent = OriginalParentOp; + Op->Asl.ParseOpcode = PARSEOP_STORE; + Op->Asl.AmlOpcode = AML_STORE_OP; + UtSetParseOpName (Op); + Op->Common.Parent = OriginalParent; - /* TBD: we really *should* release the RootOp node */ + /* Truncate any subtree expressions, they have been evaluated */ - if (ACPI_SUCCESS (Status)) - { - TotalFolds++; + Child1->Asl.Child = NULL; + Child2->Asl.Child = NULL; - /* Get the final result */ + /* First child is the folded constant */ - Status = AcpiDsResultPop (&ObjDesc, WalkState); - } + /* Second child will be the target */ - /* Check for error from the ACPICA core */ + Child1->Asl.Next = OriginalTarget; + return (AE_OK); - if (ACPI_FAILURE (Status)) - { - AslCoreSubsystemError (Op, Status, - "Failure during constant evaluation", FALSE); - } - } - if (ACPI_FAILURE (Status)) - { - /* We could not resolve the subtree for some reason */ +EvalError: - AslError (ASL_ERROR, ASL_MSG_CONSTANT_EVALUATION, Op, - Op->Asl.ParseOpName); + /* Restore original links */ - /* Set the subtree value to ZERO anyway. Eliminates further errors */ + Op->Common.Parent = OriginalParent; + Child2->Asl.Next = OriginalTarget; + return (Status); +} - OpcUpdateIntegerNode (Op, 0); - } - else - { - AslError (ASL_OPTIMIZATION, ASL_MSG_CONSTANT_FOLDED, Op, - Op->Asl.ParseOpName); - - /* - * Because we know we executed type 3/4/5 opcodes above, we know that - * the result must be either an Integer, String, or Buffer. - */ - switch (ObjDesc->Common.Type) - { - case ACPI_TYPE_INTEGER: - OpcUpdateIntegerNode (Op, ObjDesc->Integer.Value); +/******************************************************************************* + * + * FUNCTION: TrInstallReducedConstant + * + * PARAMETERS: Op - Parent operator to be transformed + * ObjDesc - Reduced constant to be installed + * + * RETURN: None + * + * DESCRIPTION: Transform the original operator to a simple constant. + * Handles Integers, Strings, and Buffers. + * + ******************************************************************************/ + +static void +TrInstallReducedConstant ( + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_PARSE_OBJECT *RootOp; - DbgPrint (ASL_PARSE_OUTPUT, - "Constant expression reduced to (%s) %8.8X%8.8X\n", - Op->Asl.ParseOpName, - ACPI_FORMAT_UINT64 (Op->Common.Value.Integer)); - break; - case ACPI_TYPE_STRING: + TotalFolds++; + AslError (ASL_OPTIMIZATION, ASL_MSG_CONSTANT_FOLDED, Op, + Op->Asl.ParseOpName); - Op->Asl.ParseOpcode = PARSEOP_STRING_LITERAL; - Op->Common.AmlOpcode = AML_STRING_OP; - Op->Asl.AmlLength = ACPI_STRLEN (ObjDesc->String.Pointer) + 1; - Op->Common.Value.String = ObjDesc->String.Pointer; + /* + * Because we know we executed type 3/4/5 opcodes above, we know that + * the result must be either an Integer, String, or Buffer. + */ + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: - DbgPrint (ASL_PARSE_OUTPUT, - "Constant expression reduced to (STRING) %s\n", - Op->Common.Value.String); + OpcUpdateIntegerNode (Op, ObjDesc->Integer.Value); - break; + DbgPrint (ASL_PARSE_OUTPUT, + "Constant expression reduced to (%s) %8.8X%8.8X\n\n", + Op->Asl.ParseOpName, + ACPI_FORMAT_UINT64 (Op->Common.Value.Integer)); + break; - case ACPI_TYPE_BUFFER: + case ACPI_TYPE_STRING: - Op->Asl.ParseOpcode = PARSEOP_BUFFER; - Op->Common.AmlOpcode = AML_BUFFER_OP; - Op->Asl.CompileFlags = NODE_AML_PACKAGE; - UtSetParseOpName (Op); + Op->Asl.ParseOpcode = PARSEOP_STRING_LITERAL; + Op->Common.AmlOpcode = AML_STRING_OP; + Op->Asl.AmlLength = ACPI_STRLEN (ObjDesc->String.Pointer) + 1; + Op->Common.Value.String = ObjDesc->String.Pointer; - /* Child node is the buffer length */ + DbgPrint (ASL_PARSE_OUTPUT, + "Constant expression reduced to (STRING) %s\n\n", + Op->Common.Value.String); - RootOp = TrAllocateNode (PARSEOP_INTEGER); + break; - RootOp->Asl.AmlOpcode = AML_DWORD_OP; - RootOp->Asl.Value.Integer = ObjDesc->Buffer.Length; - RootOp->Asl.Parent = Op; + case ACPI_TYPE_BUFFER: - (void) OpcSetOptimalIntegerSize (RootOp); + Op->Asl.ParseOpcode = PARSEOP_BUFFER; + Op->Common.AmlOpcode = AML_BUFFER_OP; + Op->Asl.CompileFlags = NODE_AML_PACKAGE; + UtSetParseOpName (Op); - Op->Asl.Child = RootOp; - Op = RootOp; - UtSetParseOpName (Op); + /* Child node is the buffer length */ - /* Peer to the child is the raw buffer data */ + RootOp = TrAllocateNode (PARSEOP_INTEGER); - RootOp = TrAllocateNode (PARSEOP_RAW_DATA); - RootOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; - RootOp->Asl.AmlLength = ObjDesc->Buffer.Length; - RootOp->Asl.Value.String = (char *) ObjDesc->Buffer.Pointer; - RootOp->Asl.Parent = Op->Asl.Parent; + RootOp->Asl.AmlOpcode = AML_DWORD_OP; + RootOp->Asl.Value.Integer = ObjDesc->Buffer.Length; + RootOp->Asl.Parent = Op; - Op->Asl.Next = RootOp; - Op = RootOp; + (void) OpcSetOptimalIntegerSize (RootOp); - DbgPrint (ASL_PARSE_OUTPUT, - "Constant expression reduced to (BUFFER) length %X\n", - ObjDesc->Buffer.Length); - break; + Op->Asl.Child = RootOp; + Op = RootOp; + UtSetParseOpName (Op); - default: + /* Peer to the child is the raw buffer data */ - printf ("Unsupported return type: %s\n", - AcpiUtGetObjectTypeName (ObjDesc)); - break; - } - } + RootOp = TrAllocateNode (PARSEOP_RAW_DATA); + RootOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; + RootOp->Asl.AmlLength = ObjDesc->Buffer.Length; + RootOp->Asl.Value.String = (char *) ObjDesc->Buffer.Pointer; + RootOp->Asl.Parent = Op->Asl.Parent; - UtSetParseOpName (Op); - Op->Asl.Child = NULL; + Op->Asl.Next = RootOp; + Op = RootOp; - AcpiDsDeleteWalkState (WalkState); - return (AE_CTRL_DEPTH); + DbgPrint (ASL_PARSE_OUTPUT, + "Constant expression reduced to (BUFFER) length %X\n\n", + ObjDesc->Buffer.Length); + break; + + default: + break; + } } @@ -511,10 +631,11 @@ OpcAmlConstantWalk ( * FUNCTION: OpcUpdateIntegerNode * * PARAMETERS: Op - Current parse object + * Value - Value for the integer op * * RETURN: None * - * DESCRIPTION: Update node to the correct integer type. + * DESCRIPTION: Update node to the correct Integer type and value * ******************************************************************************/ @@ -566,3 +687,98 @@ OpcUpdateIntegerNode ( Op->Asl.AmlLength = 0; } + + +/******************************************************************************* + * + * FUNCTION: OpcAmlEvaluationWalk1 + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Descending callback for AML execution of constant subtrees + * + ******************************************************************************/ + +static ACPI_STATUS +OpcAmlEvaluationWalk1 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ACPI_WALK_STATE *WalkState = Context; + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *OutOp; + + + WalkState->Op = Op; + WalkState->Opcode = Op->Common.AmlOpcode; + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + + /* Copy child pointer to Arg for compatibility with Interpreter */ + + if (Op->Asl.Child) + { + Op->Common.Value.Arg = Op->Asl.Child; + } + + /* Call AML dispatcher */ + + Status = AcpiDsExecBeginOp (WalkState, &OutOp); + if (ACPI_FAILURE (Status)) + { + DbgPrint (ASL_PARSE_OUTPUT, + "%s Constant interpretation failed (1) - %s\n", + Op->Asl.ParseOpName, AcpiFormatException (Status)); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: OpcAmlEvaluationWalk2 + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback for AML execution of constant subtrees + * + ******************************************************************************/ + +static ACPI_STATUS +OpcAmlEvaluationWalk2 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ACPI_WALK_STATE *WalkState = Context; + ACPI_STATUS Status; + + + WalkState->Op = Op; + WalkState->Opcode = Op->Common.AmlOpcode; + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + + /* Copy child pointer to Arg for compatibility with Interpreter */ + + if (Op->Asl.Child) + { + Op->Common.Value.Arg = Op->Asl.Child; + } + + /* Call AML dispatcher */ + + Status = AcpiDsExecEndOp (WalkState); + if (ACPI_FAILURE (Status)) + { + DbgPrint (ASL_PARSE_OUTPUT, + "%s: Constant interpretation failed (2) - %s\n", + Op->Asl.ParseOpName, AcpiFormatException (Status)); + } + + return (Status); +} diff --git a/source/compiler/asllisting.c b/source/compiler/asllisting.c index 8e107507a2c1..34277459844e 100644 --- a/source/compiler/asllisting.c +++ b/source/compiler/asllisting.c @@ -270,7 +270,10 @@ LsTreeWriteWalk ( UtPrintFormattedName (Op->Asl.ParseOpcode, Level); - DbgPrint (ASL_TREE_OUTPUT, " (%.4X)\n", Op->Asl.ParseOpcode); + DbgPrint (ASL_TREE_OUTPUT, " (%.4X) Flags %8.8X", + Op->Asl.ParseOpcode, Op->Asl.CompileFlags); + TrPrintNodeCompileFlags (Op->Asl.CompileFlags); + DbgPrint (ASL_TREE_OUTPUT, "\n"); return (AE_OK); } diff --git a/source/compiler/aslmain.c b/source/compiler/aslmain.c index 4b0848b85fa4..447b8cb5b5a7 100644 --- a/source/compiler/aslmain.c +++ b/source/compiler/aslmain.c @@ -187,6 +187,7 @@ Usage ( ACPI_OPTION ("-db", "Do not translate Buffers to Resource Templates"); ACPI_OPTION ("-dc <f1 f2 ...>", "Disassemble AML and immediately compile it"); ACPI_OPTION ("", " (Obtain DSDT from current system if no input file)"); + ACPI_OPTION ("-df", "Force disassembler to assume table contains valid AML"); ACPI_OPTION ("-dl", "Emit legacy ASL code only (no C-style operators)"); ACPI_OPTION ("-e <f1 f2 ...>", "Include ACPI table(s) for external symbol resolution"); ACPI_OPTION ("-fe <file>", "Specify external symbol declaration file"); diff --git a/source/compiler/aslmap.c b/source/compiler/aslmap.c index 61873d718dfb..ade717389bf8 100644 --- a/source/compiler/aslmap.c +++ b/source/compiler/aslmap.c @@ -222,7 +222,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* EXTENDEDIO */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* EXTENDEDMEMORY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* EXTENDEDSPACE */ OP_TABLE_ENTRY (AML_RAW_DATA_QWORD, 0, 0, ACPI_BTYPE_INTEGER), -/* EXTERNAL */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), +/* EXTERNAL */ OP_TABLE_ENTRY (AML_EXTERNAL_OP, 0, 0, 0), /* FATAL */ OP_TABLE_ENTRY (AML_FATAL_OP, 0, 0, 0), /* FIELD */ OP_TABLE_ENTRY (AML_FIELD_OP, 0, NODE_AML_PACKAGE, 0), /* FINDSETLEFTBIT */ OP_TABLE_ENTRY (AML_FIND_SET_LEFT_BIT_OP, 0, 0, ACPI_BTYPE_INTEGER), diff --git a/source/compiler/aslmapenter.c b/source/compiler/aslmapenter.c index ce726c4d4bd2..652871d860c3 100644 --- a/source/compiler/aslmapenter.c +++ b/source/compiler/aslmapenter.c @@ -216,6 +216,7 @@ MpCreateGpioInfo ( ACPI_GPIO_INFO *Info; ACPI_GPIO_INFO *NextGpio; ACPI_GPIO_INFO *PrevGpio; + char *Buffer; /* @@ -223,8 +224,8 @@ MpCreateGpioInfo ( * sorted by both source device name and then the pin number. There is * one block per pin. */ - Info = ACPI_CAST_PTR (ACPI_GPIO_INFO, - UtStringCacheCalloc (sizeof (ACPI_GPIO_INFO))); + Buffer = UtStringCacheCalloc (sizeof (ACPI_GPIO_INFO)); + Info = ACPI_CAST_PTR (ACPI_GPIO_INFO, Buffer); NextGpio = Gbl_GpioList; PrevGpio = NULL; @@ -293,14 +294,15 @@ MpCreateSerialInfo ( ACPI_SERIAL_INFO *Info; ACPI_SERIAL_INFO *NextSerial; ACPI_SERIAL_INFO *PrevSerial; + char *Buffer; /* * Allocate a new info block and insert it into the global Serial list * sorted by both source device name and then the address. */ - Info = ACPI_CAST_PTR (ACPI_SERIAL_INFO, - UtStringCacheCalloc (sizeof (ACPI_SERIAL_INFO))); + Buffer = UtStringCacheCalloc (sizeof (ACPI_SERIAL_INFO)); + Info = ACPI_CAST_PTR (ACPI_SERIAL_INFO, Buffer); NextSerial = Gbl_SerialList; PrevSerial = NULL; diff --git a/source/compiler/asloptions.c b/source/compiler/asloptions.c index 514a3ee96f31..51aae7a41ae1 100644 --- a/source/compiler/asloptions.c +++ b/source/compiler/asloptions.c @@ -274,6 +274,11 @@ AslDoOptions ( break; + case 'f': + + AcpiGbl_ForceAmlDisassembly = TRUE; + break; + case 'l': /* Use legacy ASL code (not ASL+) for disassembly */ Gbl_DoCompile = FALSE; diff --git a/source/compiler/aslrules.y b/source/compiler/aslrules.y index 67f0413d0726..dbe0882ca8b5 100644 --- a/source/compiler/aslrules.y +++ b/source/compiler/aslrules.y @@ -130,7 +130,7 @@ Expression : PARSEOP_EXP_LOGICAL_NOT {$<n>$ = TrCreateLeafNode (PARSEOP_LNOT);} TermArg {$$ = TrLinkChildren ($<n>2,1,$3);} | PARSEOP_EXP_NOT {$<n>$ = TrCreateLeafNode (PARSEOP_NOT);} - TermArg {$$ = TrLinkChildren ($<n>2,2,$3,TrCreateLeafNode (PARSEOP_ZERO));} + TermArg {$$ = TrLinkChildren ($<n>2,2,$3,TrCreateNullTarget ());} | SuperName PARSEOP_EXP_INCREMENT {$<n>$ = TrCreateLeafNode (PARSEOP_INCREMENT);} {$$ = TrLinkChildren ($<n>3,1,$1);} @@ -140,27 +140,27 @@ Expression /* Binary operators: math and logical */ | TermArg PARSEOP_EXP_ADD {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} | TermArg PARSEOP_EXP_DIVIDE {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} - TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateLeafNode (PARSEOP_ZERO), - TrCreateLeafNode (PARSEOP_ZERO));} + TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateNullTarget (), + TrCreateNullTarget ());} | TermArg PARSEOP_EXP_MODULO {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} | TermArg PARSEOP_EXP_MULTIPLY {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} | TermArg PARSEOP_EXP_SHIFT_LEFT {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} | TermArg PARSEOP_EXP_SHIFT_RIGHT {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} | TermArg PARSEOP_EXP_SUBTRACT {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} | TermArg PARSEOP_EXP_AND {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} | TermArg PARSEOP_EXP_OR {$<n>$ = TrCreateLeafNode (PARSEOP_OR);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} | TermArg PARSEOP_EXP_XOR {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);} - TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateLeafNode (PARSEOP_ZERO));} + TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} | TermArg PARSEOP_EXP_GREATER {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);} TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} @@ -198,7 +198,7 @@ EqualsTerm TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} | TermArg PARSEOP_EXP_DIV_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} - TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateLeafNode (PARSEOP_ZERO), + TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateNullTarget (), TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} | TermArg PARSEOP_EXP_MOD_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);} @@ -247,11 +247,10 @@ TermList Term : Object {} - | Expression {} | Type1Opcode {} | Type2Opcode {} - | Type2IntegerOpcode {} - | Type2StringOpcode {} + | Type2IntegerOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} + | Type2StringOpcode {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} | Type2BufferOpcode {} | Type2BufferOrStringOpcode {} | error {$$ = AslDoError(); yyclearin;} @@ -332,7 +331,7 @@ NameSpaceModifier | ScopeTerm {} ; -UserTerm +MethodInvocationTerm : NameString '(' {TrUpdateNode (PARSEOP_METHODCALL, $1);} ArgList ')' {$$ = TrLinkChildNode ($1,$4);} ; @@ -355,8 +354,7 @@ Removed from TermArg due to reduce/reduce conflicts */ TermArg - : Expression {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} - | Type2Opcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} + : Type2Opcode {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} | DataObject {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} | NameString {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} | ArgTerm {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);} @@ -364,8 +362,8 @@ TermArg ; Target - : {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_TARGET | NODE_COMPILE_TIME_CONST);} /* Placeholder is a ZeroOp object */ - | ',' {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_TARGET | NODE_COMPILE_TIME_CONST);} /* Placeholder is a ZeroOp object */ + : {$$ = TrCreateNullTarget ();} /* Placeholder is a ZeroOp object */ + | ',' {$$ = TrCreateNullTarget ();} /* Placeholder is a ZeroOp object */ | ',' SuperName {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);} ; @@ -453,7 +451,7 @@ Type2Opcode | EqualsTerm {} | TimerTerm {} | WaitTerm {} - | UserTerm {} + | MethodInvocationTerm {} ; /* @@ -461,7 +459,8 @@ Type2Opcode */ Type2IntegerOpcode /* "Type3" opcodes */ - : AddTerm {} + : Expression {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} + | AddTerm {} | AndTerm {} | DecTerm {} | DivideTerm {} @@ -507,7 +506,7 @@ Type2BufferOpcode /* "Type5" Opcodes */ ; Type2BufferOrStringOpcode - : ConcatTerm {} + : ConcatTerm {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);} | PrintfTerm {} | FprintfTerm {} | MidTerm {} @@ -543,7 +542,7 @@ Type6Opcode : RefOfTerm {} | DerefOfTerm {} | IndexTerm {} - | UserTerm {} + | MethodInvocationTerm {} ; IncludeTerm @@ -1920,7 +1919,7 @@ SuperName | DebugTerm {} | Type6Opcode {} -/* For ObjectType: SuperName except for UserTerm (method invocation) */ +/* For ObjectType: SuperName except for MethodInvocationTerm */ ObjectTypeName : NameString {} @@ -1931,7 +1930,7 @@ ObjectTypeName | DerefOfTerm {} | IndexTerm {} -/* | UserTerm {} */ /* Caused reduce/reduce with Type6Opcode->UserTerm */ +/* | MethodInvocationTerm {} */ /* Caused reduce/reduce with Type6Opcode->MethodInvocationTerm */ ; ArgTerm diff --git a/source/compiler/aslstartup.c b/source/compiler/aslstartup.c index dcea76d22158..b25dd32926f1 100644 --- a/source/compiler/aslstartup.c +++ b/source/compiler/aslstartup.c @@ -248,7 +248,7 @@ AslDoDisassembly ( /* This is where the disassembly happens */ - AcpiGbl_DbOpt_disasm = TRUE; + AcpiGbl_DbOpt_Disasm = TRUE; Status = AdAmlDisassemble (AslToFile, Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_OutputFilenamePrefix, &Gbl_Files[ASL_FILE_INPUT].Filename); diff --git a/source/compiler/asltree.c b/source/compiler/asltree.c index b0efc9a738ed..c76720a4da99 100644 --- a/source/compiler/asltree.c +++ b/source/compiler/asltree.c @@ -55,10 +55,6 @@ static ACPI_PARSE_OBJECT * TrGetNextNode ( void); -static char * -TrGetNodeFlagName ( - UINT32 Flags); - /******************************************************************************* * @@ -187,7 +183,7 @@ TrUpdateNode ( } DbgPrint (ASL_PARSE_OUTPUT, - "\nUpdateNode: Old - %s, New - %s\n\n", + "\nUpdateNode: Old - %s, New - %s\n", UtGetOpName (Op->Asl.ParseOpcode), UtGetOpName (ParseOpcode)); @@ -261,90 +257,140 @@ TrUpdateNode ( /******************************************************************************* * - * FUNCTION: TrGetNodeFlagName + * FUNCTION: TrPrintNodeCompileFlags * * PARAMETERS: Flags - Flags word to be decoded * - * RETURN: Name string. Always returns a valid string pointer. + * RETURN: None * - * DESCRIPTION: Decode a flags word + * DESCRIPTION: Decode a flags word to text. Displays all flags that are set. * ******************************************************************************/ -static char * -TrGetNodeFlagName ( +void +TrPrintNodeCompileFlags ( UINT32 Flags) { + UINT32 i; + UINT32 FlagBit = 1; + char *FlagName = NULL; + - switch (Flags) + for (i = 0; i < 32; i++) { - case NODE_VISITED: + switch (Flags & FlagBit) + { + case NODE_VISITED: + + FlagName = "NODE_VISITED"; + break; + + case NODE_AML_PACKAGE: - return ("NODE_VISITED"); + FlagName = "NODE_AML_PACKAGE"; + break; + + case NODE_IS_TARGET: + + FlagName = "NODE_IS_TARGET"; + break; + + case NODE_IS_RESOURCE_DESC: - case NODE_AML_PACKAGE: + FlagName = "NODE_IS_RESOURCE_DESC"; + break; + + case NODE_IS_RESOURCE_FIELD: + + FlagName = "NODE_IS_RESOURCE_FIELD"; + break; - return ("NODE_AML_PACKAGE"); + case NODE_HAS_NO_EXIT: - case NODE_IS_TARGET: + FlagName = "NODE_HAS_NO_EXIT"; + break; - return ("NODE_IS_TARGET"); + case NODE_IF_HAS_NO_EXIT: - case NODE_IS_RESOURCE_DESC: + FlagName = "NODE_IF_HAS_NO_EXIT"; + break; - return ("NODE_IS_RESOURCE_DESC"); + case NODE_NAME_INTERNALIZED: - case NODE_IS_RESOURCE_FIELD: + FlagName = "NODE_NAME_INTERNALIZED"; + break; - return ("NODE_IS_RESOURCE_FIELD"); + case NODE_METHOD_NO_RETVAL: - case NODE_HAS_NO_EXIT: + FlagName = "NODE_METHOD_NO_RETVAL"; + break; - return ("NODE_HAS_NO_EXIT"); + case NODE_METHOD_SOME_NO_RETVAL: - case NODE_IF_HAS_NO_EXIT: + FlagName = "NODE_METHOD_SOME_NO_RETVAL"; + break; - return ("NODE_IF_HAS_NO_EXIT"); + case NODE_RESULT_NOT_USED: - case NODE_NAME_INTERNALIZED: + FlagName = "NODE_RESULT_NOT_USED"; + break; - return ("NODE_NAME_INTERNALIZED"); + case NODE_METHOD_TYPED: - case NODE_METHOD_NO_RETVAL: + FlagName = "NODE_METHOD_TYPED"; + break; - return ("NODE_METHOD_NO_RETVAL"); + case NODE_COMPILE_TIME_CONST: - case NODE_METHOD_SOME_NO_RETVAL: + FlagName = "NODE_COMPILE_TIME_CONST"; + break; - return ("NODE_METHOD_SOME_NO_RETVAL"); + case NODE_IS_TERM_ARG: - case NODE_RESULT_NOT_USED: + FlagName = "NODE_IS_TERM_ARG"; + break; - return ("NODE_RESULT_NOT_USED"); + case NODE_WAS_ONES_OP: - case NODE_METHOD_TYPED: + FlagName = "NODE_WAS_ONES_OP"; + break; - return ("NODE_METHOD_TYPED"); + case NODE_IS_NAME_DECLARATION: - case NODE_COMPILE_TIME_CONST: + FlagName = "NODE_IS_NAME_DECLARATION"; + break; - return ("NODE_COMPILE_TIME_CONST"); + case NODE_COMPILER_EMITTED: - case NODE_IS_TERM_ARG: + FlagName = "NODE_COMPILER_EMITTED"; + break; - return ("NODE_IS_TERM_ARG"); + case NODE_IS_DUPLICATE: - case NODE_WAS_ONES_OP: + FlagName = "NODE_IS_DUPLICATE"; + break; - return ("NODE_WAS_ONES_OP"); + case NODE_IS_RESOURCE_DATA: - case NODE_IS_NAME_DECLARATION: + FlagName = "NODE_IS_RESOURCE_DATA"; + break; - return ("NODE_IS_NAME_DECLARATION"); + case NODE_IS_NULL_RETURN: - default: + FlagName = "NODE_IS_NULL_RETURN"; + break; - return ("Multiple Flags (or unknown flag) set"); + default: + break; + } + + if (FlagName) + { + DbgPrint (ASL_PARSE_OUTPUT, " %s", FlagName); + FlagName = NULL; + } + + FlagBit <<= 1; } } @@ -368,15 +414,17 @@ TrSetNodeFlags ( UINT32 Flags) { - DbgPrint (ASL_PARSE_OUTPUT, - "\nSetNodeFlags: Op %p, %8.8X %s\n\n", Op, Flags, - TrGetNodeFlagName (Flags)); - if (!Op) { return (NULL); } + DbgPrint (ASL_PARSE_OUTPUT, + "\nSetNodeFlags: %s Op %p, %8.8X", Op->Asl.ParseOpName, Op, Flags); + + TrPrintNodeCompileFlags (Flags); + DbgPrint (ASL_PARSE_OUTPUT, "\n\n"); + Op->Asl.CompileFlags |= Flags; return (Op); } @@ -588,7 +636,40 @@ TrCreateLeafNode ( DbgPrint (ASL_PARSE_OUTPUT, "\nCreateLeafNode Ln/Col %u/%u NewNode %p Op %s\n\n", - Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName(ParseOpcode)); + Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName (ParseOpcode)); + + return (Op); +} + + +/******************************************************************************* + * + * FUNCTION: TrCreateNullTarget + * + * PARAMETERS: None + * + * RETURN: Pointer to the new node. Aborts on allocation failure + * + * DESCRIPTION: Create a "null" target node. This is defined by the ACPI + * specification to be a zero AML opcode, and indicates that + * no target has been specified for the parent operation + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +TrCreateNullTarget ( + void) +{ + ACPI_PARSE_OBJECT *Op; + + + Op = TrAllocateNode (PARSEOP_ZERO); + Op->Asl.CompileFlags |= (NODE_IS_TARGET | NODE_COMPILE_TIME_CONST); + + DbgPrint (ASL_PARSE_OUTPUT, + "\nCreateNullTarget Ln/Col %u/%u NewNode %p Op %s\n", + Op->Asl.LineNumber, Op->Asl.Column, Op, + UtGetOpName (Op->Asl.ParseOpcode)); return (Op); } @@ -620,7 +701,6 @@ TrCreateConstantLeafNode ( time_t CurrentTime; char *StaticTimeString; char *TimeString; - char *Path; char *Filename; @@ -647,7 +727,7 @@ TrCreateConstantLeafNode ( /* Get the simple filename from the full path */ - FlSplitInputPathname (Op->Asl.Filename, &Path, &Filename); + FlSplitInputPathname (Op->Asl.Filename, NULL, &Filename); Op->Asl.Value.String = Filename; break; @@ -672,7 +752,7 @@ TrCreateConstantLeafNode ( } DbgPrint (ASL_PARSE_OUTPUT, - "\nCreateConstantLeafNode Ln/Col %u/%u NewNode %p Op %s Value %8.8X%8.8X ", + "\nCreateConstantLeafNode Ln/Col %u/%u NewNode %p Op %s Value %8.8X%8.8X \n", Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName (ParseOpcode), ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer)); return (Op); @@ -813,7 +893,8 @@ TrCreateValuedLeafNode ( case PARSEOP_INTEGER: - DbgPrint (ASL_PARSE_OUTPUT, "INTEGER"); + DbgPrint (ASL_PARSE_OUTPUT, "INTEGER->%8.8X%8.8X", + ACPI_FORMAT_UINT64 (Value)); break; default: @@ -948,7 +1029,7 @@ TrCreateNode ( } va_end(ap); - DbgPrint (ASL_PARSE_OUTPUT, "\n\n"); + DbgPrint (ASL_PARSE_OUTPUT, "\n"); return (Op); } @@ -1104,7 +1185,7 @@ TrLinkPeerNode ( DbgPrint (ASL_PARSE_OUTPUT, - "\nLinkPeerNode: 1=%p (%s), 2=%p (%s)\n\n", + "\nLinkPeerNode: 1=%p (%s), 2=%p (%s)\n", Op1, Op1 ? UtGetOpName(Op1->Asl.ParseOpcode) : NULL, Op2, Op2 ? UtGetOpName(Op2->Asl.ParseOpcode) : NULL); @@ -1130,7 +1211,7 @@ TrLinkPeerNode ( if (Op1 == Op2) { DbgPrint (ASL_DEBUG_OUTPUT, - "\n\n************* Internal error, linking node to itself %p\n\n\n", + "\n************* Internal error, linking node to itself %p\n", Op1); AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op1, "Linking node to itself"); @@ -1214,7 +1295,7 @@ TrLinkPeerNodes ( } va_end (ap); - DbgPrint (ASL_PARSE_OUTPUT,"\n\n"); + DbgPrint (ASL_PARSE_OUTPUT,"\n"); return (Start); } @@ -1241,7 +1322,7 @@ TrLinkChildNode ( DbgPrint (ASL_PARSE_OUTPUT, - "\nLinkChildNode: Parent=%p (%s), Child=%p (%s)\n\n", + "\nLinkChildNode: Parent=%p (%s), Child=%p (%s)\n", Op1, Op1 ? UtGetOpName(Op1->Asl.ParseOpcode): NULL, Op2, Op2 ? UtGetOpName(Op2->Asl.ParseOpcode): NULL); diff --git a/source/compiler/asltypes.y b/source/compiler/asltypes.y index 3177d1d52a78..650b8561527b 100644 --- a/source/compiler/asltypes.y +++ b/source/compiler/asltypes.y @@ -74,7 +74,7 @@ NoEcho(' %type <n> Term %type <n> TermArg %type <n> TermList -%type <n> UserTerm +%type <n> MethodInvocationTerm /* Type4Opcode is obsolete */ diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index 519afbc04bf6..4d3edc059401 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -503,8 +503,13 @@ UtDisplaySummary ( if (Gbl_FileType != ASL_INPUT_TYPE_ASCII_DATA) { - FlPrintFile (FileId, - ", %u Optimizations", Gbl_ExceptionCount[ASL_OPTIMIZATION]); + FlPrintFile (FileId, ", %u Optimizations", + Gbl_ExceptionCount[ASL_OPTIMIZATION]); + + if (TotalFolds) + { + FlPrintFile (FileId, ", %u Constants Folded", TotalFolds); + } } FlPrintFile (FileId, "\n"); diff --git a/source/compiler/aslwalks.c b/source/compiler/aslwalks.c index 7f78cafaab4c..bbc15c598a4f 100644 --- a/source/compiler/aslwalks.c +++ b/source/compiler/aslwalks.c @@ -252,6 +252,13 @@ AnOperandTypecheckWalkEnd ( } return (AE_OK); + case AML_EXTERNAL_OP: + /* + * Not really a "runtime" opcode since it used by disassembler only. + * The parser will find any issues with the operands. + */ + return (AE_OK); + default: break; @@ -388,9 +395,6 @@ AnOperandTypecheckWalkEnd ( break; case PARSEOP_DEBUG: - - break; - case PARSEOP_REFOF: case PARSEOP_INDEX: default: diff --git a/source/compiler/dtcompile.c b/source/compiler/dtcompile.c index 1c4a7082425a..0b949191570d 100644 --- a/source/compiler/dtcompile.c +++ b/source/compiler/dtcompile.c @@ -102,13 +102,18 @@ DtDoCompile ( /* Preprocessor */ - Event = UtBeginEvent ("Preprocess input file"); - PrDoPreprocess (); - UtEndEvent (Event); - - if (Gbl_PreprocessOnly) + if (Gbl_PreprocessFlag) { - return (AE_OK); + /* Preprocessor */ + + Event = UtBeginEvent ("Preprocess input file"); + PrDoPreprocess (); + UtEndEvent (Event); + + if (Gbl_PreprocessOnly) + { + return (AE_OK); + } } /* diff --git a/source/compiler/dtcompiler.h b/source/compiler/dtcompiler.h index b14c4c716d05..c6097ff56524 100644 --- a/source/compiler/dtcompiler.h +++ b/source/compiler/dtcompiler.h @@ -85,15 +85,16 @@ */ typedef struct dt_field { - char *Name; /* Field name (from name : value) */ - char *Value; /* Field value (from name : value) */ - struct dt_field *Next; /* Next field */ - struct dt_field *NextLabel; /* If field is a label, next label */ - UINT32 Line; /* Line number for this field */ - UINT32 ByteOffset; /* Offset in source file for field */ - UINT32 NameColumn; /* Start column for field name */ - UINT32 Column; /* Start column for field value */ - UINT32 TableOffset;/* Binary offset within ACPI table */ + char *Name; /* Field name (from name : value) */ + char *Value; /* Field value (from name : value) */ + UINT32 StringLength;/* Length of Value */ + struct dt_field *Next; /* Next field */ + struct dt_field *NextLabel; /* If field is a label, next label */ + UINT32 Line; /* Line number for this field */ + UINT32 ByteOffset; /* Offset in source file for field */ + UINT32 NameColumn; /* Start column for field name */ + UINT32 Column; /* Start column for field value */ + UINT32 TableOffset; /* Binary offset within ACPI table */ UINT8 Flags; } DT_FIELD; @@ -557,6 +558,7 @@ extern const unsigned char TemplateMcfg[]; extern const unsigned char TemplateMchi[]; extern const unsigned char TemplateMpst[]; extern const unsigned char TemplateMsct[]; +extern const unsigned char TemplateMsdm[]; extern const unsigned char TemplateMtmr[]; extern const unsigned char TemplatePcct[]; extern const unsigned char TemplatePmtt[]; diff --git a/source/compiler/dtio.c b/source/compiler/dtio.c index f2f7c22478a4..98837d5c292c 100644 --- a/source/compiler/dtio.c +++ b/source/compiler/dtio.c @@ -375,6 +375,7 @@ DtParseLine ( Field->ByteOffset = Offset; Field->NameColumn = NameColumn; Field->Column = Column; + Field->StringLength = Length; DtLinkField (Field); } @@ -414,6 +415,7 @@ DtGetNextLine ( int c; + ACPI_MEMSET (Gbl_CurrentLineBuffer, 0, Gbl_LineBufferSize); for (i = 0; ;) { /* @@ -939,11 +941,11 @@ DtDumpFieldList ( DbgPrint (ASL_DEBUG_OUTPUT, "\nField List:\n" "LineNo ByteOff NameCol Column TableOff " - "Flags %32s : %s\n\n", "Name", "Value"); + "Flags %32s : %s\n\n", "Name", "Value"); while (Field) { DbgPrint (ASL_DEBUG_OUTPUT, - "%.08X %.08X %.08X %.08X %.08X %.08X %32s : %s\n", + "%.08X %.08X %.08X %.08X %.08X %2.2X %32s : %s\n", Field->Line, Field->ByteOffset, Field->NameColumn, Field->Column, Field->TableOffset, Field->Flags, Field->Name, Field->Value); diff --git a/source/compiler/dttable.c b/source/compiler/dttable.c index 20444fb9b6f2..438a3ed6c630 100644 --- a/source/compiler/dttable.c +++ b/source/compiler/dttable.c @@ -2240,15 +2240,11 @@ DtCompileSlic ( DT_SUBTABLE *Subtable; DT_SUBTABLE *ParentTable; DT_FIELD **PFieldList = (DT_FIELD **) List; - DT_FIELD *SubtableStart; - ACPI_SLIC_HEADER *SlicHeader; - ACPI_DMTABLE_INFO *InfoTable; while (*PFieldList) { - SubtableStart = *PFieldList; - Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlicHdr, + Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlic, &Subtable, TRUE); if (ACPI_FAILURE (Status)) { @@ -2258,35 +2254,6 @@ DtCompileSlic ( ParentTable = DtPeekSubtable (); DtInsertSubtable (ParentTable, Subtable); DtPushSubtable (Subtable); - - SlicHeader = ACPI_CAST_PTR (ACPI_SLIC_HEADER, Subtable->Buffer); - - switch (SlicHeader->Type) - { - case ACPI_SLIC_TYPE_PUBLIC_KEY: - - InfoTable = AcpiDmTableInfoSlic0; - break; - - case ACPI_SLIC_TYPE_WINDOWS_MARKER: - - InfoTable = AcpiDmTableInfoSlic1; - break; - - default: - - DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SLIC"); - return (AE_ERROR); - } - - Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - ParentTable = DtPeekSubtable (); - DtInsertSubtable (ParentTable, Subtable); DtPopSubtable (); } diff --git a/source/compiler/dttemplate.h b/source/compiler/dttemplate.h index 0398d696df20..39be761764ec 100644 --- a/source/compiler/dttemplate.h +++ b/source/compiler/dttemplate.h @@ -662,6 +662,23 @@ const unsigned char TemplateMchi[] = 0x00,0x00,0x00,0x00,0x00 /* 00000040 "....." */ }; +const unsigned char TemplateMsdm[] = +{ + 0x4D,0x53,0x44,0x4D,0x64,0x00,0x00,0x00, /* 00000000 "MSDMd..." */ + 0x01,0x34,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 ".4Intel." */ + 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */ + 0x03,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x04,0x02,0x15,0x20,0x00,0x00,0x00,0x00, /* 00000020 "... ...." */ + 0x0A,0x10,0x16,0x17,0x18,0x19,0x1A,0x1B, /* 00000028 "........" */ + 0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22,0x23, /* 00000030 ".... !"#" */ + 0x24,0x25,0x26,0x27,0x10,0x0A,0x15,0x16, /* 00000038 "$%&'...." */ + 0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E, /* 00000040 "........" */ + 0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26, /* 00000048 ". !"#$%&" */ + 0x16,0x15,0x0A,0x10,0x16,0x17,0x18,0x19, /* 00000050 "........" */ + 0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21, /* 00000058 "...... !" */ + 0x22,0x23,0x24,0x25 /* 00000060 ""#$%" */ +}; + const unsigned char TemplateMpst[] = { 0x4D,0x50,0x53,0x54,0xB6,0x00,0x00,0x00, /* 00000000 "MPST...." */ diff --git a/source/compiler/dtutils.c b/source/compiler/dtutils.c index fbaa2be138fb..411ab0015470 100644 --- a/source/compiler/dtutils.c +++ b/source/compiler/dtutils.c @@ -364,6 +364,7 @@ DtGetFieldType ( break; case ACPI_DMT_BUFFER: + case ACPI_DMT_RAW_BUFFER: case ACPI_DMT_BUF7: case ACPI_DMT_BUF10: case ACPI_DMT_BUF16: @@ -531,7 +532,6 @@ DtGetFieldLength ( case ACPI_DMT_UINT32: case ACPI_DMT_NAME4: - case ACPI_DMT_SLIC: case ACPI_DMT_SIG: case ACPI_DMT_LPIT: @@ -588,6 +588,7 @@ DtGetFieldLength ( break; case ACPI_DMT_BUFFER: + case ACPI_DMT_RAW_BUFFER: Value = DtGetFieldValue (Field); if (Value) |