Restructured namespace data structure

date	2000.06.29.16.42.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 18:07:04 +00:00
parent 373d26134d
commit 7311707fea
4 changed files with 405 additions and 545 deletions

View File

@ -1,5 +1,5 @@
/******************************************************************************
*
*
* Module Name: psparse - Parser top level AML parse routines
*
*****************************************************************************/
@ -37,9 +37,9 @@
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
@ -47,11 +47,11 @@
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
@ -85,7 +85,7 @@
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
@ -120,47 +120,46 @@
* generated parser to tightly constrain stack and dynamic memory
* usage. At the same time, parsing is kept flexible and the code
* fairly compact by parsing based on a list of AML opcode
* templates in Gbl_AmlOpInfo[]
* templates in AcpiGbl_AmlOpInfo[]
*/
#include <acpi.h>
#include <parser.h>
#include <dispatch.h>
#include <amlcode.h>
#include <namesp.h>
#include <debugger.h>
#include "acpi.h"
#include "parser.h"
#include "dispatch.h"
#include "amlcode.h"
#include "namesp.h"
#include "debugger.h"
#define _COMPONENT PARSER
MODULE_NAME ("psparse");
UINT32 Gbl_Depth = 0;
extern UINT32 Gbl_ScopeDepth;
UINT32 AcpiGbl_Depth = 0;
extern UINT32 AcpiGbl_ScopeDepth;
/*******************************************************************************
*
* FUNCTION: PsDeleteCompletedOp
* FUNCTION: AcpiPsDeleteCompletedOp
*
* PARAMETERS: State - Walk state
* Op - Completed op
*
* RETURN: AE_OK
*
* DESCRIPTION: Callback function for PsGetNextWalkOp(). Used during
* PsDeleteParse tree to delete Op objects when all sub-objects
* DESCRIPTION: Callback function for AcpiPsGetNextWalkOp(). Used during
* AcpiPsDeleteParse tree to delete Op objects when all sub-objects
* have been visited (and deleted.)
*
******************************************************************************/
ACPI_STATUS
PsDeleteCompletedOp (
ACPI_STATUS
AcpiPsDeleteCompletedOp (
ACPI_WALK_STATE *State,
ACPI_GENERIC_OP *Op)
{
PsFreeOp (Op);
AcpiPsFreeOp (Op);
return AE_OK;
}
@ -168,7 +167,7 @@ PsDeleteCompletedOp (
#ifndef PARSER_ONLY
/*******************************************************************************
*
* FUNCTION: PsDeleteParseTree
* FUNCTION: AcpiPsDeleteParseTree
*
* PARAMETERS: Root - Root of tree (or subtree) to delete
*
@ -179,22 +178,21 @@ PsDeleteCompletedOp (
******************************************************************************/
void
PsDeleteParseTree (
AcpiPsDeleteParseTree (
ACPI_GENERIC_OP *Root)
{
ACPI_GENERIC_OP *Op;
ACPI_WALK_STATE WalkState;
WalkState.Origin = Root;
Op = Root;
/* TBD: [Restructure] hack for root case */
if (Op == Gbl_ParsedNamespaceRoot)
if (Op == AcpiGbl_ParsedNamespaceRoot)
{
Op = PsGetChild (Op);
Op = AcpiPsGetChild (Op);
}
/* Save the root until last, so that we know when the tree has been walked */
@ -204,14 +202,14 @@ PsDeleteParseTree (
while (WalkState.NextOp)
{
PsGetNextWalkOp (&WalkState, WalkState.NextOp, PsDeleteCompletedOp);
AcpiPsGetNextWalkOp (&WalkState, WalkState.NextOp, AcpiPsDeleteCompletedOp);
}
}
#endif
/*******************************************************************************
*
* FUNCTION: PsPeekOpcode
* FUNCTION: AcpiPsPeekOpcode
*
* PARAMETERS: None
*
@ -222,10 +220,10 @@ PsDeleteParseTree (
******************************************************************************/
UINT32
PsGetOpcodeSize (
AcpiPsGetOpcodeSize (
UINT32 Opcode)
{
/* Extended (2-byte) opcode if > 255 */
if (Opcode > 0x00FF)
@ -241,7 +239,7 @@ PsGetOpcodeSize (
/*******************************************************************************
*
* FUNCTION: PsPeekOpcode
* FUNCTION: AcpiPsPeekOpcode
*
* PARAMETERS: ParserState - A parser state object
*
@ -252,7 +250,7 @@ PsGetOpcodeSize (
******************************************************************************/
UINT16
PsPeekOpcode (
AcpiPsPeekOpcode (
ACPI_PARSE_STATE *ParserState)
{
UINT8 *Aml;
@ -265,16 +263,16 @@ PsPeekOpcode (
Aml++;
/*
* Original code special cased LNOTEQUAL, LLESSEQUAL, LGREATEREQUAL. These opcodes are
/*
* Original code special cased LNOTEQUAL, LLESSEQUAL, LGREATEREQUAL. These opcodes are
* no longer recognized. Instead, they are broken into two opcodes.
*
*
* if (Opcode == AML_EXTOP
* || (Opcode == AML_LNOT
* && (GET8 (Aml) == AML_LEQUAL
* || GET8 (Aml) == AML_LGREATER
* || GET8 (Aml) == AML_LLESS))) extended Opcode, !=, <=, or >=
* && (GET8 (AcpiAml) == AML_LEQUAL
* || GET8 (AcpiAml) == AML_LGREATER
* || GET8 (AcpiAml) == AML_LLESS))) extended Opcode, !=, <=, or >=
*/
if (Opcode == AML_EXTOP)
@ -293,10 +291,10 @@ PsPeekOpcode (
/*******************************************************************************
*
* FUNCTION: PsCreateState
* FUNCTION: AcpiPsCreateState
*
* PARAMETERS: Aml - Aml code pointer
* AmlSize - Length of AML code
* PARAMETERS: AcpiAml - AcpiAml code pointer
* AcpiAmlSize - Length of AML code
*
* RETURN: A new parser state object
*
@ -305,17 +303,17 @@ PsPeekOpcode (
******************************************************************************/
ACPI_PARSE_STATE *
PsCreateState (
UINT8 *Aml,
AcpiPsCreateState (
UINT8 *Aml,
INT32 AmlSize)
{
ACPI_PARSE_STATE *ParserState;
ACPI_PARSE_STATE *ParserState;
FUNCTION_TRACE ("PsInitState");
ParserState = CmCallocate (sizeof (ACPI_PARSE_STATE));
ParserState = AcpiCmCallocate (sizeof (ACPI_PARSE_STATE));
if (!ParserState)
{
return_VALUE (NULL);
@ -333,7 +331,7 @@ PsCreateState (
/*******************************************************************************
*
* FUNCTION: PsFindObject
* FUNCTION: AcpiPsFindObject
*
* PARAMETERS: Opcode - Current opcode
* ParserState - Current state
@ -352,7 +350,7 @@ PsCreateState (
#ifdef PARSER_ONLY
ACPI_STATUS
PsFindObject (
AcpiPsFindObject (
UINT16 Opcode,
ACPI_PARSE_STATE *ParserState,
ACPI_WALK_STATE *WalkState,
@ -361,12 +359,11 @@ PsFindObject (
char *Path;
/* Find the name in the parse tree */
Path = PsGetNextNamestring (ParserState);
Path = AcpiPsGetNextNamestring (ParserState);
*Op = PsFind (PsGetParentScope (ParserState),
*Op = AcpiPsFind (AcpiPsGetParentScope (ParserState),
Path, Opcode, 1);
if (!(*Op))
@ -379,7 +376,7 @@ PsFindObject (
#else
ACPI_STATUS
PsFindObject (
AcpiPsFindObject (
UINT16 Opcode,
ACPI_PARSE_STATE *ParserState,
ACPI_WALK_STATE *WalkState,
@ -387,14 +384,14 @@ PsFindObject (
{
char *Path;
ACPI_GENERIC_OP *Op;
OBJECT_TYPE_INTERNAL DataType;
OBJECT_TYPE_INTERNAL DataType;
ACPI_STATUS Status;
NAME_TABLE_ENTRY *Nte = NULL;
ACPI_NAMED_OBJECT *Entry = NULL;
FUNCTION_TRACE ("PsFindInNamespace");
/*
* The full parse tree has already been deleted -- therefore, we are parsing
* a control method. We can lookup the name in the namespace instead of
@ -402,18 +399,18 @@ PsFindObject (
*/
Path = PsGetNextNamestring (ParserState);
Path = AcpiPsGetNextNamestring (ParserState);
/* Map the raw opcode into an internal object type */
DataType = DsMapNamedOpcodeToDataType (Opcode);
DataType = AcpiDsMapNamedOpcodeToDataType (Opcode);
/*
/*
* Enter the object into the namespace
*/
Status = NsLookup (WalkState->ScopeInfo, Path, DataType, IMODE_LoadPass1, /* Create if not found */
NS_NO_UPSEARCH, WalkState, &Nte);
Status = AcpiNsLookup (WalkState->ScopeInfo, Path, DataType, IMODE_LOAD_PASS1, /* Create if not found */
NS_NO_UPSEARCH, WalkState, &Entry);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
@ -421,7 +418,7 @@ PsFindObject (
/* Create a new op */
Op = PsAllocOp (Opcode);
Op = AcpiPsAllocOp (Opcode);
if (!Op)
{
return_ACPI_STATUS (AE_NO_MEMORY);
@ -429,11 +426,11 @@ PsFindObject (
/* Initialize */
((ACPI_NAMED_OP *)Op)->Name = Nte->Name;
Op->NameTableEntry = Nte;
((ACPI_NAMED_OP *)Op)->Name = Entry->Name;
Op->AcpiNamedObject = Entry;
PsAppendArg (PsGetParentScope (ParserState), Op);
AcpiPsAppendArg (AcpiPsGetParentScope (ParserState), Op);
*OutOp = Op;
@ -443,24 +440,21 @@ PsFindObject (
#endif
/*******************************************************************************
*
* FUNCTION: PsParseLoop
* FUNCTION: AcpiPsParseLoop
*
* PARAMETERS: ParserState - Current parser state object
*
* RETURN: Status
*
* DESCRIPTION: Parse AML (pointed to by the current parser state) and return
* DESCRIPTION: Parse AML (pointed to by the current parser state) and return
* a tree of ops.
*
******************************************************************************/
ACPI_STATUS
PsParseLoop (
AcpiPsParseLoop (
ACPI_PARSE_STATE *ParserState,
ACPI_WALK_STATE *WalkState,
UINT32 ParseFlags)
@ -475,17 +469,15 @@ PsParseLoop (
ACPI_PTRDIFF AmlOffset;
UINT16 Opcode;
ACPI_GENERIC_OP PreOp;
#ifndef PARSER_ONLY
OBJECT_TYPE_INTERNAL DataType;
OBJECT_TYPE_INTERNAL DataType;
#endif
FUNCTION_TRACE_PTR ("PsParseLoop", ParserState);
/*
* Iterative parsing loop, while there is more aml to process:
*/
@ -496,8 +488,8 @@ PsParseLoop (
/* Get the next opcode from the AML stream */
AmlOffset = ParserState->Aml - ParserState->AmlStart;
Opcode = PsPeekOpcode (ParserState);
OpInfo = PsGetOpcodeInfo (Opcode);
Opcode = AcpiPsPeekOpcode (ParserState);
OpInfo = AcpiPsGetOpcodeInfo (Opcode);
/*
* First cut to determine what we have found:
@ -510,15 +502,15 @@ PsParseLoop (
{
/* Found opcode info, this is a normal opcode */
ParserState->Aml += PsGetOpcodeSize (Opcode);
ParserState->Aml += AcpiPsGetOpcodeSize (Opcode);
ArgTypes = OpInfo->ParseArgs;
}
else if (PsIsPrefixChar (Opcode) || PsIsLeadingChar (Opcode))
else if (AcpiPsIsPrefixChar (Opcode) || AcpiPsIsLeadingChar (Opcode))
{
/*
/*
* Starts with a valid prefix or ASCII char, this is a name string.
* Convert the bare name string to a namepath.
* Convert the bare name string to a namepath.
*/
Opcode = AML_NAMEPATH_OP;
@ -531,46 +523,46 @@ PsParseLoop (
DEBUG_PRINT (TRACE_PARSE, ("ParseLoop: Found unknown opcode %lX, skipping\n", Opcode));
ParserState->Aml += PsGetOpcodeSize (Opcode);
ParserState->Aml += AcpiPsGetOpcodeSize (Opcode);
continue;
}
/* Create Op structure and append to parent's argument list */
if (PsIsNamedOp (Opcode))
if (AcpiPsIsNamedOp (Opcode))
{
PreOp.Value.Arg = NULL;
PreOp.Opcode = Opcode;
while (GET_CURRENT_ARG_TYPE (ArgTypes) != ARGP_NAME)
{
Arg = PsGetNextArg (ParserState, GET_CURRENT_ARG_TYPE (ArgTypes), &ArgCount);
PsAppendArg (&PreOp, Arg);
Arg = AcpiPsGetNextArg (ParserState, GET_CURRENT_ARG_TYPE (ArgTypes), &ArgCount);
AcpiPsAppendArg (&PreOp, Arg);
INCREMENT_ARG_LIST (ArgTypes);
}
/* We know that this arg is a name, move to next arg */
INCREMENT_ARG_LIST (ArgTypes);
Status = PsFindObject (Opcode, ParserState, WalkState, &Op);
Status = AcpiPsFindObject (Opcode, ParserState, WalkState, &Op);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (AE_NOT_FOUND);
}
PsAppendArg (Op, PreOp.Value.Arg);
Gbl_Depth++;
AcpiPsAppendArg (Op, PreOp.Value.Arg);
AcpiGbl_Depth++;
if (Op->Opcode == AML_RegionOp)
if (Op->Opcode == AML_REGION_OP)
{
DeferredOp = PsToDeferredOp (Op);
DeferredOp = AcpiPsToDeferredOp (Op);
if (DeferredOp)
{
/*
/*
* Skip parsing of control method or opregion body, because we don't
* have enough info in the first pass to parse them correctly.
*
@ -587,15 +579,15 @@ PsParseLoop (
{
/* Not a named opcode, just allocate Op and append to parent */
Op = PsAllocOp (Opcode);
Op = AcpiPsAllocOp (Opcode);
if (!Op)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
PsAppendArg (PsGetParentScope (ParserState), Op);
AcpiPsAppendArg (AcpiPsGetParentScope (ParserState), Op);
}
Op->AmlOffset = AmlOffset;
if (OpInfo)
@ -613,19 +605,19 @@ PsParseLoop (
switch (Op->Opcode)
{
case AML_ByteOp: /* AML_BYTEDATA_ARG */
case AML_WordOp: /* AML_WORDDATA_ARG */
case AML_DWordOp: /* AML_DWORDATA_ARG */
case AML_StringOp: /* AML_ASCIICHARLIST_ARG */
case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
case AML_WORD_OP: /* AML_WORDDATA_ARG */
case AML_DWORD_OP: /* AML_DWORDATA_ARG */
case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */
/* fill in constant or string argument directly */
PsGetNextSimpleArg (ParserState, GET_CURRENT_ARG_TYPE (ArgTypes), Op);
AcpiPsGetNextSimpleArg (ParserState, GET_CURRENT_ARG_TYPE (ArgTypes), Op);
break;
case AML_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
PsGetNextNamepath (ParserState, Op, &ArgCount, 1);
AcpiPsGetNextNamepath (ParserState, Op, &ArgCount, 1);
ArgTypes = 0;
break;
@ -637,26 +629,26 @@ PsParseLoop (
while (GET_CURRENT_ARG_TYPE (ArgTypes) && !ArgCount)
{
AmlOffset = ParserState->Aml - ParserState->AmlStart;
Arg = PsGetNextArg (ParserState, GET_CURRENT_ARG_TYPE (ArgTypes), &ArgCount);
Arg = AcpiPsGetNextArg (ParserState, GET_CURRENT_ARG_TYPE (ArgTypes), &ArgCount);
if (Arg)
{
Arg->AmlOffset = AmlOffset;
}
PsAppendArg (Op, Arg);
AcpiPsAppendArg (Op, Arg);
INCREMENT_ARG_LIST (ArgTypes);
}
/* For a method, save the length and address of the body */
if (Op->Opcode == AML_MethodOp)
if (Op->Opcode == AML_METHOD_OP)
{
DeferredOp = PsToDeferredOp (Op);
DeferredOp = AcpiPsToDeferredOp (Op);
if (DeferredOp)
{
/*
/*
* Skip parsing of control method or opregion body, because we don't
* have enough info in the first pass to parse them correctly.
*/
@ -681,19 +673,19 @@ PsParseLoop (
{
/* completed Op, prepare for next */
if (PsIsNamedOp (Op->Opcode))
if (AcpiPsIsNamedOp (Op->Opcode))
{
if (Gbl_Depth)
if (AcpiGbl_Depth)
{
Gbl_Depth--;
AcpiGbl_Depth--;
}
if (Op->Opcode == AML_RegionOp)
if (Op->Opcode == AML_REGION_OP)
{
DeferredOp = PsToDeferredOp (Op);
DeferredOp = AcpiPsToDeferredOp (Op);
if (DeferredOp)
{
/*
/*
* Skip parsing of control method or opregion body, because we don't
* have enough info in the first pass to parse them correctly.
*
@ -703,31 +695,31 @@ PsParseLoop (
DeferredOp->BodyLength = ParserState->Aml - DeferredOp->Body;
}
}
#ifndef PARSER_ONLY
DataType = DsMapNamedOpcodeToDataType (Op->Opcode);
if (Op->Opcode == AML_NameOp)
#ifndef PARSER_ONLY
DataType = AcpiDsMapNamedOpcodeToDataType (Op->Opcode);
if (Op->Opcode == AML_NAME_OP)
{
if (Op->Value.Arg)
{
DataType = DsMapOpcodeToDataType ((Op->Value.Arg)->Opcode, NULL);
((NAME_TABLE_ENTRY *)Op->NameTableEntry)->Type = (UINT8) DataType;
DataType = AcpiDsMapOpcodeToDataType ((Op->Value.Arg)->Opcode, NULL);
((ACPI_NAMED_OBJECT*)Op->AcpiNamedObject)->Type = (UINT8) DataType;
}
}
/* Pop the scope stack */
if (NsOpensScope (DataType))
if (AcpiNsOpensScope (DataType))
{
DEBUG_PRINT (TRACE_DISPATCH, ("AmlEndNamespaceScope: Popping scope for Op %p type [%s]\n",
Op, CmGetTypeName (DataType)));
DsScopeStackPop (WalkState);
Op, AcpiCmGetTypeName (DataType)));
AcpiDsScopeStackPop (WalkState);
}
#endif
#endif
}
@ -739,14 +731,14 @@ PsParseLoop (
#ifndef PARSER_ONLY
if (ParseFlags & PARSE_DELETE_TREE)
{
PsDeleteParseTree (Op);
AcpiPsDeleteParseTree (Op);
}
#endif
if (PsHasCompletedScope (ParserState))
#endif
if (AcpiPsHasCompletedScope (ParserState))
{
PsPopScope (ParserState, &Op, &ArgTypes);
AcpiPsPopScope (ParserState, &Op, &ArgTypes);
}
else
@ -759,12 +751,12 @@ PsParseLoop (
{
/* complex argument, push Op and prepare for argument */
PsPushScope (ParserState, Op, ArgTypes, ArgCount);
AcpiPsPushScope (ParserState, Op, ArgTypes, ArgCount);
Op = NULL;
}
} /* while ParserState->Aml */
return_ACPI_STATUS (Status);
}
@ -772,7 +764,7 @@ PsParseLoop (
/*******************************************************************************
*
* FUNCTION: PsParseAml
* FUNCTION: AcpiPsParseAml
*
* PARAMETERS: StartScope - The starting point of the parse. Becomes the
* root of the parsed op tree.
@ -786,9 +778,9 @@ PsParseLoop (
******************************************************************************/
ACPI_STATUS
PsParseAml (
AcpiPsParseAml (
ACPI_GENERIC_OP *StartScope,
UINT8 *Aml,
UINT8 *Aml,
UINT32 AmlSize,
UINT32 ParseFlags)
{
@ -796,7 +788,7 @@ PsParseAml (
ACPI_PARSE_STATE *ParserState;
ACPI_WALK_STATE *WalkState;
ACPI_WALK_LIST WalkList;
NAME_TABLE_ENTRY *Nte = NULL;
ACPI_NAMED_OBJECT *Entry = NULL;
FUNCTION_TRACE ("PsParseAml");
@ -806,20 +798,20 @@ PsParseAml (
/* Initialize parser state and scope */
ParserState = PsCreateState (Aml, AmlSize);
ParserState = AcpiPsCreateState (Aml, AmlSize);
if (!ParserState)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
PsInitScope (ParserState, StartScope);
AcpiPsInitScope (ParserState, StartScope);
/* Initialize a new walk list */
WalkList.WalkState = NULL;
WalkState = DsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, &WalkList);
WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, &WalkList);
if (!WalkState)
{
Status = AE_NO_MEMORY;
@ -829,12 +821,12 @@ PsParseAml (
/* Setup the current scope */
Nte = ParserState->StartOp->NameTableEntry;
if (Nte)
Entry = ParserState->StartOp->AcpiNamedObject;
if (Entry)
{
/* Push start scope on scope stack and make it current */
Status = DsScopeStackPush (Nte->Scope, Nte->Type, WalkState);
Status = AcpiDsScopeStackPush (Entry->ChildTable, Entry->Type, WalkState);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
@ -845,16 +837,16 @@ PsParseAml (
/* Create the parse tree */
Status = PsParseLoop (ParserState, WalkState, ParseFlags);
Status = AcpiPsParseLoop (ParserState, WalkState, ParseFlags);
Cleanup:
/* Cleanup */
DsDeleteWalkState (WalkState);
PsCleanupScope (ParserState);
CmFree (ParserState);
AcpiDsDeleteWalkState (WalkState);
AcpiPsCleanupScope (ParserState);
AcpiCmFree (ParserState);
return_ACPI_STATUS (Status);

View File

@ -1,5 +1,5 @@
/******************************************************************************
*
*
* Module Name: psutils - Parser miscellaneous utilities (Parser only)
*
*****************************************************************************/
@ -37,9 +37,9 @@
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
@ -47,11 +47,11 @@
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
@ -85,7 +85,7 @@
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
@ -114,8 +114,8 @@
*****************************************************************************/
#include <acpi.h>
#include <parser.h>
#include "acpi.h"
#include "parser.h"
#include "amlcode.h"
#define _COMPONENT PARSER
@ -126,11 +126,11 @@
#define PARSEOP_NAMED 2
#define PARSEOP_DEFERRED 3
#define PARSEOP_BYTELIST 4
/*******************************************************************************
*
* FUNCTION: PsInitOp
* FUNCTION: AcpiPsInitOp
*
* PARAMETERS: Op - A newly allocated Op object
* Opcode - Opcode to store in the Op
@ -142,22 +142,20 @@
******************************************************************************/
void
PsInitOp (
AcpiPsInitOp (
ACPI_GENERIC_OP *Op,
UINT16 Opcode)
{
ACPI_OP_INFO *AmlOp;
Op->DataType = DESC_TYPE_PARSER;
Op->DataType = ACPI_DESC_TYPE_PARSER;
Op->Opcode = Opcode;
AmlOp = PsGetOpcodeInfo (Opcode);
AmlOp = AcpiPsGetOpcodeInfo (Opcode);
if (AmlOp)
{
/* Debug only! */
DEBUG_ONLY_MEMBERS (STRNCPY (Op->OpName, AmlOp->Name, sizeof (Op->OpName)));
}
}
@ -165,7 +163,7 @@ PsInitOp (
/*******************************************************************************
*
* FUNCTION: PsAllocOp
* FUNCTION: AcpiPsAllocOp
*
* PARAMETERS: Opcode - Opcode that will be stored in the new Op
*
@ -178,7 +176,7 @@ PsInitOp (
******************************************************************************/
ACPI_GENERIC_OP*
PsAllocOp (
AcpiPsAllocOp (
UINT16 Opcode)
{
ACPI_GENERIC_OP *Op = NULL;
@ -188,19 +186,19 @@ PsAllocOp (
/* Allocate the minimum required size object */
if (PsIsDeferredOp (Opcode))
if (AcpiPsIsDeferredOp (Opcode))
{
Size = sizeof (ACPI_DEFERRED_OP);
Flags = PARSEOP_DEFERRED;
}
else if (PsIsNamedOp (Opcode))
else if (AcpiPsIsNamedOp (Opcode))
{
Size = sizeof (ACPI_NAMED_OP);
Flags = PARSEOP_NAMED;
}
else if (PsIsBytelistOp (Opcode))
else if (AcpiPsIsBytelistOp (Opcode))
{
Size = sizeof (ACPI_BYTELIST_OP);
Flags = PARSEOP_BYTELIST;
@ -212,42 +210,42 @@ PsAllocOp (
Flags = PARSEOP_GENERIC;
/*
* The generic op is by far the most common (16 to 1), and therefore the op cache is
* The generic op is by far the most common (16 to 1), and therefore the op cache is
* implemented with this type.
*
* Check if there is an Op already available in the cache
*/
CmAcquireMutex (MTX_CACHES);
Gbl_ParseCacheRequests++;
if (Gbl_ParseCache)
AcpiCmAcquireMutex (ACPI_MTX_CACHES);
AcpiGbl_ParseCacheRequests++;
if (AcpiGbl_ParseCache)
{
/* Extract an op from the front of the cache list */
Gbl_ParseCacheDepth--;
Gbl_ParseCacheHits++;
Op = Gbl_ParseCache;
Gbl_ParseCache = Op->Next;
AcpiGbl_ParseCacheDepth--;
AcpiGbl_ParseCacheHits++;
Op = AcpiGbl_ParseCache;
AcpiGbl_ParseCache = Op->Next;
/* Clear the previously used Op */
MEMSET (Op, 0, sizeof (ACPI_GENERIC_OP));
}
CmReleaseMutex (MTX_CACHES);
AcpiCmReleaseMutex (ACPI_MTX_CACHES);
}
/* Allocate a new Op if necessary */
if (!Op)
{
Op = CmCallocate (Size);
Op = AcpiCmCallocate (Size);
}
/* Initialize the Op */
if (Op)
{
PsInitOp (Op, Opcode);
AcpiPsInitOp (Op, Opcode);
Op->Flags = Flags;
}
@ -255,10 +253,9 @@ PsAllocOp (
}
/*******************************************************************************
*
* FUNCTION: PsFreeOp
* FUNCTION: AcpiPsFreeOp
*
* PARAMETERS: Op - Op to be freed
*
@ -270,7 +267,7 @@ PsAllocOp (
******************************************************************************/
void
PsFreeOp (
AcpiPsFreeOp (
ACPI_GENERIC_OP *Op)
{
@ -279,33 +276,32 @@ PsFreeOp (
{
/* Is the cache full? */
if (Gbl_ParseCacheDepth < MAX_PARSE_CACHE_DEPTH)
if (AcpiGbl_ParseCacheDepth < MAX_PARSE_CACHE_DEPTH)
{
/* Put a GENERIC_OP back into the cache */
CmAcquireMutex (MTX_CACHES);
Gbl_ParseCacheDepth++;
AcpiCmAcquireMutex (ACPI_MTX_CACHES);
AcpiGbl_ParseCacheDepth++;
Op->Next = Gbl_ParseCache;
Gbl_ParseCache = Op;
Op->Next = AcpiGbl_ParseCache;
AcpiGbl_ParseCache = Op;
CmReleaseMutex (MTX_CACHES);
AcpiCmReleaseMutex (ACPI_MTX_CACHES);
return;
}
}
/*
* Not a GENERIC OP, or the cache is full, just free the Op
* Not a GENERIC OP, or the cache is full, just free the Op
*/
CmFree (Op);
AcpiCmFree (Op);
}
/*******************************************************************************
*
* FUNCTION: PsDeleteParseCache
* FUNCTION: AcpiPsDeleteParseCache
*
* PARAMETERS: None
*
@ -316,7 +312,7 @@ PsFreeOp (
******************************************************************************/
void
PsDeleteParseCache (
AcpiPsDeleteParseCache (
void)
{
ACPI_GENERIC_OP *Next;
@ -327,22 +323,19 @@ PsDeleteParseCache (
/* Traverse the global cache list */
while (Gbl_ParseCache)
while (AcpiGbl_ParseCache)
{
/* Delete one cached state object */
Next = Gbl_ParseCache->Next;
CmFree (Gbl_ParseCache);
Gbl_ParseCache = Next;
Next = AcpiGbl_ParseCache->Next;
AcpiCmFree (AcpiGbl_ParseCache);
AcpiGbl_ParseCache = Next;
}
return_VOID;
}
/*******************************************************************************
*
* FUNCTION: Utility functions
@ -356,14 +349,13 @@ PsDeleteParseCache (
******************************************************************************/
/*
* Is "c" a namestring lead character?
*/
BOOLEAN
PsIsLeadingChar (
AcpiPsIsLeadingChar (
INT32 c)
{
return ((BOOLEAN) (c == '_' || (c >= 'A' && c <= 'Z')));
@ -374,7 +366,7 @@ PsIsLeadingChar (
* Is "c" a namestring prefix character?
*/
BOOLEAN
PsIsPrefixChar (
AcpiPsIsPrefixChar (
INT32 c)
{
return ((BOOLEAN) (c == '\\' || c == '^'));
@ -382,59 +374,57 @@ PsIsPrefixChar (
BOOLEAN
PsIsNamespaceObjectOp (
AcpiPsIsNamespaceObjectOp (
UINT16 Opcode)
{
return ((BOOLEAN)
(Opcode == AML_ScopeOp ||
Opcode == AML_DeviceOp ||
Opcode == AML_ThermalZoneOp ||
Opcode == AML_MethodOp ||
Opcode == AML_PowerResOp ||
Opcode == AML_ProcessorOp ||
Opcode == AML_DefFieldOp ||
Opcode == AML_IndexFieldOp ||
Opcode == AML_BankFieldOp ||
Opcode == AML_NAMEDFIELD_OP ||
Opcode == AML_NameOp ||
Opcode == AML_AliasOp ||
Opcode == AML_MutexOp ||
Opcode == AML_EventOp ||
Opcode == AML_RegionOp ||
Opcode == AML_CreateFieldOp ||
Opcode == AML_BitFieldOp ||
Opcode == AML_ByteFieldOp ||
Opcode == AML_WordFieldOp ||
Opcode == AML_DWordFieldOp ||
return ((BOOLEAN)
(Opcode == AML_SCOPE_OP ||
Opcode == AML_DEVICE_OP ||
Opcode == AML_THERMAL_ZONE_OP ||
Opcode == AML_METHOD_OP ||
Opcode == AML_POWER_RES_OP ||
Opcode == AML_PROCESSOR_OP ||
Opcode == AML_DEF_FIELD_OP ||
Opcode == AML_INDEX_FIELD_OP ||
Opcode == AML_BANK_FIELD_OP ||
Opcode == AML_NAMEDFIELD_OP ||
Opcode == AML_NAME_OP ||
Opcode == AML_ALIAS_OP ||
Opcode == AML_MUTEX_OP ||
Opcode == AML_EVENT_OP ||
Opcode == AML_REGION_OP ||
Opcode == AML_CREATE_FIELD_OP ||
Opcode == AML_BIT_FIELD_OP ||
Opcode == AML_BYTE_FIELD_OP ||
Opcode == AML_WORD_FIELD_OP ||
Opcode == AML_DWORD_FIELD_OP ||
Opcode == AML_METHODCALL_OP ||
Opcode == AML_NAMEPATH_OP));
}
BOOLEAN
PsIsNamespaceOp (
AcpiPsIsNamespaceOp (
UINT16 Opcode)
{
return ((BOOLEAN)
(Opcode == AML_ScopeOp ||
Opcode == AML_DeviceOp ||
Opcode == AML_ThermalZoneOp ||
Opcode == AML_MethodOp ||
Opcode == AML_PowerResOp ||
Opcode == AML_ProcessorOp ||
Opcode == AML_DefFieldOp ||
Opcode == AML_IndexFieldOp ||
Opcode == AML_BankFieldOp ||
Opcode == AML_NameOp ||
Opcode == AML_AliasOp ||
Opcode == AML_MutexOp ||
Opcode == AML_EventOp ||
Opcode == AML_RegionOp ||
Opcode == AML_NAMEDFIELD_OP));
return ((BOOLEAN)
(Opcode == AML_SCOPE_OP ||
Opcode == AML_DEVICE_OP ||
Opcode == AML_THERMAL_ZONE_OP ||
Opcode == AML_METHOD_OP ||
Opcode == AML_POWER_RES_OP ||
Opcode == AML_PROCESSOR_OP ||
Opcode == AML_DEF_FIELD_OP ||
Opcode == AML_INDEX_FIELD_OP ||
Opcode == AML_BANK_FIELD_OP ||
Opcode == AML_NAME_OP ||
Opcode == AML_ALIAS_OP ||
Opcode == AML_MUTEX_OP ||
Opcode == AML_EVENT_OP ||
Opcode == AML_REGION_OP ||
Opcode == AML_NAMEDFIELD_OP));
}
/*
* Is opcode for a named object Op?
* (Includes all named object opcodes)
@ -442,29 +432,29 @@ PsIsNamespaceOp (
* TBD: [Restructure] Need a better way than this brute force approach!
*/
BOOLEAN
PsIsNamedObjectOp (
AcpiPsIsNamedObjectOp (
UINT16 Opcode)
{
return ((BOOLEAN)
(Opcode == AML_ScopeOp ||
Opcode == AML_DeviceOp ||
Opcode == AML_ThermalZoneOp ||
Opcode == AML_MethodOp ||
Opcode == AML_PowerResOp ||
Opcode == AML_ProcessorOp ||
Opcode == AML_NAMEDFIELD_OP ||
Opcode == AML_NameOp ||
Opcode == AML_AliasOp ||
Opcode == AML_MutexOp ||
Opcode == AML_EventOp ||
Opcode == AML_RegionOp ||
return ((BOOLEAN)
(Opcode == AML_SCOPE_OP ||
Opcode == AML_DEVICE_OP ||
Opcode == AML_THERMAL_ZONE_OP ||
Opcode == AML_METHOD_OP ||
Opcode == AML_POWER_RES_OP ||
Opcode == AML_PROCESSOR_OP ||
Opcode == AML_NAMEDFIELD_OP ||
Opcode == AML_NAME_OP ||
Opcode == AML_ALIAS_OP ||
Opcode == AML_MUTEX_OP ||
Opcode == AML_EVENT_OP ||
Opcode == AML_REGION_OP ||
Opcode == AML_CreateFieldOp ||
Opcode == AML_BitFieldOp ||
Opcode == AML_ByteFieldOp ||
Opcode == AML_WordFieldOp ||
Opcode == AML_DWordFieldOp ||
Opcode == AML_CREATE_FIELD_OP ||
Opcode == AML_BIT_FIELD_OP ||
Opcode == AML_BYTE_FIELD_OP ||
Opcode == AML_WORD_FIELD_OP ||
Opcode == AML_DWORD_FIELD_OP ||
Opcode == AML_METHODCALL_OP ||
Opcode == AML_NAMEPATH_OP));
}
@ -474,32 +464,32 @@ PsIsNamedObjectOp (
* Is opcode for a named Op?
*/
BOOLEAN
PsIsNamedOp (
AcpiPsIsNamedOp (
UINT16 Opcode)
{
return ((BOOLEAN)
(Opcode == AML_ScopeOp ||
Opcode == AML_DeviceOp ||
Opcode == AML_ThermalZoneOp ||
Opcode == AML_MethodOp ||
Opcode == AML_PowerResOp ||
Opcode == AML_ProcessorOp ||
Opcode == AML_NameOp ||
Opcode == AML_AliasOp ||
Opcode == AML_MutexOp ||
Opcode == AML_EventOp ||
Opcode == AML_RegionOp ||
Opcode == AML_NAMEDFIELD_OP));
return ((BOOLEAN)
(Opcode == AML_SCOPE_OP ||
Opcode == AML_DEVICE_OP ||
Opcode == AML_THERMAL_ZONE_OP ||
Opcode == AML_METHOD_OP ||
Opcode == AML_POWER_RES_OP ||
Opcode == AML_PROCESSOR_OP ||
Opcode == AML_NAME_OP ||
Opcode == AML_ALIAS_OP ||
Opcode == AML_MUTEX_OP ||
Opcode == AML_EVENT_OP ||
Opcode == AML_REGION_OP ||
Opcode == AML_NAMEDFIELD_OP));
}
BOOLEAN
PsIsDeferredOp (
AcpiPsIsDeferredOp (
UINT16 Opcode)
{
return ((BOOLEAN)
(Opcode == AML_MethodOp ||
Opcode == AML_RegionOp));
return ((BOOLEAN)
(Opcode == AML_METHOD_OP ||
Opcode == AML_REGION_OP));
}
@ -507,7 +497,7 @@ PsIsDeferredOp (
* Is opcode for a bytelist?
*/
BOOLEAN
PsIsBytelistOp (
AcpiPsIsBytelistOp (
UINT16 Opcode)
{
return ((BOOLEAN) (Opcode == AML_BYTELIST_OP));
@ -518,14 +508,30 @@ PsIsBytelistOp (
* Is opcode for a Field, IndexField, or BankField
*/
BOOLEAN
PsIsFieldOp (
AcpiPsIsFieldOp (
UINT16 Opcode)
{
return ((BOOLEAN)
(Opcode == AML_CreateFieldOp
|| Opcode == AML_DefFieldOp
|| Opcode == AML_IndexFieldOp
|| Opcode == AML_BankFieldOp));
return ((BOOLEAN)
(Opcode == AML_CREATE_FIELD_OP
|| Opcode == AML_DEF_FIELD_OP
|| Opcode == AML_INDEX_FIELD_OP
|| Opcode == AML_BANK_FIELD_OP));
}
/*
* Is field creation op
*/
BOOLEAN
AcpiPsIsCreateFieldOp (
UINT16 Opcode)
{
return ((BOOLEAN)
(Opcode == AML_CREATE_FIELD_OP ||
Opcode == AML_BIT_FIELD_OP ||
Opcode == AML_BYTE_FIELD_OP ||
Opcode == AML_WORD_FIELD_OP ||
Opcode == AML_DWORD_FIELD_OP));
}
@ -533,10 +539,10 @@ PsIsFieldOp (
* Cast an acpi_op to an acpi_deferred_op if possible
*/
ACPI_DEFERRED_OP *
PsToDeferredOp (
AcpiPsToDeferredOp (
ACPI_GENERIC_OP *Op)
{
return (PsIsDeferredOp (Op->Opcode)
return (AcpiPsIsDeferredOp (Op->Opcode)
? ( (ACPI_DEFERRED_OP *) Op) : NULL);
}
@ -545,10 +551,10 @@ PsToDeferredOp (
* Cast an acpi_op to an acpi_named_op if possible
*/
ACPI_NAMED_OP*
PsToNamedOp (
AcpiPsToNamedOp (
ACPI_GENERIC_OP *Op)
{
return (PsIsNamedOp (Op->Opcode)
return (AcpiPsIsNamedOp (Op->Opcode)
? ( (ACPI_NAMED_OP *) Op) : NULL);
}
@ -557,10 +563,10 @@ PsToNamedOp (
* Cast an acpi_op to an acpi_bytelist_op if possible
*/
ACPI_BYTELIST_OP*
PsToBytelistOp (
AcpiPsToBytelistOp (
ACPI_GENERIC_OP *Op)
{
return (PsIsBytelistOp (Op->Opcode)
return (AcpiPsIsBytelistOp (Op->Opcode)
? ( (ACPI_BYTELIST_OP*) Op) : NULL);
}
@ -569,10 +575,10 @@ PsToBytelistOp (
* Get op's name (4-byte name segment) or 0 if unnamed
*/
UINT32
PsGetName (
AcpiPsGetName (
ACPI_GENERIC_OP *Op)
{
ACPI_NAMED_OP *Named = PsToNamedOp (Op);
ACPI_NAMED_OP *Named = AcpiPsToNamedOp (Op);
return (Named ? Named->Name : 0);
}
@ -582,11 +588,11 @@ PsGetName (
* Set op's name
*/
void
PsSetName (
ACPI_GENERIC_OP *Op,
AcpiPsSetName (
ACPI_GENERIC_OP *Op,
UINT32 name)
{
ACPI_NAMED_OP *Named = PsToNamedOp (Op);
ACPI_NAMED_OP *Named = AcpiPsToNamedOp (Op);
if (Named)
{

View File

@ -1,5 +1,5 @@
/******************************************************************************
*
*
* Module Name: pswalk - Parser routines to walk parsed op tree(s)
*
*****************************************************************************/
@ -37,9 +37,9 @@
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
@ -47,11 +47,11 @@
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
@ -85,7 +85,7 @@
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
@ -114,22 +114,20 @@
*****************************************************************************/
#include <acpi.h>
#include <amlcode.h>
#include <parser.h>
#include <dispatch.h>
#include <namesp.h>
#include <interp.h>
#include "acpi.h"
#include "amlcode.h"
#include "parser.h"
#include "dispatch.h"
#include "namesp.h"
#include "interp.h"
#define _COMPONENT PARSER
MODULE_NAME ("pswalk");
/*******************************************************************************
*
* FUNCTION: PsGetNextWalkOp
* FUNCTION: AcpiPsGetNextWalkOp
*
* PARAMETERS: WalkState - Current state of the walk
* Op - Current Op to be walked
@ -144,7 +142,7 @@
******************************************************************************/
ACPI_STATUS
PsGetNextWalkOp (
AcpiPsGetNextWalkOp (
ACPI_WALK_STATE *WalkState,
ACPI_GENERIC_OP *Op,
INTERPRETER_CALLBACK AscendingCallback)
@ -164,7 +162,7 @@ PsGetNextWalkOp (
{
/* Look for an argument or child of the current op */
Next = PsGetArg (Op, 0);
Next = AcpiPsGetArg (Op, 0);
if (Next)
{
/* Still going downward in tree (Op is not completed yet) */
@ -177,7 +175,7 @@ PsGetNextWalkOp (
}
/*
/*
* No more children, this Op is complete. Save Next and Parent
* in case the Op object gets deleted by the callback routine
*/
@ -191,7 +189,7 @@ PsGetNextWalkOp (
{
case AE_CTRL_TERMINATE:
/*
/*
* A control method was terminated via a RETURN statement.
* The walk of this method is complete.
*/
@ -240,7 +238,7 @@ PsGetNextWalkOp (
default:
/*
/*
* Check for a sibling to the current op. A sibling means
* we are still going "downward" in the tree.
*/
@ -258,9 +256,9 @@ PsGetNextWalkOp (
return_ACPI_STATUS (Status);
}
/*
/*
* No sibling, but check status.
* Abort on error from callback routine
* Abort on error from callback routine
*/
if (Status != AE_OK)
{
@ -292,7 +290,7 @@ PsGetNextWalkOp (
/*
* Look for a sibling of the current Op's parent
* Continue moving up the tree until we find a node that has not been
* Continue moving up the tree until we find a node that has not been
* visited, or we get back to where we started.
*/
while (Parent)
@ -329,7 +327,7 @@ PsGetNextWalkOp (
case AE_CTRL_TRUE:
/*
/*
* Predicate of a WHILE was true and the loop just completed an execution.
* Go back to the start of the loop and reevaluate the predicate.
*/
@ -339,7 +337,7 @@ PsGetNextWalkOp (
WalkState->ControlState->Common.State = CONTROL_PREDICATE_EXECUTING;
WalkState->PrevOp = Op->Parent;
WalkState->NextOp = Op; /* Evaluate the predicate again (next) */
WalkState->NextOp = Op; /* AcpiEvaluate the predicate again (next) */
WalkState->NextOpInfo = NEXT_OP_DOWNWARD; /* Because we will traverse WHILE tree again */
return_ACPI_STATUS (AE_OK);
@ -348,7 +346,7 @@ PsGetNextWalkOp (
case AE_CTRL_TERMINATE:
/*
/*
* A control method was terminated via a RETURN statement.
* The walk of this method is complete.
*/
@ -390,7 +388,7 @@ PsGetNextWalkOp (
}
/*
* No sibling, check for an error from closing the parent
* No sibling, check for an error from closing the parent
* (Also, AE_PENDING if a method call was encountered)
*/
if (Status != AE_OK)
@ -398,7 +396,7 @@ PsGetNextWalkOp (
WalkState->PrevOp = Parent;
WalkState->NextOp = GrandParent;
WalkState->NextOpInfo = NEXT_OP_UPWARD;
return_ACPI_STATUS (Status);
}
@ -421,7 +419,7 @@ PsGetNextWalkOp (
/*******************************************************************************
*
* FUNCTION: PsWalkLoop
* FUNCTION: AcpiPsWalkLoop
*
* PARAMETERS: WalkList - State of the walk
* StartOp - Starting Op of the subtree to be walked
@ -431,12 +429,12 @@ PsGetNextWalkOp (
* RETURN: Status
*
* DESCRIPTION: Perform a walk of the parsed AML tree. Begins and terminates at
* the StartOp.
* the StartOp.
*
******************************************************************************/
ACPI_STATUS
PsWalkLoop (
AcpiPsWalkLoop (
ACPI_WALK_LIST *WalkList,
ACPI_GENERIC_OP *StartOp,
INTERPRETER_CALLBACK DescendingCallback,
@ -450,7 +448,7 @@ PsWalkLoop (
FUNCTION_TRACE_PTR ("PsWalkLoop", StartOp);
WalkState = DsGetCurrentWalkState (WalkList);
WalkState = AcpiDsGetCurrentWalkState (WalkList);
/* Walk entire subtree, visiting all nodes depth-first */
@ -462,7 +460,7 @@ PsWalkLoop (
Status = DescendingCallback (WalkState, Op);
}
/*
/*
* A TRUE exception means that an ELSE was detected, but the IF predicate evaluated TRUE.
*/
if (Status == AE_CTRL_TRUE)
@ -472,13 +470,13 @@ PsWalkLoop (
* And we do that by simply going up in the tree (either to the next sibling
* or to the parent) from here.
*/
WalkState->NextOpInfo = NEXT_OP_UPWARD;
}
/* Get the next node (op) in the depth-first walk */
Status = PsGetNextWalkOp (WalkState, Op, AscendingCallback);
Status = AcpiPsGetNextWalkOp (WalkState, Op, AscendingCallback);
/* A PENDING exception means that a control method invocation has been detected */
@ -486,11 +484,11 @@ PsWalkLoop (
{
/* Transfer control to the called control method */
Status = DsCallControlMethod (WalkList, WalkState, Op);
Status = AcpiDsCallControlMethod (WalkList, WalkState, Op);
/* If the method call worked, a new walk state was created -- get it */
WalkState = DsGetCurrentWalkState (WalkList);
WalkState = AcpiDsGetCurrentWalkState (WalkList);
}
/* Abort the walk on any exception */
@ -509,7 +507,7 @@ PsWalkLoop (
/*******************************************************************************
*
* FUNCTION: PsWalkParsedAml
* FUNCTION: AcpiPsWalkParsedAml
*
* PARAMETERS: StartOp - Starting Op of the subtree to be walked
* EndOp - Where to terminate the walk
@ -521,17 +519,17 @@ PsWalkLoop (
* DESCRIPTION: Top level interface to walk the parsed AML tree. Handles
* preemption of executing control methods.
*
* NOTE: The EndOp is usually only different from the StartOp if
* NOTE: The EndOp is usually only different from the StartOp if
* we don't want to visit the StartOp during the tree descent.
*
******************************************************************************/
ACPI_STATUS
PsWalkParsedAml (
AcpiPsWalkParsedAml (
ACPI_GENERIC_OP *StartOp,
ACPI_GENERIC_OP *EndOp,
ACPI_OBJECT_INTERNAL *MthDesc,
NAME_TABLE_ENTRY *StartScope,
ACPI_NAME_TABLE *StartScope,
ACPI_OBJECT_INTERNAL **Params,
ACPI_OBJECT_INTERNAL **CallerReturnDesc,
ACPI_OWNER_ID OwnerId,
@ -560,27 +558,22 @@ PsWalkParsedAml (
WalkList.WalkState = NULL;
WalkState = DsCreateWalkState (EndOp, MthDesc, &WalkList);
WalkState = AcpiDsCreateWalkState (OwnerId, EndOp, MthDesc, &WalkList);
if (!WalkState)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* TBD: move to createWalkSTate */
WalkState->OwnerId = OwnerId;
/* TBD:
* TEMP until we pass WalkState to the interpreter
/* TBD: [Restructure] TEMP until we pass WalkState to the interpreter
*/
PrevWalkList = Gbl_CurrentWalkList;
Gbl_CurrentWalkList = &WalkList;
PrevWalkList = AcpiGbl_CurrentWalkList;
AcpiGbl_CurrentWalkList = &WalkList;
if (StartScope)
{
/* Push start scope on scope stack and make it current */
Status = DsScopeStackPush (StartScope, ACPI_TYPE_Method, WalkState);
Status = AcpiDsScopeStackPush (StartScope, ACPI_TYPE_METHOD, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
@ -591,14 +584,14 @@ PsWalkParsedAml (
if (MthDesc)
{
/* Init arguments if this is a control method */
/* TBD: add walkstate as a param */
/* TBD: [Restructure] add walkstate as a param */
DsMethodDataInitArgs (Params, MTH_NUM_ARGS);
AcpiDsMethodDataInitArgs (Params, MTH_NUM_ARGS);
}
Op = StartOp;
Status = AE_OK;
/*
* Execute the walk loop as long as there is a valid Walk State. This handles nested
@ -611,7 +604,7 @@ PsWalkParsedAml (
{
if (Status == AE_OK)
{
Status = PsWalkLoop (&WalkList, Op, DescendingCallback, AscendingCallback);
Status = AcpiPsWalkLoop (&WalkList, Op, DescendingCallback, AscendingCallback);
}
DEBUG_PRINT (TRACE_PARSE, ("PsWalkParsedAml: Completed one call to walk loop, State=%p\n", WalkState));
@ -620,49 +613,41 @@ PsWalkParsedAml (
BREAKPOINT3;
WalkState = DsPopWalkState (&WalkList);
WalkState = AcpiDsPopWalkState (&WalkList);
ReturnDesc = WalkState->ReturnDesc; /* Extract return value before we delete WalkState */
DEBUG_PRINT (TRACE_PARSE, ("PsWalkParsedAml: ReturnValue=%p, State=%p\n", WalkState->ReturnDesc, WalkState));
/* Reset the current scope to the beginning of scope stack */
DsScopeStackClear (WalkState);
AcpiDsScopeStackClear (WalkState);
/* If we just returned from the execution of a control method, there's lots of cleanup to do */
if (WalkState->MethodDesc)
if (WalkState->MethodDesc &&
WalkState->MethodDesc->Method.ParserOp)
{
/* Signal completion of the execution of this method if necessary */
if (WalkState->MethodDesc->Method.Semaphore)
{
Status = OsdSignalSemaphore (WalkState->MethodDesc->Method.Semaphore, 1);
}
/* Delete all arguments and locals */
DsMethodDataDeleteAll (WalkState);
AcpiDsTerminateControlMethod (WalkState);
}
/* Delete this walk state and all linked control states */
DsDeleteWalkState (WalkState);
AcpiDsDeleteWalkState (WalkState);
/* Check if we have restarted a preempted walk */
WalkState = DsGetCurrentWalkState (&WalkList);
WalkState = AcpiDsGetCurrentWalkState (&WalkList);
if (WalkState &&
Status == AE_OK)
{
/* There is another walk state, restart it */
/*
/*
* If the method returned value is not used by the parent,
* The object is deleted
* The object is deleted
*/
DsRestartControlMethod (WalkState, ReturnDesc);
AcpiDsRestartControlMethod (WalkState, ReturnDesc);
/* Get the next Op to process */
@ -678,12 +663,12 @@ PsWalkParsedAml (
else if (ReturnDesc)
{
CmRemoveReference (ReturnDesc); /* Caller doesn't want it, must delete it */
AcpiCmRemoveReference (ReturnDesc); /* Caller doesn't want it, must delete it */
}
}
Gbl_CurrentWalkList = PrevWalkList;
AcpiGbl_CurrentWalkList = PrevWalkList;
return_ACPI_STATUS (Status);
}

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: psapi - Parser external interfaces
*
* Module Name: psxface - Parser external interfaces
*
*****************************************************************************/
@ -38,9 +38,9 @@
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
@ -48,11 +48,11 @@
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
@ -86,7 +86,7 @@
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
@ -114,109 +114,31 @@
*
*****************************************************************************/
#define __PSAPI_C__
#define __PSXFACE_C__
#include <acpi.h>
#include <parser.h>
#include <interp.h>
#include <amlcode.h>
#include <namesp.h>
#include "acpi.h"
#include "parser.h"
#include "dispatch.h"
#include "interp.h"
#include "amlcode.h"
#include "namesp.h"
#define _COMPONENT PARSER
MODULE_NAME ("psapi");
MODULE_NAME ("psxface");
char *Gbl_ParserId = "Non-recursive AML Parser";
char *AcpiGbl_ParserId = "Non-recursive AML Parser";
/*****************************************************************************
*
* FUNCTION: PsxLoadTable
*
* PARAMETERS: *PcodeAddr - Address of pcode block
* PcodeLength - Length of pcode block
*
* RETURN: Status
*
* DESCRIPTION: Mainline of the AML load/dump subsystem. Sets up the
* input engine, calls handler for outermost object type.
*
*
****************************************************************************/
ACPI_STATUS
PsxLoadTable (
UINT8 *PcodeAddr,
INT32 PcodeLength)
{
ACPI_STATUS Status;
FUNCTION_TRACE ("PsxLoadTable");
/* TBD By using the NAMESPACE mutex, this is now a namespace interface, move it */
if (!PcodeAddr)
{
DEBUG_PRINT (ACPI_ERROR, ("PsxLoadTable: Null AML pointer\n"));
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
DEBUG_PRINT (ACPI_INFO, ("PsxLoadTable: AML block at %p\n", PcodeAddr));
if (!PcodeLength)
{
DEBUG_PRINT (ACPI_ERROR, ("PsxLoadTable: Zero-length AML block\n"));
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
/*
* Parse the table and load the namespace with all named objects found within.
* Control methods are NOT parsed at this time. In fact, the control methods
* cannot be parsed until the entire namespace is loaded, because if a control
* method makes a forward reference (call) to another control method, we can't
* continue parsing because we don't know how many arguments to parse next!
*/
DEBUG_PRINT (ACPI_INFO, ("PsxLoadTable: **** Begin Namespace Load ****\n"));
BREAKPOINT3;
CmAcquireMutex (MTX_NAMESPACE);
Status = PsParseTable (PcodeAddr, PcodeLength, PsxLoad2BeginOp, PsxLoad2EndOp, NULL);
CmReleaseMutex (MTX_NAMESPACE);
/* TBD: Check if we should parse all methods here, or parse late */
/*
if (Gbl_MethodParsing = PARSE_EARLY)
{
*/
DEBUG_PRINT (ACPI_INFO, ("PsxLoadTable: **** Begin Object Initialization ****\n"));
BREAKPOINT3;
Status = PsxInitializeObjects ();
DEBUG_PRINT (ACPI_INFO, ("PsxLoadTable: **** Completed Object Initialization ****\n"));
BREAKPOINT3;
return_ACPI_STATUS (Status);
}
/*****************************************************************************
*
* FUNCTION: PsxExecute
* FUNCTION: AcpiPsxExecute
*
* PARAMETERS: ObjDesc - A method object containing both the AML
* address and length.
* **Params - List of parameters to pass to method,
* terminated by NULL. Params itself may be
* **Params - List of parameters to pass to method,
* terminated by NULL. Params itself may be
* NULL if no parameters are being passed.
*
* RETURN: Status
@ -226,48 +148,39 @@ BREAKPOINT3;
****************************************************************************/
ACPI_STATUS
PsxExecute (
NAME_TABLE_ENTRY *MethodEntry,
AcpiPsxExecute (
ACPI_NAMED_OBJECT *MethodEntry,
ACPI_OBJECT_INTERNAL **Params,
ACPI_OBJECT_INTERNAL **ReturnObjDesc)
{
ACPI_STATUS Status;
ACPI_OBJECT_INTERNAL *ObjDesc;
UINT8 *Pcode;
UINT32 PcodeLength;
UINT32 i;
FUNCTION_TRACE ("PsxExecute");
ObjDesc = MethodEntry->Object;
Pcode = ObjDesc->Method.Pcode;
PcodeLength = ObjDesc->Method.PcodeLength;
/* Validate the NTE and get the attached object */
BREAKPOINT3;
/* If method not parsed yet, must parse it first */
if (!ObjDesc->Method.ParserOp)
if (!MethodEntry)
{
DEBUG_PRINT (ACPI_INFO, ("PsxExecute: **** Parsing Method **** obj=%p\n",
ObjDesc));
Status = PsxParseMethod (MethodEntry);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
return_ACPI_STATUS (AE_NULL_ENTRY);
}
ObjDesc = AcpiNsGetAttachedObject (MethodEntry);
if (!ObjDesc)
{
return_ACPI_STATUS (AE_NULL_OBJECT);
}
DEBUG_PRINT (ACPI_INFO, ("PsxExecute: **** Begin Execution **** obj=%p code=%p len=%X\n",
ObjDesc, Pcode, PcodeLength));
/* Parse method if necessary, wait on concurrency semaphore */
Status = AcpiDsBeginMethodExecution (MethodEntry, ObjDesc);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
if (Params)
{
@ -275,49 +188,33 @@ BREAKPOINT3;
for (i = 0; Params[i]; i++)
{
CmUpdateObjectReference (Params[i], REF_INCREMENT);
AcpiCmAddReference (Params[i]);
}
}
/*
* If there is a concurrency limit on this method, we need to obtain a unit
* from the method semaphore. This releases the interpreter if we block
/*
* Method is parsed and ready to execute
* The walk of the parse tree is where we actually execute the method
*/
if (ObjDesc->Method.Semaphore)
{
Status = OsLocalWaitSemaphore (ObjDesc->Method.Semaphore, WAIT_FOREVER);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
DEBUG_PRINT (ACPI_INFO, ("PsxExecute: **** Begin Method Execution **** Entry=%p obj=%p\n",
MethodEntry, ObjDesc));
/* Method is parsed and ready to execute */
/* This is where we really execute the method */
Status = PsWalkParsedAml (ObjDesc->Method.ParserOp, ObjDesc->Method.ParserOp, ObjDesc, MethodEntry->Scope, Params,
ReturnObjDesc, PsxExecBeginOp, PsxExecEndOp);
/* Signal completion of the execution of this method if necessary */
if (ObjDesc->Method.Semaphore)
{
Status = OsdSignalSemaphore (ObjDesc->Method.Semaphore, 1);
}
Status = AcpiPsWalkParsedAml (ObjDesc->Method.ParserOp, ObjDesc->Method.ParserOp, ObjDesc, MethodEntry->ChildTable, Params,
ReturnObjDesc, ObjDesc->Method.OwningId, AcpiDsExecBeginOp, AcpiDsExecEndOp);
if (Params)
{
/* Take away the extra reference we gave the parameters above */
/* Take away the extra reference that we gave the parameters above */
for (i = 0; Params[i]; i++)
{
CmUpdateObjectReference (Params[i], REF_DECREMENT);
AcpiCmUpdateObjectReference (Params[i], REF_DECREMENT);
}
}
/*
/*
* Normal exit is with Status == AE_RETURN_VALUE when a ReturnOp has been executed,
* or with Status == AE_PENDING at end of AML block (end of Method code)
*/
@ -327,31 +224,11 @@ BREAKPOINT3;
DEBUG_PRINT (ACPI_INFO, ("Method returned ObjDesc=%X\n", *ReturnObjDesc));
DUMP_STACK_ENTRY (*ReturnObjDesc);
Status = AE_RETURN_VALUE;
Status = AE_CTRL_RETURN_VALUE;
}
else
{
/* Map PENDING (normal exit, no return value) to OK */
if (AE_PENDING == Status)
{
Status = AE_OK;
}
}
/* Delete the parse tree upon method completion if asked to */
if (Gbl_WhenToParseMethods & METHOD_DELETE_AT_COMPLETION)
{
PsDeleteParseTree (ObjDesc->Method.ParserOp);
ObjDesc->Method.ParserOp = NULL;
}
return_ACPI_STATUS (Status);
}