asllistsup.c revision 199767f8919635c4928607450d9e0abb932109ce
/******************************************************************************
*
* Module Name: asllistsup - Listing file support utilities
*
*****************************************************************************/
/*
* 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 ("aslistsup")
/*******************************************************************************
*
* FUNCTION: LsDumpAscii
*
* PARAMETERS: FileId - ID of current listing file
* Count - Number of bytes to convert
* Buffer - Buffer of bytes to convert
*
* RETURN: None
*
* DESCRIPTION: Convert hex bytes to ascii
*
******************************************************************************/
void
{
UINT32 i;
for (i = 0; i < Count; i++)
{
{
}
else
{
/* Not a printable character, just put out a dot */
}
}
}
/*******************************************************************************
*
* FUNCTION: LsDumpAsciiInComment
*
* PARAMETERS: FileId - ID of current listing file
* Count - Number of bytes to convert
* Buffer - Buffer of bytes to convert
*
* RETURN: None
*
* DESCRIPTION: Convert hex bytes to ascii
*
******************************************************************************/
void
{
UINT32 i;
for (i = 0; i < Count; i++)
{
{
/* Handle embedded C comment sequences */
{
/* Insert a space to break the sequence */
}
}
else
{
/* Not a printable character, just put out a dot */
}
}
}
/*******************************************************************************
*
* FUNCTION: LsCheckException
*
* PARAMETERS: LineNumber - Current logical (cumulative) line #
* FileId - ID of output listing file
*
* RETURN: None
*
* DESCRIPTION: Check if there is an exception for this line, and if there is,
* put it in the listing immediately. Handles multiple errors
* per line. Gbl_NextError points to the next error in the
*
******************************************************************************/
void
{
if ((!Gbl_NextError) ||
{
return;
}
/* Handle multiple errors per line */
if (FileId == ASL_FILE_LISTING_OUTPUT)
{
while (Gbl_NextError &&
{
}
}
}
/*******************************************************************************
*
* FUNCTION: LsWriteListingHexBytes
*
* PARAMETERS: Buffer - AML code buffer
* Length - Number of AML bytes to write
* FileId - ID of current listing file.
*
* RETURN: None
*
* DESCRIPTION: Write the contents of the AML buffer to the listing file via
* the listing buffer. The listing buffer is flushed every 16
* AML bytes.
*
******************************************************************************/
void
{
UINT32 i;
/* Transfer all requested bytes */
for (i = 0; i < Length; i++)
{
/* Print line header when buffer is empty */
if (Gbl_CurrentHexColumn == 0)
{
if (Gbl_HasIncludeFiles)
{
}
switch (FileId)
{
case ASL_FILE_LISTING_OUTPUT:
break;
break;
case ASL_FILE_C_SOURCE_OUTPUT:
break;
default:
/* No other types supported */
return;
}
}
/* Transfer AML byte and update counts */
/* Flush buffer when it is full */
{
}
}
}
/*******************************************************************************
*
* FUNCTION: LsWriteSourceLines
*
* PARAMETERS: ToLineNumber -
* ToLogicalLineNumber - Write up to this source line number
* FileId - ID of current listing file
*
* RETURN: None
*
* DESCRIPTION: Read then write source lines to the listing file until we have
* reached the specified logical (cumulative) line number. This
* automatically echos out comment blocks and other non-AML
* generating text until we get to the actual AML-generating line
* of ASL code specified by the logical line number.
*
******************************************************************************/
void
{
/* Nothing to do for these file types */
if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
{
return;
}
/* Flush any hex bytes remaining from the last opcode */
/* Read lines and write them as long as we are not caught up */
if (Gbl_SourceLine < Gbl_CurrentLine)
{
/*
* If we just completed writing some AML hex bytes, output a linefeed
* to add some whitespace for readability.
*/
{
}
if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
{
}
/* Write one line at a time until we have reached the target line # */
while ((Gbl_SourceLine < Gbl_CurrentLine) &&
{ ; }
if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
{
}
}
}
/*******************************************************************************
*
* FUNCTION: LsWriteOneSourceLine
*
* PARAMETERS: FileId - ID of current listing file
*
* RETURN: FALSE on EOF (input source file), TRUE otherwise
*
* DESCRIPTION: Read one line from the input source file and echo it to the
* listing file, prefixed with the line number, and if the source
* file contains include files, prefixed with the current filename
*
******************************************************************************/
{
/* Ignore lines that are completely blank (but count the line above) */
{
return (0);
}
if (FileByte == '\n')
{
return (1);
}
/*
* This is a non-empty line, we will print the entire line with
* the line number and possibly other prefixes and transforms.
*/
/* Line prefixes for special files, C and ASM output */
if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
{
}
if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
{
}
if (Gbl_HasIncludeFiles)
{
/*
* This file contains "include" statements, print the current
* filename and line number within the current file
*/
}
else
{
/* No include files, just print the line number */
}
/* Read the rest of this line (up to a newline or EOF) */
do
{
if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
{
if (FileByte == '/')
{
FileByte = '*';
}
}
/* Split long input lines for readability in the listing */
Column++;
if (Column >= 128)
{
if (!ProcessLongLine)
{
if ((FileByte != '}') &&
(FileByte != '{'))
{
goto WriteByte;
}
}
if (FileByte == '{')
{
StartOfLine = TRUE;
Index += 4;
continue;
}
else if (FileByte == '}')
{
if (!StartOfLine)
{
}
StartOfLine = TRUE;
Index -= 4;
continue;
}
{
continue;
}
else if (StartOfLine)
{
StartOfLine = FALSE;
}
if (FileByte == '\n')
{
/*
* This line has been completed.
* Check if an error occurred on this source line during the compile.
* If so, we print the error message after the source line.
*/
return (1);
}
}
else
{
if (FileByte == '\n')
{
/*
* This line has been completed.
* Check if an error occurred on this source line during the compile.
* If so, we print the error message after the source line.
*/
return (1);
}
}
/* EOF on the input file was reached */
return (0);
}
/*******************************************************************************
*
* FUNCTION: LsFlushListingBuffer
*
* PARAMETERS: FileId - ID of the listing file
*
* RETURN: None
*
* DESCRIPTION: Flush out the current contents of the 16-byte hex AML code
* buffer. Usually called at the termination of a single line
* of source code or when the buffer is full.
*
******************************************************************************/
void
{
UINT32 i;
if (Gbl_CurrentHexColumn == 0)
{
return;
}
/* Write the hex bytes */
switch (FileId)
{
case ASL_FILE_LISTING_OUTPUT:
for (i = 0; i < Gbl_CurrentHexColumn; i++)
{
}
{
}
/* Write the ASCII character associated with each of the bytes */
break;
for (i = 0; i < Gbl_CurrentHexColumn; i++)
{
if (i > 0)
{
}
}
{
}
/* Write the ASCII character associated with each of the bytes */
break;
case ASL_FILE_C_SOURCE_OUTPUT:
for (i = 0; i < Gbl_CurrentHexColumn; i++)
{
}
/* Pad hex output with spaces if line is shorter than max line size */
{
}
/* AML offset for the start of the line */
/* Write the ASCII character associated with each of the bytes */
break;
default:
/* No other types supported */
return;
}
Gbl_CurrentHexColumn = 0;
}
/*******************************************************************************
*
* FUNCTION: LsPushNode
*
* PARAMETERS: Filename - Pointer to the include filename
*
* RETURN: None
*
* stack enables tracking of include files (infinitely nested)
* and resumption of the listing of the parent file when the
* include file is finished.
*
******************************************************************************/
void
char *Filename)
{
/* Create a new node */
/* Initialize */
Lnode->LineNumber = 0;
/* Link (push) */
}
/*******************************************************************************
*
* FUNCTION: LsPopNode
*
* PARAMETERS: None
*
* RETURN: List head after current head is popped off
*
* DESCRIPTION: Pop the current head of the list, free it, and return the
* next node on the stack (the new current node).
*
******************************************************************************/
void)
{
/* Just grab the node at the head of the list */
if ((!Lnode) ||
{
"Could not pop empty listing stack");
return (Gbl_ListingNode);
}
/* New "Current" node is the new head */
return (Gbl_ListingNode);
}