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