1 /******************************************************************************
3 * Module Name: aslerror - Error handling and statistics
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2018, 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);
205 /*******************************************************************************
213 * DESCRIPTION: Dump the error log and abort the compiler. Used for serious
216 ******************************************************************************/
223 AePrintErrorLog (ASL_FILE_STDERR);
226 /* Print error summary to stdout also */
228 AePrintErrorLog (ASL_FILE_STDOUT);
235 /*******************************************************************************
237 * FUNCTION: AeClearErrorLog
243 * DESCRIPTION: Empty the error list
245 ******************************************************************************/
251 ASL_ERROR_MSG *Enode = Gbl_ErrorLog;
255 /* Walk the error node list */
268 /*******************************************************************************
270 * FUNCTION: AeAddToErrorLog
272 * PARAMETERS: Enode - An error node to add to the log
276 * DESCRIPTION: Add a new error node to the error log. The error log is
277 * ordered by the "logical" line number (cumulative line number
278 * including all include files.)
280 ******************************************************************************/
284 ASL_ERROR_MSG *Enode)
290 /* If Gbl_ErrorLog is null, this is the first error node */
294 Gbl_ErrorLog = Enode;
299 * Walk error list until we find a line number greater than ours.
300 * List is sorted according to line number.
305 while ((Next) && (Next->LogicalLineNumber <= Enode->LogicalLineNumber))
311 /* Found our place in the list */
321 Gbl_ErrorLog = Enode;
326 /*******************************************************************************
328 * FUNCTION: AeDecodeErrorMessageId
330 * PARAMETERS: OutputFile - Output file
331 * Enode - Error node to print
332 * PrematureEOF - True = PrematureEOF has been reached
333 * Total - Total legth of line
337 * DESCRIPTION: Print the source line of an error.
339 ******************************************************************************/
342 AeDecodeErrorMessageId (
344 ASL_ERROR_MSG *Enode,
345 BOOLEAN PrematureEOF,
349 const char *MainMessage;
355 fprintf (OutputFile, "%s %4.4d -",
356 AeDecodeExceptionLevel (Enode->Level),
357 AeBuildFullExceptionCode (Enode->Level, Enode->MessageId));
359 MainMessage = AeDecodeMessageId (Enode->MessageId);
360 ExtraMessage = Enode->Message;
362 /* If a NULL line number, just print the decoded message */
364 if (!Enode->LineNumber)
366 fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage);
370 MsgLength = strlen (MainMessage);
373 /* Use the secondary/extra message as main message */
375 MainMessage = Enode->Message;
381 MsgLength = strlen (MainMessage);
385 if (Gbl_VerboseErrors && !PrematureEOF)
389 fprintf (OutputFile, " %s",
394 SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2;
395 ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1;
397 if ((MsgLength + ErrorColumn) < (SourceColumn - 1))
399 fprintf (OutputFile, "%*s%s",
400 (int) ((SourceColumn - 1) - ErrorColumn),
405 fprintf (OutputFile, "%*s %s",
406 (int) ((SourceColumn - ErrorColumn) + 1), "^",
413 fprintf (OutputFile, " %s", MainMessage);
416 /* Print the extra info message if present */
420 fprintf (OutputFile, " (%s)", ExtraMessage);
425 fprintf (OutputFile, " and premature End-Of-File");
428 fprintf (OutputFile, "\n");
429 if (Gbl_VerboseErrors && !Enode->SubError)
431 fprintf (OutputFile, "\n");
436 /*******************************************************************************
438 * FUNCTION: AePrintErrorSourceLine
440 * PARAMETERS: OutputFile - Output file
441 * Enode - Error node to print
442 * PrematureEOF - True = PrematureEOF has been reached
443 * Total - amount of characters printed so far
448 * DESCRIPTION: Print the source line of an error.
450 ******************************************************************************/
453 AePrintErrorSourceLine (
455 ASL_ERROR_MSG *Enode,
456 BOOLEAN *PrematureEOF,
462 FILE *SourceFile = NULL;
466 if (!Enode->SourceLine)
469 * Use the merged header/source file if present, otherwise
472 SourceFile = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
475 SourceFile = Gbl_Files[ASL_FILE_INPUT].Handle;
480 /* Determine if the error occurred at source file EOF */
482 fseek (SourceFile, 0, SEEK_END);
483 FileSize = ftell (SourceFile);
485 if ((long) Enode->LogicalByteOffset >= FileSize)
487 *PrematureEOF = TRUE;
493 "[*** iASL: Source File Does not exist ***]\n");
498 /* Print filename and line number if present and valid */
500 if (Gbl_VerboseErrors)
502 fprintf (OutputFile, "%-8s", Enode->Filename);
504 if (Enode->SourceLine && Enode->LineNumber)
506 fprintf (OutputFile, " %6u: %s",
507 Enode->LineNumber, Enode->SourceLine);
509 else if (Enode->LineNumber)
511 fprintf (OutputFile, " %6u: ", Enode->LineNumber);
514 * If not at EOF, get the corresponding source code line
515 * and display it. Don't attempt this if we have a
516 * premature EOF condition.
520 fprintf (OutputFile, "\n");
524 * Seek to the offset in the combined source file,
525 * read the source line, and write it to the output.
527 Actual = fseek (SourceFile,
528 (long) Enode->LogicalByteOffset, (int) SEEK_SET);
532 "[*** iASL: Seek error on source code temp file %s ***]",
533 Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
535 fprintf (OutputFile, "\n");
538 RActual = fread (&SourceByte, 1, 1, SourceFile);
542 "[*** iASL: Read error on source code temp file %s ***]",
543 Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
546 /* Read/write the source line, up to the maximum line length */
548 while (RActual && SourceByte && (SourceByte != '\n'))
552 /* After the max line length, we will just read the line, no write */
554 if (fwrite (&SourceByte, 1, 1, OutputFile) != 1)
556 printf ("[*** iASL: Write error on output file ***]\n");
560 else if (*Total == 256)
563 "\n[*** iASL: Very long input line, message below refers to column %u ***]",
567 RActual = fread (&SourceByte, 1, 1, SourceFile);
571 "[*** iASL: Read error on source code temp file %s ***]",
572 Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
579 fprintf (OutputFile, "\n");
585 * Less verbose version of the error message, enabled via the
586 * -vi switch. The format is compatible with MS Visual Studio.
588 fprintf (OutputFile, "%s", Enode->Filename);
590 if (Enode->LineNumber)
592 fprintf (OutputFile, "(%u) : ",
600 /*******************************************************************************
602 * FUNCTION: AePrintException
604 * PARAMETERS: FileId - ID of output file
605 * Enode - Error node to print
606 * Header - Additional text before each message
610 * DESCRIPTION: Print the contents of an error node.
612 * NOTE: We don't use the FlxxxFile I/O functions here because on error
613 * they abort the compiler and call this function! Since we
614 * are reporting errors here, we ignore most output errors and
615 * just try to get out as much as we can.
617 ******************************************************************************/
622 ASL_ERROR_MSG *Enode,
626 BOOLEAN PrematureEOF = FALSE;
629 ASL_ERROR_MSG *Child = Enode->SubError;
638 * Only listing files have a header, and remarks/optimizations
643 /* Ignore remarks if requested */
645 switch (Enode->Level)
651 if (!Gbl_DisplayWarnings)
659 if (!Gbl_DisplayRemarks)
665 case ASL_OPTIMIZATION:
667 if (!Gbl_DisplayOptimizations)
679 /* Get the various required file handles */
681 OutputFile = Gbl_Files[FileId].Handle;
685 fprintf (OutputFile, "%s", Header);
688 if (!Enode->Filename)
690 AeDecodeErrorMessageId (OutputFile, Enode, PrematureEOF, Total);
694 Status = AePrintErrorSourceLine (OutputFile, Enode, &PrematureEOF, &Total);
695 if (ACPI_FAILURE (Status))
700 /* If a NULL message ID, just print the raw message */
702 if (Enode->MessageId == 0)
704 fprintf (OutputFile, "%s\n", Enode->Message);
708 AeDecodeErrorMessageId (OutputFile, Enode, PrematureEOF, Total);
712 fprintf (OutputFile, "\n");
713 AePrintSubError (OutputFile, Child);
714 Child = Child->SubError;
719 /*******************************************************************************
721 * FUNCTION: AePrintSubError
723 * PARAMETERS: OutputFile - Output file
724 * Enode - Error node to print
728 * DESCRIPTION: Print the contents of an error nodes. This function is tailored
729 * to print error nodes that are SubErrors within ASL_ERROR_MSG
731 ******************************************************************************/
736 ASL_ERROR_MSG *Enode)
739 BOOLEAN PrematureEOF = FALSE;
740 const char *MainMessage;
743 MainMessage = AeDecodeMessageId (Enode->MessageId);
745 fprintf (OutputFile, " %s%s", MainMessage, "\n ");
746 (void) AePrintErrorSourceLine (OutputFile, Enode, &PrematureEOF, &Total);
747 fprintf (OutputFile, "\n");
751 /*******************************************************************************
753 * FUNCTION: AePrintErrorLog
755 * PARAMETERS: FileId - Where to output the error log
759 * DESCRIPTION: Print the entire contents of the error log
761 ******************************************************************************/
767 ASL_ERROR_MSG *Enode = Gbl_ErrorLog;
770 /* Walk the error node list */
774 AePrintException (FileId, Enode, NULL);
780 /*******************************************************************************
782 * FUNCTION: AslInitEnode
784 * PARAMETERS: InputEnode - Input Error node to initialize
785 * Level - Seriousness (Warning/error, etc.)
786 * MessageId - Index into global message buffer
787 * CurrentLineNumber - Actual file line number
788 * LogicalLineNumber - Cumulative line number
789 * LogicalByteOffset - Byte offset in source file
790 * Column - Column in current line
791 * Filename - source filename
792 * ExtraMessage - additional error message
793 * SourceLine - Line of error source code
794 * SubError - SubError of this InputEnode
798 * DESCRIPTION: Initialize an Error node
800 ******************************************************************************/
802 static void AslInitEnode (
803 ASL_ERROR_MSG **InputEnode,
807 UINT32 LogicalLineNumber,
808 UINT32 LogicalByteOffset,
813 ASL_ERROR_MSG *SubError)
815 ASL_ERROR_MSG *Enode;
818 *InputEnode = UtLocalCalloc (sizeof (ASL_ERROR_MSG));
820 Enode->Level = Level;
821 Enode->MessageId = MessageId;
822 Enode->LineNumber = LineNumber;
823 Enode->LogicalLineNumber = LogicalLineNumber;
824 Enode->LogicalByteOffset = LogicalByteOffset;
825 Enode->Column = Column;
826 Enode->SubError = SubError;
827 Enode->Message = NULL;
828 Enode->SourceLine = NULL;
829 Enode->Filename = NULL;
833 /* Allocate a buffer for the message and a new error node */
835 Enode->Message = UtLocalCacheCalloc (strlen (ExtraMessage) + 1);
837 /* Keep a copy of the extra message */
839 strcpy (Enode->Message, ExtraMessage);
844 Enode->SourceLine = UtLocalCalloc (strlen (SourceLine) + 1);
845 strcpy (Enode->SourceLine, SourceLine);
851 Enode->Filename = Filename;
852 Enode->FilenameLength = strlen (Filename);
853 if (Enode->FilenameLength < 6)
855 Enode->FilenameLength = 6;
861 /*******************************************************************************
863 * FUNCTION: AslCommonError2
865 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
866 * MessageId - Index into global message buffer
867 * LineNumber - Actual file line number
868 * Column - Column in current line
869 * SourceLine - Actual source code line
870 * Filename - source filename
871 * ExtraMessage - additional error message
875 * DESCRIPTION: Create a new error node and add it to the error log
877 ******************************************************************************/
889 AslLogNewError (Level, MessageId, LineNumber, LineNumber, 0, Column,
890 Filename, ExtraMessage, SourceLine, NULL);
894 /*******************************************************************************
896 * FUNCTION: AslCommonError
898 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
899 * MessageId - Index into global message buffer
900 * CurrentLineNumber - Actual file line number
901 * LogicalLineNumber - Cumulative line number
902 * LogicalByteOffset - Byte offset in source file
903 * Column - Column in current line
904 * Filename - source filename
905 * ExtraMessage - additional error message
909 * DESCRIPTION: Create a new error node and add it to the error log
911 ******************************************************************************/
917 UINT32 CurrentLineNumber,
918 UINT32 LogicalLineNumber,
919 UINT32 LogicalByteOffset,
924 /* Check if user wants to ignore this exception */
926 if (AslIsExceptionIgnored (Level, MessageId))
931 AslLogNewError (Level, MessageId, CurrentLineNumber, LogicalLineNumber,
932 LogicalByteOffset, Column, Filename, ExtraMessage,
937 /*******************************************************************************
939 * FUNCTION: AslLogNewError
941 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
942 * MessageId - Index into global message buffer
943 * CurrentLineNumber - Actual file line number
944 * LogicalLineNumber - Cumulative line number
945 * LogicalByteOffset - Byte offset in source file
946 * Column - Column in current line
947 * Filename - source filename
948 * Message - additional error message
949 * SourceLine - Actual line of source code
950 * SubError - Sub-error associated with this error
954 * DESCRIPTION: Create a new error node and add it to the error log
956 ******************************************************************************/
962 UINT32 LogicalLineNumber,
963 UINT32 LogicalByteOffset,
968 ASL_ERROR_MSG *SubError)
970 ASL_ERROR_MSG *Enode = NULL;
973 AslInitEnode (&Enode, Level, MessageId, LineNumber, LogicalLineNumber,
974 LogicalByteOffset, Column, Filename, Message, SourceLine,
977 /* Add the new node to the error node list */
979 AeAddToErrorLog (Enode);
983 /* stderr is a file, send error to it immediately */
985 AePrintException (ASL_FILE_STDERR, Enode, NULL);
988 Gbl_ExceptionCount[Level]++;
989 if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
991 printf ("\nMaximum error count (%u) exceeded\n", ASL_MAX_ERROR_COUNT);
994 Gbl_NextError = Gbl_ErrorLog;
1002 /*******************************************************************************
1004 * FUNCTION: AslIsExceptionIgnored
1006 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1007 * MessageId - Index into global message buffer
1011 * DESCRIPTION: Check if a particular exception is ignored. In this case it
1012 * means that the exception is (expected or disabled.
1014 ******************************************************************************/
1017 AslIsExceptionIgnored (
1021 BOOLEAN ExceptionIgnored;
1024 /* Note: this allows exception to be disabled and expected */
1026 ExceptionIgnored = AslIsExceptionDisabled (Level, MessageId);
1027 ExceptionIgnored |= AslIsExceptionExpected (Level, MessageId);
1029 return (Gbl_AllExceptionsDisabled || ExceptionIgnored);
1033 /*******************************************************************************
1035 * FUNCTION: AslCheckExpectException
1041 * DESCRIPTION: Check the global expected messages table and raise an error
1042 * for each message that has not been received.
1044 ******************************************************************************/
1047 AslCheckExpectedExceptions (
1053 for (i = 0; i < Gbl_ExpectedMessagesIndex; ++i)
1055 if (!Gbl_ExpectedMessages[i].MessageReceived)
1057 AslError (ASL_ERROR, ASL_MSG_EXCEPTION_NOT_RECEIVED, NULL,
1058 Gbl_ExpectedMessages[i].MessageIdStr);
1064 /*******************************************************************************
1066 * FUNCTION: AslExpectException
1068 * PARAMETERS: MessageIdString - ID of excepted exception during compile
1072 * DESCRIPTION: Enter a message ID into the global expected messages table
1073 * If these messages are not raised during the compilation, throw
1076 ******************************************************************************/
1079 AslExpectException (
1080 char *MessageIdString)
1085 /* Convert argument to an integer and validate it */
1087 MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
1089 if (MessageId > 6999)
1091 printf ("\"%s\" is not a valid warning/remark/erro ID\n",
1093 return (AE_BAD_PARAMETER);
1096 /* Insert value into the global expected message array */
1098 if (Gbl_ExpectedMessagesIndex >= ASL_MAX_EXPECTED_MESSAGES)
1100 printf ("Too many messages have been registered as expected (max %u)\n",
1101 ASL_MAX_DISABLED_MESSAGES);
1105 Gbl_ExpectedMessages[Gbl_ExpectedMessagesIndex].MessageId = MessageId;
1106 Gbl_ExpectedMessages[Gbl_ExpectedMessagesIndex].MessageIdStr = MessageIdString;
1107 Gbl_ExpectedMessages[Gbl_ExpectedMessagesIndex].MessageReceived = FALSE;
1108 Gbl_ExpectedMessagesIndex++;
1113 /*******************************************************************************
1115 * FUNCTION: AslDisableException
1117 * PARAMETERS: MessageIdString - ID to be disabled
1121 * DESCRIPTION: Enter a message ID into the global disabled messages table
1123 ******************************************************************************/
1126 AslDisableException (
1127 char *MessageIdString)
1132 /* Convert argument to an integer and validate it */
1134 MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
1136 if ((MessageId < 2000) || (MessageId > 6999))
1138 printf ("\"%s\" is not a valid warning/remark/error ID\n",
1140 return (AE_BAD_PARAMETER);
1143 /* Insert value into the global disabled message array */
1145 if (Gbl_DisabledMessagesIndex >= ASL_MAX_DISABLED_MESSAGES)
1147 printf ("Too many messages have been disabled (max %u)\n",
1148 ASL_MAX_DISABLED_MESSAGES);
1152 Gbl_DisabledMessages[Gbl_DisabledMessagesIndex] = MessageId;
1153 Gbl_DisabledMessagesIndex++;
1158 /*******************************************************************************
1160 * FUNCTION: AslIsExceptionDisabled
1162 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1163 * MessageId - Index into global message buffer
1165 * RETURN: TRUE if exception/message should be ignored
1167 * DESCRIPTION: Check if the user has specified options such that this
1168 * exception should be ignored
1170 ******************************************************************************/
1173 AslIsExceptionExpected (
1177 UINT32 EncodedMessageId;
1181 /* Mark this exception as received */
1183 EncodedMessageId = AeBuildFullExceptionCode (Level, MessageId);
1184 for (i = 0; i < Gbl_ExpectedMessagesIndex; i++)
1186 /* Simple implementation via fixed array */
1188 if (EncodedMessageId == Gbl_ExpectedMessages[i].MessageId)
1190 return (Gbl_ExpectedMessages[i].MessageReceived = TRUE);
1198 /*******************************************************************************
1200 * FUNCTION: AslIsExceptionDisabled
1202 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1203 * MessageId - Index into global message buffer
1205 * RETURN: TRUE if exception/message should be ignored
1207 * DESCRIPTION: Check if the user has specified options such that this
1208 * exception should be ignored
1210 ******************************************************************************/
1213 AslIsExceptionDisabled (
1217 UINT32 EncodedMessageId;
1226 /* Check for global disable via -w1/-w2/-w3 options */
1228 if (Level > Gbl_WarningLevel)
1238 * Ignore this error/warning/remark if it has been disabled by
1239 * the user (-vw option)
1241 EncodedMessageId = AeBuildFullExceptionCode (Level, MessageId);
1242 for (i = 0; i < Gbl_DisabledMessagesIndex; i++)
1244 /* Simple implementation via fixed array */
1246 if (EncodedMessageId == Gbl_DisabledMessages[i])
1261 /*******************************************************************************
1263 * FUNCTION: AslDualParseOpError
1265 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1266 * MainMsgId - Index into global message buffer
1267 * MainOp - Parse node where error happened
1268 * MainMsg - Message pertaining to the MainOp
1269 * SubMsgId - Index into global message buffer
1270 * SubOp - Additional parse node for better message
1271 * SubMsg - Message pertainint to SubOp
1276 * DESCRIPTION: Main error reporting routine for the ASL compiler for error
1277 * messages that point to multiple parse objects.
1279 ******************************************************************************/
1282 AslDualParseOpError (
1285 ACPI_PARSE_OBJECT *MainOp,
1288 ACPI_PARSE_OBJECT *SubOp,
1291 ASL_ERROR_MSG *SubEnode = NULL;
1294 /* Check if user wants to ignore this exception */
1296 if (AslIsExceptionIgnored (Level, MainMsgId) || !MainOp)
1303 AslInitEnode (&SubEnode, Level, SubMsgId, SubOp->Asl.LineNumber,
1304 SubOp->Asl.LogicalLineNumber, SubOp->Asl.LogicalByteOffset,
1305 SubOp->Asl.Column, SubOp->Asl.Filename, SubMsg,
1309 AslLogNewError (Level, MainMsgId, MainOp->Asl.LineNumber,
1310 MainOp->Asl.LogicalLineNumber, MainOp->Asl.LogicalByteOffset,
1311 MainOp->Asl.Column, MainOp->Asl.Filename, MainMsg,
1316 /*******************************************************************************
1318 * FUNCTION: AslError
1320 * PARAMETERS: Level - Seriousness (Warning/error, etc.)
1321 * MessageId - Index into global message buffer
1322 * Op - Parse node where error happened
1323 * ExtraMessage - additional error message
1327 * DESCRIPTION: Main error reporting routine for the ASL compiler (all code
1328 * except the parser.)
1330 ******************************************************************************/
1336 ACPI_PARSE_OBJECT *Op,
1341 AslCommonError (Level, MessageId, Op->Asl.LineNumber,
1342 Op->Asl.LogicalLineNumber,
1343 Op->Asl.LogicalByteOffset,
1345 Op->Asl.Filename, ExtraMessage);
1349 AslCommonError (Level, MessageId, 0,
1350 0, 0, 0, NULL, ExtraMessage);
1355 /*******************************************************************************
1357 * FUNCTION: AslCoreSubsystemError
1359 * PARAMETERS: Op - Parse node where error happened
1360 * Status - The ACPICA Exception
1361 * ExtraMessage - additional error message
1362 * Abort - TRUE -> Abort compilation
1366 * DESCRIPTION: Error reporting routine for exceptions returned by the ACPICA
1369 ******************************************************************************/
1372 AslCoreSubsystemError (
1373 ACPI_PARSE_OBJECT *Op,
1379 sprintf (MsgBuffer, "%s %s", AcpiFormatException (Status), ExtraMessage);
1383 AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION,
1385 Op->Asl.LogicalLineNumber,
1386 Op->Asl.LogicalByteOffset,
1388 Op->Asl.Filename, MsgBuffer);
1392 AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION,
1393 0, 0, 0, 0, NULL, MsgBuffer);
1403 /*******************************************************************************
1405 * FUNCTION: AslCompilererror
1407 * PARAMETERS: CompilerMessage - Error message from the parser
1409 * RETURN: Status (0 for now)
1411 * DESCRIPTION: Report an error situation discovered in a production
1412 * NOTE: don't change the name of this function, it is called
1413 * from the auto-generated parser.
1415 ******************************************************************************/
1419 const char *CompilerMessage)
1424 AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, Gbl_CurrentLineNumber,
1425 Gbl_LogicalLineNumber, Gbl_CurrentLineOffset,
1426 Gbl_CurrentColumn, Gbl_Files[ASL_FILE_INPUT].Filename,
1427 ACPI_CAST_PTR (char, CompilerMessage));