Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1497 → Rev 1498

/drivers/devman/acpica/parser/psargs.c
0,0 → 1,893
/******************************************************************************
*
* Module Name: psargs - Parse AML opcode arguments
*
*****************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, 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
* documentation and/or other materials provided with distribution. In
* 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
* provision in the documentation and/or other materials provided with the
* 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
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* 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 __PSARGS_C__
 
#include "acpi.h"
#include "accommon.h"
#include "acparser.h"
#include "amlcode.h"
#include "acnamesp.h"
#include "acdispat.h"
 
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("psargs")
 
/* Local prototypes */
 
static UINT32
AcpiPsGetNextPackageLength (
ACPI_PARSE_STATE *ParserState);
 
static ACPI_PARSE_OBJECT *
AcpiPsGetNextField (
ACPI_PARSE_STATE *ParserState);
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsGetNextPackageLength
*
* PARAMETERS: ParserState - Current parser state object
*
* RETURN: Decoded package length. On completion, the AML pointer points
* past the length byte or bytes.
*
* DESCRIPTION: Decode and return a package length field.
* Note: Largest package length is 28 bits, from ACPI specification
*
******************************************************************************/
 
static UINT32
AcpiPsGetNextPackageLength (
ACPI_PARSE_STATE *ParserState)
{
UINT8 *Aml = ParserState->Aml;
UINT32 PackageLength = 0;
UINT32 ByteCount;
UINT8 ByteZeroMask = 0x3F; /* Default [0:5] */
 
 
ACPI_FUNCTION_TRACE (PsGetNextPackageLength);
 
 
/*
* Byte 0 bits [6:7] contain the number of additional bytes
* used to encode the package length, either 0,1,2, or 3
*/
ByteCount = (Aml[0] >> 6);
ParserState->Aml += ((ACPI_SIZE) ByteCount + 1);
 
/* Get bytes 3, 2, 1 as needed */
 
while (ByteCount)
{
/*
* Final bit positions for the package length bytes:
* Byte3->[20:27]
* Byte2->[12:19]
* Byte1->[04:11]
* Byte0->[00:03]
*/
PackageLength |= (Aml[ByteCount] << ((ByteCount << 3) - 4));
 
ByteZeroMask = 0x0F; /* Use bits [0:3] of byte 0 */
ByteCount--;
}
 
/* Byte 0 is a special case, either bits [0:3] or [0:5] are used */
 
PackageLength |= (Aml[0] & ByteZeroMask);
return_UINT32 (PackageLength);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsGetNextPackageEnd
*
* PARAMETERS: ParserState - Current parser state object
*
* RETURN: Pointer to end-of-package +1
*
* DESCRIPTION: Get next package length and return a pointer past the end of
* the package. Consumes the package length field
*
******************************************************************************/
 
UINT8 *
AcpiPsGetNextPackageEnd (
ACPI_PARSE_STATE *ParserState)
{
UINT8 *Start = ParserState->Aml;
UINT32 PackageLength;
 
 
ACPI_FUNCTION_TRACE (PsGetNextPackageEnd);
 
 
/* Function below updates ParserState->Aml */
 
PackageLength = AcpiPsGetNextPackageLength (ParserState);
 
return_PTR (Start + PackageLength); /* end of package */
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsGetNextNamestring
*
* PARAMETERS: ParserState - Current parser state object
*
* RETURN: Pointer to the start of the name string (pointer points into
* the AML.
*
* DESCRIPTION: Get next raw namestring within the AML stream. Handles all name
* prefix characters. Set parser state to point past the string.
* (Name is consumed from the AML.)
*
******************************************************************************/
 
char *
AcpiPsGetNextNamestring (
ACPI_PARSE_STATE *ParserState)
{
UINT8 *Start = ParserState->Aml;
UINT8 *End = ParserState->Aml;
 
 
ACPI_FUNCTION_TRACE (PsGetNextNamestring);
 
 
/* Point past any namestring prefix characters (backslash or carat) */
 
while (AcpiPsIsPrefixChar (*End))
{
End++;
}
 
/* Decode the path prefix character */
 
switch (*End)
{
case 0:
 
/* NullName */
 
if (End == Start)
{
Start = NULL;
}
End++;
break;
 
case AML_DUAL_NAME_PREFIX:
 
/* Two name segments */
 
End += 1 + (2 * ACPI_NAME_SIZE);
break;
 
case AML_MULTI_NAME_PREFIX_OP:
 
/* Multiple name segments, 4 chars each, count in next byte */
 
End += 2 + (*(End + 1) * ACPI_NAME_SIZE);
break;
 
default:
 
/* Single name segment */
 
End += ACPI_NAME_SIZE;
break;
}
 
ParserState->Aml = End;
return_PTR ((char *) Start);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsGetNextNamepath
*
* PARAMETERS: ParserState - Current parser state object
* Arg - Where the namepath will be stored
* ArgCount - If the namepath points to a control method
* the method's argument is returned here.
* PossibleMethodCall - Whether the namepath can possibly be the
* start of a method call
*
* RETURN: Status
*
* DESCRIPTION: Get next name (if method call, return # of required args).
* Names are looked up in the internal namespace to determine
* if the name represents a control method. If a method
* is found, the number of arguments to the method is returned.
* This information is critical for parsing to continue correctly.
*
******************************************************************************/
 
ACPI_STATUS
AcpiPsGetNextNamepath (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_STATE *ParserState,
ACPI_PARSE_OBJECT *Arg,
BOOLEAN PossibleMethodCall)
{
ACPI_STATUS Status;
char *Path;
ACPI_PARSE_OBJECT *NameOp;
ACPI_OPERAND_OBJECT *MethodDesc;
ACPI_NAMESPACE_NODE *Node;
UINT8 *Start = ParserState->Aml;
 
 
ACPI_FUNCTION_TRACE (PsGetNextNamepath);
 
 
Path = AcpiPsGetNextNamestring (ParserState);
AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
 
/* Null path case is allowed, just exit */
 
if (!Path)
{
Arg->Common.Value.Name = Path;
return_ACPI_STATUS (AE_OK);
}
 
/*
* Lookup the name in the internal namespace, starting with the current
* scope. We don't want to add anything new to the namespace here,
* however, so we use MODE_EXECUTE.
* Allow searching of the parent tree, but don't open a new scope -
* we just want to lookup the object (must be mode EXECUTE to perform
* the upsearch)
*/
Status = AcpiNsLookup (WalkState->ScopeInfo, Path,
ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
 
/*
* If this name is a control method invocation, we must
* setup the method call
*/
if (ACPI_SUCCESS (Status) &&
PossibleMethodCall &&
(Node->Type == ACPI_TYPE_METHOD))
{
if (WalkState->Opcode == AML_UNLOAD_OP)
{
/*
* AcpiPsGetNextNamestring has increased the AML pointer,
* so we need to restore the saved AML pointer for method call.
*/
WalkState->ParserState.Aml = Start;
WalkState->ArgCount = 1;
AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
return_ACPI_STATUS (AE_OK);
}
 
/* This name is actually a control method invocation */
 
MethodDesc = AcpiNsGetAttachedObject (Node);
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
"Control Method - %p Desc %p Path=%p\n", Node, MethodDesc, Path));
 
NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
if (!NameOp)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
 
/* Change Arg into a METHOD CALL and attach name to it */
 
AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
NameOp->Common.Value.Name = Path;
 
/* Point METHODCALL/NAME to the METHOD Node */
 
NameOp->Common.Node = Node;
AcpiPsAppendArg (Arg, NameOp);
 
if (!MethodDesc)
{
ACPI_ERROR ((AE_INFO,
"Control Method %p has no attached object",
Node));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
 
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
"Control Method - %p Args %X\n",
Node, MethodDesc->Method.ParamCount));
 
/* Get the number of arguments to expect */
 
WalkState->ArgCount = MethodDesc->Method.ParamCount;
return_ACPI_STATUS (AE_OK);
}
 
/*
* Special handling if the name was not found during the lookup -
* some NotFound cases are allowed
*/
if (Status == AE_NOT_FOUND)
{
/* 1) NotFound is ok during load pass 1/2 (allow forward references) */
 
if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) !=
ACPI_PARSE_EXECUTE)
{
Status = AE_OK;
}
 
/* 2) NotFound during a CondRefOf(x) is ok by definition */
 
else if (WalkState->Op->Common.AmlOpcode == AML_COND_REF_OF_OP)
{
Status = AE_OK;
}
 
/*
* 3) NotFound while building a Package is ok at this point, we
* may flag as an error later if slack mode is not enabled.
* (Some ASL code depends on allowing this behavior)
*/
else if ((Arg->Common.Parent) &&
((Arg->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
(Arg->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)))
{
Status = AE_OK;
}
}
 
/* Final exception check (may have been changed from code above) */
 
if (ACPI_FAILURE (Status))
{
ACPI_ERROR_NAMESPACE (Path, Status);
 
if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) ==
ACPI_PARSE_EXECUTE)
{
/* Report a control method execution error */
 
Status = AcpiDsMethodError (Status, WalkState);
}
}
 
/* Save the namepath */
 
Arg->Common.Value.Name = Path;
return_ACPI_STATUS (Status);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsGetNextSimpleArg
*
* PARAMETERS: ParserState - Current parser state object
* ArgType - The argument type (AML_*_ARG)
* Arg - Where the argument is returned
*
* RETURN: None
*
* DESCRIPTION: Get the next simple argument (constant, string, or namestring)
*
******************************************************************************/
 
void
AcpiPsGetNextSimpleArg (
ACPI_PARSE_STATE *ParserState,
UINT32 ArgType,
ACPI_PARSE_OBJECT *Arg)
{
UINT32 Length;
UINT16 Opcode;
UINT8 *Aml = ParserState->Aml;
 
 
ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType);
 
 
switch (ArgType)
{
case ARGP_BYTEDATA:
 
/* Get 1 byte from the AML stream */
 
Opcode = AML_BYTE_OP;
Arg->Common.Value.Integer = (UINT64) *Aml;
Length = 1;
break;
 
 
case ARGP_WORDDATA:
 
/* Get 2 bytes from the AML stream */
 
Opcode = AML_WORD_OP;
ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml);
Length = 2;
break;
 
 
case ARGP_DWORDDATA:
 
/* Get 4 bytes from the AML stream */
 
Opcode = AML_DWORD_OP;
ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml);
Length = 4;
break;
 
 
case ARGP_QWORDDATA:
 
/* Get 8 bytes from the AML stream */
 
Opcode = AML_QWORD_OP;
ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml);
Length = 8;
break;
 
 
case ARGP_CHARLIST:
 
/* Get a pointer to the string, point past the string */
 
Opcode = AML_STRING_OP;
Arg->Common.Value.String = ACPI_CAST_PTR (char, Aml);
 
/* Find the null terminator */
 
Length = 0;
while (Aml[Length])
{
Length++;
}
Length++;
break;
 
 
case ARGP_NAME:
case ARGP_NAMESTRING:
 
AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
return_VOID;
 
 
default:
 
ACPI_ERROR ((AE_INFO, "Invalid ArgType 0x%X", ArgType));
return_VOID;
}
 
AcpiPsInitOp (Arg, Opcode);
ParserState->Aml += Length;
return_VOID;
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsGetNextField
*
* PARAMETERS: ParserState - Current parser state object
*
* RETURN: A newly allocated FIELD op
*
* DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField)
*
******************************************************************************/
 
static ACPI_PARSE_OBJECT *
AcpiPsGetNextField (
ACPI_PARSE_STATE *ParserState)
{
UINT32 AmlOffset = (UINT32)
ACPI_PTR_DIFF (ParserState->Aml,
ParserState->AmlStart);
ACPI_PARSE_OBJECT *Field;
UINT16 Opcode;
UINT32 Name;
 
 
ACPI_FUNCTION_TRACE (PsGetNextField);
 
 
/* Determine field type */
 
switch (ACPI_GET8 (ParserState->Aml))
{
default:
 
Opcode = AML_INT_NAMEDFIELD_OP;
break;
 
case 0x00:
 
Opcode = AML_INT_RESERVEDFIELD_OP;
ParserState->Aml++;
break;
 
case 0x01:
 
Opcode = AML_INT_ACCESSFIELD_OP;
ParserState->Aml++;
break;
}
 
/* Allocate a new field op */
 
Field = AcpiPsAllocOp (Opcode);
if (!Field)
{
return_PTR (NULL);
}
 
Field->Common.AmlOffset = AmlOffset;
 
/* Decode the field type */
 
switch (Opcode)
{
case AML_INT_NAMEDFIELD_OP:
 
/* Get the 4-character name */
 
ACPI_MOVE_32_TO_32 (&Name, ParserState->Aml);
AcpiPsSetName (Field, Name);
ParserState->Aml += ACPI_NAME_SIZE;
 
/* Get the length which is encoded as a package length */
 
Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
break;
 
 
case AML_INT_RESERVEDFIELD_OP:
 
/* Get the length which is encoded as a package length */
 
Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
break;
 
 
case AML_INT_ACCESSFIELD_OP:
 
/*
* Get AccessType and AccessAttrib and merge into the field Op
* AccessType is first operand, AccessAttribute is second
*/
Field->Common.Value.Integer = (((UINT32) ACPI_GET8 (ParserState->Aml) << 8));
ParserState->Aml++;
Field->Common.Value.Integer |= ACPI_GET8 (ParserState->Aml);
ParserState->Aml++;
break;
 
default:
 
/* Opcode was set in previous switch */
break;
}
 
return_PTR (Field);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsGetNextArg
*
* PARAMETERS: WalkState - Current state
* ParserState - Current parser state object
* ArgType - The argument type (AML_*_ARG)
* ReturnArg - Where the next arg is returned
*
* RETURN: Status, and an op object containing the next argument.
*
* DESCRIPTION: Get next argument (including complex list arguments that require
* pushing the parser stack)
*
******************************************************************************/
 
ACPI_STATUS
AcpiPsGetNextArg (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_STATE *ParserState,
UINT32 ArgType,
ACPI_PARSE_OBJECT **ReturnArg)
{
ACPI_PARSE_OBJECT *Arg = NULL;
ACPI_PARSE_OBJECT *Prev = NULL;
ACPI_PARSE_OBJECT *Field;
UINT32 Subop;
ACPI_STATUS Status = AE_OK;
 
 
ACPI_FUNCTION_TRACE_PTR (PsGetNextArg, ParserState);
 
 
switch (ArgType)
{
case ARGP_BYTEDATA:
case ARGP_WORDDATA:
case ARGP_DWORDDATA:
case ARGP_CHARLIST:
case ARGP_NAME:
case ARGP_NAMESTRING:
 
/* Constants, strings, and namestrings are all the same size */
 
Arg = AcpiPsAllocOp (AML_BYTE_OP);
if (!Arg)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg);
break;
 
 
case ARGP_PKGLENGTH:
 
/* Package length, nothing returned */
 
ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState);
break;
 
 
case ARGP_FIELDLIST:
 
if (ParserState->Aml < ParserState->PkgEnd)
{
/* Non-empty list */
 
while (ParserState->Aml < ParserState->PkgEnd)
{
Field = AcpiPsGetNextField (ParserState);
if (!Field)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
 
if (Prev)
{
Prev->Common.Next = Field;
}
else
{
Arg = Field;
}
Prev = Field;
}
 
/* Skip to End of byte data */
 
ParserState->Aml = ParserState->PkgEnd;
}
break;
 
 
case ARGP_BYTELIST:
 
if (ParserState->Aml < ParserState->PkgEnd)
{
/* Non-empty list */
 
Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP);
if (!Arg)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
 
/* Fill in bytelist data */
 
Arg->Common.Value.Size = (UINT32)
ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml);
Arg->Named.Data = ParserState->Aml;
 
