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