diff options
-rw-r--r-- | source/common/adisasm.c | 2 | ||||
-rw-r--r-- | source/compiler/aslcodegen.c | 54 | ||||
-rw-r--r-- | source/compiler/aslcompile.c | 166 | ||||
-rw-r--r-- | source/compiler/aslcompiler.h | 50 | ||||
-rw-r--r-- | source/compiler/asldefine.h | 1 | ||||
-rw-r--r-- | source/compiler/aslerror.c | 16 | ||||
-rw-r--r-- | source/compiler/aslfileio.c | 4 | ||||
-rw-r--r-- | source/compiler/aslfiles.c | 241 | ||||
-rw-r--r-- | source/compiler/aslglobal.h | 47 | ||||
-rw-r--r-- | source/compiler/asllisting.c | 7 | ||||
-rw-r--r-- | source/compiler/aslmain.c | 68 | ||||
-rw-r--r-- | source/compiler/aslmessages.c | 4 | ||||
-rw-r--r-- | source/compiler/aslmessages.h | 4 | ||||
-rw-r--r-- | source/compiler/asloperands.c | 25 | ||||
-rw-r--r-- | source/compiler/asloptions.c | 1 | ||||
-rw-r--r-- | source/compiler/aslstartup.c | 111 | ||||
-rw-r--r-- | source/compiler/aslsupport.l | 4 | ||||
-rw-r--r-- | source/compiler/asltree.c | 70 | ||||
-rw-r--r-- | source/compiler/asltypes.h | 36 | ||||
-rw-r--r-- | source/compiler/aslutils.c | 132 | ||||
-rw-r--r-- | source/compiler/dtcompile.c | 11 | ||||
-rw-r--r-- | source/compiler/prutils.c | 1 |
22 files changed, 816 insertions, 239 deletions
diff --git a/source/common/adisasm.c b/source/common/adisasm.c index 518468b7f..c73208f68 100644 --- a/source/common/adisasm.c +++ b/source/common/adisasm.c @@ -579,7 +579,7 @@ AdDisassembleOneTable ( if (AslGbl_MapfileFlag) { fprintf (stderr, "%14s %s - %u bytes\n", - AslGbl_Files[ASL_FILE_MAP_OUTPUT].ShortDescription, + AslGbl_FileDescs[ASL_FILE_MAP_OUTPUT].ShortDescription, AslGbl_Files[ASL_FILE_MAP_OUTPUT].Filename, FlGetFileSize (ASL_FILE_MAP_OUTPUT)); } diff --git a/source/compiler/aslcodegen.c b/source/compiler/aslcodegen.c index 8edcb668a..80fce583c 100644 --- a/source/compiler/aslcodegen.c +++ b/source/compiler/aslcodegen.c @@ -174,11 +174,11 @@ CgWriteTableHeader ( ACPI_PARSE_OBJECT *Op); static void -CgCloseTable ( - void); +CgWriteNode ( + ACPI_PARSE_OBJECT *Op); static void -CgWriteNode ( +CgUpdateHeader ( ACPI_PARSE_OBJECT *Op); @@ -202,15 +202,12 @@ CgGenerateAmlOutput ( /* Generate the AML output file */ - FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0); - AslGbl_SourceLine = 0; - AslGbl_NextError = AslGbl_ErrorLog; - - TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, - CgAmlWriteWalk, NULL, NULL); + TrWalkParseTree (AslGbl_CurrentDB, + ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_DB_SEPARATELY, CgAmlWriteWalk, + NULL, NULL); DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER2); - CgCloseTable (); + CgUpdateHeader (AslGbl_CurrentDB); } @@ -708,38 +705,13 @@ CgUpdateHeader ( ACPI_OFFSET (ACPI_TABLE_HEADER, Checksum)); FlWriteFile (ASL_FILE_AML_OUTPUT, &Checksum, 1); -} - - -/******************************************************************************* - * - * FUNCTION: CgCloseTable - * - * PARAMETERS: None. - * - * RETURN: None. - * - * DESCRIPTION: Complete the ACPI table by calculating the checksum and - * re-writing each table header. This allows support for - * multiple definition blocks in a single source file. - * - ******************************************************************************/ - -static void -CgCloseTable ( - void) -{ - ACPI_PARSE_OBJECT *Op; - - /* Process all definition blocks */ - - Op = AslGbl_ParseTreeRoot->Asl.Child; - while (Op) - { - CgUpdateHeader (Op); - Op = Op->Asl.Next; - } + /* + * Seek to the end of the file. This is done to support multiple file + * compilation. Doing this simplifies other parts of the codebase because + * it eliminates the need to seek for a different starting place. + */ + FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset + Length); } diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index c46b28da1..21486ae73 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -178,6 +178,9 @@ static void CmDumpAllEvents ( void); +static void +FinishFiles( + BOOLEAN DeleteAmlFile); /******************************************************************************* * @@ -191,13 +194,13 @@ CmDumpAllEvents ( * ******************************************************************************/ -int +ACPI_STATUS CmDoCompile ( void) { - ACPI_STATUS Status; UINT8 FullCompile; UINT8 Event; + ASL_GLOBAL_FILE_NODE *FileNode; FullCompile = UtBeginEvent ("*** Total Compile time ***"); @@ -221,7 +224,7 @@ CmDoCompile ( { UtEndEvent (Event); CmCleanupAndExit (); - return (0); + return (AE_OK); } } UtEndEvent (Event); @@ -239,6 +242,11 @@ CmDoCompile ( { fprintf (stderr, "Compiler aborting due to parser-detected syntax error(s)\n"); + + /* Flag this error in the FileNode for compilation summary */ + + FileNode = FlGetCurrentFileNode (); + FileNode->ParserErrorDetected = TRUE; LsDumpParseTree (); goto ErrorExit; } @@ -292,19 +300,35 @@ CmDoCompile ( OpcAmlOpcodeWalk, NULL); UtEndEvent (Event); - /* - * Now that the input is parsed, we can open the AML output file. - * Note: by default, the name of this file comes from the table - * descriptor within the input file. - */ - Event = UtBeginEvent ("Open AML output file"); - Status = FlOpenAmlOutputFile (AslGbl_OutputFilenamePrefix); - UtEndEvent (Event); - if (ACPI_FAILURE (Status)) - { - AePrintErrorLog (ASL_FILE_STDERR); - return (-1); - } + UtEndEvent (FullCompile); + return (AE_OK); + +ErrorExit: + UtEndEvent (FullCompile); + return (AE_ERROR); +} + + +/******************************************************************************* + * + * FUNCTION: CmDoAslMiddleAndBackEnd + * + * PARAMETERS: None + * + * RETURN: Status of middle-end and back-end + * + * DESCRIPTION: Perform compiler middle-end (type checking and semantic + * analysis) and back-end (code generation) + * + ******************************************************************************/ + +int +CmDoAslMiddleAndBackEnd ( + void) +{ + UINT8 Event; + ACPI_STATUS Status; + /* Interpret and generate all compile-time constants */ @@ -351,7 +375,6 @@ CmDoCompile ( AePrintErrorLog (ASL_FILE_STDOUT); UtDisplaySummary (ASL_FILE_STDOUT); } - UtEndEvent (FullCompile); return (0); } @@ -367,7 +390,7 @@ CmDoCompile ( UtEndEvent (Event); if (ACPI_FAILURE (Status)) { - goto ErrorExit; + return (-1); } /* Namespace cross-reference */ @@ -378,7 +401,7 @@ CmDoCompile ( Status = XfCrossReferenceNamespace (); if (ACPI_FAILURE (Status)) { - goto ErrorExit; + return (-1); } /* Namespace - Check for non-referenced objects */ @@ -486,22 +509,48 @@ CmDoCompile ( Event = UtBeginEvent ("Generate AML code and write output files"); DbgPrint (ASL_DEBUG_OUTPUT, "Writing AML byte code\n\n"); - CgGenerateAmlOutput (); + + AslGbl_CurrentDB = AslGbl_ParseTreeRoot->Asl.Child; + + while (AslGbl_CurrentDB) + { + switch (FlSwitchFileSet(AslGbl_CurrentDB->Asl.Filename)) + { + case SWITCH_TO_DIFFERENT_FILE: + + /* + * reset these parameters when definition blocks belong in + * different files. If they belong in the same file, there is + * no need to reset these parameters + */ + FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0); + AslGbl_SourceLine = 0; + AslGbl_NextError = AslGbl_ErrorLog; + + /* fall-through */ + + case SWITCH_TO_SAME_FILE: + + CgGenerateAmlOutput (); + CmDoOutputFiles (); + AslGbl_CurrentDB = AslGbl_CurrentDB->Asl.Next; + + break; + + default: /* FILE_NOT_FOUND */ + + /* The requested file could not be found. Get out of here */ + + AslGbl_CurrentDB = NULL; + break; + } + } UtEndEvent (Event); Event = UtBeginEvent ("Write optional output files"); - CmDoOutputFiles (); UtEndEvent (Event); - UtEndEvent (FullCompile); - AslCheckExpectedExceptions (); - CmCleanupAndExit (); return (0); - -ErrorExit: - UtEndEvent (FullCompile); - CmCleanupAndExit (); - return (-1); } @@ -808,9 +857,13 @@ void CmCleanupAndExit ( void) { - UINT32 i; BOOLEAN DeleteAmlFile = FALSE; + ASL_GLOBAL_FILE_NODE *CurrentFileNode = AslGbl_FilesList; + + + /* Check if any errors occurred during compile */ + (void) AslCheckForErrorExit (); AePrintErrorLog (ASL_FILE_STDERR); if (AslGbl_DebugFlag) @@ -874,6 +927,54 @@ CmCleanupAndExit ( /* Close all open files */ + while (CurrentFileNode) + { + switch (FlSwitchFileSet(CurrentFileNode->Files[ASL_FILE_INPUT].Filename)) + { + case SWITCH_TO_SAME_FILE: + case SWITCH_TO_DIFFERENT_FILE: + + FinishFiles(DeleteAmlFile); + CurrentFileNode = CurrentFileNode->Next; + break; + + case FILE_NOT_FOUND: + default: + + CurrentFileNode = NULL; + break; + } + } + + /* Final cleanup after compiling one file */ + + if (!AslGbl_DoAslConversion) + { + UtDeleteLocalCaches (); + } +} + + +/******************************************************************************* + * + * FUNCTION: FinishFiles + * + * PARAMETERS: DeleteAmlFile + * + * RETURN: None. + * + * DESCRIPTION: Close all open files, delete AML files depending on the + * function parameter is true. + * + ******************************************************************************/ + +static void +FinishFiles( + BOOLEAN DeleteAmlFile) +{ + UINT32 i; + + /* * Take care with the preprocessor file (.pre), it might be the same * as the "input" file, depending on where the compiler has terminated @@ -924,10 +1025,5 @@ CmCleanupAndExit ( FlDeleteFile (ASL_FILE_SOURCE_OUTPUT); } - /* Final cleanup after compiling one file */ - if (!AslGbl_DoAslConversion) - { - UtDeleteLocalCaches (); - } } diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h index efcee77b5..64e4dd51c 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -254,10 +254,14 @@ void AslCompilerFileHeader ( UINT32 FileId); -int +ACPI_STATUS CmDoCompile ( void); +int +CmDoAslMiddleAndBackEnd ( + void); + void CmDoOutputFiles ( void); @@ -266,6 +270,10 @@ void CmCleanupAndExit ( void); +ACPI_STATUS +AslDoDisassembly ( + void); + /* * aslallocate - memory allocation @@ -875,9 +883,10 @@ ExDoExternal ( /* Values for "Visitation" parameter above */ -#define ASL_WALK_VISIT_DOWNWARD 0x01 -#define ASL_WALK_VISIT_UPWARD 0x02 -#define ASL_WALK_VISIT_TWICE (ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_UPWARD) +#define ASL_WALK_VISIT_DOWNWARD 0x01 +#define ASL_WALK_VISIT_UPWARD 0x02 +#define ASL_WALK_VISIT_DB_SEPARATELY 0x04 +#define ASL_WALK_VISIT_TWICE (ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_UPWARD) /* @@ -1035,6 +1044,11 @@ FlSeekFile ( long Offset); void +FlSeekFileSet ( + UINT32 FileId, + long Offset); + +void FlCloseFile ( UINT32 FileId); @@ -1068,6 +1082,29 @@ ACPI_STATUS FlOpenMiscOutputFiles ( char *InputFilename); +ACPI_STATUS +FlInitOneFile ( + char *InputFilename); + +ASL_FILE_SWITCH_STATUS +FlSwitchFileSet ( + char *InputFilename); + +FILE * +FlGetFileHandle ( + UINT32 OutFileId, + UINT32 InFileId, + char *Filename); + +ASL_GLOBAL_FILE_NODE * +FlGetFileNode ( + UINT32 FileId, + char *Filename); + +ASL_GLOBAL_FILE_NODE * +FlGetCurrentFileNode ( + void); + /* * aslhwmap - hardware map summary */ @@ -1221,6 +1258,11 @@ UtDisplaySummary ( UINT32 FileId); void +UtDisplayOneSummary ( + UINT32 FileId, + BOOLEAN DisplayErrorSummary); + +void UtConvertByteToHex ( UINT8 RawByte, UINT8 *Buffer); diff --git a/source/compiler/asldefine.h b/source/compiler/asldefine.h index 8089d0b95..cffb0af1f 100644 --- a/source/compiler/asldefine.h +++ b/source/compiler/asldefine.h @@ -298,5 +298,4 @@ #define COMMENT_CAPTURE_ON AslGbl_CommentState.CaptureComments = TRUE; #define COMMENT_CAPTURE_OFF AslGbl_CommentState.CaptureComments = FALSE; - #endif /* ASLDEFINE.H */ diff --git a/source/compiler/aslerror.c b/source/compiler/aslerror.c index a2f9fcef1..ff5a7276d 100644 --- a/source/compiler/aslerror.c +++ b/source/compiler/aslerror.c @@ -474,10 +474,12 @@ AePrintErrorSourceLine ( * Use the merged header/source file if present, otherwise * use input file */ - SourceFile = AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle; + SourceFile = FlGetFileHandle (ASL_FILE_SOURCE_OUTPUT, ASL_FILE_SOURCE_OUTPUT, + Enode->SourceFilename); if (!SourceFile) { - SourceFile = AslGbl_Files[ASL_FILE_INPUT].Handle; + SourceFile = FlGetFileHandle (ASL_FILE_INPUT, ASL_FILE_INPUT, + Enode->Filename); } if (SourceFile) @@ -818,6 +820,7 @@ static void AslInitEnode ( ASL_ERROR_MSG *SubError) { ASL_ERROR_MSG *Enode; + ASL_GLOBAL_FILE_NODE *FileNode; *InputEnode = UtLocalCalloc (sizeof (ASL_ERROR_MSG)); @@ -859,6 +862,13 @@ static void AslInitEnode ( { Enode->FilenameLength = 6; } + FileNode = FlGetCurrentFileNode (); + if (!FileNode) + { + return; + } + Enode->SourceFilename = + FileNode->Files[ASL_FILE_SOURCE_OUTPUT].Filename; } } @@ -992,7 +1002,7 @@ AslLogNewError ( } AslGbl_ExceptionCount[ModifiedLevel]++; - if (AslGbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT) + if (!AslGbl_IgnoreErrors && AslGbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT) { printf ("\nMaximum error count (%u) exceeded\n", ASL_MAX_ERROR_COUNT); diff --git a/source/compiler/aslfileio.c b/source/compiler/aslfileio.c index 3243ab519..3db7b5335 100644 --- a/source/compiler/aslfileio.c +++ b/source/compiler/aslfileio.c @@ -177,7 +177,7 @@ FlFileError ( { sprintf (AslGbl_MsgBuffer, "\"%s\" (%s) - %s", AslGbl_Files[FileId].Filename, - AslGbl_Files[FileId].Description, strerror (errno)); + AslGbl_FileDescs[FileId].Description, strerror (errno)); AslCommonError (ASL_ERROR, ErrorId, 0, 0, 0, 0, NULL, AslGbl_MsgBuffer); } @@ -500,7 +500,7 @@ FlDeleteFile ( if (remove (Info->Filename)) { printf ("%s (%s file) ", - Info->Filename, Info->Description); + Info->Filename, AslGbl_FileDescs[FileId].Description); perror ("Could not delete"); } diff --git a/source/compiler/aslfiles.c b/source/compiler/aslfiles.c index 0120af026..e239b52bc 100644 --- a/source/compiler/aslfiles.c +++ b/source/compiler/aslfiles.c @@ -163,6 +163,10 @@ FlOpenIncludeWithPrefix ( ACPI_PARSE_OBJECT *Op, char *Filename); +static BOOLEAN +FlInputFileExists ( + char *InputFilename); + #ifdef ACPI_OBSOLETE_FUNCTIONS ACPI_STATUS FlParseInputPathname ( @@ -172,6 +176,241 @@ FlParseInputPathname ( /******************************************************************************* * + * FUNCTION: FlInitOneFile + * + * PARAMETERS: InputFilename - The user-specified ASL source file to be + * compiled + * + * RETURN: Status + * + * DESCRIPTION: Initialize global file structure for one input file. This file + * structure contains references to input, output, debugging, and + * other miscellaneous files that are associated for a single + * input ASL file. + * + ******************************************************************************/ + +ACPI_STATUS +FlInitOneFile ( + char *InputFilename) +{ + UINT32 i; + ASL_GLOBAL_FILE_NODE *NewFileNode; + + + if (FlInputFileExists(InputFilename)) + { + AslError (ASL_ERROR, ASL_MSG_DUPLICATE_INPUT_FILE, NULL, InputFilename); + return (AE_ALREADY_EXISTS); + } + + NewFileNode = + (ASL_GLOBAL_FILE_NODE *)UtLocalCacheCalloc (sizeof (ASL_GLOBAL_FILE_NODE)); + + if (!NewFileNode) + { + AslError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, NULL, NULL); + return (AE_NO_MEMORY); + } + + NewFileNode->ParserErrorDetected = FALSE; + NewFileNode->Next = AslGbl_FilesList; + + AslGbl_FilesList = NewFileNode; + AslGbl_Files = NewFileNode->Files; + + for (i = 0; i < ASL_NUM_FILES; i++) + { + AslGbl_Files[i].Handle = NULL; + AslGbl_Files[i].Filename = NULL; + } + + AslGbl_Files[ASL_FILE_STDOUT].Handle = stdout; + AslGbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT"; + + if (AslGbl_VerboseErrors) + { + AslGbl_Files[ASL_FILE_STDERR].Handle = stderr; + } + else + { + AslGbl_Files[ASL_FILE_STDERR].Handle = stdout; + } + + AslGbl_Files[ASL_FILE_STDERR].Filename = "STDERR"; + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: FlInputFileExists + * + * PARAMETERS: Filename - File name to be searched + * + * RETURN: Status + * + * DESCRIPTION: Returns true if the file name already exists. + * + ******************************************************************************/ + +static BOOLEAN +FlInputFileExists ( + char *Filename) +{ + ASL_GLOBAL_FILE_NODE *Current = AslGbl_FilesList; + + + while (Current) + { + if (!strcmp (Filename, Current->Files[ASL_FILE_INPUT].Filename)) + { + return (TRUE); + } + Current = Current->Next; + } + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: FlSwitchFileSet + * + * PARAMETERS: Op - Parse node for the LINE asl statement + * + * RETURN: None. + * + * DESCRIPTION: Set the current line number + * + ******************************************************************************/ + +ASL_FILE_SWITCH_STATUS +FlSwitchFileSet ( + char *InputFilename) +{ + ASL_GLOBAL_FILE_NODE *Current = AslGbl_FilesList; + char *PrevFilename = Current->Files[ASL_FILE_INPUT].Filename; + + + while (Current) + { + if (!strcmp(Current->Files[ASL_FILE_INPUT].Filename, InputFilename)) + { + AslGbl_Files = Current->Files; + AslGbl_TableSignature = Current->TableSignature; + AslGbl_TableId = Current->TableId; + if (!strcmp (InputFilename, PrevFilename)) + { + return (SWITCH_TO_SAME_FILE); + } + else + { + return (SWITCH_TO_DIFFERENT_FILE); + } + } + Current = Current->Next; + } + return (FILE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: FlGetFileHandle + * + * PARAMETERS: OutFileId - denotes file type of output handle + * InFileId - denotes file type of the input Filename + * Filename + * + * RETURN: File handle + * + * DESCRIPTION: Get the file handle for a particular filename/FileId. This + * function also allows the caller to specify the file Id of the + * desired type. + * + ******************************************************************************/ + +FILE * +FlGetFileHandle ( + UINT32 OutFileId, + UINT32 InFileId, + char *Filename) +{ + ASL_GLOBAL_FILE_NODE *Current = AslGbl_FilesList; + + + while (Current) + { + if (!strcmp (Current->Files[InFileId].Filename, Filename)) + { + return (Current->Files[OutFileId].Handle); + } + Current = Current->Next; + } + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: FlGetFileNode + * + * PARAMETERS: FileId - denotes file type of the input Filename + * Filename + * + * RETURN: Global file node + * + * DESCRIPTION: Get the file node for a particular filename/FileId. + * + ******************************************************************************/ + +ASL_GLOBAL_FILE_NODE * +FlGetFileNode ( + UINT32 FileId, + char *Filename) +{ + ASL_GLOBAL_FILE_NODE *Current = AslGbl_FilesList; + + + while (Current) + { + if (!strcmp (Current->Files[FileId].Filename, Filename)) + { + return (Current); + } + Current = Current->Next; + } + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: FlGetFileNode + * + * PARAMETERS: FileId - denotes file type of the input Filename + * Filename + * + * RETURN: Global file node + * + * DESCRIPTION: Get the file node for a particular filename/FileId. + * + ******************************************************************************/ + +ASL_GLOBAL_FILE_NODE * +FlGetCurrentFileNode ( + void) +{ + return (FlGetFileNode (ASL_FILE_INPUT,AslGbl_Files[ASL_FILE_INPUT].Filename)); +} + + +/******************************************************************************* + * * FUNCTION: FlSetLineNumber * * PARAMETERS: Op - Parse node for the LINE asl statement @@ -426,8 +665,6 @@ FlOpenIncludeWithPrefix ( IncludeFile = fopen (Pathname, "r"); if (!IncludeFile) { - fprintf (stderr, "Could not open include file %s\n", Pathname); - ACPI_FREE (Pathname); return (NULL); } diff --git a/source/compiler/aslglobal.h b/source/compiler/aslglobal.h index bc7358cd6..eebf71502 100644 --- a/source/compiler/aslglobal.h +++ b/source/compiler/aslglobal.h @@ -172,28 +172,27 @@ UINT32 AslGbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] = {0,0,0,0,0,0}; /* Table below must match ASL_FILE_TYPES in asltypes.h */ - -ASL_FILE_INFO AslGbl_Files [ASL_NUM_FILES] = +ASL_FILE_DESC AslGbl_FileDescs [ASL_NUM_FILES] = { - {NULL, NULL, "stdout: ", "Standard Output"}, - {NULL, NULL, "stderr: ", "Standard Error"}, - {NULL, NULL, "Table Input: ", "Source Input"}, - {NULL, NULL, "Binary Output:", "AML Output"}, - {NULL, NULL, "Source Output:", "Source Output"}, - {NULL, NULL, "Preprocessor: ", "Preprocessor Output"}, - {NULL, NULL, "Preprocessor: ", "Preprocessor Temp File"}, - {NULL, NULL, "Listing File: ", "Listing Output"}, - {NULL, NULL, "Hex Dump: ", "Hex Table Output"}, - {NULL, NULL, "Namespace: ", "Namespace Output"}, - {NULL, NULL, "Debug File: ", "Debug Output"}, - {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, "Offset Table: ", "C Offset Table Output"}, - {NULL, NULL, "Device Map: ", "Device Map Output"}, - {NULL, NULL, "Cross Ref: ", "Cross-reference Output"}, - {NULL, NULL, "Converter db :", "Converter debug Output"} + {"stdout: ", "Standard Output"}, + {"stderr: ", "Standard Error"}, + {"Table Input: ", "Source Input"}, + {"Binary Output:", "AML Output"}, + {"Source Output:", "Source Output"}, + {"Preprocessor: ", "Preprocessor Output"}, + {"Preprocessor: ", "Preprocessor Temp File"}, + {"Listing File: ", "Listing Output"}, + {"Hex Dump: ", "Hex Table Output"}, + {"Namespace: ", "Namespace Output"}, + {"Debug File: ", "Debug Output"}, + {"ASM Source: ", "Assembly Code Output"}, + {"C Source: ", "C Code Output"}, + {"ASM Include: ", "Assembly Header Output"}, + {"C Include: ", "C Header Output"}, + {"Offset Table: ", "C Offset Table Output"}, + {"Device Map: ", "Device Map Output"}, + {"Cross Ref: ", "Cross-reference Output"}, + {"Converter dbg:", "Converter debug Output"} }; /* Table below must match the defines with the same names in actypes.h */ @@ -225,8 +224,8 @@ const char *AslGbl_OpFlagNames[ACPI_NUM_OP_FLAGS] = }; #else +extern ASL_FILE_DESC AslGbl_FileDescs [ASL_NUM_FILES]; extern UINT32 AslGbl_ExceptionCount[ASL_NUM_REPORT_LEVELS]; -extern ASL_FILE_INFO AslGbl_Files [ASL_NUM_FILES]; extern const char *AslGbl_OpFlagNames[ACPI_NUM_OP_FLAGS]; #endif @@ -269,7 +268,6 @@ ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_CurrentColumn, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_CurrentLineNumber, 1); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_LogicalLineNumber, 1); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_CurrentLineOffset, 0); -ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_OriginalInputFileSize, 0); ASL_EXTERN UINT8 ASL_INIT_GLOBAL (AslGbl_SyntaxError, 0); /* Exception reporting */ @@ -385,6 +383,7 @@ ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_SourceLine, 0); ASL_EXTERN UINT8 ASL_INIT_GLOBAL (AslGbl_FileType, 0); ASL_EXTERN char ASL_INIT_GLOBAL (*AslGbl_Signature, NULL); ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*AslGbl_ParseTreeRoot, NULL); +ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*AslGbl_CurrentDB, NULL); ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*AslGbl_ExternalsListHead, NULL); ASL_EXTERN ASL_LISTING_NODE ASL_INIT_GLOBAL (*AslGbl_ListingNode, NULL); ASL_EXTERN ACPI_PARSE_OBJECT *AslGbl_FirstLevelInsertionNode; @@ -403,6 +402,8 @@ ASL_EXTERN UINT16 ASL_INIT_GLOBAL (AslGbl_PruneType, 0); ASL_EXTERN ASL_FILE_NODE ASL_INIT_GLOBAL (*AslGbl_IncludeFileStack, NULL); ASL_EXTERN char ASL_INIT_GLOBAL (*AslGbl_TableSignature, "NO_SIG"); ASL_EXTERN char ASL_INIT_GLOBAL (*AslGbl_TableId, "NO_ID"); +ASL_EXTERN ASL_FILE_INFO ASL_INIT_GLOBAL (*AslGbl_Files, NULL); +ASL_EXTERN ASL_GLOBAL_FILE_NODE ASL_INIT_GLOBAL (*AslGbl_FilesList, NULL); /* Specific to the -q option */ diff --git a/source/compiler/asllisting.c b/source/compiler/asllisting.c index df3b7587a..7bc118bc2 100644 --- a/source/compiler/asllisting.c +++ b/source/compiler/asllisting.c @@ -254,6 +254,7 @@ static void LsGenerateListing ( UINT32 FileId) { + UINT32 WalkMode = ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_DB_SEPARATELY; /* Start at the beginning of both the source and AML files */ @@ -271,7 +272,7 @@ LsGenerateListing ( LsDoOffsetTableHeader (FileId); - TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, + TrWalkParseTree (AslGbl_CurrentDB, WalkMode, LsAmlOffsetWalk, NULL, (void *) ACPI_TO_POINTER (FileId)); LsDoOffsetTableFooter (FileId); return; @@ -279,7 +280,7 @@ LsGenerateListing ( /* Process all parse nodes */ - TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, + TrWalkParseTree (AslGbl_CurrentDB, WalkMode, LsAmlListingWalk, NULL, (void *) ACPI_TO_POINTER (FileId)); /* Final processing */ @@ -847,7 +848,7 @@ LsFinishSourceListing ( FlPrintFile (FileId, "\n\nSummary of errors and warnings\n\n"); AePrintErrorLog (FileId); FlPrintFile (FileId, "\n"); - UtDisplaySummary (FileId); + UtDisplayOneSummary (FileId, TRUE); FlPrintFile (FileId, "\n"); } } diff --git a/source/compiler/aslmain.c b/source/compiler/aslmain.c index 26f4a0c49..56a6e7001 100644 --- a/source/compiler/aslmain.c +++ b/source/compiler/aslmain.c @@ -255,6 +255,14 @@ main ( } } + /* ACPICA subsystem initialization */ + + Status = AdInitialize (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + /* Process each pathname/filename in the list, with possible wildcards */ @@ -280,6 +288,48 @@ main ( Index2++; } + if (!AcpiGbl_DisasmFlag) + { + CmDoAslMiddleAndBackEnd (); + + /* + * At this point, all semantic analysis has been completed. Check + * expected error messages before cleanup or conversion. + */ + AslCheckExpectedExceptions (); + } + + /* ASL-to-ASL+ conversion - Perform immediate disassembly */ + + if (AslGbl_DoAslConversion) + { + /* re-initialize ACPICA subsystem for disassemble*/ + + Status = AdInitialize (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + AcpiGbl_DisasmFlag = TRUE; + /* + * New input file is the output AML file from above. + * New output is from the input ASL file from above. + */ + AslGbl_OutputFilenamePrefix = AslGbl_Files[ASL_FILE_INPUT].Filename; + CvDbgPrint ("OUTPUTFILENAME: %s\n", AslGbl_OutputFilenamePrefix); + AslGbl_Files[ASL_FILE_INPUT].Filename = + AslGbl_Files[ASL_FILE_AML_OUTPUT].Filename; + AcpiGbl_DisasmFlag = TRUE; + fprintf (stderr, "\n"); + AslDoDisassembly (); + + /* delete the AML file. This AML file should never be utilized by AML interpreters. */ + + FlDeleteFile (ASL_FILE_AML_OUTPUT); + } + + CleanupAndExit: @@ -290,6 +340,9 @@ CleanupAndExit: { AcpiDmClearExternalFileList(); } + (void) AcpiTerminate (); + CmCleanupAndExit (); + return (ReturnStatus); } @@ -372,9 +425,6 @@ static void AslInitialize ( void) { - UINT32 i; - - AcpiGbl_DmOpt_Verbose = FALSE; /* Default integer width is 32 bits */ @@ -382,16 +432,4 @@ AslInitialize ( AcpiGbl_IntegerBitWidth = 32; AcpiGbl_IntegerNybbleWidth = 8; AcpiGbl_IntegerByteWidth = 4; - - for (i = 0; i < ASL_NUM_FILES; i++) - { - AslGbl_Files[i].Handle = NULL; - AslGbl_Files[i].Filename = NULL; - } - - AslGbl_Files[ASL_FILE_STDOUT].Handle = stdout; - AslGbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT"; - - AslGbl_Files[ASL_FILE_STDERR].Handle = stderr; - AslGbl_Files[ASL_FILE_STDERR].Filename = "STDERR"; } diff --git a/source/compiler/aslmessages.c b/source/compiler/aslmessages.c index 0f31c655a..4524c4c81 100644 --- a/source/compiler/aslmessages.c +++ b/source/compiler/aslmessages.c @@ -353,8 +353,8 @@ const char *AslCompilerMsgs [] = /* ASL_MSG_NULL_RESOURCE_TEMPLATE */ "Empty Resource Template (END_TAG only)", /* ASL_MSG_FOUND_HERE */ "Original name creation/declaration below: ", /* ASL_MSG_ILLEGAL_RECURSION */ "Illegal recursive call to method that creates named objects", -/* ASL_MSG_PLACE_HOLDER_00 */ "", /* TODO: fill in this slot with a new error message */ -/* ASL_MSG_PLACE_HOLDER_01 */ "", /* TODO: fill in this slot with a new error message */ +/* ASL_MSG_DUPLICATE_INPUT_FILE */ "Duplicate input files detected:", +/* ASL_MSG_WARNING_AS_ERROR */ "Warnings detected during compilation", /* ASL_MSG_OEM_TABLE_ID */ "Invalid OEM Table ID", /* ASL_MSG_OEM_ID */ "Invalid OEM ID", /* ASL_MSG_UNLOAD */ "Unload is not supported by all operating systems", diff --git a/source/compiler/aslmessages.h b/source/compiler/aslmessages.h index 817e192e0..4ada896dc 100644 --- a/source/compiler/aslmessages.h +++ b/source/compiler/aslmessages.h @@ -355,8 +355,8 @@ typedef enum ASL_MSG_NULL_RESOURCE_TEMPLATE, ASL_MSG_FOUND_HERE, ASL_MSG_ILLEGAL_RECURSION, - ASL_MSG_PLACE_HOLDER_00, - ASL_MSG_PLACE_HOLDER_01, + ASL_MSG_DUPLICATE_INPUT_FILE, + ASL_MSG_WARNING_AS_ERROR, ASL_MSG_OEM_TABLE_ID, ASL_MSG_OEM_ID, ASL_MSG_UNLOAD, diff --git a/source/compiler/asloperands.c b/source/compiler/asloperands.c index 67e16fd58..4f4b636d5 100644 --- a/source/compiler/asloperands.c +++ b/source/compiler/asloperands.c @@ -1045,6 +1045,7 @@ OpnDoDefinitionBlock ( ACPI_SIZE Length; UINT32 i; char *Filename; + ACPI_STATUS Status; /* @@ -1063,6 +1064,12 @@ OpnDoDefinitionBlock ( (AslGbl_UseDefaultAmlFilename)) { /* + * The walk may traverse multiple definition blocks. Switch files + * to ensure that the correct files are manipulated. + */ + FlSwitchFileSet (Op->Asl.Filename); + + /* * We will use the AML filename that is embedded in the source file * for the output filename. */ @@ -1076,6 +1083,22 @@ OpnDoDefinitionBlock ( AslGbl_OutputFilenamePrefix = Filename; UtConvertBackslashes (AslGbl_OutputFilenamePrefix); + + /* + * Use the definition block file parameter instead of the input + * filename. Since all files were opened previously, remove the + * existing file and open a new file with the name of this + * definiton block parameter. Since AML code generation has yet + * to happen, the previous file can be removed without any impacts. + */ + FlCloseFile (ASL_FILE_AML_OUTPUT); + FlDeleteFile (ASL_FILE_AML_OUTPUT); + Status = FlOpenAmlOutputFile (AslGbl_OutputFilenamePrefix); + if (ACPI_FAILURE (Status)) + { + AslError (ASL_ERROR, ASL_MSG_OUTPUT_FILE_OPEN, NULL, NULL); + return; + } } Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; @@ -1086,6 +1109,7 @@ OpnDoDefinitionBlock ( Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; if (Child->Asl.Value.String) { + AslGbl_FilesList->TableSignature = Child->Asl.Value.String; AslGbl_TableSignature = Child->Asl.Value.String; if (strlen (AslGbl_TableSignature) != ACPI_NAMESEG_SIZE) { @@ -1138,6 +1162,7 @@ OpnDoDefinitionBlock ( AslGbl_TableId = UtLocalCacheCalloc (Length + 1); strcpy (AslGbl_TableId, Child->Asl.Value.String); + AslGbl_FilesList->TableId = AslGbl_TableId; /* * Convert anything non-alphanumeric to an underscore. This diff --git a/source/compiler/asloptions.c b/source/compiler/asloptions.c index dc0b9079b..dc00e1d20 100644 --- a/source/compiler/asloptions.c +++ b/source/compiler/asloptions.c @@ -896,7 +896,6 @@ AslDoOptions ( */ AslGbl_VerboseErrors = FALSE; AslGbl_DoSignon = FALSE; - AslGbl_Files[ASL_FILE_STDERR].Handle = stdout; break; case 'o': diff --git a/source/compiler/aslstartup.c b/source/compiler/aslstartup.c index 8afc72e71..dfb26dcbe 100644 --- a/source/compiler/aslstartup.c +++ b/source/compiler/aslstartup.c @@ -165,10 +165,6 @@ static UINT8 AslDetectSourceFileType ( ASL_FILE_INFO *Info); -static ACPI_STATUS -AslDoDisassembly ( - void); - /* Globals */ @@ -227,12 +223,6 @@ AslInitializeGlobals ( AslGbl_ExceptionCount[i] = 0; } - for (i = ASL_FILE_INPUT; i <= ASL_MAX_FILE_TYPE; i++) - { - AslGbl_Files[i].Handle = NULL; - AslGbl_Files[i].Filename = NULL; - } - if (AcpiGbl_CaptureComments) { AslGbl_CommentState.SpacesBefore = 0; @@ -343,25 +333,19 @@ Cleanup: * RETURN: Status * * DESCRIPTION: Initiate AML file disassembly. Uses ACPICA subsystem to build - * namespace. + * namespace. This function assumes that the ACPI subsystem has + * been initialized. The caller of the initialization will also + * terminate the ACPI subsystem. * ******************************************************************************/ -static ACPI_STATUS +ACPI_STATUS AslDoDisassembly ( void) { ACPI_STATUS Status; - /* ACPICA subsystem initialization */ - - Status = AdInitialize (); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - Status = AcpiAllocateRootTable (4); if (ACPI_FAILURE (Status)) { @@ -385,10 +369,9 @@ AslDoDisassembly ( AcpiDmUnresolvedWarning (0); - /* Shutdown compiler and ACPICA subsystem */ + /* Clear Error log */ AeClearErrorLog (); - (void) AcpiTerminate (); /* * AslGbl_Files[ASL_FILE_INPUT].Filename was replaced with the @@ -401,11 +384,6 @@ AslDoDisassembly ( return (AE_CTRL_CONTINUE); } - /* No need to free the filename string */ - - AslGbl_Files[ASL_FILE_INPUT].Filename = NULL; - - UtDeleteLocalCaches (); return (AE_OK); } @@ -427,6 +405,8 @@ AslDoOneFile ( char *Filename) { ACPI_STATUS Status; + UINT8 Event; + ASL_GLOBAL_FILE_NODE *FileNode; /* Re-initialize "some" compiler/preprocessor globals */ @@ -445,6 +425,18 @@ AslDoOneFile ( return (Status); } + /* + * There was an input file detected at this point. Each input ASL file is + * associated with one global file node consisting of the input file and + * all output files associated with it. This is useful when compiling + * multiple files in one command. + */ + Status = FlInitOneFile(Filename); + if (ACPI_FAILURE (Status)) + { + return (AE_ERROR); + } + /* Take a copy of the input filename, convert any backslashes */ AslGbl_Files[ASL_FILE_INPUT].Filename = @@ -464,7 +456,12 @@ AslDoOneFile ( return (AE_ERROR); } - AslGbl_OriginalInputFileSize = FlGetFileSize (ASL_FILE_INPUT); + FileNode = FlGetCurrentFileNode(); + if (!FileNode) + { + return (AE_ERROR); + } + FileNode->OriginalInputFileSize = FlGetFileSize (ASL_FILE_INPUT); /* Determine input file type */ @@ -483,6 +480,22 @@ AslDoOneFile ( AslGbl_OutputFilenamePrefix = AslGbl_Files[ASL_FILE_INPUT].Filename; } + /* + * Open the output file. Note: by default, the name of this file comes from + * the table descriptor within the input file. + */ + if (AslGbl_FileType == ASL_INPUT_TYPE_ASCII_ASL) + { + Event = UtBeginEvent ("Open AML output file"); + Status = FlOpenAmlOutputFile (AslGbl_OutputFilenamePrefix); + UtEndEvent (Event); + if (ACPI_FAILURE (Status)) + { + AePrintErrorLog (ASL_FILE_STDERR); + return (AE_ERROR); + } + } + /* Open the optional output files (listings, etc.) */ Status = FlOpenMiscOutputFiles (AslGbl_OutputFilenamePrefix); @@ -533,20 +546,7 @@ AslDoOneFile ( */ case ASL_INPUT_TYPE_ASCII_ASL: - /* ACPICA subsystem initialization */ - - Status = AdInitialize (); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - (void) CmDoCompile (); - (void) AcpiTerminate (); - - /* Check if any errors occurred during compile */ - - Status = AslCheckForErrorExit (); + Status = CmDoCompile (); if (ACPI_FAILURE (Status)) { return (Status); @@ -557,26 +557,11 @@ AslDoOneFile ( AeClearErrorLog (); PrTerminatePreprocessor (); - /* ASL-to-ASL+ conversion - Perform immediate disassembly */ - - if (AslGbl_DoAslConversion) - { - /* - * New input file is the output AML file from above. - * New output is from the input ASL file from above. - */ - AslGbl_OutputFilenamePrefix = AslGbl_Files[ASL_FILE_INPUT].Filename; - CvDbgPrint ("OUTPUTFILENAME: %s\n", AslGbl_OutputFilenamePrefix); - AslGbl_Files[ASL_FILE_INPUT].Filename = - AslGbl_Files[ASL_FILE_AML_OUTPUT].Filename; - AcpiGbl_DisasmFlag = TRUE; - fprintf (stderr, "\n"); - AslDoDisassembly (); - - /* delete the AML file. This AML file should never be utilized by AML interpreters. */ - - FlDeleteFile (ASL_FILE_AML_OUTPUT); - } + /* + * At this point, we know how many lines are in the input file. Save it + * to display for post-compilation summary. + */ + FileNode->TotalLineCount = AslGbl_CurrentLineNumber; return (AE_OK); @@ -644,6 +629,8 @@ AslCheckForErrorExit ( (AslGbl_ExceptionCount[ASL_WARNING2] > 0) || (AslGbl_ExceptionCount[ASL_WARNING3] > 0)) { + AslError (ASL_ERROR, ASL_MSG_WARNING_AS_ERROR, NULL, + "(reporting warnings as errors)"); return (AE_ERROR); } } diff --git a/source/compiler/aslsupport.l b/source/compiler/aslsupport.l index 5cac84dc6..29a4794e0 100644 --- a/source/compiler/aslsupport.l +++ b/source/compiler/aslsupport.l @@ -534,12 +534,16 @@ count ( AslGbl_TotalKeywords++; AslGbl_TotalNamedObjects++; + AslGbl_FilesList->TotalKeywords++; + AslGbl_FilesList->TotalNamedObjects++; break; case 3: AslGbl_TotalKeywords++; AslGbl_TotalExecutableOpcodes++; + AslGbl_FilesList->TotalKeywords++; + AslGbl_FilesList->TotalExecutableOpcodes++; break; default: diff --git a/source/compiler/asltree.c b/source/compiler/asltree.c index 6bb40888e..62efc5fa9 100644 --- a/source/compiler/asltree.c +++ b/source/compiler/asltree.c @@ -462,6 +462,7 @@ TrLinkOpChildren ( { ACPI_PARSE_OBJECT *Child; ACPI_PARSE_OBJECT *PrevChild; + ACPI_PARSE_OBJECT *LastSibling; va_list ap; UINT32 i; BOOLEAN FirstChild; @@ -480,8 +481,18 @@ TrLinkOpChildren ( { case PARSEOP_ASL_CODE: - AslGbl_ParseTreeRoot = Op; - Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + if (!AslGbl_ParseTreeRoot) + { + DbgPrint (ASL_PARSE_OUTPUT, "Creating first Definition Block\n"); + AslGbl_ParseTreeRoot = Op; + Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + } + else + { + DbgPrint (ASL_PARSE_OUTPUT, "Creating subsequent Definition Block\n"); + Op = AslGbl_ParseTreeRoot; + } + DbgPrint (ASL_PARSE_OUTPUT, "ASLCODE (Tree Completed)->"); break; @@ -560,7 +571,27 @@ TrLinkOpChildren ( if (FirstChild) { FirstChild = FALSE; - Op->Asl.Child = Child; + + /* + * In the case that multiple definition blocks are being compiled, + * append the definition block to the end of the child list as the + * last sibling. This is done to facilitate namespace cross- + * reference between multiple definition blocks. + */ + if (Op->Asl.Child && + (Op->Asl.Child->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK)) + { + LastSibling = Op->Asl.Child; + while (LastSibling->Asl.Next) + { + LastSibling = LastSibling->Asl.Next; + } + LastSibling->Asl.Next = Child; + } + else + { + Op->Asl.Child = Child; + } } /* Point all children to parent */ @@ -825,6 +856,8 @@ TrWalkParseTree ( BOOLEAN OpPreviouslyVisited; ACPI_PARSE_OBJECT *StartOp = Op; ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Restore = NULL; + BOOLEAN WalkOneDefinitionBlock = Visitation & ASL_WALK_VISIT_DB_SEPARATELY; if (!AslGbl_ParseTreeRoot) @@ -835,7 +868,13 @@ TrWalkParseTree ( Level = 0; OpPreviouslyVisited = FALSE; - switch (Visitation) + if (Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK && + WalkOneDefinitionBlock) + { + Restore = Op->Asl.Next; + Op->Asl.Next = NULL; + } + switch (Visitation & ~ASL_WALK_VISIT_DB_SEPARATELY) { case ASL_WALK_VISIT_DOWNWARD: @@ -861,7 +900,7 @@ TrWalkParseTree ( { /* Exit immediately on any error */ - return (Status); + goto ErrorExit; } } @@ -907,7 +946,7 @@ TrWalkParseTree ( Status = AscendingCallback (Op, Level, Context); if (ACPI_FAILURE (Status)) { - return (Status); + goto ErrorExit; } } else @@ -956,7 +995,7 @@ TrWalkParseTree ( Status = AscendingCallback (Op, Level, Context); if (ACPI_FAILURE (Status)) { - return (Status); + goto ErrorExit; } } else @@ -979,7 +1018,7 @@ TrWalkParseTree ( { /* Exit immediately on any error */ - return (Status); + goto ErrorExit; } } @@ -1018,5 +1057,20 @@ TrWalkParseTree ( /* If we get here, the walk completed with no errors */ + if (Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK && + WalkOneDefinitionBlock) + { + Op->Asl.Next = Restore; + } + return (AE_OK); + +ErrorExit: + + if (Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK && + WalkOneDefinitionBlock) + { + Op->Asl.Next = Restore; + } + return (Status); } diff --git a/source/compiler/asltypes.h b/source/compiler/asltypes.h index 628b2d378..36484c35b 100644 --- a/source/compiler/asltypes.h +++ b/source/compiler/asltypes.h @@ -245,8 +245,6 @@ typedef struct asl_file_info { FILE *Handle; char *Filename; - const char *ShortDescription; - const char *Description; } ASL_FILE_INFO; @@ -258,6 +256,11 @@ typedef struct asl_file_status } ASL_FILE_STATUS; +typedef UINT32 ASL_FILE_SWITCH_STATUS; /* File switch status */ +#define SWITCH_TO_DIFFERENT_FILE 0 +#define SWITCH_TO_SAME_FILE 1 +#define FILE_NOT_FOUND 2 + /* * File types. Note: Any changes to this table must also be reflected * in the Gbl_Files array. @@ -295,10 +298,16 @@ typedef enum } ASL_FILE_TYPES; - #define ASL_MAX_FILE_TYPE 18 #define ASL_NUM_FILES (ASL_MAX_FILE_TYPE + 1) +typedef struct asl_file_desc +{ + const char *ShortDescription; + const char *Description; +} ASL_FILE_DESC; + + /* Name suffixes used to create filenames for output files */ #define FILE_SUFFIX_ASL_CODE "asl" @@ -343,6 +352,11 @@ typedef struct asl_include_dir * An entry in the exception list, one for each error/warning * Note: SubError nodes would be treated with the same messageId and Level * as the parent error node. + * + * The source filename represents the name of the .src of where the error + * occurred. This is useful for errors that occur inside of include files. + * Since include files aren't recorded as a part of the global files list, + * this provides a way to get the included file. */ typedef struct asl_error_msg { @@ -355,6 +369,7 @@ typedef struct asl_error_msg struct asl_error_msg *SubError; char *Filename; char *SourceLine; + char *SourceFilename; UINT32 FilenameLength; UINT16 MessageId; UINT8 Level; @@ -479,4 +494,19 @@ typedef struct asl_file_node } ASL_FILE_NODE; +typedef struct asl_files_node +{ + struct asl_file_info Files[ASL_NUM_FILES]; + struct asl_files_node *Next; + char *TableSignature; + char *TableId; + UINT64 TotalLineCount; + UINT64 OriginalInputFileSize; + UINT64 TotalKeywords; + UINT64 TotalNamedObjects; + UINT64 TotalExecutableOpcodes; + BOOLEAN ParserErrorDetected; + +} ASL_GLOBAL_FILE_NODE; + #endif /* __ASLTYPES_H */ diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index 6b0d5eff3..fb043cca5 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -174,6 +174,10 @@ UtAttachNameseg ( ACPI_PARSE_OBJECT *Op, char *Name); +static void +UtDisplayErrorSummary ( + UINT32 FileId); + /******************************************************************************* * @@ -520,21 +524,23 @@ UtSetParseOpName ( /******************************************************************************* * - * FUNCTION: UtDisplaySummary + * FUNCTION: UtDisplayOneSummary * * PARAMETERS: FileID - ID of outpout file * * RETURN: None * - * DESCRIPTION: Display compilation statistics + * DESCRIPTION: Display compilation statistics for one input file * ******************************************************************************/ void -UtDisplaySummary ( - UINT32 FileId) +UtDisplayOneSummary ( + UINT32 FileId, + BOOLEAN DisplayErrorSummary) { UINT32 i; + ASL_GLOBAL_FILE_NODE *FileNode; if (FileId != ASL_FILE_STDOUT) @@ -565,25 +571,41 @@ UtDisplaySummary ( } else { - FlPrintFile (FileId, - "%-14s %s - %u lines, %u bytes, %u keywords\n", - "ASL Input:", - AslGbl_Files[ASL_FILE_INPUT].Filename, AslGbl_CurrentLineNumber, - AslGbl_OriginalInputFileSize, AslGbl_TotalKeywords); + FileNode = FlGetCurrentFileNode (); + if (!FileNode) + { + fprintf (stderr, "Summary could not be generated"); + return; + } + if (FileNode->ParserErrorDetected) + { + FlPrintFile (FileId, + "%-14s %s - Compilation aborted due to parser-detected syntax error(s)\n", + "ASL Input:", AslGbl_Files[ASL_FILE_INPUT].Filename); + } + else + { + FlPrintFile (FileId, + "%-14s %s - %u lines, %u bytes, %u keywords\n", + "ASL Input:", + AslGbl_Files[ASL_FILE_INPUT].Filename, FileNode->TotalLineCount, + FileNode->OriginalInputFileSize, FileNode->TotalKeywords); - /* AML summary */ + /* AML summary */ - if ((AslGbl_ExceptionCount[ASL_ERROR] == 0) || (AslGbl_IgnoreErrors)) - { - if (AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle) + if ((AslGbl_ExceptionCount[ASL_ERROR] == 0) || (AslGbl_IgnoreErrors)) { - FlPrintFile (FileId, - "%-14s %s - %u bytes, %u named objects, " - "%u executable opcodes\n", - "AML Output:", - AslGbl_Files[ASL_FILE_AML_OUTPUT].Filename, - FlGetFileSize (ASL_FILE_AML_OUTPUT), - AslGbl_TotalNamedObjects, AslGbl_TotalExecutableOpcodes); + if (AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle) + { + FlPrintFile (FileId, + "%-14s %s - %u bytes, %u named objects, " + "%u executable opcodes\n", + "AML Output:", + AslGbl_Files[ASL_FILE_AML_OUTPUT].Filename, + FlGetFileSize (ASL_FILE_AML_OUTPUT), + FileNode->TotalNamedObjects, + FileNode->TotalExecutableOpcodes); + } } } } @@ -612,12 +634,38 @@ UtDisplaySummary ( } FlPrintFile (FileId, "%14s %s - %u bytes\n", - AslGbl_Files[i].ShortDescription, + AslGbl_FileDescs[i].ShortDescription, AslGbl_Files[i].Filename, FlGetFileSize (i)); } - /* Error summary */ + /* + * Optionally emit an error summary for a file. This is used to enhance the + * appearance of listing files. + */ + if (DisplayErrorSummary) + { + UtDisplayErrorSummary (FileId); + } +} + + +/******************************************************************************* + * + * FUNCTION: UtDisplayErrorSummary + * + * PARAMETERS: FileID - ID of outpout file + * + * RETURN: None + * + * DESCRIPTION: Display compilation statistics for all input files + * + ******************************************************************************/ + +static void +UtDisplayErrorSummary ( + UINT32 FileId) +{ FlPrintFile (FileId, "\nCompilation complete. %u Errors, %u Warnings, %u Remarks", AslGbl_ExceptionCount[ASL_ERROR], @@ -643,6 +691,46 @@ UtDisplaySummary ( /******************************************************************************* * + * FUNCTION: UtDisplaySummary + * + * PARAMETERS: FileID - ID of outpout file + * + * RETURN: None + * + * DESCRIPTION: Display compilation statistics for all input files + * + ******************************************************************************/ + +void +UtDisplaySummary ( + UINT32 FileId) +{ + ASL_GLOBAL_FILE_NODE *Current = AslGbl_FilesList; + + + while (Current) + { + switch (FlSwitchFileSet(Current->Files[ASL_FILE_INPUT].Filename)) + { + case SWITCH_TO_SAME_FILE: + case SWITCH_TO_DIFFERENT_FILE: + + UtDisplayOneSummary (FileId, FALSE); + Current = Current->Next; + break; + + case FILE_NOT_FOUND: + default: + + Current = NULL; + break; + } + } + UtDisplayErrorSummary (FileId); +} + +/******************************************************************************* + * * FUNCTION: UtCheckIntegerRange * * PARAMETERS: Op - Integer parse node diff --git a/source/compiler/dtcompile.c b/source/compiler/dtcompile.c index 95fcb2d46..09cb3e6c4 100644 --- a/source/compiler/dtcompile.c +++ b/source/compiler/dtcompile.c @@ -240,8 +240,7 @@ DtDoCompile ( DtError (ASL_ERROR, ASL_MSG_SYNTAX, NULL, "Input file does not appear to be an ASL or data table source file"); - Status = AE_ERROR; - goto CleanupAndExit; + return (AE_ERROR); } Event = UtBeginEvent ("Compile parse tree"); @@ -259,7 +258,7 @@ DtDoCompile ( DtError (ASL_ERROR, ASL_MSG_SYNTAX, NULL, "Could not compile input file"); - goto CleanupAndExit; + return (Status); } /* Create/open the binary output file */ @@ -268,7 +267,7 @@ DtDoCompile ( Status = FlOpenAmlOutputFile (AslGbl_OutputFilenamePrefix); if (ACPI_FAILURE (Status)) { - goto CleanupAndExit; + return (Status); } /* Write the binary, then the optional hex file */ @@ -277,10 +276,6 @@ DtDoCompile ( HxDoHexOutput (); DtWriteTableToListing (); -CleanupAndExit: - - AcpiUtDeleteCaches (); - CmCleanupAndExit (); return (Status); } diff --git a/source/compiler/prutils.c b/source/compiler/prutils.c index b5ddfa9ff..f3d615ad5 100644 --- a/source/compiler/prutils.c +++ b/source/compiler/prutils.c @@ -455,7 +455,6 @@ PrOpenIncludeWithPrefix ( IncludeFile = fopen (Pathname, OpenMode); if (!IncludeFile) { - fprintf (stderr, "Could not open include file %s\n", Pathname); return (NULL); } |