aslerror.c revision 199337
1118611Snjl
2118611Snjl/******************************************************************************
3118611Snjl *
4118611Snjl * Module Name: aslerror - Error handling and statistics
5118611Snjl *
6118611Snjl *****************************************************************************/
7118611Snjl
8118611Snjl/******************************************************************************
9118611Snjl *
10118611Snjl * 1. Copyright Notice
11118611Snjl *
12193529Sjkim * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
13118611Snjl * All rights reserved.
14118611Snjl *
15118611Snjl * 2. License
16118611Snjl *
17118611Snjl * 2.1. This is your license from Intel Corp. under its intellectual property
18118611Snjl * rights.  You may have additional license terms from the party that provided
19118611Snjl * you this software, covering your right to use that party's intellectual
20118611Snjl * property rights.
21118611Snjl *
22118611Snjl * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23118611Snjl * copy of the source code appearing in this file ("Covered Code") an
24118611Snjl * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25118611Snjl * base code distributed originally by Intel ("Original Intel Code") to copy,
26118611Snjl * make derivatives, distribute, use and display any portion of the Covered
27118611Snjl * Code in any form, with the right to sublicense such rights; and
28118611Snjl *
29118611Snjl * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30118611Snjl * license (with the right to sublicense), under only those claims of Intel
31118611Snjl * patents that are infringed by the Original Intel Code, to make, use, sell,
32118611Snjl * offer to sell, and import the Covered Code and derivative works thereof
33118611Snjl * solely to the minimum extent necessary to exercise the above copyright
34118611Snjl * license, and in no event shall the patent license extend to any additions
35118611Snjl * to or modifications of the Original Intel Code.  No other license or right
36118611Snjl * is granted directly or by implication, estoppel or otherwise;
37118611Snjl *
38118611Snjl * The above copyright and patent license is granted only if the following
39118611Snjl * conditions are met:
40118611Snjl *
41118611Snjl * 3. Conditions
42118611Snjl *
43118611Snjl * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44118611Snjl * Redistribution of source code of any substantial portion of the Covered
45118611Snjl * Code or modification with rights to further distribute source must include
46118611Snjl * the above Copyright Notice, the above License, this list of Conditions,
47118611Snjl * and the following Disclaimer and Export Compliance provision.  In addition,
48118611Snjl * Licensee must cause all Covered Code to which Licensee contributes to
49118611Snjl * contain a file documenting the changes Licensee made to create that Covered
50118611Snjl * Code and the date of any change.  Licensee must include in that file the
51118611Snjl * documentation of any changes made by any predecessor Licensee.  Licensee
52118611Snjl * must include a prominent statement that the modification is derived,
53118611Snjl * directly or indirectly, from Original Intel Code.
54118611Snjl *
55118611Snjl * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56118611Snjl * Redistribution of source code of any substantial portion of the Covered
57118611Snjl * Code or modification without rights to further distribute source must
58118611Snjl * include the following Disclaimer and Export Compliance provision in the
59118611Snjl * documentation and/or other materials provided with distribution.  In
60118611Snjl * addition, Licensee may not authorize further sublicense of source of any
61118611Snjl * portion of the Covered Code, and must include terms to the effect that the
62118611Snjl * license from Licensee to its licensee is limited to the intellectual
63118611Snjl * property embodied in the software Licensee provides to its licensee, and
64118611Snjl * not to intellectual property embodied in modifications its licensee may
65118611Snjl * make.
66118611Snjl *
67118611Snjl * 3.3. Redistribution of Executable. Redistribution in executable form of any
68118611Snjl * substantial portion of the Covered Code or modification must reproduce the
69118611Snjl * above Copyright Notice, and the following Disclaimer and Export Compliance
70118611Snjl * provision in the documentation and/or other materials provided with the
71118611Snjl * distribution.
72118611Snjl *
73118611Snjl * 3.4. Intel retains all right, title, and interest in and to the Original
74118611Snjl * Intel Code.
75118611Snjl *
76118611Snjl * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77118611Snjl * Intel shall be used in advertising or otherwise to promote the sale, use or
78118611Snjl * other dealings in products derived from or relating to the Covered Code
79118611Snjl * without prior written authorization from Intel.
80118611Snjl *
81118611Snjl * 4. Disclaimer and Export Compliance
82118611Snjl *
83118611Snjl * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84118611Snjl * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85118611Snjl * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86118611Snjl * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87118611Snjl * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88118611Snjl * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89118611Snjl * PARTICULAR PURPOSE.
90118611Snjl *
91118611Snjl * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92118611Snjl * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93118611Snjl * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94118611Snjl * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95118611Snjl * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96118611Snjl * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97118611Snjl * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98118611Snjl * LIMITED REMEDY.
99118611Snjl *
100118611Snjl * 4.3. Licensee shall not export, either directly or indirectly, any of this
101118611Snjl * software or system incorporating such software without first obtaining any
102118611Snjl * required license or other approval from the U. S. Department of Commerce or
103118611Snjl * any other agency or department of the United States Government.  In the
104118611Snjl * event Licensee exports any such software from the United States or
105118611Snjl * re-exports any such software from a foreign destination, Licensee shall
106118611Snjl * ensure that the distribution and export/re-export of the software is in
107118611Snjl * compliance with all laws, regulations, orders, or other restrictions of the
108118611Snjl * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109118611Snjl * any of its subsidiaries will export/re-export any technical data, process,
110118611Snjl * software, or service, directly or indirectly, to any country for which the
111118611Snjl * United States government or any agency thereof requires an export license,
112118611Snjl * other governmental approval, or letter of assurance, without first obtaining
113118611Snjl * such license, approval or letter.
114118611Snjl *
115118611Snjl *****************************************************************************/
116118611Snjl
117118611Snjl#define ASL_EXCEPTIONS
118151937Sjkim#include <contrib/dev/acpica/compiler/aslcompiler.h>
119118611Snjl
120118611Snjl#define _COMPONENT          ACPI_COMPILER
121118611Snjl        ACPI_MODULE_NAME    ("aslerror")
122118611Snjl
123151937Sjkim/* Local prototypes */
124118611Snjl
125151937Sjkimstatic void
126151937SjkimAeAddToErrorLog (
127151937Sjkim    ASL_ERROR_MSG           *Enode);
128151937Sjkim
129151937Sjkim
130193529Sjkimvoid
131193529SjkimAeClearErrorLog (
132193529Sjkim    void)
133193529Sjkim{
134193529Sjkim    ASL_ERROR_MSG           *Enode = Gbl_ErrorLog;
135193529Sjkim    ASL_ERROR_MSG           *Next;
136193529Sjkim
137193529Sjkim    /* Walk the error node list */
138193529Sjkim
139193529Sjkim    while (Enode)
140193529Sjkim    {
141193529Sjkim        Next = Enode->Next;
142193529Sjkim        ACPI_FREE (Enode);
143193529Sjkim        Enode = Next;
144193529Sjkim    }
145193529Sjkim
146193529Sjkim    Gbl_ErrorLog = NULL;
147193529Sjkim}
148193529Sjkim
149193529Sjkim
150118611Snjl/*******************************************************************************
151118611Snjl *
152118611Snjl * FUNCTION:    AeAddToErrorLog
153118611Snjl *
154118611Snjl * PARAMETERS:  Enode       - An error node to add to the log
155118611Snjl *
156118611Snjl * RETURN:      None
157118611Snjl *
158118611Snjl * DESCRIPTION: Add a new error node to the error log.  The error log is
159118611Snjl *              ordered by the "logical" line number (cumulative line number
160118611Snjl *              including all include files.)
161118611Snjl *
162118611Snjl ******************************************************************************/
163118611Snjl
164151937Sjkimstatic void
165118611SnjlAeAddToErrorLog (
166118611Snjl    ASL_ERROR_MSG           *Enode)
167118611Snjl{
168118611Snjl    ASL_ERROR_MSG           *Next;
169118611Snjl    ASL_ERROR_MSG           *Prev;
170118611Snjl
171118611Snjl
172118611Snjl    if (!Gbl_ErrorLog)
173118611Snjl    {
174118611Snjl        Gbl_ErrorLog = Enode;
175118611Snjl        return;
176118611Snjl    }
177118611Snjl
178118611Snjl    /* List is sorted according to line number */
179118611Snjl
180118611Snjl    if (!Gbl_ErrorLog)
181118611Snjl    {
182118611Snjl        Gbl_ErrorLog = Enode;
183118611Snjl        return;
184118611Snjl    }
185118611Snjl
186118611Snjl    /* Walk error list until we find a line number greater than ours */
187118611Snjl
188118611Snjl    Prev = NULL;
189118611Snjl    Next = Gbl_ErrorLog;
190118611Snjl
191118611Snjl    while ((Next) &&
192118611Snjl           (Next->LogicalLineNumber <= Enode->LogicalLineNumber))
193118611Snjl    {
194118611Snjl        Prev = Next;
195118611Snjl        Next = Next->Next;
196118611Snjl    }
197118611Snjl
198118611Snjl    /* Found our place in the list */
199118611Snjl
200118611Snjl    Enode->Next = Next;
201118611Snjl
202118611Snjl    if (Prev)
203118611Snjl    {
204118611Snjl        Prev->Next = Enode;
205118611Snjl    }
206118611Snjl    else
207118611Snjl    {
208118611Snjl        Gbl_ErrorLog = Enode;
209118611Snjl    }
210118611Snjl}
211118611Snjl
212118611Snjl
213118611Snjl/*******************************************************************************
214118611Snjl *
215118611Snjl * FUNCTION:    AePrintException
216118611Snjl *
217151937Sjkim * PARAMETERS:  FileId          - ID of output file
218118611Snjl *              Enode           - Error node to print
219118611Snjl *              Header          - Additional text before each message
220118611Snjl *
221118611Snjl * RETURN:      None
222118611Snjl *
223118611Snjl * DESCRIPTION: Print the contents of an error node.
224118611Snjl *
225118611Snjl * NOTE:        We don't use the FlxxxFile I/O functions here because on error
226118611Snjl *              they abort the compiler and call this function!  Since we
227118611Snjl *              are reporting errors here, we ignore most output errors and
228118611Snjl *              just try to get out as much as we can.
229118611Snjl *
230118611Snjl ******************************************************************************/
231118611Snjl
232118611Snjlvoid
233118611SnjlAePrintException (
234118611Snjl    UINT32                  FileId,
235118611Snjl    ASL_ERROR_MSG           *Enode,
236118611Snjl    char                    *Header)
237118611Snjl{
238118611Snjl    UINT8                   SourceByte;
239151937Sjkim    int                     Actual;
240151937Sjkim    size_t                  RActual;
241118611Snjl    UINT32                  MsgLength;
242118611Snjl    char                    *MainMessage;
243118611Snjl    char                    *ExtraMessage;
244118611Snjl    UINT32                  SourceColumn;
245118611Snjl    UINT32                  ErrorColumn;
246118611Snjl    FILE                    *OutputFile;
247118611Snjl    FILE                    *SourceFile;
248118611Snjl
249118611Snjl
250193529Sjkim    if (Gbl_NoErrors)
251193529Sjkim    {
252193529Sjkim        return;
253193529Sjkim    }
254193529Sjkim
255151937Sjkim    /*
256151937Sjkim     * Only listing files have a header, and remarks/optimizations
257151937Sjkim     * are always output
258151937Sjkim     */
259118611Snjl    if (!Header)
260118611Snjl    {
261118611Snjl        /* Ignore remarks if requested */
262118611Snjl
263118611Snjl        switch (Enode->Level)
264118611Snjl        {
265118611Snjl        case ASL_REMARK:
266118611Snjl            if (!Gbl_DisplayRemarks)
267118611Snjl            {
268118611Snjl                return;
269118611Snjl            }
270118611Snjl            break;
271118611Snjl
272118611Snjl        case ASL_OPTIMIZATION:
273118611Snjl            if (!Gbl_DisplayOptimizations)
274118611Snjl            {
275118611Snjl                return;
276118611Snjl            }
277118611Snjl            break;
278118611Snjl
279118611Snjl        default:
280118611Snjl            break;
281118611Snjl        }
282118611Snjl    }
283118611Snjl
284118611Snjl    /* Get the file handles */
285118611Snjl
286118611Snjl    OutputFile = Gbl_Files[FileId].Handle;
287118611Snjl    SourceFile = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
288118611Snjl
289118611Snjl    if (Header)
290118611Snjl    {
291118611Snjl        fprintf (OutputFile, "%s", Header);
292118611Snjl    }
293118611Snjl
294118611Snjl    /* Print filename and line number if present and valid */
295118611Snjl
296118611Snjl    if (Enode->Filename)
297118611Snjl    {
298118611Snjl        if (Gbl_VerboseErrors)
299118611Snjl        {
300118611Snjl            fprintf (OutputFile, "%6s", Enode->Filename);
301118611Snjl
302118611Snjl            if (Enode->LineNumber)
303118611Snjl            {
304118611Snjl                fprintf (OutputFile, "%6u: ", Enode->LineNumber);
305118611Snjl
306118611Snjl                /*
307118611Snjl                 * Seek to the offset in the combined source file, read the source
308118611Snjl                 * line, and write it to the output.
309118611Snjl                 */
310151937Sjkim                Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset,
311151937Sjkim                            (int) SEEK_SET);
312118611Snjl                if (Actual)
313118611Snjl                {
314151937Sjkim                    fprintf (OutputFile,
315193529Sjkim                        "[*** iASL: Seek error on source code temp file %s ***]",
316193529Sjkim                        Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
317118611Snjl                }
318118611Snjl                else
319118611Snjl                {
320151937Sjkim                    RActual = fread (&SourceByte, 1, 1, SourceFile);
321151937Sjkim                    if (!RActual)
322118611Snjl                    {
323151937Sjkim                        fprintf (OutputFile,
324193529Sjkim                            "[*** iASL: Read error on source code temp file %s ***]",
325193529Sjkim                            Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
326118611Snjl                    }
327118611Snjl
328151937Sjkim                    else while (RActual && SourceByte && (SourceByte != '\n'))
329118611Snjl                    {
330118611Snjl                        fwrite (&SourceByte, 1, 1, OutputFile);
331151937Sjkim                        RActual = fread (&SourceByte, 1, 1, SourceFile);
332118611Snjl                    }
333118611Snjl                }
334118611Snjl                fprintf (OutputFile, "\n");
335118611Snjl            }
336118611Snjl        }
337118611Snjl        else
338118611Snjl        {
339118611Snjl            fprintf (OutputFile, "%s", Enode->Filename);
340118611Snjl
341118611Snjl            if (Enode->LineNumber)
342118611Snjl            {
343118611Snjl                fprintf (OutputFile, "(%u) : ", Enode->LineNumber);
344118611Snjl            }
345118611Snjl        }
346118611Snjl    }
347118611Snjl
348118611Snjl    /* NULL message ID, just print the raw message */
349118611Snjl
350118611Snjl    if (Enode->MessageId == 0)
351118611Snjl    {
352118611Snjl        fprintf (OutputFile, "%s\n", Enode->Message);
353118611Snjl    }
354118611Snjl    else
355118611Snjl    {
356118611Snjl        /* Decode the message ID */
357118611Snjl
358118611Snjl        fprintf (OutputFile, "%s %4.4d -",
359118611Snjl                    AslErrorLevel[Enode->Level],
360118611Snjl                    Enode->MessageId + ((Enode->Level+1) * 1000));
361118611Snjl
362118611Snjl        MainMessage = AslMessages[Enode->MessageId];
363118611Snjl        ExtraMessage = Enode->Message;
364118611Snjl
365118611Snjl        if (Enode->LineNumber)
366118611Snjl        {
367118611Snjl            MsgLength = strlen (MainMessage);
368118611Snjl            if (MsgLength == 0)
369118611Snjl            {
370118611Snjl                MainMessage = Enode->Message;
371118611Snjl
372118611Snjl                MsgLength = strlen (MainMessage);
373118611Snjl                ExtraMessage = NULL;
374118611Snjl            }
375118611Snjl
376118611Snjl            if (Gbl_VerboseErrors)
377118611Snjl            {
378118611Snjl                SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2;
379118611Snjl                ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1;
380118611Snjl
381118611Snjl                if ((MsgLength + ErrorColumn) < (SourceColumn - 1))
382118611Snjl                {
383118611Snjl                    fprintf (OutputFile, "%*s%s",
384118611Snjl                        (int) ((SourceColumn - 1) - ErrorColumn),
385118611Snjl                        MainMessage, " ^ ");
386118611Snjl                }
387118611Snjl                else
388118611Snjl                {
389118611Snjl                    fprintf (OutputFile, "%*s %s",
390118611Snjl                        (int) ((SourceColumn - ErrorColumn) + 1), "^",
391118611Snjl                        MainMessage);
392118611Snjl                }
393118611Snjl            }
394118611Snjl            else
395118611Snjl            {
396118611Snjl                fprintf (OutputFile, " %s", MainMessage);
397118611Snjl            }
398118611Snjl
399118611Snjl            /* Print the extra info message if present */
400118611Snjl
401118611Snjl            if (ExtraMessage)
402118611Snjl            {
403118611Snjl                fprintf (OutputFile, " (%s)", ExtraMessage);
404118611Snjl            }
405118611Snjl
406118611Snjl            fprintf (OutputFile, "\n");
407118611Snjl            if (Gbl_VerboseErrors)
408118611Snjl            {
409118611Snjl                fprintf (OutputFile, "\n");
410118611Snjl            }
411118611Snjl        }
412118611Snjl        else
413118611Snjl        {
414151937Sjkim            fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage);
415118611Snjl        }
416118611Snjl    }
417118611Snjl}
418118611Snjl
419118611Snjl
420118611Snjl/*******************************************************************************
421118611Snjl *
422118611Snjl * FUNCTION:    AePrintErrorLog
423118611Snjl *
424118611Snjl * PARAMETERS:  FileId           - Where to output the error log
425118611Snjl *
426118611Snjl * RETURN:      None
427118611Snjl *
428118611Snjl * DESCRIPTION: Print the entire contents of the error log
429118611Snjl *
430118611Snjl ******************************************************************************/
431118611Snjl
432118611Snjlvoid
433118611SnjlAePrintErrorLog (
434118611Snjl    UINT32                  FileId)
435118611Snjl{
436118611Snjl    ASL_ERROR_MSG           *Enode = Gbl_ErrorLog;
437118611Snjl
438118611Snjl
439118611Snjl    /* Walk the error node list */
440118611Snjl
441118611Snjl    while (Enode)
442118611Snjl    {
443118611Snjl        AePrintException (FileId, Enode, NULL);
444118611Snjl        Enode = Enode->Next;
445118611Snjl    }
446118611Snjl}
447118611Snjl
448118611Snjl
449118611Snjl/*******************************************************************************
450118611Snjl *
451118611Snjl * FUNCTION:    AslCommonError
452118611Snjl *
453118611Snjl * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
454118611Snjl *              MessageId           - Index into global message buffer
455118611Snjl *              CurrentLineNumber   - Actual file line number
456118611Snjl *              LogicalLineNumber   - Cumulative line number
457118611Snjl *              LogicalByteOffset   - Byte offset in source file
458118611Snjl *              Column              - Column in current line
459118611Snjl *              Filename            - source filename
460118611Snjl *              ExtraMessage        - additional error message
461118611Snjl *
462151937Sjkim * RETURN:      None
463118611Snjl *
464118611Snjl * DESCRIPTION: Create a new error node and add it to the error log
465118611Snjl *
466118611Snjl ******************************************************************************/
467118611Snjl
468118611Snjlvoid
469118611SnjlAslCommonError (
470118611Snjl    UINT8                   Level,
471118611Snjl    UINT8                   MessageId,
472118611Snjl    UINT32                  CurrentLineNumber,
473118611Snjl    UINT32                  LogicalLineNumber,
474118611Snjl    UINT32                  LogicalByteOffset,
475118611Snjl    UINT32                  Column,
476118611Snjl    char                    *Filename,
477118611Snjl    char                    *ExtraMessage)
478118611Snjl{
479118611Snjl    UINT32                  MessageSize;
480118611Snjl    char                    *MessageBuffer = NULL;
481118611Snjl    ASL_ERROR_MSG           *Enode;
482118611Snjl
483118611Snjl
484118611Snjl    Enode = UtLocalCalloc (sizeof (ASL_ERROR_MSG));
485118611Snjl
486118611Snjl    if (ExtraMessage)
487118611Snjl    {
488118611Snjl        /* Allocate a buffer for the message and a new error node */
489118611Snjl
490118611Snjl        MessageSize   = strlen (ExtraMessage) + 1;
491118611Snjl        MessageBuffer = UtLocalCalloc (MessageSize);
492118611Snjl
493118611Snjl        /* Keep a copy of the extra message */
494118611Snjl
495118611Snjl        ACPI_STRCPY (MessageBuffer, ExtraMessage);
496118611Snjl    }
497118611Snjl
498118611Snjl    /* Initialize the error node */
499118611Snjl
500118611Snjl    if (Filename)
501118611Snjl    {
502118611Snjl        Enode->Filename       = Filename;
503118611Snjl        Enode->FilenameLength = strlen (Filename);
504118611Snjl        if (Enode->FilenameLength < 6)
505118611Snjl        {
506118611Snjl            Enode->FilenameLength = 6;
507118611Snjl        }
508118611Snjl    }
509118611Snjl
510118611Snjl    Enode->MessageId            = MessageId;
511118611Snjl    Enode->Level                = Level;
512118611Snjl    Enode->LineNumber           = CurrentLineNumber;
513118611Snjl    Enode->LogicalLineNumber    = LogicalLineNumber;
514118611Snjl    Enode->LogicalByteOffset    = LogicalByteOffset;
515118611Snjl    Enode->Column               = Column;
516118611Snjl    Enode->Message              = MessageBuffer;
517118611Snjl
518118611Snjl    /* Add the new node to the error node list */
519118611Snjl
520118611Snjl    AeAddToErrorLog (Enode);
521118611Snjl
522118611Snjl    if (Gbl_DebugFlag)
523118611Snjl    {
524118611Snjl        /* stderr is a file, send error to it immediately */
525118611Snjl
526118611Snjl        AePrintException (ASL_FILE_STDERR, Enode, NULL);
527118611Snjl    }
528118611Snjl
529118611Snjl    Gbl_ExceptionCount[Level]++;
530118611Snjl    if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
531118611Snjl    {
532167802Sjkim        printf ("\nMaximum error count (%d) exceeded\n", ASL_MAX_ERROR_COUNT);
533118611Snjl
534118611Snjl        Gbl_SourceLine = 0;
535118611Snjl        Gbl_NextError = Gbl_ErrorLog;
536118611Snjl        CmDoOutputFiles ();
537118611Snjl        CmCleanupAndExit ();
538199337Sjkim        exit(1);
539118611Snjl    }
540118611Snjl
541118611Snjl    return;
542118611Snjl}
543118611Snjl
544118611Snjl
545118611Snjl/*******************************************************************************
546118611Snjl *
547118611Snjl * FUNCTION:    AslError
548118611Snjl *
549118611Snjl * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
550118611Snjl *              MessageId           - Index into global message buffer
551118611Snjl *              Op                  - Parse node where error happened
552118611Snjl *              ExtraMessage        - additional error message
553118611Snjl *
554118611Snjl * RETURN:      None
555118611Snjl *
556118611Snjl * DESCRIPTION: Main error reporting routine for the ASL compiler (all code
557118611Snjl *              except the parser.)
558118611Snjl *
559118611Snjl ******************************************************************************/
560118611Snjl
561118611Snjlvoid
562118611SnjlAslError (
563118611Snjl    UINT8                   Level,
564118611Snjl    UINT8                   MessageId,
565118611Snjl    ACPI_PARSE_OBJECT       *Op,
566118611Snjl    char                    *ExtraMessage)
567118611Snjl{
568118611Snjl
569167802Sjkim    switch (Level)
570167802Sjkim    {
571167802Sjkim    case ASL_WARNING2:
572167802Sjkim    case ASL_WARNING3:
573167802Sjkim        if (Gbl_WarningLevel < Level)
574167802Sjkim        {
575167802Sjkim            return;
576167802Sjkim        }
577167802Sjkim        break;
578167802Sjkim
579167802Sjkim    default:
580167802Sjkim        break;
581167802Sjkim    }
582167802Sjkim
583167802Sjkim
584118611Snjl    if (Op)
585118611Snjl    {
586118611Snjl        AslCommonError (Level, MessageId, Op->Asl.LineNumber,
587118611Snjl                        Op->Asl.LogicalLineNumber,
588118611Snjl                        Op->Asl.LogicalByteOffset,
589118611Snjl                        Op->Asl.Column,
590118611Snjl                        Op->Asl.Filename, ExtraMessage);
591118611Snjl    }
592118611Snjl    else
593118611Snjl    {
594118611Snjl        AslCommonError (Level, MessageId, 0,
595118611Snjl                        0, 0, 0, NULL, ExtraMessage);
596118611Snjl    }
597118611Snjl}
598118611Snjl
599118611Snjl
600118611Snjl/*******************************************************************************
601118611Snjl *
602118611Snjl * FUNCTION:    AslCoreSubsystemError
603118611Snjl *
604118611Snjl * PARAMETERS:  Op                  - Parse node where error happened
605118611Snjl *              Status              - The ACPI CA Exception
606118611Snjl *              ExtraMessage        - additional error message
607118611Snjl *              Abort               - TRUE -> Abort compilation
608118611Snjl *
609118611Snjl * RETURN:      None
610118611Snjl *
611118611Snjl * DESCRIPTION: Error reporting routine for exceptions returned by the ACPI
612118611Snjl *              CA core subsystem.
613118611Snjl *
614118611Snjl ******************************************************************************/
615118611Snjl
616118611Snjlvoid
617118611SnjlAslCoreSubsystemError (
618118611Snjl    ACPI_PARSE_OBJECT       *Op,
619118611Snjl    ACPI_STATUS             Status,
620118611Snjl    char                    *ExtraMessage,
621118611Snjl    BOOLEAN                 Abort)
622118611Snjl{
623118611Snjl
624118611Snjl    sprintf (MsgBuffer, "%s %s", AcpiFormatException (Status), ExtraMessage);
625118611Snjl
626118611Snjl    if (Op)
627118611Snjl    {
628118611Snjl        AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Op->Asl.LineNumber,
629118611Snjl                        Op->Asl.LogicalLineNumber,
630118611Snjl                        Op->Asl.LogicalByteOffset,
631118611Snjl                        Op->Asl.Column,
632118611Snjl                        Op->Asl.Filename, MsgBuffer);
633118611Snjl    }
634118611Snjl    else
635118611Snjl    {
636118611Snjl        AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, 0,
637118611Snjl                        0, 0, 0, NULL, MsgBuffer);
638118611Snjl    }
639118611Snjl
640118611Snjl    if (Abort)
641118611Snjl    {
642118611Snjl        AslAbort ();
643118611Snjl    }
644118611Snjl}
645118611Snjl
646118611Snjl
647118611Snjl/*******************************************************************************
648118611Snjl *
649118611Snjl * FUNCTION:    AslCompilererror
650118611Snjl *
651118611Snjl * PARAMETERS:  CompilerMessage         - Error message from the parser
652118611Snjl *
653151937Sjkim * RETURN:      Status (0 for now)
654118611Snjl *
655118611Snjl * DESCRIPTION: Report an error situation discovered in a production
656151937Sjkim *              NOTE: don't change the name of this function, it is called
657151937Sjkim *              from the auto-generated parser.
658118611Snjl *
659118611Snjl ******************************************************************************/
660118611Snjl
661118611Snjlint
662118611SnjlAslCompilererror (
663118611Snjl    char                    *CompilerMessage)
664118611Snjl{
665118611Snjl
666118611Snjl    AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, Gbl_CurrentLineNumber,
667118611Snjl                    Gbl_LogicalLineNumber, Gbl_CurrentLineOffset,
668118611Snjl                    Gbl_CurrentColumn, Gbl_Files[ASL_FILE_INPUT].Filename,
669118611Snjl                    CompilerMessage);
670118611Snjl
671118611Snjl    return 0;
672118611Snjl}
673118611Snjl
674118611Snjl
675