/* Skip to End of byte data */
 
ParserState->Aml = ParserState->PkgEnd;
}
break;
 
 
case ARGP_TARGET:
case ARGP_SUPERNAME:
case ARGP_SIMPLENAME:
 
Subop = AcpiPsPeekOpcode (ParserState);
if (Subop == 0 ||
AcpiPsIsLeadingChar (Subop) ||
AcpiPsIsPrefixChar (Subop))
{
/* NullName or NameString */
 
Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
if (!Arg)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
 
/* To support SuperName arg of Unload */
 
if (WalkState->Opcode == AML_UNLOAD_OP)
{
Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 1);
 
/*
* If the SuperName arg of Unload is a method call,
* we have restored the AML pointer, just free this Arg
*/
if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP)
{
AcpiPsFreeOp (Arg);
Arg = NULL;
}
}
else
{
Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0);
}
}
else
{
/* Single complex argument, nothing returned */
 
WalkState->ArgCount = 1;
}
break;
 
 
case ARGP_DATAOBJ:
case ARGP_TERMARG:
 
/* Single complex argument, nothing returned */
 
WalkState->ArgCount = 1;
break;
 
 
case ARGP_DATAOBJLIST:
case ARGP_TERMLIST:
case ARGP_OBJLIST:
 
if (ParserState->Aml < ParserState->PkgEnd)
{
/* Non-empty list of variable arguments, nothing returned */
 
WalkState->ArgCount = ACPI_VAR_ARGS;
}
break;
 
 
default:
 
ACPI_ERROR ((AE_INFO, "Invalid ArgType: 0x%X", ArgType));
Status = AE_AML_OPERAND_TYPE;
break;
}
 
*ReturnArg = Arg;
return_ACPI_STATUS (Status);
}
/drivers/devman/acpica/parser/psloop.c
0,0 → 1,1340
/******************************************************************************
*
* Module Name: psloop - Main AML parse loop
*
*****************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, 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
* documentation and/or other materials provided with distribution. In
* 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
* provision in the documentation and/or other materials provided with the
* 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
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* 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.
*
*****************************************************************************/
 
 
/*
* Parse the AML and build an operation tree as most interpreters, (such as
* Perl) do. Parsing is done by hand rather than with a YACC generated parser
* to tightly constrain stack and dynamic memory usage. Parsing is kept
* flexible and the code fairly compact by parsing based on a list of AML
* opcode templates in AmlOpInfo[].
*/
 
#include "acpi.h"
#include "accommon.h"
#include "acparser.h"
#include "acdispat.h"
#include "amlcode.h"
 
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("psloop")
 
static UINT32 AcpiGbl_Depth = 0;
 
 
/* Local prototypes */
 
static ACPI_STATUS
AcpiPsGetAmlOpcode (
ACPI_WALK_STATE *WalkState);
 
static ACPI_STATUS
AcpiPsBuildNamedOp (
ACPI_WALK_STATE *WalkState,
UINT8 *AmlOpStart,
ACPI_PARSE_OBJECT *UnnamedOp,
ACPI_PARSE_OBJECT **Op);
 
static ACPI_STATUS
AcpiPsCreateOp (
ACPI_WALK_STATE *WalkState,
UINT8 *AmlOpStart,
ACPI_PARSE_OBJECT **NewOp);
 
static ACPI_STATUS
AcpiPsGetArguments (
ACPI_WALK_STATE *WalkState,
UINT8 *AmlOpStart,
ACPI_PARSE_OBJECT *Op);
 
static ACPI_STATUS
AcpiPsCompleteOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT **Op,
ACPI_STATUS Status);
 
static ACPI_STATUS
AcpiPsCompleteFinalOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op,
ACPI_STATUS Status);
 
static void
AcpiPsLinkModuleCode (
ACPI_PARSE_OBJECT *ParentOp,
UINT8 *AmlStart,
UINT32 AmlLength,
ACPI_OWNER_ID OwnerId);
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsGetAmlOpcode
*
* PARAMETERS: WalkState - Current state
*
* RETURN: Status
*
* DESCRIPTION: Extract the next AML opcode from the input stream.
*
******************************************************************************/
 
static ACPI_STATUS
AcpiPsGetAmlOpcode (
ACPI_WALK_STATE *WalkState)
{
 
ACPI_FUNCTION_TRACE_PTR (PsGetAmlOpcode, WalkState);
 
 
WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml,
WalkState->ParserState.AmlStart);
WalkState->Opcode = AcpiPsPeekOpcode (&(WalkState->ParserState));
 
/*
* First cut to determine what we have found:
* 1) A valid AML opcode
* 2) A name string
* 3) An unknown/invalid opcode
*/
WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
 
switch (WalkState->OpInfo->Class)
{
case AML_CLASS_ASCII:
case AML_CLASS_PREFIX:
/*
* Starts with a valid prefix or ASCII char, this is a name
* string. Convert the bare name string to a namepath.
*/
WalkState->Opcode = AML_INT_NAMEPATH_OP;
WalkState->ArgTypes = ARGP_NAMESTRING;
break;
 
case AML_CLASS_UNKNOWN:
 
/* The opcode is unrecognized. Just skip unknown opcodes */
 
ACPI_ERROR ((AE_INFO,
"Found unknown opcode 0x%X at AML address %p offset 0x%X, ignoring",
WalkState->Opcode, WalkState->ParserState.Aml, WalkState->AmlOffset));
 
ACPI_DUMP_BUFFER (WalkState->ParserState.Aml, 128);
 
/* Assume one-byte bad opcode */
 
WalkState->ParserState.Aml++;
return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
 
default:
 
/* Found opcode info, this is a normal opcode */
 
WalkState->ParserState.Aml += AcpiPsGetOpcodeSize (WalkState->Opcode);
WalkState->ArgTypes = WalkState->OpInfo->ParseArgs;
break;
}
 
return_ACPI_STATUS (AE_OK);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsBuildNamedOp
*
* PARAMETERS: WalkState - Current state
* AmlOpStart - Begin of named Op in AML
* UnnamedOp - Early Op (not a named Op)
* Op - Returned Op
*
* RETURN: Status
*
* DESCRIPTION: Parse a named Op
*
******************************************************************************/
 
static ACPI_STATUS
AcpiPsBuildNamedOp (
ACPI_WALK_STATE *WalkState,
UINT8 *AmlOpStart,
ACPI_PARSE_OBJECT *UnnamedOp,
ACPI_PARSE_OBJECT **Op)
{
ACPI_STATUS Status = AE_OK;
ACPI_PARSE_OBJECT *Arg = NULL;
 
 
ACPI_FUNCTION_TRACE_PTR (PsBuildNamedOp, WalkState);
 
 
UnnamedOp->Common.Value.Arg = NULL;
UnnamedOp->Common.ArgListLength = 0;
UnnamedOp->Common.AmlOpcode = WalkState->Opcode;
 
/*
* Get and append arguments until we find the node that contains
* the name (the type ARGP_NAME).
*/
while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) &&
(GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME))
{
Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState),
GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
AcpiPsAppendArg (UnnamedOp, Arg);
INCREMENT_ARG_LIST (WalkState->ArgTypes);
}
 
/*
* Make sure that we found a NAME and didn't run out of arguments
*/
if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes))
{
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
 
/* We know that this arg is a name, move to next arg */
 
INCREMENT_ARG_LIST (WalkState->ArgTypes);
 
/*
* Find the object. This will either insert the object into
* the namespace or simply look it up
*/
WalkState->Op = NULL;
 
Status = WalkState->DescendingCallback (WalkState, Op);
if (ACPI_FAILURE (Status))
{
ACPI_EXCEPTION ((AE_INFO, Status, "During name lookup/catalog"));
return_ACPI_STATUS (Status);
}
 
if (!*Op)
{
return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
}
 
Status = AcpiPsNextParseState (WalkState, *Op, Status);
if (ACPI_FAILURE (Status))
{
if (Status == AE_CTRL_PENDING)
{
return_ACPI_STATUS (AE_CTRL_PARSE_PENDING);
}
return_ACPI_STATUS (Status);
}
 
AcpiPsAppendArg (*Op, UnnamedOp->Common.Value.Arg);
AcpiGbl_Depth++;
 
if ((*Op)->Common.AmlOpcode == AML_REGION_OP ||
(*Op)->Common.AmlOpcode == AML_DATA_REGION_OP)
{
/*
* Defer final parsing of an OperationRegion body, because we don't
* have enough info in the first pass to parse it correctly (i.e.,
* there may be method calls within the TermArg elements of the body.)
*
* However, we must continue parsing because the opregion is not a
* standalone package -- we don't know where the end is at this point.
*
* (Length is unknown until parse of the body complete)
*/
(*Op)->Named.Data = AmlOpStart;
(*Op)->Named.Length = 0;
}
 
return_ACPI_STATUS (AE_OK);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsCreateOp
*
* PARAMETERS: WalkState - Current state
* AmlOpStart - Op start in AML
* NewOp - Returned Op
*
* RETURN: Status
*
* DESCRIPTION: Get Op from AML
*
******************************************************************************/
 
static ACPI_STATUS
AcpiPsCreateOp (
ACPI_WALK_STATE *WalkState,
UINT8 *AmlOpStart,
ACPI_PARSE_OBJECT **NewOp)
{
ACPI_STATUS Status = AE_OK;
ACPI_PARSE_OBJECT *Op;
ACPI_PARSE_OBJECT *NamedOp = NULL;
ACPI_PARSE_OBJECT *ParentScope;
UINT8 ArgumentCount;
const ACPI_OPCODE_INFO *OpInfo;
 
 
ACPI_FUNCTION_TRACE_PTR (PsCreateOp, WalkState);
 
 
Status = AcpiPsGetAmlOpcode (WalkState);
if (Status == AE_CTRL_PARSE_CONTINUE)
{
return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
}
 
/* Create Op structure and append to parent's argument list */
 
WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
Op = AcpiPsAllocOp (WalkState->Opcode);
if (!Op)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
 
if (WalkState->OpInfo->Flags & AML_NAMED)
{
Status = AcpiPsBuildNamedOp (WalkState, AmlOpStart, Op, &NamedOp);
AcpiPsFreeOp (Op);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
*NewOp = NamedOp;
return_ACPI_STATUS (AE_OK);
}
 
/* Not a named opcode, just allocate Op and append to parent */
 
if (WalkState->OpInfo->Flags & AML_CREATE)
{
/*
* Backup to beginning of CreateXXXfield declaration
* BodyLength is unknown until we parse the body
*/
Op->Named.Data = AmlOpStart;
Op->Named.Length = 0;
}
 
if (WalkState->Opcode == AML_BANK_FIELD_OP)
{
/*
* Backup to beginning of BankField declaration
* BodyLength is unknown until we parse the body
*/
Op->Named.Data = AmlOpStart;
Op->Named.Length = 0;
}
 
ParentScope = AcpiPsGetParentScope (&(WalkState->ParserState));
AcpiPsAppendArg (ParentScope, Op);
 
if (ParentScope)
{
OpInfo = AcpiPsGetOpcodeInfo (ParentScope->Common.AmlOpcode);
if (OpInfo->Flags & AML_HAS_TARGET)
{
ArgumentCount = AcpiPsGetArgumentCount (OpInfo->Type);
if (ParentScope->Common.ArgListLength > ArgumentCount)
{
Op->Common.Flags |= ACPI_PARSEOP_TARGET;
}
}
else if (ParentScope->Common.AmlOpcode == AML_INCREMENT_OP)
{
Op->Common.Flags |= ACPI_PARSEOP_TARGET;
}
}
 
if (WalkState->DescendingCallback != NULL)
{
/*
* Find the object. This will either insert the object into
* the namespace or simply look it up
*/
WalkState->Op = *NewOp = Op;
 
Status = WalkState->DescendingCallback (WalkState, &Op);
Status = AcpiPsNextParseState (WalkState, Op, Status);
if (Status == AE_CTRL_PENDING)
{
Status = AE_CTRL_PARSE_PENDING;
}
}
 
return_ACPI_STATUS (Status);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsGetArguments
*
* PARAMETERS: WalkState - Current state
* AmlOpStart - Op start in AML
* Op - Current Op
*
* RETURN: Status
*
* DESCRIPTION: Get arguments for passed Op.
*
******************************************************************************/
 
static ACPI_STATUS
AcpiPsGetArguments (
ACPI_WALK_STATE *WalkState,
UINT8 *AmlOpStart,
ACPI_PARSE_OBJECT *Op)
{
ACPI_STATUS Status = AE_OK;
ACPI_PARSE_OBJECT *Arg = NULL;
const ACPI_OPCODE_INFO *OpInfo;
 
 
ACPI_FUNCTION_TRACE_PTR (PsGetArguments, WalkState);
 
 
switch (Op->Common.AmlOpcode)
{
case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
case AML_WORD_OP: /* AML_WORDDATA_ARG */
case AML_DWORD_OP: /* AML_DWORDATA_ARG */
case AML_QWORD_OP: /* AML_QWORDATA_ARG */
case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */
 
/* Fill in constant or string argument directly */
 
AcpiPsGetNextSimpleArg (&(WalkState->ParserState),
GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), Op);
break;
 
case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
 
Status = AcpiPsGetNextNamepath (WalkState, &(WalkState->ParserState), Op, 1);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
WalkState->ArgTypes = 0;
break;
 
default:
/*
* Op is not a constant or string, append each argument to the Op
*/
while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && !WalkState->ArgCount)
{
WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml,
WalkState->ParserState.AmlStart);
 
Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState),
GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
if (Arg)
{
Arg->Common.AmlOffset = WalkState->AmlOffset;
AcpiPsAppendArg (Op, Arg);
}
 
INCREMENT_ARG_LIST (WalkState->ArgTypes);
}
 
 
/*
* Handle executable code at "module-level". This refers to
* executable opcodes that appear outside of any control method.
*/
if ((WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2) &&
((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) == 0))
{
/*
* We want to skip If/Else/While constructs during Pass1 because we
* want to actually conditionally execute the code during Pass2.
*
* Except for disassembly, where we always want to walk the
* If/Else/While packages
*/
switch (Op->Common.AmlOpcode)
{
case AML_IF_OP:
case AML_ELSE_OP:
case AML_WHILE_OP:
 
/*
* Currently supported module-level opcodes are:
* IF/ELSE/WHILE. These appear to be the most common,
* and easiest to support since they open an AML
* package.
*/
if (WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1)
{
AcpiPsLinkModuleCode (Op->Common.Parent, AmlOpStart,
(UINT32) (WalkState->ParserState.PkgEnd - AmlOpStart),
WalkState->OwnerId);
}
 
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
"Pass1: Skipping an If/Else/While body\n"));
 
