iASL: Add -ts hex output option (emit ASL code).

New option to emit the hex AML code in an ASL buffer.
ACPICA BZ 853.
This commit is contained in:
Robert Moore 2010-04-08 13:44:37 -07:00
parent f633a5f198
commit 8cf3f0b4b9
4 changed files with 108 additions and 3 deletions

View File

@ -177,7 +177,8 @@ AslCompilerSignon (
{
Prefix = "; ";
}
else if (Gbl_HexOutputFlag == HEX_OUTPUT_C)
else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) ||
(Gbl_HexOutputFlag == HEX_OUTPUT_ASL))
{
FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n");
Prefix = " * ";
@ -265,7 +266,8 @@ AslCompilerFileHeader (
{
Prefix = "; ";
}
else if (Gbl_HexOutputFlag == HEX_OUTPUT_C)
else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) ||
(Gbl_HexOutputFlag == HEX_OUTPUT_ASL))
{
Prefix = " * ";
}

View File

@ -200,6 +200,8 @@ ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_WarningLevel, ASL_WARNI
#define HEX_OUTPUT_NONE 0
#define HEX_OUTPUT_C 1
#define HEX_OUTPUT_ASM 2
#define HEX_OUTPUT_ASL 3
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_HexOutputFlag, HEX_OUTPUT_NONE);

View File

@ -198,6 +198,10 @@ static void
LsDoHexOutputAsm (
void);
static void
LsDoHexOutputAsl (
void);
ACPI_STATUS
LsTreeWriteWalk (
ACPI_PARSE_OBJECT *Op,
@ -1337,6 +1341,11 @@ LsDoHexOutput (
LsDoHexOutputAsm ();
break;
case HEX_OUTPUT_ASL:
LsDoHexOutputAsl ();
break;
default:
/* No other output types supported */
break;
@ -1432,6 +1441,94 @@ LsDoHexOutputC (
}
/*******************************************************************************
*
* FUNCTION: LsDoHexOutputAsl
*
* PARAMETERS: None
*
* RETURN: None.
*
* DESCRIPTION: Create the hex output file. This is the same data as the AML
* output file, but formatted into hex/ascii bytes suitable for
* inclusion into a C source file.
*
******************************************************************************/
static void
LsDoHexOutputAsl (
void)
{
UINT8 FileData[HEX_TABLE_LINE_SIZE];
UINT32 LineLength;
UINT32 Offset = 0;
UINT32 AmlFileSize;
UINT32 i;
/* Get AML size, seek back to start */
AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT);
FlPrintFile (ASL_FILE_HEX_OUTPUT, " * ASL source code output\n");
FlPrintFile (ASL_FILE_HEX_OUTPUT, " * AML code block contains 0x%X bytes\n *\n */\n",
AmlFileSize);
FlPrintFile (ASL_FILE_HEX_OUTPUT, " Name (BUF1, Buffer()\n {\n");
while (Offset < AmlFileSize)
{
/* Read enough bytes needed for one output line */
LineLength = fread (FileData, 1, HEX_TABLE_LINE_SIZE,
Gbl_Files[ASL_FILE_AML_OUTPUT].Handle);
if (!LineLength)
{
break;
}
FlPrintFile (ASL_FILE_HEX_OUTPUT, " ");
for (i = 0; i < LineLength; i++)
{
/*
* Print each hex byte.
* Add a comma until the very last byte of the AML file
* (Some C compilers complain about a trailing comma)
*/
FlPrintFile (ASL_FILE_HEX_OUTPUT, "0x%2.2X", FileData[i]);
if ((Offset + i + 1) < AmlFileSize)
{
FlPrintFile (ASL_FILE_HEX_OUTPUT, ",");
}
else
{
FlPrintFile (ASL_FILE_HEX_OUTPUT, " ");
}
}
/* Add fill spaces if needed for last line */
if (LineLength < HEX_TABLE_LINE_SIZE)
{
FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s",
5 * (HEX_TABLE_LINE_SIZE - LineLength), " ");
}
/* Emit the offset and ascii dump for the entire line */
FlPrintFile (ASL_FILE_HEX_OUTPUT, " /* %8.8X", Offset);
LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData);
FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n",
HEX_TABLE_LINE_SIZE - LineLength + 1, " ");
Offset += LineLength;
}
FlPrintFile (ASL_FILE_HEX_OUTPUT, " })\n");
FlCloseFile (ASL_FILE_HEX_OUTPUT);
}
/*******************************************************************************
*
* FUNCTION: LsDoHexOutputAsm

View File

@ -203,7 +203,7 @@ Options (
printf ("\nAML Output Files:\n");
printf (" -s<a|c> Create AML in assembler or C source file (*.asm or *.c)\n");
printf (" -i<a|c> Create assembler or C include file (*.inc or *.h)\n");
printf (" -t<a|c> Create AML in assembler or C hex table (*.hex)\n");
printf (" -t<a|c|s> Create AML in assembler, C, or ASL hex table (*.hex)\n");
printf ("\nAML Code Generation:\n");
printf (" -oa Disable all optimizations (compatibility mode)\n");
@ -741,6 +741,10 @@ AslDoOptions (
Gbl_HexOutputFlag = HEX_OUTPUT_C;
break;
case 's':
Gbl_HexOutputFlag = HEX_OUTPUT_ASL;
break;
default:
printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
return (-1);