1 /******************************************************************************
2  *
3  * Module Name: aslerror - Error handling and statistics
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2014, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43 
44 #define ASL_EXCEPTIONS
45 #include "aslcompiler.h"
46 
47 #define _COMPONENT          ACPI_COMPILER
48         ACPI_MODULE_NAME    ("aslerror")
49 
50 /* Local prototypes */
51 
52 static void
53 AeAddToErrorLog (
54     ASL_ERROR_MSG           *Enode);
55 
56 
57 /*******************************************************************************
58  *
59  * FUNCTION:    AslAbort
60  *
61  * PARAMETERS:  None
62  *
63  * RETURN:      None
64  *
65  * DESCRIPTION: Dump the error log and abort the compiler. Used for serious
66  *              I/O errors.
67  *
68  ******************************************************************************/
69 
70 void
71 AslAbort (
72     void)
73 {
74 
75     AePrintErrorLog (ASL_FILE_STDERR);
76     if (Gbl_DebugFlag)
77     {
78         /* Print error summary to stdout also */
79 
80         AePrintErrorLog (ASL_FILE_STDOUT);
81     }
82 
83     exit (1);
84 }
85 
86 
87 /*******************************************************************************
88  *
89  * FUNCTION:    AeClearErrorLog
90  *
91  * PARAMETERS:  None
92  *
93  * RETURN:      None
94  *
95  * DESCRIPTION: Empty the error list
96  *
97  ******************************************************************************/
98 
99 void
100 AeClearErrorLog (
101     void)
102 {
103     ASL_ERROR_MSG           *Enode = Gbl_ErrorLog;
104     ASL_ERROR_MSG           *Next;
105 
106     /* Walk the error node list */
107 
108     while (Enode)
109     {
110         Next = Enode->Next;
111         ACPI_FREE (Enode);
112         Enode = Next;
113     }
114 
115     Gbl_ErrorLog = NULL;
116 }
117 
118 
119 /*******************************************************************************
120  *
121  * FUNCTION:    AeAddToErrorLog
122  *
123  * PARAMETERS:  Enode       - An error node to add to the log
124  *
125  * RETURN:      None
126  *
127  * DESCRIPTION: Add a new error node to the error log. The error log is
128  *              ordered by the "logical" line number (cumulative line number
129  *              including all include files.)
130  *
131  ******************************************************************************/
132 
133 static void
134 AeAddToErrorLog (
135     ASL_ERROR_MSG           *Enode)
136 {
137     ASL_ERROR_MSG           *Next;
138     ASL_ERROR_MSG           *Prev;
139 
140 
141     /* If Gbl_ErrorLog is null, this is the first error node */
142 
143     if (!Gbl_ErrorLog)
144     {
145         Gbl_ErrorLog = Enode;
146         return;
147     }
148 
149     /*
150      * Walk error list until we find a line number greater than ours.
151      * List is sorted according to line number.
152      */
153     Prev = NULL;
154     Next = Gbl_ErrorLog;
155 
156     while ((Next) &&
157            (Next->LogicalLineNumber <= Enode->LogicalLineNumber))
158     {
159         Prev = Next;
160         Next = Next->Next;
161     }
162 
163     /* Found our place in the list */
164 
165     Enode->Next = Next;
166 
167     if (Prev)
168     {
169         Prev->Next = Enode;
170     }
171     else
172     {
173         Gbl_ErrorLog = Enode;
174     }
175 }
176 
177 
178 /*******************************************************************************
179  *
180  * FUNCTION:    AePrintException
181  *
182  * PARAMETERS:  FileId          - ID of output file
183  *              Enode           - Error node to print
184  *              Header          - Additional text before each message
185  *
186  * RETURN:      None
187  *
188  * DESCRIPTION: Print the contents of an error node.
189  *
190  * NOTE:        We don't use the FlxxxFile I/O functions here because on error
191  *              they abort the compiler and call this function!  Since we
192  *              are reporting errors here, we ignore most output errors and
193  *              just try to get out as much as we can.
194  *
195  ******************************************************************************/
196 
197 void
198 AePrintException (
199     UINT32                  FileId,
200     ASL_ERROR_MSG           *Enode,
201     char                    *Header)
202 {
203     UINT8                   SourceByte;
204     int                     Actual;
205     size_t                  RActual;
206     UINT32                  MsgLength;
207     char                    *MainMessage;
208     char                    *ExtraMessage;
209     UINT32                  SourceColumn;
210     UINT32                  ErrorColumn;
211     FILE                    *OutputFile;
212     FILE                    *SourceFile = NULL;
213     long                    FileSize;
214     BOOLEAN                 PrematureEOF = FALSE;
215     UINT32                  Total = 0;
216 
217 
218     if (Gbl_NoErrors)
219     {
220         return;
221     }
222 
223     /*
224      * Only listing files have a header, and remarks/optimizations
225      * are always output
226      */
227     if (!Header)
228     {
229         /* Ignore remarks if requested */
230 
231         switch (Enode->Level)
232         {
233         case ASL_WARNING:
234         case ASL_WARNING2:
235         case ASL_WARNING3:
236 
237             if (!Gbl_DisplayWarnings)
238             {
239                 return;
240             }
241             break;
242 
243         case ASL_REMARK:
244 
245             if (!Gbl_DisplayRemarks)
246             {
247                 return;
248             }
249             break;
250 
251         case ASL_OPTIMIZATION:
252 
253             if (!Gbl_DisplayOptimizations)
254             {
255                 return;
256             }
257             break;
258 
259         default:
260 
261             break;
262         }
263     }
264 
265     /* Get the various required file handles */
266 
267     OutputFile = Gbl_Files[FileId].Handle;
268 
269     if (!Enode->SourceLine)
270     {
271         /* Use the merged header/source file if present, otherwise use input file */
272 
273         SourceFile = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
274         if (!SourceFile)
275         {
276             SourceFile = Gbl_Files[ASL_FILE_INPUT].Handle;
277         }
278 
279         if (SourceFile)
280         {
281             /* Determine if the error occurred at source file EOF */
282 
283             fseek (SourceFile, 0, SEEK_END);
284             FileSize = ftell (SourceFile);
285 
286             if ((long) Enode->LogicalByteOffset >= FileSize)
287             {
288                 PrematureEOF = TRUE;
289             }
290         }
291     }
292 
293     if (Header)
294     {
295         fprintf (OutputFile, "%s", Header);
296     }
297 
298     /* Print filename and line number if present and valid */
299 
300     if (Enode->Filename)
301     {
302         if (Gbl_VerboseErrors)
303         {
304             fprintf (OutputFile, "%-8s", Enode->Filename);
305 
306             if (Enode->LineNumber)
307             {
308                 if (Enode->SourceLine)
309                 {
310                     fprintf (OutputFile, " %6u: %s",
311                         Enode->LineNumber, Enode->SourceLine);
312                 }
313                 else
314                 {
315                     fprintf (OutputFile, " %6u: ", Enode->LineNumber);
316 
317                     /*
318                      * If not at EOF, get the corresponding source code line and
319                      * display it. Don't attempt this if we have a premature EOF
320                      * condition.
321                      */
322                     if (!PrematureEOF)
323                     {
324                         /*
325                          * Seek to the offset in the combined source file, read
326                          * the source line, and write it to the output.
327                          */
328                         Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset,
329                                     (int) SEEK_SET);
330                         if (Actual)
331                         {
332                             fprintf (OutputFile,
333                                 "[*** iASL: Seek error on source code temp file %s ***]",
334                                 Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
335                         }
336                         else
337                         {
338                             RActual = fread (&SourceByte, 1, 1, SourceFile);
339                             if (RActual != 1)
340                             {
341                                 fprintf (OutputFile,
342                                     "[*** iASL: Read error on source code temp file %s ***]",
343                                     Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
344                             }
345                             else
346                             {
347                                 /* Read/write the source line, up to the maximum line length */
348 
349                                 while (RActual && SourceByte && (SourceByte != '\n'))
350                                 {
351                                     if (Total < 256)
352                                     {
353                                         /* After the max line length, we will just read the line, no write */
354 
355                                         if (fwrite (&SourceByte, 1, 1, OutputFile) != 1)
356                                         {
357                                             printf ("[*** iASL: Write error on output file ***]\n");
358                                             return;
359                                         }
360                                     }
361                                     else if (Total == 256)
362                                     {
363                                         fprintf (OutputFile,
364                                             "\n[*** iASL: Very long input line, message below refers to column %u ***]",
365                                             Enode->Column);
366                                     }
367 
368                                     RActual = fread (&SourceByte, 1, 1, SourceFile);
369                                     if (RActual != 1)
370                                     {
371                                         fprintf (OutputFile,
372                                             "[*** iASL: Read error on source code temp file %s ***]",
373                                             Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
374                                         return;
375                                     }
376                                     Total++;
377                                 }
378                             }
379                         }
380                     }
381 
382                     fprintf (OutputFile, "\n");
383                 }
384             }
385         }
386         else
387         {
388             /*
389              * Less verbose version of the error message, enabled via the
390              * -vi switch. The format is compatible with MS Visual Studio.
391              */
392             fprintf (OutputFile, "%s", Enode->Filename);
393 
394             if (Enode->LineNumber)
395             {
396                 fprintf (OutputFile, "(%u) : ",
397                     Enode->LineNumber);
398             }
399         }
400     }
401 
402     /* NULL message ID, just print the raw message */
403 
404     if (Enode->MessageId == 0)
405     {
406         fprintf (OutputFile, "%s\n", Enode->Message);
407     }
408     else
409     {
410         /* Decode the message ID */
411 
412         if (Gbl_VerboseErrors)
413         {
414             fprintf (OutputFile, "%s %4.4d -",
415                         AslErrorLevel[Enode->Level],
416                         Enode->MessageId + ((Enode->Level+1) * 1000));
417         }
418         else /* IDE case */
419         {
420             fprintf (OutputFile, "%s %4.4d:",
421                         AslErrorLevelIde[Enode->Level],
422                         Enode->MessageId + ((Enode->Level+1) * 1000));
423         }
424 
425         MainMessage = AslMessages[Enode->MessageId];
426         ExtraMessage = Enode->Message;
427 
428         if (Enode->LineNumber)
429         {
430             /* Main message: try to use string from AslMessages first */
431 
432             if (!MainMessage)
433             {
434                 MainMessage = "";
435             }
436 
437             MsgLength = strlen (MainMessage);
438             if (MsgLength == 0)
439             {
440                 /* Use the secondary/extra message as main message */
441 
442                 MainMessage = Enode->Message;
443                 if (!MainMessage)
444                 {
445                     MainMessage = "";
446                 }
447 
448                 MsgLength = strlen (MainMessage);
449                 ExtraMessage = NULL;
450             }
451 
452             if (Gbl_VerboseErrors && !PrematureEOF)
453             {
454                 if (Total >= 256)
455                 {
456                     fprintf (OutputFile, "    %s",
457                         MainMessage);
458                 }
459                 else
460                 {
461                     SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2;
462                     ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1;
463 
464                     if ((MsgLength + ErrorColumn) < (SourceColumn - 1))
465                     {
466                         fprintf (OutputFile, "%*s%s",
467                             (int) ((SourceColumn - 1) - ErrorColumn),
468                             MainMessage, " ^ ");
469                     }
470                     else
471                     {
472                         fprintf (OutputFile, "%*s %s",
473                             (int) ((SourceColumn - ErrorColumn) + 1), "^",
474                             MainMessage);
475                     }
476                 }
477             }
478             else
479             {
480                 fprintf (OutputFile, " %s", MainMessage);
481             }
482 
483             /* Print the extra info message if present */
484 
485             if (ExtraMessage)
486             {
487                 fprintf (OutputFile, " (%s)", ExtraMessage);
488             }
489 
490             if (PrematureEOF)
491             {
492                 fprintf (OutputFile, " and premature End-Of-File");
493             }
494 
495             fprintf (OutputFile, "\n");
496             if (Gbl_VerboseErrors)
497             {
498                 fprintf (OutputFile, "\n");
499             }
500         }
501         else
502         {
503             fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage);
504         }
505     }
506 }
507 
508 
509 /*******************************************************************************
510  *
511  * FUNCTION:    AePrintErrorLog
512  *
513  * PARAMETERS:  FileId           - Where to output the error log
514  *
515  * RETURN:      None
516  *
517  * DESCRIPTION: Print the entire contents of the error log
518  *
519  ******************************************************************************/
520 
521 void
522 AePrintErrorLog (
523     UINT32                  FileId)
524 {
525     ASL_ERROR_MSG           *Enode = Gbl_ErrorLog;
526 
527 
528     /* Walk the error node list */
529 
530     while (Enode)
531     {
532         AePrintException (FileId, Enode, NULL);
533         Enode = Enode->Next;
534     }
535 }
536 
537 
538 /*******************************************************************************
539  *
540  * FUNCTION:    AslCommonError2
541  *
542  * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
543  *              MessageId           - Index into global message buffer
544  *              LineNumber          - Actual file line number
545  *              Column              - Column in current line
546  *              SourceLine          - Actual source code line
547  *              Filename            - source filename
548  *              ExtraMessage        - additional error message
549  *
550  * RETURN:      None
551  *
552  * DESCRIPTION: Create a new error node and add it to the error log
553  *
554  ******************************************************************************/
555 
556 void
557 AslCommonError2 (
558     UINT8                   Level,
559     UINT8                   MessageId,
560     UINT32                  LineNumber,
561     UINT32                  Column,
562     char                    *SourceLine,
563     char                    *Filename,
564     char                    *ExtraMessage)
565 {
566     char                    *MessageBuffer = NULL;
567     char                    *LineBuffer;
568     ASL_ERROR_MSG           *Enode;
569 
570 
571     Enode = UtLocalCalloc (sizeof (ASL_ERROR_MSG));
572 
573     if (ExtraMessage)
574     {
575         /* Allocate a buffer for the message and a new error node */
576 
577         MessageBuffer = UtLocalCalloc (strlen (ExtraMessage) + 1);
578 
579         /* Keep a copy of the extra message */
580 
581         ACPI_STRCPY (MessageBuffer, ExtraMessage);
582     }
583 
584     LineBuffer = UtLocalCalloc (strlen (SourceLine) + 1);
585     ACPI_STRCPY (LineBuffer, SourceLine);
586 
587     /* Initialize the error node */
588 
589     if (Filename)
590     {
591         Enode->Filename       = Filename;
592         Enode->FilenameLength = strlen (Filename);
593         if (Enode->FilenameLength < 6)
594         {
595             Enode->FilenameLength = 6;
596         }
597     }
598 
599     Enode->MessageId            = MessageId;
600     Enode->Level                = Level;
601     Enode->LineNumber           = LineNumber;
602     Enode->LogicalLineNumber    = LineNumber;
603     Enode->LogicalByteOffset    = 0;
604     Enode->Column               = Column;
605     Enode->Message              = MessageBuffer;
606     Enode->SourceLine           = LineBuffer;
607 
608     /* Add the new node to the error node list */
609 
610     AeAddToErrorLog (Enode);
611 
612     if (Gbl_DebugFlag)
613     {
614         /* stderr is a file, send error to it immediately */
615 
616         AePrintException (ASL_FILE_STDERR, Enode, NULL);
617     }
618 
619     Gbl_ExceptionCount[Level]++;
620 }
621 
622 
623 /*******************************************************************************
624  *
625  * FUNCTION:    AslCommonError
626  *
627  * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
628  *              MessageId           - Index into global message buffer
629  *              CurrentLineNumber   - Actual file line number
630  *              LogicalLineNumber   - Cumulative line number
631  *              LogicalByteOffset   - Byte offset in source file
632  *              Column              - Column in current line
633  *              Filename            - source filename
634  *              ExtraMessage        - additional error message
635  *
636  * RETURN:      None
637  *
638  * DESCRIPTION: Create a new error node and add it to the error log
639  *
640  ******************************************************************************/
641 
642 void
643 AslCommonError (
644     UINT8                   Level,
645     UINT8                   MessageId,
646     UINT32                  CurrentLineNumber,
647     UINT32                  LogicalLineNumber,
648     UINT32                  LogicalByteOffset,
649     UINT32                  Column,
650     char                    *Filename,
651     char                    *ExtraMessage)
652 {
653     char                    *MessageBuffer = NULL;
654     ASL_ERROR_MSG           *Enode;
655 
656 
657     Enode = UtLocalCalloc (sizeof (ASL_ERROR_MSG));
658 
659     if (ExtraMessage)
660     {
661         /* Allocate a buffer for the message and a new error node */
662 
663         MessageBuffer = UtLocalCalloc (strlen (ExtraMessage) + 1);
664 
665         /* Keep a copy of the extra message */
666 
667         ACPI_STRCPY (MessageBuffer, ExtraMessage);
668     }
669 
670     /* Initialize the error node */
671 
672     if (Filename)
673     {
674         Enode->Filename       = Filename;
675         Enode->FilenameLength = strlen (Filename);
676         if (Enode->FilenameLength < 6)
677         {
678             Enode->FilenameLength = 6;
679         }
680     }
681 
682     Enode->MessageId            = MessageId;
683     Enode->Level                = Level;
684     Enode->LineNumber           = CurrentLineNumber;
685     Enode->LogicalLineNumber    = LogicalLineNumber;
686     Enode->LogicalByteOffset    = LogicalByteOffset;
687     Enode->Column               = Column;
688     Enode->Message              = MessageBuffer;
689     Enode->SourceLine           = NULL;
690 
691     /* Add the new node to the error node list */
692 
693     AeAddToErrorLog (Enode);
694 
695     if (Gbl_DebugFlag)
696     {
697         /* stderr is a file, send error to it immediately */
698 
699         AePrintException (ASL_FILE_STDERR, Enode, NULL);
700     }
701 
702     Gbl_ExceptionCount[Level]++;
703     if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
704     {
705         printf ("\nMaximum error count (%u) exceeded\n", ASL_MAX_ERROR_COUNT);
706 
707         Gbl_SourceLine = 0;
708         Gbl_NextError = Gbl_ErrorLog;
709         CmCleanupAndExit ();
710         exit(1);
711     }
712 
713     return;
714 }
715 
716 
717 /*******************************************************************************
718  *
719  * FUNCTION:    AslDisableException
720  *
721  * PARAMETERS:  MessageIdString     - ID to be disabled
722  *
723  * RETURN:      Status
724  *
725  * DESCRIPTION: Enter a message ID into the global disabled messages table
726  *
727  ******************************************************************************/
728 
729 ACPI_STATUS
730 AslDisableException (
731     char                    *MessageIdString)
732 {
733     UINT32                  MessageId;
734 
735 
736     /* Convert argument to an integer and validate it */
737 
738     MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
739 
740     if ((MessageId < 2000) || (MessageId > 5999))
741     {
742         printf ("\"%s\" is not a valid warning/remark ID\n",
743             MessageIdString);
744         return (AE_BAD_PARAMETER);
745     }
746 
747     /* Insert value into the global disabled message array */
748 
749     if (Gbl_DisabledMessagesIndex >= ASL_MAX_DISABLED_MESSAGES)
750     {
751         printf ("Too many messages have been disabled (max %u)\n",
752             ASL_MAX_DISABLED_MESSAGES);
753         return (AE_LIMIT);
754     }
755 
756     Gbl_DisabledMessages[Gbl_DisabledMessagesIndex] = MessageId;
757     Gbl_DisabledMessagesIndex++;
758     return (AE_OK);
759 }
760 
761 
762 /*******************************************************************************
763  *
764  * FUNCTION:    AslIsExceptionDisabled
765  *
766  * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
767  *              MessageId           - Index into global message buffer
768  *
769  * RETURN:      TRUE if exception/message should be ignored
770  *
771  * DESCRIPTION: Check if the user has specified options such that this
772  *              exception should be ignored
773  *
774  ******************************************************************************/
775 
776 BOOLEAN
777 AslIsExceptionDisabled (
778     UINT8                   Level,
779     UINT8                   MessageId)
780 {
781     UINT32                  EncodedMessageId;
782     UINT32                  i;
783 
784 
785     switch (Level)
786     {
787     case ASL_WARNING2:
788     case ASL_WARNING3:
789 
790         /* Check for global disable via -w1/-w2/-w3 options */
791 
792         if (Level > Gbl_WarningLevel)
793         {
794             return (TRUE);
795         }
796         /* Fall through */
797 
798     case ASL_WARNING:
799     case ASL_REMARK:
800         /*
801          * Ignore this warning/remark if it has been disabled by
802          * the user (-vw option)
803          */
804         EncodedMessageId = MessageId + ((Level + 1) * 1000);
805         for (i = 0; i < Gbl_DisabledMessagesIndex; i++)
806         {
807             /* Simple implementation via fixed array */
808 
809             if (EncodedMessageId == Gbl_DisabledMessages[i])
810             {
811                 return (TRUE);
812             }
813         }
814         break;
815 
816     default:
817         break;
818     }
819 
820     return (FALSE);
821 }
822 
823 
824 /*******************************************************************************
825  *
826  * FUNCTION:    AslError
827  *
828  * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
829  *              MessageId           - Index into global message buffer
830  *              Op                  - Parse node where error happened
831  *              ExtraMessage        - additional error message
832  *
833  * RETURN:      None
834  *
835  * DESCRIPTION: Main error reporting routine for the ASL compiler (all code
836  *              except the parser.)
837  *
838  ******************************************************************************/
839 
840 void
841 AslError (
842     UINT8                   Level,
843     UINT8                   MessageId,
844     ACPI_PARSE_OBJECT       *Op,
845     char                    *ExtraMessage)
846 {
847 
848     /* Check if user wants to ignore this exception */
849 
850     if (Gbl_AllExceptionsDisabled ||
851         AslIsExceptionDisabled (Level, MessageId))
852     {
853         return;
854     }
855 
856     if (Op)
857     {
858         AslCommonError (Level, MessageId, Op->Asl.LineNumber,
859             Op->Asl.LogicalLineNumber,
860             Op->Asl.LogicalByteOffset,
861             Op->Asl.Column,
862             Op->Asl.Filename, ExtraMessage);
863     }
864     else
865     {
866         AslCommonError (Level, MessageId, 0,
867             0, 0, 0, NULL, ExtraMessage);
868     }
869 }
870 
871 
872 /*******************************************************************************
873  *
874  * FUNCTION:    AslCoreSubsystemError
875  *
876  * PARAMETERS:  Op                  - Parse node where error happened
877  *              Status              - The ACPI CA Exception
878  *              ExtraMessage        - additional error message
879  *              Abort               - TRUE -> Abort compilation
880  *
881  * RETURN:      None
882  *
883  * DESCRIPTION: Error reporting routine for exceptions returned by the ACPI
884  *              CA core subsystem.
885  *
886  ******************************************************************************/
887 
888 void
889 AslCoreSubsystemError (
890     ACPI_PARSE_OBJECT       *Op,
891     ACPI_STATUS             Status,
892     char                    *ExtraMessage,
893     BOOLEAN                 Abort)
894 {
895 
896     sprintf (MsgBuffer, "%s %s", AcpiFormatException (Status), ExtraMessage);
897 
898     if (Op)
899     {
900         AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Op->Asl.LineNumber,
901                         Op->Asl.LogicalLineNumber,
902                         Op->Asl.LogicalByteOffset,
903                         Op->Asl.Column,
904                         Op->Asl.Filename, MsgBuffer);
905     }
906     else
907     {
908         AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, 0,
909                         0, 0, 0, NULL, MsgBuffer);
910     }
911 
912     if (Abort)
913     {
914         AslAbort ();
915     }
916 }
917 
918 
919 /*******************************************************************************
920  *
921  * FUNCTION:    AslCompilererror
922  *
923  * PARAMETERS:  CompilerMessage         - Error message from the parser
924  *
925  * RETURN:      Status (0 for now)
926  *
927  * DESCRIPTION: Report an error situation discovered in a production
928  *              NOTE: don't change the name of this function, it is called
929  *              from the auto-generated parser.
930  *
931  ******************************************************************************/
932 
933 int
934 AslCompilererror (
935     const char              *CompilerMessage)
936 {
937 
938     AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, Gbl_CurrentLineNumber,
939         Gbl_LogicalLineNumber, Gbl_CurrentLineOffset,
940         Gbl_CurrentColumn, Gbl_Files[ASL_FILE_INPUT].Filename,
941         ACPI_CAST_PTR (char, CompilerMessage));
942 
943     return (0);
944 }
945