/* Skip body of if/else/while in pass 1 */
 
WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd;
WalkState->ArgCount = 0;
break;
 
default:
/*
* Check for an unsupported executable opcode at module
* level. We must be in PASS1, the parent must be a SCOPE,
* The opcode class must be EXECUTE, and the opcode must
* not be an argument to another opcode.
*/
if ((WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1) &&
(Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP))
{
OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
if ((OpInfo->Class == AML_CLASS_EXECUTE) &&
(!Arg))
{
ACPI_WARNING ((AE_INFO,
"Detected an unsupported executable opcode "
"at module-level: [0x%.4X] at table offset 0x%.4X",
Op->Common.AmlOpcode,
(UINT32) (ACPI_PTR_DIFF (AmlOpStart,
WalkState->ParserState.AmlStart) +
sizeof (ACPI_TABLE_HEADER))));
}
}
break;
}
}
 
/* Special processing for certain opcodes */
 
switch (Op->Common.AmlOpcode)
{
case AML_METHOD_OP:
/*
* Skip parsing of control method because we don't have enough
* info in the first pass to parse it correctly.
*
* Save the length and address of the body
*/
Op->Named.Data = WalkState->ParserState.Aml;
Op->Named.Length = (UINT32)
(WalkState->ParserState.PkgEnd - WalkState->ParserState.Aml);
 
/* Skip body of method */
 
WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd;
WalkState->ArgCount = 0;
break;
 
case AML_BUFFER_OP:
case AML_PACKAGE_OP:
case AML_VAR_PACKAGE_OP:
 
if ((Op->Common.Parent) &&
(Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) &&
(WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2))
{
/*
* Skip parsing of Buffers and Packages because we don't have
* enough info in the first pass to parse them correctly.
*/
Op->Named.Data = AmlOpStart;
Op->Named.Length = (UINT32)
(WalkState->ParserState.PkgEnd - AmlOpStart);
 
/* Skip body */
 
WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd;
WalkState->ArgCount = 0;
}
break;
 
case AML_WHILE_OP:
 
if (WalkState->ControlState)
{
WalkState->ControlState->Control.PackageEnd =
WalkState->ParserState.PkgEnd;
}
break;
 
default:
 
/* No action for all other opcodes */
break;
}
 
break;
}
 
return_ACPI_STATUS (AE_OK);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsLinkModuleCode
*
* PARAMETERS: ParentOp - Parent parser op
* AmlStart - Pointer to the AML
* AmlLength - Length of executable AML
* OwnerId - OwnerId of module level code
*
* RETURN: None.
*
* DESCRIPTION: Wrap the module-level code with a method object and link the
* object to the global list. Note, the mutex field of the method
* object is used to link multiple module-level code objects.
*
******************************************************************************/
 
static void
AcpiPsLinkModuleCode (
ACPI_PARSE_OBJECT *ParentOp,
UINT8 *AmlStart,
UINT32 AmlLength,
ACPI_OWNER_ID OwnerId)
{
ACPI_OPERAND_OBJECT *Prev;
ACPI_OPERAND_OBJECT *Next;
ACPI_OPERAND_OBJECT *MethodObj;
ACPI_NAMESPACE_NODE *ParentNode;
 
 
/* Get the tail of the list */
 
Prev = Next = AcpiGbl_ModuleCodeList;
while (Next)
{
Prev = Next;
Next = Next->Method.Mutex;
}
 
/*
* Insert the module level code into the list. Merge it if it is
* adjacent to the previous element.
*/
if (!Prev ||
((Prev->Method.AmlStart + Prev->Method.AmlLength) != AmlStart))
{
/* Create, initialize, and link a new temporary method object */
 
MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
if (!MethodObj)
{
return;
}
 
if (ParentOp->Common.Node)
{
ParentNode = ParentOp->Common.Node;
}
else
{
ParentNode = AcpiGbl_RootNode;
}
 
MethodObj->Method.AmlStart = AmlStart;
MethodObj->Method.AmlLength = AmlLength;
MethodObj->Method.OwnerId = OwnerId;
MethodObj->Method.Flags |= AOPOBJ_MODULE_LEVEL;
 
/*
* Save the parent node in NextObject. This is cheating, but we
* don't want to expand the method object.
*/
MethodObj->Method.NextObject =
ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParentNode);
 
if (!Prev)
{
AcpiGbl_ModuleCodeList = MethodObj;
}
else
{
Prev->Method.Mutex = MethodObj;
}
}
else
{
Prev->Method.AmlLength += AmlLength;
}
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsCompleteOp
*
* PARAMETERS: WalkState - Current state
* Op - Returned Op
* Status - Parse status before complete Op
*
* RETURN: Status
*
* DESCRIPTION: Complete Op
*
******************************************************************************/
 
static ACPI_STATUS
AcpiPsCompleteOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT **Op,
ACPI_STATUS Status)
{
ACPI_STATUS Status2;
 
 
ACPI_FUNCTION_TRACE_PTR (PsCompleteOp, WalkState);
 
 
/*
* Finished one argument of the containing scope
*/
WalkState->ParserState.Scope->ParseScope.ArgCount--;
 
/* Close this Op (will result in parse subtree deletion) */
 
Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
if (ACPI_FAILURE (Status2))
{
return_ACPI_STATUS (Status2);
}
 
*Op = NULL;
 
switch (Status)
{
case AE_OK:
break;
 
 
case AE_CTRL_TRANSFER:
 
/* We are about to transfer to a called method */
 
WalkState->PrevOp = NULL;
WalkState->PrevArgTypes = WalkState->ArgTypes;
return_ACPI_STATUS (Status);
 
 
case AE_CTRL_END:
 
AcpiPsPopScope (&(WalkState->ParserState), Op,
&WalkState->ArgTypes, &WalkState->ArgCount);
 
if (*Op)
{
WalkState->Op = *Op;
WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode);
WalkState->Opcode = (*Op)->Common.AmlOpcode;
 
Status = WalkState->AscendingCallback (WalkState);
Status = AcpiPsNextParseState (WalkState, *Op, Status);
 
Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
if (ACPI_FAILURE (Status2))
{
return_ACPI_STATUS (Status2);
}
}
 
Status = AE_OK;
break;
 
 
case AE_CTRL_BREAK:
case AE_CTRL_CONTINUE:
 
/* Pop off scopes until we find the While */
 
while (!(*Op) || ((*Op)->Common.AmlOpcode != AML_WHILE_OP))
{
AcpiPsPopScope (&(WalkState->ParserState), Op,
&WalkState->ArgTypes, &WalkState->ArgCount);
}
 
/* Close this iteration of the While loop */
 
WalkState->Op = *Op;
WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode);
WalkState->Opcode = (*Op)->Common.AmlOpcode;
 
Status = WalkState->AscendingCallback (WalkState);
Status = AcpiPsNextParseState (WalkState, *Op, Status);
 
Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
if (ACPI_FAILURE (Status2))
{
return_ACPI_STATUS (Status2);
}
 
Status = AE_OK;
break;
 
 
case AE_CTRL_TERMINATE:
 
/* Clean up */
do
{
if (*Op)
{
Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
if (ACPI_FAILURE (Status2))
{
return_ACPI_STATUS (Status2);
}
 
AcpiUtDeleteGenericState (
AcpiUtPopGenericState (&WalkState->ControlState));
}
 
AcpiPsPopScope (&(WalkState->ParserState), Op,
&WalkState->ArgTypes, &WalkState->ArgCount);
 
} while (*Op);
 
return_ACPI_STATUS (AE_OK);
 
 
default: /* All other non-AE_OK status */
 
do
{
if (*Op)
{
Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
if (ACPI_FAILURE (Status2))
{
return_ACPI_STATUS (Status2);
}
}
 
AcpiPsPopScope (&(WalkState->ParserState), Op,
&WalkState->ArgTypes, &WalkState->ArgCount);
 
} while (*Op);
 
 
#if 0
/*
* TBD: Cleanup parse ops on error
*/
if (*Op == NULL)
{
AcpiPsPopScope (ParserState, Op,
&WalkState->ArgTypes, &WalkState->ArgCount);
}
#endif
WalkState->PrevOp = NULL;
WalkState->PrevArgTypes = WalkState->ArgTypes;
return_ACPI_STATUS (Status);
}
 
/* This scope complete? */
 
if (AcpiPsHasCompletedScope (&(WalkState->ParserState)))
{
AcpiPsPopScope (&(WalkState->ParserState), Op,
&WalkState->ArgTypes, &WalkState->ArgCount);
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *Op));
}
else
{
*Op = NULL;
}
 
return_ACPI_STATUS (AE_OK);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsCompleteFinalOp
*
* PARAMETERS: WalkState - Current state
* Op - Current Op
* Status - Current parse status before complete last
* Op
*
* RETURN: Status
*
* DESCRIPTION: Complete last Op.
*
******************************************************************************/
 
