Home | History | Annotate | Line # | Download | only in compiler
aslerror.c revision 1.1.1.2
      1      1.1  jruoho 
      2      1.1  jruoho /******************************************************************************
      3      1.1  jruoho  *
      4      1.1  jruoho  * Module Name: aslerror - Error handling and statistics
      5      1.1  jruoho  *
      6      1.1  jruoho  *****************************************************************************/
      7      1.1  jruoho 
      8  1.1.1.2  jruoho /*
      9  1.1.1.2  jruoho  * Copyright (C) 2000 - 2011, Intel Corp.
     10      1.1  jruoho  * All rights reserved.
     11      1.1  jruoho  *
     12  1.1.1.2  jruoho  * Redistribution and use in source and binary forms, with or without
     13  1.1.1.2  jruoho  * modification, are permitted provided that the following conditions
     14  1.1.1.2  jruoho  * are met:
     15  1.1.1.2  jruoho  * 1. Redistributions of source code must retain the above copyright
     16  1.1.1.2  jruoho  *    notice, this list of conditions, and the following disclaimer,
     17  1.1.1.2  jruoho  *    without modification.
     18  1.1.1.2  jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     19  1.1.1.2  jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     20  1.1.1.2  jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     21  1.1.1.2  jruoho  *    including a substantially similar Disclaimer requirement for further
     22  1.1.1.2  jruoho  *    binary redistribution.
     23  1.1.1.2  jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     24  1.1.1.2  jruoho  *    of any contributors may be used to endorse or promote products derived
     25  1.1.1.2  jruoho  *    from this software without specific prior written permission.
     26  1.1.1.2  jruoho  *
     27  1.1.1.2  jruoho  * Alternatively, this software may be distributed under the terms of the
     28  1.1.1.2  jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     29  1.1.1.2  jruoho  * Software Foundation.
     30  1.1.1.2  jruoho  *
     31  1.1.1.2  jruoho  * NO WARRANTY
     32  1.1.1.2  jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     33  1.1.1.2  jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     34  1.1.1.2  jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     35  1.1.1.2  jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     36  1.1.1.2  jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     37  1.1.1.2  jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     38  1.1.1.2  jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     39  1.1.1.2  jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     40  1.1.1.2  jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     41  1.1.1.2  jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     42  1.1.1.2  jruoho  * POSSIBILITY OF SUCH DAMAGES.
     43  1.1.1.2  jruoho  */
     44      1.1  jruoho 
     45      1.1  jruoho #define ASL_EXCEPTIONS
     46      1.1  jruoho #include "aslcompiler.h"
     47      1.1  jruoho 
     48      1.1  jruoho #define _COMPONENT          ACPI_COMPILER
     49      1.1  jruoho         ACPI_MODULE_NAME    ("aslerror")
     50      1.1  jruoho 
     51      1.1  jruoho /* Local prototypes */
     52      1.1  jruoho 
     53      1.1  jruoho static void
     54      1.1  jruoho AeAddToErrorLog (
     55      1.1  jruoho     ASL_ERROR_MSG           *Enode);
     56      1.1  jruoho 
     57      1.1  jruoho 
     58      1.1  jruoho void
     59      1.1  jruoho AeClearErrorLog (
     60      1.1  jruoho     void)
     61      1.1  jruoho {
     62      1.1  jruoho     ASL_ERROR_MSG           *Enode = Gbl_ErrorLog;
     63      1.1  jruoho     ASL_ERROR_MSG           *Next;
     64      1.1  jruoho 
     65      1.1  jruoho     /* Walk the error node list */
     66      1.1  jruoho 
     67      1.1  jruoho     while (Enode)
     68      1.1  jruoho     {
     69      1.1  jruoho         Next = Enode->Next;
     70      1.1  jruoho         ACPI_FREE (Enode);
     71      1.1  jruoho         Enode = Next;
     72      1.1  jruoho     }
     73      1.1  jruoho 
     74      1.1  jruoho     Gbl_ErrorLog = NULL;
     75      1.1  jruoho }
     76      1.1  jruoho 
     77      1.1  jruoho 
     78      1.1  jruoho /*******************************************************************************
     79      1.1  jruoho  *
     80      1.1  jruoho  * FUNCTION:    AeAddToErrorLog
     81      1.1  jruoho  *
     82      1.1  jruoho  * PARAMETERS:  Enode       - An error node to add to the log
     83      1.1  jruoho  *
     84      1.1  jruoho  * RETURN:      None
     85      1.1  jruoho  *
     86      1.1  jruoho  * DESCRIPTION: Add a new error node to the error log.  The error log is
     87      1.1  jruoho  *              ordered by the "logical" line number (cumulative line number
     88      1.1  jruoho  *              including all include files.)
     89      1.1  jruoho  *
     90      1.1  jruoho  ******************************************************************************/
     91      1.1  jruoho 
     92      1.1  jruoho static void
     93      1.1  jruoho AeAddToErrorLog (
     94      1.1  jruoho     ASL_ERROR_MSG           *Enode)
     95      1.1  jruoho {
     96      1.1  jruoho     ASL_ERROR_MSG           *Next;
     97      1.1  jruoho     ASL_ERROR_MSG           *Prev;
     98      1.1  jruoho 
     99      1.1  jruoho 
    100      1.1  jruoho     /* If Gbl_ErrorLog is null, this is the first error node */
    101      1.1  jruoho 
    102      1.1  jruoho     if (!Gbl_ErrorLog)
    103      1.1  jruoho     {
    104      1.1  jruoho         Gbl_ErrorLog = Enode;
    105      1.1  jruoho         return;
    106      1.1  jruoho     }
    107      1.1  jruoho 
    108      1.1  jruoho     /*
    109      1.1  jruoho      * Walk error list until we find a line number greater than ours.
    110      1.1  jruoho      * List is sorted according to line number.
    111      1.1  jruoho      */
    112      1.1  jruoho     Prev = NULL;
    113      1.1  jruoho     Next = Gbl_ErrorLog;
    114      1.1  jruoho 
    115      1.1  jruoho     while ((Next) &&
    116      1.1  jruoho            (Next->LogicalLineNumber <= Enode->LogicalLineNumber))
    117      1.1  jruoho     {
    118      1.1  jruoho         Prev = Next;
    119      1.1  jruoho         Next = Next->Next;
    120      1.1  jruoho     }
    121      1.1  jruoho 
    122      1.1  jruoho     /* Found our place in the list */
    123      1.1  jruoho 
    124      1.1  jruoho     Enode->Next = Next;
    125      1.1  jruoho 
    126      1.1  jruoho     if (Prev)
    127      1.1  jruoho     {
    128      1.1  jruoho         Prev->Next = Enode;
    129      1.1  jruoho     }
    130      1.1  jruoho     else
    131      1.1  jruoho     {
    132      1.1  jruoho         Gbl_ErrorLog = Enode;
    133      1.1  jruoho     }
    134      1.1  jruoho }
    135      1.1  jruoho 
    136      1.1  jruoho 
    137      1.1  jruoho /*******************************************************************************
    138      1.1  jruoho  *
    139      1.1  jruoho  * FUNCTION:    AePrintException
    140      1.1  jruoho  *
    141      1.1  jruoho  * PARAMETERS:  FileId          - ID of output file
    142      1.1  jruoho  *              Enode           - Error node to print
    143      1.1  jruoho  *              Header          - Additional text before each message
    144      1.1  jruoho  *
    145      1.1  jruoho  * RETURN:      None
    146      1.1  jruoho  *
    147      1.1  jruoho  * DESCRIPTION: Print the contents of an error node.
    148      1.1  jruoho  *
    149      1.1  jruoho  * NOTE:        We don't use the FlxxxFile I/O functions here because on error
    150      1.1  jruoho  *              they abort the compiler and call this function!  Since we
    151      1.1  jruoho  *              are reporting errors here, we ignore most output errors and
    152      1.1  jruoho  *              just try to get out as much as we can.
    153      1.1  jruoho  *
    154      1.1  jruoho  ******************************************************************************/
    155      1.1  jruoho 
    156      1.1  jruoho void
    157      1.1  jruoho AePrintException (
    158      1.1  jruoho     UINT32                  FileId,
    159      1.1  jruoho     ASL_ERROR_MSG           *Enode,
    160      1.1  jruoho     char                    *Header)
    161      1.1  jruoho {
    162      1.1  jruoho     UINT8                   SourceByte;
    163      1.1  jruoho     int                     Actual;
    164      1.1  jruoho     size_t                  RActual;
    165      1.1  jruoho     UINT32                  MsgLength;
    166      1.1  jruoho     char                    *MainMessage;
    167      1.1  jruoho     char                    *ExtraMessage;
    168      1.1  jruoho     UINT32                  SourceColumn;
    169      1.1  jruoho     UINT32                  ErrorColumn;
    170      1.1  jruoho     FILE                    *OutputFile;
    171      1.1  jruoho     FILE                    *SourceFile;
    172  1.1.1.2  jruoho     long                    FileSize;
    173  1.1.1.2  jruoho     BOOLEAN                 PrematureEOF = FALSE;
    174      1.1  jruoho 
    175      1.1  jruoho 
    176      1.1  jruoho     if (Gbl_NoErrors)
    177      1.1  jruoho     {
    178      1.1  jruoho         return;
    179      1.1  jruoho     }
    180      1.1  jruoho 
    181      1.1  jruoho     /*
    182      1.1  jruoho      * Only listing files have a header, and remarks/optimizations
    183      1.1  jruoho      * are always output
    184      1.1  jruoho      */
    185      1.1  jruoho     if (!Header)
    186      1.1  jruoho     {
    187      1.1  jruoho         /* Ignore remarks if requested */
    188      1.1  jruoho 
    189      1.1  jruoho         switch (Enode->Level)
    190      1.1  jruoho         {
    191      1.1  jruoho         case ASL_REMARK:
    192      1.1  jruoho             if (!Gbl_DisplayRemarks)
    193      1.1  jruoho             {
    194      1.1  jruoho                 return;
    195      1.1  jruoho             }
    196      1.1  jruoho             break;
    197      1.1  jruoho 
    198      1.1  jruoho         case ASL_OPTIMIZATION:
    199      1.1  jruoho             if (!Gbl_DisplayOptimizations)
    200      1.1  jruoho             {
    201      1.1  jruoho                 return;
    202      1.1  jruoho             }
    203      1.1  jruoho             break;
    204      1.1  jruoho 
    205      1.1  jruoho         default:
    206      1.1  jruoho             break;
    207      1.1  jruoho         }
    208      1.1  jruoho     }
    209      1.1  jruoho 
    210      1.1  jruoho     /* Get the file handles */
    211      1.1  jruoho 
    212      1.1  jruoho     OutputFile = Gbl_Files[FileId].Handle;
    213  1.1.1.2  jruoho 
    214  1.1.1.2  jruoho     /* Use the merged header/source file if present, otherwise use input file */
    215  1.1.1.2  jruoho 
    216      1.1  jruoho     SourceFile = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
    217  1.1.1.2  jruoho     if (!SourceFile)
    218  1.1.1.2  jruoho     {
    219  1.1.1.2  jruoho         SourceFile = Gbl_Files[ASL_FILE_INPUT].Handle;
    220  1.1.1.2  jruoho     }
    221  1.1.1.2  jruoho 
    222  1.1.1.2  jruoho     if (SourceFile)
    223  1.1.1.2  jruoho     {
    224  1.1.1.2  jruoho         /* Determine if the error occurred at source file EOF */
    225  1.1.1.2  jruoho 
    226  1.1.1.2  jruoho         fseek (SourceFile, 0, SEEK_END);
    227  1.1.1.2  jruoho         FileSize = ftell (SourceFile);
    228  1.1.1.2  jruoho 
    229  1.1.1.2  jruoho         if ((long) Enode->LogicalByteOffset >= FileSize)
    230  1.1.1.2  jruoho         {
    231  1.1.1.2  jruoho             PrematureEOF = TRUE;
    232  1.1.1.2  jruoho         }
    233  1.1.1.2  jruoho     }
    234      1.1  jruoho 
    235      1.1  jruoho     if (Header)
    236      1.1  jruoho     {
    237      1.1  jruoho         fprintf (OutputFile, "%s", Header);
    238      1.1  jruoho     }
    239      1.1  jruoho 
    240      1.1  jruoho     /* Print filename and line number if present and valid */
    241      1.1  jruoho 
    242      1.1  jruoho     if (Enode->Filename)
    243      1.1  jruoho     {
    244      1.1  jruoho         if (Gbl_VerboseErrors)
    245      1.1  jruoho         {
    246      1.1  jruoho             fprintf (OutputFile, "%6s", Enode->Filename);
    247      1.1  jruoho 
    248      1.1  jruoho             if (Enode->LineNumber)
    249      1.1  jruoho             {
    250  1.1.1.2  jruoho                 fprintf (OutputFile, " %6u: ", Enode->LineNumber);
    251      1.1  jruoho 
    252      1.1  jruoho                 /*
    253  1.1.1.2  jruoho                  * If not at EOF, get the corresponding source code line and
    254  1.1.1.2  jruoho                  * display it. Don't attempt this if we have a premature EOF
    255  1.1.1.2  jruoho                  * condition.
    256      1.1  jruoho                  */
    257  1.1.1.2  jruoho                 if (!PrematureEOF)
    258      1.1  jruoho                 {
    259  1.1.1.2  jruoho                     /*
    260  1.1.1.2  jruoho                      * Seek to the offset in the combined source file, read
    261  1.1.1.2  jruoho                      * the source line, and write it to the output.
    262  1.1.1.2  jruoho                      */
    263  1.1.1.2  jruoho                     Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset,
    264  1.1.1.2  jruoho                                 (int) SEEK_SET);
    265  1.1.1.2  jruoho                     if (Actual)
    266      1.1  jruoho                     {
    267      1.1  jruoho                         fprintf (OutputFile,
    268  1.1.1.2  jruoho                             "[*** iASL: Seek error on source code temp file %s ***]",
    269      1.1  jruoho                             Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
    270      1.1  jruoho                     }
    271  1.1.1.2  jruoho                     else
    272      1.1  jruoho                     {
    273      1.1  jruoho                         RActual = fread (&SourceByte, 1, 1, SourceFile);
    274  1.1.1.2  jruoho                         if (!RActual)
    275  1.1.1.2  jruoho                         {
    276  1.1.1.2  jruoho                             fprintf (OutputFile,
    277  1.1.1.2  jruoho                                 "[*** iASL: Read error on source code temp file %s ***]",
    278  1.1.1.2  jruoho                                 Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
    279  1.1.1.2  jruoho                         }
    280  1.1.1.2  jruoho 
    281  1.1.1.2  jruoho                         else while (RActual && SourceByte && (SourceByte != '\n'))
    282  1.1.1.2  jruoho                         {
    283  1.1.1.2  jruoho                             fwrite (&SourceByte, 1, 1, OutputFile);
    284  1.1.1.2  jruoho                             RActual = fread (&SourceByte, 1, 1, SourceFile);
    285  1.1.1.2  jruoho                         }
    286      1.1  jruoho                     }
    287      1.1  jruoho                 }
    288  1.1.1.2  jruoho 
    289      1.1  jruoho                 fprintf (OutputFile, "\n");
    290      1.1  jruoho             }
    291      1.1  jruoho         }
    292      1.1  jruoho         else
    293      1.1  jruoho         {
    294      1.1  jruoho             fprintf (OutputFile, "%s", Enode->Filename);
    295      1.1  jruoho 
    296      1.1  jruoho             if (Enode->LineNumber)
    297      1.1  jruoho             {
    298      1.1  jruoho                 fprintf (OutputFile, "(%u) : ", Enode->LineNumber);
    299      1.1  jruoho             }
    300      1.1  jruoho         }
    301      1.1  jruoho     }
    302      1.1  jruoho 
    303      1.1  jruoho     /* NULL message ID, just print the raw message */
    304      1.1  jruoho 
    305      1.1  jruoho     if (Enode->MessageId == 0)
    306      1.1  jruoho     {
    307      1.1  jruoho         fprintf (OutputFile, "%s\n", Enode->Message);
    308      1.1  jruoho     }
    309      1.1  jruoho     else
    310      1.1  jruoho     {
    311      1.1  jruoho         /* Decode the message ID */
    312      1.1  jruoho 
    313  1.1.1.2  jruoho         fprintf (OutputFile, "%s %4.4d - ",
    314      1.1  jruoho                     AslErrorLevel[Enode->Level],
    315      1.1  jruoho                     Enode->MessageId + ((Enode->Level+1) * 1000));
    316      1.1  jruoho 
    317      1.1  jruoho         MainMessage = AslMessages[Enode->MessageId];
    318      1.1  jruoho         ExtraMessage = Enode->Message;
    319      1.1  jruoho 
    320      1.1  jruoho         if (Enode->LineNumber)
    321      1.1  jruoho         {
    322      1.1  jruoho             MsgLength = strlen (MainMessage);
    323      1.1  jruoho             if (MsgLength == 0)
    324      1.1  jruoho             {
    325      1.1  jruoho                 MainMessage = Enode->Message;
    326      1.1  jruoho 
    327      1.1  jruoho                 MsgLength = strlen (MainMessage);
    328      1.1  jruoho                 ExtraMessage = NULL;
    329      1.1  jruoho             }
    330      1.1  jruoho 
    331  1.1.1.2  jruoho             if (Gbl_VerboseErrors && !PrematureEOF)
    332      1.1  jruoho             {
    333      1.1  jruoho                 SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2;
    334      1.1  jruoho                 ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1;
    335      1.1  jruoho 
    336      1.1  jruoho                 if ((MsgLength + ErrorColumn) < (SourceColumn - 1))
    337      1.1  jruoho                 {
    338      1.1  jruoho                     fprintf (OutputFile, "%*s%s",
    339      1.1  jruoho                         (int) ((SourceColumn - 1) - ErrorColumn),
    340      1.1  jruoho                         MainMessage, " ^ ");
    341      1.1  jruoho                 }
    342      1.1  jruoho                 else
    343      1.1  jruoho                 {
    344      1.1  jruoho                     fprintf (OutputFile, "%*s %s",
    345      1.1  jruoho                         (int) ((SourceColumn - ErrorColumn) + 1), "^",
    346      1.1  jruoho                         MainMessage);
    347      1.1  jruoho                 }
    348      1.1  jruoho             }
    349      1.1  jruoho             else
    350      1.1  jruoho             {
    351      1.1  jruoho                 fprintf (OutputFile, " %s", MainMessage);
    352      1.1  jruoho             }
    353      1.1  jruoho 
    354      1.1  jruoho             /* Print the extra info message if present */
    355      1.1  jruoho 
    356      1.1  jruoho             if (ExtraMessage)
    357      1.1  jruoho             {
    358      1.1  jruoho                 fprintf (OutputFile, " (%s)", ExtraMessage);
    359      1.1  jruoho             }
    360      1.1  jruoho 
    361  1.1.1.2  jruoho             if (PrematureEOF)
    362  1.1.1.2  jruoho             {
    363  1.1.1.2  jruoho                 fprintf (OutputFile, " and premature End-Of-File");
    364  1.1.1.2  jruoho             }
    365  1.1.1.2  jruoho 
    366      1.1  jruoho             fprintf (OutputFile, "\n");
    367      1.1  jruoho             if (Gbl_VerboseErrors)
    368      1.1  jruoho             {
    369      1.1  jruoho                 fprintf (OutputFile, "\n");
    370      1.1  jruoho             }
    371      1.1  jruoho         }
    372      1.1  jruoho         else
    373      1.1  jruoho         {
    374      1.1  jruoho             fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage);
    375      1.1  jruoho         }
    376      1.1  jruoho     }
    377      1.1  jruoho }
    378      1.1  jruoho 
    379      1.1  jruoho 
    380      1.1  jruoho /*******************************************************************************
    381      1.1  jruoho  *
    382      1.1  jruoho  * FUNCTION:    AePrintErrorLog
    383      1.1  jruoho  *
    384      1.1  jruoho  * PARAMETERS:  FileId           - Where to output the error log
    385      1.1  jruoho  *
    386      1.1  jruoho  * RETURN:      None
    387      1.1  jruoho  *
    388      1.1  jruoho  * DESCRIPTION: Print the entire contents of the error log
    389      1.1  jruoho  *
    390      1.1  jruoho  ******************************************************************************/
    391      1.1  jruoho 
    392      1.1  jruoho void
    393      1.1  jruoho AePrintErrorLog (
    394      1.1  jruoho     UINT32                  FileId)
    395      1.1  jruoho {
    396      1.1  jruoho     ASL_ERROR_MSG           *Enode = Gbl_ErrorLog;
    397      1.1  jruoho 
    398      1.1  jruoho 
    399      1.1  jruoho     /* Walk the error node list */
    400      1.1  jruoho 
    401      1.1  jruoho     while (Enode)
    402      1.1  jruoho     {
    403      1.1  jruoho         AePrintException (FileId, Enode, NULL);
    404      1.1  jruoho         Enode = Enode->Next;
    405      1.1  jruoho     }
    406      1.1  jruoho }
    407      1.1  jruoho 
    408      1.1  jruoho 
    409      1.1  jruoho /*******************************************************************************
    410      1.1  jruoho  *
    411      1.1  jruoho  * FUNCTION:    AslCommonError
    412      1.1  jruoho  *
    413      1.1  jruoho  * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
    414      1.1  jruoho  *              MessageId           - Index into global message buffer
    415      1.1  jruoho  *              CurrentLineNumber   - Actual file line number
    416      1.1  jruoho  *              LogicalLineNumber   - Cumulative line number
    417      1.1  jruoho  *              LogicalByteOffset   - Byte offset in source file
    418      1.1  jruoho  *              Column              - Column in current line
    419      1.1  jruoho  *              Filename            - source filename
    420      1.1  jruoho  *              ExtraMessage        - additional error message
    421      1.1  jruoho  *
    422      1.1  jruoho  * RETURN:      None
    423      1.1  jruoho  *
    424      1.1  jruoho  * DESCRIPTION: Create a new error node and add it to the error log
    425      1.1  jruoho  *
    426      1.1  jruoho  ******************************************************************************/
    427      1.1  jruoho 
    428      1.1  jruoho void
    429      1.1  jruoho AslCommonError (
    430      1.1  jruoho     UINT8                   Level,
    431      1.1  jruoho     UINT8                   MessageId,
    432      1.1  jruoho     UINT32                  CurrentLineNumber,
    433      1.1  jruoho     UINT32                  LogicalLineNumber,
    434      1.1  jruoho     UINT32                  LogicalByteOffset,
    435      1.1  jruoho     UINT32                  Column,
    436      1.1  jruoho     char                    *Filename,
    437      1.1  jruoho     char                    *ExtraMessage)
    438      1.1  jruoho {
    439      1.1  jruoho     UINT32                  MessageSize;
    440      1.1  jruoho     char                    *MessageBuffer = NULL;
    441      1.1  jruoho     ASL_ERROR_MSG           *Enode;
    442      1.1  jruoho 
    443      1.1  jruoho 
    444      1.1  jruoho     Enode = UtLocalCalloc (sizeof (ASL_ERROR_MSG));
    445      1.1  jruoho 
    446      1.1  jruoho     if (ExtraMessage)
    447      1.1  jruoho     {
    448      1.1  jruoho         /* Allocate a buffer for the message and a new error node */
    449      1.1  jruoho 
    450      1.1  jruoho         MessageSize   = strlen (ExtraMessage) + 1;
    451      1.1  jruoho         MessageBuffer = UtLocalCalloc (MessageSize);
    452      1.1  jruoho 
    453      1.1  jruoho         /* Keep a copy of the extra message */
    454      1.1  jruoho 
    455      1.1  jruoho         ACPI_STRCPY (MessageBuffer, ExtraMessage);
    456      1.1  jruoho     }
    457      1.1  jruoho 
    458      1.1  jruoho     /* Initialize the error node */
    459      1.1  jruoho 
    460      1.1  jruoho     if (Filename)
    461      1.1  jruoho     {
    462      1.1  jruoho         Enode->Filename       = Filename;
    463      1.1  jruoho         Enode->FilenameLength = strlen (Filename);
    464      1.1  jruoho         if (Enode->FilenameLength < 6)
    465      1.1  jruoho         {
    466      1.1  jruoho             Enode->FilenameLength = 6;
    467      1.1  jruoho         }
    468      1.1  jruoho     }
    469      1.1  jruoho 
    470      1.1  jruoho     Enode->MessageId            = MessageId;
    471      1.1  jruoho     Enode->Level                = Level;
    472      1.1  jruoho     Enode->LineNumber           = CurrentLineNumber;
    473      1.1  jruoho     Enode->LogicalLineNumber    = LogicalLineNumber;
    474      1.1  jruoho     Enode->LogicalByteOffset    = LogicalByteOffset;
    475      1.1  jruoho     Enode->Column               = Column;
    476      1.1  jruoho     Enode->Message              = MessageBuffer;
    477      1.1  jruoho 
    478      1.1  jruoho     /* Add the new node to the error node list */
    479      1.1  jruoho 
    480      1.1  jruoho     AeAddToErrorLog (Enode);
    481      1.1  jruoho 
    482      1.1  jruoho     if (Gbl_DebugFlag)
    483      1.1  jruoho     {
    484      1.1  jruoho         /* stderr is a file, send error to it immediately */
    485      1.1  jruoho 
    486      1.1  jruoho         AePrintException (ASL_FILE_STDERR, Enode, NULL);
    487      1.1  jruoho     }
    488      1.1  jruoho 
    489      1.1  jruoho     Gbl_ExceptionCount[Level]++;
    490      1.1  jruoho     if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
    491      1.1  jruoho     {
    492      1.1  jruoho         printf ("\nMaximum error count (%u) exceeded\n", ASL_MAX_ERROR_COUNT);
    493      1.1  jruoho 
    494      1.1  jruoho         Gbl_SourceLine = 0;
    495      1.1  jruoho         Gbl_NextError = Gbl_ErrorLog;
    496      1.1  jruoho         CmDoOutputFiles ();
    497      1.1  jruoho         CmCleanupAndExit ();
    498      1.1  jruoho         exit(1);
    499      1.1  jruoho     }
    500      1.1  jruoho 
    501      1.1  jruoho     return;
    502      1.1  jruoho }
    503      1.1  jruoho 
    504      1.1  jruoho 
    505      1.1  jruoho /*******************************************************************************
    506      1.1  jruoho  *
    507      1.1  jruoho  * FUNCTION:    AslError
    508      1.1  jruoho  *
    509      1.1  jruoho  * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
    510      1.1  jruoho  *              MessageId           - Index into global message buffer
    511      1.1  jruoho  *              Op                  - Parse node where error happened
    512      1.1  jruoho  *              ExtraMessage        - additional error message
    513      1.1  jruoho  *
    514      1.1  jruoho  * RETURN:      None
    515      1.1  jruoho  *
    516      1.1  jruoho  * DESCRIPTION: Main error reporting routine for the ASL compiler (all code
    517      1.1  jruoho  *              except the parser.)
    518      1.1  jruoho  *
    519      1.1  jruoho  ******************************************************************************/
    520      1.1  jruoho 
    521      1.1  jruoho void
    522      1.1  jruoho AslError (
    523      1.1  jruoho     UINT8                   Level,
    524      1.1  jruoho     UINT8                   MessageId,
    525      1.1  jruoho     ACPI_PARSE_OBJECT       *Op,
    526      1.1  jruoho     char                    *ExtraMessage)
    527      1.1  jruoho {
    528      1.1  jruoho 
    529      1.1  jruoho     switch (Level)
    530      1.1  jruoho     {
    531      1.1  jruoho     case ASL_WARNING2:
    532      1.1  jruoho     case ASL_WARNING3:
    533      1.1  jruoho         if (Gbl_WarningLevel < Level)
    534      1.1  jruoho         {
    535      1.1  jruoho             return;
    536      1.1  jruoho         }
    537      1.1  jruoho         break;
    538      1.1  jruoho 
    539      1.1  jruoho     default:
    540      1.1  jruoho         break;
    541      1.1  jruoho     }
    542      1.1  jruoho 
    543      1.1  jruoho 
    544      1.1  jruoho     if (Op)
    545      1.1  jruoho     {
    546      1.1  jruoho         AslCommonError (Level, MessageId, Op->Asl.LineNumber,
    547      1.1  jruoho                         Op->Asl.LogicalLineNumber,
    548      1.1  jruoho                         Op->Asl.LogicalByteOffset,
    549      1.1  jruoho                         Op->Asl.Column,
    550      1.1  jruoho                         Op->Asl.Filename, ExtraMessage);
    551      1.1  jruoho     }
    552      1.1  jruoho     else
    553      1.1  jruoho     {
    554      1.1  jruoho         AslCommonError (Level, MessageId, 0,
    555      1.1  jruoho                         0, 0, 0, NULL, ExtraMessage);
    556      1.1  jruoho     }
    557      1.1  jruoho }
    558      1.1  jruoho 
    559      1.1  jruoho 
    560      1.1  jruoho /*******************************************************************************
    561      1.1  jruoho  *
    562      1.1  jruoho  * FUNCTION:    AslCoreSubsystemError
    563      1.1  jruoho  *
    564      1.1  jruoho  * PARAMETERS:  Op                  - Parse node where error happened
    565      1.1  jruoho  *              Status              - The ACPI CA Exception
    566      1.1  jruoho  *              ExtraMessage        - additional error message
    567      1.1  jruoho  *              Abort               - TRUE -> Abort compilation
    568      1.1  jruoho  *
    569      1.1  jruoho  * RETURN:      None
    570      1.1  jruoho  *
    571      1.1  jruoho  * DESCRIPTION: Error reporting routine for exceptions returned by the ACPI
    572      1.1  jruoho  *              CA core subsystem.
    573      1.1  jruoho  *
    574      1.1  jruoho  ******************************************************************************/
    575      1.1  jruoho 
    576      1.1  jruoho void
    577      1.1  jruoho AslCoreSubsystemError (
    578      1.1  jruoho     ACPI_PARSE_OBJECT       *Op,
    579      1.1  jruoho     ACPI_STATUS             Status,
    580      1.1  jruoho     char                    *ExtraMessage,
    581      1.1  jruoho     BOOLEAN                 Abort)
    582      1.1  jruoho {
    583      1.1  jruoho 
    584      1.1  jruoho     sprintf (MsgBuffer, "%s %s", AcpiFormatException (Status), ExtraMessage);
    585      1.1  jruoho 
    586      1.1  jruoho     if (Op)
    587      1.1  jruoho     {
    588      1.1  jruoho         AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Op->Asl.LineNumber,
    589      1.1  jruoho                         Op->Asl.LogicalLineNumber,
    590      1.1  jruoho                         Op->Asl.LogicalByteOffset,
    591      1.1  jruoho                         Op->Asl.Column,
    592      1.1  jruoho                         Op->Asl.Filename, MsgBuffer);
    593      1.1  jruoho     }
    594      1.1  jruoho     else
    595      1.1  jruoho     {
    596      1.1  jruoho         AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, 0,
    597      1.1  jruoho                         0, 0, 0, NULL, MsgBuffer);
    598      1.1  jruoho     }
    599      1.1  jruoho 
    600      1.1  jruoho     if (Abort)
    601      1.1  jruoho     {
    602      1.1  jruoho         AslAbort ();
    603      1.1  jruoho     }
    604      1.1  jruoho }
    605      1.1  jruoho 
    606      1.1  jruoho 
    607      1.1  jruoho /*******************************************************************************
    608      1.1  jruoho  *
    609      1.1  jruoho  * FUNCTION:    AslCompilererror
    610      1.1  jruoho  *
    611      1.1  jruoho  * PARAMETERS:  CompilerMessage         - Error message from the parser
    612      1.1  jruoho  *
    613      1.1  jruoho  * RETURN:      Status (0 for now)
    614      1.1  jruoho  *
    615      1.1  jruoho  * DESCRIPTION: Report an error situation discovered in a production
    616      1.1  jruoho  *              NOTE: don't change the name of this function, it is called
    617      1.1  jruoho  *              from the auto-generated parser.
    618      1.1  jruoho  *
    619      1.1  jruoho  ******************************************************************************/
    620      1.1  jruoho 
    621      1.1  jruoho int
    622      1.1  jruoho AslCompilererror (
    623      1.1  jruoho     char                    *CompilerMessage)
    624      1.1  jruoho {
    625      1.1  jruoho 
    626      1.1  jruoho     AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, Gbl_CurrentLineNumber,
    627      1.1  jruoho                     Gbl_LogicalLineNumber, Gbl_CurrentLineOffset,
    628      1.1  jruoho                     Gbl_CurrentColumn, Gbl_Files[ASL_FILE_INPUT].Filename,
    629      1.1  jruoho                     CompilerMessage);
    630      1.1  jruoho 
    631      1.1  jruoho     return 0;
    632      1.1  jruoho }
    633      1.1  jruoho 
    634      1.1  jruoho 
    635