dsopcode.c revision 27f7c58306b55fe9e0cfd2934039be1729b505e9
/******************************************************************************
*
* Module Name: dsopcode - Dispatcher Op Region support and handling of
* "control" opcodes
* $Revision: 1.108 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 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,
* and the following Disclaimer and Export Compliance provision. In addition,
* 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
* 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.
* 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
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* 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.
*
* 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
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
#define __DSOPCODE_C__
#include "acpi.h"
#include "acparser.h"
#include "amlcode.h"
#include "acdispat.h"
#include "acinterp.h"
#include "acnamesp.h"
#include "acevents.h"
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dsopcode")
/* Local prototypes */
static ACPI_STATUS
static ACPI_STATUS
/*******************************************************************************
*
* FUNCTION: AcpiDsExecuteArguments
*
* PARAMETERS: Node - Object NS node
* ScopeNode - Parent NS node
* AmlLength - Length of executable AML
* AmlStart - Pointer to the AML
*
* RETURN: Status.
*
* DESCRIPTION: Late (deferred) execution of region or field arguments
*
******************************************************************************/
static ACPI_STATUS
{
/*
* Allocate a new parser op to be the root of the parsed tree
*/
if (!Op)
{
}
/* Save the Node for use in AcpiPsParseAml */
/* Create and initialize a new parser state */
if (!WalkState)
{
goto Cleanup;
}
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
/* Mark this parse as a deferred opcode */
/* Pass1: Parse the entire declaration */
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
/* Get and init the Op created above */
/* Evaluate the deferred arguments */
if (!Op)
{
}
/* Create and initialize a new parser state */
if (!WalkState)
{
goto Cleanup;
}
/* Execute the opcode and arguments */
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
/* Mark this execution as a deferred opcode */
}
/*******************************************************************************
*
* FUNCTION: AcpiDsGetBufferFieldArguments
*
* PARAMETERS: ObjDesc - A valid BufferField object
*
* RETURN: Status.
*
* DESCRIPTION: Get BufferField Buffer and Index. This implements the late
* evaluation of these field attributes.
*
******************************************************************************/
{
{
}
/* Get the AML pointer (method object) and BufferField node */
AcpiUtGetNodeName (Node)));
/* Execute the AML code for the TermArg arguments */
}
/*******************************************************************************
*
* FUNCTION: AcpiDsGetBufferArguments
*
* PARAMETERS: ObjDesc - A valid Buffer object
*
* RETURN: Status.
*
* DESCRIPTION: Get Buffer length and initializer byte list. This implements
* the late evaluation of these attributes.
*
******************************************************************************/
{
{
}
/* Get the Buffer node */
if (!Node)
{
"No pointer back to NS node in buffer obj %p", ObjDesc));
}
/* Execute the AML code for the TermArg arguments */
}
/*******************************************************************************
*
* FUNCTION: AcpiDsGetPackageArguments
*
* PARAMETERS: ObjDesc - A valid Package object
*
* RETURN: Status.
*
* DESCRIPTION: Get Package length and initializer byte list. This implements
* the late evaluation of these attributes.
*
******************************************************************************/
{
{
}
/* Get the Package node */
if (!Node)
{
"No pointer back to NS node in package %p", ObjDesc));
}
/* Execute the AML code for the TermArg arguments */
}
/*****************************************************************************
*
* FUNCTION: AcpiDsGetRegionArguments
*
* PARAMETERS: ObjDesc - A valid region object
*
* RETURN: Status.
*
* DESCRIPTION: Get region address and length. This implements the late
* evaluation of these region attributes.
*
****************************************************************************/
{
{
}
if (!ExtraDesc)
{
}
/* Get the Region node */
/* Execute the argument AML */
if (ACPI_FAILURE (Status))
{
}
if (ACPI_FAILURE (Status))
{
/*
* the region as invalid, so that it will cause an additional error if
* it is ever used. Then return AE_OK.
*/
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDsInitializeRegion
*
* PARAMETERS: ObjHandle - Region namespace node
*
* RETURN: Status
*
* DESCRIPTION: Front end to EvInitializeRegion
*
******************************************************************************/
{
/* Namespace is NOT locked */
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsInitBufferField
*
* PARAMETERS: AmlOpcode - CreateXxxField
* ObjDesc - BufferField object
* BufferDesc - Host Buffer
* OffsetDesc - Offset into buffer
* LengthDesc - Length of field (CREATE_FIELD_OP only)
* ResultDesc - Where to store the result
*
* RETURN: Status
*
* DESCRIPTION: Perform actual initialization of a buffer field
*
******************************************************************************/
static ACPI_STATUS
{
/* Host object must be a Buffer */
{
"Target of Create Field is not a Buffer object - %s",
goto Cleanup;
}
/*
* The last parameter to all of these opcodes (ResultDesc) started
* out as a NameString, and should therefore now be a NS node
* after resolution in AcpiExResolveOperands().
*/
{
"(%s) destination not a NS Node [%s]",
goto Cleanup;
}
/*
* Setup the Bit offsets and counts, according to the opcode
*/
switch (AmlOpcode)
{
case AML_CREATE_FIELD_OP:
/* Offset is in bits, count is in bits */
/* Must have a valid (>0) bit count */
if (BitCount == 0)
{
"Attempt to CreateField of length zero"));
goto Cleanup;
}
break;
case AML_CREATE_BIT_FIELD_OP:
/* Offset is in bits, Field is one bit */
BitCount = 1;
break;
case AML_CREATE_BYTE_FIELD_OP:
/* Offset is in bytes, field is one byte */
BitCount = 8;
break;
case AML_CREATE_WORD_FIELD_OP:
/* Offset is in bytes, field is one word */
BitCount = 16;
break;
/* Offset is in bytes, field is one dword */
BitCount = 32;
break;
/* Offset is in bytes, field is one qword */
BitCount = 64;
break;
default:
"Unknown field creation opcode %02x",
AmlOpcode));
goto Cleanup;
}
/* Entire field must fit within the current length of the buffer */
{
"Field [%4.4s] at %d exceeds Buffer [%4.4s] size %d (bits)",
goto Cleanup;
}
/*
* Initialize areas of the field object that are common to all fields
* For FieldFlags, use LOCK_RULE = 0 (NO_LOCK),
* UPDATE_RULE = 0 (UPDATE_PRESERVE)
*/
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
/* Reference count for BufferDesc inherits ObjDesc count */
/* Always delete the operands */
if (AmlOpcode == AML_CREATE_FIELD_OP)
{
}
/* On failure, delete the result descriptor */
if (ACPI_FAILURE (Status))
{
}
else
{
/* Now the address and length are valid for this BufferField */
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDsEvalBufferFieldOperands
*
* PARAMETERS: WalkState - Current walk
* Op - A valid BufferField Op object
*
* RETURN: Status
*
* DESCRIPTION: Get BufferField Buffer and Index
* Called from AcpiDsExecEndOp during BufferField parse tree walk
*
******************************************************************************/
{
/*
* This is where we evaluate the address and length fields of the
* CreateXxxField declaration
*/
/* NextOp points to the op that holds the Buffer */
if (ACPI_FAILURE (Status))
{
}
if (!ObjDesc)
{
}
/* Resolve the operands */
if (ACPI_FAILURE (Status))
{
}
/* Initialize the Buffer Field */
{
/* NOTE: Slightly different operands for this opcode */
}
else
{
/* All other, CreateXxxField opcodes */
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDsEvalRegionOperands
*
* PARAMETERS: WalkState - Current walk
* Op - A valid region Op object
*
* RETURN: Status
*
* DESCRIPTION: Get region address and length
* Called from AcpiDsExecEndOp during OpRegion parse tree walk
*
******************************************************************************/
{
/*
* This is where we evaluate the address and length fields of the
* OpRegion declaration
*/
/* NextOp points to the op that holds the SpaceID */
/* NextOp points to address op */
if (ACPI_FAILURE (Status))
{
}
/* Resolve the length and address operands to numbers */
if (ACPI_FAILURE (Status))
{
}
1, "after AcpiExResolveOperands");
if (!ObjDesc)
{
}
/*
* Get the length operand and save it
* (at Top of stack)
*/
/*
* Get the address and save it
* (at top of stack - 1)
*/
/* Now the address and length are valid for this opregion */
}
/*******************************************************************************
*
* FUNCTION: AcpiDsEvalDataObjectOperands
*
* PARAMETERS: WalkState - Current walk
* Op - A valid DataObject Op object
* ObjDesc - DataObject
*
* RETURN: Status
*
* DESCRIPTION: Get the operands and complete the following data object types:
* Buffer, Package.
*
******************************************************************************/
{
/* The first operand (for all of these data objects) is the length */
if (ACPI_FAILURE (Status))
{
}
if (ACPI_FAILURE (Status))
{
}
/* Extract length operand */
/* Cleanup for length operand */
if (ACPI_FAILURE (Status))
{
}
/*
* Create the actual data object
*/
{
case AML_BUFFER_OP:
break;
case AML_PACKAGE_OP:
case AML_VAR_PACKAGE_OP:
break;
default:
}
if (ACPI_SUCCESS (Status))
{
/*
* Return the object in the WalkState, unless the parent is a package -
* in this case, the return object will be stored in the parse tree
* for the package.
*/
{
}
}
}
/*******************************************************************************
*
* 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_IF_OP:
case AML_WHILE_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, go back and evaluate it again! */
}
"[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!
*/
}
{
/* 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:
/* Call up to the OS service layer to handle this */
/* If and when it returns, all done. */
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);
}