dscontrol.c revision 199767f8919635c4928607450d9e0abb932109ce
/******************************************************************************
*
* Module Name: dscontrol - Support for execution control opcodes -
*
*****************************************************************************/
/*
* 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 ("dscontrol")
/*******************************************************************************
*
* FUNCTION: AcpiDsExecBeginControlOp
*
* PARAMETERS: WalkList - The list that owns the walk stack
* Op - The control Op
*
* RETURN: Status
*
* DESCRIPTION: Handles all control ops encountered during control method
* execution.
*
******************************************************************************/
{
{
case AML_WHILE_OP:
/*
* If this is an additional iteration of a while loop, continue.
* There is no need to allocate a new control state.
*/
if (WalkState->ControlState)
{
{
/* Reset the state to start-of-loop */
break;
}
}
/*lint -fallthrough */
case AML_IF_OP:
/*
* constructs. We need to manage these as a stack, in order
* to handle nesting.
*/
if (!ControlState)
{
break;
}
/*
* Save a pointer to the predicate for multiple executions
* of a loop
*/
/* Push the control state on this walk's control stack */
break;
case AML_ELSE_OP:
/* Predicate is in the state object */
/* If predicate is true, the IF was executed, ignore ELSE part */
if (WalkState->LastPredicate)
{
}
break;
case AML_RETURN_OP:
break;
default:
break;
}
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsExecEndControlOp
*
* PARAMETERS: WalkList - The list that owns the walk stack
* Op - The control Op
*
* RETURN: Status
*
* DESCRIPTION: Handles all control ops encountered during control method
* execution.
*
******************************************************************************/
{
{
case AML_IF_OP:
/*
* Save the result of the predicate in case there is an
* ELSE to come
*/
/*
* Pop the control state that was created at the start
* of the IF and free it
*/
break;
case AML_ELSE_OP:
break;
case AML_WHILE_OP:
{
/* Predicate was true, the body of the loop was just executed */
/*
* This loop counter mechanism allows the interpreter to escape
* possibly infinite loops. This can occur in poorly written AML
* when the hardware does not respond within a while loop and the
* loop does not implement a timeout.
*/
{
break;
}
/*
* Go back and evaluate the predicate and maybe execute the loop
* another time
*/
break;
}
/* Predicate was false, terminate this while loop */
"[WHILE_OP] termination! Op=%p\n",Op));
/* Pop this control state and free it */
break;
case AML_RETURN_OP:
/*
* One optional operand -- the return value
* It can be either an immediate operand or a result that
* has been bubbled up the tree
*/
{
/* Since we have a real Return(), delete any implicit return */
/* Return statement has an immediate operand */
if (ACPI_FAILURE (Status))
{
return (Status);
}
/*
* If value being returned is a Reference (such as
* an arg or local), resolve it now because it may
* cease to exist at the end of the method.
*/
if (ACPI_FAILURE (Status))
{
return (Status);
}
/*
* Get the return value and save as the last result
* value. This is the only place where WalkState->ReturnDesc
* is set to anything other than zero!
*/
}
else if (WalkState->ResultCount)
{
/* Since we have a real Return(), delete any implicit return */
/*
* The return value has come from a previous calculation.
*
* If value being returned is a Reference (such as
* an arg or local), resolve it now because it may
* cease to exist at the end of the method.
*
* Allow references created by the Index operator to return
* unchanged.
*/
if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) &&
{
if (ACPI_FAILURE (Status))
{
return (Status);
}
}
}
else
{
/* No return operand */
if (WalkState->NumOperands)
{
}
WalkState->NumOperands = 0;
}
"Completed RETURN_OP State=%p, RetVal=%p\n",
/* End the control method execution right now */
break;
case AML_NOOP_OP:
/* Just do nothing! */
break;
case AML_BREAK_POINT_OP:
/*
* Set the single-step flag. This will cause the debugger (if present)
* to break to the console within the AML debugger at the start of the
* next AML instruction.
*/
AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n"));
/* Call to the OSL in case OS wants a piece of the action */
"Executed AML Breakpoint opcode");
break;
case AML_BREAK_OP:
case AML_CONTINUE_OP: /* ACPI 2.0 */
/* Pop and delete control states until we find a while */
while (WalkState->ControlState &&
{
}
/* No while found? */
if (!WalkState->ControlState)
{
return (AE_AML_NO_WHILE);
}
/* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */
/* Return status depending on opcode */
{
}
else
{
}
break;
default:
break;
}
return (Status);
}