aslcodegen.c revision 199767f8919635c4928607450d9e0abb932109ce
/******************************************************************************
*
* Module Name: aslcodegen - AML code generation
*
*****************************************************************************/
/*
* 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 ("aslcodegen")
/* Local prototypes */
static ACPI_STATUS
void *Context);
static void
void *Buffer,
static void
static void
static void
void);
static void
/*******************************************************************************
*
* FUNCTION: CgGenerateAmlOutput
*
* PARAMETERS: None.
*
* RETURN: None
*
* DESCRIPTION: Generate AML code. Currently generates the listing file
* simultaneously.
*
******************************************************************************/
void
void)
{
/* Generate the AML output file */
Gbl_SourceLine = 0;
"%*s Value P_Op A_Op OpLen PByts Len SubLen PSubLen OpPtr"
" Parent Child Next Flags AcTyp Final Col L# EL# LL# ELL#\n",
76, " ");
CgCloseTable ();
}
/*******************************************************************************
*
* FUNCTION: CgAmlWriteWalk
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Parse tree walk to generate the AML code.
*
******************************************************************************/
static ACPI_STATUS
void *Context)
{
/*
* Print header at level 0. Alignment assumes 32-bit pointers
*/
if (!Level)
{
"Final parse tree used for AML output:\n");
"%*s Value P_Op A_Op OpLen PByts Len SubLen PSubLen OpPtr"
" Parent Child Next Flags AcTyp Final Col L# EL# LL# ELL#\n",
76, " ");
}
/* Debug output */
{
}
else
{
}
"%08X %04X %04X %01X %04X %04X %04X %04X "
"%08X %08X %08X %08X %08X %08X %04X %02d %02d %02d %02d %02d\n",
/* 9 */ Op,
/* Generate the AML for this node */
CgWriteNode (Op);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: CgLocalWriteAmlData
*
* PARAMETERS: Op - Current parse op
* Buffer - Buffer to write
* Length - Size of data in buffer
*
* RETURN: None
*
* DESCRIPTION: Write a buffer of AML data to the AML output file.
*
******************************************************************************/
static void
void *Buffer,
{
/* Write the raw data to the AML file */
/* Update the final AML length for this node (used for listings) */
if (Op)
{
}
}
/*******************************************************************************
*
* FUNCTION: CgWriteAmlOpcode
*
* PARAMETERS: Op - Parse node with an AML opcode
*
* RETURN: None.
*
* DESCRIPTION: Write the AML opcode corresponding to a parse node.
*
******************************************************************************/
static void
{
UINT32 i;
union {
} Aml;
union {
} PkgLen;
/* We expect some DEFAULT_ARGs, just ignore them */
{
return;
}
{
case AML_UNASSIGNED_OPCODE:
/* These opcodes should not get here */
printf ("Found a node with an unassigned AML opcode\n");
return;
case AML_INT_RESERVEDFIELD_OP:
/* Special opcodes for within a field definition */
break;
case AML_INT_ACCESSFIELD_OP:
break;
case AML_INT_CONNECTION_OP:
break;
default:
break;
}
{
case AML_PACKAGE_LENGTH:
/* Value is the length to be encoded (Used in field definitions) */
break;
default:
/* Check for two-byte opcode */
{
/* Write the high byte first */
}
/* Subtreelength doesn't include length of package length bytes */
break;
}
/* Does this opcode have an associated "PackageLength" field? */
{
{
/* Simplest case -- no bytes to follow, just write the count */
}
{
/*
* Encode the "bytes to follow" in the first byte, top two bits.
* The low-order nybble of the length is in the bottom 4 bits
*/
PkgLenFirstByte = (UINT8)
/*
* Shift the length over by the 4 bits we just stuffed
* in the first byte
*/
/* Now we can write the remaining bytes - either 1, 2, or 3 bytes */
{
}
}
}
{
case AML_BYTE_OP:
break;
case AML_WORD_OP:
break;
case AML_DWORD_OP:
break;
case AML_QWORD_OP:
break;
case AML_STRING_OP:
break;
default:
/* All data opcodes must appear above */
break;
}
}
/*******************************************************************************
*
* FUNCTION: CgWriteTableHeader
*
* PARAMETERS: Op - The DEFINITIONBLOCK node
*
* RETURN: None
*
* DESCRIPTION: Write a table header corresponding to the DEFINITIONBLOCK
*
******************************************************************************/
static void
{
/* AML filename */
/* Signature */
/* Revision */
/* Command-line Revision override */
if (Gbl_RevisionOverride)
{
}
/* OEMID */
/* OEM TableID */
/* OEM Revision */
/* Compiler ID */
/* Compiler version */
/* Table length. Checksum zero for now, will rewrite later */
TableHeader.Checksum = 0;
}
/*******************************************************************************
*
* FUNCTION: CgCloseTable
*
* PARAMETERS: None.
*
* RETURN: None.
*
* DESCRIPTION: Complete the ACPI table by calculating the checksum and
* re-writing the header.
*
******************************************************************************/
static void
void)
{
signed char Sum;
Sum = 0;
/* Calculate the checksum over the entire file */
{
}
/* Re-write the table header with the checksum */
}
/*******************************************************************************
*
* FUNCTION: CgWriteNode
*
* PARAMETERS: Op - Parse node to write.
*
* RETURN: None.
*
* DESCRIPTION: Write the AML that corresponds to a parse node.
*
******************************************************************************/
static void
{
/* Always check for DEFAULT_ARG and other "Noop" nodes */
/* TBD: this may not be the best place for this check */
{
return;
}
{
case AML_RAW_DATA_BYTE:
case AML_RAW_DATA_WORD:
case AML_RAW_DATA_DWORD:
case AML_RAW_DATA_QWORD:
return;
case AML_RAW_DATA_BUFFER:
return;
case AML_RAW_DATA_CHAIN:
while (Rnode)
{
}
return;
default:
/* Internal data opcodes must all appear above */
break;
}
{
case PARSEOP_DEFAULT_ARG:
break;
case PARSEOP_DEFINITIONBLOCK:
break;
case PARSEOP_NAMESEG:
case PARSEOP_NAMESTRING:
case PARSEOP_METHODCALL:
break;
default:
break;
}
}