Automated cleanup

date	2004.10.15.22.35.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 17:10:27 +00:00
parent 9f315cfa79
commit f6ff8128aa
2 changed files with 175 additions and 72 deletions

View File

@ -1,7 +1,7 @@
/*******************************************************************************
*
* Module Name: dsutils - Dispatcher utilities
* $Revision: 1.106 $
* $Revision: 1.107 $
*
******************************************************************************/
@ -163,7 +163,7 @@ AcpiDsIsResultUsed (
}
/*
* If there is no parent, we are executing at the method level.
* If there is no parent, we are executing at the method level.
* An executing method typically has no parent, since each method
* is parsed separately.
*/
@ -172,7 +172,7 @@ AcpiDsIsResultUsed (
/*
* If this is the last statement in the method, we know it is not a
* Return() operator (would not come here.) The following code is the
* optional support for a so-called "implicit return". Some AML code
* optional support for a so-called "implicit return". Some AML code
* assumes that the last value of the method is "implicitly" returned
* to the caller. Just save the last result as the return value.
* NOTE: this is optional because the ASL language does not actually
@ -181,7 +181,7 @@ AcpiDsIsResultUsed (
if ((AcpiGbl_EnableInterpreterSlack) &&
(WalkState->ParserState.Aml >= WalkState->ParserState.AmlEnd))
{
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Result of [%s] will be implicitly returned\n",
AcpiPsGetOpcodeName (Op->Common.AmlOpcode)));

View File

@ -2,7 +2,7 @@
*
* Module Name: dswexec - Dispatcher method execution callbacks;
* dispatch to interpreter.
* $Revision: 1.85 $
* $Revision: 1.112 $
*
*****************************************************************************/
@ -10,7 +10,7 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
* All rights reserved.
*
* 2. License
@ -124,26 +124,28 @@
#include "acinterp.h"
#include "acnamesp.h"
#include "acdebug.h"
#include "acdisasm.h"
#define _COMPONENT ACPI_DISPATCHER
MODULE_NAME ("dswexec")
ACPI_MODULE_NAME ("dswexec")
/*
* Dispatch table for opcode classes
*/
ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] = {
AcpiExOpcode_1A_0T_0R,
AcpiExOpcode_1A_0T_1R,
AcpiExOpcode_1A_1T_0R,
AcpiExOpcode_1A_1T_1R,
AcpiExOpcode_2A_0T_0R,
AcpiExOpcode_2A_0T_1R,
AcpiExOpcode_2A_1T_1R,
AcpiExOpcode_2A_2T_1R,
AcpiExOpcode_3A_0T_0R,
AcpiExOpcode_3A_1T_1R,
AcpiExOpcode_6A_0T_1R};
static ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] = {
AcpiExOpcode_0A_0T_1R,
AcpiExOpcode_1A_0T_0R,
AcpiExOpcode_1A_0T_1R,
AcpiExOpcode_1A_1T_0R,
AcpiExOpcode_1A_1T_1R,
AcpiExOpcode_2A_0T_0R,
AcpiExOpcode_2A_0T_1R,
AcpiExOpcode_2A_1T_1R,
AcpiExOpcode_2A_2T_1R,
AcpiExOpcode_3A_0T_0R,
AcpiExOpcode_3A_1T_1R,
AcpiExOpcode_6A_0T_1R};
/*****************************************************************************
*
@ -160,18 +162,18 @@ ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] = {
ACPI_STATUS
AcpiDsGetPredicateValue (
ACPI_WALK_STATE *WalkState,
UINT32 HasResultObj)
ACPI_OPERAND_OBJECT *ResultObj)
{
ACPI_STATUS Status = AE_OK;
ACPI_OPERAND_OBJECT *ObjDesc;
FUNCTION_TRACE_PTR ("DsGetPredicateValue", WalkState);
ACPI_FUNCTION_TRACE_PTR ("DsGetPredicateValue", WalkState);
WalkState->ControlState->Common.State = 0;
if (HasResultObj)
if (ResultObj)
{
Status = AcpiDsResultPop (&ObjDesc, WalkState);
if (ACPI_FAILURE (Status))
@ -212,11 +214,11 @@ AcpiDsGetPredicateValue (
* Result of predicate evaluation currently must
* be a number
*/
if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Bad predicate (not a number) ObjDesc=%p State=%p Type=%X\n",
ObjDesc, WalkState, ObjDesc->Common.Type));
ObjDesc, WalkState, ACPI_GET_OBJECT_TYPE (ObjDesc)));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
@ -224,7 +226,7 @@ AcpiDsGetPredicateValue (
/* Truncate the predicate to 32-bits if necessary */
AcpiExTruncateFor32bitTable (ObjDesc, WalkState);
AcpiExTruncateFor32bitTable (ObjDesc);
/*
* Save the result of the predicate evaluation on
@ -252,7 +254,7 @@ Cleanup:
/* Break to debugger to display result */
DEBUGGER_EXEC (AcpiDbDisplayResultObject (ObjDesc, WalkState));
ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (ObjDesc, WalkState));
/*
* Delete the predicate result object (we know that
@ -260,7 +262,7 @@ Cleanup:
*/
AcpiUtRemoveReference (ObjDesc);
WalkState->ControlState->Common.State = CONTROL_NORMAL;
WalkState->ControlState->Common.State = ACPI_CONTROL_NORMAL;
return_ACPI_STATUS (Status);
}
@ -290,7 +292,7 @@ AcpiDsExecBeginOp (
UINT32 OpcodeClass;
FUNCTION_TRACE_PTR ("DsExecBeginOp", WalkState);
ACPI_FUNCTION_TRACE_PTR ("DsExecBeginOp", WalkState);
Op = WalkState->Op;
@ -304,14 +306,19 @@ AcpiDsExecBeginOp (
Op = *OutOp;
WalkState->Op = Op;
WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode);
WalkState->Opcode = Op->Opcode;
WalkState->Opcode = Op->Common.AmlOpcode;
WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
if (AcpiNsOpensScope (WalkState->OpInfo->ObjectType))
{
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
AcpiUtGetTypeName (WalkState->OpInfo->ObjectType), Op));
AcpiDsScopeStackPop (WalkState);
Status = AcpiDsScopeStackPop (WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
}
@ -332,12 +339,12 @@ AcpiDsExecBeginOp (
*/
if ((WalkState->ControlState) &&
(WalkState->ControlState->Common.State ==
CONTROL_CONDITIONAL_EXECUTING))
ACPI_CONTROL_CONDITIONAL_EXECUTING))
{
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Exec predicate Op=%p State=%p\n",
Op, WalkState));
WalkState->ControlState->Common.State = CONTROL_PREDICATE_EXECUTING;
WalkState->ControlState->Common.State = ACPI_CONTROL_PREDICATE_EXECUTING;
/* Save start of predicate */
@ -349,7 +356,7 @@ AcpiDsExecBeginOp (
/* We want to send namepaths to the load code */
if (Op->Opcode == AML_INT_NAMEPATH_OP)
if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
{
OpcodeClass = AML_CLASS_NAMED_OBJECT;
}
@ -373,7 +380,7 @@ AcpiDsExecBeginOp (
case AML_CLASS_NAMED_OBJECT:
if (WalkState->WalkType == WALK_METHOD)
if (WalkState->WalkType == ACPI_WALK_METHOD)
{
/*
* Found a named object declaration during method
@ -385,7 +392,7 @@ AcpiDsExecBeginOp (
Status = AcpiDsLoad2BeginOp (WalkState, NULL);
}
if (Op->Opcode == AML_REGION_OP)
if (Op->Common.AmlOpcode == AML_REGION_OP)
{
Status = AcpiDsResultStackPush (WalkState);
}
@ -438,10 +445,9 @@ AcpiDsExecEndOp (
UINT32 OpClass;
ACPI_PARSE_OBJECT *NextOp;
ACPI_PARSE_OBJECT *FirstArg;
UINT32 i;
FUNCTION_TRACE_PTR ("DsExecEndOp", WalkState);
ACPI_FUNCTION_TRACE_PTR ("DsExecEndOp", WalkState);
Op = WalkState->Op;
@ -450,11 +456,11 @@ AcpiDsExecEndOp (
if (OpClass == AML_CLASS_UNKNOWN)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode %X\n", Op->Opcode));
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode %X\n", Op->Common.AmlOpcode));
return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
}
FirstArg = Op->Value.Arg;
FirstArg = Op->Common.Value.Arg;
/* Init the walk state */
@ -464,8 +470,8 @@ AcpiDsExecEndOp (
/* Call debugger for single step support (DEBUG build only) */
DEBUGGER_EXEC (Status = AcpiDbSingleStep (WalkState, Op, OpClass));
DEBUGGER_EXEC (if (ACPI_FAILURE (Status)) {return_ACPI_STATUS (Status);});
ACPI_DEBUGGER_EXEC (Status = AcpiDbSingleStep (WalkState, Op, OpClass));
ACPI_DEBUGGER_EXEC (if (ACPI_FAILURE (Status)) {return_ACPI_STATUS (Status);});
/* Decode the Opcode Class */
@ -474,7 +480,7 @@ AcpiDsExecEndOp (
case AML_CLASS_ARGUMENT: /* constants, literals, etc. -- do nothing */
break;
case AML_CLASS_EXECUTE: /* most operators with arguments */
/* Build resolved operand stack */
@ -500,7 +506,7 @@ AcpiDsExecEndOp (
WalkState);
if (ACPI_SUCCESS (Status))
{
DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE,
ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
AcpiPsGetOpcodeName (WalkState->Opcode),
WalkState->NumOperands, "after ExResolveOperands");
@ -509,28 +515,35 @@ AcpiDsExecEndOp (
* routine. There is one routine per opcode "type" based upon the
* number of opcode arguments and return type.
*/
Status = AcpiGbl_OpTypeDispatch [OpType] (WalkState);
Status = AcpiGbl_OpTypeDispatch[OpType] (WalkState);
}
else
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"[%s]: Could not resolve operands, %s\n",
AcpiPsGetOpcodeName (WalkState->Opcode),
AcpiFormatException (Status)));
/*
* Treat constructs of the form "Store(LocalX,LocalX)" as noops when the
* Local is uninitialized.
*/
if ((Status == AE_AML_UNINITIALIZED_LOCAL) &&
(WalkState->Opcode == AML_STORE_OP) &&
(WalkState->Operands[0]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
(WalkState->Operands[1]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
(WalkState->Operands[0]->Reference.Opcode ==
WalkState->Operands[1]->Reference.Opcode))
{
Status = AE_OK;
}
else
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"[%s]: Could not resolve operands, %s\n",
AcpiPsGetOpcodeName (WalkState->Opcode),
AcpiFormatException (Status)));
}
}
/* Always delete the argument objects and clear the operand stack */
for (i = 0; i < WalkState->NumOperands; i++)
{
/*
* Remove a reference to all operands, including both
* "Arguments" and "Targets".
*/
AcpiUtRemoveReference (WalkState->Operands[i]);
WalkState->Operands[i] = NULL;
}
WalkState->NumOperands = 0;
AcpiDsClearOperands (WalkState);
/*
* If a result object was returned from above, push it on the
@ -554,8 +567,12 @@ AcpiDsExecEndOp (
/* 1 Operand, 0 ExternalResult, 0 InternalResult */
Status = AcpiDsExecEndControlOp (WalkState, Op);
if (ACPI_FAILURE (Status))
{
break;
}
AcpiDsResultStackPop (WalkState);
Status = AcpiDsResultStackPop (WalkState);
break;
@ -573,7 +590,7 @@ AcpiDsExecEndOp (
/* NextOp points to first argument op */
NextOp = NextOp->Next;
NextOp = NextOp->Common.Next;
/*
* Get the method's arguments and put them on the operand stack
@ -585,13 +602,16 @@ AcpiDsExecEndOp (
}
/*
* Since the operands will be passed to another control method,
* we must resolve all local references here (Local variables,
* Since the operands will be passed to another control method,
* we must resolve all local references here (Local variables,
* arguments to *this* method, etc.)
*/
Status = AcpiDsResolveOperands (WalkState);
if (ACPI_FAILURE (Status))
{
/* On error, clear all resolved operands */
AcpiDsClearOperands (WalkState);
break;
}
@ -623,6 +643,55 @@ AcpiDsExecEndOp (
break;
case AML_TYPE_CREATE_OBJECT:
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Executing CreateObject (Buffer/Package) Op=%p\n", Op));
switch (Op->Common.Parent->Common.AmlOpcode)
{
case AML_NAME_OP:
/*
* Put the Node on the object stack (Contains the ACPI Name of
* this object)
*/
WalkState->Operands[0] = (void *) Op->Common.Parent->Common.Node;
WalkState->NumOperands = 1;
Status = AcpiDsCreateNode (WalkState, Op->Common.Parent->Common.Node, Op->Common.Parent);
if (ACPI_FAILURE (Status))
{
break;
}
/* Fall through */
/*lint -fallthrough */
case AML_INT_EVAL_SUBTREE_OP:
Status = AcpiDsEvalDataObjectOperands (WalkState, Op,
AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node));
break;
default:
Status = AcpiDsEvalDataObjectOperands (WalkState, Op, NULL);
break;
}
/*
* If a result object was returned from above, push it on the
* current result stack
*/
if (ACPI_SUCCESS (Status) &&
WalkState->ResultObj)
{
Status = AcpiDsResultPush (WalkState->ResultObj, WalkState);
}
break;
case AML_TYPE_NAMED_FIELD:
case AML_TYPE_NAMED_COMPLEX:
case AML_TYPE_NAMED_SIMPLE:
@ -634,7 +703,7 @@ AcpiDsExecEndOp (
break;
}
if (Op->Opcode == AML_REGION_OP)
if (Op->Common.AmlOpcode == AML_REGION_OP)
{
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Executing OpRegion Address/Length Op=%p\n", Op));
@ -659,7 +728,7 @@ AcpiDsExecEndOp (
case AML_TYPE_BOGUS:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Internal opcode=%X type Op=%p\n",
WalkState->Opcode, Op));
break;
@ -669,7 +738,7 @@ AcpiDsExecEndOp (
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n",
OpClass, OpType, Op->Opcode, Op));
OpClass, OpType, Op->Common.AmlOpcode, Op));
Status = AE_NOT_IMPLEMENTED;
break;
@ -677,32 +746,47 @@ AcpiDsExecEndOp (
}
/*
* ACPI 2.0 support for 64-bit integers: Truncate numeric
* ACPI 2.0 support for 64-bit integers: Truncate numeric
* result value if we are executing from a 32-bit ACPI table
*/
AcpiExTruncateFor32bitTable (WalkState->ResultObj, WalkState);
AcpiExTruncateFor32bitTable (WalkState->ResultObj);
/*
* Check if we just completed the evaluation of a
* conditional predicate
*/
if ((WalkState->ControlState) &&
if ((ACPI_SUCCESS (Status)) &&
(WalkState->ControlState) &&
(WalkState->ControlState->Common.State ==
CONTROL_PREDICATE_EXECUTING) &&
ACPI_CONTROL_PREDICATE_EXECUTING) &&
(WalkState->ControlState->Control.PredicateOp == Op))
{
Status = AcpiDsGetPredicateValue (WalkState, (UINT32) WalkState->ResultObj);
Status = AcpiDsGetPredicateValue (WalkState, WalkState->ResultObj);
WalkState->ResultObj = NULL;
}
Cleanup:
/* Invoke exception handler on error */
if (ACPI_FAILURE (Status) &&
AcpiGbl_ExceptionHandler &&
!(Status & AE_CODE_CONTROL))
{
AcpiExExitInterpreter ();
Status = AcpiGbl_ExceptionHandler (Status,
WalkState->MethodNode->Name.Integer, WalkState->Opcode,
WalkState->AmlOffset, NULL);
AcpiExEnterInterpreter ();
}
if (WalkState->ResultObj)
{
/* Break to debugger to display result */
DEBUGGER_EXEC (AcpiDbDisplayResultObject (WalkState->ResultObj, WalkState));
ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (WalkState->ResultObj, WalkState));
/*
* Delete the result op if and only if:
@ -712,9 +796,28 @@ Cleanup:
AcpiDsDeleteResultIfNotUsed (Op, WalkState->ResultObj, WalkState);
}
#ifdef _UNDER_DEVELOPMENT
if (WalkState->ParserState.Aml == WalkState->ParserState.AmlEnd)
{
AcpiDbMethodEnd (WalkState);
}
#endif
/* Always clear the object stack */
WalkState->NumOperands = 0;
#ifdef ACPI_DISASSEMBLER
/* On error, display method locals/args */
if (ACPI_FAILURE (Status))
{
AcpiDmDumpMethodInfo (Status, WalkState, Op);
}
#endif
return_ACPI_STATUS (Status);
}