Parse/dispatch support for DataTableRegion

date	2001.09.21.22.15.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 17:09:49 +00:00
parent 2af11ea087
commit 8d2af8820c
2 changed files with 149 additions and 110 deletions

View File

@ -1,7 +1,7 @@
/*******************************************************************************
*
* Module Name: dsutils - Dispatcher utilities
* $Revision: 1.69 $
* $Revision: 1.73 $
*
******************************************************************************/
@ -147,7 +147,7 @@ AcpiDsIsResultUsed (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState)
{
ACPI_OPCODE_INFO *ParentInfo;
const ACPI_OPCODE_INFO *ParentInfo;
FUNCTION_TRACE_PTR ("DsIsResultUsed", Op);
@ -192,7 +192,6 @@ AcpiDsIsResultUsed (
* Otherwise leave it as is, it will be deleted when it is used
* as an operand later.
*/
switch (ACPI_GET_OP_CLASS (ParentInfo))
{
/*
@ -206,7 +205,7 @@ AcpiDsIsResultUsed (
/* Never delete the return value associated with a return opcode */
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Result used, [RETURN] opcode=%X Op=%X\n", Op->Opcode, Op));
return_VALUE (TRUE);
break;
@ -218,7 +217,6 @@ AcpiDsIsResultUsed (
* If we are executing the predicate AND this is the predicate op,
* we will use the return value!
*/
if ((WalkState->ControlState->Common.State == CONTROL_PREDICATE_EXECUTING) &&
(WalkState->ControlState->Control.PredicateOp == Op))
{
@ -255,7 +253,7 @@ AcpiDsIsResultUsed (
return_VALUE (TRUE);
}
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Result not used, Parent opcode=%X Op=%X\n", Op->Opcode, Op));
return_VALUE (FALSE);
@ -362,7 +360,7 @@ AcpiDsCreateOperand (
UINT16 Opcode;
UINT32 Flags;
OPERATING_MODE InterpreterMode;
ACPI_OPCODE_INFO *OpInfo;
const ACPI_OPCODE_INFO *OpInfo;
FUNCTION_TRACE_PTR ("DsCreateOperand", Arg);
@ -429,7 +427,6 @@ AcpiDsCreateOperand (
* The only case where we pass through (ignore) a NOT_FOUND
* error is for the CondRefOf opcode.
*/
if (Status == AE_NOT_FOUND)
{
if (ParentOp->Opcode == AML_COND_REF_OF_OP)
@ -526,7 +523,7 @@ AcpiDsCreateOperand (
* Only error is underflow, and this indicates
* a missing or null operand!
*/
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Missing or null operand, %s\n",
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Missing or null operand, %s\n",
AcpiFormatException (Status)));
return_ACPI_STATUS (Status);
}
@ -595,6 +592,7 @@ AcpiDsCreateOperands (
FUNCTION_TRACE_PTR ("DsCreateOperands", FirstArg);
/* For all arguments in the list... */
Arg = FirstArg;
@ -624,7 +622,6 @@ Cleanup:
* pop everything off of the operand stack and delete those
* objects
*/
AcpiDsObjStackPopAndDelete (ArgCount, WalkState);
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While creating Arg %d - %s\n",
@ -667,7 +664,6 @@ AcpiDsResolveOperands (
* TBD: [Investigate] Note from previous parser:
* RefOf problem with AcpiExResolveToValue() conversion.
*/
for (i = 0; i < WalkState->NumOperands; i++)
{
Status = AcpiExResolveToValue (&WalkState->Operands[i], WalkState);
@ -702,7 +698,7 @@ AcpiDsMapOpcodeToDataType (
UINT32 *OutFlags)
{
ACPI_OBJECT_TYPE8 DataType = INTERNAL_TYPE_INVALID;
ACPI_OPCODE_INFO *OpInfo;
const ACPI_OPCODE_INFO *OpInfo;
UINT32 Flags = 0;
@ -744,7 +740,7 @@ AcpiDsMapOpcodeToDataType (
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Unknown (type LITERAL) AML opcode: %x\n", Opcode));
break;
}
@ -856,6 +852,9 @@ AcpiDsMapNamedOpcodeToDataType (
ACPI_OBJECT_TYPE8 DataType;
FUNCTION_ENTRY ();
/* Decode Opcode */
switch (Opcode)
@ -917,6 +916,7 @@ AcpiDsMapNamedOpcodeToDataType (
DataType = ACPI_TYPE_EVENT;
break;
case AML_DATA_REGION_OP:
case AML_REGION_OP:
DataType = ACPI_TYPE_REGION;
break;

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: dswload - Dispatcher namespace load callbacks
* $Revision: 1.41 $
* $Revision: 1.48 $
*
*****************************************************************************/
@ -129,6 +129,42 @@
MODULE_NAME ("dswload")
ACPI_STATUS
AcpiDsInitCallbacks (
ACPI_WALK_STATE *WalkState,
UINT32 PassNumber)
{
switch (PassNumber)
{
case 1:
WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE;
WalkState->DescendingCallback = AcpiDsLoad1BeginOp;
WalkState->AscendingCallback = AcpiDsLoad1EndOp;
break;
case 2:
WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE;
WalkState->DescendingCallback = AcpiDsLoad2BeginOp;
WalkState->AscendingCallback = AcpiDsLoad2EndOp;
break;
case 3:
WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE;
WalkState->DescendingCallback = AcpiDsExecBeginOp;
WalkState->AscendingCallback = AcpiDsExecEndOp;
break;
default:
return (AE_BAD_PARAMETER);
break;
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsLoad1BeginOp
@ -145,52 +181,53 @@
ACPI_STATUS
AcpiDsLoad1BeginOp (
UINT16 Opcode,
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT **OutOp)
{
ACPI_PARSE_OBJECT *Op;
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_OBJECT_TYPE8 DataType;
NATIVE_CHAR *Path;
ACPI_OPCODE_INFO *OpInfo;
PROC_NAME ("DsLoad1BeginOp");
Op = WalkState->Op;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
/* We are only interested in opcodes that have an associated name */
OpInfo = AcpiPsGetOpcodeInfo (Opcode);
if (!(OpInfo->Flags & AML_NAMED))
if (WalkState->Op)
{
*OutOp = Op;
return (AE_OK);
if (!(WalkState->OpInfo->Flags & AML_NAMED))
{
*OutOp = Op;
return (AE_OK);
}
/* Check if this object has already been installed in the namespace */
if (Op->Node)
{
*OutOp = Op;
return (AE_OK);
}
}
/* Check if this object has already been installed in the namespace */
if (Op && Op->Node)
{
*OutOp = Op;
return (AE_OK);
}
Path = AcpiPsGetNextNamestring (WalkState->ParserState);
Path = AcpiPsGetNextNamestring (&WalkState->ParserState);
/* Map the raw opcode into an internal object type */
DataType = AcpiDsMapNamedOpcodeToDataType (Opcode);
DataType = AcpiDsMapNamedOpcodeToDataType (WalkState->Opcode);
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"State=%p Op=%p Type=%x\n", WalkState, Op, DataType));
if (Opcode == AML_SCOPE_OP)
if (WalkState->Opcode == AML_SCOPE_OP)
{
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"State=%p Op=%p Type=%x\n", WalkState, Op, DataType));
@ -201,7 +238,7 @@ AcpiDsLoad1BeginOp (
* as we go downward in the parse tree. Any necessary subobjects that involve
* arguments to the opcode must be created as we go back up the parse tree later.
*/
Status = AcpiNsLookup (WalkState->ScopeInfo, Path, DataType,
Status = AcpiNsLookup (WalkState->ScopeInfo, Path, DataType,
IMODE_LOAD_PASS1, NS_NO_UPSEARCH, WalkState, &(Node));
if (ACPI_FAILURE (Status))
@ -213,7 +250,7 @@ AcpiDsLoad1BeginOp (
{
/* Create a new op */
Op = AcpiPsAllocOp (Opcode);
Op = AcpiPsAllocOp (WalkState->Opcode);
if (!Op)
{
return (AE_NO_MEMORY);
@ -229,12 +266,9 @@ AcpiDsLoad1BeginOp (
* can get it again quickly when this scope is closed
*/
Op->Node = Node;
AcpiPsAppendArg (AcpiPsGetParentScope (WalkState->ParserState), Op);
AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op);
*OutOp = Op;
return (Status);
}
@ -256,26 +290,25 @@ AcpiDsLoad1BeginOp (
ACPI_STATUS
AcpiDsLoad1EndOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op)
ACPI_WALK_STATE *WalkState)
{
ACPI_PARSE_OBJECT *Op;
ACPI_OBJECT_TYPE8 DataType;
ACPI_OPCODE_INFO *OpInfo;
PROC_NAME ("DsLoad1EndOp");
Op = WalkState->Op;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
/* We are only interested in opcodes that have an associated name */
OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode);
if (!(OpInfo->Flags & AML_NAMED))
if (!(WalkState->OpInfo->Flags & AML_NAMED))
{
return (AE_OK);
}
/* Get the type to determine if we should pop the scope */
DataType = AcpiDsMapNamedOpcodeToDataType (Op->Opcode);
@ -293,7 +326,6 @@ AcpiDsLoad1EndOp (
}
}
/* Pop the scope stack */
if (AcpiNsOpensScope (DataType))
@ -305,7 +337,6 @@ AcpiDsLoad1EndOp (
}
return (AE_OK);
}
@ -325,46 +356,44 @@ AcpiDsLoad1EndOp (
ACPI_STATUS
AcpiDsLoad2BeginOp (
UINT16 Opcode,
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT **OutOp)
{
ACPI_PARSE_OBJECT *Op;
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_OBJECT_TYPE8 DataType;
NATIVE_CHAR *BufferPtr;
void *Original = NULL;
ACPI_OPCODE_INFO *OpInfo;
PROC_NAME ("DsLoad2BeginOp");
Op = WalkState->Op;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
/* We only care about Namespace opcodes here */
OpInfo = AcpiPsGetOpcodeInfo (Opcode);
if (!(OpInfo->Flags & AML_NSOPCODE) &&
Opcode != AML_INT_NAMEPATH_OP)
{
return (AE_OK);
}
/* TBD: [Restructure] Temp! same code as in psparse */
if (!(OpInfo->Flags & AML_NAMED))
{
return (AE_OK);
}
if (Op)
{
/* We only care about Namespace opcodes here */
if (!(WalkState->OpInfo->Flags & AML_NSOPCODE) &&
WalkState->Opcode != AML_INT_NAMEPATH_OP)
{
return (AE_OK);
}
/* TBD: [Restructure] Temp! same code as in psparse */
if (!(WalkState->OpInfo->Flags & AML_NAMED))
{
return (AE_OK);
}
/*
* Get the name we are going to enter or lookup in the namespace
*/
if (Opcode == AML_INT_NAMEPATH_OP)
if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
{
/* For Namepath op, get the path string */
@ -387,33 +416,33 @@ AcpiDsLoad2BeginOp (
else
{
BufferPtr = AcpiPsGetNextNamestring (WalkState->ParserState);
BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState);
}
/* Map the raw opcode into an internal object type */
DataType = AcpiDsMapNamedOpcodeToDataType (Opcode);
DataType = AcpiDsMapNamedOpcodeToDataType (WalkState->Opcode);
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"State=%p Op=%p Type=%x\n", WalkState, Op, DataType));
if (Opcode == AML_FIELD_OP ||
Opcode == AML_BANK_FIELD_OP ||
Opcode == AML_INDEX_FIELD_OP)
if (WalkState->Opcode == AML_FIELD_OP ||
WalkState->Opcode == AML_BANK_FIELD_OP ||
WalkState->Opcode == AML_INDEX_FIELD_OP)
{
Node = NULL;
Status = AE_OK;
}
else if (Opcode == AML_INT_NAMEPATH_OP)
else if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
{
/*
* The NamePath is an object reference to an existing object. Don't enter the
* name into the namespace, but look it up for use later
*/
Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, DataType,
Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, DataType,
IMODE_EXECUTE, NS_SEARCH_PARENT, WalkState, &(Node));
}
@ -441,7 +470,7 @@ AcpiDsLoad2BeginOp (
* as we go downward in the parse tree. Any necessary subobjects that involve
* arguments to the opcode must be created as we go back up the parse tree later.
*/
Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, DataType,
Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, DataType,
IMODE_EXECUTE, NS_NO_UPSEARCH, WalkState, &(Node));
}
@ -451,7 +480,7 @@ AcpiDsLoad2BeginOp (
{
/* Create a new op */
Op = AcpiPsAllocOp (Opcode);
Op = AcpiPsAllocOp (WalkState->Opcode);
if (!Op)
{
return (AE_NO_MEMORY);
@ -463,7 +492,6 @@ AcpiDsLoad2BeginOp (
*OutOp = Op;
}
/*
* Put the Node in the "op" object that the parser uses, so we
* can get it again quickly when this scope is closed
@ -503,25 +531,25 @@ AcpiDsLoad2BeginOp (
ACPI_STATUS
AcpiDsLoad2EndOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op)
ACPI_WALK_STATE *WalkState)
{
ACPI_PARSE_OBJECT *Op;
ACPI_STATUS Status = AE_OK;
ACPI_OBJECT_TYPE8 DataType;
ACPI_NAMESPACE_NODE *Node;
ACPI_PARSE_OBJECT *Arg;
ACPI_NAMESPACE_NODE *NewNode;
ACPI_OPCODE_INFO *OpInfo;
PROC_NAME ("DsLoad2EndOp");
Op = WalkState->Op;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
/* Only interested in opcodes that have namespace objects */
OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode);
if (!(OpInfo->Flags & AML_NSOBJECT))
if (!(WalkState->OpInfo->Flags & AML_NSOBJECT))
{
return (AE_OK);
}
@ -533,7 +561,7 @@ AcpiDsLoad2EndOp (
if (((ACPI_PARSE2_OBJECT *)Op)->Name == -1)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unnamed scope! Op=%p State=%p\n",
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unnamed scope! Op=%p State=%p\n",
Op, WalkState));
return (AE_OK);
}
@ -552,7 +580,6 @@ AcpiDsLoad2EndOp (
* Put the Node on the object stack (Contains the ACPI Name of
* this object)
*/
WalkState->Operands[0] = (void *) Node;
WalkState->NumOperands = 1;
@ -566,32 +593,32 @@ AcpiDsLoad2EndOp (
AcpiDsScopeStackPop (WalkState);
}
/*
* Named operations are as follows:
*
* AML_SCOPE
* AML_DEVICE
* AML_THERMALZONE
* AML_METHOD
* AML_POWERRES
* AML_PROCESSOR
* AML_FIELD
* AML_INDEXFIELD
* AML_BANKFIELD
* AML_NAMEDFIELD
* AML_NAME
* AML_ALIAS
* AML_MUTEX
* AML_EVENT
* AML_OPREGION
* AML_CREATEFIELD
* AML_BANKFIELD
* AML_CREATEBITFIELD
* AML_CREATEBYTEFIELD
* AML_CREATEWORDFIELD
* AML_CREATEDWORDFIELD
* AML_CREATEFIELD
* AML_CREATEQWORDFIELD
* AML_CREATEWORDFIELD
* AML_DATA_REGION
* AML_DEVICE
* AML_EVENT
* AML_FIELD
* AML_INDEXFIELD
* AML_METHOD
* AML_METHODCALL
* AML_MUTEX
* AML_NAME
* AML_NAMEDFIELD
* AML_OPREGION
* AML_POWERRES
* AML_PROCESSOR
* AML_SCOPE
* AML_THERMALZONE
*/
@ -613,9 +640,8 @@ AcpiDsLoad2EndOp (
* Create the field object, but the field buffer and index must
* be evaluated later during the execution phase
*/
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"CreateXxxField: State=%p Op=%p NamedObj=%p\n",
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"CreateXxxField: State=%p Op=%p NamedObj=%p\n",
WalkState, Op, Node));
/* Get the NameString argument */
@ -675,22 +701,19 @@ AcpiDsLoad2EndOp (
case AML_INT_METHODCALL_OP:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
WalkState, Op, Node));
/*
* Lookup the method name and save the Node
*/
Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String,
ACPI_TYPE_ANY, IMODE_LOAD_PASS2,
NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE,
WalkState, &(NewNode));
if (ACPI_SUCCESS (Status))
{
/* TBD: has name already been resolved by here ??*/
/* TBD: [Restructure] Make sure that what we found is indeed a method! */
@ -849,7 +872,7 @@ AcpiDsLoad2EndOp (
}
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"LOADING-Opregion: Op=%p State=%p NamedObj=%p\n",
"LOADING-OpRegion: Op=%p State=%p NamedObj=%p\n",
Op, WalkState, Node));
/*
@ -866,6 +889,22 @@ AcpiDsLoad2EndOp (
break;
case AML_DATA_REGION_OP:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"LOADING-DataRegion: Op=%p State=%p NamedObj=%p\n",
Op, WalkState, Node));
Status = AcpiDsCreateOperands (WalkState, Arg);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
Status = AcpiExCreateTableRegion (WalkState);
break;
/* Namespace Modifier Opcodes */
case AML_ALIAS_OP: