1 /******************************************************************************
3 * Module Name: aslerror - Error handling and statistics
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2019, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
152 #include "aslcompiler.h"
154 #define _COMPONENT ACPI_COMPILER
155 ACPI_MODULE_NAME ("aslerror")
157 /* Local prototypes */
161 ASL_ERROR_MSG *Enode);
164 AslIsExceptionExpected (
169 AslIsExceptionDisabled (
173 static void AslInitEnode (
174 ASL_ERROR_MSG **Enode,
178 UINT32 LogicalLineNumber,
179 UINT32 LogicalByteOffset,
184 ASL_ERROR_MSG *SubError);
191 UINT32 LogicalLineNumber,
192 UINT32 LogicalByteOffset,
197 ASL_ERROR_MSG *SubError);
202 ASL_ERROR_MSG *Enode);
210 /*******************************************************************************
218 * DESCRIPTION: Dump the error log and abort the compiler. Used for serious
221 ******************************************************************************/
228 AePrintErrorLog (ASL_FILE_STDERR);
229 if (AslGbl_DebugFlag)
231 /* Print error summary to stdout also */
233 AePrintErrorLog (ASL_FILE_STDOUT);
240 /*******************************************************************************
242 * FUNCTION: AeClearErrorLog
248 * DESCRIPTION: Empty the error list
250 ******************************************************************************/
256 ASL_ERROR_MSG *Enode = AslGbl_ErrorLog;
260 /* Walk the error node list */
269 AslGbl_ErrorLog = NULL;
273 /*******************************************************************************
275 * FUNCTION: AeAddToErrorLog
277 * PARAMETERS: Enode - An error node to add to the log
281 * DESCRIPTION: Add a new error node to the error log. The error log is
282 * ordered by the "logical" line number (cumulative line number
283 * including all include files.)
285 ******************************************************************************/
289 ASL_ERROR_MSG *Enode)
295 /* If Gbl_ErrorLog is null, this is the first error node */
297 if (!AslGbl_ErrorLog)
299 AslGbl_ErrorLog = Enode;
304 * Walk error list until we find a line number greater than ours.
305 * List is sorted according to line number.
308 Next = AslGbl_ErrorLog;
310 while ((Next) && (Next->LogicalLineNumber <= Enode->LogicalLineNumber))
316 /* Found our place in the list */
326 AslGbl_ErrorLog = Enode;
331 /*******************************************************************************
333 * FUNCTION: AeDecodeErrorMessageId
335 * PARAMETERS: OutputFile - Output file
336 * Enode - Error node to print
337 * PrematureEOF - True = PrematureEOF has been reached
338 * Total - Total legth of line
342 * DESCRIPTION: Print the source line of an error.
344 ******************************************************************************/
347 AeDecodeErrorMessageId (
349 ASL_ERROR_MSG *Enode,
350 BOOLEAN PrematureEOF,
354 const char *MainMessage;
360 fprintf (OutputFile, "%s %4.4d -",
361 AeDecodeExceptionLevel (Enode->Level),
362 AeBuildFullExceptionCode (Enode->Level, Enode->MessageId));
364 MainMessage = AeDecodeMessageId (Enode->MessageId);
365 ExtraMessage = Enode->Message;
367 /* If a NULL line number, just print the decoded message */
369 if (!Enode->LineNumber)
371 fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage);
375 MsgLength = strlen (MainMessage);
378 /* Use the secondary/extra message as main message */
380 MainMessage = Enode->Message;
386 MsgLength = strlen (MainMessage);
390 if (AslGbl_VerboseErrors && !PrematureEOF)
394 fprintf (OutputFile, " %s",
399 SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2;
400 ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1;
402 if ((MsgLength + ErrorColumn) < (SourceColumn - 1))
404 fprintf (OutputFile, "%*s%s",
405 (int) ((SourceColumn - 1) - ErrorColumn),
410 fprintf (OutputFile, "%*s %s",
411 (int) ((SourceColumn - ErrorColumn) + 1), "^",
418 fprintf (OutputFile, " %s", MainMessage);
421 /* Print the extra info message if present */
425 fprintf (OutputFile, " (%s)", ExtraMessage);
430 fprintf (OutputFile, " and premature End-Of-File");
433 fprintf (OutputFile, "\n");
434 if (AslGbl_VerboseErrors && !Enode->SubError)
436 fprintf (OutputFile, "\n");
441 /*******************************************************************************
443 * FUNCTION: AePrintErrorSourceLine
445 * PARAMETERS: OutputFile - Output file
446 * Enode - Error node to print
447 * PrematureEOF - True = PrematureEOF has been reached
448 * Total - amount of characters printed so far
453 * DESCRIPTION: Print the source line of an error.
455 ******************************************************************************/
458 AePrintErrorSourceLine (
460 ASL_ERROR_MSG *Enode,
461 BOOLEAN *PrematureEOF,
467 FILE *SourceFile = NULL;
471 if (!Enode->SourceLine)
474 * Use the merged header/source file if present, otherwise
477 SourceFile = FlGetFileHandle (ASL_FILE_SOURCE_OUTPUT,
478 ASL_FILE_SOURCE_OUTPUT, Enode->SourceFilename);
481 SourceFile = FlGetFileHandle (ASL_FILE_INPUT,
482 ASL_FILE_INPUT, Enode->Filename);
487 /* Determine if the error occurred at source file EOF */
489 fseek (SourceFile, 0, SEEK_END);
490 FileSize = ftell (SourceFile);
492 if ((long) Enode->LogicalByteOffset >= FileSize)
494 *PrematureEOF = TRUE;
500 "[*** iASL: Source File Does not exist ***]\n");
505 /* Print filename and line number if present and valid */
507 if (AslGbl_VerboseErrors)
509 fprintf (OutputFile, "%-8s", Enode->Filename);
511 if (Enode->SourceLine && Enode->LineNumber)
513 fprintf (OutputFile, " %6u: %s",
514 Enode->LineNumber, Enode->SourceLine);
516 else if (Enode->LineNumber)
518 fprintf (OutputFile, " %6u: ", Enode->LineNumber);
521 * If not at EOF, get the corresponding source code line
522 * and display it. Don't attempt this if we have a
523 * premature EOF condition.
527 fprintf (OutputFile, "\n");
531 * Seek to the offset in the combined source file,
532 * read the source line, and write it to the output.
534 Actual = fseek (SourceFile,
535 (long) Enode->LogicalByteOffset, (int) SEEK_SET);
539 "[*** iASL: Seek error on source code temp file %s ***]",
540 AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
542 fprintf (OutputFile, "\n");
545 RActual = fread (&SourceByte, 1, 1, SourceFile);
549 "[*** iASL: Read error on source code temp file %s ***]",
550 AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
553 /* Read/write the source line, up to the maximum line length */
555 while (RActual && SourceByte && (SourceByte != '\n'))
559 /* After the max line length, we will just read the line, no write */
561 if (fwrite (&SourceByte, 1, 1, OutputFile) != 1)
563 printf ("[*** iASL: Write error on output file ***]\n");
567 else if (*Total == 256)
570 "\n[*** iASL: Very long input line, message below refers to column %u ***]",
574 RActual = fread (&SourceByte, 1, 1, SourceFile);
578 "[*** iASL: Read error on source code temp file %s ***]",
579 AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
586 fprintf (OutputFile, "\n");
592 * Less verbose version of the error message, enabled via the
593 * -vi switch. The format is compatible with MS Visual Studio.
595 fprintf (OutputFile, "%s", Enode->Filename);
597 if (Enode->LineNumber)
599 fprintf (OutputFile, "(%u) : ",
607 /*******************************************************************************
609 * FUNCTION: AePrintException
611 * PARAMETERS: FileId - ID of output file
612 * Enode - Error node to print
613 * Header - Additional text before each message
617 * DESCRIPTION: Print the contents of an error node.
619 * NOTE: We don't use the FlxxxFile I/O functions here because on error
620 * they abort the compiler and call this function! Since we
621 * are reporting errors here, we ignore most output errors and
622 * just try to get out as much as we can.
624 ******************************************************************************/
629 ASL_ERROR_MSG *Enode,
633 BOOLEAN PrematureEOF = FALSE;
636 ASL_ERROR_MSG *Child = Enode->SubError;
645 * Only listing files have a header, and remarks/optimizations
650 /* Ignore remarks if requested */
652 switch (Enode->Level)
658 if (!AslGbl_DisplayWarnings)
666 if (!AslGbl_DisplayRemarks)
672 case ASL_OPTIMIZATION:
674 if (!AslGbl_DisplayOptimizations)
686 /* Get the various required file handles */
688 OutputFile = AslGbl_Files[FileId].Handle;
692 fprintf (OutputFile, "%s", Header);
695 if (!Enode->Filename)
697 AeDecodeErrorMessageId (OutputFile, Enode, PrematureEOF, Total);
701 Status = AePrintErrorSourceLine (OutputFile, Enode, &PrematureEOF, &Total);
702 if (ACPI_FAILURE (Status))
707 /* If a NULL message ID, just print the raw message */
709 if (Enode->MessageId == 0)
711 fprintf (OutputFile, "%s\n", Enode->Message);
715 AeDecodeErrorMessageId (OutputFile, Enode, PrematureEOF, Total);
719 fprintf (OutputFile, "\n");
720 AePrintSubError (OutputFile, Child);
721 Child = Child->SubError;
726 /*******************************************************************************
728 * FUNCTION: AePrintSubError
730 * PARAMETERS: OutputFile - Output file
731 * Enode - Error node to print
735 * DESCRIPTION: Print the contents of an error nodes. This function is tailored
736 * to print error nodes that are SubErrors within ASL_ERROR_MSG
738 ******************************************************************************/
743 ASL_ERROR_MSG *Enode)
746 BOOLEAN PrematureEOF = FALSE;
747 const char *MainMessage;
750 MainMessage = AeDecodeMessageId (Enode->MessageId);
752 fprintf (OutputFile, " %s%s", MainMessage, "\n ");
753 (void) AePrintErrorSourceLine (OutputFile, Enode, &PrematureEOF, &Total);
754 fprintf (OutputFile, "\n");
758 /*******************************************************************************
760 * FUNCTION: AePrintErrorLog
762 * PARAMETERS: FileId - Where to output the error log
766 * DESCRIPTION: Print the entire contents of the error log
768 ******************************************************************************/
774 ASL_ERROR_MSG *Enode = AslGbl_ErrorLog;
777 /* Walk the error node list */
781 AePrintException (FileId, Enode, NULL);
787 /*******************************************************************************
789 * FUNCTION: AslInitEnode
791 * PARAMETERS: InputEnode - Input Error node to initialize
792 * Level - Seriousness (Warning/error, etc.)
793 * MessageId - Index into global message buffer
794 * CurrentLineNumber - Actual file line number
795 * LogicalLineNumber - Cumulative line number
796 * LogicalByteOffset - Byte offset in source file
797 * Column - Column in current line
798 * Filename - source filename
799 * ExtraMessage - additional error message
800 * SourceLine - Line of error source code
801 * SubError - SubError of this InputEnode
805 * DESCRIPTION: Initialize an Error node
807 ******************************************************************************/
809 static void AslInitEnode (
810 ASL_ERROR_MSG **InputEnode,
814 UINT32 LogicalLineNumber,
815 UINT32 LogicalByteOffset,
820 ASL_ERROR_MSG *SubError)
822 ASL_ERROR_MSG *Enode;
823 ASL_GLOBAL_FILE_NODE *FileNode;
826 *InputEnode = UtLocalCalloc (sizeof (ASL_ERROR_MSG));
828 Enode->Level = Level;
829 Enode->MessageId = MessageId;
830 Enode->LineNumber = LineNumber;
831 Enode->LogicalLineNumber = LogicalLineNumber;
832 Enode->LogicalByteOffset = LogicalByteOffset;
833 Enode->Column = Column;
834 Enode->SubError = SubError;
835 Enode->Message = NULL;
836 Enode->SourceLine = NULL;
837 Enode->Filename = NULL;
841 /* Allocate a buffer for the message and a new error node */
843 Enode->Message = UtLocalCacheCalloc (strlen (ExtraMessage) + 1);
845 /* Keep a copy of the extra message */
847 strcpy (Enode->Message, ExtraMessage);
852 Enode->SourceLine = UtLocalCalloc (strlen (SourceLine) + 1);
853 strcpy (Enode->SourceLine, SourceLine);
859 Enode->Filename = Filename;
860 Enode->FilenameLength = strlen (Filename);
861 if (Enode->FilenameLength < 6)
863 Enode->FilenameLength = 6;
866 FileNode = FlGetCurrentFileNode ();
872 if (!FlInputFileExists (Filename))
875 * This means that this file is an include file. Record the .src
876 * file as the error message source because this file is not in
877 * the global file list.
879 Enode->SourceFilename =
880 FileNode->Files[ASL_FILE_SOURCE_OUTPUT].Filename;
886 /*******************************************************************************
888 * FUNCTION: AslCommonError2
890 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
891 * MessageId - Index into global message buffer
892 * LineNumber - Actual file line number
893 * Column - Column in current line
894 * SourceLine - Actual source code line
895 * Filename - source filename
896 * ExtraMessage - additional error message
900 * DESCRIPTION: Create a new error node and add it to the error log
902 ******************************************************************************/
914 AslLogNewError (Level, MessageId, LineNumber, LineNumber, 0, Column,
915 Filename, ExtraMessage, SourceLine, NULL);
919 /*******************************************************************************
921 * FUNCTION: AslCommonError
923 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
924 * MessageId - Index into global message buffer
925 * CurrentLineNumber - Actual file line number
926 * LogicalLineNumber - Cumulative line number
927 * LogicalByteOffset - Byte offset in source file
928 * Column - Column in current line
929 * Filename - source filename
930 * ExtraMessage - additional error message
934 * DESCRIPTION: Create a new error node and add it to the error log
936 ******************************************************************************/
942 UINT32 CurrentLineNumber,
943 UINT32 LogicalLineNumber,
944 UINT32 LogicalByteOffset,
949 /* Check if user wants to ignore this exception */
951 if (AslIsExceptionIgnored (Level, MessageId))
956 AslLogNewError (Level, MessageId, CurrentLineNumber, LogicalLineNumber,
957 LogicalByteOffset, Column, Filename, ExtraMessage,
962 /*******************************************************************************
964 * FUNCTION: AslLogNewError
966 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
967 * MessageId - Index into global message buffer
968 * CurrentLineNumber - Actual file line number
969 * LogicalLineNumber - Cumulative line number
970 * LogicalByteOffset - Byte offset in source file
971 * Column - Column in current line
972 * Filename - source filename
973 * Message - additional error message
974 * SourceLine - Actual line of source code
975 * SubError - Sub-error associated with this error
979 * DESCRIPTION: Create a new error node and add it to the error log
981 ******************************************************************************/
987 UINT32 LogicalLineNumber,
988 UINT32 LogicalByteOffset,
993 ASL_ERROR_MSG *SubError)
995 ASL_ERROR_MSG *Enode = NULL;
996 UINT8 ModifiedLevel = GetModifiedLevel (Level, MessageId);
999 AslInitEnode (&Enode, ModifiedLevel, MessageId, LineNumber,
1000 LogicalLineNumber, LogicalByteOffset, Column, Filename, Message,
1001 SourceLine, SubError);
1003 /* Add the new node to the error node list */
1005 AeAddToErrorLog (Enode);
1007 if (AslGbl_DebugFlag)
1009 /* stderr is a file, send error to it immediately */
1011 AePrintException (ASL_FILE_STDERR, Enode, NULL);
1014 AslGbl_ExceptionCount[ModifiedLevel]++;
1015 if (!AslGbl_IgnoreErrors && AslGbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
1017 printf ("\nMaximum error count (%u) exceeded\n", ASL_MAX_ERROR_COUNT);
1019 AslGbl_SourceLine = 0;
1020 AslGbl_NextError = AslGbl_ErrorLog;
1021 CmCleanupAndExit ();
1029 /*******************************************************************************
1031 * FUNCTION: GetModifiedLevel
1033 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1034 * MessageId - Index into global message buffer
1036 * RETURN: UINT8 - modified level
1038 * DESCRIPTION: Get the modified level of exception codes that are reported as
1039 * errors from the -ww option.
1041 ******************************************************************************/
1049 UINT16 ExceptionCode;
1052 ExceptionCode = AeBuildFullExceptionCode (Level, MessageId);
1054 for (i = 0; i < AslGbl_ElevatedMessagesIndex; i++)
1056 if (ExceptionCode == AslGbl_ElevatedMessages[i])
1066 /*******************************************************************************
1068 * FUNCTION: AslIsExceptionIgnored
1070 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1071 * MessageId - Index into global message buffer
1075 * DESCRIPTION: Check if a particular exception is ignored. In this case it
1076 * means that the exception is (expected or disabled.
1078 ******************************************************************************/
1081 AslIsExceptionIgnored (
1085 BOOLEAN ExceptionIgnored;
1088 /* Note: this allows exception to be disabled and expected */
1090 ExceptionIgnored = AslIsExceptionDisabled (Level, MessageId);
1091 ExceptionIgnored |= AslIsExceptionExpected (Level, MessageId);
1093 return (AslGbl_AllExceptionsDisabled || ExceptionIgnored);
1097 /*******************************************************************************
1099 * FUNCTION: AslCheckExpectException
1105 * DESCRIPTION: Check the global expected messages table and raise an error
1106 * for each message that has not been received.
1108 ******************************************************************************/
1111 AslCheckExpectedExceptions (
1117 for (i = 0; i < AslGbl_ExpectedMessagesIndex; ++i)
1119 if (!AslGbl_ExpectedMessages[i].MessageReceived)
1121 AslError (ASL_ERROR, ASL_MSG_EXCEPTION_NOT_RECEIVED, NULL,
1122 AslGbl_ExpectedMessages[i].MessageIdStr);
1128 /*******************************************************************************
1130 * FUNCTION: AslExpectException
1132 * PARAMETERS: MessageIdString - ID of excepted exception during compile
1136 * DESCRIPTION: Enter a message ID into the global expected messages table
1137 * If these messages are not raised during the compilation, throw
1140 ******************************************************************************/
1143 AslExpectException (
1144 char *MessageIdString)
1149 /* Convert argument to an integer and validate it */
1151 MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
1153 if (MessageId > 6999)
1155 printf ("\"%s\" is not a valid warning/remark/erro ID\n",
1157 return (AE_BAD_PARAMETER);
1160 /* Insert value into the global expected message array */
1162 if (AslGbl_ExpectedMessagesIndex >= ASL_MAX_EXPECTED_MESSAGES)
1164 printf ("Too many messages have been registered as expected (max %d)\n",
1165 ASL_MAX_DISABLED_MESSAGES);
1169 AslGbl_ExpectedMessages[AslGbl_ExpectedMessagesIndex].MessageId = MessageId;
1170 AslGbl_ExpectedMessages[AslGbl_ExpectedMessagesIndex].MessageIdStr = MessageIdString;
1171 AslGbl_ExpectedMessages[AslGbl_ExpectedMessagesIndex].MessageReceived = FALSE;
1172 AslGbl_ExpectedMessagesIndex++;
1177 /*******************************************************************************
1179 * FUNCTION: AslDisableException
1181 * PARAMETERS: MessageIdString - ID to be disabled
1185 * DESCRIPTION: Enter a message ID into the global disabled messages table
1187 ******************************************************************************/
1190 AslDisableException (
1191 char *MessageIdString)
1196 /* Convert argument to an integer and validate it */
1198 MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
1200 if ((MessageId < 2000) || (MessageId > 6999))
1202 printf ("\"%s\" is not a valid warning/remark/error ID\n",
1204 return (AE_BAD_PARAMETER);
1207 /* Insert value into the global disabled message array */
1209 if (AslGbl_DisabledMessagesIndex >= ASL_MAX_DISABLED_MESSAGES)
1211 printf ("Too many messages have been disabled (max %d)\n",
1212 ASL_MAX_DISABLED_MESSAGES);
1216 AslGbl_DisabledMessages[AslGbl_DisabledMessagesIndex] = MessageId;
1217 AslGbl_DisabledMessagesIndex++;
1222 /*******************************************************************************
1224 * FUNCTION: AslElevateException
1226 * PARAMETERS: MessageIdString - ID of excepted exception during compile
1230 * DESCRIPTION: Enter a message ID into the global elevated exceptions table.
1231 * These messages will be considered as compilation errors.
1233 ******************************************************************************/
1236 AslElevateException (
1237 char *MessageIdString)
1242 /* Convert argument to an integer and validate it */
1244 MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
1246 if (MessageId > 6999)
1248 printf ("\"%s\" is not a valid warning/remark/erro ID\n",
1250 return (AE_BAD_PARAMETER);
1253 /* Insert value into the global expected message array */
1255 if (AslGbl_ElevatedMessagesIndex >= ASL_MAX_ELEVATED_MESSAGES)
1257 printf ("Too many messages have been registered as elevated (max %d)\n",
1258 ASL_MAX_DISABLED_MESSAGES);
1262 AslGbl_ElevatedMessages[AslGbl_ElevatedMessagesIndex] = MessageId;
1263 AslGbl_ElevatedMessagesIndex++;
1267 /*******************************************************************************
1269 * FUNCTION: AslIsExceptionDisabled
1271 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1272 * MessageId - Index into global message buffer
1274 * RETURN: TRUE if exception/message should be ignored
1276 * DESCRIPTION: Check if the user has specified options such that this
1277 * exception should be ignored
1279 ******************************************************************************/
1282 AslIsExceptionExpected (
1286 UINT32 EncodedMessageId;
1290 /* Mark this exception as received */
1292 EncodedMessageId = AeBuildFullExceptionCode (Level, MessageId);
1293 for (i = 0; i < AslGbl_ExpectedMessagesIndex; i++)
1295 /* Simple implementation via fixed array */
1297 if (EncodedMessageId == AslGbl_ExpectedMessages[i].MessageId)
1299 return (AslGbl_ExpectedMessages[i].MessageReceived = TRUE);
1307 /*******************************************************************************
1309 * FUNCTION: AslIsExceptionDisabled
1311 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1312 * MessageId - Index into global message buffer
1314 * RETURN: TRUE if exception/message should be ignored
1316 * DESCRIPTION: Check if the user has specified options such that this
1317 * exception should be ignored
1319 ******************************************************************************/
1322 AslIsExceptionDisabled (
1326 UINT32 EncodedMessageId;
1335 /* Check for global disable via -w1/-w2/-w3 options */
1337 if (Level > AslGbl_WarningLevel)
1347 * Ignore this error/warning/remark if it has been disabled by
1348 * the user (-vw option)
1350 EncodedMessageId = AeBuildFullExceptionCode (Level, MessageId);
1351 for (i = 0; i < AslGbl_DisabledMessagesIndex; i++)
1353 /* Simple implementation via fixed array */
1355 if (EncodedMessageId == AslGbl_DisabledMessages[i])
1370 /*******************************************************************************
1372 * FUNCTION: AslDualParseOpError
1374 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1375 * MainMsgId - Index into global message buffer
1376 * MainOp - Parse node where error happened
1377 * MainMsg - Message pertaining to the MainOp
1378 * SubMsgId - Index into global message buffer
1379 * SubOp - Additional parse node for better message
1380 * SubMsg - Message pertainint to SubOp
1385 * DESCRIPTION: Main error reporting routine for the ASL compiler for error
1386 * messages that point to multiple parse objects.
1388 ******************************************************************************/
1391 AslDualParseOpError (
1394 ACPI_PARSE_OBJECT *MainOp,
1397 ACPI_PARSE_OBJECT *SubOp,
1400 ASL_ERROR_MSG *SubEnode = NULL;
1403 /* Check if user wants to ignore this exception */
1405 if (AslIsExceptionIgnored (Level, MainMsgId) || !MainOp)
1412 AslInitEnode (&SubEnode, Level, SubMsgId, SubOp->Asl.LineNumber,
1413 SubOp->Asl.LogicalLineNumber, SubOp->Asl.LogicalByteOffset,
1414 SubOp->Asl.Column, SubOp->Asl.Filename, SubMsg,
1418 AslLogNewError (Level, MainMsgId, MainOp->Asl.LineNumber,
1419 MainOp->Asl.LogicalLineNumber, MainOp->Asl.LogicalByteOffset,
1420 MainOp->Asl.Column, MainOp->Asl.Filename, MainMsg,
1425 /*******************************************************************************
1427 * FUNCTION: AslError
1429 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1430 * MessageId - Index into global message buffer
1431 * Op - Parse node where error happened
1432 * ExtraMessage - additional error message
1436 * DESCRIPTION: Main error reporting routine for the ASL compiler (all code
1437 * except the parser.)
1439 ******************************************************************************/
1445 ACPI_PARSE_OBJECT *Op,
1450 AslCommonError (Level, MessageId, Op->Asl.LineNumber,
1451 Op->Asl.LogicalLineNumber,
1452 Op->Asl.LogicalByteOffset,
1454 Op->Asl.Filename, ExtraMessage);
1458 AslCommonError (Level, MessageId, 0,
1459 0, 0, 0, NULL, ExtraMessage);
1464 /*******************************************************************************
1466 * FUNCTION: AslCoreSubsystemError
1468 * PARAMETERS: Op - Parse node where error happened
1469 * Status - The ACPICA Exception
1470 * ExtraMessage - additional error message
1471 * Abort - TRUE -> Abort compilation
1475 * DESCRIPTION: Error reporting routine for exceptions returned by the ACPICA
1478 ******************************************************************************/
1481 AslCoreSubsystemError (
1482 ACPI_PARSE_OBJECT *Op,
1488 sprintf (AslGbl_MsgBuffer, "%s %s", AcpiFormatException (Status), ExtraMessage);
1492 AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION,
1494 Op->Asl.LogicalLineNumber,
1495 Op->Asl.LogicalByteOffset,
1497 Op->Asl.Filename, AslGbl_MsgBuffer);
1501 AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION,
1502 0, 0, 0, 0, NULL, AslGbl_MsgBuffer);
1512 /*******************************************************************************
1514 * FUNCTION: AslCompilererror
1516 * PARAMETERS: CompilerMessage - Error message from the parser
1518 * RETURN: Status (0 for now)
1520 * DESCRIPTION: Report an error situation discovered in a production
1521 * NOTE: don't change the name of this function, it is called
1522 * from the auto-generated parser.
1524 ******************************************************************************/
1528 const char *CompilerMessage)
1531 AslGbl_SyntaxError++;
1533 AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, AslGbl_CurrentLineNumber,
1534 AslGbl_LogicalLineNumber, AslGbl_CurrentLineOffset,
1535 AslGbl_CurrentColumn, AslGbl_Files[ASL_FILE_INPUT].Filename,
1536 ACPI_CAST_PTR (char, CompilerMessage));