aboutsummaryrefslogtreecommitdiff
path: root/compiler/asllisting.c
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/asllisting.c')
-rw-r--r--compiler/asllisting.c247
1 files changed, 181 insertions, 66 deletions
diff --git a/compiler/asllisting.c b/compiler/asllisting.c
index c4253c2e115f..93f83ad84279 100644
--- a/compiler/asllisting.c
+++ b/compiler/asllisting.c
@@ -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;
@@ -1362,60 +1371,160 @@ static void
LsDoHexOutputC (
void)
{
- UINT32 j;
- UINT8 FileByte[HEX_TABLE_LINE_SIZE];
- UINT8 Buffer[4];
+ 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, " * C source code output\n *\n */\n");
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, " * C 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, "unsigned char AmlCode[] =\n{\n");
- /* Start at the beginning of the AML file */
+ while (Offset < AmlFileSize)
+ {
+ /* Read enough bytes needed for one output line */
- FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
+ LineLength = fread (FileData, 1, HEX_TABLE_LINE_SIZE,
+ Gbl_Files[ASL_FILE_AML_OUTPUT].Handle);
+ if (!LineLength)
+ {
+ break;
+ }
- /* Process all AML bytes in the AML file */
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, " ");
- j = 0;
- while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte[j], 1) == AE_OK)
- {
- if (j == 0)
+ for (i = 0; i < LineLength; i++)
{
- FlPrintFile (ASL_FILE_HEX_OUTPUT, " ");
+ /*
+ * 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, " ");
+ }
}
- /* Convert each AML byte to hex */
+ /* Add fill spaces if needed for last line */
- UtConvertByteToHex (FileByte[j], Buffer);
- FlWriteFile (ASL_FILE_HEX_OUTPUT, Buffer, 4);
- FlPrintFile (ASL_FILE_HEX_OUTPUT, ",");
+ if (LineLength < HEX_TABLE_LINE_SIZE)
+ {
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s",
+ 5 * (HEX_TABLE_LINE_SIZE - LineLength), " ");
+ }
- /* An occasional linefeed improves readability */
+ /* Emit the offset and ascii dump for the entire line */
- Offset++;
- j++;
+ 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, " ");
- if (j >= HEX_TABLE_LINE_SIZE)
- {
- /* End of line, emit the ascii dump of the entire line */
+ Offset += LineLength;
+ }
- FlPrintFile (ASL_FILE_HEX_OUTPUT,
- " /* %8.8X", Offset - HEX_TABLE_LINE_SIZE);
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, "};\n");
+ FlCloseFile (ASL_FILE_HEX_OUTPUT);
+}
- /* Write the ASCII character associated with each of the bytes */
- LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT,
- HEX_TABLE_LINE_SIZE, FileByte);
- FlPrintFile (ASL_FILE_HEX_OUTPUT, " */\n");
+/*******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
- /* Start new line */
+static void
+LsDoHexOutputAsl (
+ void)
+{
+ UINT8 FileData[HEX_TABLE_LINE_SIZE];
+ UINT32 LineLength;
+ UINT32 Offset = 0;
+ UINT32 AmlFileSize;
+ UINT32 i;
- j = 0;
+
+ /* 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};\n");
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, " })\n");
FlCloseFile (ASL_FILE_HEX_OUTPUT);
}
@@ -1438,58 +1547,64 @@ static void
LsDoHexOutputAsm (
void)
{
- UINT32 j;
- UINT8 FileByte[HEX_TABLE_LINE_SIZE];
- UINT8 Buffer[4];
+ UINT8 FileData[HEX_TABLE_LINE_SIZE];
+ UINT32 LineLength;
UINT32 Offset = 0;
- BOOLEAN DoComma = FALSE;
+ UINT32 AmlFileSize;
+ UINT32 i;
- FlPrintFile (ASL_FILE_HEX_OUTPUT, "; Assembly code source output\n;\n");
+ /* Get AML size, seek back to start */
- /* Start at the beginning of the AML file */
+ AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT);
- FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, "; Assembly code source output\n");
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, "; AML code block contains 0x%X bytes\n;\n",
+ AmlFileSize);
- /* Process all AML bytes in the AML file */
-
- j = 0;
- while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte[j], 1) == AE_OK)
+ while (Offset < AmlFileSize)
{
- if (j == 0)
+ /* 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)
{
- FlPrintFile (ASL_FILE_HEX_OUTPUT, " db ");
+ break;
}
- else if (DoComma)
+
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, " db ");
+
+ for (i = 0; i < LineLength; i++)
{
- FlPrintFile (ASL_FILE_HEX_OUTPUT, ",");
- DoComma = FALSE;
+ /*
+ * Print each hex byte.
+ * Add a comma until the last byte of the line
+ */
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, "0%2.2Xh", FileData[i]);
+ if ((i + 1) < LineLength)
+ {
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, ",");
+ }
}
- /* Convert each AML byte to hex */
-
- UtConvertByteToAsmHex (FileByte[j], Buffer);
- FlWriteFile (ASL_FILE_HEX_OUTPUT, Buffer, 4);
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, " ");
- /* An occasional linefeed improves readability */
+ /* Add fill spaces if needed for last line */
- Offset++;
- j++;
- if (j >= HEX_TABLE_LINE_SIZE)
+ if (LineLength < HEX_TABLE_LINE_SIZE)
{
- FlPrintFile (ASL_FILE_HEX_OUTPUT,
- " ;%8.8X", Offset - HEX_TABLE_LINE_SIZE);
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s",
+ 5 * (HEX_TABLE_LINE_SIZE - LineLength), " ");
+ }
- /* Write the ASCII character associated with each of the bytes */
+ /* Emit the offset and ascii dump for the entire line */
- LsDumpAscii (ASL_FILE_HEX_OUTPUT, HEX_TABLE_LINE_SIZE, FileByte);
- FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n");
- j = 0;
- }
- else
- {
- DoComma = TRUE;
- }
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, " ; %8.8X", Offset);
+ LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData);
+ FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n");
+
+ Offset += LineLength;
}
FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n");