Home | History | Annotate | Line # | Download | only in utilities
uterror.c revision 1.1.1.2
      1      1.1  christos /*******************************************************************************
      2      1.1  christos  *
      3      1.1  christos  * Module Name: uterror - Various internal error/warning output functions
      4      1.1  christos  *
      5      1.1  christos  ******************************************************************************/
      6      1.1  christos 
      7      1.1  christos /*
      8  1.1.1.2  christos  * Copyright (C) 2000 - 2014, Intel Corp.
      9      1.1  christos  * All rights reserved.
     10      1.1  christos  *
     11      1.1  christos  * Redistribution and use in source and binary forms, with or without
     12      1.1  christos  * modification, are permitted provided that the following conditions
     13      1.1  christos  * are met:
     14      1.1  christos  * 1. Redistributions of source code must retain the above copyright
     15      1.1  christos  *    notice, this list of conditions, and the following disclaimer,
     16      1.1  christos  *    without modification.
     17      1.1  christos  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18      1.1  christos  *    substantially similar to the "NO WARRANTY" disclaimer below
     19      1.1  christos  *    ("Disclaimer") and any redistribution must be conditioned upon
     20      1.1  christos  *    including a substantially similar Disclaimer requirement for further
     21      1.1  christos  *    binary redistribution.
     22      1.1  christos  * 3. Neither the names of the above-listed copyright holders nor the names
     23      1.1  christos  *    of any contributors may be used to endorse or promote products derived
     24      1.1  christos  *    from this software without specific prior written permission.
     25      1.1  christos  *
     26      1.1  christos  * Alternatively, this software may be distributed under the terms of the
     27      1.1  christos  * GNU General Public License ("GPL") version 2 as published by the Free
     28      1.1  christos  * Software Foundation.
     29      1.1  christos  *
     30      1.1  christos  * NO WARRANTY
     31      1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32      1.1  christos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33      1.1  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34      1.1  christos  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35      1.1  christos  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36      1.1  christos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37      1.1  christos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38      1.1  christos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39      1.1  christos  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40      1.1  christos  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41      1.1  christos  * POSSIBILITY OF SUCH DAMAGES.
     42      1.1  christos  */
     43      1.1  christos 
     44      1.1  christos #define __UTERROR_C__
     45      1.1  christos 
     46      1.1  christos #include "acpi.h"
     47      1.1  christos #include "accommon.h"
     48      1.1  christos #include "acnamesp.h"
     49      1.1  christos 
     50      1.1  christos 
     51      1.1  christos #define _COMPONENT          ACPI_UTILITIES
     52      1.1  christos         ACPI_MODULE_NAME    ("uterror")
     53      1.1  christos 
     54      1.1  christos 
     55      1.1  christos /*
     56      1.1  christos  * This module contains internal error functions that may
     57      1.1  christos  * be configured out.
     58      1.1  christos  */
     59      1.1  christos #if !defined (ACPI_NO_ERROR_MESSAGES)
     60      1.1  christos 
     61      1.1  christos /*******************************************************************************
     62      1.1  christos  *
     63      1.1  christos  * FUNCTION:    AcpiUtPredefinedWarning
     64      1.1  christos  *
     65      1.1  christos  * PARAMETERS:  ModuleName      - Caller's module name (for error output)
     66      1.1  christos  *              LineNumber      - Caller's line number (for error output)
     67      1.1  christos  *              Pathname        - Full pathname to the node
     68      1.1  christos  *              NodeFlags       - From Namespace node for the method/object
     69      1.1  christos  *              Format          - Printf format string + additional args
     70      1.1  christos  *
     71      1.1  christos  * RETURN:      None
     72      1.1  christos  *
     73      1.1  christos  * DESCRIPTION: Warnings for the predefined validation module. Messages are
     74      1.1  christos  *              only emitted the first time a problem with a particular
     75      1.1  christos  *              method/object is detected. This prevents a flood of error
     76      1.1  christos  *              messages for methods that are repeatedly evaluated.
     77      1.1  christos  *
     78      1.1  christos  ******************************************************************************/
     79      1.1  christos 
     80      1.1  christos void ACPI_INTERNAL_VAR_XFACE
     81      1.1  christos AcpiUtPredefinedWarning (
     82      1.1  christos     const char              *ModuleName,
     83      1.1  christos     UINT32                  LineNumber,
     84      1.1  christos     char                    *Pathname,
     85      1.1  christos     UINT8                   NodeFlags,
     86      1.1  christos     const char              *Format,
     87      1.1  christos     ...)
     88      1.1  christos {
     89      1.1  christos     va_list                 ArgList;
     90      1.1  christos 
     91      1.1  christos 
     92      1.1  christos     /*
     93      1.1  christos      * Warning messages for this method/object will be disabled after the
     94      1.1  christos      * first time a validation fails or an object is successfully repaired.
     95      1.1  christos      */
     96      1.1  christos     if (NodeFlags & ANOBJ_EVALUATED)
     97      1.1  christos     {
     98      1.1  christos         return;
     99      1.1  christos     }
    100      1.1  christos 
    101      1.1  christos     AcpiOsPrintf (ACPI_MSG_WARNING "%s: ", Pathname);
    102      1.1  christos 
    103      1.1  christos     va_start (ArgList, Format);
    104      1.1  christos     AcpiOsVprintf (Format, ArgList);
    105      1.1  christos     ACPI_MSG_SUFFIX;
    106      1.1  christos     va_end (ArgList);
    107      1.1  christos }
    108      1.1  christos 
    109      1.1  christos 
    110      1.1  christos /*******************************************************************************
    111      1.1  christos  *
    112      1.1  christos  * FUNCTION:    AcpiUtPredefinedInfo
    113      1.1  christos  *
    114      1.1  christos  * PARAMETERS:  ModuleName      - Caller's module name (for error output)
    115      1.1  christos  *              LineNumber      - Caller's line number (for error output)
    116      1.1  christos  *              Pathname        - Full pathname to the node
    117      1.1  christos  *              NodeFlags       - From Namespace node for the method/object
    118      1.1  christos  *              Format          - Printf format string + additional args
    119      1.1  christos  *
    120      1.1  christos  * RETURN:      None
    121      1.1  christos  *
    122      1.1  christos  * DESCRIPTION: Info messages for the predefined validation module. Messages
    123      1.1  christos  *              are only emitted the first time a problem with a particular
    124      1.1  christos  *              method/object is detected. This prevents a flood of
    125      1.1  christos  *              messages for methods that are repeatedly evaluated.
    126      1.1  christos  *
    127      1.1  christos  ******************************************************************************/
    128      1.1  christos 
    129      1.1  christos void ACPI_INTERNAL_VAR_XFACE
    130      1.1  christos AcpiUtPredefinedInfo (
    131      1.1  christos     const char              *ModuleName,
    132      1.1  christos     UINT32                  LineNumber,
    133      1.1  christos     char                    *Pathname,
    134      1.1  christos     UINT8                   NodeFlags,
    135      1.1  christos     const char              *Format,
    136      1.1  christos     ...)
    137      1.1  christos {
    138      1.1  christos     va_list                 ArgList;
    139      1.1  christos 
    140      1.1  christos 
    141      1.1  christos     /*
    142      1.1  christos      * Warning messages for this method/object will be disabled after the
    143      1.1  christos      * first time a validation fails or an object is successfully repaired.
    144      1.1  christos      */
    145      1.1  christos     if (NodeFlags & ANOBJ_EVALUATED)
    146      1.1  christos     {
    147      1.1  christos         return;
    148      1.1  christos     }
    149      1.1  christos 
    150      1.1  christos     AcpiOsPrintf (ACPI_MSG_INFO "%s: ", Pathname);
    151      1.1  christos 
    152      1.1  christos     va_start (ArgList, Format);
    153      1.1  christos     AcpiOsVprintf (Format, ArgList);
    154      1.1  christos     ACPI_MSG_SUFFIX;
    155      1.1  christos     va_end (ArgList);
    156      1.1  christos }
    157      1.1  christos 
    158      1.1  christos 
    159      1.1  christos /*******************************************************************************
    160      1.1  christos  *
    161      1.1  christos  * FUNCTION:    AcpiUtPredefinedBiosError
    162      1.1  christos  *
    163      1.1  christos  * PARAMETERS:  ModuleName      - Caller's module name (for error output)
    164      1.1  christos  *              LineNumber      - Caller's line number (for error output)
    165      1.1  christos  *              Pathname        - Full pathname to the node
    166      1.1  christos  *              NodeFlags       - From Namespace node for the method/object
    167      1.1  christos  *              Format          - Printf format string + additional args
    168      1.1  christos  *
    169      1.1  christos  * RETURN:      None
    170      1.1  christos  *
    171      1.1  christos  * DESCRIPTION: BIOS error message for predefined names. Messages
    172      1.1  christos  *              are only emitted the first time a problem with a particular
    173      1.1  christos  *              method/object is detected. This prevents a flood of
    174      1.1  christos  *              messages for methods that are repeatedly evaluated.
    175      1.1  christos  *
    176      1.1  christos  ******************************************************************************/
    177      1.1  christos 
    178      1.1  christos void ACPI_INTERNAL_VAR_XFACE
    179      1.1  christos AcpiUtPredefinedBiosError (
    180      1.1  christos     const char              *ModuleName,
    181      1.1  christos     UINT32                  LineNumber,
    182      1.1  christos     char                    *Pathname,
    183      1.1  christos     UINT8                   NodeFlags,
    184      1.1  christos     const char              *Format,
    185      1.1  christos     ...)
    186      1.1  christos {
    187      1.1  christos     va_list                 ArgList;
    188      1.1  christos 
    189      1.1  christos 
    190      1.1  christos     /*
    191      1.1  christos      * Warning messages for this method/object will be disabled after the
    192      1.1  christos      * first time a validation fails or an object is successfully repaired.
    193      1.1  christos      */
    194      1.1  christos     if (NodeFlags & ANOBJ_EVALUATED)
    195      1.1  christos     {
    196      1.1  christos         return;
    197      1.1  christos     }
    198      1.1  christos 
    199      1.1  christos     AcpiOsPrintf (ACPI_MSG_BIOS_ERROR "%s: ", Pathname);
    200      1.1  christos 
    201      1.1  christos     va_start (ArgList, Format);
    202      1.1  christos     AcpiOsVprintf (Format, ArgList);
    203      1.1  christos     ACPI_MSG_SUFFIX;
    204      1.1  christos     va_end (ArgList);
    205      1.1  christos }
    206      1.1  christos 
    207      1.1  christos 
    208      1.1  christos /*******************************************************************************
    209      1.1  christos  *
    210      1.1  christos  * FUNCTION:    AcpiUtNamespaceError
    211      1.1  christos  *
    212      1.1  christos  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
    213      1.1  christos  *              LineNumber          - Caller's line number (for error output)
    214      1.1  christos  *              InternalName        - Name or path of the namespace node
    215      1.1  christos  *              LookupStatus        - Exception code from NS lookup
    216      1.1  christos  *
    217      1.1  christos  * RETURN:      None
    218      1.1  christos  *
    219      1.1  christos  * DESCRIPTION: Print error message with the full pathname for the NS node.
    220      1.1  christos  *
    221      1.1  christos  ******************************************************************************/
    222      1.1  christos 
    223      1.1  christos void
    224      1.1  christos AcpiUtNamespaceError (
    225      1.1  christos     const char              *ModuleName,
    226      1.1  christos     UINT32                  LineNumber,
    227      1.1  christos     const char              *InternalName,
    228      1.1  christos     ACPI_STATUS             LookupStatus)
    229      1.1  christos {
    230      1.1  christos     ACPI_STATUS             Status;
    231      1.1  christos     UINT32                  BadName;
    232      1.1  christos     char                    *Name = NULL;
    233      1.1  christos 
    234      1.1  christos 
    235      1.1  christos     ACPI_MSG_REDIRECT_BEGIN;
    236      1.1  christos     AcpiOsPrintf (ACPI_MSG_ERROR);
    237      1.1  christos 
    238      1.1  christos     if (LookupStatus == AE_BAD_CHARACTER)
    239      1.1  christos     {
    240      1.1  christos         /* There is a non-ascii character in the name */
    241      1.1  christos 
    242      1.1  christos         ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR (UINT32, InternalName));
    243      1.1  christos         AcpiOsPrintf ("[0x%.8X] (NON-ASCII)", BadName);
    244      1.1  christos     }
    245      1.1  christos     else
    246      1.1  christos     {
    247      1.1  christos         /* Convert path to external format */
    248      1.1  christos 
    249      1.1  christos         Status = AcpiNsExternalizeName (ACPI_UINT32_MAX,
    250      1.1  christos                     InternalName, NULL, &Name);
    251      1.1  christos 
    252      1.1  christos         /* Print target name */
    253      1.1  christos 
    254      1.1  christos         if (ACPI_SUCCESS (Status))
    255      1.1  christos         {
    256      1.1  christos             AcpiOsPrintf ("[%s]", Name);
    257      1.1  christos         }
    258      1.1  christos         else
    259      1.1  christos         {
    260      1.1  christos             AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]");
    261      1.1  christos         }
    262      1.1  christos 
    263      1.1  christos         if (Name)
    264      1.1  christos         {
    265      1.1  christos             ACPI_FREE (Name);
    266      1.1  christos         }
    267      1.1  christos     }
    268      1.1  christos 
    269      1.1  christos     AcpiOsPrintf (" Namespace lookup failure, %s",
    270      1.1  christos         AcpiFormatException (LookupStatus));
    271      1.1  christos 
    272      1.1  christos     ACPI_MSG_SUFFIX;
    273      1.1  christos     ACPI_MSG_REDIRECT_END;
    274      1.1  christos }
    275      1.1  christos 
    276      1.1  christos 
    277      1.1  christos /*******************************************************************************
    278      1.1  christos  *
    279      1.1  christos  * FUNCTION:    AcpiUtMethodError
    280      1.1  christos  *
    281      1.1  christos  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
    282      1.1  christos  *              LineNumber          - Caller's line number (for error output)
    283      1.1  christos  *              Message             - Error message to use on failure
    284      1.1  christos  *              PrefixNode          - Prefix relative to the path
    285      1.1  christos  *              Path                - Path to the node (optional)
    286      1.1  christos  *              MethodStatus        - Execution status
    287      1.1  christos  *
    288      1.1  christos  * RETURN:      None
    289      1.1  christos  *
    290      1.1  christos  * DESCRIPTION: Print error message with the full pathname for the method.
    291      1.1  christos  *
    292      1.1  christos  ******************************************************************************/
    293      1.1  christos 
    294      1.1  christos void
    295      1.1  christos AcpiUtMethodError (
    296      1.1  christos     const char              *ModuleName,
    297      1.1  christos     UINT32                  LineNumber,
    298      1.1  christos     const char              *Message,
    299      1.1  christos     ACPI_NAMESPACE_NODE     *PrefixNode,
    300      1.1  christos     const char              *Path,
    301      1.1  christos     ACPI_STATUS             MethodStatus)
    302      1.1  christos {
    303      1.1  christos     ACPI_STATUS             Status;
    304      1.1  christos     ACPI_NAMESPACE_NODE     *Node = PrefixNode;
    305      1.1  christos 
    306      1.1  christos 
    307      1.1  christos     ACPI_MSG_REDIRECT_BEGIN;
    308      1.1  christos     AcpiOsPrintf (ACPI_MSG_ERROR);
    309      1.1  christos 
    310      1.1  christos     if (Path)
    311      1.1  christos     {
    312      1.1  christos         Status = AcpiNsGetNode (PrefixNode, Path, ACPI_NS_NO_UPSEARCH,
    313      1.1  christos                     &Node);
    314      1.1  christos         if (ACPI_FAILURE (Status))
    315      1.1  christos         {
    316      1.1  christos             AcpiOsPrintf ("[Could not get node by pathname]");
    317      1.1  christos         }
    318      1.1  christos     }
    319      1.1  christos 
    320      1.1  christos     AcpiNsPrintNodePathname (Node, Message);
    321      1.1  christos     AcpiOsPrintf (", %s", AcpiFormatException (MethodStatus));
    322      1.1  christos 
    323      1.1  christos     ACPI_MSG_SUFFIX;
    324      1.1  christos     ACPI_MSG_REDIRECT_END;
    325      1.1  christos }
    326      1.1  christos 
    327      1.1  christos #endif /* ACPI_NO_ERROR_MESSAGES */
    328