static ACPI_STATUS
AcpiPsCompleteFinalOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op,
ACPI_STATUS Status)
{
ACPI_STATUS Status2;
 
 
ACPI_FUNCTION_TRACE_PTR (PsCompleteFinalOp, WalkState);
 
 
/*
* 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 ASL blocks are closed with
* sequential closing braces). We want to terminate each one cleanly.
*/
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", Op));
do
{
if (Op)
{
if (WalkState->AscendingCallback != NULL)
{
WalkState->Op = Op;
WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
WalkState->Opcode = Op->Common.AmlOpcode;
 
Status = WalkState->AscendingCallback (WalkState);
Status = AcpiPsNextParseState (WalkState, Op, Status);
if (Status == AE_CTRL_PENDING)
{
Status = AcpiPsCompleteOp (WalkState, &Op, AE_OK);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
 
if (Status == AE_CTRL_TERMINATE)
{
Status = AE_OK;
 
/* Clean up */
do
{
if (Op)
{
Status2 = AcpiPsCompleteThisOp (WalkState, Op);
if (ACPI_FAILURE (Status2))
{
return_ACPI_STATUS (Status2);
}
}
 
AcpiPsPopScope (&(WalkState->ParserState), &Op,
&WalkState->ArgTypes, &WalkState->ArgCount);
 
} while (Op);
 
return_ACPI_STATUS (Status);
}
 
else if (ACPI_FAILURE (Status))
{
/* First error is most important */
 
(void) AcpiPsCompleteThisOp (WalkState, Op);
return_ACPI_STATUS (Status);
}
}
 
Status2 = AcpiPsCompleteThisOp (WalkState, Op);
if (ACPI_FAILURE (Status2))
{
return_ACPI_STATUS (Status2);
}
}
 
AcpiPsPopScope (&(WalkState->ParserState), &Op, &WalkState->ArgTypes,
&WalkState->ArgCount);
 
} while (Op);
 
return_ACPI_STATUS (Status);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsParseLoop
*
* PARAMETERS: WalkState - Current state
*
* RETURN: Status
*
* DESCRIPTION: Parse AML (pointed to by the current parser state) and return
* a tree of ops.
*
******************************************************************************/
 
ACPI_STATUS
AcpiPsParseLoop (
ACPI_WALK_STATE *WalkState)
{
ACPI_STATUS Status = AE_OK;
ACPI_PARSE_OBJECT *Op = NULL; /* current op */
ACPI_PARSE_STATE *ParserState;
UINT8 *AmlOpStart = NULL;
 
 
ACPI_FUNCTION_TRACE_PTR (PsParseLoop, WalkState);
 
 
if (WalkState->DescendingCallback == NULL)
{
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
 
ParserState = &WalkState->ParserState;
WalkState->ArgTypes = 0;
 
#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
 
if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART)
{
/* We are restarting a preempted control method */
 
if (AcpiPsHasCompletedScope (ParserState))
{
/*
* We must check if a predicate to an IF or WHILE statement
* was just completed
*/
if ((ParserState->Scope->ParseScope.Op) &&
((ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_IF_OP) ||
(ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_WHILE_OP)) &&
(WalkState->ControlState) &&
(WalkState->ControlState->Common.State ==
ACPI_CONTROL_PREDICATE_EXECUTING))
{
/*
* A predicate was just completed, get the value of the
* predicate and branch based on that value
*/
WalkState->Op = NULL;
Status = AcpiDsGetPredicateValue (WalkState, ACPI_TO_POINTER (TRUE));
if (ACPI_FAILURE (Status) &&
((Status & AE_CODE_MASK) != AE_CODE_CONTROL))
{
if (Status == AE_AML_NO_RETURN_VALUE)
{
ACPI_EXCEPTION ((AE_INFO, Status,
"Invoked method did not return a value"));
}
 
ACPI_EXCEPTION ((AE_INFO, Status, "GetPredicate Failed"));
return_ACPI_STATUS (Status);
}
 
Status = AcpiPsNextParseState (WalkState, Op, Status);
}
 
AcpiPsPopScope (ParserState, &Op,
&WalkState->ArgTypes, &WalkState->ArgCount);
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op));
}
else if (WalkState->PrevOp)
{
/* We were in the middle of an op */
 
Op = WalkState->PrevOp;
WalkState->ArgTypes = WalkState->PrevArgTypes;
}
}
#endif
 
/* Iterative parsing loop, while there is more AML to process: */
 
while ((ParserState->Aml < ParserState->AmlEnd) || (Op))
{
AmlOpStart = ParserState->Aml;
if (!Op)
{
Status = AcpiPsCreateOp (WalkState, AmlOpStart, &Op);
if (ACPI_FAILURE (Status))
{
if (Status == AE_CTRL_PARSE_CONTINUE)
{
continue;
}
 
if (Status == AE_CTRL_PARSE_PENDING)
{
Status = AE_OK;
}
 
Status = AcpiPsCompleteOp (WalkState, &Op, Status);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
continue;
}
 
Op->Common.AmlOffset = WalkState->AmlOffset;
 
if (WalkState->OpInfo)
{
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
"Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n",
(UINT32) Op->Common.AmlOpcode, WalkState->OpInfo->Name,
Op, ParserState->Aml, Op->Common.AmlOffset));
}
}
 
 
/*
* Start ArgCount at zero because we don't know if there are
* any args yet
*/
WalkState->ArgCount = 0;
 
/* Are there any arguments that must be processed? */
 
if (WalkState->ArgTypes)
{
/* Get arguments */
 
Status = AcpiPsGetArguments (WalkState, AmlOpStart, Op);
if (ACPI_FAILURE (Status))
{
Status = AcpiPsCompleteOp (WalkState, &Op, Status);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
continue;
}
}
 
/* Check for arguments that need to be processed */
 
if (WalkState->ArgCount)
{
/*
* There are arguments (complex ones), push Op and
* prepare for argument
*/
Status = AcpiPsPushScope (ParserState, Op,
WalkState->ArgTypes, WalkState->ArgCount);
if (ACPI_FAILURE (Status))
{
Status = AcpiPsCompleteOp (WalkState, &Op, Status);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
continue;
}
 
Op = NULL;
continue;
}
 
/*
* All arguments have been processed -- Op is complete,
* prepare for next
*/
WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
if (WalkState->OpInfo->Flags & AML_NAMED)
{
if (AcpiGbl_Depth)
{
AcpiGbl_Depth--;
}
 
if (Op->Common.AmlOpcode == AML_REGION_OP ||
Op->Common.AmlOpcode == AML_DATA_REGION_OP)
{
/*
* Skip parsing of control method or opregion body,
* because we don't have enough info in the first pass
* to parse them correctly.
*
* Completed parsing an OpRegion declaration, we now
* know the length.
*/
Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
}
}
 
if (WalkState->OpInfo->Flags & AML_CREATE)
{
/*
* Backup to beginning of CreateXXXfield declaration (1 for
* Opcode)
*
* BodyLength is unknown until we parse the body
*/
Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
}
 
if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP)
{
/*
* Backup to beginning of BankField declaration
*
* BodyLength is unknown until we parse the body
*/
Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
}
 
/* This op complete, notify the dispatcher */
 
if (WalkState->AscendingCallback != NULL)
{
WalkState->Op = Op;
WalkState->Opcode = Op->Common.AmlOpcode;
 
Status = WalkState->AscendingCallback (WalkState);
Status = AcpiPsNextParseState (WalkState, Op, Status);
if (Status == AE_CTRL_PENDING)
{
Status = AE_OK;
}
}
 
Status = AcpiPsCompleteOp (WalkState, &Op, Status);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
} /* while ParserState->Aml */
 
Status = AcpiPsCompleteFinalOp (WalkState, Op, Status);
return_ACPI_STATUS (Status);
}
 
/drivers/devman/acpica/parser/psopcode.c
0,0 → 1,589
/******************************************************************************
*
* Module Name: psopcode - Parser/Interpreter opcode information table
*
*****************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, 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
* documentation and/or other materials provided with distribution. In
* 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
* provision in the documentation and/or other materials provided with the
* 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
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* 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.
*
*****************************************************************************/
 
 
#include "acpi.h"
#include "accommon.h"
#include "acparser.h"
#include "acopcode.h"
#include "amlcode.h"
 
 
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("psopcode")
 
 
static const UINT8 AcpiGbl_ArgumentCount[] = {0,1,1,1,1,2,2,2,2,3,3,6};
 
 
/*******************************************************************************
*
* NAME: AcpiGbl_AmlOpInfo
*
* DESCRIPTION: Opcode table. Each entry contains <opcode, type, name, operands>
* The name is a simple ascii string, the operand specifier is an
* ascii string with one letter per operand. The letter specifies
* the operand type.
*
******************************************************************************/
 
/*
* Summary of opcode types/flags
*
 
Opcodes that have associated namespace objects (AML_NSOBJECT flag)
 
AML_SCOPE_OP
AML_DEVICE_OP
AML_THERMAL_ZONE_OP
AML_METHOD_OP
AML_POWER_RES_OP
AML_PROCESSOR_OP
AML_FIELD_OP
AML_INDEX_FIELD_OP
AML_BANK_FIELD_OP
AML_NAME_OP
AML_ALIAS_OP
AML_MUTEX_OP
AML_EVENT_OP
AML_REGION_OP
AML_CREATE_FIELD_OP
AML_CREATE_BIT_FIELD_OP
AML_CREATE_BYTE_FIELD_OP
AML_CREATE_WORD_FIELD_OP
AML_CREATE_DWORD_FIELD_OP
AML_CREATE_QWORD_FIELD_OP
AML_INT_NAMEDFIELD_OP
AML_INT_METHODCALL_OP
AML_INT_NAMEPATH_OP
 
Opcodes that are "namespace" opcodes (AML_NSOPCODE flag)
 
AML_SCOPE_OP
AML_DEVICE_OP
AML_THERMAL_ZONE_OP
AML_METHOD_OP
AML_POWER_RES_OP
AML_PROCESSOR_OP
AML_FIELD_OP
AML_INDEX_FIELD_OP
AML_BANK_FIELD_OP
AML_NAME_OP
AML_ALIAS_OP
AML_MUTEX_OP
AML_EVENT_OP
AML_REGION_OP
AML_INT_NAMEDFIELD_OP
 
Opcodes that have an associated namespace node (AML_NSNODE flag)
 
AML_SCOPE_OP
AML_DEVICE_OP
AML_THERMAL_ZONE_OP
AML_METHOD_OP
AML_POWER_RES_OP
AML_PROCESSOR_OP
AML_NAME_OP
AML_ALIAS_OP
AML_MUTEX_OP
AML_EVENT_OP
AML_REGION_OP
AML_CREATE_FIELD_OP
AML_CREATE_BIT_FIELD_OP
AML_CREATE_BYTE_FIELD_OP
AML_CREATE_WORD_FIELD_OP
AML_CREATE_DWORD_FIELD_OP
AML_CREATE_QWORD_FIELD_OP
AML_INT_NAMEDFIELD_OP
AML_INT_METHODCALL_OP
AML_INT_NAMEPATH_OP
 
Opcodes that define named ACPI objects (AML_NAMED flag)
 
AML_SCOPE_OP
AML_DEVICE_OP
AML_THERMAL_ZONE_OP
AML_METHOD_OP
AML_POWER_RES_OP
AML_PROCESSOR_OP
AML_NAME_OP
AML_ALIAS_OP
AML_MUTEX_OP
AML_EVENT_OP
AML_REGION_OP
AML_INT_NAMEDFIELD_OP
 
Opcodes that contain executable AML as part of the definition that
must be deferred until needed
 
AML_METHOD_OP
AML_VAR_PACKAGE_OP
AML_CREATE_FIELD_OP
AML_CREATE_BIT_FIELD_OP
AML_CREATE_BYTE_FIELD_OP
AML_CREATE_WORD_FIELD_OP
AML_CREATE_DWORD_FIELD_OP
AML_CREATE_QWORD_FIELD_OP
AML_REGION_OP
AML_BUFFER_OP
 
Field opcodes
 
AML_CREATE_FIELD_OP
AML_FIELD_OP
AML_INDEX_FIELD_OP
AML_BANK_FIELD_OP
 
Field "Create" opcodes
 
AML_CREATE_FIELD_OP
AML_CREATE_BIT_FIELD_OP
AML_CREATE_BYTE_FIELD_OP
AML_CREATE_WORD_FIELD_OP
AML_CREATE_DWORD_FIELD_OP
AML_CREATE_QWORD_FIELD_OP
 
******************************************************************************/
 
 
/*
* Master Opcode information table. A summary of everything we know about each
* opcode, all in one place.
*/
const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] =
{
/*! [Begin] no source code translation */
/* Index Name Parser Args Interpreter Args ObjectType Class Type Flags */
 
/* 00 */ ACPI_OP ("Zero", ARGP_ZERO_OP, ARGI_ZERO_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT),
/* 01 */ ACPI_OP ("One", ARGP_ONE_OP, ARGI_ONE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT),
/* 02 */ ACPI_OP ("Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP, ACPI_TYPE_LOCAL_ALIAS, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
/* 03 */ ACPI_OP ("Name", ARGP_NAME_OP, ARGI_NAME_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
/* 04 */ ACPI_OP ("ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
/* 05 */ ACPI_OP ("WordConst", ARGP_WORD_OP, ARGI_WORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
/* 06 */ ACPI_OP ("DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
/* 07 */ ACPI_OP ("String", ARGP_STRING_OP, ARGI_STRING_OP, ACPI_TYPE_STRING, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
/* 08 */ ACPI_OP ("Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_LOCAL_SCOPE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
/* 09 */ ACPI_OP ("Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP, ACPI_TYPE_BUFFER, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT),
/* 0A */ ACPI_OP ("Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT),
/* 0B */ ACPI_OP ("Method", ARGP_METHOD_OP, ARGI_METHOD_OP, ACPI_TYPE_METHOD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
/* 0C */ ACPI_OP ("Local0", ARGP_LOCAL0, ARGI_LOCAL0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
/* 0D */ ACPI_OP ("Local1", ARGP_LOCAL1, ARGI_LOCAL1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
/* 0E */ ACPI_OP ("Local2", ARGP_LOCAL2, ARGI_LOCAL2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
/* 0F */ ACPI_OP ("Local3", ARGP_LOCAL3, ARGI_LOCAL3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
/* 10 */ ACPI_OP ("Local4", ARGP_LOCAL4, ARGI_LOCAL4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
/* 11 */ ACPI_OP ("Local5", ARGP_LOCAL5, ARGI_LOCAL5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
/* 12 */ ACPI_OP ("Local6", ARGP_LOCAL6, ARGI_LOCAL6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
/* 13 */ ACPI_OP ("Local7", ARGP_LOCAL7, ARGI_LOCAL7, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
/* 14 */ ACPI_OP ("Arg0", ARGP_ARG0, ARGI_ARG0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
/* 15 */ ACPI_OP ("Arg1", ARGP_ARG1, ARGI_ARG1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
/* 16 */ ACPI_OP ("Arg2", ARGP_ARG2, ARGI_ARG2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
/* 17 */ ACPI_OP ("Arg3", ARGP_ARG3, ARGI_ARG3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
/* 18 */ ACPI_OP ("Arg4", ARGP_ARG4, ARGI_ARG4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
/* 19 */ ACPI_OP ("Arg5", ARGP_ARG5, ARGI_ARG5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
/* 1A */ ACPI_OP ("Arg6", ARGP_ARG6, ARGI_ARG6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
/* 1B */ ACPI_OP ("Store", ARGP_STORE_OP, ARGI_STORE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R),
/* 1C */ ACPI_OP ("RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R),
/* 1D */ ACPI_OP ("Add", ARGP_ADD_OP, ARGI_ADD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
/* 1E */ ACPI_OP ("Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
/* 1F */ ACPI_OP ("Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
/* 20 */ ACPI_OP ("Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
/* 21 */ ACPI_OP ("Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
/* 22 */ ACPI_OP ("Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
/* 23 */ ACPI_OP ("Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_2T_1R, AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT),
/* 24 */ ACPI_OP ("ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
/* 25 */ ACPI_OP ("ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
/* 26 */ ACPI_OP ("And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
/* 27 */ ACPI_OP ("NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
/* 28 */ ACPI_OP ("Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
/* 29 */ ACPI_OP ("NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
/* 2A */ ACPI_OP ("XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
/* 2B */ ACPI_OP ("Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
/* 2C */ ACPI_OP ("FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
/* 2D */ ACPI_OP ("FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP,ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
/* 2E */ ACPI_OP ("DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R),
/* 2F */ ACPI_OP ("Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_0R, AML_FLAGS_EXEC_2A_0T_0R),
/* 30 */ ACPI_OP ("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE),
/* 31 */ ACPI_OP ("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R),
/* 32 */ ACPI_OP ("Match", ARGP_MATCH_OP, ARGI_MATCH_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT),
/* 33 */ ACPI_OP ("CreateDWordField", ARGP_CREATE_DWORD_FIELD_OP,ARGI_CREATE_DWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
/* 34 */ ACPI_OP ("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
/* 35 */ ACPI_OP ("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
/* 36 */ ACPI_OP ("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, ARGI_CREATE_BIT_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
/* 37 */ ACPI_OP ("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE),
/* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT),
/* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT),
/* 3A */ ACPI_OP ("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
/* 3B */ ACPI_OP ("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
/* 3C */ ACPI_OP ("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
/* 3D */ ACPI_OP ("LLess", ARGP_LLESS_OP, ARGI_LLESS_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
/* 3E */ ACPI_OP ("If", ARGP_IF_OP, ARGI_IF_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
/* 3F */ ACPI_OP ("Else", ARGP_ELSE_OP, ARGI_ELSE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
/* 40 */ ACPI_OP ("While", ARGP_WHILE_OP, ARGI_WHILE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
/* 41 */ ACPI_OP ("Noop", ARGP_NOOP_OP, ARGI_NOOP_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
/* 42 */ ACPI_OP ("Return", ARGP_RETURN_OP, ARGI_RETURN_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
/* 43 */ ACPI_OP ("Break", ARGP_BREAK_OP, ARGI_BREAK_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
/* 44 */ ACPI_OP ("BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
/* 45 */ ACPI_OP ("Ones", ARGP_ONES_OP, ARGI_ONES_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT),
 
/* Prefixed opcodes (Two-byte opcodes with a prefix op) */
 
/* 46 */ ACPI_OP ("Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP, ACPI_TYPE_MUTEX, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
/* 47 */ ACPI_OP ("Event", ARGP_EVENT_OP, ARGI_EVENT_OP, ACPI_TYPE_EVENT, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ),
/* 48 */ ACPI_OP ("CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R),
/* 49 */ ACPI_OP ("CreateField", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_FIELD | AML_CREATE),
/* 4A */ ACPI_OP ("Load", ARGP_LOAD_OP, ARGI_LOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_0R, AML_FLAGS_EXEC_1A_1T_0R),
/* 4B */ ACPI_OP ("Stall", ARGP_STALL_OP, ARGI_STALL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
/* 4C */ ACPI_OP ("Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
/* 4D */ ACPI_OP ("Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R),
/* 4E */ ACPI_OP ("Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
/* 4F */ ACPI_OP ("Wait", ARGP_WAIT_OP, ARGI_WAIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R),
/* 50 */ ACPI_OP ("Reset", ARGP_RESET_OP, ARGI_RESET_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
/* 51 */ ACPI_OP ("Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
/* 52 */ ACPI_OP ("FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
/* 53 */ ACPI_OP ("ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
/* 54 */ ACPI_OP ("Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
/* 55 */ ACPI_OP ("Revision", ARGP_REVISION_OP, ARGI_REVISION_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0),
/* 56 */ ACPI_OP ("Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0),
/* 57 */ ACPI_OP ("Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_0T_0R, AML_FLAGS_EXEC_3A_0T_0R),
/* 58 */ ACPI_OP ("OperationRegion", ARGP_REGION_OP, ARGI_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
/* 59 */ ACPI_OP ("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
/* 5A */ ACPI_OP ("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
/* 5B */ ACPI_OP ("Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP, ACPI_TYPE_PROCESSOR, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
/* 5C */ ACPI_OP ("PowerResource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP, ACPI_TYPE_POWER, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
/* 5D */ ACPI_OP ("ThermalZone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP, ACPI_TYPE_THERMAL, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
/* 5E */ ACPI_OP ("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
/* 5F */ ACPI_OP ("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, ACPI_TYPE_LOCAL_BANK_FIELD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD | AML_DEFER),
 
/* Internal opcodes that map to invalid AML opcodes */
 
/* 60 */ ACPI_OP ("LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT),
/* 61 */ ACPI_OP ("LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT),
/* 62 */ ACPI_OP ("LGreaterEqual", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT),
/* 63 */ ACPI_OP ("-NamePath-", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_NSOBJECT | AML_NSNODE ),
/* 64 */ ACPI_OP ("-MethodCall-", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP, ACPI_TYPE_METHOD, AML_CLASS_METHOD_CALL, AML_TYPE_METHOD_CALL, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE),
/* 65 */ ACPI_OP ("-ByteList-", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP, ACPI_TYPE_ANY, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, 0),
/* 66 */ ACPI_OP ("-ReservedField-", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0),
/* 67 */ ACPI_OP ("-NamedField-", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ),
/* 68 */ ACPI_OP ("-AccessField-", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0),
/* 69 */ ACPI_OP ("-StaticString", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0),
/* 6A */ ACPI_OP ("-Return Value-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_RETURN_VALUE, AML_TYPE_RETURN, AML_HAS_ARGS | AML_HAS_RETVAL),
/* 6B */ ACPI_OP ("-UNKNOWN_OP-", ARG_NONE, ARG_NONE, ACPI_TYPE_INVALID, AML_CLASS_UNKNOWN, AML_TYPE_BOGUS, AML_HAS_ARGS),
/* 6C */ ACPI_OP ("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS),
/* 6D */ ACPI_OP ("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS),
 
/* ACPI 2.0 opcodes */
 
/* 6E */ ACPI_OP ("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
/* 6F */ ACPI_OP ("Package", /* Var */ ARGP_VAR_PACKAGE_OP, ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER),
/* 70 */ ACPI_OP ("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
/* 71 */ ACPI_OP ("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
/* 72 */ ACPI_OP ("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
/* 73 */ ACPI_OP ("ToBuffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
/* 74 */ ACPI_OP ("ToDecimalString", ARGP_TO_DEC_STR_OP, ARGI_TO_DEC_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
/* 75 */ ACPI_OP ("ToHexString", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
/* 76 */ ACPI_OP ("ToInteger", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
/* 77 */ ACPI_OP ("ToString", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
/* 78 */ ACPI_OP ("CopyObject", ARGP_COPY_OP, ARGI_COPY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R),
/* 79 */ ACPI_OP ("Mid", ARGP_MID_OP, ARGI_MID_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_1T_1R, AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT),
/* 7A */ ACPI_OP ("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
/* 7B */ ACPI_OP ("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R),
/* 7C */ ACPI_OP ("DataTableRegion", ARGP_DATA_REGION_OP, ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
/* 7D */ ACPI_OP ("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE),
 
/* ACPI 3.0 opcodes */
 
/* 7E */ ACPI_OP ("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R, AML_FLAGS_EXEC_0A_0T_1R)
 
/*! [End] no source code translation !*/
};
 
/*
* This table is directly indexed by the opcodes, and returns an
* index into the table above
*/
static const UINT8 AcpiGbl_ShortOpIndex[256] =
{
/* 0 1 2 3 4 5 6 7 */
/* 8 9 A B C D E F */
/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK,
/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK,
/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK,
/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX,
/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D,
/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC,
/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13,
/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK,
/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22,
/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30,
/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72,
/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74,
/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A,
/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61,
/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK,
/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45,
};
 
/*
* This table is indexed by the second opcode of the extended opcode
* pair. It returns an index into the opcode table (AcpiGbl_AmlOpInfo)
*/
static const UINT8 AcpiGbl_LongOpIndex[NUM_EXTENDED_OPCODE] =
{
/* 0 1 2 3 4 5 6 7 */
/* 8 9 A B C D E F */
/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK,
/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B,
/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK,
/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
/* 0x88 */ 0x7C,
};
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsGetOpcodeInfo
*
* PARAMETERS: Opcode - The AML opcode
*
* RETURN: A pointer to the info about the opcode.
*
* DESCRIPTION: Find AML opcode description based on the opcode.
* NOTE: This procedure must ALWAYS return a valid pointer!
*
******************************************************************************/
 
const ACPI_OPCODE_INFO *
AcpiPsGetOpcodeInfo (
UINT16 Opcode)
{
ACPI_FUNCTION_NAME (PsGetOpcodeInfo);
 
 
/*
* Detect normal 8-bit opcode or extended 16-bit opcode
*/
if (!(Opcode & 0xFF00))
{
/* Simple (8-bit) opcode: 0-255, can't index beyond table */
 
return (&AcpiGbl_AmlOpInfo [AcpiGbl_ShortOpIndex [(UINT8) Opcode]]);
}
 
if (((Opcode & 0xFF00) == AML_EXTENDED_OPCODE) &&
(((UINT8) Opcode) <= MAX_EXTENDED_OPCODE))
{
/* Valid extended (16-bit) opcode */
 
return (&AcpiGbl_AmlOpInfo [AcpiGbl_LongOpIndex [(UINT8) Opcode]]);
}
 
/* Unknown AML opcode */
 
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Unknown AML opcode [%4.4X]\n", Opcode));
 
return (&AcpiGbl_AmlOpInfo [_UNK]);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsGetOpcodeName
*
* PARAMETERS: Opcode - The AML opcode
*
* RETURN: A pointer to the name of the opcode (ASCII String)
* Note: Never returns NULL.
*
* DESCRIPTION: Translate an opcode into a human-readable string
*
******************************************************************************/
 
char *
AcpiPsGetOpcodeName (
UINT16 Opcode)
{
#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
 
const ACPI_OPCODE_INFO *Op;
 
 
Op = AcpiPsGetOpcodeInfo (Opcode);
 
/* Always guaranteed to return a valid pointer */
 
return (Op->Name);
 
#else
return ("OpcodeName unavailable");
 
#endif
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsGetArgumentCount
*
* PARAMETERS: OpType - Type associated with the AML opcode
*
* RETURN: Argument count
*
* DESCRIPTION: Obtain the number of expected arguments for an AML opcode
*
******************************************************************************/
 
UINT8
AcpiPsGetArgumentCount (
UINT32 OpType)
{
 
if (OpType <= AML_TYPE_EXEC_6A_0T_1R)
{
return (AcpiGbl_ArgumentCount[OpType]);
}
 
return (0);
}
/drivers/devman/acpica/parser/psparse.c
0,0 → 1,791
/******************************************************************************
*
* Module Name: psparse - Parser top level AML parse routines
*
*****************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, 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
* documentation and/or other materials provided with distribution. In
* 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
* provision in the documentation and/or other materials provided with the
* 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
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* 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.
*
*****************************************************************************/
 
 
/*
* Parse the AML and build an operation tree as most interpreters,
* like Perl, do. Parsing is done by hand rather than with a YACC
* 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 AmlOpInfo[]
*/
 
#include "acpi.h"
#include "accommon.h"
#include "acparser.h"
#include "acdispat.h"
#include "amlcode.h"
#include "acnamesp.h"
#include "acinterp.h"
 
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("psparse")
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsGetOpcodeSize
*
* PARAMETERS: Opcode - An AML opcode
*
* RETURN: Size of the opcode, in bytes (1 or 2)
*
* DESCRIPTION: Get the size of the current opcode.
*
******************************************************************************/
 
UINT32
AcpiPsGetOpcodeSize (
UINT32 Opcode)
{
 
/* Extended (2-byte) opcode if > 255 */
 
if (Opcode > 0x00FF)
{
return (2);
}
 
/* Otherwise, just a single byte opcode */
 
return (1);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsPeekOpcode
*
* PARAMETERS: ParserState - A parser state object
*
* RETURN: Next AML opcode
*
* DESCRIPTION: Get next AML opcode (without incrementing AML pointer)
*
******************************************************************************/
 
UINT16
AcpiPsPeekOpcode (
ACPI_PARSE_STATE *ParserState)
{
UINT8 *Aml;
UINT16 Opcode;
 
 
Aml = ParserState->Aml;
Opcode = (UINT16) ACPI_GET8 (Aml);
 
if (Opcode == AML_EXTENDED_OP_PREFIX)
{
/* Extended opcode, get the second opcode byte */
 
Aml++;
Opcode = (UINT16) ((Opcode << 8) | ACPI_GET8 (Aml));
}
 
return (Opcode);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsCompleteThisOp
*
* PARAMETERS: WalkState - Current State
* Op - Op to complete
*
* RETURN: Status
*
* DESCRIPTION: Perform any cleanup at the completion of an Op.
*
******************************************************************************/
 
ACPI_STATUS
AcpiPsCompleteThisOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *Prev;
ACPI_PARSE_OBJECT *Next;
const ACPI_OPCODE_INFO *ParentInfo;
ACPI_PARSE_OBJECT *ReplacementOp = NULL;
ACPI_STATUS Status = AE_OK;
 
 
ACPI_FUNCTION_TRACE_PTR (PsCompleteThisOp, Op);
 
 
/* Check for null Op, can happen if AML code is corrupt */
 
if (!Op)
{
return_ACPI_STATUS (AE_OK); /* OK for now */
}
 
/* Delete this op and the subtree below it if asked to */
 
if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) ||
(WalkState->OpInfo->Class == AML_CLASS_ARGUMENT))
{
return_ACPI_STATUS (AE_OK);
}
 
/* Make sure that we only delete this subtree */
 
if (Op->Common.Parent)
{
Prev = Op->Common.Parent->Common.Value.Arg;
if (!Prev)
{
/* Nothing more to do */
 
goto Cleanup;
}
 
/*
* Check if we need to replace the operator and its subtree
* with a return value op (placeholder op)
*/
ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode);
 
switch (ParentInfo->Class)
{
case AML_CLASS_CONTROL:
break;
 
case AML_CLASS_CREATE:
 
/*
* These opcodes contain TermArg operands. The current
* op must be replaced by a placeholder return op
*/
ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
if (!ReplacementOp)
{
Status = AE_NO_MEMORY;
}
break;
 
case AML_CLASS_NAMED_OBJECT:
 
/*
* These opcodes contain TermArg operands. The current
* op must be replaced by a placeholder return op
*/
if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) ||
(Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) ||
(Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) ||
(Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
(Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP) ||
(Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
{
ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
if (!ReplacementOp)
{
Status = AE_NO_MEMORY;
}
}
else if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) &&
(WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2))
{
if ((Op->Common.AmlOpcode == AML_BUFFER_OP) ||
(Op->Common.AmlOpcode == AML_PACKAGE_OP) ||
(Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
{
ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode);
if (!ReplacementOp)
{
Status = AE_NO_MEMORY;
}
else
{
ReplacementOp->Named.Data = Op->Named.Data;
ReplacementOp->Named.Length = Op->Named.Length;
}
}
}
break;
 
default:
 
ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
if (!ReplacementOp)
{
Status = AE_NO_MEMORY;
}
}
 
/* We must unlink this op from the parent tree */
 
if (Prev == Op)
{
/* This op is the first in the list */
 
if (ReplacementOp)
{
ReplacementOp->Common.Parent = Op->Common.Parent;
ReplacementOp->Common.Value.Arg = NULL;
ReplacementOp->Common.Node = Op->Common.Node;
Op->Common.Parent->Common.Value.Arg = ReplacementOp;
ReplacementOp->Common.Next = Op->Common.Next;
}
else
{
Op->Common.Parent->Common.Value.Arg = Op->Common.Next;
}
}
 
/* Search the parent list */
 
else while (Prev)
{
/* Traverse all siblings in the parent's argument list */
 
Next = Prev->Common.Next;
if (Next == Op)
{
if (ReplacementOp)
{
ReplacementOp->Common.Parent = Op->Common.Parent;
ReplacementOp->Common.Value.Arg = NULL;
ReplacementOp->Common.Node = Op->Common.Node;
Prev->Common.Next = ReplacementOp;
ReplacementOp->Common.Next = Op->Common.Next;
Next = NULL;
}
else
{
Prev->Common.Next = Op->Common.Next;
Next = NULL;
}
}
Prev = Next;
}
}
 
 
Cleanup:
 
/* Now we can actually delete the subtree rooted at Op */
 
AcpiPsDeleteParseTree (Op);
return_ACPI_STATUS (Status);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsNextParseState
*
* PARAMETERS: WalkState - Current state
* Op - Current parse op
* CallbackStatus - Status from previous operation
*
* RETURN: Status
*
* DESCRIPTION: Update the parser state based upon the return exception from
* the parser callback.
*
******************************************************************************/
 
ACPI_STATUS
AcpiPsNextParseState (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op,
ACPI_STATUS CallbackStatus)
{
ACPI_PARSE_STATE *ParserState = &WalkState->ParserState;
ACPI_STATUS Status = AE_CTRL_PENDING;
 
 
ACPI_FUNCTION_TRACE_PTR (PsNextParseState, Op);
 
 
switch (CallbackStatus)
{
case AE_CTRL_TERMINATE:
/*
* A control method was terminated via a RETURN statement.
* The walk of this method is complete.
*/
ParserState->Aml = ParserState->AmlEnd;
Status = AE_CTRL_TERMINATE;
break;
 
 
case AE_CTRL_BREAK:
 
ParserState->Aml = WalkState->AmlLastWhile;
WalkState->ControlState->Common.Value = FALSE;
Status = AE_CTRL_BREAK;
break;
 
 
case AE_CTRL_CONTINUE:
 
ParserState->Aml = WalkState->AmlLastWhile;
Status = AE_CTRL_CONTINUE;
break;
 
 
case AE_CTRL_PENDING:
 
ParserState->Aml = WalkState->AmlLastWhile;
break;
 
#if 0
case AE_CTRL_SKIP:
 
ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
Status = AE_OK;
break;
#endif
 
case AE_CTRL_TRUE:
/*
* Predicate of an IF was true, and we are at the matching ELSE.
* Just close out this package
*/
ParserState->Aml = AcpiPsGetNextPackageEnd (ParserState);
Status = AE_CTRL_PENDING;
break;
 
 
case AE_CTRL_FALSE:
/*
* Either an IF/WHILE Predicate was false or we encountered a BREAK
* opcode. In both cases, we do not execute the rest of the
* package; We simply close out the parent (finishing the walk of
* this branch of the tree) and continue execution at the parent
* level.
*/
ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
 
/* In the case of a BREAK, just force a predicate (if any) to FALSE */
 
WalkState->ControlState->Common.Value = FALSE;
Status = AE_CTRL_END;
break;
 
 
case AE_CTRL_TRANSFER:
 
/* A method call (invocation) -- transfer control */
 
Status = AE_CTRL_TRANSFER;
WalkState->PrevOp = Op;
WalkState->MethodCallOp = Op;
WalkState->MethodCallNode = (Op->Common.Value.Arg)->Common.Node;
 
/* Will return value (if any) be used by the caller? */
 
WalkState->ReturnUsed = AcpiDsIsResultUsed (Op, WalkState);
break;
 
 
default:
 
Status = CallbackStatus;
if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL)
{
Status = AE_OK;
}
break;
}
 
return_ACPI_STATUS (Status);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsParseAml
*
* PARAMETERS: WalkState - Current state
*
*
* RETURN: Status
*
* DESCRIPTION: Parse raw AML and return a tree of ops
*
******************************************************************************/
 
ACPI_STATUS
AcpiPsParseAml (
ACPI_WALK_STATE *WalkState)
{
ACPI_STATUS Status;
ACPI_THREAD_STATE *Thread;
ACPI_THREAD_STATE *PrevWalkList = AcpiGbl_CurrentWalkList;
ACPI_WALK_STATE *PreviousWalkState;
 
 
ACPI_FUNCTION_TRACE (PsParseAml);
 
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
"Entered with WalkState=%p Aml=%p size=%X\n",
WalkState, WalkState->ParserState.Aml,
WalkState->ParserState.AmlSize));
 
if (!WalkState->ParserState.Aml)
{
return_ACPI_STATUS (AE_NULL_OBJECT);
}
 
/* Create and initialize a new thread state */
 
Thread = AcpiUtCreateThreadState ();
if (!Thread)
{
if (WalkState->MethodDesc)
{
/* Executing a control method - additional cleanup */
 
AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
}
 
AcpiDsDeleteWalkState (WalkState);
return_ACPI_STATUS (AE_NO_MEMORY);
}
 
WalkState->Thread = Thread;
 
/*
* If executing a method, the starting SyncLevel is this method's
* SyncLevel
*/
if (WalkState->MethodDesc)
{
WalkState->Thread->CurrentSyncLevel = WalkState->MethodDesc->Method.SyncLevel;
}
 
AcpiDsPushWalkState (WalkState, Thread);
 
/*
* This global allows the AML debugger to get a handle to the currently
* executing control method.
*/
AcpiGbl_CurrentWalkList = Thread;
 
/*
* Execute the walk loop as long as there is a valid Walk State. This
* handles nested control method invocations without recursion.
*/
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", WalkState));
 
Status = AE_OK;
while (WalkState)
{
if (ACPI_SUCCESS (Status))
{
/*
* The ParseLoop executes AML until the method terminates
* or calls another method.
*/
Status = AcpiPsParseLoop (WalkState);
}
 
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
"Completed one call to walk loop, %s State=%p\n",
AcpiFormatException (Status), WalkState));
 
if (Status == AE_CTRL_TRANSFER)
{
/*
* A method call was detected.
* Transfer control to the called control method
*/
Status = AcpiDsCallControlMethod (Thread, WalkState, NULL);
if (ACPI_FAILURE (Status))
{
Status = AcpiDsMethodError (Status, WalkState);
}
 
/*
* If the transfer to the new method method call worked, a new walk
* state was created -- get it
*/
WalkState = AcpiDsGetCurrentWalkState (Thread);
continue;
}
else if (Status == AE_CTRL_TERMINATE)
{
Status = AE_OK;
}
else if ((Status != AE_OK) && (WalkState->MethodDesc))
{
/* Either the method parse or actual execution failed */
 
ACPI_ERROR_METHOD ("Method parse/execution failed",
WalkState->MethodNode, NULL, Status);
 
/* Check for possible multi-thread reentrancy problem */
 
if ((Status == AE_ALREADY_EXISTS) &&
(!WalkState->MethodDesc->Method.Mutex))
{
ACPI_INFO ((AE_INFO,
"Marking method %4.4s as Serialized because of AE_ALREADY_EXISTS error",
WalkState->MethodNode->Name.Ascii));
 
/*
* Method tried to create an object twice. The probable cause is
* that the method cannot handle reentrancy.
*
* The method is marked NotSerialized, but it tried to create
* a named object, causing the second thread entrance to fail.
* Workaround this problem by marking the method permanently
* as Serialized.
*/
WalkState->MethodDesc->Method.MethodFlags |= AML_METHOD_SERIALIZED;
WalkState->MethodDesc->Method.SyncLevel = 0;
}
}
 
/* We are done with this walk, move on to the parent if any */
 
WalkState = AcpiDsPopWalkState (Thread);
 
/* Reset the current scope to the beginning of scope stack */
 
AcpiDsScopeStackClear (WalkState);
 
/*
* If we just returned from the execution of a control method or if we
* encountered an error during the method parse phase, there's lots of
* cleanup to do
*/
if (((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) ||
(ACPI_FAILURE (Status)))
{
AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
}
 
/* Delete this walk state and all linked control states */
 
AcpiPsCleanupScope (&WalkState->ParserState);
PreviousWalkState = WalkState;
 
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
"ReturnValue=%p, ImplicitValue=%p State=%p\n",
WalkState->ReturnDesc, WalkState->ImplicitReturnObj, WalkState));
 
/* Check if we have restarted a preempted walk */
 
WalkState = AcpiDsGetCurrentWalkState (Thread);
if (WalkState)
{
if (ACPI_SUCCESS (Status))
{
/*
* There is another walk state, restart it.
* If the method return value is not used by the parent,
* The object is deleted
*/
if (!PreviousWalkState->ReturnDesc)
{
/*
* In slack mode execution, if there is no return value
* we should implicitly return zero (0) as a default value.
*/
if (AcpiGbl_EnableInterpreterSlack &&
!PreviousWalkState->ImplicitReturnObj)
{
PreviousWalkState->ImplicitReturnObj =
AcpiUtCreateIntegerObject ((UINT64) 0);
if (!PreviousWalkState->ImplicitReturnObj)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
}
 
/* Restart the calling control method */
 
Status = AcpiDsRestartControlMethod (WalkState,
PreviousWalkState->ImplicitReturnObj);
}
else
{
/*
* We have a valid return value, delete any implicit
* return value.
*/
AcpiDsClearImplicitReturn (PreviousWalkState);
 
Status = AcpiDsRestartControlMethod (WalkState,
PreviousWalkState->ReturnDesc);
}
if (ACPI_SUCCESS (Status))
{
WalkState->WalkType |= ACPI_WALK_METHOD_RESTART;
}
}
else
{
/* On error, delete any return object or implicit return */
 
AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
AcpiDsClearImplicitReturn (PreviousWalkState);
}
}
 
/*
* Just completed a 1st-level method, save the final internal return
* value (if any)
*/
else if (PreviousWalkState->CallerReturnDesc)
{
if (PreviousWalkState->ImplicitReturnObj)
{
*(PreviousWalkState->CallerReturnDesc) =
PreviousWalkState->ImplicitReturnObj;
}
else
{
/* NULL if no return value */
 
*(PreviousWalkState->CallerReturnDesc) =
PreviousWalkState->ReturnDesc;
}
}
else
{
if (PreviousWalkState->ReturnDesc)
{
/* Caller doesn't want it, must delete it */
 
AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
}
if (PreviousWalkState->ImplicitReturnObj)
{
/* Caller doesn't want it, must delete it */
 
AcpiUtRemoveReference (PreviousWalkState->ImplicitReturnObj);
}
}
 
AcpiDsDeleteWalkState (PreviousWalkState);
}
 
/* Normal exit */
 
AcpiExReleaseAllMutexes (Thread);
AcpiUtDeleteGenericState (ACPI_CAST_PTR (ACPI_GENERIC_STATE, Thread));
AcpiGbl_CurrentWalkList = PrevWalkList;
return_ACPI_STATUS (Status);
}
 
 
/drivers/devman/acpica/parser/psscope.c
0,0 → 1,374
/******************************************************************************
*
* Module Name: psscope - Parser scope stack management routines
*
*****************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, 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
* documentation and/or other materials provided with distribution. In
* 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
* provision in the documentation and/or other materials provided with the
* 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
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* 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.
*
*****************************************************************************/
 
 
#include "acpi.h"
#include "accommon.h"
#include "acparser.h"
 
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("psscope")
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsGetParentScope
*
* PARAMETERS: ParserState - Current parser state object
*
* RETURN: Pointer to an Op object
*
* DESCRIPTION: Get parent of current op being parsed
*
******************************************************************************/
 
ACPI_PARSE_OBJECT *
AcpiPsGetParentScope (
ACPI_PARSE_STATE *ParserState)
{
 
return (ParserState->Scope->ParseScope.Op);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsHasCompletedScope
*
* PARAMETERS: ParserState - Current parser state object
*
* RETURN: Boolean, TRUE = scope completed.
*
* DESCRIPTION: Is parsing of current argument complete? Determined by
* 1) AML pointer is at or beyond the end of the scope
* 2) The scope argument count has reached zero.
*
******************************************************************************/
 
BOOLEAN
AcpiPsHasCompletedScope (
ACPI_PARSE_STATE *ParserState)
{
 
return ((BOOLEAN)
((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd ||
!ParserState->Scope->ParseScope.ArgCount)));
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsInitScope
*
* PARAMETERS: ParserState - Current parser state object
* Root - the Root Node of this new scope
*
* RETURN: Status
*
* DESCRIPTION: Allocate and init a new scope object
*
******************************************************************************/
 
ACPI_STATUS
AcpiPsInitScope (
ACPI_PARSE_STATE *ParserState,
ACPI_PARSE_OBJECT *RootOp)
{
ACPI_GENERIC_STATE *Scope;
 
 
ACPI_FUNCTION_TRACE_PTR (PsInitScope, RootOp);
 
 
Scope = AcpiUtCreateGenericState ();
if (!Scope)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
 
Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RPSCOPE;
Scope->ParseScope.Op = RootOp;
Scope->ParseScope.ArgCount = ACPI_VAR_ARGS;
Scope->ParseScope.ArgEnd = ParserState->AmlEnd;
Scope->ParseScope.PkgEnd = ParserState->AmlEnd;
 
ParserState->Scope = Scope;
ParserState->StartOp = RootOp;
 
return_ACPI_STATUS (AE_OK);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsPushScope
*
* PARAMETERS: ParserState - Current parser state object
* Op - Current op to be pushed
* RemainingArgs - List of args remaining
* ArgCount - Fixed or variable number of args
*
* RETURN: Status
*
* DESCRIPTION: Push current op to begin parsing its argument
*
******************************************************************************/
 
ACPI_STATUS
AcpiPsPushScope (
ACPI_PARSE_STATE *ParserState,
ACPI_PARSE_OBJECT *Op,
UINT32 RemainingArgs,
UINT32 ArgCount)
{
ACPI_GENERIC_STATE *Scope;
 
 
ACPI_FUNCTION_TRACE_PTR (PsPushScope, Op);
 
 
Scope = AcpiUtCreateGenericState ();
if (!Scope)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
 
Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PSCOPE;
Scope->ParseScope.Op = Op;
Scope->ParseScope.ArgList = RemainingArgs;
Scope->ParseScope.ArgCount = ArgCount;
Scope->ParseScope.PkgEnd = ParserState->PkgEnd;
 
/* Push onto scope stack */
 
AcpiUtPushGenericState (&ParserState->Scope, Scope);
 
if (ArgCount == ACPI_VAR_ARGS)
{
/* Multiple arguments */
 
Scope->ParseScope.ArgEnd = ParserState->PkgEnd;
}
else
{
/* Single argument */
 
Scope->ParseScope.ArgEnd = ACPI_TO_POINTER (ACPI_MAX_PTR);
}
 
return_ACPI_STATUS (AE_OK);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsPopScope
*
* PARAMETERS: ParserState - Current parser state object
* Op - Where the popped op is returned
* ArgList - Where the popped "next argument" is
* returned
* ArgCount - Count of objects in ArgList
*
* RETURN: Status
*
* DESCRIPTION: Return to parsing a previous op
*
******************************************************************************/
 
void
AcpiPsPopScope (
ACPI_PARSE_STATE *ParserState,
ACPI_PARSE_OBJECT **Op,
UINT32 *ArgList,
UINT32 *ArgCount)
{
ACPI_GENERIC_STATE *Scope = ParserState->Scope;
 
 
ACPI_FUNCTION_TRACE (PsPopScope);
 
 
/* Only pop the scope if there is in fact a next scope */
 
if (Scope->Common.Next)
{
Scope = AcpiUtPopGenericState (&ParserState->Scope);
 
/* Return to parsing previous op */
 
*Op = Scope->ParseScope.Op;
*ArgList = Scope->ParseScope.ArgList;
*ArgCount = Scope->ParseScope.ArgCount;
ParserState->PkgEnd = Scope->ParseScope.PkgEnd;
 
/* All done with this scope state structure */
 
AcpiUtDeleteGenericState (Scope);
}
else
{
/* Empty parse stack, prepare to fetch next opcode */
 
*Op = NULL;
*ArgList = 0;
*ArgCount = 0;
}
 
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
"Popped Op %p Args %X\n", *Op, *ArgCount));
return_VOID;
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsCleanupScope
*
* PARAMETERS: ParserState - Current parser state object
*
* RETURN: None
*
* DESCRIPTION: Destroy available list, remaining stack levels, and return
* root scope
*
******************************************************************************/
 
void
AcpiPsCleanupScope (
ACPI_PARSE_STATE *ParserState)
{
ACPI_GENERIC_STATE *Scope;
 
 
ACPI_FUNCTION_TRACE_PTR (PsCleanupScope, ParserState);
 
 
if (!ParserState)
{
return_VOID;
}
 
/* Delete anything on the scope stack */
 
while (ParserState->Scope)
{
Scope = AcpiUtPopGenericState (&ParserState->Scope);
AcpiUtDeleteGenericState (Scope);
}
 
return_VOID;
}
 
/drivers/devman/acpica/parser/pstree.c
0,0 → 1,427
/******************************************************************************
*
* Module Name: pstree - Parser op tree manipulation/traversal/search
*
*****************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, 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
* documentation and/or other materials provided with distribution. In
* 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
* provision in the documentation and/or other materials provided with the
* 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
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* 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 __PSTREE_C__
 
#include "acpi.h"
#include "accommon.h"
#include "acparser.h"
#include "amlcode.h"
 
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("pstree")
 
/* Local prototypes */
 
#ifdef ACPI_OBSOLETE_FUNCTIONS
ACPI_PARSE_OBJECT *
AcpiPsGetChild (
ACPI_PARSE_OBJECT *op);
#endif
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsGetArg
*
* PARAMETERS: Op - Get an argument for this op
* Argn - Nth argument to get
*
* RETURN: The argument (as an Op object). NULL if argument does not exist
*
* DESCRIPTION: Get the specified op's argument.
*
******************************************************************************/
 
ACPI_PARSE_OBJECT *
AcpiPsGetArg (
ACPI_PARSE_OBJECT *Op,
UINT32 Argn)
{
ACPI_PARSE_OBJECT *Arg = NULL;
const ACPI_OPCODE_INFO *OpInfo;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
/* Get the info structure for this opcode */
 
OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
if (OpInfo->Class == AML_CLASS_UNKNOWN)
{
/* Invalid opcode or ASCII character */
 
return (NULL);
}
 
/* Check if this opcode requires argument sub-objects */
 
if (!(OpInfo->Flags & AML_HAS_ARGS))
{
/* Has no linked argument objects */
 
return (NULL);
}
 
/* Get the requested argument object */
 
Arg = Op->Common.Value.Arg;
while (Arg && Argn)
{
Argn--;
Arg = Arg->Common.Next;
}
 
return (Arg);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsAppendArg
*
* PARAMETERS: Op - Append an argument to this Op.
* Arg - Argument Op to append
*
* RETURN: None.
*
* DESCRIPTION: Append an argument to an op's argument list (a NULL arg is OK)
*
******************************************************************************/
 
void
AcpiPsAppendArg (
ACPI_PARSE_OBJECT *Op,
ACPI_PARSE_OBJECT *Arg)
{
ACPI_PARSE_OBJECT *PrevArg;
const ACPI_OPCODE_INFO *OpInfo;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
if (!Op)
{
return;
}
 
/* Get the info structure for this opcode */
 
OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
if (OpInfo->Class == AML_CLASS_UNKNOWN)
{
/* Invalid opcode */
 
ACPI_ERROR ((AE_INFO, "Invalid AML Opcode: 0x%2.2X",
Op->Common.AmlOpcode));
return;
}
 
/* Check if this opcode requires argument sub-objects */
 
if (!(OpInfo->Flags & AML_HAS_ARGS))
{
/* Has no linked argument objects */
 
return;
}
 
/* Append the argument to the linked argument list */
 
if (Op->Common.Value.Arg)
{
/* Append to existing argument list */
 
PrevArg = Op->Common.Value.Arg;
while (PrevArg->Common.Next)
{
PrevArg = PrevArg->Common.Next;
}
PrevArg->Common.Next = Arg;
}
else
{
/* No argument list, this will be the first argument */
 
Op->Common.Value.Arg = Arg;
}
 
/* Set the parent in this arg and any args linked after it */
 
while (Arg)
{
Arg->Common.Parent = Op;
Arg = Arg->Common.Next;
 
Op->Common.ArgListLength++;
}
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsGetDepthNext
*
* PARAMETERS: Origin - Root of subtree to search
* Op - Last (previous) Op that was found
*
* RETURN: Next Op found in the search.
*
* DESCRIPTION: Get next op in tree (walking the tree in depth-first order)
* Return NULL when reaching "origin" or when walking up from root
*
******************************************************************************/
 
ACPI_PARSE_OBJECT *
AcpiPsGetDepthNext (
ACPI_PARSE_OBJECT *Origin,
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *Next = NULL;
ACPI_PARSE_OBJECT *Parent;
ACPI_PARSE_OBJECT *Arg;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
if (!Op)
{
return (NULL);
}
 
/* Look for an argument or child */
 
Next = AcpiPsGetArg (Op, 0);
if (Next)
{
return (Next);
}
 
/* Look for a sibling */
 
Next = Op->Common.Next;
if (Next)
{
return (Next);
}
 
/* Look for a sibling of parent */
 
Parent = Op->Common.Parent;
 
while (Parent)
{
Arg = AcpiPsGetArg (Parent, 0);
while (Arg && (Arg != Origin) && (Arg != Op))
{
Arg = Arg->Common.Next;
}
 
if (Arg == Origin)
{
/* Reached parent of origin, end search */
 
return (NULL);
}
 
if (Parent->Common.Next)
{
/* Found sibling of parent */
 
return (Parent->Common.Next);
}
 
Op = Parent;
Parent = Parent->Common.Parent;
}
 
return (Next);
}
 
 
#ifdef ACPI_OBSOLETE_FUNCTIONS
/*******************************************************************************
*
* FUNCTION: AcpiPsGetChild
*
* PARAMETERS: Op - Get the child of this Op
*
* RETURN: Child Op, Null if none is found.
*
* DESCRIPTION: Get op's children or NULL if none
*
******************************************************************************/
 
ACPI_PARSE_OBJECT *
AcpiPsGetChild (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *Child = NULL;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
switch (Op->Common.AmlOpcode)
{
case AML_SCOPE_OP:
case AML_ELSE_OP:
case AML_DEVICE_OP:
case AML_THERMAL_ZONE_OP:
case AML_INT_METHODCALL_OP:
 
Child = AcpiPsGetArg (Op, 0);
break;
 
 
case AML_BUFFER_OP:
case AML_PACKAGE_OP:
case AML_METHOD_OP:
case AML_IF_OP:
case AML_WHILE_OP:
case AML_FIELD_OP:
 
Child = AcpiPsGetArg (Op, 1);
break;
 
 
case AML_POWER_RES_OP:
case AML_INDEX_FIELD_OP:
 
Child = AcpiPsGetArg (Op, 2);
break;
 
 
case AML_PROCESSOR_OP:
case AML_BANK_FIELD_OP:
 
Child = AcpiPsGetArg (Op, 3);
break;
 
 
default:
/* All others have no children */
break;
}
 
return (Child);
}
#endif
 
 
/drivers/devman/acpica/parser/psutils.c
0,0 → 1,362
/******************************************************************************
*
* Module Name: psutils - Parser miscellaneous utilities (Parser only)
*
*****************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, 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
* documentation and/or other materials provided with distribution. In
* 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
* provision in the documentation and/or other materials provided with the
* 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
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* 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.
*
*****************************************************************************/
 
 
#include "acpi.h"
#include "accommon.h"
#include "acparser.h"
#include "amlcode.h"
 
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("psutils")
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsCreateScopeOp
*
* PARAMETERS: None
*
* RETURN: A new Scope object, null on failure
*
* DESCRIPTION: Create a Scope and associated namepath op with the root name
*
******************************************************************************/
 
ACPI_PARSE_OBJECT *
AcpiPsCreateScopeOp (
void)
{
ACPI_PARSE_OBJECT *ScopeOp;
 
 
ScopeOp = AcpiPsAllocOp (AML_SCOPE_OP);
if (!ScopeOp)
{
return (NULL);
}
 
ScopeOp->Named.Name = ACPI_ROOT_NAME;
return (ScopeOp);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsInitOp
*
* PARAMETERS: Op - A newly allocated Op object
* Opcode - Opcode to store in the Op
*
* RETURN: None
*
* DESCRIPTION: Initialize a parse (Op) object
*
******************************************************************************/
 
void
AcpiPsInitOp (
ACPI_PARSE_OBJECT *Op,
UINT16 Opcode)
{
ACPI_FUNCTION_ENTRY ();
 
 
Op->Common.DescriptorType = ACPI_DESC_TYPE_PARSER;
Op->Common.AmlOpcode = Opcode;
 
ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (Op->Common.AmlOpName,
(AcpiPsGetOpcodeInfo (Opcode))->Name,
sizeof (Op->Common.AmlOpName)));
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsAllocOp
*
* PARAMETERS: Opcode - Opcode that will be stored in the new Op
*
* RETURN: Pointer to the new Op, null on failure
*
* DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on
* opcode. A cache of opcodes is available for the pure
* GENERIC_OP, since this is by far the most commonly used.
*
******************************************************************************/
 
ACPI_PARSE_OBJECT*
AcpiPsAllocOp (
UINT16 Opcode)
{
ACPI_PARSE_OBJECT *Op;
const ACPI_OPCODE_INFO *OpInfo;
UINT8 Flags = ACPI_PARSEOP_GENERIC;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
OpInfo = AcpiPsGetOpcodeInfo (Opcode);
 
/* Determine type of ParseOp required */
 
if (OpInfo->Flags & AML_DEFER)
{
Flags = ACPI_PARSEOP_DEFERRED;
}
else if (OpInfo->Flags & AML_NAMED)
{
Flags = ACPI_PARSEOP_NAMED;
}
else if (Opcode == AML_INT_BYTELIST_OP)
{
Flags = ACPI_PARSEOP_BYTELIST;
}
 
/* Allocate the minimum required size object */
 
if (Flags == ACPI_PARSEOP_GENERIC)
{
/* The generic op (default) is by far the most common (16 to 1) */
 
Op = AcpiOsAcquireObject (AcpiGbl_PsNodeCache);
}
else
{
/* Extended parseop */
 
Op = AcpiOsAcquireObject (AcpiGbl_PsNodeExtCache);
}
 
/* Initialize the Op */
 
if (Op)
{
AcpiPsInitOp (Op, Opcode);
Op->Common.Flags = Flags;
}
 
return (Op);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsFreeOp
*
* PARAMETERS: Op - Op to be freed
*
* RETURN: None.
*
* DESCRIPTION: Free an Op object. Either put it on the GENERIC_OP cache list
* or actually free it.
*
******************************************************************************/
 
void
AcpiPsFreeOp (
ACPI_PARSE_OBJECT *Op)
{
ACPI_FUNCTION_NAME (PsFreeOp);
 
 
if (Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n", Op));
}
 
if (Op->Common.Flags & ACPI_PARSEOP_GENERIC)
{
(void) AcpiOsReleaseObject (AcpiGbl_PsNodeCache, Op);
}
else
{
(void) AcpiOsReleaseObject (AcpiGbl_PsNodeExtCache, Op);
}
}
 
 
/*******************************************************************************
*
* FUNCTION: Utility functions
*
* DESCRIPTION: Low level character and object functions
*
******************************************************************************/
 
 
/*
* Is "c" a namestring lead character?
*/
BOOLEAN
AcpiPsIsLeadingChar (
UINT32 c)
{
return ((BOOLEAN) (c == '_' || (c >= 'A' && c <= 'Z')));
}
 
 
/*
* Is "c" a namestring prefix character?
*/
BOOLEAN
AcpiPsIsPrefixChar (
UINT32 c)
{
return ((BOOLEAN) (c == '\\' || c == '^'));
}
 
 
/*
* Get op's name (4-byte name segment) or 0 if unnamed
*/
UINT32
AcpiPsGetName (
ACPI_PARSE_OBJECT *Op)
{
 
/* The "generic" object has no name associated with it */
 
if (Op->Common.Flags & ACPI_PARSEOP_GENERIC)
{
return (0);
}
 
/* Only the "Extended" parse objects have a name */
 
return (Op->Named.Name);
}
 
 
/*
* Set op's name
*/
void
AcpiPsSetName (
ACPI_PARSE_OBJECT *Op,
UINT32 name)
{
 
/* The "generic" object has no name associated with it */
 
if (Op->Common.Flags & ACPI_PARSEOP_GENERIC)
{
return;
}
 
Op->Named.Name = name;
}
 
/drivers/devman/acpica/parser/pswalk.c
0,0 → 1,193
/******************************************************************************
*
* Module Name: pswalk - Parser routines to walk parsed op tree(s)
*
*****************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, 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
* documentation and/or other materials provided with distribution. In
* 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
* provision in the documentation and/or other materials provided with the
* 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
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* 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.
*
*****************************************************************************/
 
 
#include "acpi.h"
#include "accommon.h"
#include "acparser.h"
 
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("pswalk")
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsDeleteParseTree
*
* PARAMETERS: SubtreeRoot - Root of tree (or subtree) to delete
*
* RETURN: None
*
* DESCRIPTION: Delete a portion of or an entire parse tree.
*
******************************************************************************/
 
void
AcpiPsDeleteParseTree (
ACPI_PARSE_OBJECT *SubtreeRoot)
{
ACPI_PARSE_OBJECT *Op = SubtreeRoot;
ACPI_PARSE_OBJECT *Next = NULL;
ACPI_PARSE_OBJECT *Parent = NULL;
 
 
ACPI_FUNCTION_TRACE_PTR (PsDeleteParseTree, SubtreeRoot);
 
 
/* Visit all nodes in the subtree */
 
while (Op)
{
/* Check if we are not ascending */
 
if (Op != Parent)
{
/* Look for an argument or child of the current op */
 
Next = AcpiPsGetArg (Op, 0);
if (Next)
{
/* Still going downward in tree (Op is not completed yet) */
 
Op = Next;
continue;
}
}
 
/* No more children, this Op is complete. */
 
Next = Op->Common.Next;
Parent = Op->Common.Parent;
 
AcpiPsFreeOp (Op);
 
/* If we are back to the starting point, the walk is complete. */
 
if (Op == SubtreeRoot)
{
return_VOID;
}
if (Next)
{
Op = Next;
}
else
{
Op = Parent;
}
}
 
return_VOID;
}
/drivers/devman/acpica/parser/psxface.c
0,0 → 1,515
/******************************************************************************
*
* Module Name: psxface - Parser external interfaces
*
*****************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, 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
* documentation and/or other materials provided with distribution. In
* 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
* provision in the documentation and/or other materials provided with the
* 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
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* 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 __PSXFACE_C__
 
#include "acpi.h"
#include "accommon.h"
#include "acparser.h"
#include "acdispat.h"
#include "acinterp.h"
#include "actables.h"
#include "amlcode.h"
 
 
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("psxface")
 
/* Local Prototypes */
 
static void
AcpiPsStartTrace (
ACPI_EVALUATE_INFO *Info);
 
static void
AcpiPsStopTrace (
ACPI_EVALUATE_INFO *Info);
 
static void
AcpiPsUpdateParameterList (
ACPI_EVALUATE_INFO *Info,
UINT16 Action);
 
 
/*******************************************************************************
*
* FUNCTION: AcpiDebugTrace
*
* PARAMETERS: MethodName - Valid ACPI name string
* DebugLevel - Optional level mask. 0 to use default
* DebugLayer - Optional layer mask. 0 to use default
* Flags - bit 1: one shot(1) or persistent(0)
*
* RETURN: Status
*
* DESCRIPTION: External interface to enable debug tracing during control
* method execution
*
******************************************************************************/
 
ACPI_STATUS
AcpiDebugTrace (
char *Name,
UINT32 DebugLevel,
UINT32 DebugLayer,
UINT32 Flags)
{
ACPI_STATUS Status;
 
 
Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (Status))
{
return (Status);
}
 
/* TBDs: Validate name, allow full path or just nameseg */
 
AcpiGbl_TraceMethodName = *ACPI_CAST_PTR (UINT32, Name);
AcpiGbl_TraceFlags = Flags;
 
if (DebugLevel)
{
AcpiGbl_TraceDbgLevel = DebugLevel;
}
if (DebugLayer)
{
AcpiGbl_TraceDbgLayer = DebugLayer;
}
 
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return (AE_OK);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsStartTrace
*
* PARAMETERS: Info - Method info struct
*
* RETURN: None
*
* DESCRIPTION: Start control method execution trace
*
******************************************************************************/
 
static void
AcpiPsStartTrace (
ACPI_EVALUATE_INFO *Info)
{
ACPI_STATUS Status;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (Status))
{
return;
}
 
if ((!AcpiGbl_TraceMethodName) ||
(AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer))
{
goto Exit;
}
 
AcpiGbl_OriginalDbgLevel = AcpiDbgLevel;
AcpiGbl_OriginalDbgLayer = AcpiDbgLayer;
 
AcpiDbgLevel = 0x00FFFFFF;
AcpiDbgLayer = ACPI_UINT32_MAX;
 
if (AcpiGbl_TraceDbgLevel)
{
AcpiDbgLevel = AcpiGbl_TraceDbgLevel;
}
if (AcpiGbl_TraceDbgLayer)
{
AcpiDbgLayer = AcpiGbl_TraceDbgLayer;
}
 
 
Exit:
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsStopTrace
*
* PARAMETERS: Info - Method info struct
*
* RETURN: None
*
* DESCRIPTION: Stop control method execution trace
*
******************************************************************************/
 
static void
AcpiPsStopTrace (
ACPI_EVALUATE_INFO *Info)
{
ACPI_STATUS Status;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (Status))
{
return;
}
 
if ((!AcpiGbl_TraceMethodName) ||
(AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer))
{
goto Exit;
}
 
/* Disable further tracing if type is one-shot */
 
if (AcpiGbl_TraceFlags & 1)
{
AcpiGbl_TraceMethodName = 0;
AcpiGbl_TraceDbgLevel = 0;
AcpiGbl_TraceDbgLayer = 0;
}
 
AcpiDbgLevel = AcpiGbl_OriginalDbgLevel;
AcpiDbgLayer = AcpiGbl_OriginalDbgLayer;
 
Exit:
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsExecuteMethod
*
* PARAMETERS: Info - Method info block, contains:
* Node - Method Node to execute
* ObjDesc - Method object
* Parameters - List of parameters to pass to the method,
* terminated by NULL. Params itself may be
* NULL if no parameters are being passed.
* ReturnObject - Where to put method's return value (if
* any). If NULL, no value is returned.
* ParameterType - Type of Parameter list
* ReturnObject - Where to put method's return value (if
* any). If NULL, no value is returned.
* PassNumber - Parse or execute pass
*
* RETURN: Status
*
* DESCRIPTION: Execute a control method
*
******************************************************************************/
 
ACPI_STATUS
AcpiPsExecuteMethod (
ACPI_EVALUATE_INFO *Info)
{
ACPI_STATUS Status;
ACPI_PARSE_OBJECT *Op;
ACPI_WALK_STATE *WalkState;
 
 
ACPI_FUNCTION_TRACE (PsExecuteMethod);
 
 
/* Quick validation of DSDT header */
 
AcpiTbCheckDsdtHeader ();
 
/* Validate the Info and method Node */
 
if (!Info || !Info->ResolvedNode)
{
return_ACPI_STATUS (AE_NULL_ENTRY);
}
 
/* Init for new method, wait on concurrency semaphore */
 
Status = AcpiDsBeginMethodExecution (Info->ResolvedNode, Info->ObjDesc, NULL);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
/*
* The caller "owns" the parameters, so give each one an extra reference
*/
AcpiPsUpdateParameterList (Info, REF_INCREMENT);
 
/* Begin tracing if requested */
 
AcpiPsStartTrace (Info);
 
/*
* Execute the method. Performs parse simultaneously
*/
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
"**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n",
Info->ResolvedNode->Name.Ascii, Info->ResolvedNode, Info->ObjDesc));
 
/* Create and init a Root Node */
 
Op = AcpiPsCreateScopeOp ();
if (!Op)
{
Status = AE_NO_MEMORY;
goto Cleanup;
}
 
/* Create and initialize a new walk state */
 
Info->PassNumber = ACPI_IMODE_EXECUTE;
WalkState = AcpiDsCreateWalkState (
Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL);
if (!WalkState)
{
Status = AE_NO_MEMORY;
goto Cleanup;
}
 
Status = AcpiDsInitAmlWalk (WalkState, Op, Info->ResolvedNode,
Info->ObjDesc->Method.AmlStart,
Info->ObjDesc->Method.AmlLength, Info, Info->PassNumber);
if (ACPI_FAILURE (Status))
{
AcpiDsDeleteWalkState (WalkState);
goto Cleanup;
}
 
if (Info->ObjDesc->Method.Flags & AOPOBJ_MODULE_LEVEL)
{
WalkState->ParseFlags |= ACPI_PARSE_MODULE_LEVEL;
}
 
/* Invoke an internal method if necessary */
 
if (Info->ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY)
{
Status = Info->ObjDesc->Method.Extra.Implementation (WalkState);
Info->ReturnObject = WalkState->ReturnDesc;
 
/* Cleanup states */
 
AcpiDsScopeStackClear (WalkState);
AcpiPsCleanupScope (&WalkState->ParserState);
AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
AcpiDsDeleteWalkState (WalkState);
goto Cleanup;
}
 
/*
* Start method evaluation with an implicit return of zero. This is done
* for Windows compatibility.
*/
if (AcpiGbl_EnableInterpreterSlack)
{
WalkState->ImplicitReturnObj =
AcpiUtCreateIntegerObject ((UINT64) 0);
if (!WalkState->ImplicitReturnObj)
{
Status = AE_NO_MEMORY;
AcpiDsDeleteWalkState (WalkState);
goto Cleanup;
}
}
 
/* Parse the AML */
 
Status = AcpiPsParseAml (WalkState);
 
/* WalkState was deleted by ParseAml */
 
Cleanup:
AcpiPsDeleteParseTree (Op);
 
/* End optional tracing */
 
AcpiPsStopTrace (Info);
 
/* Take away the extra reference that we gave the parameters above */
 
AcpiPsUpdateParameterList (Info, REF_DECREMENT);
 
/* Exit now if error above */
 
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
/*
* If the method has returned an object, signal this to the caller with
* a control exception code
*/
if (Info->ReturnObject)
{
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n",
Info->ReturnObject));
ACPI_DUMP_STACK_ENTRY (Info->ReturnObject);
 
Status = AE_CTRL_RETURN_VALUE;
}
 
return_ACPI_STATUS (Status);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiPsUpdateParameterList
*
* PARAMETERS: Info - See ACPI_EVALUATE_INFO
* (Used: ParameterType and Parameters)
* Action - Add or Remove reference
*
* RETURN: Status
*
* DESCRIPTION: Update reference count on all method parameter objects
*
******************************************************************************/
 
static void
AcpiPsUpdateParameterList (
ACPI_EVALUATE_INFO *Info,
UINT16 Action)
{
UINT32 i;
 
 
if (Info->Parameters)
{
/* Update reference count for each parameter */
 
for (i = 0; Info->Parameters[i]; i++)
{
/* Ignore errors, just do them all */
 
(void) AcpiUtUpdateObjectReference (Info->Parameters[i], Action);
}
}
}