aslerror.c revision 209746
197403Sobrien
297403Sobrien/******************************************************************************
3169691Skan *
497403Sobrien * Module Name: aslerror - Error handling and statistics
597403Sobrien *
697403Sobrien *****************************************************************************/
797403Sobrien
897403Sobrien/******************************************************************************
997403Sobrien *
1097403Sobrien * 1. Copyright Notice
1197403Sobrien *
1297403Sobrien * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
1397403Sobrien * All rights reserved.
1497403Sobrien *
1597403Sobrien * 2. License
1697403Sobrien *
1797403Sobrien * 2.1. This is your license from Intel Corp. under its intellectual property
1897403Sobrien * rights.  You may have additional license terms from the party that provided
19169691Skan * you this software, covering your right to use that party's intellectual
2097403Sobrien * property rights.
2197403Sobrien *
2297403Sobrien * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2397403Sobrien * copy of the source code appearing in this file ("Covered Code") an
2497403Sobrien * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2597403Sobrien * base code distributed originally by Intel ("Original Intel Code") to copy,
2697403Sobrien * make derivatives, distribute, use and display any portion of the Covered
2797403Sobrien * Code in any form, with the right to sublicense such rights; and
2897403Sobrien *
2997403Sobrien * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3097403Sobrien * license (with the right to sublicense), under only those claims of Intel
31169691Skan * patents that are infringed by the Original Intel Code, to make, use, sell,
32169691Skan * offer to sell, and import the Covered Code and derivative works thereof
33169691Skan * solely to the minimum extent necessary to exercise the above copyright
34169691Skan * license, and in no event shall the patent license extend to any additions
3597403Sobrien * to or modifications of the Original Intel Code.  No other license or right
36132720Skan * is granted directly or by implication, estoppel or otherwise;
37132720Skan *
3897403Sobrien * The above copyright and patent license is granted only if the following
3997403Sobrien * conditions are met:
4097403Sobrien *
41132720Skan * 3. Conditions
42132720Skan *
4397403Sobrien * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44169691Skan * Redistribution of source code of any substantial portion of the Covered
4597403Sobrien * Code or modification with rights to further distribute source must include
46169691Skan * the above Copyright Notice, the above License, this list of Conditions,
47169691Skan * and the following Disclaimer and Export Compliance provision.  In addition,
4897403Sobrien * Licensee must cause all Covered Code to which Licensee contributes to
4997403Sobrien * contain a file documenting the changes Licensee made to create that Covered
5097403Sobrien * Code and the date of any change.  Licensee must include in that file the
5197403Sobrien * documentation of any changes made by any predecessor Licensee.  Licensee
5297403Sobrien * must include a prominent statement that the modification is derived,
53132720Skan * directly or indirectly, from Original Intel Code.
54132720Skan *
55132720Skan * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56132720Skan * Redistribution of source code of any substantial portion of the Covered
57132720Skan * Code or modification without rights to further distribute source must
58132720Skan * include the following Disclaimer and Export Compliance provision in the
59132720Skan * documentation and/or other materials provided with distribution.  In
60132720Skan * addition, Licensee may not authorize further sublicense of source of any
61132720Skan * portion of the Covered Code, and must include terms to the effect that the
6297403Sobrien * license from Licensee to its licensee is limited to the intellectual
6397403Sobrien * property embodied in the software Licensee provides to its licensee, and
6497403Sobrien * not to intellectual property embodied in modifications its licensee may
6597403Sobrien * make.
6697403Sobrien *
6797403Sobrien * 3.3. Redistribution of Executable. Redistribution in executable form of any
6897403Sobrien * substantial portion of the Covered Code or modification must reproduce the
6997403Sobrien * above Copyright Notice, and the following Disclaimer and Export Compliance
7097403Sobrien * provision in the documentation and/or other materials provided with the
7197403Sobrien * distribution.
7297403Sobrien *
7397403Sobrien * 3.4. Intel retains all right, title, and interest in and to the Original
7497403Sobrien * Intel Code.
7597403Sobrien *
76132720Skan * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77132720Skan * Intel shall be used in advertising or otherwise to promote the sale, use or
78132720Skan * other dealings in products derived from or relating to the Covered Code
79132720Skan * without prior written authorization from Intel.
80132720Skan *
81132720Skan * 4. Disclaimer and Export Compliance
82132720Skan *
83132720Skan * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84132720Skan * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85132720Skan * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86132720Skan * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8797403Sobrien * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88132720Skan * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89132720Skan * PARTICULAR PURPOSE.
90132720Skan *
91132720Skan * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92132720Skan * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93132720Skan * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94132720Skan * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95132720Skan * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96132720Skan * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97132720Skan * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98132720Skan * LIMITED REMEDY.
99132720Skan *
100132720Skan * 4.3. Licensee shall not export, either directly or indirectly, any of this
101132720Skan * software or system incorporating such software without first obtaining any
102132720Skan * required license or other approval from the U. S. Department of Commerce or
103132720Skan * any other agency or department of the United States Government.  In the
104132720Skan * event Licensee exports any such software from the United States or
105132720Skan * re-exports any such software from a foreign destination, Licensee shall
106132720Skan * ensure that the distribution and export/re-export of the software is in
107132720Skan * compliance with all laws, regulations, orders, or other restrictions of the
108132720Skan * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109132720Skan * any of its subsidiaries will export/re-export any technical data, process,
110132720Skan * software, or service, directly or indirectly, to any country for which the
11197403Sobrien * United States government or any agency thereof requires an export license,
11297403Sobrien * other governmental approval, or letter of assurance, without first obtaining
113132720Skan * such license, approval or letter.
114132720Skan *
11597403Sobrien *****************************************************************************/
11697403Sobrien
11797403Sobrien#define ASL_EXCEPTIONS
11897403Sobrien#include <contrib/dev/acpica/compiler/aslcompiler.h>
11997403Sobrien
120132720Skan#define _COMPONENT          ACPI_COMPILER
121132720Skan        ACPI_MODULE_NAME    ("aslerror")
12297403Sobrien
123132720Skan/* Local prototypes */
12497403Sobrien
125132720Skanstatic void
126132720SkanAeAddToErrorLog (
127132720Skan    ASL_ERROR_MSG           *Enode);
128132720Skan
129132720Skan
130132720Skanvoid
131132720SkanAeClearErrorLog (
132132720Skan    void)
133132720Skan{
134132720Skan    ASL_ERROR_MSG           *Enode = Gbl_ErrorLog;
135132720Skan    ASL_ERROR_MSG           *Next;
136132720Skan
137132720Skan    /* Walk the error node list */
138132720Skan
139132720Skan    while (Enode)
140132720Skan    {
141132720Skan        Next = Enode->Next;
142132720Skan        ACPI_FREE (Enode);
143132720Skan        Enode = Next;
144132720Skan    }
145132720Skan
146132720Skan    Gbl_ErrorLog = NULL;
147132720Skan}
148132720Skan
149132720Skan
150132720Skan/*******************************************************************************
151132720Skan *
152132720Skan * FUNCTION:    AeAddToErrorLog
153132720Skan *
154132720Skan * PARAMETERS:  Enode       - An error node to add to the log
155132720Skan *
156132720Skan * RETURN:      None
157132720Skan *
158132720Skan * DESCRIPTION: Add a new error node to the error log.  The error log is
159132720Skan *              ordered by the "logical" line number (cumulative line number
160132720Skan *              including all include files.)
161132720Skan *
162132720Skan ******************************************************************************/
163132720Skan
164132720Skanstatic void
165132720SkanAeAddToErrorLog (
166132720Skan    ASL_ERROR_MSG           *Enode)
167132720Skan{
168132720Skan    ASL_ERROR_MSG           *Next;
169132720Skan    ASL_ERROR_MSG           *Prev;
170132720Skan
171132720Skan
172132720Skan    /* If Gbl_ErrorLog is null, this is the first error node */
173132720Skan
174132720Skan    if (!Gbl_ErrorLog)
175132720Skan    {
176132720Skan        Gbl_ErrorLog = Enode;
177132720Skan        return;
178132720Skan    }
179132720Skan
180132720Skan    /*
181132720Skan     * Walk error list until we find a line number greater than ours.
182132720Skan     * List is sorted according to line number.
183132720Skan     */
184132720Skan    Prev = NULL;
185132720Skan    Next = Gbl_ErrorLog;
186132720Skan
187132720Skan    while ((Next) &&
188132720Skan           (Next->LogicalLineNumber <= Enode->LogicalLineNumber))
189132720Skan    {
190132720Skan        Prev = Next;
191132720Skan        Next = Next->Next;
192132720Skan    }
193132720Skan
194132720Skan    /* Found our place in the list */
195132720Skan
196132720Skan    Enode->Next = Next;
197169691Skan
198169691Skan    if (Prev)
199132720Skan    {
200132720Skan        Prev->Next = Enode;
201132720Skan    }
202132720Skan    else
203132720Skan    {
204132720Skan        Gbl_ErrorLog = Enode;
205132720Skan    }
206132720Skan}
207132720Skan
208132720Skan
209132720Skan/*******************************************************************************
210132720Skan *
211132720Skan * FUNCTION:    AePrintException
212132720Skan *
213132720Skan * PARAMETERS:  FileId          - ID of output file
214132720Skan *              Enode           - Error node to print
215132720Skan *              Header          - Additional text before each message
216132720Skan *
217132720Skan * RETURN:      None
21897403Sobrien *
21997403Sobrien * DESCRIPTION: Print the contents of an error node.
220132720Skan *
221132720Skan * NOTE:        We don't use the FlxxxFile I/O functions here because on error
222132720Skan *              they abort the compiler and call this function!  Since we
223117397Skan *              are reporting errors here, we ignore most output errors and
224132720Skan *              just try to get out as much as we can.
225132720Skan *
226132720Skan ******************************************************************************/
227132720Skan
228132720Skanvoid
229132720SkanAePrintException (
230132720Skan    UINT32                  FileId,
231132720Skan    ASL_ERROR_MSG           *Enode,
232132720Skan    char                    *Header)
233169691Skan{
234169691Skan    UINT8                   SourceByte;
235132720Skan    int                     Actual;
236132720Skan    size_t                  RActual;
237132720Skan    UINT32                  MsgLength;
238132720Skan    char                    *MainMessage;
239132720Skan    char                    *ExtraMessage;
240132720Skan    UINT32                  SourceColumn;
241132720Skan    UINT32                  ErrorColumn;
242132720Skan    FILE                    *OutputFile;
243132720Skan    FILE                    *SourceFile;
244132720Skan
245132720Skan
246132720Skan    if (Gbl_NoErrors)
247132720Skan    {
248132720Skan        return;
249132720Skan    }
250132720Skan
251132720Skan    /*
252132720Skan     * Only listing files have a header, and remarks/optimizations
253132720Skan     * are always output
254132720Skan     */
255132720Skan    if (!Header)
256132720Skan    {
257132720Skan        /* Ignore remarks if requested */
258132720Skan
259132720Skan        switch (Enode->Level)
260132720Skan        {
261117397Skan        case ASL_REMARK:
26297403Sobrien            if (!Gbl_DisplayRemarks)
263132720Skan            {
264132720Skan                return;
265132720Skan            }
266132720Skan            break;
267132720Skan
268132720Skan        case ASL_OPTIMIZATION:
269132720Skan            if (!Gbl_DisplayOptimizations)
270132720Skan            {
271132720Skan                return;
272132720Skan            }
273132720Skan            break;
274132720Skan
275132720Skan        default:
276169691Skan            break;
277169691Skan        }
27897403Sobrien    }
27997403Sobrien
28097403Sobrien    /* Get the file handles */
28197403Sobrien
28297403Sobrien    OutputFile = Gbl_Files[FileId].Handle;
28397403Sobrien
284132720Skan    /* Use the merged header/source file if present, otherwise use input file */
285169691Skan
286132720Skan    SourceFile = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
287132720Skan    if (!SourceFile)
288132720Skan    {
289132720Skan        SourceFile = Gbl_Files[ASL_FILE_INPUT].Handle;
290169691Skan    }
29197403Sobrien
292169691Skan    if (Header)
293169691Skan    {
294132720Skan        fprintf (OutputFile, "%s", Header);
29597403Sobrien    }
296169691Skan
29797403Sobrien    /* Print filename and line number if present and valid */
298169691Skan
299132720Skan    if (Enode->Filename)
300132720Skan    {
301132720Skan        if (Gbl_VerboseErrors)
302132720Skan        {
303132720Skan            fprintf (OutputFile, "%6s", Enode->Filename);
304132720Skan
305169691Skan            if (Enode->LineNumber)
306169691Skan            {
307169691Skan                fprintf (OutputFile, "%6u: ", Enode->LineNumber);
308169691Skan
309132720Skan                /*
31097403Sobrien                 * Seek to the offset in the combined source file, read the source
31197403Sobrien                 * line, and write it to the output.
312132720Skan                 */
313169691Skan                Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset,
314169691Skan                            (int) SEEK_SET);
315169691Skan                if (Actual)
31697403Sobrien                {
317132720Skan                    fprintf (OutputFile,
318132720Skan                        "[*** iASL: Seek error on source code temp file %s ***]",
319132720Skan                        Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
320132720Skan                }
321132720Skan                else
322132720Skan                {
323132720Skan                    RActual = fread (&SourceByte, 1, 1, SourceFile);
324132720Skan                    if (!RActual)
325132720Skan                    {
326132720Skan                        fprintf (OutputFile,
327169691Skan                            "[*** iASL: Read error on source code temp file %s ***]",
328169691Skan                            Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
329169691Skan                    }
330169691Skan
331169691Skan                    else while (RActual && SourceByte && (SourceByte != '\n'))
332169691Skan                    {
333132720Skan                        fwrite (&SourceByte, 1, 1, OutputFile);
334132720Skan                        RActual = fread (&SourceByte, 1, 1, SourceFile);
335132720Skan                    }
33697403Sobrien                }
33797403Sobrien                fprintf (OutputFile, "\n");
33897403Sobrien            }
33997403Sobrien        }
34097403Sobrien        else
34197403Sobrien        {
342132720Skan            fprintf (OutputFile, "%s", Enode->Filename);
343132720Skan
344132720Skan            if (Enode->LineNumber)
34597403Sobrien            {
346169691Skan                fprintf (OutputFile, "(%u) : ", Enode->LineNumber);
347169691Skan            }
348169691Skan        }
349169691Skan    }
350169691Skan
351169691Skan    /* NULL message ID, just print the raw message */
352169691Skan
353169691Skan    if (Enode->MessageId == 0)
354169691Skan    {
355169691Skan        fprintf (OutputFile, "%s\n", Enode->Message);
356169691Skan    }
357169691Skan    else
358169691Skan    {
359169691Skan        /* Decode the message ID */
360169691Skan
361169691Skan        fprintf (OutputFile, "%s %4.4d -",
362169691Skan                    AslErrorLevel[Enode->Level],
363169691Skan                    Enode->MessageId + ((Enode->Level+1) * 1000));
364169691Skan
365169691Skan        MainMessage = AslMessages[Enode->MessageId];
366169691Skan        ExtraMessage = Enode->Message;
367169691Skan
368169691Skan        if (Enode->LineNumber)
369169691Skan        {
370169691Skan            MsgLength = strlen (MainMessage);
371169691Skan            if (MsgLength == 0)
372169691Skan            {
373169691Skan                MainMessage = Enode->Message;
374169691Skan
375169691Skan                MsgLength = strlen (MainMessage);
376132720Skan                ExtraMessage = NULL;
377169691Skan            }
378169691Skan
379169691Skan            if (Gbl_VerboseErrors)
380169691Skan            {
381169691Skan                SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2;
382169691Skan                ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1;
383169691Skan
384169691Skan                if ((MsgLength + ErrorColumn) < (SourceColumn - 1))
385169691Skan                {
386169691Skan                    fprintf (OutputFile, "%*s%s",
387169691Skan                        (int) ((SourceColumn - 1) - ErrorColumn),
38897403Sobrien                        MainMessage, " ^ ");
389169691Skan                }
390169691Skan                else
391169691Skan                {
392169691Skan                    fprintf (OutputFile, "%*s %s",
393169691Skan                        (int) ((SourceColumn - ErrorColumn) + 1), "^",
394169691Skan                        MainMessage);
395169691Skan                }
396169691Skan            }
397169691Skan            else
398169691Skan            {
399169691Skan                fprintf (OutputFile, " %s", MainMessage);
400169691Skan            }
401169691Skan
402169691Skan            /* Print the extra info message if present */
403169691Skan
404169691Skan            if (ExtraMessage)
405169691Skan            {
406169691Skan                fprintf (OutputFile, " (%s)", ExtraMessage);
407169691Skan            }
408169691Skan
409169691Skan            fprintf (OutputFile, "\n");
410169691Skan            if (Gbl_VerboseErrors)
411169691Skan            {
412169691Skan                fprintf (OutputFile, "\n");
413169691Skan            }
414169691Skan        }
415169691Skan        else
416169691Skan        {
417169691Skan            fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage);
418169691Skan        }
419169691Skan    }
420169691Skan}
421169691Skan
422169691Skan
423169691Skan/*******************************************************************************
424169691Skan *
425169691Skan * FUNCTION:    AePrintErrorLog
426169691Skan *
427169691Skan * PARAMETERS:  FileId           - Where to output the error log
428169691Skan *
429169691Skan * RETURN:      None
430169691Skan *
431169691Skan * DESCRIPTION: Print the entire contents of the error log
432169691Skan *
433169691Skan ******************************************************************************/
434169691Skan
435169691Skanvoid
436169691SkanAePrintErrorLog (
437169691Skan    UINT32                  FileId)
438169691Skan{
439169691Skan    ASL_ERROR_MSG           *Enode = Gbl_ErrorLog;
440169691Skan
441169691Skan
442169691Skan    /* Walk the error node list */
443169691Skan
444169691Skan    while (Enode)
445169691Skan    {
446169691Skan        AePrintException (FileId, Enode, NULL);
447169691Skan        Enode = Enode->Next;
448169691Skan    }
449169691Skan}
450169691Skan
451169691Skan
452169691Skan/*******************************************************************************
453169691Skan *
454169691Skan * FUNCTION:    AslCommonError
455169691Skan *
456169691Skan * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
457169691Skan *              MessageId           - Index into global message buffer
458169691Skan *              CurrentLineNumber   - Actual file line number
459169691Skan *              LogicalLineNumber   - Cumulative line number
460169691Skan *              LogicalByteOffset   - Byte offset in source file
461169691Skan *              Column              - Column in current line
462169691Skan *              Filename            - source filename
463169691Skan *              ExtraMessage        - additional error message
464169691Skan *
465169691Skan * RETURN:      None
466169691Skan *
467169691Skan * DESCRIPTION: Create a new error node and add it to the error log
468169691Skan *
469169691Skan ******************************************************************************/
470169691Skan
471169691Skanvoid
472169691SkanAslCommonError (
473169691Skan    UINT8                   Level,
474169691Skan    UINT8                   MessageId,
475169691Skan    UINT32                  CurrentLineNumber,
476169691Skan    UINT32                  LogicalLineNumber,
477169691Skan    UINT32                  LogicalByteOffset,
478169691Skan    UINT32                  Column,
479169691Skan    char                    *Filename,
480169691Skan    char                    *ExtraMessage)
481169691Skan{
482169691Skan    UINT32                  MessageSize;
483169691Skan    char                    *MessageBuffer = NULL;
484169691Skan    ASL_ERROR_MSG           *Enode;
48597403Sobrien
48697403Sobrien
487169691Skan    Enode = UtLocalCalloc (sizeof (ASL_ERROR_MSG));
48897403Sobrien
489132720Skan    if (ExtraMessage)
490132720Skan    {
49197403Sobrien        /* Allocate a buffer for the message and a new error node */
492132720Skan
493132720Skan        MessageSize   = strlen (ExtraMessage) + 1;
494132720Skan        MessageBuffer = UtLocalCalloc (MessageSize);
495132720Skan
49697403Sobrien        /* Keep a copy of the extra message */
49797403Sobrien
49897403Sobrien        ACPI_STRCPY (MessageBuffer, ExtraMessage);
499132720Skan    }
500169691Skan
50197403Sobrien    /* Initialize the error node */
50297403Sobrien
50397403Sobrien    if (Filename)
50497403Sobrien    {
505169691Skan        Enode->Filename       = Filename;
506169691Skan        Enode->FilenameLength = strlen (Filename);
507169691Skan        if (Enode->FilenameLength < 6)
508169691Skan        {
50997403Sobrien            Enode->FilenameLength = 6;
510132720Skan        }
511132720Skan    }
512132720Skan
513132720Skan    Enode->MessageId            = MessageId;
514132720Skan    Enode->Level                = Level;
515132720Skan    Enode->LineNumber           = CurrentLineNumber;
516169691Skan    Enode->LogicalLineNumber    = LogicalLineNumber;
517169691Skan    Enode->LogicalByteOffset    = LogicalByteOffset;
518169691Skan    Enode->Column               = Column;
519169691Skan    Enode->Message              = MessageBuffer;
520132720Skan
521132720Skan    /* Add the new node to the error node list */
522132720Skan
523132720Skan    AeAddToErrorLog (Enode);
524169691Skan
52597403Sobrien    if (Gbl_DebugFlag)
526132720Skan    {
527132720Skan        /* stderr is a file, send error to it immediately */
528132720Skan
529132720Skan        AePrintException (ASL_FILE_STDERR, Enode, NULL);
530132720Skan    }
531102782Skan
532169691Skan    Gbl_ExceptionCount[Level]++;
533169691Skan    if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
53497403Sobrien    {
535132720Skan        printf ("\nMaximum error count (%u) exceeded\n", ASL_MAX_ERROR_COUNT);
536132720Skan
537169691Skan        Gbl_SourceLine = 0;
538132720Skan        Gbl_NextError = Gbl_ErrorLog;
539169691Skan        CmDoOutputFiles ();
540132720Skan        CmCleanupAndExit ();
541132720Skan        exit(1);
542132720Skan    }
543132720Skan
544132720Skan    return;
545169691Skan}
546169691Skan
547169691Skan
548169691Skan/*******************************************************************************
549169691Skan *
550169691Skan * FUNCTION:    AslError
551132720Skan *
552132720Skan * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
553132720Skan *              MessageId           - Index into global message buffer
554132720Skan *              Op                  - Parse node where error happened
555169691Skan *              ExtraMessage        - additional error message
556169691Skan *
557169691Skan * RETURN:      None
558132720Skan *
559132720Skan * DESCRIPTION: Main error reporting routine for the ASL compiler (all code
560132720Skan *              except the parser.)
561132720Skan *
562132720Skan ******************************************************************************/
563169691Skan
564132720Skanvoid
565169691SkanAslError (
566169691Skan    UINT8                   Level,
567169691Skan    UINT8                   MessageId,
568169691Skan    ACPI_PARSE_OBJECT       *Op,
569169691Skan    char                    *ExtraMessage)
570169691Skan{
571132720Skan
572169691Skan    switch (Level)
573169691Skan    {
574169691Skan    case ASL_WARNING2:
575132720Skan    case ASL_WARNING3:
576169691Skan        if (Gbl_WarningLevel < Level)
577169691Skan        {
578169691Skan            return;
579132720Skan        }
580169691Skan        break;
581169691Skan
582132720Skan    default:
583169691Skan        break;
584169691Skan    }
585132720Skan
586132720Skan
587132720Skan    if (Op)
588169691Skan    {
589169691Skan        AslCommonError (Level, MessageId, Op->Asl.LineNumber,
590169691Skan                        Op->Asl.LogicalLineNumber,
591169691Skan                        Op->Asl.LogicalByteOffset,
592169691Skan                        Op->Asl.Column,
593169691Skan                        Op->Asl.Filename, ExtraMessage);
594169691Skan    }
595169691Skan    else
596169691Skan    {
597132720Skan        AslCommonError (Level, MessageId, 0,
598169691Skan                        0, 0, 0, NULL, ExtraMessage);
599132720Skan    }
600132720Skan}
601169691Skan
602169691Skan
60397403Sobrien/*******************************************************************************
604132720Skan *
605132720Skan * FUNCTION:    AslCoreSubsystemError
606132720Skan *
607132720Skan * PARAMETERS:  Op                  - Parse node where error happened
608169691Skan *              Status              - The ACPI CA Exception
609169691Skan *              ExtraMessage        - additional error message
610169691Skan *              Abort               - TRUE -> Abort compilation
611169691Skan *
612169691Skan * RETURN:      None
613169691Skan *
614132720Skan * DESCRIPTION: Error reporting routine for exceptions returned by the ACPI
615169691Skan *              CA core subsystem.
616169691Skan *
617169691Skan ******************************************************************************/
618169691Skan
619169691Skanvoid
620169691SkanAslCoreSubsystemError (
621169691Skan    ACPI_PARSE_OBJECT       *Op,
622169691Skan    ACPI_STATUS             Status,
623169691Skan    char                    *ExtraMessage,
624169691Skan    BOOLEAN                 Abort)
625169691Skan{
626169691Skan
627169691Skan    sprintf (MsgBuffer, "%s %s", AcpiFormatException (Status), ExtraMessage);
628169691Skan
629169691Skan    if (Op)
630169691Skan    {
631169691Skan        AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Op->Asl.LineNumber,
632169691Skan                        Op->Asl.LogicalLineNumber,
633169691Skan                        Op->Asl.LogicalByteOffset,
634169691Skan                        Op->Asl.Column,
635169691Skan                        Op->Asl.Filename, MsgBuffer);
636169691Skan    }
637169691Skan    else
638169691Skan    {
639132720Skan        AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, 0,
640169691Skan                        0, 0, 0, NULL, MsgBuffer);
641169691Skan    }
642169691Skan
643169691Skan    if (Abort)
644169691Skan    {
645169691Skan        AslAbort ();
646169691Skan    }
647169691Skan}
648169691Skan
649169691Skan
650169691Skan/*******************************************************************************
651169691Skan *
652169691Skan * FUNCTION:    AslCompilererror
653169691Skan *
654169691Skan * PARAMETERS:  CompilerMessage         - Error message from the parser
655169691Skan *
656169691Skan * RETURN:      Status (0 for now)
657169691Skan *
658169691Skan * DESCRIPTION: Report an error situation discovered in a production
659169691Skan *              NOTE: don't change the name of this function, it is called
660169691Skan *              from the auto-generated parser.
661169691Skan *
662169691Skan ******************************************************************************/
663169691Skan
664169691Skanint
665169691SkanAslCompilererror (
666169691Skan    char                    *CompilerMessage)
667169691Skan{
668169691Skan
669169691Skan    AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, Gbl_CurrentLineNumber,
670169691Skan                    Gbl_LogicalLineNumber, Gbl_CurrentLineOffset,
671169691Skan                    Gbl_CurrentColumn, Gbl_Files[ASL_FILE_INPUT].Filename,
672169691Skan                    CompilerMessage);
673169691Skan
674169691Skan    return 0;
675169691Skan}
676169691Skan
677169691Skan
678169691Skan