psargs.c revision 27f7c58306b55fe9e0cfd2934039be1729b505e9
/******************************************************************************
*
* Module Name: psargs - Parse AML opcode arguments
* $Revision: 1.91 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
#define __PSARGS_C__
#include "acpi.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
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.
* Note: Largest package length is 28 bits, from ACPI specification
*
******************************************************************************/
static UINT32
{
UINT32 PackageLength = 0;
/*
* Byte 0 bits [6:7] contain the number of additional bytes
* used to encode the package length, either 0,1,2, or 3
*/
/* 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]
*/
ByteCount--;
}
/* Byte 0 is a special case, either bits [0:3] or [0:5] are used */
}
/*******************************************************************************
*
* 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 *
{
/* Function below updates 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 *
{
/* Point past any namestring prefix characters (backslash or carat) */
while (AcpiPsIsPrefixChar (*End))
{
End++;
}
/* Decode the path prefix character */
switch (*End)
{
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, count in next byte */
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.
* 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.
*
******************************************************************************/
{
char *Path;
/* Null path case is allowed, just exit */
if (!Path)
{
}
/* Setup search scope info */
if (Node)
{
}
/*
* Lookup the name in the internal namespace. 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)
*/
/*
* If this name is a control method invocation, we must
* setup the method call
*/
if (ACPI_SUCCESS (Status) &&
{
/* This name is actually a control method invocation */
if (!NameOp)
{
}
/* Change Arg into a METHOD CALL and attach name to it */
/* Point METHODCALL/NAME to the METHOD Node */
if (!MethodDesc)
{
"Control Method %p has no attached object",
Node));
}
"Control Method - %p Args %X\n",
/* Get the number of arguments to expect */
}
/*
* 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) */
{
}
/* 2) NotFound during a CondRefOf(x) is ok by definition */
{
}
/*
* 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)
*/
{
}
}
/* Final exception check (may have been changed from code above) */
if (ACPI_FAILURE (Status))
{
{
/* Report a control method execution error */
}
}
/* Save the namepath */
}
/*******************************************************************************
*
* 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:
/* Get 1 byte from the AML stream */
Length = 1;
break;
case ARGP_WORDDATA:
/* Get 2 bytes from the AML stream */
Length = 2;
break;
case ARGP_DWORDDATA:
/* Get 4 bytes from the AML stream */
Length = 4;
break;
case ARGP_QWORDDATA:
/* Get 8 bytes from the AML stream */
Length = 8;
break;
case ARGP_CHARLIST:
/* Get a pointer to the string, point past the string */
/* Find the null terminator */
Length = 0;
{
Length++;
}
Length++;
break;
case ARGP_NAME:
case ARGP_NAMESTRING:
default:
}
}
/*******************************************************************************
*
* 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 *
{
/* 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;
}
}