Merge our local patches into the 20010920 snapshot. Note that the

"implicit return" hack in psparse.c was resubmitted by Iwasaki-san.

Submitted by:	iwasaki
This commit is contained in:
Mike Smith 2001-10-04 23:15:26 +00:00
parent 875063d979
commit 947ff3286e
4 changed files with 174 additions and 274 deletions

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Name: acconfig.h - Global configuration constants
* $Revision: 69 $
* $Revision: 71 $
*
*****************************************************************************/
@ -144,7 +144,7 @@
/* Version string */
#define ACPI_CA_VERSION 0x20010831
#define ACPI_CA_VERSION 0x20010920
/* Maximum objects in the various object caches */
@ -169,7 +169,7 @@
/* Max reference count (for debug only) */
#define MAX_REFERENCE_COUNT 0x200
#define MAX_REFERENCE_COUNT 0x400
/* Size of cached memory mapping for system memory operation region */

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Name: acgcc.h - GCC specific defines, etc.
* $Revision: 9 $
* $Revision: 13 $
*
*****************************************************************************/
@ -130,7 +130,6 @@
#define BREAKPOINT3
#define disable() __cli()
#define enable() __sti()
#define wbinvd()
/*! [Begin] no source code translation */
@ -185,6 +184,7 @@
#else /* DO IA32 */
#define COMPILER_DEPENDENT_UINT64 unsigned long long
#define ACPI_ASM_MACROS
#define causeinterrupt(level)
@ -192,9 +192,6 @@
#define disable() __cli()
#define enable() __sti()
#define halt() __asm__ __volatile__ ("sti; hlt":::"memory")
#ifndef __FreeBSD__ /* XXX conflicts with inline in cpufunc.h */
#define wbinvd() __asm__ __volatile__ ("wbinvd":::"memory")
#endif
/*! [Begin] no source code translation
*
@ -233,6 +230,23 @@
:"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~3L):"dx"); \
} while(0)
/*
* Math helper asm macros
*/
#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
asm("divl %2;" \
:"=a"(q32), "=d"(r32) \
:"r"(d32), \
"0"(n_lo), "1"(n_hi))
#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
asm("shrl $1,%2;" \
"rcrl $1,%3;" \
:"=r"(n_hi), "=r"(n_lo) \
:"0"(n_hi), "1"(n_lo))
/*! [End] no source code translation !*/
#endif /* IA 32 */

View File

