1 /******************************************************************************
3 * Module Name: aslerror - Error handling and statistics
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2020, 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 <contrib/dev/acpica/compiler/aslcompiler.h>
154 #define _COMPONENT ACPI_COMPILER
155 ACPI_MODULE_NAME ("aslerror")
157 /* Local prototypes */
161 ASL_ERROR_MSG *Enode);
164 AslIsExceptionExpected (
171 AslIsExceptionDisabled (
177 ASL_ERROR_MSG **Enode,
181 UINT32 LogicalLineNumber,
182 UINT32 LogicalByteOffset,
187 ASL_ERROR_MSG *SubError);
194 UINT32 LogicalLineNumber,
195 UINT32 LogicalByteOffset,
200 ASL_ERROR_MSG *SubError);
205 ASL_ERROR_MSG *Enode);
213 /*******************************************************************************
221 * DESCRIPTION: Dump the error log and abort the compiler. Used for serious
224 ******************************************************************************/
231 AePrintErrorLog (ASL_FILE_STDERR);
232 if (AslGbl_DebugFlag)
234 /* Print error summary to stdout also */
236 AePrintErrorLog (ASL_FILE_STDOUT);
243 /*******************************************************************************
245 * FUNCTION: AeClearErrorLog
251 * DESCRIPTION: Empty the error list
253 ******************************************************************************/
259 ASL_ERROR_MSG *Enode = AslGbl_ErrorLog;
263 /* Walk the error node list */
272 AslGbl_ErrorLog = NULL;
276 /*******************************************************************************
278 * FUNCTION: AeAddToErrorLog
280 * PARAMETERS: Enode - An error node to add to the log
284 * DESCRIPTION: Add a new error node to the error log. The error log is
285 * ordered by the "logical" line number (cumulative line number
286 * including all include files.)
288 ******************************************************************************/
292 ASL_ERROR_MSG *Enode)
298 /* If Gbl_ErrorLog is null, this is the first error node */
300 if (!AslGbl_ErrorLog)
302 AslGbl_ErrorLog = Enode;
307 * Walk error list until we find a line number greater than ours.
308 * List is sorted according to line number.
311 Next = AslGbl_ErrorLog;
313 while ((Next) && (Next->LogicalLineNumber <= Enode->LogicalLineNumber))
319 /* Found our place in the list */
329 AslGbl_ErrorLog = Enode;
334 /*******************************************************************************
336 * FUNCTION: AeDecodeErrorMessageId
338 * PARAMETERS: OutputFile - Output file
339 * Enode - Error node to print
340 * PrematureEOF - True = PrematureEOF has been reached
341 * Total - Total length of line
345 * DESCRIPTION: Print the source line of an error.
347 ******************************************************************************/
350 AeDecodeErrorMessageId (
352 ASL_ERROR_MSG *Enode,
353 BOOLEAN PrematureEOF,
357 const char *MainMessage;
363 fprintf (OutputFile, "%s %4.4d -",
364 AeDecodeExceptionLevel (Enode->Level),
365 AeBuildFullExceptionCode (Enode->Level, Enode->MessageId));
367 MainMessage = AeDecodeMessageId (Enode->MessageId);
368 ExtraMessage = Enode->Message;
370 /* If a NULL line number, just print the decoded message */
372 if (!Enode->LineNumber)
374 fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage);
378 MsgLength = strlen (MainMessage);
381 /* Use the secondary/extra message as main message */
383 MainMessage = Enode->Message;
389 MsgLength = strlen (MainMessage);
393 if (AslGbl_VerboseErrors && !PrematureEOF)
397 fprintf (OutputFile, " %s",
402 SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2;
403 ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1;
405 if ((MsgLength + ErrorColumn) < (SourceColumn - 1))
407 fprintf (OutputFile, "%*s%s",
408 (int) ((SourceColumn - 1) - ErrorColumn),
413 fprintf (OutputFile, "%*s %s",
414 (int) ((SourceColumn - ErrorColumn) + 1), "^",
421 fprintf (OutputFile, " %s", MainMessage);
424 /* Print the extra info message if present */
428 fprintf (OutputFile, " (%s)", ExtraMessage);
433 fprintf (OutputFile, " and premature End-Of-File");
436 fprintf (OutputFile, "\n");
437 if (AslGbl_VerboseErrors && !Enode->SubError)
439 fprintf (OutputFile, "\n");
444 /*******************************************************************************
446 * FUNCTION: AePrintErrorSourceLine
448 * PARAMETERS: OutputFile - Output file
449 * Enode - Error node to print
450 * PrematureEOF - True = PrematureEOF has been reached
451 * Total - Number of characters printed so far
456 * DESCRIPTION: Print the source line of an error.
458 ******************************************************************************/
461 AePrintErrorSourceLine (
463 ASL_ERROR_MSG *Enode,
464 BOOLEAN *PrematureEOF,
470 FILE *SourceFile = NULL;
474 if (!Enode->SourceLine)
477 * Use the merged header/source file if present, otherwise
480 SourceFile = FlGetFileHandle (ASL_FILE_SOURCE_OUTPUT,
481 ASL_FILE_SOURCE_OUTPUT, Enode->SourceFilename);
484 SourceFile = FlGetFileHandle (ASL_FILE_INPUT,
485 ASL_FILE_INPUT, Enode->Filename);
490 /* Determine if the error occurred at source file EOF */
492 fseek (SourceFile, 0, SEEK_END);
493 FileSize = ftell (SourceFile);
495 if ((long) Enode->LogicalByteOffset >= FileSize)
497 *PrematureEOF = TRUE;
503 "[*** iASL: Source File Does not exist ***]\n");
508 /* Print filename and line number if present and valid */
510 if (AslGbl_VerboseErrors)
512 fprintf (OutputFile, "%-8s", Enode->Filename);
514 if (Enode->SourceLine && Enode->LineNumber)
516 fprintf (OutputFile, " %6u: %s",
517 Enode->LineNumber, Enode->SourceLine);
519 else if (Enode->LineNumber)
521 fprintf (OutputFile, " %6u: ", Enode->LineNumber);
524 * If not at EOF, get the corresponding source code line
525 * and display it. Don't attempt this if we have a
526 * premature EOF condition.
530 fprintf (OutputFile, "\n");
535 * Seek to the offset in the combined source file,
536 * read the source line, and write it to the output.
538 Actual = fseek (SourceFile,
539 (long) Enode->LogicalByteOffset, (int) SEEK_SET);
543 "[*** iASL: Seek error on source code temp file %s ***]",
544 AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
546 fprintf (OutputFile, "\n");
549 RActual = fread (&SourceByte, 1, 1, SourceFile);
553 "[*** iASL: Read error on source code temp file %s ***]",
554 AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
558 /* Read/write the source line, up to the maximum line length */
560 while (RActual && SourceByte && (SourceByte != '\n'))
564 /* After the max line length, we will just read the line, no write */
566 if (fwrite (&SourceByte, 1, 1, OutputFile) != 1)
568 printf ("[*** iASL: Write error on output file ***]\n");
572 else if (*Total == 256)
575 "\n[*** iASL: Very long input line, message below refers to column %u ***]",
579 RActual = fread (&SourceByte, 1, 1, SourceFile);
583 "[*** iASL: Read error on source code temp file %s ***]",
584 AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
591 fprintf (OutputFile, "\n");
597 * Less verbose version of the error message, enabled via the
598 * -vi switch. The format is compatible with MS Visual Studio.
600 fprintf (OutputFile, "%s", Enode->Filename);
602 if (Enode->LineNumber)
604 fprintf (OutputFile, "(%u) : ",
612 /*******************************************************************************
614 * FUNCTION: AePrintException
616 * PARAMETERS: FileId - ID of output file
617 * Enode - Error node to print
618 * Header - Additional text before each message
622 * DESCRIPTION: Print the contents of an error node.
624 * NOTE: We don't use the FlxxxFile I/O functions here because on error
625 * they abort the compiler and call this function! Since we
626 * are reporting errors here, we ignore most output errors and
627 * just try to get out as much as we can.
629 ******************************************************************************/
634 ASL_ERROR_MSG *Enode,
638 BOOLEAN PrematureEOF = FALSE;
641 ASL_ERROR_MSG *Child = Enode->SubError;
650 * Only listing files have a header, and remarks/optimizations
655 /* Ignore remarks if requested */
657 switch (Enode->Level)
663 if (!AslGbl_DisplayWarnings)
671 if (!AslGbl_DisplayRemarks)
677 case ASL_OPTIMIZATION:
679 if (!AslGbl_DisplayOptimizations)
691 /* Get the various required file handles */
693 OutputFile = AslGbl_Files[FileId].Handle;
697 fprintf (OutputFile, "%s", Header);
700 if (!Enode->Filename)
702 AeDecodeErrorMessageId (OutputFile, Enode, PrematureEOF, Total);
706 Status = AePrintErrorSourceLine (OutputFile, Enode, &PrematureEOF, &Total);
707 if (ACPI_FAILURE (Status))
712 /* If a NULL message ID, just print the raw message */
714 if (Enode->MessageId == 0)
716 fprintf (OutputFile, "%s\n", Enode->Message);
720 AeDecodeErrorMessageId (OutputFile, Enode, PrematureEOF, Total);
724 fprintf (OutputFile, "\n");
725 AePrintSubError (OutputFile, Child);
726 Child = Child->SubError;
731 /*******************************************************************************
733 * FUNCTION: AePrintSubError
735 * PARAMETERS: OutputFile - Output file
736 * Enode - Error node to print
740 * DESCRIPTION: Print the contents of an error node. This function is tailored
741 * to print error nodes that are SubErrors within ASL_ERROR_MSG
743 ******************************************************************************/
748 ASL_ERROR_MSG *Enode)
751 BOOLEAN PrematureEOF = FALSE;
752 const char *MainMessage;
755 MainMessage = AeDecodeMessageId (Enode->MessageId);
757 fprintf (OutputFile, " %s", MainMessage);
761 fprintf (OutputFile, "(%s)", Enode->Message);
764 fprintf (OutputFile, "\n ");
765 (void) AePrintErrorSourceLine (OutputFile, Enode, &PrematureEOF, &Total);
766 fprintf (OutputFile, "\n");
770 /*******************************************************************************
772 * FUNCTION: AePrintErrorLog
774 * PARAMETERS: FileId - Where to output the error log
778 * DESCRIPTION: Print the entire contents of the error log
780 ******************************************************************************/
786 ASL_ERROR_MSG *Enode = AslGbl_ErrorLog;
789 /* Walk the error node list */
793 AePrintException (FileId, Enode, NULL);
799 /*******************************************************************************
801 * FUNCTION: AslInitEnode
803 * PARAMETERS: InputEnode - Input Error node to initialize
804 * Level - Seriousness (Warning/error, etc.)
805 * MessageId - Index into global message buffer
806 * CurrentLineNumber - Actual file line number
807 * LogicalLineNumber - Cumulative line number
808 * LogicalByteOffset - Byte offset in source file
809 * Column - Column in current line
810 * Filename - Source filename
811 * ExtraMessage - Additional error message
812 * SourceLine - Line of error source code
813 * SubError - SubError of this InputEnode
817 * DESCRIPTION: Initialize an Error node
819 ******************************************************************************/
821 static void AslInitEnode (
822 ASL_ERROR_MSG **InputEnode,
826 UINT32 LogicalLineNumber,
827 UINT32 LogicalByteOffset,
832 ASL_ERROR_MSG *SubError)
834 ASL_ERROR_MSG *Enode;
835 ASL_GLOBAL_FILE_NODE *FileNode;
838 *InputEnode = UtLocalCalloc (sizeof (ASL_ERROR_MSG));
840 Enode->Level = Level;
841 Enode->MessageId = MessageId;
842 Enode->LineNumber = LineNumber;
843 Enode->LogicalLineNumber = LogicalLineNumber;
844 Enode->LogicalByteOffset = LogicalByteOffset;
845 Enode->Column = Column;
846 Enode->SubError = SubError;
847 Enode->Message = NULL;
848 Enode->SourceLine = NULL;
849 Enode->Filename = NULL;
853 /* Allocate a buffer for the message and a new error node */
855 Enode->Message = UtLocalCacheCalloc (strlen (ExtraMessage) + 1);
857 /* Keep a copy of the extra message */
859 strcpy (Enode->Message, ExtraMessage);
864 Enode->SourceLine = UtLocalCalloc (strlen (SourceLine) + 1);
865 strcpy (Enode->SourceLine, SourceLine);
871 Enode->Filename = Filename;
872 Enode->FilenameLength = strlen (Filename);
873 if (Enode->FilenameLength < 6)
875 Enode->FilenameLength = 6;
879 * Attempt to get the file node of the filename listed in the parse
880 * node. If the name doesn't exist in the global file node, it is
881 * because the file is included by #include or ASL include. In this
882 * case, get the current file node. The source output of the current
883 * file will contain the contents of the file listed in the parse node.
885 FileNode = FlGetFileNode (ASL_FILE_INPUT, Filename);
888 FileNode = FlGetCurrentFileNode ();
891 Enode->SourceFilename =
892 FileNode->Files[ASL_FILE_SOURCE_OUTPUT].Filename;
897 /*******************************************************************************
899 * FUNCTION: AslCommonError2
901 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
902 * MessageId - Index into global message buffer
903 * LineNumber - Actual file line number
904 * Column - Column in current line
905 * SourceLine - Actual source code line
906 * Filename - Source filename
907 * ExtraMessage - Additional error message
911 * DESCRIPTION: Create a new error node and add it to the error log
913 ******************************************************************************/
925 AslLogNewError (Level, MessageId, LineNumber, LineNumber, 0, Column,
926 Filename, ExtraMessage, SourceLine, NULL);
930 /*******************************************************************************
932 * FUNCTION: AslCommonError
934 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
935 * MessageId - Index into global message buffer
936 * CurrentLineNumber - Actual file line number
937 * LogicalLineNumber - Cumulative line number
938 * LogicalByteOffset - Byte offset in source file
939 * Column - Column in current line
940 * Filename - Source filename
941 * ExtraMessage - Additional error message
945 * DESCRIPTION: Create a new error node and add it to the error log
947 ******************************************************************************/
953 UINT32 CurrentLineNumber,
954 UINT32 LogicalLineNumber,
955 UINT32 LogicalByteOffset,
960 /* Check if user wants to ignore this exception */
962 if (AslIsExceptionIgnored (Filename, LogicalLineNumber, Level, MessageId))
967 AslLogNewError (Level, MessageId, CurrentLineNumber, LogicalLineNumber,
968 LogicalByteOffset, Column, Filename, ExtraMessage,
973 /*******************************************************************************
975 * FUNCTION: AslLogNewError
977 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
978 * MessageId - Index into global message buffer
979 * CurrentLineNumber - Actual file line number
980 * LogicalLineNumber - Cumulative line number
981 * LogicalByteOffset - Byte offset in source file
982 * Column - Column in current line
983 * Filename - Source filename
984 * Message - Additional error message
985 * SourceLine - Actual line of source code
986 * SubError - Sub-error associated with this error
990 * DESCRIPTION: Create a new error node and add it to the error log
992 ******************************************************************************/
998 UINT32 LogicalLineNumber,
999 UINT32 LogicalByteOffset,
1004 ASL_ERROR_MSG *SubError)
1006 ASL_ERROR_MSG *Enode = NULL;
1007 UINT8 ModifiedLevel = GetModifiedLevel (Level, MessageId);
1010 AslInitEnode (&Enode, ModifiedLevel, MessageId, LineNumber,
1011 LogicalLineNumber, LogicalByteOffset, Column, Filename, Message,
1012 SourceLine, SubError);
1014 /* Add the new node to the error node list */
1016 AeAddToErrorLog (Enode);
1018 if (AslGbl_DebugFlag)
1020 /* stderr is a file, send error to it immediately */
1022 AePrintException (ASL_FILE_STDERR, Enode, NULL);
1025 AslGbl_ExceptionCount[ModifiedLevel]++;
1026 if (!AslGbl_IgnoreErrors && AslGbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
1028 printf ("\nMaximum error count (%u) exceeded\n", ASL_MAX_ERROR_COUNT);
1030 AslGbl_SourceLine = 0;
1031 AslGbl_NextError = AslGbl_ErrorLog;
1032 CmCleanupAndExit ();
1040 /*******************************************************************************
1042 * FUNCTION: GetModifiedLevel
1044 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1045 * MessageId - Index into global message buffer
1047 * RETURN: UINT8 - Modified level
1049 * DESCRIPTION: Get the modified level of exception codes that are reported as
1050 * errors from the -ww option.
1052 ******************************************************************************/
1060 UINT16 ExceptionCode;
1063 ExceptionCode = AeBuildFullExceptionCode (Level, MessageId);
1065 for (i = 0; i < AslGbl_ElevatedMessagesIndex; i++)
1067 if (ExceptionCode == AslGbl_ElevatedMessages[i])
1077 /*******************************************************************************
1079 * FUNCTION: AslIsExceptionIgnored
1081 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1082 * MessageId - Index into global message buffer
1086 * DESCRIPTION: Check if a particular exception is ignored. In this case it
1087 * means that the exception is (expected or disabled.
1089 ******************************************************************************/
1092 AslIsExceptionIgnored (
1098 BOOLEAN ExceptionIgnored;
1101 /* Note: this allows exception to be disabled and expected */
1103 ExceptionIgnored = AslIsExceptionDisabled (Level, MessageId);
1105 AslIsExceptionExpected (Filename, LineNumber, Level, MessageId);
1107 return (AslGbl_AllExceptionsDisabled || ExceptionIgnored);
1111 /*******************************************************************************
1113 * FUNCTION: AslCheckExpectedException
1119 * DESCRIPTION: Check the global expected messages table and raise an error
1120 * for each message that has not been received.
1122 ******************************************************************************/
1125 AslCheckExpectedExceptions (
1129 ASL_EXPECTED_MSG_NODE *Current = AslGbl_ExpectedErrorCodeList;
1130 ASL_LOCATION_NODE *LocationNode;
1133 for (i = 0; i < AslGbl_ExpectedMessagesIndex; ++i)
1135 if (!AslGbl_ExpectedMessages[i].MessageReceived)
1137 AslError (ASL_ERROR, ASL_MSG_EXCEPTION_NOT_RECEIVED, NULL,
1138 AslGbl_ExpectedMessages[i].MessageIdStr);
1144 LocationNode = Current->LocationList;
1146 while (LocationNode)
1148 if (!LocationNode->MessageReceived)
1150 AslCommonError (ASL_ERROR, ASL_MSG_EXCEPTION_NOT_RECEIVED,
1151 LocationNode->LineNumber, LocationNode->LineNumber,
1152 LocationNode->LogicalByteOffset, LocationNode->Column,
1153 LocationNode->Filename, Current->MessageIdStr);
1156 LocationNode = LocationNode->Next;
1159 Current = Current->Next;
1164 /*******************************************************************************
1166 * FUNCTION: AslLogExpectedException
1168 * PARAMETERS: MessageIdString - ID of excepted exception during compile
1172 * DESCRIPTION: Enter a message ID into the global expected messages table
1173 * If these messages are not raised during the compilation, throw
1176 ******************************************************************************/
1179 AslLogExpectedException (
1180 char *MessageIdString)
1185 /* Convert argument to an integer and validate it */
1187 MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
1189 if (MessageId > 6999)
1191 printf ("\"%s\" is not a valid warning/remark/erro ID\n",
1193 return (AE_BAD_PARAMETER);
1196 /* Insert value into the global expected message array */
1198 if (AslGbl_ExpectedMessagesIndex >= ASL_MAX_EXPECTED_MESSAGES)
1200 printf ("Too many messages have been registered as expected (max %d)\n",
1201 ASL_MAX_DISABLED_MESSAGES);
1205 AslGbl_ExpectedMessages[AslGbl_ExpectedMessagesIndex].MessageId = MessageId;
1206 AslGbl_ExpectedMessages[AslGbl_ExpectedMessagesIndex].MessageIdStr = MessageIdString;
1207 AslGbl_ExpectedMessages[AslGbl_ExpectedMessagesIndex].MessageReceived = FALSE;
1208 AslGbl_ExpectedMessagesIndex++;
1213 /*******************************************************************************
1215 * FUNCTION: AslLogExpectedExceptionByLine
1217 * PARAMETERS: MessageIdString - ID of excepted exception during compile
1221 * DESCRIPTION: Enter a message ID into the global expected messages table
1222 * based on file and line number. If these messages are not raised
1223 * during the compilation, throw an error.
1225 ******************************************************************************/
1228 AslLogExpectedExceptionByLine (
1229 char *MessageIdString)
1231 ASL_LOCATION_NODE *NewErrorLocationNode;
1232 ASL_EXPECTED_MSG_NODE *Current = AslGbl_ExpectedErrorCodeList;
1236 NewErrorLocationNode = UtLocalCalloc (sizeof (ASL_LOCATION_NODE));
1238 NewErrorLocationNode->LineNumber = AslGbl_CurrentLineNumber;
1239 NewErrorLocationNode->Filename = AslGbl_Files[ASL_FILE_INPUT].Filename;
1240 NewErrorLocationNode->LogicalByteOffset = AslGbl_CurrentLineOffset;
1241 NewErrorLocationNode->Column = AslGbl_CurrentColumn;
1243 MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
1245 /* search the existing list for a matching message ID */
1247 while (Current && Current->MessageId != MessageId )
1249 Current = Current->Next;
1253 /* ID was not found, create a new node for this message ID */
1255 Current = UtLocalCalloc (sizeof (ASL_EXPECTED_MSG_NODE));
1257 Current->Next = AslGbl_ExpectedErrorCodeList;
1258 Current->MessageIdStr = MessageIdString;
1259 Current->MessageId = MessageId;
1260 AslGbl_ExpectedErrorCodeList = Current;
1263 NewErrorLocationNode->Next = Current->LocationList;
1264 Current->LocationList = NewErrorLocationNode;
1268 /*******************************************************************************
1270 * FUNCTION: AslDisableException
1272 * PARAMETERS: MessageIdString - ID to be disabled
1276 * DESCRIPTION: Enter a message ID into the global disabled messages table
1278 ******************************************************************************/
1281 AslDisableException (
1282 char *MessageIdString)
1287 /* Convert argument to an integer and validate it */
1289 MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
1291 if ((MessageId < 2000) || (MessageId > 6999))
1293 printf ("\"%s\" is not a valid warning/remark/error ID\n",
1295 return (AE_BAD_PARAMETER);
1298 /* Insert value into the global disabled message array */
1300 if (AslGbl_DisabledMessagesIndex >= ASL_MAX_DISABLED_MESSAGES)
1302 printf ("Too many messages have been disabled (max %d)\n",
1303 ASL_MAX_DISABLED_MESSAGES);
1307 AslGbl_DisabledMessages[AslGbl_DisabledMessagesIndex] = MessageId;
1308 AslGbl_DisabledMessagesIndex++;
1313 /*******************************************************************************
1315 * FUNCTION: AslElevateException
1317 * PARAMETERS: MessageIdString - ID of excepted exception during compile
1321 * DESCRIPTION: Enter a message ID into the global elevated exceptions table.
1322 * These messages will be considered as compilation errors.
1324 ******************************************************************************/
1327 AslElevateException (
1328 char *MessageIdString)
1333 /* Convert argument to an integer and validate it */
1335 MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
1337 if (MessageId > 6999)
1339 printf ("\"%s\" is not a valid warning/remark/erro ID\n",
1341 return (AE_BAD_PARAMETER);
1344 /* Insert value into the global expected message array */
1346 if (AslGbl_ElevatedMessagesIndex >= ASL_MAX_ELEVATED_MESSAGES)
1348 printf ("Too many messages have been registered as elevated (max %d)\n",
1349 ASL_MAX_DISABLED_MESSAGES);
1353 AslGbl_ElevatedMessages[AslGbl_ElevatedMessagesIndex] = MessageId;
1354 AslGbl_ElevatedMessagesIndex++;
1359 /*******************************************************************************
1361 * FUNCTION: AslIsExceptionDisabled
1363 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1364 * MessageId - Index into global message buffer
1366 * RETURN: TRUE if exception/message should be ignored
1368 * DESCRIPTION: Check if the user has specified options such that this
1369 * exception should be ignored
1371 ******************************************************************************/
1374 AslIsExceptionExpected (
1380 ASL_EXPECTED_MSG_NODE *Current = AslGbl_ExpectedErrorCodeList;
1381 ASL_LOCATION_NODE *CurrentErrorLocation;
1382 UINT32 EncodedMessageId;
1386 /* Mark this exception as received */
1388 EncodedMessageId = AeBuildFullExceptionCode (Level, MessageId);
1389 for (i = 0; i < AslGbl_ExpectedMessagesIndex; i++)
1391 /* Simple implementation via fixed array */
1393 if (EncodedMessageId == AslGbl_ExpectedMessages[i].MessageId)
1395 return (AslGbl_ExpectedMessages[i].MessageReceived = TRUE);
1399 while (Current && Current->MessageId != EncodedMessageId)
1401 Current = Current->Next;
1408 CurrentErrorLocation = Current->LocationList;
1410 while (CurrentErrorLocation)
1412 if (!strcmp (CurrentErrorLocation->Filename, Filename) &&
1413 CurrentErrorLocation->LineNumber == LineNumber)
1415 return (CurrentErrorLocation->MessageReceived = TRUE);
1418 CurrentErrorLocation = CurrentErrorLocation->Next;
1425 /*******************************************************************************
1427 * FUNCTION: AslIsExceptionDisabled
1429 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1430 * MessageId - Index into global message buffer
1432 * RETURN: TRUE if exception/message should be ignored
1434 * DESCRIPTION: Check if the user has specified options such that this
1435 * exception should be ignored
1437 ******************************************************************************/
1440 AslIsExceptionDisabled (
1444 UINT32 EncodedMessageId;
1453 /* Check for global disable via -w1/-w2/-w3 options */
1455 if (Level > AslGbl_WarningLevel)
1465 * Ignore this error/warning/remark if it has been disabled by
1466 * the user (-vw option)
1468 EncodedMessageId = AeBuildFullExceptionCode (Level, MessageId);
1469 for (i = 0; i < AslGbl_DisabledMessagesIndex; i++)
1471 /* Simple implementation via fixed array */
1473 if (EncodedMessageId == AslGbl_DisabledMessages[i])
1488 /*******************************************************************************
1490 * FUNCTION: AslDualParseOpError
1492 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1493 * MainMsgId - Index into global message buffer
1494 * MainOp - Parse node where error happened
1495 * MainMsg - Message pertaining to the MainOp
1496 * SubMsgId - Index into global message buffer
1497 * SubOp - Additional parse node for better message
1498 * SubMsg - Message pertaining to SubOp
1503 * DESCRIPTION: Main error reporting routine for the ASL compiler for error
1504 * messages that point to multiple parse objects.
1506 ******************************************************************************/
1509 AslDualParseOpError (
1512 ACPI_PARSE_OBJECT *MainOp,
1515 ACPI_PARSE_OBJECT *SubOp,
1518 ASL_ERROR_MSG *SubEnode = NULL;
1521 /* Check if user wants to ignore this exception */
1523 if (!MainOp || AslIsExceptionIgnored (MainOp->Asl.Filename,
1524 MainOp->Asl.LogicalLineNumber, Level, MainMsgId))
1531 AslInitEnode (&SubEnode, Level, SubMsgId, SubOp->Asl.LineNumber,
1532 SubOp->Asl.LogicalLineNumber, SubOp->Asl.LogicalByteOffset,
1533 SubOp->Asl.Column, SubOp->Asl.Filename, SubMsg,
1537 AslLogNewError (Level, MainMsgId, MainOp->Asl.LineNumber,
1538 MainOp->Asl.LogicalLineNumber, MainOp->Asl.LogicalByteOffset,
1539 MainOp->Asl.Column, MainOp->Asl.Filename, MainMsg,
1544 /*******************************************************************************
1546 * FUNCTION: AslError
1548 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1549 * MessageId - Index into global message buffer
1550 * Op - Parse node where error happened
1551 * ExtraMessage - Additional error message
1555 * DESCRIPTION: Main error reporting routine for the ASL compiler (all code
1556 * except the parser.)
1558 ******************************************************************************/
1564 ACPI_PARSE_OBJECT *Op,
1569 AslCommonError (Level, MessageId, Op->Asl.LineNumber,
1570 Op->Asl.LogicalLineNumber,
1571 Op->Asl.LogicalByteOffset,
1573 Op->Asl.Filename, ExtraMessage);
1577 AslCommonError (Level, MessageId, 0,
1578 0, 0, 0, NULL, ExtraMessage);
1583 /*******************************************************************************
1585 * FUNCTION: AslCoreSubsystemError
1587 * PARAMETERS: Op - Parse node where error happened
1588 * Status - The ACPICA Exception
1589 * ExtraMessage - Additional error message
1590 * Abort - TRUE -> Abort compilation
1594 * DESCRIPTION: Error reporting routine for exceptions returned by the ACPICA
1597 ******************************************************************************/
1600 AslCoreSubsystemError (
1601 ACPI_PARSE_OBJECT *Op,
1607 sprintf (AslGbl_MsgBuffer, "%s %s", AcpiFormatException (Status), ExtraMessage);
1611 AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION,
1613 Op->Asl.LogicalLineNumber,
1614 Op->Asl.LogicalByteOffset,
1616 Op->Asl.Filename, AslGbl_MsgBuffer);
1620 AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION,
1621 0, 0, 0, 0, NULL, AslGbl_MsgBuffer);
1631 /*******************************************************************************
1633 * FUNCTION: AslCompilererror
1635 * PARAMETERS: CompilerMessage - Error message from the parser
1637 * RETURN: Status (0 for now)
1639 * DESCRIPTION: Report an error situation discovered in a production
1640 * NOTE: don't change the name of this function, it is called
1641 * from the auto-generated parser.
1643 ******************************************************************************/
1647 const char *CompilerMessage)
1650 AslGbl_SyntaxError++;
1652 AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, AslGbl_CurrentLineNumber,
1653 AslGbl_LogicalLineNumber, AslGbl_CurrentLineOffset,
1654 AslGbl_CurrentColumn, AslGbl_Files[ASL_FILE_INPUT].Filename,
1655 ACPI_CAST_PTR (char, CompilerMessage));