From 703db490eb5bc70a153a1f8d12c0c145bbd914ab Mon Sep 17 00:00:00 2001 From: Al Stone Date: May 11 2019 00:05:46 +0000 Subject: New upstream version 20190405 --- diff --git a/changes.txt b/changes.txt index f8de9aa..7be71e6 100644 --- a/changes.txt +++ b/changes.txt @@ -1,4 +1,38 @@ ---------------------------------------- +05 April 2019. Summary of changes for version 20190405: + + +1) ACPICA kernel-resident subsystem: + +Event Manager: History: Commit 18996f2db918 ("ACPICA: Events: Stop +unconditionally clearing ACPI IRQs during suspend/resume") was added +earlier to stop clearing of event status bits unconditionally on suspend +and resume paths. Though this change fixed an issue on suspend path, it +introduced regressions on several resume paths. In the case of S0ix, +events are enabled as part of device suspend path. If status bits for the +events are set when they are enabled, it could result in premature wake +from S0ix. If status is cleared for any event that is being enabled so +that any stale events are cleared out. In case of S0ix, events are +enabled as part of device suspend path. If status bits for the events are +set when they are enabled, it could result in premature wake from S0ix. + +This change ensures that status is cleared for any event that is being +enabled so that any stale events are cleared out. + + +2) iASL Compiler/Disassembler and ACPICA tools: + +iASL: Implemented an enhanced multiple file compilation that combines +named objects from all input files to a single namespace. With this +feature, any unresolved external declarations as well as duplicate named +object declarations can be detected during compilation rather than +generating errors much later at runtime. The following commands are +examples that utilize this feature: + iasl dsdt.asl ssdt.asl + iasl dsdt.asl ssdt1.asl ssdt2.asl + iasl dsdt.asl ssdt*.asl + +---------------------------------------- 29 March 2019. Summary of changes for version 20190329: diff --git a/source/common/adisasm.c b/source/common/adisasm.c index 134a9e3..fbd079f 100644 --- a/source/common/adisasm.c +++ b/source/common/adisasm.c @@ -471,7 +471,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 084e445..4c84c30 100644 --- a/source/compiler/aslcodegen.c +++ b/source/compiler/aslcodegen.c @@ -66,11 +66,11 @@ CgWriteTableHeader ( ACPI_PARSE_OBJECT *Op); static void -CgCloseTable ( - void); +CgWriteNode ( + ACPI_PARSE_OBJECT *Op); static void -CgWriteNode ( +CgUpdateHeader ( ACPI_PARSE_OBJECT *Op); @@ -94,15 +94,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, + 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); } @@ -600,38 +597,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 e178630..882a350 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -70,6 +70,10 @@ static void CmDumpAllEvents ( void); +static void +CmFinishFiles( + BOOLEAN DeleteAmlFile); + /******************************************************************************* * @@ -83,13 +87,13 @@ CmDumpAllEvents ( * ******************************************************************************/ -int +ACPI_STATUS CmDoCompile ( void) { - ACPI_STATUS Status; UINT8 FullCompile; UINT8 Event; + ASL_GLOBAL_FILE_NODE *FileNode; FullCompile = UtBeginEvent ("*** Total Compile time ***"); @@ -113,7 +117,7 @@ CmDoCompile ( { UtEndEvent (Event); CmCleanupAndExit (); - return (0); + return (AE_OK); } } UtEndEvent (Event); @@ -131,6 +135,12 @@ 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; + AslGbl_ParserErrorDetected = TRUE; LsDumpParseTree (); goto ErrorExit; } @@ -184,19 +194,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 */ @@ -243,7 +269,6 @@ CmDoCompile ( AePrintErrorLog (ASL_FILE_STDOUT); UtDisplaySummary (ASL_FILE_STDOUT); } - UtEndEvent (FullCompile); return (0); } @@ -259,7 +284,7 @@ CmDoCompile ( UtEndEvent (Event); if (ACPI_FAILURE (Status)) { - goto ErrorExit; + return (-1); } /* Namespace cross-reference */ @@ -270,7 +295,7 @@ CmDoCompile ( Status = XfCrossReferenceNamespace (); if (ACPI_FAILURE (Status)) { - goto ErrorExit; + return (-1); } /* Namespace - Check for non-referenced objects */ @@ -378,22 +403,47 @@ 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); } @@ -700,10 +750,14 @@ 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) { @@ -757,15 +811,63 @@ CmCleanupAndExit ( * We will delete the AML file if there are errors and the * force AML output option has not been used. */ - if ((AslGbl_ExceptionCount[ASL_ERROR] > 0) && + if (AslGbl_ParserErrorDetected || ((AslGbl_ExceptionCount[ASL_ERROR] > 0) && (!AslGbl_IgnoreErrors) && - AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle) + AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle)) { DeleteAmlFile = TRUE; } /* Close all open files */ + while (CurrentFileNode) + { + switch (FlSwitchFileSet (CurrentFileNode->Files[ASL_FILE_INPUT].Filename)) + { + case SWITCH_TO_SAME_FILE: + case SWITCH_TO_DIFFERENT_FILE: + + CmFinishFiles (DeleteAmlFile); + CurrentFileNode = CurrentFileNode->Next; + break; + + case FILE_NOT_FOUND: + default: + + CurrentFileNode = NULL; + break; + } + } + + /* Final cleanup after compiling one file */ + + if (!AslGbl_DoAslConversion) + { + UtDeleteLocalCaches (); + } +} + + +/******************************************************************************* + * + * FUNCTION: CmFinishFiles + * + * PARAMETERS: DeleteAmlFile + * + * RETURN: None. + * + * DESCRIPTION: Close all open files, delete AML files depending on the + * function parameter is true. + * + ******************************************************************************/ + +static void +CmFinishFiles( + 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 @@ -782,7 +884,15 @@ CmCleanupAndExit ( for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++) { - FlCloseFile (i); + /* + * Some files such as debug output files could be pointing to + * stderr or stdout. Leave these alone. + */ + if (AslGbl_Files[i].Handle != stderr && + AslGbl_Files[i].Handle != stdout) + { + FlCloseFile (i); + } } /* Delete AML file if there are errors */ @@ -815,11 +925,4 @@ 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 791ec81..2c7dd41 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -146,10 +146,14 @@ void AslCompilerFileHeader ( UINT32 FileId); -int +ACPI_STATUS CmDoCompile ( void); +int +CmDoAslMiddleAndBackEnd ( + void); + void CmDoOutputFiles ( void); @@ -158,6 +162,10 @@ void CmCleanupAndExit ( void); +ACPI_STATUS +AslDoDisassembly ( + void); + /* * aslallocate - memory allocation @@ -767,9 +775,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) /* @@ -927,6 +936,11 @@ FlSeekFile ( long Offset); void +FlSeekFileSet ( + UINT32 FileId, + long Offset); + +void FlCloseFile ( UINT32 FileId); @@ -960,6 +974,34 @@ 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); + +BOOLEAN +FlInputFileExists ( + char *InputFilename); + + /* * aslhwmap - hardware map summary */ @@ -975,7 +1017,6 @@ ACPI_STATUS LdLoadNamespace ( ACPI_PARSE_OBJECT *RootOp); - /* * asllookup - namespace lookup functions */ @@ -983,6 +1024,7 @@ void LkFindUnreferencedObjects ( void); + /* * aslhelp - help screens */ @@ -1010,6 +1052,7 @@ void NsSetupNamespaceListing ( void *Handle); + /* * asloptions - command line processing */ @@ -1018,6 +1061,7 @@ AslCommandLine ( int argc, char **argv); + /* * aslxref - namespace cross reference */ @@ -1113,6 +1157,11 @@ UtDisplaySummary ( UINT32 FileId); void +UtDisplayOneSummary ( + UINT32 FileId, + BOOLEAN DisplayErrorSummary); + +void UtConvertByteToHex ( UINT8 RawByte, UINT8 *Buffer); @@ -1163,6 +1212,7 @@ AuConvertUuidToString ( char *UuIdBuffer, char *OutString); + /* * aslresource - Resource template generation utilities */ @@ -1370,6 +1420,7 @@ ASL_RESOURCE_NODE * RsDoPinGroupConfigDescriptor ( ASL_RESOURCE_INFO *Info); + /* * aslrestype2d - DWord address descriptors */ diff --git a/source/compiler/asldefine.h b/source/compiler/asldefine.h index c7f3316..7de5787 100644 --- a/source/compiler/asldefine.h +++ b/source/compiler/asldefine.h @@ -190,5 +190,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 57ceef3..80de6c7 100644 --- a/source/compiler/aslerror.c +++ b/source/compiler/aslerror.c @@ -366,10 +366,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) @@ -710,6 +712,7 @@ static void AslInitEnode ( ASL_ERROR_MSG *SubError) { ASL_ERROR_MSG *Enode; + ASL_GLOBAL_FILE_NODE *FileNode; *InputEnode = UtLocalCalloc (sizeof (ASL_ERROR_MSG)); @@ -751,6 +754,23 @@ static void AslInitEnode ( { Enode->FilenameLength = 6; } + + FileNode = FlGetCurrentFileNode (); + if (!FileNode) + { + return; + } + + if (!FlInputFileExists (Filename)) + { + /* + * This means that this file is an include file. Record the .src + * file as the error message source because this file is not in + * the global file list. + */ + Enode->SourceFilename = + FileNode->Files[ASL_FILE_SOURCE_OUTPUT].Filename; + } } } @@ -884,7 +904,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 32d345e..da03832 100644 --- a/source/compiler/aslfileio.c +++ b/source/compiler/aslfileio.c @@ -69,7 +69,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); } @@ -392,7 +392,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 d52d69c..e1b799d 100644 --- a/source/compiler/aslfiles.c +++ b/source/compiler/aslfiles.c @@ -64,6 +64,257 @@ 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 = ACPI_CAST_PTR (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. + * + ******************************************************************************/ + +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; + + + if (!Filename) + { + return (NULL); + } + + while (Current) + { + if (!strcmp (Current->Files[InFileId].Filename, Filename)) + { + return (Current->Files[OutFileId].Handle); + } + + Current = Current->Next; + } + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: FlGetFileNode + * + * PARAMETERS: FileId - File type (ID) of the input Filename + * Filename - File to search for + * + * RETURN: A 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; + + + if (!Filename) + { + return (NULL); + } + + while (Current) + { + if (!strcmp (Current->Files[FileId].Filename, Filename)) + { + return (Current); + } + + Current = Current->Next; + } + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: FlGetCurrentFileNode + * + * PARAMETERS: None + * + * RETURN: Global file node + * + * DESCRIPTION: Get the current input file node + * + ******************************************************************************/ + +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 @@ -318,8 +569,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 2c0ec2c..ce9d8c3 100644 --- a/source/compiler/aslglobal.h +++ b/source/compiler/aslglobal.h @@ -64,28 +64,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 */ @@ -117,8 +116,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 @@ -161,7 +160,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 */ @@ -192,6 +190,7 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_ListingFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_IgnoreErrors, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_SourceOutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_ParseOnlyFlag, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_ParserErrorDetected, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_CompileTimesFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_FoldConstants, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_VerboseErrors, TRUE); @@ -277,6 +276,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; @@ -295,6 +295,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 3da6213..3d54388 100644 --- a/source/compiler/asllisting.c +++ b/source/compiler/asllisting.c @@ -146,6 +146,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 */ @@ -163,7 +164,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; @@ -171,7 +172,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 */ @@ -739,7 +740,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/aslload.c b/source/compiler/aslload.c index 0488d18..cdb9e33 100644 --- a/source/compiler/aslload.c +++ b/source/compiler/aslload.c @@ -216,6 +216,7 @@ LdLoadFieldElements ( (Node->Flags & ANOBJ_IS_EXTERNAL)) { Node->Type = (UINT8) ACPI_TYPE_LOCAL_REGION_FIELD; + Node->Flags &= ~ANOBJ_IS_EXTERNAL; } else { diff --git a/source/compiler/aslmain.c b/source/compiler/aslmain.c index 84cbc8c..27c0fdc 100644 --- a/source/compiler/aslmain.c +++ b/source/compiler/aslmain.c @@ -147,6 +147,14 @@ main ( } } + /* ACPICA subsystem initialization */ + + Status = AdInitialize (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + /* Process each pathname/filename in the list, with possible wildcards */ @@ -172,17 +180,71 @@ main ( Index2++; } + /* + * At this point, compilation of a data table or disassembly is complete. + */ + if (AslGbl_FileType == ASL_INPUT_TYPE_ASCII_DATA || AcpiGbl_DisasmFlag) + { + goto CleanupAndExit; + } + + 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 disassembler */ + + Status = AdInitialize (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * 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; + AslGbl_Files[ASL_FILE_INPUT].Filename = + AslGbl_Files[ASL_FILE_AML_OUTPUT].Filename; + + CvDbgPrint ("Output filename: %s\n", AslGbl_OutputFilenamePrefix); + fprintf (stderr, "\n"); + + AcpiGbl_DisasmFlag = TRUE; + AslDoDisassembly (); + AcpiGbl_DisasmFlag = FALSE; + + /* delete the AML file. This AML file should never be utilized by AML interpreters. */ + + FlDeleteFile (ASL_FILE_AML_OUTPUT); + } + + CleanupAndExit: UtFreeLineBuffers (); AslParserCleanup (); + AcpiDmClearExternalFileList(); + (void) AcpiTerminate (); + + /* CmCleanupAndExit is intended for the compiler only */ - if (AcpiGbl_ExternalFileList) + if (!AcpiGbl_DisasmFlag) { - AcpiDmClearExternalFileList(); + CmCleanupAndExit (); } + return (ReturnStatus); } @@ -264,9 +326,6 @@ static void AslInitialize ( void) { - UINT32 i; - - AcpiGbl_DmOpt_Verbose = FALSE; /* Default integer width is 32 bits */ @@ -274,16 +333,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 508952e..bba1da2 100644 --- a/source/compiler/aslmessages.c +++ b/source/compiler/aslmessages.c @@ -245,8 +245,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", @@ -255,7 +255,8 @@ const char *AslCompilerMsgs [] = /* ASL_MSG_PREFIX_NOT_EXIST */ "One or more prefix Scopes do not exist", /* ASL_MSG_NAMEPATH_NOT_EXIST */ "One or more objects within the Pathname do not exist", /* ASL_MSG_REGION_LENGTH */ "Operation Region declared with zero length", -/* ASL_MSG_TEMPORARY_OBJECT */ "Object is created temporarily in another method and cannot be accessed" +/* ASL_MSG_TEMPORARY_OBJECT */ "Object is created temporarily in another method and cannot be accessed", +/* ASL_MSG_UNDEFINED_EXTERNAL */ "Named object was declared external but the actual definition does not exist" }; /* Table compiler */ diff --git a/source/compiler/aslmessages.h b/source/compiler/aslmessages.h index 4c5de61..a10ff89 100644 --- a/source/compiler/aslmessages.h +++ b/source/compiler/aslmessages.h @@ -247,8 +247,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, @@ -258,6 +258,7 @@ typedef enum ASL_MSG_NAMEPATH_NOT_EXIST, ASL_MSG_REGION_LENGTH, ASL_MSG_TEMPORARY_OBJECT, + ASL_MSG_UNDEFINED_EXTERNAL, /* These messages are used by the Data Table compiler only */ diff --git a/source/compiler/asloperands.c b/source/compiler/asloperands.c index fed6517..1e0745a 100644 --- a/source/compiler/asloperands.c +++ b/source/compiler/asloperands.c @@ -937,6 +937,7 @@ OpnDoDefinitionBlock ( ACPI_SIZE Length; UINT32 i; char *Filename; + ACPI_STATUS Status; /* @@ -955,6 +956,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. */ @@ -968,6 +975,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; @@ -978,6 +1001,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) { @@ -1030,6 +1054,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 c27090f..05ec38a 100644 --- a/source/compiler/asloptions.c +++ b/source/compiler/asloptions.c @@ -788,7 +788,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 cb710e6..b74605b 100644 --- a/source/compiler/aslstartup.c +++ b/source/compiler/aslstartup.c @@ -57,10 +57,6 @@ static UINT8 AslDetectSourceFileType ( ASL_FILE_INFO *Info); -static ACPI_STATUS -AslDoDisassembly ( - void); - /* Globals */ @@ -119,12 +115,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; @@ -235,25 +225,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)) { @@ -262,11 +246,6 @@ AslDoDisassembly ( return (Status); } - /* Handle additional output files for disassembler */ - - AslGbl_FileType = ASL_INPUT_TYPE_BINARY_ACPI_TABLE; - Status = FlOpenMiscOutputFiles (AslGbl_OutputFilenamePrefix); - /* This is where the disassembly happens */ AcpiGbl_DmOpt_Disasm = TRUE; @@ -282,10 +261,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 @@ -298,11 +276,6 @@ AslDoDisassembly ( return (AE_CTRL_CONTINUE); } - /* No need to free the filename string */ - - AslGbl_Files[ASL_FILE_INPUT].Filename = NULL; - - UtDeleteLocalCaches (); return (AE_OK); } @@ -324,6 +297,8 @@ AslDoOneFile ( char *Filename) { ACPI_STATUS Status; + UINT8 Event; + ASL_GLOBAL_FILE_NODE *FileNode; /* Re-initialize "some" compiler/preprocessor globals */ @@ -342,6 +317,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 = @@ -351,18 +338,6 @@ AslDoOneFile ( UtConvertBackslashes (AslGbl_Files[ASL_FILE_INPUT].Filename); /* - * AML Disassembly (Optional) - */ - if (AcpiGbl_DisasmFlag) - { - Status = AslDoDisassembly (); - if (Status != AE_CTRL_CONTINUE) - { - return (Status); - } - } - - /* * Open the input file. Here, this should be an ASCII source file, * either an ASL file or a Data Table file */ @@ -373,7 +348,13 @@ 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 */ @@ -392,6 +373,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); @@ -442,20 +439,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); @@ -466,27 +450,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); /* @@ -553,6 +521,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 22939dd..aff251e 100644 --- a/source/compiler/aslsupport.l +++ b/source/compiler/aslsupport.l @@ -424,14 +424,18 @@ count ( { case 2: - AslGbl_TotalKeywords++; - AslGbl_TotalNamedObjects++; + ++AslGbl_TotalKeywords; + ++AslGbl_TotalNamedObjects; + ++AslGbl_FilesList->TotalKeywords; + ++AslGbl_FilesList->TotalNamedObjects; break; case 3: - AslGbl_TotalKeywords++; - AslGbl_TotalExecutableOpcodes++; + ++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 332afcd..8e0d98b 100644 --- a/source/compiler/asltree.c +++ b/source/compiler/asltree.c @@ -354,6 +354,7 @@ TrLinkOpChildren ( { ACPI_PARSE_OBJECT *Child; ACPI_PARSE_OBJECT *PrevChild; + ACPI_PARSE_OBJECT *LastSibling; va_list ap; UINT32 i; BOOLEAN FirstChild; @@ -372,8 +373,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; @@ -452,7 +463,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 */ @@ -717,6 +748,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) @@ -727,7 +760,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: @@ -753,7 +792,7 @@ TrWalkParseTree ( { /* Exit immediately on any error */ - return (Status); + goto ErrorExit; } } @@ -799,7 +838,7 @@ TrWalkParseTree ( Status = AscendingCallback (Op, Level, Context); if (ACPI_FAILURE (Status)) { - return (Status); + goto ErrorExit; } } else @@ -848,7 +887,7 @@ TrWalkParseTree ( Status = AscendingCallback (Op, Level, Context); if (ACPI_FAILURE (Status)) { - return (Status); + goto ErrorExit; } } else @@ -871,7 +910,7 @@ TrWalkParseTree ( { /* Exit immediately on any error */ - return (Status); + goto ErrorExit; } } @@ -910,5 +949,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 3a1f19d..9c40512 100644 --- a/source/compiler/asltypes.h +++ b/source/compiler/asltypes.h @@ -113,10 +113,10 @@ typedef struct asl_analysis_walk_info typedef struct asl_mapping_entry { - UINT32 Value; - UINT32 AcpiBtype; /* Object type or return type */ - UINT16 AmlOpcode; - UINT8 Flags; + UINT32 Value; + UINT32 AcpiBtype; /* Object type or return type */ + UINT16 AmlOpcode; + UINT8 Flags; } ASL_MAPPING_ENTRY; @@ -125,8 +125,8 @@ typedef struct asl_mapping_entry typedef struct asl_walk_info { - ACPI_PARSE_OBJECT **NodePtr; - UINT32 *LevelPtr; + ACPI_PARSE_OBJECT **NodePtr; + UINT32 *LevelPtr; } ASL_WALK_INFO; @@ -135,10 +135,8 @@ typedef struct asl_walk_info typedef struct asl_file_info { - FILE *Handle; - char *Filename; - const char *ShortDescription; - const char *Description; + FILE *Handle; + char *Filename; } ASL_FILE_INFO; @@ -150,6 +148,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. @@ -187,10 +190,17 @@ 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" @@ -217,16 +227,16 @@ typedef enum typedef struct asl_cache_info { - void *Next; - char Buffer[1]; + void *Next; + char Buffer[1]; } ASL_CACHE_INFO; typedef struct asl_include_dir { - char *Dir; - struct asl_include_dir *Next; + char *Dir; + struct asl_include_dir *Next; } ASL_INCLUDE_DIR; @@ -235,6 +245,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 { @@ -247,6 +262,7 @@ typedef struct asl_error_msg struct asl_error_msg *SubError; char *Filename; char *SourceLine; + char *SourceFilename; UINT32 FilenameLength; UINT16 MessageId; UINT8 Level; @@ -254,6 +270,7 @@ typedef struct asl_error_msg } ASL_ERROR_MSG; /* An entry in the expected messages array */ + typedef struct asl_expected_message { UINT32 MessageId; @@ -371,4 +388,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; + UINT32 TotalLineCount; + UINT32 OriginalInputFileSize; + UINT32 TotalKeywords; + UINT32 TotalNamedObjects; + UINT32 TotalExecutableOpcodes; + BOOLEAN ParserErrorDetected; + +} ASL_GLOBAL_FILE_NODE; + #endif /* __ASLTYPES_H */ diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index ba8dda6..7db8ffc 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -66,6 +66,10 @@ UtAttachNameseg ( ACPI_PARSE_OBJECT *Op, char *Name); +static void +UtDisplayErrorSummary ( + UINT32 FileId); + /******************************************************************************* * @@ -412,21 +416,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) @@ -457,25 +463,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); - - /* AML summary */ - - if ((AslGbl_ExceptionCount[ASL_ERROR] == 0) || (AslGbl_IgnoreErrors)) + FileNode = FlGetCurrentFileNode (); + if (!FileNode) { - if (AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle) + 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 - %7u bytes %6u keywords %6u source lines\n", + "ASL Input:", + AslGbl_Files[ASL_FILE_INPUT].Filename, + FileNode->OriginalInputFileSize, + FileNode->TotalKeywords, + FileNode->TotalLineCount); + + /* AML summary */ + + if (!AslGbl_ParserErrorDetected && + ((AslGbl_ExceptionCount[ASL_ERROR] == 0) || AslGbl_IgnoreErrors) && + AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle) { FlPrintFile (FileId, - "%-14s %s - %u bytes, %u named objects, " - "%u executable opcodes\n", + "%-14s %s - %7u bytes %6u opcodes %6u named objects\n", "AML Output:", AslGbl_Files[ASL_FILE_AML_OUTPUT].Filename, FlGetFileSize (ASL_FILE_AML_OUTPUT), - AslGbl_TotalNamedObjects, AslGbl_TotalExecutableOpcodes); + FileNode->TotalExecutableOpcodes, + FileNode->TotalNamedObjects); } } } @@ -504,14 +526,55 @@ 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) +{ + BOOLEAN ErrorDetected; + + + ErrorDetected = AslGbl_ParserErrorDetected || + ((AslGbl_ExceptionCount[ASL_ERROR] > 0) && !AslGbl_IgnoreErrors); + + if (ErrorDetected) + { + FlPrintFile (FileId, "\nCompilation failed. "); + } + else + { + FlPrintFile (FileId, "\nCompilation successful. "); + } FlPrintFile (FileId, - "\nCompilation complete. %u Errors, %u Warnings, %u Remarks", + "%u Errors, %u Warnings, %u Remarks", AslGbl_ExceptionCount[ASL_ERROR], AslGbl_ExceptionCount[ASL_WARNING] + AslGbl_ExceptionCount[ASL_WARNING2] + @@ -520,6 +583,19 @@ UtDisplaySummary ( if (AslGbl_FileType != ASL_INPUT_TYPE_ASCII_DATA) { + if (AslGbl_ParserErrorDetected) + { + FlPrintFile (FileId, + "\nNo AML files were generated due to syntax error(s)\n"); + return; + } + else if (ErrorDetected) + { + FlPrintFile (FileId, + "\nNo AML files were generated due to compiler error(s)\n"); + return; + } + FlPrintFile (FileId, ", %u Optimizations", AslGbl_ExceptionCount[ASL_OPTIMIZATION]); @@ -535,6 +611,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/aslxref.c b/source/compiler/aslxref.c index a63d94b..6a6d5be 100644 --- a/source/compiler/aslxref.c +++ b/source/compiler/aslxref.c @@ -1077,6 +1077,24 @@ XfNamespaceLocateBegin ( } } + /* + * 5) Check for external resolution + * By this point, everything should be loaded in the namespace. If a + * namespace lookup results in a namespace node that is an external, it + * means that this named object was not defined in the input ASL. This + * causes issues because there are plenty of incidents where developers + * use the external keyword to suppress compiler errors about undefined + * objects. Note: this only applies when compiling multiple definition + * blocks. + */ + if (AslGbl_ParseTreeRoot->Asl.Child && AslGbl_ParseTreeRoot->Asl.Child->Asl.Next && + (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL && + Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL) && + (Node->Flags & ANOBJ_IS_EXTERNAL)) + { + AslError (ASL_ERROR, ASL_MSG_UNDEFINED_EXTERNAL, Op, NULL); + } + /* 5) Check for a connection object */ #if 0 else if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONNECTION) diff --git a/source/compiler/dtcompile.c b/source/compiler/dtcompile.c index 94073d8..28c5636 100644 --- a/source/compiler/dtcompile.c +++ b/source/compiler/dtcompile.c @@ -132,8 +132,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"); @@ -151,7 +150,7 @@ DtDoCompile ( DtError (ASL_ERROR, ASL_MSG_SYNTAX, NULL, "Could not compile input file"); - goto CleanupAndExit; + return (Status); } /* Create/open the binary output file */ @@ -160,7 +159,7 @@ DtDoCompile ( Status = FlOpenAmlOutputFile (AslGbl_OutputFilenamePrefix); if (ACPI_FAILURE (Status)) { - goto CleanupAndExit; + return (Status); } /* Write the binary, then the optional hex file */ @@ -169,10 +168,6 @@ DtDoCompile ( HxDoHexOutput (); DtWriteTableToListing (); -CleanupAndExit: - - AcpiUtDeleteCaches (); - CmCleanupAndExit (); return (Status); } diff --git a/source/compiler/prutils.c b/source/compiler/prutils.c index 59b0dcd..3ba8a7f 100644 --- a/source/compiler/prutils.c +++ b/source/compiler/prutils.c @@ -347,7 +347,6 @@ PrOpenIncludeWithPrefix ( IncludeFile = fopen (Pathname, OpenMode); if (!IncludeFile) { - fprintf (stderr, "Could not open include file %s\n", Pathname); return (NULL); } diff --git a/source/components/events/evgpe.c b/source/components/events/evgpe.c index 7527a00..b293aee 100644 --- a/source/components/events/evgpe.c +++ b/source/components/events/evgpe.c @@ -132,6 +132,14 @@ AcpiEvEnableGpe ( ACPI_FUNCTION_TRACE (EvEnableGpe); + /* Clear the GPE (of stale events) */ + + Status = AcpiHwClearGpe(GpeEventInfo); + if (ACPI_FAILURE(Status)) + { + return_ACPI_STATUS(Status); + } + /* Enable the requested GPE */ Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_ENABLE); diff --git a/source/components/namespace/nsalloc.c b/source/components/namespace/nsalloc.c index 8f079c3..fb5cc71 100644 --- a/source/components/namespace/nsalloc.c +++ b/source/components/namespace/nsalloc.c @@ -124,6 +124,11 @@ AcpiNsDeleteNode ( ACPI_FUNCTION_NAME (NsDeleteNode); + if (!Node) + { + return_VOID; + } + /* Detach an object if there is one */ AcpiNsDetachObject (Node); diff --git a/source/include/acpixf.h b/source/include/acpixf.h index d700786..75533de 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.h @@ -46,7 +46,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20190329 +#define ACPI_CA_VERSION 0x20190405 #include "acconfig.h" #include "actypes.h"