aslerror.c revision 202771
112115Sdyson
212115Sdyson/******************************************************************************
312115Sdyson *
412115Sdyson * Module Name: aslerror - Error handling and statistics
512115Sdyson *
612115Sdyson *****************************************************************************/
712115Sdyson
812115Sdyson/******************************************************************************
912115Sdyson *
1012115Sdyson * 1. Copyright Notice
1112115Sdyson *
1212115Sdyson * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
1312115Sdyson * All rights reserved.
1412115Sdyson *
1512115Sdyson * 2. License
1612115Sdyson *
1712115Sdyson * 2.1. This is your license from Intel Corp. under its intellectual property
1812115Sdyson * rights.  You may have additional license terms from the party that provided
1912115Sdyson * you this software, covering your right to use that party's intellectual
2012115Sdyson * property rights.
2112115Sdyson *
2212115Sdyson * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2312115Sdyson * copy of the source code appearing in this file ("Covered Code") an
2412115Sdyson * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2512115Sdyson * base code distributed originally by Intel ("Original Intel Code") to copy,
2612115Sdyson * make derivatives, distribute, use and display any portion of the Covered
2712115Sdyson * Code in any form, with the right to sublicense such rights; and
2812115Sdyson *
2912115Sdyson * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3012115Sdyson * license (with the right to sublicense), under only those claims of Intel
3112115Sdyson * patents that are infringed by the Original Intel Code, to make, use, sell,
3212115Sdyson * offer to sell, and import the Covered Code and derivative works thereof
3312115Sdyson * solely to the minimum extent necessary to exercise the above copyright
3412115Sdyson * license, and in no event shall the patent license extend to any additions
3512115Sdyson * to or modifications of the Original Intel Code.  No other license or right
3612115Sdyson * is granted directly or by implication, estoppel or otherwise;
3712115Sdyson *
3812115Sdyson * The above copyright and patent license is granted only if the following
3912115Sdyson * conditions are met:
4012115Sdyson *
4112115Sdyson * 3. Conditions
4212115Sdyson *
4312115Sdyson * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4412115Sdyson * Redistribution of source code of any substantial portion of the Covered
4593016Sbde * Code or modification with rights to further distribute source must include
4612115Sdyson * the above Copyright Notice, the above License, this list of Conditions,
4712115Sdyson * and the following Disclaimer and Export Compliance provision.  In addition,
4812115Sdyson * Licensee must cause all Covered Code to which Licensee contributes to
4912159Sbde * contain a file documenting the changes Licensee made to create that Covered
5012115Sdyson * Code and the date of any change.  Licensee must include in that file the
5160041Sphk * documentation of any changes made by any predecessor Licensee.  Licensee
5212115Sdyson * must include a prominent statement that the modification is derived,
5312115Sdyson * directly or indirectly, from Original Intel Code.
5412115Sdyson *
5512115Sdyson * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5612115Sdyson * Redistribution of source code of any substantial portion of the Covered
5796753Siedowse * Code or modification without rights to further distribute source must
5812115Sdyson * include the following Disclaimer and Export Compliance provision in the
5912115Sdyson * documentation and/or other materials provided with distribution.  In
6012115Sdyson * addition, Licensee may not authorize further sublicense of source of any
6196749Siedowse * portion of the Covered Code, and must include terms to the effect that the
6296749Siedowse * license from Licensee to its licensee is limited to the intellectual
6312115Sdyson * property embodied in the software Licensee provides to its licensee, and
6412115Sdyson * not to intellectual property embodied in modifications its licensee may
6512115Sdyson * make.
6612115Sdyson *
6796753Siedowse * 3.3. Redistribution of Executable. Redistribution in executable form of any
6896753Siedowse * substantial portion of the Covered Code or modification must reproduce the
6996753Siedowse * above Copyright Notice, and the following Disclaimer and Export Compliance
7096753Siedowse * provision in the documentation and/or other materials provided with the
7196753Siedowse * distribution.
7296753Siedowse *
7396753Siedowse * 3.4. Intel retains all right, title, and interest in and to the Original
7496753Siedowse * Intel Code.
7596753Siedowse *
76111742Sdes * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7712115Sdyson * Intel shall be used in advertising or otherwise to promote the sale, use or
7812115Sdyson * other dealings in products derived from or relating to the Covered Code
7912115Sdyson * without prior written authorization from Intel.
8012115Sdyson *
8112115Sdyson * 4. Disclaimer and Export Compliance
8212115Sdyson *
8355477Sbde * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8455477Sbde * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8555477Sbde * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8655477Sbde * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8755477Sbde * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8855477Sbde * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
8955477Sbde * PARTICULAR PURPOSE.
9055477Sbde *
9155477Sbde * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9255477Sbde * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9355477Sbde * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9455477Sbde * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9555477Sbde * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9655477Sbde * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9755477Sbde * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9855477Sbde * LIMITED REMEDY.
9955477Sbde *
10055477Sbde * 4.3. Licensee shall not export, either directly or indirectly, any of this
10155477Sbde * software or system incorporating such software without first obtaining any
10255477Sbde * required license or other approval from the U. S. Department of Commerce or
10355477Sbde * any other agency or department of the United States Government.  In the
10455477Sbde * event Licensee exports any such software from the United States or
10555477Sbde * re-exports any such software from a foreign destination, Licensee shall
10655477Sbde * ensure that the distribution and export/re-export of the software is in
10755477Sbde * compliance with all laws, regulations, orders, or other restrictions of the
10855477Sbde * U.S. Export Administration Regulations. Licensee agrees that neither it nor
10955477Sbde * any of its subsidiaries will export/re-export any technical data, process,
11055477Sbde * software, or service, directly or indirectly, to any country for which the
11155477Sbde * United States government or any agency thereof requires an export license,
11255477Sbde * other governmental approval, or letter of assurance, without first obtaining
11355477Sbde * such license, approval or letter.
11455477Sbde *
11555477Sbde *****************************************************************************/
11655477Sbde
11755477Sbde#define ASL_EXCEPTIONS
11893014Sbde#include <contrib/dev/acpica/compiler/aslcompiler.h>
11993014Sbde
12012159Sbde#define _COMPONENT          ACPI_COMPILER
12112115Sdyson        ACPI_MODULE_NAME    ("aslerror")
12212115Sdyson
12312115Sdyson/* Local prototypes */
12412115Sdyson
12512115Sdysonstatic void
12612115SdysonAeAddToErrorLog (
12712115Sdyson    ASL_ERROR_MSG           *Enode);
12812115Sdyson
12912115Sdyson
13012115Sdysonvoid
13112115SdysonAeClearErrorLog (
13212115Sdyson    void)
13312115Sdyson{
134111742Sdes    ASL_ERROR_MSG           *Enode = Gbl_ErrorLog;
13512115Sdyson    ASL_ERROR_MSG           *Next;
13612115Sdyson
13712115Sdyson    /* Walk the error node list */
13812115Sdyson
13912115Sdyson    while (Enode)
14012115Sdyson    {
141111742Sdes        Next = Enode->Next;
142111742Sdes        ACPI_FREE (Enode);
143111742Sdes        Enode = Next;
144111742Sdes    }
145111742Sdes
14612115Sdyson    Gbl_ErrorLog = NULL;
147111742Sdes}
148111742Sdes
14912115Sdyson
15055477Sbde/*******************************************************************************
15124649Sdfr *
15212115Sdyson * FUNCTION:    AeAddToErrorLog
15312115Sdyson *
15412115Sdyson * PARAMETERS:  Enode       - An error node to add to the log
15512115Sdyson *
15665780Sbde * RETURN:      None
15712115Sdyson *
15865780Sbde * DESCRIPTION: Add a new error node to the error log.  The error log is
15912115Sdyson *              ordered by the "logical" line number (cumulative line number
16065780Sbde *              including all include files.)
16165780Sbde *
16265780Sbde ******************************************************************************/
16365780Sbde
16465780Sbdestatic void
16565780SbdeAeAddToErrorLog (
16665780Sbde    ASL_ERROR_MSG           *Enode)
16765780Sbde{
16865780Sbde    ASL_ERROR_MSG           *Next;
16965780Sbde    ASL_ERROR_MSG           *Prev;
17065780Sbde
17165780Sbde
17212115Sdyson    /* If Gbl_ErrorLog is null, this is the first error node */
17365780Sbde
174111742Sdes    if (!Gbl_ErrorLog)
17565780Sbde    {
17612115Sdyson        Gbl_ErrorLog = Enode;
17712115Sdyson        return;
17812115Sdyson    }
17912115Sdyson
18012115Sdyson    /*
18165780Sbde     * Walk error list until we find a line number greater than ours.
18212115Sdyson     * List is sorted according to line number.
18312115Sdyson     */
184111119Simp    Prev = NULL;
18512115Sdyson    Next = Gbl_ErrorLog;
18612115Sdyson
18712115Sdyson    while ((Next) &&
18812115Sdyson           (Next->LogicalLineNumber <= Enode->LogicalLineNumber))
18955477Sbde    {
19024649Sdfr        Prev = Next;
19155477Sbde        Next = Next->Next;
192111742Sdes    }
19355477Sbde
19455477Sbde    /* Found our place in the list */
19555477Sbde
19655477Sbde    Enode->Next = Next;
19755477Sbde
19855477Sbde    if (Prev)
199125843Sbde    {
20055477Sbde        Prev->Next = Enode;
20155477Sbde    }
20255477Sbde    else
203125843Sbde    {
204125843Sbde        Gbl_ErrorLog = Enode;
20555477Sbde    }
20655477Sbde}
207125843Sbde
20855477Sbde
20955477Sbde/*******************************************************************************
21055477Sbde *
21155477Sbde * FUNCTION:    AePrintException
21255477Sbde *
21355477Sbde * PARAMETERS:  FileId          - ID of output file
21455477Sbde *              Enode           - Error node to print
21555477Sbde *              Header          - Additional text before each message
21655477Sbde *
21755477Sbde * RETURN:      None
21855477Sbde *
21912115Sdyson * DESCRIPTION: Print the contents of an error node.
22012115Sdyson *
22112115Sdyson * NOTE:        We don't use the FlxxxFile I/O functions here because on error
22255477Sbde *              they abort the compiler and call this function!  Since we
223111742Sdes *              are reporting errors here, we ignore most output errors and
224111742Sdes *              just try to get out as much as we can.
225111741Sdes *
22624649Sdfr ******************************************************************************/
22724649Sdfr
22812115Sdysonvoid
22912115SdysonAePrintException (
23012115Sdyson    UINT32                  FileId,
23112115Sdyson    ASL_ERROR_MSG           *Enode,
23212115Sdyson    char                    *Header)
23312115Sdyson{
23412115Sdyson    UINT8                   SourceByte;
23512115Sdyson    int                     Actual;
23612115Sdyson    size_t                  RActual;
23724649Sdfr    UINT32                  MsgLength;
23824649Sdfr    char                    *MainMessage;
23965780Sbde    char                    *ExtraMessage;
24024649Sdfr    UINT32                  SourceColumn;
24124649Sdfr    UINT32                  ErrorColumn;
24224649Sdfr    FILE                    *OutputFile;
243125843Sbde    FILE                    *SourceFile;
24424649Sdfr
245111119Simp
24624649Sdfr    if (Gbl_NoErrors)
24765780Sbde    {
24865780Sbde        return;
24965780Sbde    }
25055477Sbde
25124649Sdfr    /*
25224649Sdfr     * Only listing files have a header, and remarks/optimizations
25324649Sdfr     * are always output
25424649Sdfr     */
25524649Sdfr    if (!Header)
25624649Sdfr    {
25712115Sdyson        /* Ignore remarks if requested */
25812115Sdyson
25924649Sdfr        switch (Enode->Level)
26024649Sdfr        {
261111742Sdes        case ASL_REMARK:
26212115Sdyson            if (!Gbl_DisplayRemarks)
26312115Sdyson            {
26412115Sdyson                return;
26512115Sdyson            }
26612115Sdyson            break;
26712115Sdyson
26812115Sdyson        case ASL_OPTIMIZATION:
26912115Sdyson            if (!Gbl_DisplayOptimizations)
27012115Sdyson            {
27112115Sdyson                return;
27212115Sdyson            }
27312115Sdyson            break;
27412115Sdyson
27512115Sdyson        default:
27612115Sdyson            break;
27712115Sdyson        }
27812115Sdyson    }
27912115Sdyson
28012115Sdyson    /* Get the file handles */
281125843Sbde
28212115Sdyson    OutputFile = Gbl_Files[FileId].Handle;
28312115Sdyson    SourceFile = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
28412115Sdyson
28512115Sdyson    if (Header)
28612115Sdyson    {
28712115Sdyson        fprintf (OutputFile, "%s", Header);
28812115Sdyson    }
28912115Sdyson
29012115Sdyson    /* Print filename and line number if present and valid */
29112115Sdyson
29212115Sdyson    if (Enode->Filename)
29312115Sdyson    {
29412115Sdyson        if (Gbl_VerboseErrors)
29512115Sdyson        {
29628787Sphk            fprintf (OutputFile, "%6s", Enode->Filename);
29712115Sdyson
29812115Sdyson            if (Enode->LineNumber)
29912115Sdyson            {
30012115Sdyson                fprintf (OutputFile, "%6u: ", Enode->LineNumber);
30112115Sdyson
30296752Siedowse                /*
30396752Siedowse                 * Seek to the offset in the combined source file, read the source
30412115Sdyson                 * line, and write it to the output.
30596752Siedowse                 */
30612115Sdyson                Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset,
30712115Sdyson                            (int) SEEK_SET);
30812115Sdyson                if (Actual)
30912115Sdyson                {
31012115Sdyson                    fprintf (OutputFile,
31112115Sdyson                        "[*** iASL: Seek error on source code temp file %s ***]",
31212115Sdyson                        Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
31312115Sdyson                }
31412115Sdyson                else
31512115Sdyson                {
31612115Sdyson                    RActual = fread (&SourceByte, 1, 1, SourceFile);
31712115Sdyson                    if (!RActual)
31812115Sdyson                    {
31912115Sdyson                        fprintf (OutputFile,
32012115Sdyson                            "[*** iASL: Read error on source code temp file %s ***]",
32112115Sdyson                            Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
32212115Sdyson                    }
32312115Sdyson
32412115Sdyson                    else while (RActual && SourceByte && (SourceByte != '\n'))
32512115Sdyson                    {
32612115Sdyson                        fwrite (&SourceByte, 1, 1, OutputFile);
32783366Sjulian                        RActual = fread (&SourceByte, 1, 1, SourceFile);
32812115Sdyson                    }
32912115Sdyson                }
33012115Sdyson                fprintf (OutputFile, "\n");
33112115Sdyson            }
33212115Sdyson        }
33312115Sdyson        else
33412115Sdyson        {
33512115Sdyson            fprintf (OutputFile, "%s", Enode->Filename);
33612115Sdyson
33712115Sdyson            if (Enode->LineNumber)
33812115Sdyson            {
33912115Sdyson                fprintf (OutputFile, "(%u) : ", Enode->LineNumber);
34012115Sdyson            }
34112115Sdyson        }
34212115Sdyson    }
34312115Sdyson
34412115Sdyson    /* NULL message ID, just print the raw message */
34512115Sdyson
34612115Sdyson    if (Enode->MessageId == 0)
34712115Sdyson    {
34812115Sdyson        fprintf (OutputFile, "%s\n", Enode->Message);
34912115Sdyson    }
35012115Sdyson    else
35112115Sdyson    {
35212115Sdyson        /* Decode the message ID */
35312115Sdyson
354111742Sdes        fprintf (OutputFile, "%s %4.4d -",
35512115Sdyson                    AslErrorLevel[Enode->Level],
35612115Sdyson                    Enode->MessageId + ((Enode->Level+1) * 1000));
35712115Sdyson
35812115Sdyson        MainMessage = AslMessages[Enode->MessageId];
35912115Sdyson        ExtraMessage = Enode->Message;
36012115Sdyson
36112115Sdyson        if (Enode->LineNumber)
36212115Sdyson        {
36312115Sdyson            MsgLength = strlen (MainMessage);
36412115Sdyson            if (MsgLength == 0)
36512115Sdyson            {
36612115Sdyson                MainMessage = Enode->Message;
36712115Sdyson
36812115Sdyson                MsgLength = strlen (MainMessage);
36912115Sdyson                ExtraMessage = NULL;
37012115Sdyson            }
37196749Siedowse
37212115Sdyson            if (Gbl_VerboseErrors)
37312115Sdyson            {
37412115Sdyson                SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2;
37512115Sdyson                ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1;
37612115Sdyson
37712115Sdyson                if ((MsgLength + ErrorColumn) < (SourceColumn - 1))
37812115Sdyson                {
37912115Sdyson                    fprintf (OutputFile, "%*s%s",
38096749Siedowse                        (int) ((SourceColumn - 1) - ErrorColumn),
38196749Siedowse                        MainMessage, " ^ ");
38212115Sdyson                }
38312115Sdyson                else
38412115Sdyson                {
38512115Sdyson                    fprintf (OutputFile, "%*s %s",
38612115Sdyson                        (int) ((SourceColumn - ErrorColumn) + 1), "^",
38712115Sdyson                        MainMessage);
38812115Sdyson                }
38912115Sdyson            }
39012115Sdyson            else
39112115Sdyson            {
39212115Sdyson                fprintf (OutputFile, " %s", MainMessage);
39312115Sdyson            }
39412115Sdyson
39512115Sdyson            /* Print the extra info message if present */
39612115Sdyson
39712115Sdyson            if (ExtraMessage)
39843301Sdillon            {
39996749Siedowse                fprintf (OutputFile, " (%s)", ExtraMessage);
40096749Siedowse            }
40112115Sdyson
40212115Sdyson            fprintf (OutputFile, "\n");
40312115Sdyson            if (Gbl_VerboseErrors)
40412115Sdyson            {
40512115Sdyson                fprintf (OutputFile, "\n");
40612115Sdyson            }
40712115Sdyson        }
40812115Sdyson        else
40912115Sdyson        {
41012115Sdyson            fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage);
41112115Sdyson        }
41212115Sdyson    }
41312115Sdyson}
41412115Sdyson
41512115Sdyson
41612115Sdyson/*******************************************************************************
41796753Siedowse *
41896753Siedowse * FUNCTION:    AePrintErrorLog
41912115Sdyson *
42055477Sbde * PARAMETERS:  FileId           - Where to output the error log
42112115Sdyson *
42212115Sdyson * RETURN:      None
42312147Sdyson *
42412115Sdyson * DESCRIPTION: Print the entire contents of the error log
42596749Siedowse *
42612115Sdyson ******************************************************************************/
42712115Sdyson
42812115Sdysonvoid
42912115SdysonAePrintErrorLog (
43012115Sdyson    UINT32                  FileId)
43112115Sdyson{
43212115Sdyson    ASL_ERROR_MSG           *Enode = Gbl_ErrorLog;
43312115Sdyson
43412115Sdyson
43512115Sdyson    /* Walk the error node list */
43612115Sdyson
43712115Sdyson    while (Enode)
43812115Sdyson    {
43912115Sdyson        AePrintException (FileId, Enode, NULL);
44012115Sdyson        Enode = Enode->Next;
44112115Sdyson    }
44212115Sdyson}
44312115Sdyson
44412115Sdyson
44512115Sdyson/*******************************************************************************
44612115Sdyson *
44712115Sdyson * FUNCTION:    AslCommonError
44812115Sdyson *
44912115Sdyson * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
45012115Sdyson *              MessageId           - Index into global message buffer
45112115Sdyson *              CurrentLineNumber   - Actual file line number
45212115Sdyson *              LogicalLineNumber   - Cumulative line number
45312115Sdyson *              LogicalByteOffset   - Byte offset in source file
45412115Sdyson *              Column              - Column in current line
45512115Sdyson *              Filename            - source filename
45612115Sdyson *              ExtraMessage        - additional error message
45712115Sdyson *
45812115Sdyson * RETURN:      None
45912115Sdyson *
46012115Sdyson * DESCRIPTION: Create a new error node and add it to the error log
46112115Sdyson *
46212115Sdyson ******************************************************************************/
46312115Sdyson
46412115Sdysonvoid
46512115SdysonAslCommonError (
46612115Sdyson    UINT8                   Level,
46712115Sdyson    UINT8                   MessageId,
46812115Sdyson    UINT32                  CurrentLineNumber,
46912115Sdyson    UINT32                  LogicalLineNumber,
47012115Sdyson    UINT32                  LogicalByteOffset,
47112115Sdyson    UINT32                  Column,
47212115Sdyson    char                    *Filename,
47312115Sdyson    char                    *ExtraMessage)
47412115Sdyson{
47512115Sdyson    UINT32                  MessageSize;
47612115Sdyson    char                    *MessageBuffer = NULL;
47712115Sdyson    ASL_ERROR_MSG           *Enode;
47812115Sdyson
47912115Sdyson
48012115Sdyson    Enode = UtLocalCalloc (sizeof (ASL_ERROR_MSG));
48112115Sdyson
48212115Sdyson    if (ExtraMessage)
48312115Sdyson    {
48412115Sdyson        /* Allocate a buffer for the message and a new error node */
48512115Sdyson
48612115Sdyson        MessageSize   = strlen (ExtraMessage) + 1;
48712115Sdyson        MessageBuffer = UtLocalCalloc (MessageSize);
48812115Sdyson
48912115Sdyson        /* Keep a copy of the extra message */
49012115Sdyson
49112115Sdyson        ACPI_STRCPY (MessageBuffer, ExtraMessage);
49212115Sdyson    }
49312115Sdyson
49412115Sdyson    /* Initialize the error node */
49512115Sdyson
49612115Sdyson    if (Filename)
49712115Sdyson    {
49812115Sdyson        Enode->Filename       = Filename;
49912115Sdyson        Enode->FilenameLength = strlen (Filename);
50012115Sdyson        if (Enode->FilenameLength < 6)
50112115Sdyson        {
50212115Sdyson            Enode->FilenameLength = 6;
50312115Sdyson        }
50412115Sdyson    }
50512115Sdyson
50612115Sdyson    Enode->MessageId            = MessageId;
50712115Sdyson    Enode->Level                = Level;
50812115Sdyson    Enode->LineNumber           = CurrentLineNumber;
50983366Sjulian    Enode->LogicalLineNumber    = LogicalLineNumber;
51012115Sdyson    Enode->LogicalByteOffset    = LogicalByteOffset;
51112115Sdyson    Enode->Column               = Column;
51212115Sdyson    Enode->Message              = MessageBuffer;
51312115Sdyson
51412115Sdyson    /* Add the new node to the error node list */
51512115Sdyson
51612115Sdyson    AeAddToErrorLog (Enode);
51712115Sdyson
51812115Sdyson    if (Gbl_DebugFlag)
51912115Sdyson    {
52012115Sdyson        /* stderr is a file, send error to it immediately */
52112115Sdyson
52212115Sdyson        AePrintException (ASL_FILE_STDERR, Enode, NULL);
52312115Sdyson    }
52412115Sdyson
52512115Sdyson    Gbl_ExceptionCount[Level]++;
52612115Sdyson    if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
52712115Sdyson    {
52812115Sdyson        printf ("\nMaximum error count (%d) exceeded\n", ASL_MAX_ERROR_COUNT);
52912115Sdyson
53012115Sdyson        Gbl_SourceLine = 0;
53112115Sdyson        Gbl_NextError = Gbl_ErrorLog;
53212115Sdyson        CmDoOutputFiles ();
53312115Sdyson        CmCleanupAndExit ();
53412115Sdyson        exit(1);
53512115Sdyson    }
53612115Sdyson
53712115Sdyson    return;
53812115Sdyson}
53912115Sdyson
54012115Sdyson
54112115Sdyson/*******************************************************************************
54212115Sdyson *
54312115Sdyson * FUNCTION:    AslError
54412115Sdyson *
54512115Sdyson * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
54612115Sdyson *              MessageId           - Index into global message buffer
54783366Sjulian *              Op                  - Parse node where error happened
54812115Sdyson *              ExtraMessage        - additional error message
54912115Sdyson *
55012115Sdyson * RETURN:      None
55112115Sdyson *
55212115Sdyson * DESCRIPTION: Main error reporting routine for the ASL compiler (all code
55312115Sdyson *              except the parser.)
55412115Sdyson *
55512115Sdyson ******************************************************************************/
55612115Sdyson
55712115Sdysonvoid
55812115SdysonAslError (
55912115Sdyson    UINT8                   Level,
56012115Sdyson    UINT8                   MessageId,
56112115Sdyson    ACPI_PARSE_OBJECT       *Op,
56212115Sdyson    char                    *ExtraMessage)
56312115Sdyson{
56412115Sdyson
56512115Sdyson    switch (Level)
56696749Siedowse    {
56712115Sdyson    case ASL_WARNING2:
56812115Sdyson    case ASL_WARNING3:
56912115Sdyson        if (Gbl_WarningLevel < Level)
570105420Sbde        {
57112115Sdyson            return;
57212115Sdyson        }
57312115Sdyson        break;
57412115Sdyson
57512115Sdyson    default:
57612115Sdyson        break;
57712115Sdyson    }
57812115Sdyson
57912115Sdyson
58012115Sdyson    if (Op)
58112115Sdyson    {
58212115Sdyson        AslCommonError (Level, MessageId, Op->Asl.LineNumber,
58312115Sdyson                        Op->Asl.LogicalLineNumber,
58412115Sdyson                        Op->Asl.LogicalByteOffset,
58512115Sdyson                        Op->Asl.Column,
58612115Sdyson                        Op->Asl.Filename, ExtraMessage);
58712115Sdyson    }
58812115Sdyson    else
58912115Sdyson    {
59012115Sdyson        AslCommonError (Level, MessageId, 0,
59183366Sjulian                        0, 0, 0, NULL, ExtraMessage);
59212115Sdyson    }
59312115Sdyson}
59412115Sdyson
59512115Sdyson
59612115Sdyson/*******************************************************************************
59712115Sdyson *
59812115Sdyson * FUNCTION:    AslCoreSubsystemError
59912115Sdyson *
60012115Sdyson * PARAMETERS:  Op                  - Parse node where error happened
60112115Sdyson *              Status              - The ACPI CA Exception
60212115Sdyson *              ExtraMessage        - additional error message
60312115Sdyson *              Abort               - TRUE -> Abort compilation
60412115Sdyson *
60512115Sdyson * RETURN:      None
60612115Sdyson *
60712115Sdyson * DESCRIPTION: Error reporting routine for exceptions returned by the ACPI
60892462Smckusick *              CA core subsystem.
60992462Smckusick *
61012115Sdyson ******************************************************************************/
61112115Sdyson
61212115Sdysonvoid
61312115SdysonAslCoreSubsystemError (
61412115Sdyson    ACPI_PARSE_OBJECT       *Op,
61512115Sdyson    ACPI_STATUS             Status,
61612115Sdyson    char                    *ExtraMessage,
61712115Sdyson    BOOLEAN                 Abort)
61812115Sdyson{
61912115Sdyson
62012115Sdyson    sprintf (MsgBuffer, "%s %s", AcpiFormatException (Status), ExtraMessage);
62112115Sdyson
62212115Sdyson    if (Op)
62312115Sdyson    {
62412115Sdyson        AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Op->Asl.LineNumber,
62512115Sdyson                        Op->Asl.LogicalLineNumber,
62683366Sjulian                        Op->Asl.LogicalByteOffset,
62712115Sdyson                        Op->Asl.Column,
62812115Sdyson                        Op->Asl.Filename, MsgBuffer);
62912115Sdyson    }
63012115Sdyson    else
63112115Sdyson    {
63212115Sdyson        AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, 0,
63312115Sdyson                        0, 0, 0, NULL, MsgBuffer);
63412115Sdyson    }
63512115Sdyson
63612115Sdyson    if (Abort)
63712115Sdyson    {
63883366Sjulian        AslAbort ();
63912115Sdyson    }
64012115Sdyson}
64112115Sdyson
64212115Sdyson
64312115Sdyson/*******************************************************************************
64412115Sdyson *
64512115Sdyson * FUNCTION:    AslCompilererror
64692462Smckusick *
64792462Smckusick * PARAMETERS:  CompilerMessage         - Error message from the parser
64812115Sdyson *
64912115Sdyson * RETURN:      Status (0 for now)
65012115Sdyson *
65112115Sdyson * DESCRIPTION: Report an error situation discovered in a production
65283366Sjulian *              NOTE: don't change the name of this function, it is called
65312115Sdyson *              from the auto-generated parser.
65412115Sdyson *
65512115Sdyson ******************************************************************************/
65612115Sdyson
65712115Sdysonint
65812115SdysonAslCompilererror (
65912115Sdyson    char                    *CompilerMessage)
66012115Sdyson{
66112115Sdyson
66212115Sdyson    AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, Gbl_CurrentLineNumber,
66312115Sdyson                    Gbl_LogicalLineNumber, Gbl_CurrentLineOffset,
66412115Sdyson                    Gbl_CurrentColumn, Gbl_Files[ASL_FILE_INPUT].Filename,
66512115Sdyson                    CompilerMessage);
66612115Sdyson
66712115Sdyson    return 0;
66812115Sdyson}
66912115Sdyson
67012115Sdyson
67112115Sdyson