summaryrefslogtreecommitdiff
path: root/source/compiler/asllisting.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/compiler/asllisting.c')
-rw-r--r--source/compiler/asllisting.c445
1 files changed, 47 insertions, 398 deletions
diff --git a/source/compiler/asllisting.c b/source/compiler/asllisting.c
index b70bcf8ab8d5..5bf50e2d5371 100644
--- a/source/compiler/asllisting.c
+++ b/source/compiler/asllisting.c
@@ -59,12 +59,6 @@ LsDumpAscii (
UINT32 Count,
UINT8 *Buffer);
-static void
-LsDumpAsciiInComment (
- UINT32 FileId,
- UINT32 Count,
- UINT8 *Buffer);
-
static ACPI_STATUS
LsAmlListingWalk (
ACPI_PARSE_OBJECT *Op,
@@ -117,27 +111,55 @@ LsWriteNodeToListing (
ACPI_PARSE_OBJECT *Op,
UINT32 FileId);
-static void
-LsDoHexOutputC (
- void);
-
-static void
-LsDoHexOutputAsm (
- void);
-
-static void
-LsDoHexOutputAsl (
- void);
-
static ACPI_STATUS
LsTreeWriteWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context);
-static UINT32
-LsReadAmlOutputFile (
- UINT8 *Buffer);
+
+/*******************************************************************************
+ *
+ * FUNCTION: LsDoListings
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Generate all requested listing files.
+ *
+ ******************************************************************************/
+
+void
+LsDoListings (
+ void)
+{
+
+ if (Gbl_C_OutputFlag)
+ {
+ LsGenerateListing (ASL_FILE_C_SOURCE_OUTPUT);
+ }
+
+ if (Gbl_ListingFlag)
+ {
+ LsGenerateListing (ASL_FILE_LISTING_OUTPUT);
+ }
+
+ if (Gbl_AsmOutputFlag)
+ {
+ LsGenerateListing (ASL_FILE_ASM_SOURCE_OUTPUT);
+ }
+
+ if (Gbl_C_IncludeOutputFlag)
+ {
+ LsGenerateListing (ASL_FILE_C_INCLUDE_OUTPUT);
+ }
+
+ if (Gbl_AsmIncludeOutputFlag)
+ {
+ LsGenerateListing (ASL_FILE_ASM_INCLUDE_OUTPUT);
+ }
+}
/*******************************************************************************
@@ -147,7 +169,7 @@ LsReadAmlOutputFile (
* PARAMETERS: ASL_WALK_CALLBACK
*
*
- * RETURN: None.
+ * RETURN: None
*
* DESCRIPTION: Dump entire parse tree, for compiler debug only
*
@@ -196,7 +218,7 @@ LsDumpParseTree (
* Count - Number of bytes to convert
* Buffer - Buffer of bytes to convert
*
- * RETURN: None.
+ * RETURN: None
*
* DESCRIPTION: Convert hex bytes to ascii
*
@@ -239,13 +261,13 @@ LsDumpAscii (
* Count - Number of bytes to convert
* Buffer - Buffer of bytes to convert
*
- * RETURN: None.
+ * RETURN: None
*
* DESCRIPTION: Convert hex bytes to ascii
*
******************************************************************************/
-static void
+void
LsDumpAsciiInComment (
UINT32 FileId,
UINT32 Count,
@@ -374,50 +396,6 @@ LsGenerateListing (
/*******************************************************************************
*
- * FUNCTION: LsDoListings
- *
- * PARAMETERS: None.
- *
- * RETURN: None
- *
- * DESCRIPTION: Generate all requested listing files.
- *
- ******************************************************************************/
-
-void
-LsDoListings (
- void)
-{
-
- if (Gbl_C_OutputFlag)
- {
- LsGenerateListing (ASL_FILE_C_SOURCE_OUTPUT);
- }
-
- if (Gbl_ListingFlag)
- {
- LsGenerateListing (ASL_FILE_LISTING_OUTPUT);
- }
-
- if (Gbl_AsmOutputFlag)
- {
- LsGenerateListing (ASL_FILE_ASM_SOURCE_OUTPUT);
- }
-
- if (Gbl_C_IncludeOutputFlag)
- {
- LsGenerateListing (ASL_FILE_C_INCLUDE_OUTPUT);
- }
-
- if (Gbl_AsmIncludeOutputFlag)
- {
- LsGenerateListing (ASL_FILE_ASM_INCLUDE_OUTPUT);
- }
-}
-
-
-/*******************************************************************************
- *
* FUNCTION: LsPushNode
*
* PARAMETERS: Filename - Pointer to the include filename
@@ -1241,332 +1219,3 @@ LsWriteNodeToListing (
break;
}
}
-
-
-/*******************************************************************************
- *
- * FUNCTION: LsDoHexOutput
- *
- * PARAMETERS: None
- *
- * RETURN: None.
- *
- * DESCRIPTION: Create the hex output file.
- *
- ******************************************************************************/
-
-void
-LsDoHexOutput (
- void)
-{
-
- switch (Gbl_HexOutputFlag)
- {
- case HEX_OUTPUT_C:
-
- LsDoHexOutputC ();
- break;
-
- case HEX_OUTPUT_ASM:
-
- LsDoHexOutputAsm ();
- break;
-
- case HEX_OUTPUT_ASL:
-
- LsDoHexOutputAsl ();
- break;
-
- default:
- /* No other output types supported */
- break;
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: LsReadAmlOutputFile
- *
- * PARAMETERS: Buffer - Where to return data
- *
- * RETURN: None.
- *
- * DESCRIPTION: Read a line of the AML output prior to formatting the data
- *
- ******************************************************************************/
-
-static UINT32
-LsReadAmlOutputFile (
- UINT8 *Buffer)
-{
- UINT32 Actual;
-
-
- Actual = fread (Buffer, 1, HEX_TABLE_LINE_SIZE,
- Gbl_Files[ASL_FILE_AML_OUTPUT].Handle);
-
- if (ferror (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle))
- {
- FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ);
- AslAbort ();
- }
-
- return (Actual);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: LsDoHexOutputC
- *
- * 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
-LsDoHexOutputC (
- 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);
- FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
-
- 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");
-
- while (Offset < AmlFileSize)
- {
- /* Read enough bytes needed for one output line */
-
- LineLength = LsReadAmlOutputFile (FileData);
- 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");
-}
-
-
-/*******************************************************************************
- *
- * 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);
- FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
-
- 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 = LsReadAmlOutputFile (FileData);
- 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");
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: LsDoHexOutputAsm
- *
- * 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 ASM source file.
- *
- ******************************************************************************/
-
-static void
-LsDoHexOutputAsm (
- 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);
- 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);
-
- while (Offset < AmlFileSize)
- {
- /* Read enough bytes needed for one output line */
-
- LineLength = LsReadAmlOutputFile (FileData);
- if (!LineLength)
- {
- break;
- }
-
- FlPrintFile (ASL_FILE_HEX_OUTPUT, " db ");
-
- for (i = 0; i < LineLength; i++)
- {
- /*
- * 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, ",");
- }
- }
-
- 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, "\n");
-
- Offset += LineLength;
- }
-
- FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n");
-}