psargs.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/******************************************************************************
*
* Module Name: psargs - Parse AML opcode arguments
* $Revision: 80 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
#define __PSARGS_C__
#include "acpi.h"
#include "acparser.h"
#include "amlcode.h"
#include "acnamesp.h"
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("psargs")
/* Local prototypes */
static UINT32
static ACPI_PARSE_OBJECT *
/*******************************************************************************
*
* 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
*
******************************************************************************/
static UINT32
{
ACPI_FUNCTION_TRACE ("PsGetNextPackageLength");
ParserState->Aml++;
{
case 0: /* 1-byte encoding (bits 0-5) */
break;
case 1: /* 2-byte encoding (next byte + bits 0-3) */
(EncodedLength & 0x0F));
ParserState->Aml++;
break;
case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */
(EncodedLength & 0x0F));
break;
case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */
(EncodedLength & 0x0F));
break;
default:
/* Can't get here, only 2 bits / 4 cases */
break;
}
}
/*******************************************************************************
*
* 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 *
{
ACPI_FUNCTION_TRACE ("PsGetNextPackageEnd");
/* Function below changes ParserState->Aml */
}
/*******************************************************************************
*
* 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 *
{
ACPI_FUNCTION_TRACE ("PsGetNextNamestring");
/* Handle multiple prefix characters */
{
/* Include prefix '\\' or '^' */
End++;
}
/* Decode the path */
{
case 0:
/* NullName */
{
}
End++;
break;
case AML_DUAL_NAME_PREFIX:
/* Two name segments */
break;
case AML_MULTI_NAME_PREFIX_OP:
/* Multiple name segments, 4 chars each */
break;
default:
/* Single name segment */
End += ACPI_NAME_SIZE;
break;
}
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.
* MethodCall - 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.
*
******************************************************************************/
{
char *Path;
ACPI_FUNCTION_TRACE ("PsGetNextNamepath");
/* Null path case is allowed */
if (Path)
{
/*
* Lookup the name in the internal namespace
*/
if (Node)
{
}
/*
* Lookup object. 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 upsearch)
*/
{
{
/* This name is actually a control method invocation */
"Control Method - %p Desc %p Path=%p\n",
if (!NameOp)
{
}
/* Change arg into a METHOD CALL and attach name to it */
/* Point METHODCALL/NAME to the METHOD Node */
if (!MethodDesc)
{
"PsGetNextNamepath: Control Method %p has no attached object\n",
Node));
}
"Control Method - %p Args %X\n",
/* Get the number of arguments to expect */
}
/*
* Else this is normal named object reference.
* Just init the NAMEPATH object with the pathname.
* (See code below)
*/
}
if (ACPI_FAILURE (Status))
{
/*
* 1) Any error other than NOT_FOUND is always severe
* 2) NOT_FOUND is only important if we are executing a method.
* 3) If executing a CondRefOf opcode, NOT_FOUND is ok.
*/
(Status == AE_NOT_FOUND) &&
(Status != AE_NOT_FOUND))
{
AcpiOsPrintf ("SearchNode %p StartNode %p ReturnNode %p\n",
}
else
{
/*
* We got a NOT_FOUND during table load or we encountered
* a CondRefOf(x) where the target does not exist.
* Either case is ok
*/
}
}
}
/*
* Just initialize the Op with the pathname.
*/
}
/*******************************************************************************
*
* 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
{
switch (ArgType)
{
case ARGP_BYTEDATA:
ParserState->Aml++;
break;
case ARGP_WORDDATA:
/* Get 2 bytes from the AML stream */
break;
case ARGP_DWORDDATA:
/* Get 4 bytes from the AML stream */
break;
case ARGP_QWORDDATA:
/* Get 8 bytes from the AML stream */
break;
case ARGP_CHARLIST:
{
ParserState->Aml++;
}
ParserState->Aml++;
break;
case ARGP_NAME:
case ARGP_NAMESTRING:
break;
default:
break;
}
}
/*******************************************************************************
*
* 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 *
{
ACPI_FUNCTION_TRACE ("PsGetNextField");
/* Determine field type */
{
default:
break;
case 0x00:
ParserState->Aml++;
break;
case 0x01:
ParserState->Aml++;
break;
}
/* Allocate a new field op */
if (!Field)
{
return_PTR (NULL);
}
/* Decode the field type */
switch (Opcode)
{
case AML_INT_NAMEDFIELD_OP:
/* Get the 4-character name */
/* Get the length which is encoded as a package length */
break;
case AML_INT_RESERVEDFIELD_OP:
/* Get the length which is encoded as a package length */
break;
case AML_INT_ACCESSFIELD_OP:
/*
* Get AccessType and AccessAttrib and merge into the field Op
* AccessType is first operand, AccessAttribute is second
*/
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)
*
******************************************************************************/
{
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 */
if (!Arg)
{
}
break;
case ARGP_PKGLENGTH:
/* Package length, nothing returned */
break;
case ARGP_FIELDLIST:
{
/* Non-empty list */
{
if (!Field)
{
}
if (Prev)
{
}
else
{
}
}
/* Skip to End of byte data */
}
break;
case ARGP_BYTELIST:
{
/* Non-empty list */
if (!Arg)
{
}
/* Fill in bytelist data */
/* Skip to End of byte data */
}
break;
case ARGP_TARGET:
case ARGP_SUPERNAME:
case ARGP_SIMPLENAME:
if (Subop == 0 ||
AcpiPsIsLeadingChar (Subop) ||
{
/* NullName or NameString */
if (!Arg)
{
}
}
else
{
/* Single complex argument, nothing returned */
}
break;
case ARGP_DATAOBJ:
case ARGP_TERMARG:
/* Single complex argument, nothing returned */
break;
case ARGP_DATAOBJLIST:
case ARGP_TERMLIST:
case ARGP_OBJLIST:
{
/* Non-empty list of variable arguments, nothing returned */
}
break;
default:
break;
}
}