diff options
author | jkim <jkim@FreeBSD.org> | 2013-04-04 21:18:57 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2013-04-04 21:18:57 +0000 |
commit | 4b5fbe0ac6228523722afb80af9d5c8ed2ba5ee8 (patch) | |
tree | 2d060ed4fedfc9aace2e673176570faa8ae1d376 /source/compiler | |
parent | bd5edd68a8fda8df18c688919e100f7f1df5ad6b (diff) | |
download | FreeBSD-src-4b5fbe0ac6228523722afb80af9d5c8ed2ba5ee8.zip FreeBSD-src-4b5fbe0ac6228523722afb80af9d5c8ed2ba5ee8.tar.gz |
Import ACPICA 20130328.
Diffstat (limited to 'source/compiler')
-rw-r--r-- | source/compiler/aslcompile.c | 3 | ||||
-rw-r--r-- | source/compiler/aslcompiler.h | 71 | ||||
-rw-r--r-- | source/compiler/asldefine.h | 6 | ||||
-rw-r--r-- | source/compiler/aslerror.c | 28 | ||||
-rw-r--r-- | source/compiler/aslfiles.c | 21 | ||||
-rw-r--r-- | source/compiler/aslglobal.h | 4 | ||||
-rw-r--r-- | source/compiler/asllisting.c | 844 | ||||
-rw-r--r-- | source/compiler/asllistsup.c | 706 | ||||
-rw-r--r-- | source/compiler/aslmain.c | 8 | ||||
-rw-r--r-- | source/compiler/asloffset.c | 326 | ||||
-rw-r--r-- | source/compiler/aslpredef.c | 266 | ||||
-rw-r--r-- | source/compiler/aslprepkg.c | 26 | ||||
-rw-r--r-- | source/compiler/aslresource.c | 1 | ||||
-rw-r--r-- | source/compiler/asltypes.h | 5 | ||||
-rw-r--r-- | source/compiler/aslwalks.c | 6 |
15 files changed, 1374 insertions, 947 deletions
diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index c752870..73b6732 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -126,6 +126,7 @@ AslCompilerSignon ( break; case ASL_FILE_C_SOURCE_OUTPUT: + case ASL_FILE_C_OFFSET_OUTPUT: case ASL_FILE_C_INCLUDE_OUTPUT: Prefix = " * "; @@ -199,6 +200,7 @@ AslCompilerFileHeader ( break; case ASL_FILE_C_SOURCE_OUTPUT: + case ASL_FILE_C_OFFSET_OUTPUT: case ASL_FILE_C_INCLUDE_OUTPUT: Prefix = " * "; @@ -222,6 +224,7 @@ AslCompilerFileHeader ( switch (FileId) { case ASL_FILE_C_SOURCE_OUTPUT: + case ASL_FILE_C_OFFSET_OUTPUT: case ASL_FILE_C_INCLUDE_OUTPUT: FlPrintFile (FileId, " */\n"); break; diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h index 4f899fc..cfe3ecf 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -350,22 +350,65 @@ LsDoListings ( void); void +LsWriteNodeToAsmListing ( + ACPI_PARSE_OBJECT *Op); + +void +LsWriteNode ( + ACPI_PARSE_OBJECT *Op, + UINT32 FileId); + +void +LsDumpParseTree ( + void); + + +/* + * asllistsup - Listing file support utilities + */ +void +LsDumpAscii ( + UINT32 FileId, + UINT32 Count, + UINT8 *Buffer); + +void LsDumpAsciiInComment ( UINT32 FileId, UINT32 Count, UINT8 *Buffer); void -LsWriteNodeToAsmListing ( - ACPI_PARSE_OBJECT *Op); +LsCheckException ( + UINT32 LineNumber, + UINT32 FileId); void -LsWriteNode ( - ACPI_PARSE_OBJECT *Op, +LsFlushListingBuffer ( UINT32 FileId); void -LsDumpParseTree ( +LsWriteListingHexBytes ( + UINT8 *Buffer, + UINT32 Length, + UINT32 FileId); + +void +LsWriteSourceLines ( + UINT32 ToLineNumber, + UINT32 ToLogicalLineNumber, + UINT32 FileId); + +UINT32 +LsWriteOneSourceLine ( + UINT32 FileId); + +void +LsPushNode ( + char *Filename); + +ASL_LISTING_NODE * +LsPopNode ( void); @@ -388,6 +431,24 @@ OpcAmlConstantWalk ( /* + * asloffset - generate C offset file for BIOS support + */ +ACPI_STATUS +LsAmlOffsetWalk ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +void +LsDoOffsetTableHeader ( + UINT32 FileId); + +void +LsDoOffsetTableFooter ( + UINT32 FileId); + + +/* * aslopcodes - generate AML opcodes */ ACPI_STATUS diff --git a/source/compiler/asldefine.h b/source/compiler/asldefine.h index 75c8fad..76e2e12 100644 --- a/source/compiler/asldefine.h +++ b/source/compiler/asldefine.h @@ -120,6 +120,7 @@ #define FILE_SUFFIX_ASM_INCLUDE "inc" #define FILE_SUFFIX_C_INCLUDE "h" #define FILE_SUFFIX_ASL_CODE "asl" +#define FILE_SUFFIX_C_OFFSET "offset.h" /* Types for input files */ @@ -138,6 +139,11 @@ #define ASL_EOF ACPI_UINT32_MAX +/* Listings */ + +#define ASL_LISTING_LINE_PREFIX ": " + + /* Support for reserved method names */ #define ACPI_VALID_RESERVED_NAME_MAX 0x80000000 diff --git a/source/compiler/aslerror.c b/source/compiler/aslerror.c index 551a2a5..5b3b483 100644 --- a/source/compiler/aslerror.c +++ b/source/compiler/aslerror.c @@ -302,12 +302,25 @@ AePrintException ( } else { - while (RActual && SourceByte && (SourceByte != '\n') && (Total < 256)) + /* Read/write the source line, up to the maximum line length */ + + while (RActual && SourceByte && (SourceByte != '\n')) { - if (fwrite (&SourceByte, 1, 1, OutputFile) != 1) + if (Total < 256) { - printf ("[*** iASL: Write error on output file ***]\n"); - return; + /* After the max line length, we will just read the line, no write */ + + if (fwrite (&SourceByte, 1, 1, OutputFile) != 1) + { + printf ("[*** iASL: Write error on output file ***]\n"); + return; + } + } + else if (Total == 256) + { + fprintf (OutputFile, + "\n[*** iASL: Very long input line, message below refers to column %u ***]", + Enode->Column); } RActual = fread (&SourceByte, 1, 1, SourceFile); @@ -320,13 +333,6 @@ AePrintException ( } Total++; } - - if (Total >= 256) - { - fprintf (OutputFile, - "\n[*** iASL: Long input line, an error occurred at column %u ***]", - Enode->Column); - } } } } diff --git a/source/compiler/aslfiles.c b/source/compiler/aslfiles.c index 5676df1..0881fd4 100644 --- a/source/compiler/aslfiles.c +++ b/source/compiler/aslfiles.c @@ -675,6 +675,27 @@ FlOpenMiscOutputFiles ( AslCompilerFileHeader (ASL_FILE_C_SOURCE_OUTPUT); } + /* Create/Open a C code source output file for the offset table if asked */ + + if (Gbl_C_OffsetTableFlag) + { + Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_OFFSET); + if (!Filename) + { + AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, + 0, 0, 0, 0, NULL, NULL); + return (AE_ERROR); + } + + /* Open the C code source file, text mode */ + + FlOpenFile (ASL_FILE_C_OFFSET_OUTPUT, Filename, "w+t"); + + FlPrintFile (ASL_FILE_C_OFFSET_OUTPUT, "/*\n"); + AslCompilerSignon (ASL_FILE_C_OFFSET_OUTPUT); + AslCompilerFileHeader (ASL_FILE_C_OFFSET_OUTPUT); + } + /* Create/Open a assembly include output file if asked */ if (Gbl_AsmIncludeOutputFlag) diff --git a/source/compiler/aslglobal.h b/source/compiler/aslglobal.h index 1b1f67c..c15c669 100644 --- a/source/compiler/aslglobal.h +++ b/source/compiler/aslglobal.h @@ -86,7 +86,8 @@ ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES] = {NULL, NULL, "ASM Source: ", "Assembly Code Output"}, {NULL, NULL, "C Source: ", "C Code Output"}, {NULL, NULL, "ASM Include: ", "Assembly Header Output"}, - {NULL, NULL, "C Include: ", "C Header Output"} + {NULL, NULL, "C Include: ", "C Header Output"}, + {NULL, NULL, "Offset Table: ", "C Offset Table Output"} }; #else @@ -143,6 +144,7 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_PreprocessorOutputFlag, ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DebugFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_AsmOutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_C_OutputFlag, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_C_OffsetTableFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_AsmIncludeOutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_C_IncludeOutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_ListingFlag, FALSE); diff --git a/source/compiler/asllisting.c b/source/compiler/asllisting.c index 4e7bb48..04c5179 100644 --- a/source/compiler/asllisting.c +++ b/source/compiler/asllisting.c @@ -41,23 +41,22 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" #include "acparser.h" #include "acnamesp.h" + #define _COMPONENT ACPI_COMPILER - ACPI_MODULE_NAME ("aslisting") + ACPI_MODULE_NAME ("asllisting") + /* Local prototypes */ static void -LsDumpAscii ( - UINT32 FileId, - UINT32 Count, - UINT8 *Buffer); +LsGenerateListing ( + UINT32 FileId); static ACPI_STATUS LsAmlListingWalk ( @@ -65,66 +64,27 @@ LsAmlListingWalk ( UINT32 Level, void *Context); -static void -LsGenerateListing ( - UINT32 FileId); - -static void -LsPushNode ( - char *Filename); - -static ASL_LISTING_NODE * -LsPopNode ( - void); - -static void -LsCheckException ( - UINT32 LineNumber, - UINT32 FileId); - -static void -LsFlushListingBuffer ( - UINT32 FileId); +static ACPI_STATUS +LsTreeWriteWalk ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); static void -LsWriteListingHexBytes ( - UINT8 *Buffer, - UINT32 Length, - UINT32 FileId); - -static UINT32 -LsWriteOneSourceLine ( +LsWriteNodeToListing ( + ACPI_PARSE_OBJECT *Op, UINT32 FileId); static void LsFinishSourceListing ( UINT32 FileId); -static void -LsWriteSourceLines ( - UINT32 ToLineNumber, - UINT32 ToLogicalLineNumber, - UINT32 FileId); - -static void -LsWriteNodeToListing ( - ACPI_PARSE_OBJECT *Op, - UINT32 FileId); - -static ACPI_STATUS -LsTreeWriteWalk ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - -#define ASL_LISTING_LINE_PREFIX ": " - /******************************************************************************* * * FUNCTION: LsDoListings * - * PARAMETERS: None + * PARAMETERS: None. Examines the various output file global flags. * * RETURN: None * @@ -161,153 +121,60 @@ LsDoListings ( { LsGenerateListing (ASL_FILE_ASM_INCLUDE_OUTPUT); } -} - - -/******************************************************************************* - * - * FUNCTION: LsTreeWriteWalk - * - * PARAMETERS: ASL_WALK_CALLBACK - * - * - * RETURN: None - * - * DESCRIPTION: Dump entire parse tree, for compiler debug only - * - ******************************************************************************/ - -static ACPI_STATUS -LsTreeWriteWalk ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context) -{ - - /* Debug output */ - - DbgPrint (ASL_TREE_OUTPUT, - "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level); - UtPrintFormattedName (Op->Asl.ParseOpcode, Level); - - - DbgPrint (ASL_TREE_OUTPUT, "\n"); - return (AE_OK); -} - - -void -LsDumpParseTree ( - void) -{ - if (!Gbl_DebugFlag) + if (Gbl_C_OffsetTableFlag) { - return; + LsGenerateListing (ASL_FILE_C_OFFSET_OUTPUT); } - - DbgPrint (ASL_TREE_OUTPUT, "\nOriginal parse tree from parser:\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, - LsTreeWriteWalk, NULL, NULL); } /******************************************************************************* * - * FUNCTION: LsDumpAscii + * FUNCTION: LsGenerateListing * - * PARAMETERS: FileId - ID of current listing file - * Count - Number of bytes to convert - * Buffer - Buffer of bytes to convert + * PARAMETERS: FileId - ID of listing file * * RETURN: None * - * DESCRIPTION: Convert hex bytes to ascii + * DESCRIPTION: Generate a listing file. This can be one of the several types + * of "listings" supported. * ******************************************************************************/ static void -LsDumpAscii ( - UINT32 FileId, - UINT32 Count, - UINT8 *Buffer) +LsGenerateListing ( + UINT32 FileId) { - UINT8 BufChar; - UINT32 i; - - - FlPrintFile (FileId, " \""); - for (i = 0; i < Count; i++) - { - BufChar = Buffer[i]; - if (isprint (BufChar)) - { - FlPrintFile (FileId, "%c", BufChar); - } - else - { - /* Not a printable character, just put out a dot */ - - FlPrintFile (FileId, "."); - } - } - FlPrintFile (FileId, "\""); -} + /* Start at the beginning of both the source and AML files */ -/******************************************************************************* - * - * 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 -LsDumpAsciiInComment ( - UINT32 FileId, - UINT32 Count, - UINT8 *Buffer) -{ - UINT8 BufChar = 0; - UINT8 LastChar; - UINT32 i; - + FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0); + FlSeekFile (ASL_FILE_AML_OUTPUT, 0); + Gbl_SourceLine = 0; + Gbl_CurrentHexColumn = 0; + LsPushNode (Gbl_Files[ASL_FILE_INPUT].Filename); - FlPrintFile (FileId, " \""); - for (i = 0; i < Count; i++) + if (FileId == ASL_FILE_C_OFFSET_OUTPUT) { - LastChar = BufChar; - BufChar = Buffer[i]; + /* Offset table file has a special header and footer */ - if (isprint (BufChar)) - { - /* Handle embedded C comment sequences */ + LsDoOffsetTableHeader (FileId); - if (((LastChar == '*') && (BufChar == '/')) || - ((LastChar == '/') && (BufChar == '*'))) - { - /* Insert a space to break the sequence */ + TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlOffsetWalk, + NULL, (void *) ACPI_TO_POINTER (FileId)); + LsDoOffsetTableFooter (FileId); + return; + } - FlPrintFile (FileId, ".", BufChar); - } + /* Process all parse nodes */ - FlPrintFile (FileId, "%c", BufChar); - } - else - { - /* Not a printable character, just put out a dot */ + TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlListingWalk, + NULL, (void *) ACPI_TO_POINTER (FileId)); - FlPrintFile (FileId, "."); - } - } - FlPrintFile (FileId, "\""); + /* Final processing */ + + LsFinishSourceListing (FileId); } @@ -361,576 +228,47 @@ LsAmlListingWalk ( /******************************************************************************* * - * FUNCTION: LsGenerateListing - * - * PARAMETERS: FileId - ID of listing file - * - * RETURN: None - * - * DESCRIPTION: Generate a listing file. This can be one of the several types - * of "listings" supported. - * - ******************************************************************************/ - -static void -LsGenerateListing ( - UINT32 FileId) -{ - - /* Start at the beginning of both the source and AML files */ - - FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0); - FlSeekFile (ASL_FILE_AML_OUTPUT, 0); - Gbl_SourceLine = 0; - Gbl_CurrentHexColumn = 0; - LsPushNode (Gbl_Files[ASL_FILE_INPUT].Filename); - - /* Process all parse nodes */ - - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlListingWalk, - NULL, (void *) ACPI_TO_POINTER (FileId)); - - /* Final processing */ - - LsFinishSourceListing (FileId); -} - - -/******************************************************************************* - * - * FUNCTION: LsPushNode - * - * PARAMETERS: Filename - Pointer to the include filename - * - * RETURN: None - * - * DESCRIPTION: Push a listing node on the listing/include file stack. This - * stack enables tracking of include files (infinitely nested) - * and resumption of the listing of the parent file when the - * include file is finished. - * - ******************************************************************************/ - -static void -LsPushNode ( - char *Filename) -{ - ASL_LISTING_NODE *Lnode; - - - /* Create a new node */ - - Lnode = UtLocalCalloc (sizeof (ASL_LISTING_NODE)); - - /* Initialize */ - - Lnode->Filename = Filename; - Lnode->LineNumber = 0; - - /* Link (push) */ - - Lnode->Next = Gbl_ListingNode; - Gbl_ListingNode = Lnode; -} - - -/******************************************************************************* - * - * FUNCTION: LsPopNode + * FUNCTION: LsDumpParseTree, LsTreeWriteWalk * * 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). - * - ******************************************************************************/ - -static ASL_LISTING_NODE * -LsPopNode ( - void) -{ - ASL_LISTING_NODE *Lnode; - - - /* Just grab the node at the head of the list */ - - Lnode = Gbl_ListingNode; - if ((!Lnode) || - (!Lnode->Next)) - { - AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL, - "Could not pop empty listing stack"); - return (Gbl_ListingNode); - } - - Gbl_ListingNode = Lnode->Next; - ACPI_FREE (Lnode); - - /* New "Current" node is the new head */ - - return (Gbl_ListingNode); -} - - -/******************************************************************************* - * - * 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 - * sorted (by line #) list of compile errors/warnings. - * - ******************************************************************************/ - -static void -LsCheckException ( - UINT32 LineNumber, - UINT32 FileId) -{ - - if ((!Gbl_NextError) || - (LineNumber < Gbl_NextError->LogicalLineNumber )) - { - return; - } - - /* Handle multiple errors per line */ - - if (FileId == ASL_FILE_LISTING_OUTPUT) - { - while (Gbl_NextError && - (LineNumber >= Gbl_NextError->LogicalLineNumber)) - { - AePrintException (FileId, Gbl_NextError, "\n[****iasl****]\n"); - - Gbl_NextError = Gbl_NextError->Next; - } - - FlPrintFile (FileId, "\n"); - } -} - - -/******************************************************************************* - * - * 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. - * - ******************************************************************************/ - -static void -LsFlushListingBuffer ( - UINT32 FileId) -{ - 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++) - { - FlPrintFile (FileId, "%2.2X ", Gbl_AmlBuffer[i]); - } - - for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 3); i++) - { - FlWriteFile (FileId, ".", 1); - } - - /* Write the ASCII character associated with each of the bytes */ - - LsDumpAscii (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer); - break; - - - case ASL_FILE_ASM_SOURCE_OUTPUT: - - for (i = 0; i < Gbl_CurrentHexColumn; i++) - { - if (i > 0) - { - FlPrintFile (FileId, ","); - } - FlPrintFile (FileId, "0%2.2Xh", Gbl_AmlBuffer[i]); - } - - for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 5); i++) - { - FlWriteFile (FileId, " ", 1); - } - - FlPrintFile (FileId, " ;%8.8X", - Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE); - - /* Write the ASCII character associated with each of the bytes */ - - LsDumpAscii (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer); - break; - - - case ASL_FILE_C_SOURCE_OUTPUT: - - for (i = 0; i < Gbl_CurrentHexColumn; i++) - { - FlPrintFile (FileId, "0x%2.2X,", Gbl_AmlBuffer[i]); - } - - for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 5); i++) - { - FlWriteFile (FileId, " ", 1); - } - - FlPrintFile (FileId, " /* %8.8X", - Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE); - - /* Write the ASCII character associated with each of the bytes */ - - LsDumpAsciiInComment (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer); - FlPrintFile (FileId, " */"); - break; - - default: - /* No other types supported */ - return; - } - - FlPrintFile (FileId, "\n"); - - Gbl_CurrentHexColumn = 0; - Gbl_HexBytesWereWritten = TRUE; -} - - -/******************************************************************************* - * - * 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. - * - ******************************************************************************/ - -static void -LsWriteListingHexBytes ( - UINT8 *Buffer, - UINT32 Length, - UINT32 FileId) -{ - 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) - { - FlPrintFile (FileId, "%*s", 10, " "); - } - - switch (FileId) - { - case ASL_FILE_LISTING_OUTPUT: - - FlPrintFile (FileId, "%8.8X%s", Gbl_CurrentAmlOffset, - ASL_LISTING_LINE_PREFIX); - break; - - case ASL_FILE_ASM_SOURCE_OUTPUT: - - FlPrintFile (FileId, " db "); - break; - - case ASL_FILE_C_SOURCE_OUTPUT: - - FlPrintFile (FileId, " "); - break; - - default: - /* No other types supported */ - return; - } - } - - /* Transfer AML byte and update counts */ - - Gbl_AmlBuffer[Gbl_CurrentHexColumn] = Buffer[i]; - - Gbl_CurrentHexColumn++; - Gbl_CurrentAmlOffset++; - - /* Flush buffer when it is full */ - - if (Gbl_CurrentHexColumn >= HEX_LISTING_LINE_SIZE) - { - LsFlushListingBuffer (FileId); - } - } -} - - -/******************************************************************************* - * - * 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 - * - ******************************************************************************/ - -static UINT32 -LsWriteOneSourceLine ( - UINT32 FileId) -{ - UINT8 FileByte; - - - 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, " *"); - } - if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT) - { - FlPrintFile (FileId, "; "); - } - - if (Gbl_HasIncludeFiles) - { - /* - * This file contains "include" statements, print the current - * filename and line number within the current file - */ - 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, "%8u%s", Gbl_SourceLine, - ASL_LISTING_LINE_PREFIX); - } - - /* Read the rest of this line (up to a newline or EOF) */ - - do - { - if (FileId == ASL_FILE_C_SOURCE_OUTPUT) - { - if (FileByte == '/') - { - FileByte = '*'; - } - } - - FlWriteFile (FileId, &FileByte, 1); - 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 */ - - return (0); -} - - -/******************************************************************************* - * - * FUNCTION: LsFinishSourceListing - * - * PARAMETERS: FileId - ID of current listing file. - * - * RETURN: None - * - * DESCRIPTION: Cleanup routine for the listing file. Flush the hex AML - * listing buffer, and flush out any remaining lines in the - * source input file. + * DESCRIPTION: Dump entire parse tree, for compiler debug only * ******************************************************************************/ -static void -LsFinishSourceListing ( - UINT32 FileId) +void +LsDumpParseTree ( + void) { - if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) || - (FileId == ASL_FILE_C_INCLUDE_OUTPUT)) + if (!Gbl_DebugFlag) { return; } - LsFlushListingBuffer (FileId); - Gbl_CurrentAmlOffset = 0; - - /* Flush any remaining text in the source file */ - - if (FileId == ASL_FILE_C_SOURCE_OUTPUT) - { - FlPrintFile (FileId, " /*\n"); - } - - while (LsWriteOneSourceLine (FileId)) - { ; } - - if (FileId == ASL_FILE_C_SOURCE_OUTPUT) - { - FlPrintFile (FileId, "\n */\n };\n"); - } - - FlPrintFile (FileId, "\n"); - - if (FileId == ASL_FILE_LISTING_OUTPUT) - { - /* Print a summary of the compile exceptions */ - - FlPrintFile (FileId, "\n\nSummary of errors and warnings\n\n"); - AePrintErrorLog (FileId); - FlPrintFile (FileId, "\n"); - UtDisplaySummary (FileId); - FlPrintFile (FileId, "\n"); - } + DbgPrint (ASL_TREE_OUTPUT, "\nOriginal parse tree from parser:\n\n"); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + LsTreeWriteWalk, NULL, NULL); } -/******************************************************************************* - * - * 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. - * - ******************************************************************************/ - -static void -LsWriteSourceLines ( - UINT32 ToLineNumber, - UINT32 ToLogicalLineNumber, - UINT32 FileId) +static ACPI_STATUS +LsTreeWriteWalk ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) { - if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) || - (FileId == ASL_FILE_C_INCLUDE_OUTPUT)) - { - return; - } - - Gbl_CurrentLine = ToLogicalLineNumber; - - /* Flush any hex bytes remaining from the last opcode */ - - LsFlushListingBuffer (FileId); - - /* 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 (Gbl_HexBytesWereWritten) - { - FlPrintFile (FileId, "\n"); - Gbl_HexBytesWereWritten = FALSE; - } - - if (FileId == ASL_FILE_C_SOURCE_OUTPUT) - { - FlPrintFile (FileId, " /*\n"); - } - - /* Write one line at a time until we have reached the target line # */ + /* Debug output */ - while ((Gbl_SourceLine < Gbl_CurrentLine) && - LsWriteOneSourceLine (FileId)) - { ; } + DbgPrint (ASL_TREE_OUTPUT, + "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level); + UtPrintFormattedName (Op->Asl.ParseOpcode, Level); - if (FileId == ASL_FILE_C_SOURCE_OUTPUT) - { - FlPrintFile (FileId, " */"); - } - FlPrintFile (FileId, "\n"); - } + DbgPrint (ASL_TREE_OUTPUT, "\n"); + return (AE_OK); } @@ -938,7 +276,7 @@ LsWriteSourceLines ( * * FUNCTION: LsWriteNodeToListing * - * PARAMETERS: Op - Parse node to write to the listing file. + * PARAMETERS: Op - Parse node to write to the listing file. * FileId - ID of current listing file * * RETURN: None. @@ -1244,3 +582,61 @@ LsWriteNodeToListing ( break; } } + + +/******************************************************************************* + * + * FUNCTION: LsFinishSourceListing + * + * PARAMETERS: FileId - ID of current listing file. + * + * RETURN: None + * + * DESCRIPTION: Cleanup routine for the listing file. Flush the hex AML + * listing buffer, and flush out any remaining lines in the + * source input file. + * + ******************************************************************************/ + +static void +LsFinishSourceListing ( + UINT32 FileId) +{ + + if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) || + (FileId == ASL_FILE_C_INCLUDE_OUTPUT)) + { + return; + } + + LsFlushListingBuffer (FileId); + Gbl_CurrentAmlOffset = 0; + + /* Flush any remaining text in the source file */ + + if (FileId == ASL_FILE_C_SOURCE_OUTPUT) + { + FlPrintFile (FileId, " /*\n"); + } + + while (LsWriteOneSourceLine (FileId)) + { ; } + + if (FileId == ASL_FILE_C_SOURCE_OUTPUT) + { + FlPrintFile (FileId, "\n */\n };\n"); + } + + FlPrintFile (FileId, "\n"); + + if (FileId == ASL_FILE_LISTING_OUTPUT) + { + /* Print a summary of the compile exceptions */ + + FlPrintFile (FileId, "\n\nSummary of errors and warnings\n\n"); + AePrintErrorLog (FileId); + FlPrintFile (FileId, "\n"); + UtDisplaySummary (FileId); + FlPrintFile (FileId, "\n"); + } +} diff --git a/source/compiler/asllistsup.c b/source/compiler/asllistsup.c new file mode 100644 index 0000000..4156dcc --- /dev/null +++ b/source/compiler/asllistsup.c @@ -0,0 +1,706 @@ +/****************************************************************************** + * + * Module Name: asllistsup - Listing file support utilities + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2013, 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.h" +#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 +LsDumpAscii ( + UINT32 FileId, + UINT32 Count, + UINT8 *Buffer) +{ + UINT8 BufChar; + UINT32 i; + + + FlPrintFile (FileId, " \""); + for (i = 0; i < Count; i++) + { + BufChar = Buffer[i]; + if (isprint (BufChar)) + { + FlPrintFile (FileId, "%c", BufChar); + } + else + { + /* Not a printable character, just put out a dot */ + + FlPrintFile (FileId, "."); + } + } + FlPrintFile (FileId, "\""); +} + + +/******************************************************************************* + * + * 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 +LsDumpAsciiInComment ( + UINT32 FileId, + UINT32 Count, + UINT8 *Buffer) +{ + UINT8 BufChar = 0; + UINT8 LastChar; + UINT32 i; + + + FlPrintFile (FileId, " \""); + for (i = 0; i < Count; i++) + { + LastChar = BufChar; + BufChar = Buffer[i]; + + if (isprint (BufChar)) + { + /* Handle embedded C comment sequences */ + + if (((LastChar == '*') && (BufChar == '/')) || + ((LastChar == '/') && (BufChar == '*'))) + { + /* Insert a space to break the sequence */ + + FlPrintFile (FileId, ".", BufChar); + } + + FlPrintFile (FileId, "%c", BufChar); + } + else + { + /* Not a printable character, just put out a dot */ + + FlPrintFile (FileId, "."); + } + } + + FlPrintFile (FileId, "\""); +} + + +/******************************************************************************* + * + * 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 + * sorted (by line #) list of compile errors/warnings. + * + ******************************************************************************/ + +void +LsCheckException ( + UINT32 LineNumber, + UINT32 FileId) +{ + + if ((!Gbl_NextError) || + (LineNumber < Gbl_NextError->LogicalLineNumber )) + { + return; + } + + /* Handle multiple errors per line */ + + if (FileId == ASL_FILE_LISTING_OUTPUT) + { + while (Gbl_NextError && + (LineNumber >= Gbl_NextError->LogicalLineNumber)) + { + AePrintException (FileId, Gbl_NextError, "\n[****iasl****]\n"); + + Gbl_NextError = Gbl_NextError->Next; + } + + FlPrintFile (FileId, "\n"); + } +} + + +/******************************************************************************* + * + * 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 +LsWriteListingHexBytes ( + UINT8 *Buffer, + UINT32 Length, + UINT32 FileId) +{ + 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) + { + FlPrintFile (FileId, "%*s", 10, " "); + } + + switch (FileId) + { + case ASL_FILE_LISTING_OUTPUT: + + FlPrintFile (FileId, "%8.8X%s", Gbl_CurrentAmlOffset, + ASL_LISTING_LINE_PREFIX); + break; + + case ASL_FILE_ASM_SOURCE_OUTPUT: + + FlPrintFile (FileId, " db "); + break; + + case ASL_FILE_C_SOURCE_OUTPUT: + + FlPrintFile (FileId, " "); + break; + + default: + /* No other types supported */ + return; + } + } + + /* Transfer AML byte and update counts */ + + Gbl_AmlBuffer[Gbl_CurrentHexColumn] = Buffer[i]; + + Gbl_CurrentHexColumn++; + Gbl_CurrentAmlOffset++; + + /* Flush buffer when it is full */ + + if (Gbl_CurrentHexColumn >= HEX_LISTING_LINE_SIZE) + { + LsFlushListingBuffer (FileId); + } + } +} + + +/******************************************************************************* + * + * 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 +LsWriteSourceLines ( + UINT32 ToLineNumber, + UINT32 ToLogicalLineNumber, + UINT32 FileId) +{ + + /* Nothing to do for these file types */ + + if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) || + (FileId == ASL_FILE_C_INCLUDE_OUTPUT)) + { + return; + } + + Gbl_CurrentLine = ToLogicalLineNumber; + + /* Flush any hex bytes remaining from the last opcode */ + + LsFlushListingBuffer (FileId); + + /* 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 (Gbl_HexBytesWereWritten) + { + FlPrintFile (FileId, "\n"); + Gbl_HexBytesWereWritten = FALSE; + } + + if (FileId == ASL_FILE_C_SOURCE_OUTPUT) + { + FlPrintFile (FileId, " /*\n"); + } + + /* Write one line at a time until we have reached the target line # */ + + while ((Gbl_SourceLine < Gbl_CurrentLine) && + LsWriteOneSourceLine (FileId)) + { ; } + + if (FileId == ASL_FILE_C_SOURCE_OUTPUT) + { + FlPrintFile (FileId, " */"); + } + + FlPrintFile (FileId, "\n"); + } +} + + +/******************************************************************************* + * + * 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 + * + ******************************************************************************/ + +UINT32 +LsWriteOneSourceLine ( + UINT32 FileId) +{ + UINT8 FileByte; + UINT32 Column = 0; + UINT32 Index = 16; + BOOLEAN StartOfLine = FALSE; + BOOLEAN ProcessLongLine = FALSE; + + + 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, " *"); + } + if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT) + { + FlPrintFile (FileId, "; "); + } + + if (Gbl_HasIncludeFiles) + { + /* + * This file contains "include" statements, print the current + * filename and line number within the current file + */ + 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, "%8u%s", Gbl_SourceLine, + ASL_LISTING_LINE_PREFIX); + } + + /* 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; + } + + ProcessLongLine = TRUE; + } + + if (FileByte == '{') + { + FlPrintFile (FileId, "\n%*s{\n", Index, " "); + StartOfLine = TRUE; + Index += 4; + continue; + } + + else if (FileByte == '}') + { + if (!StartOfLine) + { + FlPrintFile (FileId, "\n"); + } + + StartOfLine = TRUE; + Index -= 4; + FlPrintFile (FileId, "%*s}\n", Index, " "); + continue; + } + + /* Ignore spaces/tabs at the start of line */ + + else if ((FileByte == ' ') && StartOfLine) + { + continue; + } + + else if (StartOfLine) + { + StartOfLine = FALSE; + FlPrintFile (FileId, "%*s", Index, " "); + } + +WriteByte: + FlWriteFile (FileId, &FileByte, 1); + 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); + } + } + else + { + FlWriteFile (FileId, &FileByte, 1); + 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 */ + + 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 +LsFlushListingBuffer ( + UINT32 FileId) +{ + 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++) + { + FlPrintFile (FileId, "%2.2X ", Gbl_AmlBuffer[i]); + } + + for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 3); i++) + { + FlWriteFile (FileId, ".", 1); + } + + /* Write the ASCII character associated with each of the bytes */ + + LsDumpAscii (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer); + break; + + + case ASL_FILE_ASM_SOURCE_OUTPUT: + + for (i = 0; i < Gbl_CurrentHexColumn; i++) + { + if (i > 0) + { + FlPrintFile (FileId, ","); + } + FlPrintFile (FileId, "0%2.2Xh", Gbl_AmlBuffer[i]); + } + + for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 5); i++) + { + FlWriteFile (FileId, " ", 1); + } + + FlPrintFile (FileId, " ;%8.8X", + Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE); + + /* Write the ASCII character associated with each of the bytes */ + + LsDumpAscii (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer); + break; + + + case ASL_FILE_C_SOURCE_OUTPUT: + + for (i = 0; i < Gbl_CurrentHexColumn; i++) + { + FlPrintFile (FileId, "0x%2.2X,", Gbl_AmlBuffer[i]); + } + + /* Pad hex output with spaces if line is shorter than max line size */ + + for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 5); i++) + { + FlWriteFile (FileId, " ", 1); + } + + /* AML offset for the start of the line */ + + FlPrintFile (FileId, " /* %8.8X", + Gbl_CurrentAmlOffset - Gbl_CurrentHexColumn); + + /* Write the ASCII character associated with each of the bytes */ + + LsDumpAsciiInComment (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer); + FlPrintFile (FileId, " */"); + break; + + default: + /* No other types supported */ + return; + } + + FlPrintFile (FileId, "\n"); + + Gbl_CurrentHexColumn = 0; + Gbl_HexBytesWereWritten = TRUE; +} + + +/******************************************************************************* + * + * FUNCTION: LsPushNode + * + * PARAMETERS: Filename - Pointer to the include filename + * + * RETURN: None + * + * DESCRIPTION: Push a listing node on the listing/include file stack. This + * stack enables tracking of include files (infinitely nested) + * and resumption of the listing of the parent file when the + * include file is finished. + * + ******************************************************************************/ + +void +LsPushNode ( + char *Filename) +{ + ASL_LISTING_NODE *Lnode; + + + /* Create a new node */ + + Lnode = UtLocalCalloc (sizeof (ASL_LISTING_NODE)); + + /* Initialize */ + + Lnode->Filename = Filename; + Lnode->LineNumber = 0; + + /* Link (push) */ + + Lnode->Next = Gbl_ListingNode; + Gbl_ListingNode = Lnode; +} + + +/******************************************************************************* + * + * 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). + * + ******************************************************************************/ + +ASL_LISTING_NODE * +LsPopNode ( + void) +{ + ASL_LISTING_NODE *Lnode; + + + /* Just grab the node at the head of the list */ + + Lnode = Gbl_ListingNode; + if ((!Lnode) || + (!Lnode->Next)) + { + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL, + "Could not pop empty listing stack"); + return (Gbl_ListingNode); + } + + Gbl_ListingNode = Lnode->Next; + ACPI_FREE (Lnode); + + /* New "Current" node is the new head */ + + return (Gbl_ListingNode); +} diff --git a/source/compiler/aslmain.c b/source/compiler/aslmain.c index 71a7cec..4cc63fa 100644 --- a/source/compiler/aslmain.c +++ b/source/compiler/aslmain.c @@ -156,6 +156,7 @@ Options ( ACPI_OPTION ("-sc -sa", "Create source file in C or assembler (*.c or *.asm)"); ACPI_OPTION ("-ic -ia", "Create include file in C or assembler (*.h or *.inc)"); ACPI_OPTION ("-tc -ta -ts", "Create hex AML table in C, assembler, or ASL (*.hex)"); + ACPI_OPTION ("-so", "Create offset table in C (*.offset.h)"); printf ("\nOptional Listing Files:\n"); ACPI_OPTION ("-l", "Create mixed listing file (ASL source and AML) (*.lst)"); @@ -784,6 +785,13 @@ AslDoOptions ( Gbl_C_OutputFlag = TRUE; break; + case 'o': + + /* Produce AML offset table in C */ + + Gbl_C_OffsetTableFlag = TRUE; + break; + default: printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); return (-1); diff --git a/source/compiler/asloffset.c b/source/compiler/asloffset.c new file mode 100644 index 0000000..190b92a --- /dev/null +++ b/source/compiler/asloffset.c @@ -0,0 +1,326 @@ +/****************************************************************************** + * + * Module Name: asloffset - Generate a C "offset table" for BIOS use. + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2013, 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.h" +#include "aslcompiler.y.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("asloffset") + + +/* Local prototypes */ + +static void +LsEmitOffsetTableEntry ( + UINT32 FileId, + ACPI_NAMESPACE_NODE *Node, + UINT32 Offset, + UINT32 Length, + char *OpName, + UINT64 Value, + UINT8 AmlOpcode); + + +/******************************************************************************* + * + * FUNCTION: LsAmlOffsetWalk + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Process one node during a offset table file generation. + * + * Three types of objects are currently emitted to the offset table: + * 1) Tagged (named) resource descriptors + * 2) Named integer objects with constant integer values + * 3) Operation Regions that have constant Offset (address) parameters + * + * The offset table allows the BIOS to dynamically update the values of these + * objects at boot time. + * + ******************************************************************************/ + +ACPI_STATUS +LsAmlOffsetWalk ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + UINT32 FileId = (UINT32) ACPI_TO_INTEGER (Context); + ACPI_NAMESPACE_NODE *Node; + UINT32 Length; + UINT32 OffsetOfOpcode; + ACPI_PARSE_OBJECT *AddressOp; + + + /* Ignore actual data blocks for resource descriptors */ + + if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DATA) + { + return (AE_OK); /* Do NOT update the global AML offset */ + } + + /* We are only interested in named objects (have a namespace node) */ + + Node = Op->Asl.Node; + if (!Node) + { + Gbl_CurrentAmlOffset += Op->Asl.FinalAmlLength; + return (AE_OK); + } + + /* Named resource descriptor (has a descriptor tag) */ + + if ((Node->Type == ACPI_TYPE_LOCAL_RESOURCE) && + (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)) + { + LsEmitOffsetTableEntry (FileId, Node, Gbl_CurrentAmlOffset, + Op->Asl.FinalAmlLength, Op->Asl.ParseOpName, 0, Op->Asl.Extra); + } + + /* Named object -- Name (NameString, DataRefObject) */ + + else if (Op->Asl.AmlOpcode == AML_NAME_OP) + { + if (!Op->Asl.Child) + { + FlPrintFile (FileId, "%s NO CHILD!\n", MsgBuffer); + return (AE_OK); + } + + Length = Op->Asl.FinalAmlLength; + + /* Get to the NameSeg/NamePath Op (and length of the name) */ + + Op = Op->Asl.Child; + OffsetOfOpcode = Length + Op->Asl.FinalAmlLength; + + /* Get actual value associated with the name */ + + Op = Op->Asl.Next; + switch (Op->Asl.AmlOpcode) + { + /* + * We are only interested in integer constants that can be changed + * at boot time. Note, the One/Ones/Zero opcodes are considered + * non-changeable, so we ignore them here. + */ + case AML_BYTE_OP: + case AML_WORD_OP: + case AML_DWORD_OP: + case AML_QWORD_OP: + + /* The +1/-1 is to handle the integer size prefix (opcode) */ + + LsEmitOffsetTableEntry (FileId, Node, + (Gbl_CurrentAmlOffset + OffsetOfOpcode + 1), + (Op->Asl.FinalAmlLength - 1), Op->Asl.ParseOpName, + Op->Asl.Value.Integer, (UINT8) Op->Asl.AmlOpcode); + break; + + default: + break; + } + + Gbl_CurrentAmlOffset += Length; + return (AE_OK); + } + + /* OperationRegion (NameString, RegionSpace, RegionOffset, RegionLength) */ + + else if (Op->Asl.AmlOpcode == AML_REGION_OP) + { + Length = Op->Asl.FinalAmlLength; + + /* Get the name/namepath node */ + + AddressOp = Op->Asl.Child; + OffsetOfOpcode = Length + AddressOp->Asl.FinalAmlLength + 1; + + /* Get the SpaceId node, then the Offset (address) node */ + + AddressOp = AddressOp->Asl.Next; + AddressOp = AddressOp->Asl.Next; + + switch (AddressOp->Asl.AmlOpcode) + { + /* + * We are only interested in integer constants that can be changed + * at boot time. Note, the One/Ones/Zero opcodes are considered + * non-changeable, so we ignore them here. + */ + case AML_BYTE_OP: + case AML_WORD_OP: + case AML_DWORD_OP: + case AML_QWORD_OP: + + /* The +1/-1 is to handle the integer size prefix (opcode) */ + + LsEmitOffsetTableEntry (FileId, Node, + (Gbl_CurrentAmlOffset + OffsetOfOpcode + 1), + (AddressOp->Asl.FinalAmlLength - 1), Op->Asl.ParseOpName, + AddressOp->Asl.Value.Integer, (UINT8) AddressOp->Asl.AmlOpcode); + + Gbl_CurrentAmlOffset += Length; + return (AE_OK); + + default: + break; + } + } + + Gbl_CurrentAmlOffset += Op->Asl.FinalAmlLength; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: LsEmitOffsetTableEntry + * + * PARAMETERS: FileId - ID of current listing file + * Node - Namespace node associated with the name + * Offset - Offset of the value within the AML table + * Length - Length in bytes of the value + * OpName - Name of the AML opcode + * Value - Current value of the AML field + * AmlOpcode - Opcode associated with the field + * + * RETURN: None + * + * DESCRIPTION: Emit a line of the offset table (-so option) + * + ******************************************************************************/ + +static void +LsEmitOffsetTableEntry ( + UINT32 FileId, + ACPI_NAMESPACE_NODE *Node, + UINT32 Offset, + UINT32 Length, + char *OpName, + UINT64 Value, + UINT8 AmlOpcode) +{ + ACPI_BUFFER TargetPath; + ACPI_STATUS Status; + + + /* Get the full pathname to the namespace node */ + + TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiNsHandleToPathname (Node, &TargetPath); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* [1] - Skip the opening backslash for the path */ + + strcpy (MsgBuffer, "\""); + strcat (MsgBuffer, &((char *) TargetPath.Pointer)[1]); + strcat (MsgBuffer, "\","); + ACPI_FREE (TargetPath.Pointer); + + /* + * Max offset is 4G, constrained by 32-bit ACPI table length. + * Max Length for Integers is 8 bytes. + */ + FlPrintFile (FileId, + " {%-29s 0x%8.8X, 0x%2.2X, 0x%8.8X%8.8X}, /* %s */\n", + MsgBuffer, Offset, AmlOpcode, ACPI_FORMAT_UINT64 (Value), OpName); +} + + +/******************************************************************************* + * + * FUNCTION: LsDoOffsetTableHeader, LsDoOffsetTableFooter + * + * PARAMETERS: FileId - ID of current listing file + * + * RETURN: None + * + * DESCRIPTION: Header and footer for the offset table file. + * + ******************************************************************************/ + +void +LsDoOffsetTableHeader ( + UINT32 FileId) +{ + + Gbl_CurrentAmlOffset = 0; + + FlPrintFile (FileId, + "#ifndef __AML_OFFSET_TABLE_H\n" + "#define __AML_OFFSET_TABLE_H\n\n"); + + FlPrintFile (FileId, "typedef struct {\n" + " char *Pathname;\n" + " unsigned long Offset;\n" + " unsigned char AmlOpcode;\n" + " unsigned long long AmlValue;\n" + "} AML_OFFSET_TABLE_ENTRY;\n\n"); + + FlPrintFile (FileId, + "#endif /* __AML_OFFSET_TABLE_H */\n\n"); + + FlPrintFile (FileId, + "AML_OFFSET_TABLE_ENTRY %s_%s_OffsetTable[] =\n{\n", + Gbl_TableSignature, Gbl_TableId); +} + + +void +LsDoOffsetTableFooter ( + UINT32 FileId) +{ + + FlPrintFile (FileId, + " {0,0,0,0} /* Table terminator */\n};\n\n"); + Gbl_CurrentAmlOffset = 0; +} diff --git a/source/compiler/aslpredef.c b/source/compiler/aslpredef.c index ca877a8..4330c19 100644 --- a/source/compiler/aslpredef.c +++ b/source/compiler/aslpredef.c @@ -42,6 +42,7 @@ */ #define ACPI_CREATE_PREDEFINED_TABLE +#define ACPI_CREATE_RESOURCE_TABLE #include "aslcompiler.h" #include "aslcompiler.y.h" @@ -65,90 +66,6 @@ ApCheckForSpecialName ( ACPI_PARSE_OBJECT *Op, char *Name); -static void -ApGetExpectedTypes ( - char *Buffer, - UINT32 ExpectedBtypes); - - -/* - * Names for the types that can be returned by the predefined objects. - * Used for warning messages. Must be in the same order as the ACPI_RTYPEs - */ -static const char *AcpiRtypeNames[] = -{ - "/Integer", - "/String", - "/Buffer", - "/Package", - "/Reference", -}; - -/* - * Predefined names for use in Resource Descriptors. These names do not - * appear in the global Predefined Name table (since these names never - * appear in actual AML byte code, only in the original ASL) - */ -static const ACPI_PREDEFINED_INFO ResourceNames[] = { - {{"_ALN", 0, 0}}, - {{"_ASI", 0, 0}}, - {{"_ASZ", 0, 0}}, - {{"_ATT", 0, 0}}, - {{"_BAS", 0, 0}}, - {{"_BM_", 0, 0}}, - {{"_DBT", 0, 0}}, /* Acpi 5.0 */ - {{"_DEC", 0, 0}}, - {{"_DPL", 0, 0}}, /* Acpi 5.0 */ - {{"_DRS", 0, 0}}, /* Acpi 5.0 */ - {{"_END", 0, 0}}, /* Acpi 5.0 */ - {{"_FLC", 0, 0}}, /* Acpi 5.0 */ - {{"_GRA", 0, 0}}, - {{"_HE_", 0, 0}}, - {{"_INT", 0, 0}}, - {{"_IOR", 0, 0}}, /* Acpi 5.0 */ - {{"_LEN", 0, 0}}, - {{"_LIN", 0, 0}}, /* Acpi 5.0 */ - {{"_LL_", 0, 0}}, - {{"_MAF", 0, 0}}, - {{"_MAX", 0, 0}}, - {{"_MEM", 0, 0}}, - {{"_MIF", 0, 0}}, - {{"_MIN", 0, 0}}, - {{"_MOD", 0, 0}}, /* Acpi 5.0 */ - {{"_MTP", 0, 0}}, - {{"_PAR", 0, 0}}, /* Acpi 5.0 */ - {{"_PHA", 0, 0}}, /* Acpi 5.0 */ - {{"_PIN", 0, 0}}, /* Acpi 5.0 */ - {{"_PPI", 0, 0}}, /* Acpi 5.0 */ - {{"_POL", 0, 0}}, /* Acpi 5.0 */ - {{"_RBO", 0, 0}}, - {{"_RBW", 0, 0}}, - {{"_RNG", 0, 0}}, - {{"_RT_", 0, 0}}, /* Acpi 3.0 */ - {{"_RW_", 0, 0}}, - {{"_RXL", 0, 0}}, /* Acpi 5.0 */ - {{"_SHR", 0, 0}}, - {{"_SIZ", 0, 0}}, - {{"_SLV", 0, 0}}, /* Acpi 5.0 */ - {{"_SPE", 0, 0}}, /* Acpi 5.0 */ - {{"_STB", 0, 0}}, /* Acpi 5.0 */ - {{"_TRA", 0, 0}}, - {{"_TRS", 0, 0}}, - {{"_TSF", 0, 0}}, /* Acpi 3.0 */ - {{"_TTP", 0, 0}}, - {{"_TXL", 0, 0}}, /* Acpi 5.0 */ - {{"_TYP", 0, 0}}, - {{"_VEN", 0, 0}}, /* Acpi 5.0 */ - {{{0,0,0,0}, 0, 0}} /* Table terminator */ -}; - -static const ACPI_PREDEFINED_INFO ScopeNames[] = { - {{"_SB_", 0, 0}}, - {{"_SI_", 0, 0}}, - {{"_TZ_", 0, 0}}, - {{{0,0,0,0}, 0, 0}} /* Table terminator */ -}; - /******************************************************************************* * @@ -170,9 +87,9 @@ ApCheckForPredefinedMethod ( ACPI_PARSE_OBJECT *Op, ASL_METHOD_INFO *MethodInfo) { - UINT32 Index; - UINT32 RequiredArgsCurrent; - UINT32 RequiredArgsOld; + UINT32 Index; + UINT32 RequiredArgCount; + const ACPI_PREDEFINED_INFO *ThisName; /* Check for a match against the predefined name list */ @@ -213,17 +130,16 @@ ApCheckForPredefinedMethod ( * arg counts. */ Gbl_ReservedMethods++; + ThisName = &AcpiGbl_PredefinedMethods[Index]; + RequiredArgCount = ThisName->Info.ArgumentList & METHOD_ARG_MASK; - RequiredArgsCurrent = PredefinedNames[Index].Info.ParamCount & 0x0F; - RequiredArgsOld = PredefinedNames[Index].Info.ParamCount >> 4; - - if ((MethodInfo->NumArguments != RequiredArgsCurrent) && - (MethodInfo->NumArguments != RequiredArgsOld)) + if (MethodInfo->NumArguments != RequiredArgCount) { sprintf (MsgBuffer, "%4.4s requires %u", - PredefinedNames[Index].Info.Name, RequiredArgsCurrent); + ThisName->Info.Name, RequiredArgCount); - if (MethodInfo->NumArguments > RequiredArgsCurrent) + if ((MethodInfo->NumArguments > RequiredArgCount) && + !(ThisName->Info.ArgumentList & ARG_COUNT_IS_MINIMUM)) { AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, MsgBuffer); @@ -240,13 +156,13 @@ ApCheckForPredefinedMethod ( * required to return a value */ if (MethodInfo->NumReturnNoValue && - PredefinedNames[Index].Info.ExpectedBtypes) + ThisName->Info.ExpectedBtypes) { - ApGetExpectedTypes (StringBuffer, - PredefinedNames[Index].Info.ExpectedBtypes); + AcpiUtGetExpectedReturnTypes (StringBuffer, + ThisName->Info.ExpectedBtypes); sprintf (MsgBuffer, "%s required for %4.4s", - StringBuffer, PredefinedNames[Index].Info.Name); + StringBuffer, ThisName->Info.Name); AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op, MsgBuffer); @@ -329,8 +245,9 @@ ApCheckPredefinedReturnValue ( ACPI_PARSE_OBJECT *Op, ASL_METHOD_INFO *MethodInfo) { - UINT32 Index; - ACPI_PARSE_OBJECT *ReturnValueOp; + UINT32 Index; + ACPI_PARSE_OBJECT *ReturnValueOp; + const ACPI_PREDEFINED_INFO *ThisName; /* Check parent method for a match against the predefined name list */ @@ -356,7 +273,8 @@ ApCheckPredefinedReturnValue ( default: /* A standard predefined ACPI name */ - if (!PredefinedNames[Index].Info.ExpectedBtypes) + ThisName = &AcpiGbl_PredefinedMethods[Index]; + if (!ThisName->Info.ExpectedBtypes) { /* No return value expected, warn if there is one */ @@ -379,16 +297,14 @@ ApCheckPredefinedReturnValue ( /* Static data return object - check against expected type */ - ApCheckObjectType (PredefinedNames[Index].Info.Name, - ReturnValueOp, - PredefinedNames[Index].Info.ExpectedBtypes, - ACPI_NOT_PACKAGE_ELEMENT); + ApCheckObjectType (ThisName->Info.Name, ReturnValueOp, + ThisName->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT); /* For packages, check the individual package elements */ if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_PACKAGE) { - ApCheckPackage (ReturnValueOp, &PredefinedNames[Index]); + ApCheckPackage (ReturnValueOp, ThisName); } break; @@ -430,8 +346,9 @@ ApCheckForPredefinedObject ( ACPI_PARSE_OBJECT *Op, char *Name) { - UINT32 Index; - ACPI_PARSE_OBJECT *ObjectOp; + UINT32 Index; + ACPI_PARSE_OBJECT *ObjectOp; + const ACPI_PREDEFINED_INFO *ThisName; /* @@ -470,7 +387,8 @@ ApCheckForPredefinedObject ( * If this predefined name requires input arguments, then * it must be implemented as a control method */ - if (PredefinedNames[Index].Info.ParamCount > 0) + ThisName = &AcpiGbl_PredefinedMethods[Index]; + if ((ThisName->Info.ArgumentList & METHOD_ARG_MASK) > 0) { AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, "with arguments"); @@ -483,7 +401,7 @@ ApCheckForPredefinedObject ( * (with zero args, because the args > 0 case was handled above) * Examples are: _DIS, _INI, _IRC, _OFF, _ON, _PSx */ - if (!PredefinedNames[Index].Info.ExpectedBtypes) + if (!ThisName->Info.ExpectedBtypes) { AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, "with zero arguments"); @@ -493,16 +411,14 @@ ApCheckForPredefinedObject ( /* Typecheck the actual object, it is the next argument */ ObjectOp = Op->Asl.Child->Asl.Next; - ApCheckObjectType (PredefinedNames[Index].Info.Name, - Op->Asl.Child->Asl.Next, - PredefinedNames[Index].Info.ExpectedBtypes, - ACPI_NOT_PACKAGE_ELEMENT); + ApCheckObjectType (ThisName->Info.Name, Op->Asl.Child->Asl.Next, + ThisName->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT); /* For packages, check the individual package elements */ if (ObjectOp->Asl.ParseOpcode == PARSEOP_PACKAGE) { - ApCheckPackage (ObjectOp, &PredefinedNames[Index]); + ApCheckPackage (ObjectOp, ThisName); } } @@ -525,7 +441,8 @@ ApCheckForPredefinedName ( ACPI_PARSE_OBJECT *Op, char *Name) { - UINT32 i; + UINT32 i; + const ACPI_PREDEFINED_INFO *ThisName; if (Name[0] == 0) @@ -543,31 +460,40 @@ ApCheckForPredefinedName ( /* Check for a standard predefined method name */ - for (i = 0; PredefinedNames[i].Info.Name[0]; i++) + ThisName = AcpiGbl_PredefinedMethods; + for (i = 0; ThisName->Info.Name[0]; i++) { - if (ACPI_COMPARE_NAME (Name, PredefinedNames[i].Info.Name)) + if (ACPI_COMPARE_NAME (Name, ThisName->Info.Name)) { /* Return index into predefined array */ return (i); } + + ThisName++; /* Does not account for extra package data, but is OK */ } /* Check for resource names and predefined scope names */ - for (i = 0; ResourceNames[i].Info.Name[0]; i++) + ThisName = AcpiGbl_ResourceNames; + while (ThisName->Info.Name[0]) { - if (ACPI_COMPARE_NAME (Name, ResourceNames[i].Info.Name)) + if (ACPI_COMPARE_NAME (Name, ThisName->Info.Name)) { return (ACPI_PREDEFINED_NAME); } + + ThisName++; } - for (i = 0; ScopeNames[i].Info.Name[0]; i++) + ThisName = AcpiGbl_ScopeNames; + while (ThisName->Info.Name[0]) { - if (ACPI_COMPARE_NAME (Name, ScopeNames[i].Info.Name)) + if (ACPI_COMPARE_NAME (Name, ThisName->Info.Name)) { return (ACPI_PREDEFINED_NAME); } + + ThisName++; } /* Check for _Lxx/_Exx/_Wxx/_Qxx/_T_x. Warning if unknown predefined name */ @@ -742,16 +668,16 @@ TypeErrorExit: /* Format the expected types and emit an error message */ - ApGetExpectedTypes (StringBuffer, ExpectedBtypes); + AcpiUtGetExpectedReturnTypes (StringBuffer, ExpectedBtypes); if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) { - sprintf (MsgBuffer, "%s: found %s, %s required", + sprintf (MsgBuffer, "%4.4s: found %s, %s required", PredefinedName, TypeName, StringBuffer); } else { - sprintf (MsgBuffer, "%s: found %s at index %u, %s required", + sprintf (MsgBuffer, "%4.4s: found %s at index %u, %s required", PredefinedName, TypeName, PackageIndex, StringBuffer); } @@ -778,8 +704,8 @@ ApDisplayReservedNames ( void) { const ACPI_PREDEFINED_INFO *ThisName; - char TypeBuffer[48]; /* Room for 5 types */ UINT32 Count; + UINT32 NumTypes; /* @@ -788,33 +714,12 @@ ApDisplayReservedNames ( printf ("\nPredefined Name Information\n\n"); Count = 0; - ThisName = PredefinedNames; + ThisName = AcpiGbl_PredefinedMethods; while (ThisName->Info.Name[0]) { - printf ("%4.4s Requires %u arguments, ", - ThisName->Info.Name, ThisName->Info.ParamCount & 0x0F); - - if (ThisName->Info.ExpectedBtypes) - { - ApGetExpectedTypes (TypeBuffer, ThisName->Info.ExpectedBtypes); - printf ("Must return: %s\n", TypeBuffer); - } - else - { - printf ("No return value\n"); - } - - /* - * Skip next entry in the table if this name returns a Package - * (next entry contains the package info) - */ - if (ThisName->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE) - { - ThisName++; - } - + AcpiUtDisplayPredefinedMethod (MsgBuffer, ThisName, FALSE); Count++; - ThisName++; + ThisName = AcpiUtGetNextPredefinedMethod (ThisName); } printf ("%u Predefined Names are recognized\n", Count); @@ -822,69 +727,34 @@ ApDisplayReservedNames ( /* * Resource Descriptor names */ - printf ("\nResource Descriptor Predefined Names\n\n"); + printf ("\nPredefined Names for Resource Descriptor Fields\n\n"); Count = 0; - ThisName = ResourceNames; + ThisName = AcpiGbl_ResourceNames; while (ThisName->Info.Name[0]) { - printf ("%4.4s Resource Descriptor\n", ThisName->Info.Name); + NumTypes = AcpiUtGetResourceBitWidth (MsgBuffer, + ThisName->Info.ArgumentList); + + printf ("%4.4s Field is %s bits wide%s\n", + ThisName->Info.Name, MsgBuffer, + (NumTypes > 1) ? " (depending on descriptor type)" : ""); + Count++; ThisName++; } - printf ("%u Resource Descriptor Names are recognized\n", Count); + printf ("%u Resource Descriptor Field Names are recognized\n", Count); /* * Predefined scope names */ - printf ("\nPredefined Scope Names\n\n"); + printf ("\nPredefined Scope/Device Names (automatically created at root)\n\n"); - ThisName = ScopeNames; + ThisName = AcpiGbl_ScopeNames; while (ThisName->Info.Name[0]) { - printf ("%4.4s Scope\n", ThisName->Info.Name); + printf ("%4.4s Scope/Device\n", ThisName->Info.Name); ThisName++; } } - - -/******************************************************************************* - * - * FUNCTION: ApGetExpectedTypes - * - * PARAMETERS: Buffer - Where the formatted string is returned - * ExpectedBTypes - Bitfield of expected data types - * - * RETURN: None, formatted string - * - * DESCRIPTION: Format the expected object types into a printable string. - * - ******************************************************************************/ - -static void -ApGetExpectedTypes ( - char *Buffer, - UINT32 ExpectedBtypes) -{ - UINT32 ThisRtype; - UINT32 i; - UINT32 j; - - - j = 1; - Buffer[0] = 0; - ThisRtype = ACPI_RTYPE_INTEGER; - - for (i = 0; i < ACPI_NUM_RTYPES; i++) - { - /* If one of the expected types, concatenate the name of this type */ - - if (ExpectedBtypes & ThisRtype) - { - ACPI_STRCAT (Buffer, &AcpiRtypeNames[i][j]); - j = 0; /* Use name separator from now on */ - } - ThisRtype <<= 1; /* Next Rtype */ - } -} diff --git a/source/compiler/aslprepkg.c b/source/compiler/aslprepkg.c index e8434d5..da34947 100644 --- a/source/compiler/aslprepkg.c +++ b/source/compiler/aslprepkg.c @@ -126,15 +126,35 @@ ApCheckPackage ( Count = (UINT32) Op->Asl.Value.Integer; /* - * Most packages must have at least one element. The only exception - * is the variable-length package (ACPI_PTYPE1_VAR). + * Many of the variable-length top-level packages are allowed to simply + * have zero elements. This allows the BIOS to tell the host that even + * though the predefined name/method exists, the feature is not supported. + * Other package types require one or more elements. In any case, there + * is no need to continue validation. */ if (!Count) { - if (Package->RetInfo.Type != ACPI_PTYPE1_VAR) + switch (Package->RetInfo.Type) { + case ACPI_PTYPE1_FIXED: + case ACPI_PTYPE1_OPTION: + case ACPI_PTYPE2_PKG_COUNT: + case ACPI_PTYPE2_REV_FIXED: + ApZeroLengthPackage (Predefined->Info.Name, ParentOp); + break; + + case ACPI_PTYPE1_VAR: + case ACPI_PTYPE2: + case ACPI_PTYPE2_COUNT: + case ACPI_PTYPE2_FIXED: + case ACPI_PTYPE2_MIN: + case ACPI_PTYPE2_FIX_VAR: + default: + + break; } + return; } diff --git a/source/compiler/aslresource.c b/source/compiler/aslresource.c index f0b3998..272f9b0 100644 --- a/source/compiler/aslresource.c +++ b/source/compiler/aslresource.c @@ -894,6 +894,7 @@ RsDoOneResourceDescriptor ( if (Rnode) { DescriptorTypeOp->Asl.FinalAmlLength = Rnode->BufferLength; + DescriptorTypeOp->Asl.Extra = ((AML_RESOURCE *) Rnode->Buffer)->DescriptorType; } return (Rnode); diff --git a/source/compiler/asltypes.h b/source/compiler/asltypes.h index 538911f..6f2fb88 100644 --- a/source/compiler/asltypes.h +++ b/source/compiler/asltypes.h @@ -164,12 +164,13 @@ typedef enum ASL_FILE_ASM_SOURCE_OUTPUT, ASL_FILE_C_SOURCE_OUTPUT, ASL_FILE_ASM_INCLUDE_OUTPUT, - ASL_FILE_C_INCLUDE_OUTPUT + ASL_FILE_C_INCLUDE_OUTPUT, + ASL_FILE_C_OFFSET_OUTPUT } ASL_FILE_TYPES; -#define ASL_MAX_FILE_TYPE 13 +#define ASL_MAX_FILE_TYPE 14 #define ASL_NUM_FILES (ASL_MAX_FILE_TYPE + 1) diff --git a/source/compiler/aslwalks.c b/source/compiler/aslwalks.c index 8976a9d..20adf5e 100644 --- a/source/compiler/aslwalks.c +++ b/source/compiler/aslwalks.c @@ -499,13 +499,13 @@ AnOtherSemanticAnalysisWalkBegin ( (PrevArgNode) && (PrevArgNode->Asl.ParseOpcode == PARSEOP_ZERO)) { - AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, + AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); } } else if (ArgNode->Asl.ParseOpcode == PARSEOP_ZERO) { - AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, + AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); } } @@ -523,7 +523,7 @@ AnOtherSemanticAnalysisWalkBegin ( break; default: - AslError (ASL_WARNING, ASL_MSG_RESULT_NOT_USED, + AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); break; } |