@ -349,12 +349,14 @@ AcpiRemoveGpeHandler (
ACPI_STATUS
AcpiEnableEvent (
UINT32 AcpiEvent,
UINT32 Type);
UINT32 Type,
UINT32 Flags);
ACPI_STATUS
AcpiDisableEvent (
UINT32 AcpiEvent,
UINT32 Type);
UINT32 Type,
UINT32 Flags);
ACPI_STATUS
AcpiClearEvent (

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: psparse - Parser top level AML parse routines
* $Revision: 96 $
* $Revision: 101 $
*
*****************************************************************************/
@ -215,55 +215,13 @@ AcpiPsPeekOpcode (
/* Extended opcode */
Opcode = (UINT16) ((Opcode << 8) | GET8 (Aml));
Aml++;
}
/* don't convert bare name to a namepath */
return (Opcode);
}
/*******************************************************************************
*
* FUNCTION: AcpiPsCreateState
*
* PARAMETERS: Aml - Aml code pointer
* AmlSize - Length of AML code
*
* RETURN: A new parser state object
*
* DESCRIPTION: Create and initialize a new parser state object
*
******************************************************************************/
ACPI_PARSE_STATE *
AcpiPsCreateState (
UINT8 *Aml,
UINT32 AmlSize)
{
ACPI_PARSE_STATE *ParserState;
FUNCTION_TRACE ("PsCreateState");
ParserState = ACPI_MEM_CALLOCATE (sizeof (ACPI_PARSE_STATE));
if (!ParserState)
{
return_PTR (NULL);
}
ParserState->Aml = Aml;
ParserState->AmlEnd = Aml + AmlSize;
ParserState->PkgEnd = ParserState->AmlEnd;
ParserState->AmlStart = Aml;
return_PTR (ParserState);
}
/*******************************************************************************
*
* FUNCTION: AcpiPsFindObject
@ -286,30 +244,26 @@ AcpiPsCreateState (
ACPI_STATUS
AcpiPsFindObject (
UINT16 Opcode,
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT **OutOp)
{
NATIVE_CHAR *Path;
const ACPI_OPCODE_INFO *OpInfo;
/* We are only interested in opcodes that have an associated name */
OpInfo = AcpiPsGetOpcodeInfo (Opcode);
if (!(OpInfo->Flags & AML_NAMED))
if (!(WalkState->OpInfo->Flags & AML_NAMED))
{
*OutOp = Op;
*OutOp = WalkState->Op;
return (AE_OK);
}
/* Find the name in the parse tree */
Path = AcpiPsGetNextNamestring (WalkState->ParserState);
Path = AcpiPsGetNextNamestring (&WalkState->ParserState);
*OutOp = AcpiPsFind (AcpiPsGetParentScope (WalkState->ParserState),
Path, Opcode, 1);
*OutOp = AcpiPsFind (AcpiPsGetParentScope (&WalkState->ParserState),
Path, WalkState->Opcode, 1);
if (!(*OutOp))
{
@ -343,7 +297,6 @@ AcpiPsCompleteThisOp (
#ifndef PARSER_ONLY
ACPI_PARSE_OBJECT *Prev;
ACPI_PARSE_OBJECT *Next;
const ACPI_OPCODE_INFO *OpInfo;
const ACPI_OPCODE_INFO *ParentInfo;
UINT32 OpcodeClass;
ACPI_PARSE_OBJECT *ReplacementOp = NULL;
@ -352,8 +305,7 @@ AcpiPsCompleteThisOp (
FUNCTION_TRACE_PTR ("PsCompleteThisOp", Op);
OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode);
OpcodeClass = ACPI_GET_OP_CLASS (OpInfo);
OpcodeClass = ACPI_GET_OP_CLASS (WalkState->OpInfo);
/* Delete this op and the subtree below it if asked to */
@ -494,7 +446,7 @@ AcpiPsNextParseState (
ACPI_PARSE_OBJECT *Op,
ACPI_STATUS CallbackStatus)
{
ACPI_PARSE_STATE *ParserState = WalkState->ParserState;
ACPI_PARSE_STATE *ParserState = &WalkState->ParserState;
ACPI_STATUS Status = AE_CTRL_PENDING;
UINT8 *Start;
UINT32 PackageLength;
@ -611,13 +563,7 @@ AcpiPsParseLoop (
{
ACPI_STATUS Status = AE_OK;
ACPI_PARSE_OBJECT *Op = NULL; /* current op */
const ACPI_OPCODE_INFO *OpInfo;
ACPI_PARSE_OBJECT *Arg = NULL;
ACPI_PARSE2_OBJECT *DeferredOp;
UINT32 ArgCount; /* push for fixed or var args */
UINT32 ArgTypes = 0;
UINT32 AmlOffset;
UINT16 Opcode;
ACPI_PARSE_OBJECT PreOp;
ACPI_PARSE_STATE *ParserState;
UINT8 *AmlOpStart;
@ -626,7 +572,8 @@ AcpiPsParseLoop (
FUNCTION_TRACE_PTR ("PsParseLoop", WalkState);
ParserState = WalkState->ParserState;
ParserState = &WalkState->ParserState;
WalkState->ArgTypes = 0;
#ifndef PARSER_ONLY
if (WalkState->WalkType & WALK_METHOD_RESTART)
@ -640,7 +587,7 @@ AcpiPsParseLoop (
* was just completed
*/
if ((ParserState->Scope->ParseScope.Op) &&
((ParserState->Scope->ParseScope.Op->Opcode == AML_IF_OP) ||
((ParserState->Scope->ParseScope.Op->Opcode == AML_IF_OP) ||
(ParserState->Scope->ParseScope.Op->Opcode == AML_WHILE_OP)) &&
(WalkState->ControlState) &&
(WalkState->ControlState->Common.State ==
@ -651,7 +598,8 @@ AcpiPsParseLoop (
* A predicate was just completed, get the value of the
* predicate and branch based on that value
*/
Status = AcpiDsGetPredicateValue (WalkState, NULL, TRUE);
WalkState->Op = NULL;
Status = AcpiDsGetPredicateValue (WalkState, TRUE);
if (ACPI_FAILURE (Status) &&
((Status & AE_CODE_MASK) != AE_CODE_CONTROL))
{
@ -670,7 +618,7 @@ AcpiPsParseLoop (
Status = AcpiPsNextParseState (WalkState, Op, Status);
}
AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount);
AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount);
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op));
}
@ -679,7 +627,7 @@ AcpiPsParseLoop (
/* We were in the middle of an op */
Op = WalkState->PrevOp;
ArgTypes = WalkState->PrevArgTypes;
WalkState->ArgTypes = WalkState->PrevArgTypes;
}
}
#endif
@ -694,8 +642,8 @@ AcpiPsParseLoop (
/* Get the next opcode from the AML stream */
AmlOpStart = ParserState->Aml;
AmlOffset = ParserState->Aml - ParserState->AmlStart;
Opcode = AcpiPsPeekOpcode (ParserState);
WalkState->AmlOffset = ParserState->Aml - ParserState->AmlStart;
WalkState->Opcode = AcpiPsPeekOpcode (ParserState);
/*
* First cut to determine what we have found:
@ -703,15 +651,15 @@ AcpiPsParseLoop (
* 2) A name string
* 3) An unknown/invalid opcode
*/
OpInfo = AcpiPsGetOpcodeInfo (Opcode);
switch (ACPI_GET_OP_TYPE (OpInfo))
WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
switch (ACPI_GET_OP_TYPE (WalkState->OpInfo))
{
case ACPI_OP_TYPE_OPCODE:
/* Found opcode info, this is a normal opcode */
ParserState->Aml += AcpiPsGetOpcodeSize (Opcode);
ArgTypes = OpInfo->ParseArgs;
ParserState->Aml += AcpiPsGetOpcodeSize (WalkState->Opcode);
WalkState->ArgTypes = WalkState->OpInfo->ParseArgs;
break;
case ACPI_OP_TYPE_ASCII:
@ -720,8 +668,8 @@ AcpiPsParseLoop (
* Starts with a valid prefix or ASCII char, this is a name
* string. Convert the bare name string to a namepath.
*/
Opcode = AML_INT_NAMEPATH_OP;
ArgTypes = ARGP_NAMESTRING;
WalkState->Opcode = AML_INT_NAMEPATH_OP;
WalkState->ArgTypes = ARGP_NAMESTRING;
break;
case ACPI_OP_TYPE_UNKNOWN:
@ -730,7 +678,7 @@ AcpiPsParseLoop (
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Found unknown opcode %lX at AML offset %X, ignoring\n",
Opcode, AmlOffset));
WalkState->Opcode, WalkState->AmlOffset));
DUMP_BUFFER (ParserState->Aml, 128);
@ -743,24 +691,24 @@ AcpiPsParseLoop (
/* Create Op structure and append to parent's argument list */
if (OpInfo->Flags & AML_NAMED)
if (WalkState->OpInfo->Flags & AML_NAMED)
{
PreOp.Value.Arg = NULL;
PreOp.Opcode = Opcode;
PreOp.Opcode = WalkState->Opcode;
while (GET_CURRENT_ARG_TYPE (ArgTypes) != ARGP_NAME)
while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME)
{
Arg = AcpiPsGetNextArg (ParserState,
GET_CURRENT_ARG_TYPE (ArgTypes),
&ArgCount);
GET_CURRENT_ARG_TYPE (WalkState->ArgTypes),
&WalkState->ArgCount);
AcpiPsAppendArg (&PreOp, Arg);
INCREMENT_ARG_LIST (ArgTypes);
INCREMENT_ARG_LIST (WalkState->ArgTypes);
}
/* We know that this arg is a name, move to next arg */
INCREMENT_ARG_LIST (ArgTypes);
INCREMENT_ARG_LIST (WalkState->ArgTypes);
if (WalkState->DescendingCallback != NULL)
{
@ -768,7 +716,19 @@ AcpiPsParseLoop (
* Find the object. This will either insert the object into
* the namespace or simply look it up
*/
Status = WalkState->DescendingCallback (Opcode, NULL, WalkState, &Op);
WalkState->Op = NULL;
Status = WalkState->DescendingCallback (WalkState, &Op);
/* TBD: check status here? */
if (ACPI_FAILURE (Status))
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "During name lookup/catalog, %s\n",
AcpiFormatException (Status)));
goto CloseThisOp;
}
if (Op == NULL)
{
continue;
@ -792,8 +752,6 @@ AcpiPsParseLoop (
if (Op->Opcode == AML_REGION_OP)
{
DeferredOp = (ACPI_PARSE2_OBJECT *) Op;
/*
* Defer final parsing of an OperationRegion body,
* because we don't have enough info in the first pass
@ -806,8 +764,8 @@ AcpiPsParseLoop (
*
* (Length is unknown until parse of the body complete)
*/
DeferredOp->Data = AmlOpStart;
DeferredOp->Length = 0;
((ACPI_PARSE2_OBJECT * ) Op)->Data = AmlOpStart;
((ACPI_PARSE2_OBJECT * ) Op)->Length = 0;
}
}
@ -816,24 +774,22 @@ AcpiPsParseLoop (
{
/* Not a named opcode, just allocate Op and append to parent */
OpInfo = AcpiPsGetOpcodeInfo (Opcode);
Op = AcpiPsAllocOp (Opcode);
WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
Op = AcpiPsAllocOp (WalkState->Opcode);
if (!Op)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
if (OpInfo->Flags & AML_CREATE)
if (WalkState->OpInfo->Flags & AML_CREATE)
{
/*
* Backup to beginning of CreateXXXfield declaration
* BodyLength is unknown until we parse the body
*/
DeferredOp = (ACPI_PARSE2_OBJECT *) Op;
DeferredOp->Data = AmlOpStart;
DeferredOp->Length = 0;
((ACPI_PARSE2_OBJECT * ) Op)->Data = AmlOpStart;
((ACPI_PARSE2_OBJECT * ) Op)->Length = 0;
}
AcpiPsAppendArg (AcpiPsGetParentScope (ParserState), Op);
@ -844,7 +800,9 @@ AcpiPsParseLoop (
* Find the object. This will either insert the object into
* the namespace or simply look it up
*/
Status = WalkState->DescendingCallback (Opcode, Op, WalkState, &Op);
WalkState->Op = Op;
Status = WalkState->DescendingCallback (WalkState, &Op);
Status = AcpiPsNextParseState (WalkState, Op, Status);
if (Status == AE_CTRL_PENDING)
{
@ -859,9 +817,9 @@ AcpiPsParseLoop (
}
}
Op->AmlOffset = AmlOffset;
Op->AmlOffset = WalkState->AmlOffset;
if (OpInfo)
if (WalkState->OpInfo)
{
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
"Op=%p Opcode=%4.4lX Aml %p Oft=%5.5lX\n",
@ -872,10 +830,10 @@ AcpiPsParseLoop (
/* Start ArgCount at zero because we don't know if there are any args yet */
ArgCount = 0;
WalkState->ArgCount = 0;
if (ArgTypes) /* Are there any arguments that must be processed? */
if (WalkState->ArgTypes) /* Are there any arguments that must be processed? */
{
/* get arguments */
@ -890,13 +848,13 @@ AcpiPsParseLoop (
/* fill in constant or string argument directly */
AcpiPsGetNextSimpleArg (ParserState,
GET_CURRENT_ARG_TYPE (ArgTypes), Op);
GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), Op);
break;
case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
AcpiPsGetNextNamepath (ParserState, Op, &ArgCount, 1);
ArgTypes = 0;
AcpiPsGetNextNamepath (ParserState, Op, &WalkState->ArgCount, 1);
WalkState->ArgTypes = 0;
break;
@ -904,19 +862,19 @@ AcpiPsParseLoop (
/* Op is not a constant or string, append each argument */
while (GET_CURRENT_ARG_TYPE (ArgTypes) && !ArgCount)
while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && !WalkState->ArgCount)
{
AmlOffset = ParserState->Aml - ParserState->AmlStart;
WalkState->AmlOffset = ParserState->Aml - ParserState->AmlStart;
Arg = AcpiPsGetNextArg (ParserState,
GET_CURRENT_ARG_TYPE (ArgTypes),
&ArgCount);
GET_CURRENT_ARG_TYPE (WalkState->ArgTypes),
&WalkState->ArgCount);
if (Arg)
{
Arg->AmlOffset = AmlOffset;
Arg->AmlOffset = WalkState->AmlOffset;
AcpiPsAppendArg (Op, Arg);
}
INCREMENT_ARG_LIST (ArgTypes);
INCREMENT_ARG_LIST (WalkState->ArgTypes);
}
@ -924,16 +882,14 @@ AcpiPsParseLoop (
if (Op->Opcode == AML_METHOD_OP)
{
DeferredOp = (ACPI_PARSE2_OBJECT *) Op;
/*
* Skip parsing of control method or opregion body,
* because we don't have enough info in the first pass
* to parse them correctly.
*/
DeferredOp->Data = ParserState->Aml;
DeferredOp->Length = (UINT32) (ParserState->PkgEnd -
ParserState->Aml);
((ACPI_PARSE2_OBJECT * ) Op)->Data = ParserState->Aml;
((ACPI_PARSE2_OBJECT * ) Op)->Length = (UINT32) (ParserState->PkgEnd -
ParserState->Aml);
/*
* Skip body of method. For OpRegions, we must continue
@ -941,7 +897,7 @@ AcpiPsParseLoop (
* package (We don't know where the end is).
*/
ParserState->Aml = ParserState->PkgEnd;
ArgCount = 0;
WalkState->ArgCount = 0;
}
break;
@ -952,12 +908,12 @@ AcpiPsParseLoop (
/*
* Zero ArgCount means that all arguments for this op have been processed
*/
if (!ArgCount)
if (!WalkState->ArgCount)
{
/* completed Op, prepare for next */
OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode);
if (OpInfo->Flags & AML_NAMED)
WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode);
if (WalkState->OpInfo->Flags & AML_NAMED)
{
if (AcpiGbl_Depth)
{
@ -966,8 +922,6 @@ AcpiPsParseLoop (
if (Op->Opcode == AML_REGION_OP)
{
DeferredOp = (ACPI_PARSE2_OBJECT *) Op;
/*
* Skip parsing of control method or opregion body,
* because we don't have enough info in the first pass
@ -976,12 +930,12 @@ AcpiPsParseLoop (
* Completed parsing an OpRegion declaration, we now
* know the length.
*/
DeferredOp->Length = (UINT32) (ParserState->Aml -
DeferredOp->Data);
((ACPI_PARSE2_OBJECT * ) Op)->Length = (UINT32) (ParserState->Aml -
((ACPI_PARSE2_OBJECT * ) Op)->Data);
}
}
if (OpInfo->Flags & AML_CREATE)
if (WalkState->OpInfo->Flags & AML_CREATE)
{
/*
* Backup to beginning of CreateXXXfield declaration (1 for
@ -989,16 +943,18 @@ AcpiPsParseLoop (
*
* BodyLength is unknown until we parse the body
*/
DeferredOp = (ACPI_PARSE2_OBJECT *) Op;
DeferredOp->Length = (UINT32) (ParserState->Aml -
DeferredOp->Data);
((ACPI_PARSE2_OBJECT * ) Op)->Length = (UINT32) (ParserState->Aml -
((ACPI_PARSE2_OBJECT * ) Op)->Data);
}
/* This op complete, notify the dispatcher */
if (WalkState->AscendingCallback != NULL)
{
Status = WalkState->AscendingCallback (WalkState, Op);
WalkState->Op = Op;
WalkState->Opcode = Op->Opcode;
Status = WalkState->AscendingCallback (WalkState);
Status = AcpiPsNextParseState (WalkState, Op, Status);
if (Status == AE_CTRL_PENDING)
{
@ -1035,16 +991,20 @@ AcpiPsParseLoop (
* We are about to transfer to a called method.
*/
WalkState->PrevOp = Op;
WalkState->PrevArgTypes = ArgTypes;
WalkState->PrevArgTypes = WalkState->ArgTypes;
return_ACPI_STATUS (Status);
break;
case AE_CTRL_END:
AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount);
AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount);
Status = WalkState->AscendingCallback (WalkState, Op);
WalkState->Op = Op;
WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode);
WalkState->Opcode = Op->Opcode;
Status = WalkState->AscendingCallback (WalkState);
Status = AcpiPsNextParseState (WalkState, Op, Status);
AcpiPsCompleteThisOp (WalkState, Op);
@ -1065,7 +1025,7 @@ AcpiPsParseLoop (
AcpiPsCompleteThisOp (WalkState, Op);
}
AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount);
AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount);
} while (Op);
return_ACPI_STATUS (Status);
@ -1076,10 +1036,10 @@ AcpiPsParseLoop (
if (Op == NULL)
{
AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount);
AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount);
}
WalkState->PrevOp = Op;
WalkState->PrevArgTypes = ArgTypes;
WalkState->PrevArgTypes = WalkState->ArgTypes;
/*
* TEMP:
@ -1093,7 +1053,7 @@ AcpiPsParseLoop (
if (AcpiPsHasCompletedScope (ParserState))
{
AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount);
AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount);
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op));
}
@ -1111,7 +1071,7 @@ AcpiPsParseLoop (
{
/* complex argument, push Op and prepare for argument */
AcpiPsPushScope (ParserState, Op, ArgTypes, ArgCount);
AcpiPsPushScope (ParserState, Op, WalkState->ArgTypes, WalkState->ArgCount);
Op = NULL;
}
@ -1121,17 +1081,21 @@ AcpiPsParseLoop (
/*
* Complete the last Op (if not completed), and clear the scope stack.
* It is easily possible to end an AML "package" with an unbounded number
* of open scopes (such as when several AML blocks are closed with
* of open scopes (such as when several ASL blocks are closed with
* sequential closing braces). We want to terminate each one cleanly.
*/
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Package complete at Op %p\n", Op));
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", Op));
do
{
if (Op)
{
if (WalkState->AscendingCallback != NULL)
{
Status = WalkState->AscendingCallback (WalkState, Op);
WalkState->Op = Op;
WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode);
WalkState->Opcode = Op->Opcode;
Status = WalkState->AscendingCallback (WalkState);
Status = AcpiPsNextParseState (WalkState, Op, Status);
if (Status == AE_CTRL_PENDING)
{
@ -1151,7 +1115,7 @@ AcpiPsParseLoop (
AcpiPsCompleteThisOp (WalkState, Op);
}
AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount);
AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount);
} while (Op);
@ -1168,7 +1132,7 @@ AcpiPsParseLoop (
AcpiPsCompleteThisOp (WalkState, Op);
}
AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount);
AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount);
} while (Op);
@ -1194,110 +1158,37 @@ AcpiPsParseLoop (
ACPI_STATUS
AcpiPsParseAml (
ACPI_PARSE_OBJECT *StartScope,
UINT8 *Aml,
UINT32 AmlSize,
UINT32 ParseFlags,
ACPI_NAMESPACE_NODE *MethodNode,
ACPI_OPERAND_OBJECT **Params,
ACPI_OPERAND_OBJECT **CallerReturnDesc,
ACPI_PARSE_DOWNWARDS DescendingCallback,
ACPI_PARSE_UPWARDS AscendingCallback)
ACPI_WALK_STATE *WalkState)
{
ACPI_STATUS Status;
ACPI_PARSE_STATE *ParserState;
ACPI_WALK_STATE *WalkState;
ACPI_WALK_LIST WalkList;
ACPI_WALK_LIST *PrevWalkList = AcpiGbl_CurrentWalkList;
ACPI_OPERAND_OBJECT *ReturnDesc;
ACPI_WALK_STATE *PreviousWalkState;
ACPI_OPERAND_OBJECT **CallerReturnDesc = WalkState->CallerReturnDesc;
ACPI_OPERAND_OBJECT *EffectiveReturnDesc = NULL;
ACPI_OPERAND_OBJECT *MthDesc = NULL;
FUNCTION_TRACE ("PsParseAml");
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Entered with Scope=%p Aml=%p size=%lX\n",
StartScope, Aml, AmlSize));
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Entered with WalkState=%p Aml=%p size=%lX\n",
WalkState, WalkState->ParserState.Aml, WalkState->ParserState.AmlSize));
/* Create and initialize a new parser state */
ParserState = AcpiPsCreateState (Aml, AmlSize);
if (!ParserState)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
AcpiPsInitScope (ParserState, StartScope);
if (MethodNode)
{
MthDesc = AcpiNsGetAttachedObject (MethodNode);
}
/* Create and initialize a new walk list */
WalkList.WalkState = NULL;
WalkList.WalkState = NULL;
WalkList.AcquiredMutexList.Prev = NULL;
WalkList.AcquiredMutexList.Next = NULL;
WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, ParserState->StartOp,
MthDesc, &WalkList);
if (!WalkState)
{
Status = AE_NO_MEMORY;
goto Cleanup;
}
WalkState->WalkList = &WalkList;
AcpiDsPushWalkState (WalkState, &WalkList);
WalkState->MethodNode = MethodNode;
WalkState->ParserState = ParserState;
WalkState->ParseFlags = ParseFlags;
WalkState->DescendingCallback = DescendingCallback;
WalkState->AscendingCallback = AscendingCallback;
/* TBD: [Restructure] TEMP until we pass WalkState to the interpreter
*/
AcpiGbl_CurrentWalkList = &WalkList;
if (MethodNode)
{
ParserState->StartNode = MethodNode;
WalkState->WalkType = WALK_METHOD;
/* Push start scope on scope stack and make it current */
Status = AcpiDsScopeStackPush (MethodNode, ACPI_TYPE_METHOD, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/* Init arguments if this is a control method */
/* TBD: [Restructure] add walkstate as a param */
AcpiDsMethodDataInitArgs (Params, MTH_NUM_ARGS, WalkState);
}
else
{
/* Setup the current scope */
ParserState->StartNode = ParserState->StartOp->Node;
if (ParserState->StartNode)
{
/* Push start scope on scope stack and make it current */
Status = AcpiDsScopeStackPush (ParserState->StartNode,
ParserState->StartNode->Type, WalkState);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
}
}
/*
* Execute the walk loop as long as there is a valid Walk State. This
* handles nested control method invocations without recursion.
@ -1309,6 +1200,10 @@ AcpiPsParseAml (
{
if (ACPI_SUCCESS (Status))
{
/*
* The ParseLoop executes AML until the method terminates
* or calls another method.
*/
Status = AcpiPsParseLoop (WalkState);
}
@ -1340,21 +1235,15 @@ AcpiPsParseAml (
WalkState = AcpiDsPopWalkState (&WalkList);
/* Extract return value before we delete WalkState */
ReturnDesc = WalkState->ReturnDesc;
/* Save the last effective return value */
if (CallerReturnDesc && ReturnDesc)
if (CallerReturnDesc && WalkState->ReturnDesc)
{
EffectiveReturnDesc = ReturnDesc;
AcpiUtRemoveReference (EffectiveReturnDesc);
EffectiveReturnDesc = WalkState->ReturnDesc;
AcpiUtAddReference (EffectiveReturnDesc);
}
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "ReturnValue=%p, State=%p\n",
WalkState->ReturnDesc, WalkState));
/* Reset the current scope to the beginning of scope stack */
AcpiDsScopeStackClear (WalkState);
@ -1370,73 +1259,68 @@ AcpiPsParseAml (
/* Delete this walk state and all linked control states */
AcpiPsCleanupScope (WalkState->ParserState);
ACPI_MEM_FREE (WalkState->ParserState);
AcpiDsDeleteWalkState (WalkState);
AcpiPsCleanupScope (&WalkState->ParserState);
PreviousWalkState = WalkState;
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "ReturnValue=%p, State=%p\n",
WalkState->ReturnDesc, WalkState));
/* Check if we have restarted a preempted walk */
WalkState = AcpiDsGetCurrentWalkState (&WalkList);
if (WalkState &&
ACPI_SUCCESS (Status))
if (WalkState)
{
/* There is another walk state, restart it */
if (ACPI_SUCCESS (Status))
{
/* There is another walk state, restart it */
/*
* If the method returned value is not used by the parent,
* The object is deleted
*/
AcpiDsRestartControlMethod (WalkState, ReturnDesc);
WalkState->WalkType |= WALK_METHOD_RESTART;
/*
* If the method returned value is not used by the parent,
* The object is deleted
*/
AcpiDsRestartControlMethod (WalkState, PreviousWalkState->ReturnDesc);
WalkState->WalkType |= WALK_METHOD_RESTART;
}
}
/*
* Just completed a 1st-level method, save the final internal return
* value (if any)
*/
else if (CallerReturnDesc)
else if (PreviousWalkState->CallerReturnDesc)
{
/*
* Some AML code expects return value w/o ReturnOp.
* Return the saved effective return value instead.
*/
if (ReturnDesc == NULL && EffectiveReturnDesc != NULL)
if (PreviousWalkState->ReturnDesc == NULL && EffectiveReturnDesc != NULL)
{
AcpiUtRemoveReference (ReturnDesc);
ReturnDesc = EffectiveReturnDesc;
PreviousWalkState->ReturnDesc = EffectiveReturnDesc;
AcpiUtAddReference (PreviousWalkState->ReturnDesc);
}
*CallerReturnDesc = ReturnDesc; /* NULL if no return value */
*(PreviousWalkState->CallerReturnDesc) = PreviousWalkState->ReturnDesc; /* NULL if no return value */
}
else if (ReturnDesc)
else if (PreviousWalkState->ReturnDesc)
{
/* Caller doesn't want it, must delete it */
AcpiUtRemoveReference (ReturnDesc);
AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
}
AcpiDsDeleteWalkState (PreviousWalkState);
}
/* Normal exit */
AcpiUtRemoveReference (EffectiveReturnDesc);
AcpiExReleaseAllMutexes ((ACPI_OPERAND_OBJECT *) &WalkList.AcquiredMutexList);
AcpiGbl_CurrentWalkList = PrevWalkList;
return_ACPI_STATUS (Status);
Cleanup:
/* Cleanup */
AcpiDsDeleteWalkState (WalkState);
AcpiPsCleanupScope (ParserState);
ACPI_MEM_FREE (ParserState);
AcpiExReleaseAllMutexes ((ACPI_OPERAND_OBJECT *)&WalkList.AcquiredMutexList);
AcpiGbl_CurrentWalkList = PrevWalkList;
return_ACPI_STATUS (Status);
}