dswstate.c revision 199767f8919635c4928607450d9e0abb932109ce
/******************************************************************************
*
* Module Name: dswstate - Dispatcher parse tree walk management routines
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2015, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dswstate")
/* Local prototypes */
static ACPI_STATUS
static ACPI_STATUS
/*******************************************************************************
*
* FUNCTION: AcpiDsResultPop
*
* PARAMETERS: Object - Where to return the popped object
* WalkState - Current Walk state
*
* RETURN: Status
*
* DESCRIPTION: Pop an object off the top of this walk's result stack
*
******************************************************************************/
{
/* Incorrect state of result stack */
{
return (AE_AML_INTERNAL);
}
{
return (AE_AML_INTERNAL);
}
/* Empty result stack */
if (!State)
{
return (AE_AML_NO_RETURN_VALUE);
}
/* Return object of the top element and clean that top element result stack */
WalkState->ResultCount--;
if (!*Object)
{
WalkState));
return (AE_AML_NO_RETURN_VALUE);
}
if (Index == 0)
{
if (ACPI_FAILURE (Status))
{
return (Status);
}
}
"Obj=%p [%s] Index=%X State=%p Num=%X\n", *Object,
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsResultPush
*
* PARAMETERS: Object - Where to return the popped object
* WalkState - Current Walk state
*
* RETURN: Status
*
* DESCRIPTION: Push an object onto the current result stack
*
******************************************************************************/
{
{
return (AE_AML_INTERNAL);
}
{
/* Extend the result stack */
if (ACPI_FAILURE (Status))
{
return (Status);
}
}
{
return (AE_AML_INTERNAL);
}
if (!State)
{
return (AE_AML_INTERNAL);
}
if (!Object)
{
"Null Object! Obj=%p State=%p Num=%u",
return (AE_BAD_PARAMETER);
}
/* Assign the address of object to the top free element of result stack */
WalkState->ResultCount++;
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsResultStackPush
*
* PARAMETERS: WalkState - Current Walk state
*
* RETURN: Status
*
* DESCRIPTION: Push an object onto the WalkState result stack
*
******************************************************************************/
static ACPI_STATUS
{
/* Check for stack overflow */
{
return (AE_STACK_OVERFLOW);
}
if (!State)
{
return (AE_NO_MEMORY);
}
/* Increase the length of the result stack by the length of frame */
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsResultStackPop
*
* PARAMETERS: WalkState - Current Walk state
*
* RETURN: Status
*
* DESCRIPTION: Pop an object off of the WalkState result stack
*
******************************************************************************/
static ACPI_STATUS
{
/* Check for stack underflow */
{
WalkState));
return (AE_AML_NO_OPERAND);
}
{
return (AE_AML_INTERNAL);
}
/* Decrease the length of result stack by the length of frame */
"Result=%p RemainingResults=%X State=%p\n",
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsObjStackPush
*
* PARAMETERS: Object - Object to push
* WalkState - Current Walk state
*
* RETURN: Status
*
*
******************************************************************************/
void *Object,
{
/* Check for stack overflow */
{
"Object stack overflow! Obj=%p State=%p #Ops=%u",
return (AE_STACK_OVERFLOW);
}
/* Put the object onto the stack */
WalkState->NumOperands++;
/* For the usual order of filling the operand stack */
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsObjStackPop
*
* WalkState - Current Walk state
*
* RETURN: Status
*
* DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
* deleted by this routine.
*
******************************************************************************/
{
UINT32 i;
for (i = 0; i < PopCount; i++)
{
/* Check for stack underflow */
if (WalkState->NumOperands == 0)
{
"Object stack underflow! Count=%X State=%p #Ops=%u",
return (AE_STACK_UNDERFLOW);
}
/* Just set the stack entry to null */
WalkState->NumOperands--;
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsObjStackPopAndDelete
*
* WalkState - Current Walk state
*
* RETURN: Status
*
* DESCRIPTION: Pop this walk's object stack and delete each object that is
* popped off.
*
******************************************************************************/
void
{
INT32 i;
if (PopCount == 0)
{
return;
}
{
if (WalkState->NumOperands == 0)
{
return;
}
/* Pop the stack and delete an object if present in this stack entry */
WalkState->NumOperands--;
if (ObjDesc)
{
}
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDsGetCurrentWalkState
*
* PARAMETERS: Thread - Get current active state for this Thread
*
* RETURN: Pointer to the current walk state
*
* DESCRIPTION: Get the walk state that is at the head of the list (the "current"
* walk state.)
*
******************************************************************************/
{
if (!Thread)
{
return (NULL);
}
Thread->WalkStateList));
return (Thread->WalkStateList);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsPushWalkState
*
* PARAMETERS: WalkState - State to push
* Thread - Thread state object
*
* RETURN: None
*
* DESCRIPTION: Place the Thread state at the head of the state list
*
******************************************************************************/
void
{
}
/*******************************************************************************
*
* FUNCTION: AcpiDsPopWalkState
*
* PARAMETERS: Thread - Current thread state
*
* RETURN: A WalkState object popped from the thread's stack
*
* DESCRIPTION: Remove and return the walkstate object that is at the head of
* the walk stack for the given walk list. NULL indicates that
* the list is empty.
*
******************************************************************************/
{
if (WalkState)
{
/* Next walk state becomes the current walk state */
/*
* Don't clear the NEXT field, this serves as an indicator
* that there is a parent WALK STATE
* Do Not: WalkState->Next = NULL;
*/
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDsCreateWalkState
*
* PARAMETERS: OwnerId - ID for object creation
* Origin - Starting point for this walk
* MethodDesc - Method object
* Thread - Current thread state
*
* RETURN: Pointer to the new walk state.
*
* DESCRIPTION: Allocate and initialize a new walk state. The current walk
* state is set to this new state.
*
******************************************************************************/
{
if (!WalkState)
{
return_PTR (NULL);
}
#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
#endif
/* Put the new state at the head of the walk list */
if (Thread)
{
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDsInitAmlWalk
*
* PARAMETERS: WalkState - New state to be initialized
* Op - Current parse op
* MethodNode - Control method NS node, if any
* AmlStart - Start of AML
* AmlLength - Length of AML
* Info - Method info block (params, etc.)
* PassNumber - 1, 2, or 3
*
* RETURN: Status
*
* DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk
*
******************************************************************************/
{
/* The NextOp of the NextWalk will be the beginning of the method */
if (Info)
{
}
if (ACPI_FAILURE (Status))
{
}
if (MethodNode)
{
/* Push start scope on scope stack and make it current */
if (ACPI_FAILURE (Status))
{
}
/* Init the method arguments */
if (ACPI_FAILURE (Status))
{
}
}
else
{
/*
* Setup the current scope.
* Find a Named Op that has a namespace node associated with it.
* search upwards from this Op. Current scope is the first
* Op with a namespace node.
*/
{
}
if (!ExtraOp)
{
}
else
{
}
if (ParserState->StartNode)
{
/* Push start scope on scope stack and make it current */
if (ACPI_FAILURE (Status))
{
}
}
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDsDeleteWalkState
*
* PARAMETERS: WalkState - State to delete
*
* RETURN: Status
*
* DESCRIPTION: Delete a walk state including all internal data structures
*
******************************************************************************/
void
{
if (!WalkState)
{
}
{
WalkState));
}
/* There should not be any open scopes */
{
WalkState));
}
/* Always must free any linked control states */
while (WalkState->ControlState)
{
}
/* Always must free any linked parse states */
{
}
/* Always must free any stacked result states */
{
}
}