asloperands.c revision 199767f8919635c4928607450d9e0abb932109ce
/******************************************************************************
*
* Module Name: asloperands - AML operand processing
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2015, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#include "aslcompiler.y.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("asloperands")
/* Local prototypes */
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
/*******************************************************************************
*
* FUNCTION: OpnDoMutex
*
* PARAMETERS: Op - The parent parse node
*
* RETURN: None
*
* DESCRIPTION: Construct the operands for the MUTEX ASL keyword.
*
******************************************************************************/
static void
{
{
}
return;
}
/*******************************************************************************
*
* FUNCTION: OpnDoMethod
*
* PARAMETERS: Op - The parent parse node
*
* RETURN: None
*
* DESCRIPTION: Construct the operands for the METHOD ASL keyword.
*
******************************************************************************/
static void
{
/* Optional arguments for this opcode with defaults */
UINT8 Serialized = 0;
UINT8 Concurrency = 0;
/* Opcode and package length first */
/* Method name */
/* Num args */
{
}
/* Serialized Flag */
{
}
/* Concurrency value (valid values are 0-15) */
{
/* This is a ByteConstExpr, so eval the constant now */
{
}
}
/* Put the bits in their proper places */
/* Use the last node for the combined flags byte */
/* Save the arg count in the first node */
}
/*******************************************************************************
*
* FUNCTION: OpnDoFieldCommon
*
* PARAMETERS: FieldOp - Node for an ASL field
* Op - The parent parse node
*
* RETURN: None
*
* DESCRIPTION: Construct the AML operands for the various field keywords,
* FIELD, BANKFIELD, INDEXFIELD
*
******************************************************************************/
static void
{
/* AccessType -- not optional, so no need to check for DEFAULT_ARG */
/* Set the access type in the parent (field) node for use later */
/* LockRule -- not optional, so no need to check for DEFAULT_ARG */
/* UpdateRule -- not optional, so no need to check for DEFAULT_ARG */
/*
* Generate the flags byte. The various fields are already
* in the right bit position via translation from the
* keywords by the parser.
*/
/* Use the previous node to be the FieldFlags node */
/* Set the node to RAW_DATA */
/* Process the FieldUnitList */
CurrentBitOffset = 0;
while (Next)
{
/* Save the offset of this field unit */
{
case PARSEOP_ACCESSAS:
/* Nothing additional to do */
break;
case PARSEOP_OFFSET:
/* New offset into the field */
/*
* Examine the specified offset in relation to the
* current offset counter.
*/
if (NewBitOffset < CurrentBitOffset)
{
/*
* Not allowed to specify a backwards offset!
* Issue error and ignore this node.
*/
NULL);
}
else if (NewBitOffset == CurrentBitOffset)
{
/*
* Offset is redundant; we don't need to output an
* offset opcode. Just set these nodes to default
*/
}
else
{
/*
* Valid new offset - set the value to be inserted into the AML
* and update the offset counter.
*/
}
break;
case PARSEOP_NAMESEG:
case PARSEOP_RESERVED_BYTES:
/* Named or reserved field entry */
/* Save the current AccessAs value for error checking later */
switch (AccessType)
{
case AML_FIELD_ACCESS_ANY:
case AML_FIELD_ACCESS_BYTE:
case AML_FIELD_ACCESS_BUFFER:
default:
MinimumLength = 8;
break;
case AML_FIELD_ACCESS_WORD:
MinimumLength = 16;
break;
case AML_FIELD_ACCESS_DWORD:
MinimumLength = 32;
break;
case AML_FIELD_ACCESS_QWORD:
MinimumLength = 64;
break;
}
break;
default:
/* All supported field opcodes must appear above */
break;
}
/* Move on to next entry in the field list */
}
}
/*******************************************************************************
*
* FUNCTION: OpnDoField
*
* PARAMETERS: Op - The parent parse node
*
* RETURN: None
*
* DESCRIPTION: Construct the AML operands for the FIELD ASL keyword
*
******************************************************************************/
static void
{
/* Opcode is parent node */
/* First child is field name */
/* Second child is the AccessType */
}
/*******************************************************************************
*
* FUNCTION: OpnDoIndexField
*
* PARAMETERS: Op - The parent parse node
*
* RETURN: None
*
* DESCRIPTION: Construct the AML operands for the INDEXFIELD ASL keyword
*
******************************************************************************/
static void
{
/* Opcode is parent node */
/* First child is the index name */
/* Second child is the data name */
/* Third child is the AccessType */
}
/*******************************************************************************
*
* FUNCTION: OpnDoBankField
*
* PARAMETERS: Op - The parent parse node
*
* RETURN: None
*
* DESCRIPTION: Construct the AML operands for the BANKFIELD ASL keyword
*
******************************************************************************/
static void
{
/* Opcode is parent node */
/* First child is the region name */
/* Second child is the bank name */
/* Third child is the bank value */
/* Fourth child is the AccessType */
}
/*******************************************************************************
*
* FUNCTION: OpnDoRegion
*
* PARAMETERS: Op - The parent parse node
*
* RETURN: None
*
* DESCRIPTION: Tries to get the length of the region. Can only do this at
* compile time if the length is a constant.
*
******************************************************************************/
static void
{
/* Opcode is parent node */
/* First child is the region name */
/* Second child is the space ID*/
/* Third child is the region offset */
/* Fourth child is the region length */
{
}
else
{
}
}
/*******************************************************************************
*
* FUNCTION: OpnDoBuffer
*
* PARAMETERS: Op - The parent parse node
*
* RETURN: None
*
* DESCRIPTION: Construct the AML operands for the BUFFER ASL keyword. We
* build a single raw byte buffer from the initialization nodes,
* each parse node contains a buffer byte.
*
******************************************************************************/
static void
{
/* Optional arguments for this opcode with defaults */
UINT32 BufferLength = 0;
/* Opcode and package length first */
/* Buffer Length is next, followed by the initializer list */
/*
* If the BufferLength is not an INTEGER or was not specified in the ASL
* (DEFAULT_ARG), it is a TermArg that is
* evaluated at run-time, and we are therefore finished.
*/
{
return;
}
/*
* We want to count the number of items in the initializer list, because if
* it is larger than the buffer length, we will define the buffer size
* to be the size of the initializer list (as per the ACPI Specification)
*/
{
case PARSEOP_INTEGER:
case PARSEOP_BYTECONST:
case PARSEOP_WORDCONST:
case PARSEOP_DWORDCONST:
/* The peer list contains the byte list (if any...) */
while (InitializerOp)
{
/* For buffers, this is a list of raw bytes */
BufferLength++;
}
break;
case PARSEOP_STRING_LITERAL:
/*
* Only one initializer, the string. Buffer must be big enough to hold
* the string plus the null termination byte
*/
break;
case PARSEOP_RAW_DATA:
/* Buffer nodes are already initialized (e.g. Unicode operator) */
return;
case PARSEOP_DEFAULT_ARG:
break;
default:
"Unknown buffer initializer opcode");
printf ("Unknown buffer initializer opcode [%s]\n",
return;
}
/* Check if initializer list is longer than the buffer length */
{
}
if (!BufferLength)
{
/* No length AND no items -- issue notice */
/* But go ahead and put the buffer length of zero into the AML */
}
/*
* Just set the buffer size node to be the buffer length, regardless
* of whether it was previously an integer or a default_arg placeholder
*/
(void) OpcSetOptimalIntegerSize (BufferLengthOp);
/* Remaining nodes are handled via the tree walk */
}
/*******************************************************************************
*
* FUNCTION: OpnDoPackage
*
* PARAMETERS: Op - The parent parse node
*
* RETURN: None
*
* DESCRIPTION: Construct the AML operands for the PACKAGE ASL keyword. NOTE:
* can only be called after constants have been folded, to ensure
* that the PackageLength operand has been fully reduced.
*
******************************************************************************/
void
{
UINT32 PackageLength = 0;
/* Opcode and package length first, followed by the initializer list */
/* Count the number of items in the initializer list */
{
/* The peer list contains the byte list (if any...) */
while (InitializerOp)
{
}
}
/* If package length is a constant, compare to the initializer list */
{
{
/*
* Allow package length to be longer than the initializer
* list -- but if the length of initializer list is nonzero,
* issue a message since this is probably a coding error,
* even though technically legal.
*/
if (PackageLength > 0)
{
}
}
{
/*
* The package length is smaller than the length of the
* initializer list. This is an error as per the ACPI spec.
*/
}
}
{
/*
* This is the case if the PackageLength was left empty - Package()
* The package length becomes the length of the initializer list
*/
/* Set the AML opcode */
}
/* If not a variable-length package, check for a zero package length */
{
if (!PackageLength)
{
/* No length AND no initializer list -- issue a remark */
/* But go ahead and put the buffer length of zero into the AML */
}
}
/*
* If the PackageLength is a constant <= 255, we can change the
* AML opcode from VarPackage to a simple (ACPI 1.0) Package opcode.
*/
{
/*
* Just set the package size node to be the package length, regardless
* of whether it was previously an integer or a default_arg placeholder
*/
}
/* Remaining nodes are handled via the tree walk */
}
/*******************************************************************************
*
* FUNCTION: OpnDoLoadTable
*
* PARAMETERS: Op - The parent parse node
*
* RETURN: None
*
* DESCRIPTION: Construct the AML operands for the LOADTABLE ASL keyword.
*
******************************************************************************/
static void
{
/* Opcode is parent node */
/* First child is the table signature */
/* Second child is the OEM ID*/
/* Third child is the OEM table ID */
/* Fourth child is the RootPath string */
{
}
#ifdef ASL_FUTURE_IMPLEMENTATION
/* TBD: NOT IMPLEMENTED */
/* Fifth child is the [optional] ParameterPathString */
/* Sixth child is the [optional] ParameterData */
{
}
{
}
#endif
}
/*******************************************************************************
*
* FUNCTION: OpnDoDefinitionBlock
*
* PARAMETERS: Op - The parent parse node
*
* RETURN: None
*
* DESCRIPTION: Construct the AML operands for the DEFINITIONBLOCK ASL keyword
*
******************************************************************************/
static void
{
UINT32 i;
char *Filename;
/*
* These nodes get stuffed into the table header. They are special
* cased when the table is written to the output file.
*
* Mark all of these nodes as non-usable so they won't get output
* as AML opcodes!
*/
/* Get AML filename. Use it if non-null */
{
/*
* We will use the AML filename that is embedded in the source file
* for the output filename.
*/
/* Prepend the current directory path */
}
/* Signature */
{
{
"Length is not exactly 4");
}
for (i = 0; i < ACPI_NAME_SIZE; i++)
{
if (!isalnum ((int) Gbl_TableSignature[i]))
{
"Contains non-alphanumeric characters");
}
}
}
/* Revision */
/*
* We used the revision to set the integer width earlier
*/
/* OEMID */
/* OEM TableID */
{
/*
* Convert anything non-alphanumeric to an underscore. This
* allows us to use the TableID to generate unique C symbols.
*/
for (i = 0; i < Length; i++)
{
if (!isalnum ((int) Gbl_TableId[i]))
{
Gbl_TableId[i] = '_';
}
}
}
/* OEM Revision */
}
/*******************************************************************************
*
* FUNCTION: UtGetArg
*
* 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 (peer)
*
******************************************************************************/
UtGetArg (
{
/* Get the requested argument object */
{
Argn--;
}
return (Arg);
}
/*******************************************************************************
*
* FUNCTION: OpnAttachNameToNode
*
* PARAMETERS: Op - The parent parse node
*
* RETURN: None
*
* argument list and attach it to the parent node so that we
* can get to it quickly later.
*
******************************************************************************/
static void
{
{
}
{
case AML_DATA_REGION_OP:
case AML_DEVICE_OP:
case AML_EVENT_OP:
case AML_METHOD_OP:
case AML_MUTEX_OP:
case AML_REGION_OP:
case AML_POWER_RES_OP:
case AML_PROCESSOR_OP:
case AML_THERMAL_ZONE_OP:
case AML_NAME_OP:
case AML_SCOPE_OP:
break;
case AML_ALIAS_OP:
break;
case AML_CREATE_BIT_FIELD_OP:
case AML_CREATE_BYTE_FIELD_OP:
case AML_CREATE_WORD_FIELD_OP:
break;
case AML_CREATE_FIELD_OP:
break;
case AML_BANK_FIELD_OP:
case AML_INDEX_FIELD_OP:
case AML_FIELD_OP:
return;
default:
return;
}
if (Child)
{
}
}
/*******************************************************************************
*
* FUNCTION: OpnGenerateAmlOperands
*
* PARAMETERS: Op - The parent parse node
*
* RETURN: None
*
* DESCRIPTION: Prepare nodes to be output as AML data and operands. The more
* complex AML opcodes require processing of the child nodes
*
******************************************************************************/
void
{
{
return;
}
{
case PARSEOP_DEFINITIONBLOCK:
break;
case PARSEOP_METHOD:
OpnDoMethod (Op);
break;
case PARSEOP_MUTEX:
OpnDoMutex (Op);
break;
case PARSEOP_FIELD:
OpnDoField (Op);
break;
case PARSEOP_INDEXFIELD:
break;
case PARSEOP_BANKFIELD:
OpnDoBankField (Op);
break;
case PARSEOP_BUFFER:
OpnDoBuffer (Op);
break;
case PARSEOP_LOADTABLE:
OpnDoLoadTable (Op);
break;
case PARSEOP_OPERATIONREGION:
OpnDoRegion (Op);
break;
case PARSEOP_RESOURCETEMPLATE:
break;
case PARSEOP_NAMESEG:
case PARSEOP_NAMESTRING:
case PARSEOP_METHODCALL:
case PARSEOP_STRING_LITERAL:
break;
default:
break;
}
/* TBD: move */
}