diff options
author | Jung-uk Kim <jkim@FreeBSD.org> | 2013-01-17 23:56:43 +0000 |
---|---|---|
committer | Jung-uk Kim <jkim@FreeBSD.org> | 2013-01-17 23:56:43 +0000 |
commit | efcc2a30547c400649a351e85e6cd97dab8f3817 (patch) | |
tree | a7cdf321edb5a438878660c0df9e9bf8a70038e1 /sys/contrib/dev/acpica/compiler/asllisting.c | |
parent | 70ca194a4c1c64dc90c9fd546d333072a0f9f477 (diff) | |
parent | b28e481ae9b051dab150e9b5a89730cdc1103a9c (diff) | |
download | src-efcc2a30547c400649a351e85e6cd97dab8f3817.tar.gz src-efcc2a30547c400649a351e85e6cd97dab8f3817.zip |
Merge ACPICA 20130117.
Notes
Notes:
svn path=/head/; revision=245582
Diffstat (limited to 'sys/contrib/dev/acpica/compiler/asllisting.c')
-rw-r--r-- | sys/contrib/dev/acpica/compiler/asllisting.c | 486 |
1 files changed, 80 insertions, 406 deletions
diff --git a/sys/contrib/dev/acpica/compiler/asllisting.c b/sys/contrib/dev/acpica/compiler/asllisting.c index 9a85fd790a3d..49c43fb8c094 100644 --- a/sys/contrib/dev/acpica/compiler/asllisting.c +++ b/sys/contrib/dev/acpica/compiler/asllisting.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2012, Intel Corp. + * Copyright (C) 2000 - 2013, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -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,57 @@ 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); +#define ASL_LISTING_LINE_PREFIX ": " + + +/******************************************************************************* + * + * 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 +171,7 @@ LsReadAmlOutputFile ( * PARAMETERS: ASL_WALK_CALLBACK * * - * RETURN: None. + * RETURN: None * * DESCRIPTION: Dump entire parse tree, for compiler debug only * @@ -196,7 +220,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 +263,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 +398,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 @@ -687,7 +667,8 @@ LsWriteListingHexBytes ( { case ASL_FILE_LISTING_OUTPUT: - FlPrintFile (FileId, "%8.8X....", Gbl_CurrentAmlOffset); + FlPrintFile (FileId, "%8.8X%s", Gbl_CurrentAmlOffset, + ASL_LISTING_LINE_PREFIX); break; case ASL_FILE_ASM_SOURCE_OUTPUT: @@ -747,6 +728,24 @@ LsWriteOneSourceLine ( Gbl_SourceLine++; Gbl_ListingNode->LineNumber++; + /* Ignore lines that are completely blank (but count the line above) */ + + if (FlReadFile (ASL_FILE_SOURCE_OUTPUT, &FileByte, 1) != AE_OK) + { + 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) { FlPrintFile (FileId, " *"); @@ -762,19 +761,21 @@ LsWriteOneSourceLine ( * This file contains "include" statements, print the current * filename and line number within the current file */ - FlPrintFile (FileId, "%12s %5d....", - Gbl_ListingNode->Filename, Gbl_ListingNode->LineNumber); + FlPrintFile (FileId, "%12s %5d%s", + Gbl_ListingNode->Filename, Gbl_ListingNode->LineNumber, + ASL_LISTING_LINE_PREFIX); } else { /* No include files, just print the line number */ - FlPrintFile (FileId, "%8d....", Gbl_SourceLine); + FlPrintFile (FileId, "%8u%s", Gbl_SourceLine, + ASL_LISTING_LINE_PREFIX); } - /* Read one line (up to a newline or EOF) */ + /* Read the rest of this line (up to a newline or EOF) */ - while (FlReadFile (ASL_FILE_SOURCE_OUTPUT, &FileByte, 1) == AE_OK) + do { if (FileId == ASL_FILE_C_SOURCE_OUTPUT) { @@ -788,13 +789,15 @@ LsWriteOneSourceLine ( 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. */ LsCheckException (Gbl_SourceLine, FileId); return (1); } - } + + } while (FlReadFile (ASL_FILE_SOURCE_OUTPUT, &FileByte, 1) == AE_OK); /* EOF on the input file was reached */ @@ -1241,332 +1244,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"); -} |