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/aslfold.c | |
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/aslfold.c')
-rw-r--r-- | source/compiler/aslfold.c | 706 |
1 files changed, 461 insertions, 245 deletions
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); +} |