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