From b74f8e484d361af1bffa76df1873237718e350f9 Mon Sep 17 00:00:00 2001 From: Erik Schmauss Date: Mon, 10 Dec 2018 16:42:53 -0800 Subject: [PATCH 1/2] iASL: add the ability to report specific warnings or remarks as errors Signed-off-by: Erik Schmauss --- source/compiler/aslcompiler.h | 4 ++ source/compiler/aslerror.c | 97 +++++++++++++++++++++++++++++++++-- source/compiler/aslglobal.h | 3 ++ source/compiler/aslhelp.c | 1 + source/compiler/asloptions.c | 17 ++++++ 5 files changed, 118 insertions(+), 4 deletions(-) diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h index bd02879d5..c5e8cb0c2 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -474,6 +474,10 @@ ACPI_STATUS AslExpectException ( char *MessageIdString); +ACPI_STATUS +AslElevateException ( + char *MessageIdString); + ACPI_STATUS AslDisableException ( char *MessageIdString); diff --git a/source/compiler/aslerror.c b/source/compiler/aslerror.c index 10ea3ec1b..2a18dded5 100644 --- a/source/compiler/aslerror.c +++ b/source/compiler/aslerror.c @@ -201,6 +201,11 @@ AePrintSubError ( FILE *OutputFile, ASL_ERROR_MSG *Enode); +static UINT8 +GetModifiedLevel ( + UINT8 Level, + UINT16 MessageId); + /******************************************************************************* * @@ -968,11 +973,12 @@ AslLogNewError ( ASL_ERROR_MSG *SubError) { ASL_ERROR_MSG *Enode = NULL; + UINT8 ModifiedLevel = GetModifiedLevel (Level, MessageId); - AslInitEnode (&Enode, Level, MessageId, LineNumber, LogicalLineNumber, - LogicalByteOffset, Column, Filename, Message, SourceLine, - SubError); + AslInitEnode (&Enode, ModifiedLevel, MessageId, LineNumber, + LogicalLineNumber, LogicalByteOffset, Column, Filename, Message, + SourceLine, SubError); /* Add the new node to the error node list */ @@ -985,7 +991,7 @@ AslLogNewError ( AePrintException (ASL_FILE_STDERR, Enode, NULL); } - AslGbl_ExceptionCount[Level]++; + AslGbl_ExceptionCount[ModifiedLevel]++; if (AslGbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT) { printf ("\nMaximum error count (%u) exceeded\n", ASL_MAX_ERROR_COUNT); @@ -999,6 +1005,44 @@ AslLogNewError ( return; } + +/******************************************************************************* + * + * FUNCTION: GetModifiedLevel + * + * PARAMETERS: Level - Seriousness (Warning/error, etc.) + * MessageId - Index into global message buffer + * + * RETURN: UINT8 - modified level + * + * DESCRIPTION: Get the modified level of exception codes that are reported as + * errors from the -ww option. + * + ******************************************************************************/ + +static UINT8 +GetModifiedLevel ( + UINT8 Level, + UINT16 MessageId) +{ + UINT16 i; + UINT16 ExceptionCode; + + + ExceptionCode = AeBuildFullExceptionCode (Level, MessageId); + + for (i = 0; i < AslGbl_ElevatedMessagesIndex; i++) + { + if (ExceptionCode == AslGbl_ElevatedMessages[i]) + { + return (ASL_ERROR); + } + } + + return (Level); +} + + /******************************************************************************* * * FUNCTION: AslIsExceptionIgnored @@ -1155,6 +1199,51 @@ AslDisableException ( } +/******************************************************************************* + * + * FUNCTION: AslElevateException + * + * PARAMETERS: MessageIdString - ID of excepted exception during compile + * + * RETURN: Status + * + * DESCRIPTION: Enter a message ID into the global elevated exceptions table. + * These messages will be considered as compilation errors. + * + ******************************************************************************/ + +ACPI_STATUS +AslElevateException ( + char *MessageIdString) +{ + UINT32 MessageId; + + + /* Convert argument to an integer and validate it */ + + MessageId = (UINT32) strtoul (MessageIdString, NULL, 0); + + if (MessageId > 6999) + { + printf ("\"%s\" is not a valid warning/remark/erro ID\n", + MessageIdString); + return (AE_BAD_PARAMETER); + } + + /* Insert value into the global expected message array */ + + if (AslGbl_ElevatedMessagesIndex >= ASL_MAX_ELEVATED_MESSAGES) + { + printf ("Too many messages have been registered as elevated (max %d)\n", + ASL_MAX_DISABLED_MESSAGES); + return (AE_LIMIT); + } + + AslGbl_ElevatedMessages[AslGbl_ExpectedMessagesIndex] = MessageId; + AslGbl_ElevatedMessagesIndex++; + return (AE_OK); +} + /******************************************************************************* * * FUNCTION: AslIsExceptionDisabled diff --git a/source/compiler/aslglobal.h b/source/compiler/aslglobal.h index c3e69cbbd..2c7155676 100644 --- a/source/compiler/aslglobal.h +++ b/source/compiler/aslglobal.h @@ -255,6 +255,7 @@ extern int AslCompilerdebug; #define ASL_STRING_BUFFER_SIZE (1024 * 32) /* 32k */ #define ASL_MAX_DISABLED_MESSAGES 32 #define ASL_MAX_EXPECTED_MESSAGES 32 +#define ASL_MAX_ELEVATED_MESSAGES 32 #define HEX_TABLE_LINE_SIZE 8 #define HEX_LISTING_LINE_SIZE 8 @@ -394,6 +395,7 @@ ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_CurrentAmlOffset, 0) ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_CurrentLine, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_DisabledMessagesIndex, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_ExpectedMessagesIndex, 0); +ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_ElevatedMessagesIndex, 0); ASL_EXTERN UINT8 ASL_INIT_GLOBAL (AslGbl_HexBytesWereWritten, FALSE); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_NumNamespaceObjects, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_ReservedMethods, 0); @@ -435,6 +437,7 @@ ASL_EXTERN char AslGbl_StringBuffer[ASL_STRING_BUFFER_SIZE]; ASL_EXTERN char AslGbl_StringBuffer2[ASL_STRING_BUFFER_SIZE]; ASL_EXTERN UINT32 AslGbl_DisabledMessages[ASL_MAX_DISABLED_MESSAGES]; ASL_EXTERN ASL_EXPECTED_MESSAGE AslGbl_ExpectedMessages[ASL_MAX_EXPECTED_MESSAGES]; +ASL_EXTERN UINT32 AslGbl_ElevatedMessages[ASL_MAX_ELEVATED_MESSAGES]; #endif /* __ASLGLOBAL_H */ diff --git a/source/compiler/aslhelp.c b/source/compiler/aslhelp.c index 608f18532..4377f83c6 100644 --- a/source/compiler/aslhelp.c +++ b/source/compiler/aslhelp.c @@ -209,6 +209,7 @@ Usage ( ACPI_OPTION ("-vx ", "Expect a specific warning, remark, or error"); ACPI_OPTION ("-w <1|2|3>", "Set warning reporting level"); ACPI_OPTION ("-we", "Report warnings as errors"); + ACPI_OPTION ("-ww ", "Report specific warning or remark as error"); printf ("\nAML Bytecode Generation (*.aml):\n"); ACPI_OPTION ("-oa", "Disable all optimizations (compatibility mode)"); diff --git a/source/compiler/asloptions.c b/source/compiler/asloptions.c index 15519634a..325ee4aca 100644 --- a/source/compiler/asloptions.c +++ b/source/compiler/asloptions.c @@ -982,6 +982,23 @@ AslDoOptions ( AslGbl_WarningsAsErrors = TRUE; break; + case 'w': + + /* Get the required argument */ + + if (AcpiGetoptArgument (argc, argv)) + { + return (-1); + } + + Status = AslElevateException (AcpiGbl_Optarg); + if (ACPI_FAILURE (Status)) + { + return (-1); + } + break; + + default: printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); From ca62aa832c84308cd0648be67d718d36f807ede6 Mon Sep 17 00:00:00 2001 From: Erik Schmauss Date: Tue, 11 Dec 2018 14:48:50 -0800 Subject: [PATCH 2/2] iASL: remove obsolete AcpiGbl_DoExternals flag This was meant to be a debug flag during the development of external opcode. This flag is no longer needed because generation of external opcodes are stable. Signed-off-by: Erik Schmauss --- source/compiler/aslcodegen.c | 6 ------ source/compiler/aslcompile.c | 27 ++++++++++++--------------- source/compiler/aslglobal.h | 1 - source/compiler/asllength.c | 5 +---- source/compiler/aslopcodes.c | 9 --------- source/compiler/asltransform.c | 6 +----- 6 files changed, 14 insertions(+), 40 deletions(-) diff --git a/source/compiler/aslcodegen.c b/source/compiler/aslcodegen.c index 7b2e3e5ce..356011f06 100644 --- a/source/compiler/aslcodegen.c +++ b/source/compiler/aslcodegen.c @@ -773,12 +773,6 @@ CgWriteNode ( return; } - if ((Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && - AslGbl_DoExternals == FALSE) - { - return; - } - Op->Asl.FinalAmlLength = 0; switch (Op->Asl.AmlOpcode) diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index 4ae190763..1b8838aab 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -388,23 +388,20 @@ CmDoCompile ( /* Resolve External Declarations */ - if (AslGbl_DoExternals) - { - Event = UtBeginEvent ("Resolve all Externals"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nResolve Externals\n\n"); + Event = UtBeginEvent ("Resolve all Externals"); + DbgPrint (ASL_DEBUG_OUTPUT, "\nResolve Externals\n\n"); - if (AslGbl_DoExternalsInPlace) - { - TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, - ExAmlExternalWalkBegin, NULL, NULL); - } - else - { - TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE, - ExAmlExternalWalkBegin, ExAmlExternalWalkEnd, NULL); - } - UtEndEvent (Event); + if (AslGbl_DoExternalsInPlace) + { + TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, + ExAmlExternalWalkBegin, NULL, NULL); } + else + { + TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE, + ExAmlExternalWalkBegin, ExAmlExternalWalkEnd, NULL); + } + UtEndEvent (Event); /* * Semantic analysis. This can happen only after the diff --git a/source/compiler/aslglobal.h b/source/compiler/aslglobal.h index c3e69cbbd..3f52e7517 100644 --- a/source/compiler/aslglobal.h +++ b/source/compiler/aslglobal.h @@ -319,7 +319,6 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_AllExceptionsDisable ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_PruneParseTree, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_DoTypechecking, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_EnableReferenceTypechecking, FALSE); -ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_DoExternals, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_DoExternalsInPlace, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_DoAslConversion, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_OptimizeTrivialParseNodes, TRUE); diff --git a/source/compiler/asllength.c b/source/compiler/asllength.c index 696dc2424..8fef83b91 100644 --- a/source/compiler/asllength.c +++ b/source/compiler/asllength.c @@ -519,10 +519,7 @@ CgGenerateAmlLengths ( case PARSEOP_EXTERNAL: - if (AslGbl_DoExternals == TRUE) - { - CgGenerateAmlOpcodeLength (Op); - } + CgGenerateAmlOpcodeLength (Op); break; default: diff --git a/source/compiler/aslopcodes.c b/source/compiler/aslopcodes.c index 218223b83..32d04781c 100644 --- a/source/compiler/aslopcodes.c +++ b/source/compiler/aslopcodes.c @@ -927,15 +927,6 @@ OpcGenerateAmlOpcode ( AslGbl_HasIncludeFiles = TRUE; break; - case PARSEOP_EXTERNAL: - - if (AslGbl_DoExternals == FALSE) - { - Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; - Op->Asl.Child->Asl.Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; - } - break; - case PARSEOP_TIMER: if (AcpiGbl_IntegerBitWidth == 32) diff --git a/source/compiler/asltransform.c b/source/compiler/asltransform.c index 324b0364d..2bf32db4b 100644 --- a/source/compiler/asltransform.c +++ b/source/compiler/asltransform.c @@ -460,11 +460,7 @@ TrTransformSubtree ( case PARSEOP_EXTERNAL: - if (AslGbl_DoExternals == TRUE) - { - ExDoExternal (Op); - } - + ExDoExternal (Op); break; case PARSEOP___METHOD__: