Home | History | Annotate | Line # | Download | only in utilities
utexcep.c revision 1.1.1.1.10.2
      1  1.1.1.1.10.2  tls /*******************************************************************************
      2  1.1.1.1.10.2  tls  *
      3  1.1.1.1.10.2  tls  * Module Name: utexcep - Exception code support
      4  1.1.1.1.10.2  tls  *
      5  1.1.1.1.10.2  tls  ******************************************************************************/
      6  1.1.1.1.10.2  tls 
      7  1.1.1.1.10.2  tls /*
      8  1.1.1.1.10.2  tls  * Copyright (C) 2000 - 2013, Intel Corp.
      9  1.1.1.1.10.2  tls  * All rights reserved.
     10  1.1.1.1.10.2  tls  *
     11  1.1.1.1.10.2  tls  * Redistribution and use in source and binary forms, with or without
     12  1.1.1.1.10.2  tls  * modification, are permitted provided that the following conditions
     13  1.1.1.1.10.2  tls  * are met:
     14  1.1.1.1.10.2  tls  * 1. Redistributions of source code must retain the above copyright
     15  1.1.1.1.10.2  tls  *    notice, this list of conditions, and the following disclaimer,
     16  1.1.1.1.10.2  tls  *    without modification.
     17  1.1.1.1.10.2  tls  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.1.1.1.10.2  tls  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.1.1.1.10.2  tls  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.1.1.1.10.2  tls  *    including a substantially similar Disclaimer requirement for further
     21  1.1.1.1.10.2  tls  *    binary redistribution.
     22  1.1.1.1.10.2  tls  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.1.1.1.10.2  tls  *    of any contributors may be used to endorse or promote products derived
     24  1.1.1.1.10.2  tls  *    from this software without specific prior written permission.
     25  1.1.1.1.10.2  tls  *
     26  1.1.1.1.10.2  tls  * Alternatively, this software may be distributed under the terms of the
     27  1.1.1.1.10.2  tls  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.1.1.1.10.2  tls  * Software Foundation.
     29  1.1.1.1.10.2  tls  *
     30  1.1.1.1.10.2  tls  * NO WARRANTY
     31  1.1.1.1.10.2  tls  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.1.1.1.10.2  tls  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.1.1.1.10.2  tls  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.1.1.1.10.2  tls  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.1.1.1.10.2  tls  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.1.1.1.10.2  tls  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.1.1.1.10.2  tls  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.1.1.1.10.2  tls  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.1.1.1.10.2  tls  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.1.1.1.10.2  tls  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.1.1.1.10.2  tls  * POSSIBILITY OF SUCH DAMAGES.
     42  1.1.1.1.10.2  tls  */
     43  1.1.1.1.10.2  tls 
     44  1.1.1.1.10.2  tls 
     45  1.1.1.1.10.2  tls #define __UTEXCEP_C__
     46  1.1.1.1.10.2  tls #define EXPORT_ACPI_INTERFACES
     47  1.1.1.1.10.2  tls 
     48  1.1.1.1.10.2  tls #define ACPI_DEFINE_EXCEPTION_TABLE
     49  1.1.1.1.10.2  tls #include "acpi.h"
     50  1.1.1.1.10.2  tls #include "accommon.h"
     51  1.1.1.1.10.2  tls 
     52  1.1.1.1.10.2  tls 
     53  1.1.1.1.10.2  tls #define _COMPONENT          ACPI_UTILITIES
     54  1.1.1.1.10.2  tls         ACPI_MODULE_NAME    ("utexcep")
     55  1.1.1.1.10.2  tls 
     56  1.1.1.1.10.2  tls 
     57  1.1.1.1.10.2  tls /*******************************************************************************
     58  1.1.1.1.10.2  tls  *
     59  1.1.1.1.10.2  tls  * FUNCTION:    AcpiFormatException
     60  1.1.1.1.10.2  tls  *
     61  1.1.1.1.10.2  tls  * PARAMETERS:  Status              - The ACPI_STATUS code to be formatted
     62  1.1.1.1.10.2  tls  *
     63  1.1.1.1.10.2  tls  * RETURN:      A string containing the exception text. A valid pointer is
     64  1.1.1.1.10.2  tls  *              always returned.
     65  1.1.1.1.10.2  tls  *
     66  1.1.1.1.10.2  tls  * DESCRIPTION: This function translates an ACPI exception into an ASCII
     67  1.1.1.1.10.2  tls  *              string. Returns "unknown status" string for invalid codes.
     68  1.1.1.1.10.2  tls  *
     69  1.1.1.1.10.2  tls  ******************************************************************************/
     70  1.1.1.1.10.2  tls 
     71  1.1.1.1.10.2  tls const char *
     72  1.1.1.1.10.2  tls AcpiFormatException (
     73  1.1.1.1.10.2  tls     ACPI_STATUS             Status)
     74  1.1.1.1.10.2  tls {
     75  1.1.1.1.10.2  tls     const ACPI_EXCEPTION_INFO   *Exception;
     76  1.1.1.1.10.2  tls 
     77  1.1.1.1.10.2  tls 
     78  1.1.1.1.10.2  tls     ACPI_FUNCTION_ENTRY ();
     79  1.1.1.1.10.2  tls 
     80  1.1.1.1.10.2  tls 
     81  1.1.1.1.10.2  tls     Exception = AcpiUtValidateException (Status);
     82  1.1.1.1.10.2  tls     if (!Exception)
     83  1.1.1.1.10.2  tls     {
     84  1.1.1.1.10.2  tls         /* Exception code was not recognized */
     85  1.1.1.1.10.2  tls 
     86  1.1.1.1.10.2  tls         ACPI_ERROR ((AE_INFO,
     87  1.1.1.1.10.2  tls             "Unknown exception code: 0x%8.8X", Status));
     88  1.1.1.1.10.2  tls 
     89  1.1.1.1.10.2  tls         return ("UNKNOWN_STATUS_CODE");
     90  1.1.1.1.10.2  tls     }
     91  1.1.1.1.10.2  tls 
     92  1.1.1.1.10.2  tls     return (Exception->Name);
     93  1.1.1.1.10.2  tls }
     94  1.1.1.1.10.2  tls 
     95  1.1.1.1.10.2  tls ACPI_EXPORT_SYMBOL (AcpiFormatException)
     96  1.1.1.1.10.2  tls 
     97  1.1.1.1.10.2  tls 
     98  1.1.1.1.10.2  tls /*******************************************************************************
     99  1.1.1.1.10.2  tls  *
    100  1.1.1.1.10.2  tls  * FUNCTION:    AcpiUtValidateException
    101  1.1.1.1.10.2  tls  *
    102  1.1.1.1.10.2  tls  * PARAMETERS:  Status              - The ACPI_STATUS code to be formatted
    103  1.1.1.1.10.2  tls  *
    104  1.1.1.1.10.2  tls  * RETURN:      A string containing the exception text. NULL if exception is
    105  1.1.1.1.10.2  tls  *              not valid.
    106  1.1.1.1.10.2  tls  *
    107  1.1.1.1.10.2  tls  * DESCRIPTION: This function validates and translates an ACPI exception into
    108  1.1.1.1.10.2  tls  *              an ASCII string.
    109  1.1.1.1.10.2  tls  *
    110  1.1.1.1.10.2  tls  ******************************************************************************/
    111  1.1.1.1.10.2  tls 
    112  1.1.1.1.10.2  tls const ACPI_EXCEPTION_INFO *
    113  1.1.1.1.10.2  tls AcpiUtValidateException (
    114  1.1.1.1.10.2  tls     ACPI_STATUS             Status)
    115  1.1.1.1.10.2  tls {
    116  1.1.1.1.10.2  tls     UINT32                      SubStatus;
    117  1.1.1.1.10.2  tls     const ACPI_EXCEPTION_INFO   *Exception = NULL;
    118  1.1.1.1.10.2  tls 
    119  1.1.1.1.10.2  tls 
    120  1.1.1.1.10.2  tls     ACPI_FUNCTION_ENTRY ();
    121  1.1.1.1.10.2  tls 
    122  1.1.1.1.10.2  tls 
    123  1.1.1.1.10.2  tls     /*
    124  1.1.1.1.10.2  tls      * Status is composed of two parts, a "type" and an actual code
    125  1.1.1.1.10.2  tls      */
    126  1.1.1.1.10.2  tls     SubStatus = (Status & ~AE_CODE_MASK);
    127  1.1.1.1.10.2  tls 
    128  1.1.1.1.10.2  tls     switch (Status & AE_CODE_MASK)
    129  1.1.1.1.10.2  tls     {
    130  1.1.1.1.10.2  tls     case AE_CODE_ENVIRONMENTAL:
    131  1.1.1.1.10.2  tls 
    132  1.1.1.1.10.2  tls         if (SubStatus <= AE_CODE_ENV_MAX)
    133  1.1.1.1.10.2  tls         {
    134  1.1.1.1.10.2  tls             Exception = &AcpiGbl_ExceptionNames_Env [SubStatus];
    135  1.1.1.1.10.2  tls         }
    136  1.1.1.1.10.2  tls         break;
    137  1.1.1.1.10.2  tls 
    138  1.1.1.1.10.2  tls     case AE_CODE_PROGRAMMER:
    139  1.1.1.1.10.2  tls 
    140  1.1.1.1.10.2  tls         if (SubStatus <= AE_CODE_PGM_MAX)
    141  1.1.1.1.10.2  tls         {
    142  1.1.1.1.10.2  tls             Exception = &AcpiGbl_ExceptionNames_Pgm [SubStatus];
    143  1.1.1.1.10.2  tls         }
    144  1.1.1.1.10.2  tls         break;
    145  1.1.1.1.10.2  tls 
    146  1.1.1.1.10.2  tls     case AE_CODE_ACPI_TABLES:
    147  1.1.1.1.10.2  tls 
    148  1.1.1.1.10.2  tls         if (SubStatus <= AE_CODE_TBL_MAX)
    149  1.1.1.1.10.2  tls         {
    150  1.1.1.1.10.2  tls             Exception = &AcpiGbl_ExceptionNames_Tbl [SubStatus];
    151  1.1.1.1.10.2  tls         }
    152  1.1.1.1.10.2  tls         break;
    153  1.1.1.1.10.2  tls 
    154  1.1.1.1.10.2  tls     case AE_CODE_AML:
    155  1.1.1.1.10.2  tls 
    156  1.1.1.1.10.2  tls         if (SubStatus <= AE_CODE_AML_MAX)
    157  1.1.1.1.10.2  tls         {
    158  1.1.1.1.10.2  tls             Exception = &AcpiGbl_ExceptionNames_Aml [SubStatus];
    159  1.1.1.1.10.2  tls         }
    160  1.1.1.1.10.2  tls         break;
    161  1.1.1.1.10.2  tls 
    162  1.1.1.1.10.2  tls     case AE_CODE_CONTROL:
    163  1.1.1.1.10.2  tls 
    164  1.1.1.1.10.2  tls         if (SubStatus <= AE_CODE_CTRL_MAX)
    165  1.1.1.1.10.2  tls         {
    166  1.1.1.1.10.2  tls             Exception = &AcpiGbl_ExceptionNames_Ctrl [SubStatus];
    167  1.1.1.1.10.2  tls         }
    168  1.1.1.1.10.2  tls         break;
    169  1.1.1.1.10.2  tls 
    170  1.1.1.1.10.2  tls     default:
    171  1.1.1.1.10.2  tls 
    172  1.1.1.1.10.2  tls         break;
    173  1.1.1.1.10.2  tls     }
    174  1.1.1.1.10.2  tls 
    175  1.1.1.1.10.2  tls     if (!Exception || !Exception->Name)
    176  1.1.1.1.10.2  tls     {
    177  1.1.1.1.10.2  tls         return (NULL);
    178  1.1.1.1.10.2  tls     }
    179  1.1.1.1.10.2  tls 
    180  1.1.1.1.10.2  tls     return (Exception);
    181  1.1.1.1.10.2  tls }
    182