1 /******************************************************************************
2  *
3  * Module Name: aslerror - Error handling and statistics
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2020, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
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
19  * property rights.
20  *
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
27  *
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;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
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.
53  *
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
64  * make.
65  *
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
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
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.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
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
88  * PARTICULAR PURPOSE.
89  *
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
97  * LIMITED REMEDY.
98  *
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.
113  *
114  *****************************************************************************
115  *
116  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
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.
133  *
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.
145  *
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.
149  *
150  *****************************************************************************/
151 
152 #include "aslcompiler.h"
153 
154 #define _COMPONENT          ACPI_COMPILER
155         ACPI_MODULE_NAME    ("aslerror")
156 
157 /* Local prototypes */
158 
159 static void
160 AeAddToErrorLog (
161     ASL_ERROR_MSG           *Enode);
162 
163 static BOOLEAN
164 AslIsExceptionExpected (
165     UINT8                   Level,
166     UINT16                  MessageId);
167 
168 static BOOLEAN
169 AslIsExceptionDisabled (
170     UINT8                   Level,
171     UINT16                  MessageId);
172 
173 static void AslInitEnode (
174     ASL_ERROR_MSG           **Enode,
175     UINT8                   Level,
176     UINT16                  MessageId,
177     UINT32                  LineNumber,
178     UINT32                  LogicalLineNumber,
179     UINT32                  LogicalByteOffset,
180     UINT32                  Column,
181     char                    *Filename,
182     char                    *Message,
183     char                    *SourceLine,
184     ASL_ERROR_MSG           *SubError);
185 
186 static void
187 AslLogNewError (
188     UINT8                   Level,
189     UINT16                  MessageId,
190     UINT32                  LineNumber,
191     UINT32                  LogicalLineNumber,
192     UINT32                  LogicalByteOffset,
193     UINT32                  Column,
194     char                    *Filename,
195     char                    *Message,
196     char                    *SourceLine,
197     ASL_ERROR_MSG           *SubError);
198 
199 static void
200 AePrintSubError (
201     FILE                    *OutputFile,
202     ASL_ERROR_MSG           *Enode);
203 
204 static UINT8
205 GetModifiedLevel (
206     UINT8                   Level,
207     UINT16                  MessageId);
208 
209 
210 /*******************************************************************************
211  *
212  * FUNCTION:    AslAbort
213  *
214  * PARAMETERS:  None
215  *
216  * RETURN:      None
217  *
218  * DESCRIPTION: Dump the error log and abort the compiler. Used for serious
219  *              I/O errors.
220  *
221  ******************************************************************************/
222 
223 void
224 AslAbort (
225     void)
226 {
227 
228     AePrintErrorLog (ASL_FILE_STDERR);
229     if (AslGbl_DebugFlag)
230     {
231         /* Print error summary to stdout also */
232 
233         AePrintErrorLog (ASL_FILE_STDOUT);
234     }
235 
236     exit (1);
237 }
238 
239 
240 /*******************************************************************************
241  *
242  * FUNCTION:    AeClearErrorLog
243  *
244  * PARAMETERS:  None
245  *
246  * RETURN:      None
247  *
248  * DESCRIPTION: Empty the error list
249  *
250  ******************************************************************************/
251 
252 void
253 AeClearErrorLog (
254     void)
255 {
256     ASL_ERROR_MSG           *Enode = AslGbl_ErrorLog;
257     ASL_ERROR_MSG           *Next;
258 
259 
260     /* Walk the error node list */
261 
262     while (Enode)
263     {
264         Next = Enode->Next;
265         ACPI_FREE (Enode);
266         Enode = Next;
267     }
268 
269    AslGbl_ErrorLog = NULL;
270 }
271 
272 
273 /*******************************************************************************
274  *
275  * FUNCTION:    AeAddToErrorLog
276  *
277  * PARAMETERS:  Enode       - An error node to add to the log
278  *
279  * RETURN:      None
280  *
281  * DESCRIPTION: Add a new error node to the error log. The error log is
282  *              ordered by the "logical" line number (cumulative line number
283  *              including all include files.)
284  *
285  ******************************************************************************/
286 
287 static void
288 AeAddToErrorLog (
289     ASL_ERROR_MSG           *Enode)
290 {
291     ASL_ERROR_MSG           *Next;
292     ASL_ERROR_MSG           *Prev;
293 
294 
295     /* If Gbl_ErrorLog is null, this is the first error node */
296 
297     if (!AslGbl_ErrorLog)
298     {
299         AslGbl_ErrorLog = Enode;
300         return;
301     }
302 
303     /*
304      * Walk error list until we find a line number greater than ours.
305      * List is sorted according to line number.
306      */
307     Prev = NULL;
308     Next = AslGbl_ErrorLog;
309 
310     while ((Next) && (Next->LogicalLineNumber <= Enode->LogicalLineNumber))
311     {
312         Prev = Next;
313         Next = Next->Next;
314     }
315 
316     /* Found our place in the list */
317 
318     Enode->Next = Next;
319 
320     if (Prev)
321     {
322         Prev->Next = Enode;
323     }
324     else
325     {
326         AslGbl_ErrorLog = Enode;
327     }
328 }
329 
330 
331 /*******************************************************************************
332  *
333  * FUNCTION:    AeDecodeErrorMessageId
334  *
335  * PARAMETERS:  OutputFile      - Output file
336  *              Enode           - Error node to print
337  *              PrematureEOF    - True = PrematureEOF has been reached
338  *              Total           - Total length of line
339  *
340  * RETURN:      None
341  *
342  * DESCRIPTION: Print the source line of an error.
343  *
344  ******************************************************************************/
345 
346 static void
347 AeDecodeErrorMessageId (
348     FILE                    *OutputFile,
349     ASL_ERROR_MSG           *Enode,
350     BOOLEAN                 PrematureEOF,
351     UINT32                  Total)
352 {
353     UINT32                  MsgLength;
354     const char              *MainMessage;
355     char                    *ExtraMessage;
356     UINT32                  SourceColumn;
357     UINT32                  ErrorColumn;
358 
359 
360     fprintf (OutputFile, "%s %4.4d -",
361         AeDecodeExceptionLevel (Enode->Level),
362         AeBuildFullExceptionCode (Enode->Level, Enode->MessageId));
363 
364     MainMessage = AeDecodeMessageId (Enode->MessageId);
365     ExtraMessage = Enode->Message;
366 
367     /* If a NULL line number, just print the decoded message */
368 
369     if (!Enode->LineNumber)
370     {
371         fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage);
372         return;
373     }
374 
375     MsgLength = strlen (MainMessage);
376     if (MsgLength == 0)
377     {
378         /* Use the secondary/extra message as main message */
379 
380         MainMessage = Enode->Message;
381         if (!MainMessage)
382         {
383             MainMessage = "";
384         }
385 
386         MsgLength = strlen (MainMessage);
387         ExtraMessage = NULL;
388     }
389 
390     if (AslGbl_VerboseErrors && !PrematureEOF)
391     {
392         if (Total >= 256)
393         {
394             fprintf (OutputFile, "    %s",
395                 MainMessage);
396         }
397         else
398         {
399             SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2;
400             ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1;
401 
402             if ((MsgLength + ErrorColumn) < (SourceColumn - 1))
403             {
404                 fprintf (OutputFile, "%*s%s",
405                     (int) ((SourceColumn - 1) - ErrorColumn),
406                     MainMessage, " ^ ");
407             }
408             else
409             {
410                 fprintf (OutputFile, "%*s %s",
411                     (int) ((SourceColumn - ErrorColumn) + 1), "^",
412                     MainMessage);
413             }
414         }
415     }
416     else
417     {
418         fprintf (OutputFile, " %s", MainMessage);
419     }
420 
421     /* Print the extra info message if present */
422 
423     if (ExtraMessage)
424     {
425         fprintf (OutputFile, " (%s)", ExtraMessage);
426     }
427 
428     if (PrematureEOF)
429     {
430         fprintf (OutputFile, " and premature End-Of-File");
431     }
432 
433     fprintf (OutputFile, "\n");
434     if (AslGbl_VerboseErrors && !Enode->SubError)
435     {
436         fprintf (OutputFile, "\n");
437     }
438 }
439 
440 
441 /*******************************************************************************
442  *
443  * FUNCTION:    AePrintErrorSourceLine
444  *
445  * PARAMETERS:  OutputFile      - Output file
446  *              Enode           - Error node to print
447  *              PrematureEOF    - True = PrematureEOF has been reached
448  *              Total           - Number of characters printed so far
449  *
450  *
451  * RETURN:      Status
452  *
453  * DESCRIPTION: Print the source line of an error.
454  *
455  ******************************************************************************/
456 
457 static ACPI_STATUS
458 AePrintErrorSourceLine (
459     FILE                    *OutputFile,
460     ASL_ERROR_MSG           *Enode,
461     BOOLEAN                 *PrematureEOF,
462     UINT32                  *Total)
463 {
464     UINT8                   SourceByte;
465     int                     Actual;
466     size_t                  RActual;
467     FILE                    *SourceFile = NULL;
468     long                    FileSize;
469 
470 
471     if (!Enode->SourceLine)
472     {
473         /*
474          * Use the merged header/source file if present, otherwise
475          * use input file
476          */
477         SourceFile = FlGetFileHandle (ASL_FILE_SOURCE_OUTPUT,
478             ASL_FILE_SOURCE_OUTPUT, Enode->SourceFilename);
479         if (!SourceFile)
480         {
481             SourceFile = FlGetFileHandle (ASL_FILE_INPUT,
482                 ASL_FILE_INPUT, Enode->Filename);
483         }
484 
485         if (SourceFile)
486         {
487             /* Determine if the error occurred at source file EOF */
488 
489             fseek (SourceFile, 0, SEEK_END);
490             FileSize = ftell (SourceFile);
491 
492             if ((long) Enode->LogicalByteOffset >= FileSize)
493             {
494                 *PrematureEOF = TRUE;
495             }
496         }
497         else
498         {
499             fprintf (OutputFile,
500                 "[*** iASL: Source File Does not exist ***]\n");
501             return AE_IO_ERROR;
502         }
503     }
504 
505     /* Print filename and line number if present and valid */
506 
507     if (AslGbl_VerboseErrors)
508     {
509         fprintf (OutputFile, "%-8s", Enode->Filename);
510 
511         if (Enode->SourceLine && Enode->LineNumber)
512         {
513             fprintf (OutputFile, " %6u: %s",
514                 Enode->LineNumber, Enode->SourceLine);
515         }
516         else if (Enode->LineNumber)
517         {
518             fprintf (OutputFile, " %6u: ", Enode->LineNumber);
519 
520             /*
521              * If not at EOF, get the corresponding source code line
522              * and display it. Don't attempt this if we have a
523              * premature EOF condition.
524              */
525             if (*PrematureEOF)
526             {
527                 fprintf (OutputFile, "\n");
528                 return AE_OK;
529             }
530 
531             /*
532              * Seek to the offset in the combined source file,
533              * read the source line, and write it to the output.
534              */
535             Actual = fseek (SourceFile,
536                 (long) Enode->LogicalByteOffset, (int) SEEK_SET);
537             if (Actual)
538             {
539                 fprintf (OutputFile,
540                     "[*** iASL: Seek error on source code temp file %s ***]",
541                     AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
542 
543                 fprintf (OutputFile, "\n");
544                 return AE_OK;
545             }
546             RActual = fread (&SourceByte, 1, 1, SourceFile);
547             if (RActual != 1)
548             {
549                 fprintf (OutputFile,
550                     "[*** iASL: Read error on source code temp file %s ***]",
551                     AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
552                 return AE_IO_ERROR;
553             }
554 
555             /* Read/write the source line, up to the maximum line length */
556 
557             while (RActual && SourceByte && (SourceByte != '\n'))
558             {
559                 if (*Total < 256)
560                 {
561                     /* After the max line length, we will just read the line, no write */
562 
563                     if (fwrite (&SourceByte, 1, 1, OutputFile) != 1)
564                     {
565                         printf ("[*** iASL: Write error on output file ***]\n");
566                         return AE_IO_ERROR;
567                     }
568                 }
569                 else if (*Total == 256)
570                 {
571                     fprintf (OutputFile,
572                         "\n[*** iASL: Very long input line, message below refers to column %u ***]",
573                         Enode->Column);
574                 }
575 
576                 RActual = fread (&SourceByte, 1, 1, SourceFile);
577                 if (RActual != 1)
578                 {
579                     fprintf (OutputFile,
580                         "[*** iASL: Read error on source code temp file %s ***]",
581                         AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
582 
583                     return AE_IO_ERROR;
584                 }
585                 *Total += 1;
586             }
587 
588             fprintf (OutputFile, "\n");
589         }
590     }
591     else
592     {
593         /*
594          * Less verbose version of the error message, enabled via the
595          * -vi switch. The format is compatible with MS Visual Studio.
596          */
597         fprintf (OutputFile, "%s", Enode->Filename);
598 
599         if (Enode->LineNumber)
600         {
601             fprintf (OutputFile, "(%u) : ",
602                 Enode->LineNumber);
603         }
604     }
605 
606     return AE_OK;
607 }
608 
609 /*******************************************************************************
610  *
611  * FUNCTION:    AePrintException
612  *
613  * PARAMETERS:  FileId          - ID of output file
614  *              Enode           - Error node to print
615  *              Header          - Additional text before each message
616  *
617  * RETURN:      None
618  *
619  * DESCRIPTION: Print the contents of an error node.
620  *
621  * NOTE:        We don't use the FlxxxFile I/O functions here because on error
622  *              they abort the compiler and call this function!  Since we
623  *              are reporting errors here, we ignore most output errors and
624  *              just try to get out as much as we can.
625  *
626  ******************************************************************************/
627 
628 void
629 AePrintException (
630     UINT32                  FileId,
631     ASL_ERROR_MSG           *Enode,
632     char                    *Header)
633 {
634     FILE                    *OutputFile;
635     BOOLEAN                 PrematureEOF = FALSE;
636     UINT32                  Total = 0;
637     ACPI_STATUS             Status;
638     ASL_ERROR_MSG           *Child = Enode->SubError;
639 
640 
641     if (AslGbl_NoErrors)
642     {
643         return;
644     }
645 
646     /*
647      * Only listing files have a header, and remarks/optimizations
648      * are always output
649      */
650     if (!Header)
651     {
652         /* Ignore remarks if requested */
653 
654         switch (Enode->Level)
655         {
656         case ASL_WARNING:
657         case ASL_WARNING2:
658         case ASL_WARNING3:
659 
660             if (!AslGbl_DisplayWarnings)
661             {
662                 return;
663             }
664             break;
665 
666         case ASL_REMARK:
667 
668             if (!AslGbl_DisplayRemarks)
669             {
670                 return;
671             }
672             break;
673 
674         case ASL_OPTIMIZATION:
675 
676             if (!AslGbl_DisplayOptimizations)
677             {
678                 return;
679             }
680             break;
681 
682         default:
683 
684             break;
685         }
686     }
687 
688     /* Get the various required file handles */
689 
690     OutputFile = AslGbl_Files[FileId].Handle;
691 
692     if (Header)
693     {
694         fprintf (OutputFile, "%s", Header);
695     }
696 
697     if (!Enode->Filename)
698     {
699         AeDecodeErrorMessageId (OutputFile, Enode, PrematureEOF, Total);
700         return;
701     }
702 
703     Status = AePrintErrorSourceLine (OutputFile, Enode, &PrematureEOF, &Total);
704     if (ACPI_FAILURE (Status))
705     {
706         return;
707     }
708 
709     /* If a NULL message ID, just print the raw message */
710 
711     if (Enode->MessageId == 0)
712     {
713         fprintf (OutputFile, "%s\n", Enode->Message);
714         return;
715     }
716 
717     AeDecodeErrorMessageId (OutputFile, Enode, PrematureEOF, Total);
718 
719     while (Child)
720     {
721         fprintf (OutputFile, "\n");
722         AePrintSubError (OutputFile, Child);
723         Child = Child->SubError;
724     }
725 }
726 
727 
728 /*******************************************************************************
729  *
730  * FUNCTION:    AePrintSubError
731  *
732  * PARAMETERS:  OutputFile      - Output file
733  *              Enode           - Error node to print
734  *
735  * RETURN:      None
736  *
737  * DESCRIPTION: Print the contents of an error node. This function is tailored
738  *              to print error nodes that are SubErrors within ASL_ERROR_MSG
739  *
740  ******************************************************************************/
741 
742 static void
743 AePrintSubError (
744     FILE                    *OutputFile,
745     ASL_ERROR_MSG           *Enode)
746 {
747     UINT32                  Total = 0;
748     BOOLEAN                 PrematureEOF = FALSE;
749     const char              *MainMessage;
750 
751 
752     MainMessage = AeDecodeMessageId (Enode->MessageId);
753 
754     fprintf (OutputFile, "    %s", MainMessage);
755 
756     if (Enode->Message)
757     {
758         fprintf (OutputFile, "(%s)", Enode->Message);
759     }
760 
761     fprintf (OutputFile, "\n    ");
762     (void) AePrintErrorSourceLine (OutputFile, Enode, &PrematureEOF, &Total);
763     fprintf (OutputFile, "\n");
764 }
765 
766 
767 /*******************************************************************************
768  *
769  * FUNCTION:    AePrintErrorLog
770  *
771  * PARAMETERS:  FileId           - Where to output the error log
772  *
773  * RETURN:      None
774  *
775  * DESCRIPTION: Print the entire contents of the error log
776  *
777  ******************************************************************************/
778 
779 void
780 AePrintErrorLog (
781     UINT32                  FileId)
782 {
783     ASL_ERROR_MSG           *Enode = AslGbl_ErrorLog;
784 
785 
786     /* Walk the error node list */
787 
788     while (Enode)
789     {
790         AePrintException (FileId, Enode, NULL);
791         Enode = Enode->Next;
792     }
793 }
794 
795 
796 /*******************************************************************************
797  *
798  * FUNCTION:    AslInitEnode
799  *
800  * PARAMETERS:  InputEnode          - Input Error node to initialize
801  *              Level               - Seriousness (Warning/error, etc.)
802  *              MessageId           - Index into global message buffer
803  *              CurrentLineNumber   - Actual file line number
804  *              LogicalLineNumber   - Cumulative line number
805  *              LogicalByteOffset   - Byte offset in source file
806  *              Column              - Column in current line
807  *              Filename            - Source filename
808  *              ExtraMessage        - Additional error message
809  *              SourceLine          - Line of error source code
810  *              SubError            - SubError of this InputEnode
811  *
812  * RETURN:      None
813  *
814  * DESCRIPTION: Initialize an Error node
815  *
816  ******************************************************************************/
817 
818 static void AslInitEnode (
819     ASL_ERROR_MSG           **InputEnode,
820     UINT8                   Level,
821     UINT16                  MessageId,
822     UINT32                  LineNumber,
823     UINT32                  LogicalLineNumber,
824     UINT32                  LogicalByteOffset,
825     UINT32                  Column,
826     char                    *Filename,
827     char                    *ExtraMessage,
828     char                    *SourceLine,
829     ASL_ERROR_MSG           *SubError)
830 {
831     ASL_ERROR_MSG           *Enode;
832     ASL_GLOBAL_FILE_NODE    *FileNode;
833 
834 
835     *InputEnode = UtLocalCalloc (sizeof (ASL_ERROR_MSG));
836     Enode = *InputEnode;
837     Enode->Level                = Level;
838     Enode->MessageId            = MessageId;
839     Enode->LineNumber           = LineNumber;
840     Enode->LogicalLineNumber    = LogicalLineNumber;
841     Enode->LogicalByteOffset    = LogicalByteOffset;
842     Enode->Column               = Column;
843     Enode->SubError             = SubError;
844     Enode->Message              = NULL;
845     Enode->SourceLine           = NULL;
846     Enode->Filename             = NULL;
847 
848     if (ExtraMessage)
849     {
850         /* Allocate a buffer for the message and a new error node */
851 
852         Enode->Message = UtLocalCacheCalloc (strlen (ExtraMessage) + 1);
853 
854         /* Keep a copy of the extra message */
855 
856         strcpy (Enode->Message, ExtraMessage);
857     }
858 
859     if (SourceLine)
860     {
861         Enode->SourceLine = UtLocalCalloc (strlen (SourceLine) + 1);
862         strcpy (Enode->SourceLine, SourceLine);
863     }
864 
865 
866     if (Filename)
867     {
868         Enode->Filename = Filename;
869         Enode->FilenameLength = strlen (Filename);
870         if (Enode->FilenameLength < 6)
871         {
872             Enode->FilenameLength = 6;
873         }
874 
875         /*
876          * Attempt to get the file node of the filename listed in the parse
877          * node. If the name doesn't exist in the global file node, it is
878          * because the file is included by #include or ASL include. In this
879          * case, get the current file node. The source output of the current
880          * file will contain the contents of the file listed in the parse node.
881          */
882         FileNode = FlGetFileNode (ASL_FILE_INPUT, Filename);
883         if (!FileNode)
884         {
885             FileNode = FlGetCurrentFileNode ();
886         }
887 
888         Enode->SourceFilename =
889             FileNode->Files[ASL_FILE_SOURCE_OUTPUT].Filename;
890     }
891 }
892 
893 
894 /*******************************************************************************
895  *
896  * FUNCTION:    AslCommonError2
897  *
898  * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
899  *              MessageId           - Index into global message buffer
900  *              LineNumber          - Actual file line number
901  *              Column              - Column in current line
902  *              SourceLine          - Actual source code line
903  *              Filename            - Source filename
904  *              ExtraMessage        - Additional error message
905  *
906  * RETURN:      None
907  *
908  * DESCRIPTION: Create a new error node and add it to the error log
909  *
910  ******************************************************************************/
911 
912 void
913 AslCommonError2 (
914     UINT8                   Level,
915     UINT16                  MessageId,
916     UINT32                  LineNumber,
917     UINT32                  Column,
918     char                    *SourceLine,
919     char                    *Filename,
920     char                    *ExtraMessage)
921 {
922     AslLogNewError (Level, MessageId, LineNumber, LineNumber, 0, Column,
923         Filename, ExtraMessage, SourceLine, NULL);
924 }
925 
926 
927 /*******************************************************************************
928  *
929  * FUNCTION:    AslCommonError
930  *
931  * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
932  *              MessageId           - Index into global message buffer
933  *              CurrentLineNumber   - Actual file line number
934  *              LogicalLineNumber   - Cumulative line number
935  *              LogicalByteOffset   - Byte offset in source file
936  *              Column              - Column in current line
937  *              Filename            - Source filename
938  *              ExtraMessage        - Additional error message
939  *
940  * RETURN:      None
941  *
942  * DESCRIPTION: Create a new error node and add it to the error log
943  *
944  ******************************************************************************/
945 
946 void
947 AslCommonError (
948     UINT8                   Level,
949     UINT16                  MessageId,
950     UINT32                  CurrentLineNumber,
951     UINT32                  LogicalLineNumber,
952     UINT32                  LogicalByteOffset,
953     UINT32                  Column,
954     char                    *Filename,
955     char                    *ExtraMessage)
956 {
957     /* Check if user wants to ignore this exception */
958 
959     if (AslIsExceptionIgnored (Level, MessageId))
960     {
961         return;
962     }
963 
964     AslLogNewError (Level, MessageId, CurrentLineNumber, LogicalLineNumber,
965         LogicalByteOffset, Column, Filename, ExtraMessage,
966         NULL, NULL);
967 }
968 
969 
970 /*******************************************************************************
971  *
972  * FUNCTION:    AslLogNewError
973  *
974  * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
975  *              MessageId           - Index into global message buffer
976  *              CurrentLineNumber   - Actual file line number
977  *              LogicalLineNumber   - Cumulative line number
978  *              LogicalByteOffset   - Byte offset in source file
979  *              Column              - Column in current line
980  *              Filename            - Source filename
981  *              Message             - Additional error message
982  *              SourceLine          - Actual line of source code
983  *              SubError            - Sub-error associated with this error
984  *
985  * RETURN:      None
986  *
987  * DESCRIPTION: Create a new error node and add it to the error log
988  *
989  ******************************************************************************/
990 static void
991 AslLogNewError (
992     UINT8                   Level,
993     UINT16                  MessageId,
994     UINT32                  LineNumber,
995     UINT32                  LogicalLineNumber,
996     UINT32                  LogicalByteOffset,
997     UINT32                  Column,
998     char                    *Filename,
999     char                    *Message,
1000     char                    *SourceLine,
1001     ASL_ERROR_MSG           *SubError)
1002 {
1003     ASL_ERROR_MSG           *Enode = NULL;
1004     UINT8                   ModifiedLevel = GetModifiedLevel (Level, MessageId);
1005 
1006 
1007     AslInitEnode (&Enode, ModifiedLevel, MessageId, LineNumber,
1008         LogicalLineNumber, LogicalByteOffset, Column, Filename, Message,
1009         SourceLine, SubError);
1010 
1011     /* Add the new node to the error node list */
1012 
1013     AeAddToErrorLog (Enode);
1014 
1015     if (AslGbl_DebugFlag)
1016     {
1017         /* stderr is a file, send error to it immediately */
1018 
1019         AePrintException (ASL_FILE_STDERR, Enode, NULL);
1020     }
1021 
1022     AslGbl_ExceptionCount[ModifiedLevel]++;
1023     if (!AslGbl_IgnoreErrors && AslGbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
1024     {
1025         printf ("\nMaximum error count (%u) exceeded\n", ASL_MAX_ERROR_COUNT);
1026 
1027         AslGbl_SourceLine = 0;
1028         AslGbl_NextError = AslGbl_ErrorLog;
1029         CmCleanupAndExit ();
1030         exit(1);
1031     }
1032 
1033     return;
1034 }
1035 
1036 
1037 /*******************************************************************************
1038  *
1039  * FUNCTION:    GetModifiedLevel
1040  *
1041  * PARAMETERS:  Level           - Seriousness (Warning/error, etc.)
1042  *              MessageId       - Index into global message buffer
1043  *
1044  * RETURN:      UINT8           - Modified level
1045  *
1046  * DESCRIPTION: Get the modified level of exception codes that are reported as
1047  *              errors from the -ww option.
1048  *
1049  ******************************************************************************/
1050 
1051 static UINT8
1052 GetModifiedLevel (
1053     UINT8                   Level,
1054     UINT16                  MessageId)
1055 {
1056     UINT16                  i;
1057     UINT16                  ExceptionCode;
1058 
1059 
1060     ExceptionCode = AeBuildFullExceptionCode (Level, MessageId);
1061 
1062     for (i = 0; i < AslGbl_ElevatedMessagesIndex; i++)
1063     {
1064         if (ExceptionCode == AslGbl_ElevatedMessages[i])
1065         {
1066             return (ASL_ERROR);
1067         }
1068     }
1069 
1070     return (Level);
1071 }
1072 
1073 
1074 /*******************************************************************************
1075  *
1076  * FUNCTION:    AslIsExceptionIgnored
1077  *
1078  * PARAMETERS:  Level           - Seriousness (Warning/error, etc.)
1079  *              MessageId       - Index into global message buffer
1080  *
1081  * RETURN:      BOOLEAN
1082  *
1083  * DESCRIPTION: Check if a particular exception is ignored. In this case it
1084  *              means that the exception is (expected or disabled.
1085  *
1086  ******************************************************************************/
1087 
1088 BOOLEAN
1089 AslIsExceptionIgnored (
1090     UINT8                   Level,
1091     UINT16                  MessageId)
1092 {
1093     BOOLEAN                 ExceptionIgnored;
1094 
1095 
1096     /* Note: this allows exception to be disabled and expected */
1097 
1098     ExceptionIgnored = AslIsExceptionDisabled (Level, MessageId);
1099     ExceptionIgnored |= AslIsExceptionExpected (Level, MessageId);
1100 
1101     return (AslGbl_AllExceptionsDisabled || ExceptionIgnored);
1102 }
1103 
1104 
1105 /*******************************************************************************
1106  *
1107  * FUNCTION:    AslCheckExpectException
1108  *
1109  * PARAMETERS:  none
1110  *
1111  * RETURN:      none
1112  *
1113  * DESCRIPTION: Check the global expected messages table and raise an error
1114  *              for each message that has not been received.
1115  *
1116  ******************************************************************************/
1117 
1118 void
1119 AslCheckExpectedExceptions (
1120     void)
1121 {
1122     UINT8                   i;
1123 
1124 
1125     for (i = 0; i < AslGbl_ExpectedMessagesIndex; ++i)
1126     {
1127         if (!AslGbl_ExpectedMessages[i].MessageReceived)
1128         {
1129             AslError (ASL_ERROR, ASL_MSG_EXCEPTION_NOT_RECEIVED, NULL,
1130                 AslGbl_ExpectedMessages[i].MessageIdStr);
1131         }
1132     }
1133 }
1134 
1135 
1136 /*******************************************************************************
1137  *
1138  * FUNCTION:    AslExpectException
1139  *
1140  * PARAMETERS:  MessageIdString     - ID of excepted exception during compile
1141  *
1142  * RETURN:      Status
1143  *
1144  * DESCRIPTION: Enter a message ID into the global expected messages table
1145  *              If these messages are not raised during the compilation, throw
1146  *              an error.
1147  *
1148  ******************************************************************************/
1149 
1150 ACPI_STATUS
1151 AslExpectException (
1152     char                    *MessageIdString)
1153 {
1154     UINT32                  MessageId;
1155 
1156 
1157     /* Convert argument to an integer and validate it */
1158 
1159     MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
1160 
1161     if (MessageId > 6999)
1162     {
1163         printf ("\"%s\" is not a valid warning/remark/erro ID\n",
1164             MessageIdString);
1165         return (AE_BAD_PARAMETER);
1166     }
1167 
1168     /* Insert value into the global expected message array */
1169 
1170     if (AslGbl_ExpectedMessagesIndex >= ASL_MAX_EXPECTED_MESSAGES)
1171     {
1172         printf ("Too many messages have been registered as expected (max %d)\n",
1173             ASL_MAX_DISABLED_MESSAGES);
1174         return (AE_LIMIT);
1175     }
1176 
1177     AslGbl_ExpectedMessages[AslGbl_ExpectedMessagesIndex].MessageId = MessageId;
1178     AslGbl_ExpectedMessages[AslGbl_ExpectedMessagesIndex].MessageIdStr = MessageIdString;
1179     AslGbl_ExpectedMessages[AslGbl_ExpectedMessagesIndex].MessageReceived = FALSE;
1180     AslGbl_ExpectedMessagesIndex++;
1181     return (AE_OK);
1182 }
1183 
1184 
1185 /*******************************************************************************
1186  *
1187  * FUNCTION:    AslDisableException
1188  *
1189  * PARAMETERS:  MessageIdString     - ID to be disabled
1190  *
1191  * RETURN:      Status
1192  *
1193  * DESCRIPTION: Enter a message ID into the global disabled messages table
1194  *
1195  ******************************************************************************/
1196 
1197 ACPI_STATUS
1198 AslDisableException (
1199     char                    *MessageIdString)
1200 {
1201     UINT32                  MessageId;
1202 
1203 
1204     /* Convert argument to an integer and validate it */
1205 
1206     MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
1207 
1208     if ((MessageId < 2000) || (MessageId > 6999))
1209     {
1210         printf ("\"%s\" is not a valid warning/remark/error ID\n",
1211             MessageIdString);
1212         return (AE_BAD_PARAMETER);
1213     }
1214 
1215     /* Insert value into the global disabled message array */
1216 
1217     if (AslGbl_DisabledMessagesIndex >= ASL_MAX_DISABLED_MESSAGES)
1218     {
1219         printf ("Too many messages have been disabled (max %d)\n",
1220             ASL_MAX_DISABLED_MESSAGES);
1221         return (AE_LIMIT);
1222     }
1223 
1224     AslGbl_DisabledMessages[AslGbl_DisabledMessagesIndex] = MessageId;
1225     AslGbl_DisabledMessagesIndex++;
1226     return (AE_OK);
1227 }
1228 
1229 
1230 /*******************************************************************************
1231  *
1232  * FUNCTION:    AslElevateException
1233  *
1234  * PARAMETERS:  MessageIdString     - ID of excepted exception during compile
1235  *
1236  * RETURN:      Status
1237  *
1238  * DESCRIPTION: Enter a message ID into the global elevated exceptions table.
1239  *              These messages will be considered as compilation errors.
1240  *
1241  ******************************************************************************/
1242 
1243 ACPI_STATUS
1244 AslElevateException (
1245     char                    *MessageIdString)
1246 {
1247     UINT32                  MessageId;
1248 
1249 
1250     /* Convert argument to an integer and validate it */
1251 
1252     MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
1253 
1254     if (MessageId > 6999)
1255     {
1256         printf ("\"%s\" is not a valid warning/remark/erro ID\n",
1257             MessageIdString);
1258         return (AE_BAD_PARAMETER);
1259     }
1260 
1261     /* Insert value into the global expected message array */
1262 
1263     if (AslGbl_ElevatedMessagesIndex >= ASL_MAX_ELEVATED_MESSAGES)
1264     {
1265         printf ("Too many messages have been registered as elevated (max %d)\n",
1266             ASL_MAX_DISABLED_MESSAGES);
1267         return (AE_LIMIT);
1268     }
1269 
1270     AslGbl_ElevatedMessages[AslGbl_ElevatedMessagesIndex] = MessageId;
1271     AslGbl_ElevatedMessagesIndex++;
1272     return (AE_OK);
1273 }
1274 
1275 /*******************************************************************************
1276  *
1277  * FUNCTION:    AslIsExceptionDisabled
1278  *
1279  * PARAMETERS:  Level           - Seriousness (Warning/error, etc.)
1280  *              MessageId       - Index into global message buffer
1281  *
1282  * RETURN:      TRUE if exception/message should be ignored
1283  *
1284  * DESCRIPTION: Check if the user has specified options such that this
1285  *              exception should be ignored
1286  *
1287  ******************************************************************************/
1288 
1289 static BOOLEAN
1290 AslIsExceptionExpected (
1291     UINT8                   Level,
1292     UINT16                  MessageId)
1293 {
1294     UINT32                  EncodedMessageId;
1295     UINT32                  i;
1296 
1297 
1298     /* Mark this exception as received */
1299 
1300     EncodedMessageId = AeBuildFullExceptionCode (Level, MessageId);
1301     for (i = 0; i < AslGbl_ExpectedMessagesIndex; i++)
1302     {
1303         /* Simple implementation via fixed array */
1304 
1305         if (EncodedMessageId == AslGbl_ExpectedMessages[i].MessageId)
1306         {
1307             return (AslGbl_ExpectedMessages[i].MessageReceived = TRUE);
1308         }
1309     }
1310 
1311     return (FALSE);
1312 }
1313 
1314 
1315 /*******************************************************************************
1316  *
1317  * FUNCTION:    AslIsExceptionDisabled
1318  *
1319  * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
1320  *              MessageId           - Index into global message buffer
1321  *
1322  * RETURN:      TRUE if exception/message should be ignored
1323  *
1324  * DESCRIPTION: Check if the user has specified options such that this
1325  *              exception should be ignored
1326  *
1327  ******************************************************************************/
1328 
1329 static BOOLEAN
1330 AslIsExceptionDisabled (
1331     UINT8                   Level,
1332     UINT16                  MessageId)
1333 {
1334     UINT32                  EncodedMessageId;
1335     UINT32                  i;
1336 
1337 
1338     switch (Level)
1339     {
1340     case ASL_WARNING2:
1341     case ASL_WARNING3:
1342 
1343         /* Check for global disable via -w1/-w2/-w3 options */
1344 
1345         if (Level > AslGbl_WarningLevel)
1346         {
1347             return (TRUE);
1348         }
1349         /* Fall through */
1350 
1351     case ASL_WARNING:
1352     case ASL_REMARK:
1353     case ASL_ERROR:
1354         /*
1355          * Ignore this error/warning/remark if it has been disabled by
1356          * the user (-vw option)
1357          */
1358         EncodedMessageId = AeBuildFullExceptionCode (Level, MessageId);
1359         for (i = 0; i < AslGbl_DisabledMessagesIndex; i++)
1360         {
1361             /* Simple implementation via fixed array */
1362 
1363             if (EncodedMessageId == AslGbl_DisabledMessages[i])
1364             {
1365                 return (TRUE);
1366             }
1367         }
1368         break;
1369 
1370     default:
1371         break;
1372     }
1373 
1374     return (FALSE);
1375 }
1376 
1377 
1378 /*******************************************************************************
1379  *
1380  * FUNCTION:    AslDualParseOpError
1381  *
1382  * PARAMETERS:  Level           - Seriousness (Warning/error, etc.)
1383  *              MainMsgId       - Index into global message buffer
1384  *              MainOp          - Parse node where error happened
1385  *              MainMsg         - Message pertaining to the MainOp
1386  *              SubMsgId        - Index into global message buffer
1387  *              SubOp           - Additional parse node for better message
1388  *              SubMsg          - Message pertaining to SubOp
1389  *
1390  *
1391  * RETURN:      None
1392  *
1393  * DESCRIPTION: Main error reporting routine for the ASL compiler for error
1394  *              messages that point to multiple parse objects.
1395  *
1396  ******************************************************************************/
1397 
1398 void
1399 AslDualParseOpError (
1400     UINT8                   Level,
1401     UINT16                  MainMsgId,
1402     ACPI_PARSE_OBJECT       *MainOp,
1403     char                    *MainMsg,
1404     UINT16                  SubMsgId,
1405     ACPI_PARSE_OBJECT       *SubOp,
1406     char                    *SubMsg)
1407 {
1408     ASL_ERROR_MSG           *SubEnode = NULL;
1409 
1410 
1411     /* Check if user wants to ignore this exception */
1412 
1413     if (AslIsExceptionIgnored (Level, MainMsgId) || !MainOp)
1414     {
1415         return;
1416     }
1417 
1418     if (SubOp)
1419     {
1420         AslInitEnode (&SubEnode, Level, SubMsgId, SubOp->Asl.LineNumber,
1421             SubOp->Asl.LogicalLineNumber, SubOp->Asl.LogicalByteOffset,
1422             SubOp->Asl.Column, SubOp->Asl.Filename, SubMsg,
1423             NULL, NULL);
1424     }
1425 
1426     AslLogNewError (Level, MainMsgId, MainOp->Asl.LineNumber,
1427         MainOp->Asl.LogicalLineNumber, MainOp->Asl.LogicalByteOffset,
1428         MainOp->Asl.Column, MainOp->Asl.Filename, MainMsg,
1429         NULL, SubEnode);
1430 }
1431 
1432 
1433 /*******************************************************************************
1434  *
1435  * FUNCTION:    AslError
1436  *
1437  * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
1438  *              MessageId           - Index into global message buffer
1439  *              Op                  - Parse node where error happened
1440  *              ExtraMessage        - Additional error message
1441  *
1442  * RETURN:      None
1443  *
1444  * DESCRIPTION: Main error reporting routine for the ASL compiler (all code
1445  *              except the parser.)
1446  *
1447  ******************************************************************************/
1448 
1449 void
1450 AslError (
1451     UINT8                   Level,
1452     UINT16                  MessageId,
1453     ACPI_PARSE_OBJECT       *Op,
1454     char                    *ExtraMessage)
1455 {
1456     if (Op)
1457     {
1458         AslCommonError (Level, MessageId, Op->Asl.LineNumber,
1459             Op->Asl.LogicalLineNumber,
1460             Op->Asl.LogicalByteOffset,
1461             Op->Asl.Column,
1462             Op->Asl.Filename, ExtraMessage);
1463     }
1464     else
1465     {
1466         AslCommonError (Level, MessageId, 0,
1467             0, 0, 0, NULL, ExtraMessage);
1468     }
1469 }
1470 
1471 
1472 /*******************************************************************************
1473  *
1474  * FUNCTION:    AslCoreSubsystemError
1475  *
1476  * PARAMETERS:  Op                  - Parse node where error happened
1477  *              Status              - The ACPICA Exception
1478  *              ExtraMessage        - Additional error message
1479  *              Abort               - TRUE -> Abort compilation
1480  *
1481  * RETURN:      None
1482  *
1483  * DESCRIPTION: Error reporting routine for exceptions returned by the ACPICA
1484  *              core subsystem.
1485  *
1486  ******************************************************************************/
1487 
1488 void
1489 AslCoreSubsystemError (
1490     ACPI_PARSE_OBJECT       *Op,
1491     ACPI_STATUS             Status,
1492     char                    *ExtraMessage,
1493     BOOLEAN                 Abort)
1494 {
1495 
1496     sprintf (AslGbl_MsgBuffer, "%s %s", AcpiFormatException (Status), ExtraMessage);
1497 
1498     if (Op)
1499     {
1500         AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION,
1501             Op->Asl.LineNumber,
1502             Op->Asl.LogicalLineNumber,
1503             Op->Asl.LogicalByteOffset,
1504             Op->Asl.Column,
1505             Op->Asl.Filename, AslGbl_MsgBuffer);
1506     }
1507     else
1508     {
1509         AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION,
1510             0, 0, 0, 0, NULL, AslGbl_MsgBuffer);
1511     }
1512 
1513     if (Abort)
1514     {
1515         AslAbort ();
1516     }
1517 }
1518 
1519 
1520 /*******************************************************************************
1521  *
1522  * FUNCTION:    AslCompilererror
1523  *
1524  * PARAMETERS:  CompilerMessage         - Error message from the parser
1525  *
1526  * RETURN:      Status (0 for now)
1527  *
1528  * DESCRIPTION: Report an error situation discovered in a production
1529  *              NOTE: don't change the name of this function, it is called
1530  *              from the auto-generated parser.
1531  *
1532  ******************************************************************************/
1533 
1534 int
1535 AslCompilererror (
1536     const char              *CompilerMessage)
1537 {
1538 
1539     AslGbl_SyntaxError++;
1540 
1541     AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, AslGbl_CurrentLineNumber,
1542         AslGbl_LogicalLineNumber, AslGbl_CurrentLineOffset,
1543         AslGbl_CurrentColumn, AslGbl_Files[ASL_FILE_INPUT].Filename,
1544         ACPI_CAST_PTR (char, CompilerMessage));
1545 
1546     return (0);
1547 }
1548