1 /*******************************************************************************
3 * Module Name: utxferror - Various error/warning output functions
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2011, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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.
44 #define __UTXFERROR_C__
46 #include <contrib/dev/acpica/include/acpi.h>
47 #include <contrib/dev/acpica/include/accommon.h>
48 #include <contrib/dev/acpica/include/acnamesp.h>
51 #define _COMPONENT ACPI_UTILITIES
52 ACPI_MODULE_NAME ("utxferror")
55 * This module is used for the in-kernel ACPICA as well as the ACPICA
58 * For the iASL compiler case, the output is redirected to stderr so that
59 * any of the various ACPI errors and warnings do not appear in the output
60 * files, for either the compiler or disassembler portions of the tool.
62 #ifdef ACPI_ASL_COMPILER
65 extern FILE *AcpiGbl_OutputFile;
67 #define ACPI_MSG_REDIRECT_BEGIN \
68 FILE *OutputFile = AcpiGbl_OutputFile; \
69 AcpiOsRedirectOutput (stderr);
71 #define ACPI_MSG_REDIRECT_END \
72 AcpiOsRedirectOutput (OutputFile);
76 * non-iASL case - no redirection, nothing to do
78 #define ACPI_MSG_REDIRECT_BEGIN
79 #define ACPI_MSG_REDIRECT_END
83 * Common message prefixes
85 #define ACPI_MSG_ERROR "ACPI Error: "
86 #define ACPI_MSG_EXCEPTION "ACPI Exception: "
87 #define ACPI_MSG_WARNING "ACPI Warning: "
88 #define ACPI_MSG_INFO "ACPI: "
91 * Common message suffix
93 #define ACPI_MSG_SUFFIX \
94 AcpiOsPrintf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, ModuleName, LineNumber)
97 /*******************************************************************************
101 * PARAMETERS: ModuleName - Caller's module name (for error output)
102 * LineNumber - Caller's line number (for error output)
103 * Format - Printf format string + additional args
107 * DESCRIPTION: Print "ACPI Error" message with module/line/version info
109 ******************************************************************************/
111 void ACPI_INTERNAL_VAR_XFACE
113 const char *ModuleName,
121 ACPI_MSG_REDIRECT_BEGIN;
122 AcpiOsPrintf (ACPI_MSG_ERROR);
124 va_start (ArgList, Format);
125 AcpiOsVprintf (Format, ArgList);
129 ACPI_MSG_REDIRECT_END;
132 ACPI_EXPORT_SYMBOL (AcpiError)
135 /*******************************************************************************
137 * FUNCTION: AcpiException
139 * PARAMETERS: ModuleName - Caller's module name (for error output)
140 * LineNumber - Caller's line number (for error output)
141 * Status - Status to be formatted
142 * Format - Printf format string + additional args
146 * DESCRIPTION: Print "ACPI Exception" message with module/line/version info
147 * and decoded ACPI_STATUS.
149 ******************************************************************************/
151 void ACPI_INTERNAL_VAR_XFACE
153 const char *ModuleName,
162 ACPI_MSG_REDIRECT_BEGIN;
163 AcpiOsPrintf (ACPI_MSG_EXCEPTION "%s, ", AcpiFormatException (Status));
165 va_start (ArgList, Format);
166 AcpiOsVprintf (Format, ArgList);
170 ACPI_MSG_REDIRECT_END;
173 ACPI_EXPORT_SYMBOL (AcpiException)
176 /*******************************************************************************
178 * FUNCTION: AcpiWarning
180 * PARAMETERS: ModuleName - Caller's module name (for error output)
181 * LineNumber - Caller's line number (for error output)
182 * Format - Printf format string + additional args
186 * DESCRIPTION: Print "ACPI Warning" message with module/line/version info
188 ******************************************************************************/
190 void ACPI_INTERNAL_VAR_XFACE
192 const char *ModuleName,
200 ACPI_MSG_REDIRECT_BEGIN;
201 AcpiOsPrintf (ACPI_MSG_WARNING);
203 va_start (ArgList, Format);
204 AcpiOsVprintf (Format, ArgList);
208 ACPI_MSG_REDIRECT_END;
211 ACPI_EXPORT_SYMBOL (AcpiWarning)
214 /*******************************************************************************
218 * PARAMETERS: ModuleName - Caller's module name (for error output)
219 * LineNumber - Caller's line number (for error output)
220 * Format - Printf format string + additional args
224 * DESCRIPTION: Print generic "ACPI:" information message. There is no
225 * module/line/version info in order to keep the message simple.
227 * TBD: ModuleName and LineNumber args are not needed, should be removed.
229 ******************************************************************************/
231 void ACPI_INTERNAL_VAR_XFACE
233 const char *ModuleName,
241 /* Temporarily hide too verbose printfs. */
246 ACPI_MSG_REDIRECT_BEGIN;
247 AcpiOsPrintf (ACPI_MSG_INFO);
249 va_start (ArgList, Format);
250 AcpiOsVprintf (Format, ArgList);
254 ACPI_MSG_REDIRECT_END;
257 ACPI_EXPORT_SYMBOL (AcpiInfo)
261 * The remainder of this module contains internal error functions that may
264 #if !defined (ACPI_NO_ERROR_MESSAGES) && !defined (ACPI_BIN_APP)
266 /*******************************************************************************
268 * FUNCTION: AcpiUtPredefinedWarning
270 * PARAMETERS: ModuleName - Caller's module name (for error output)
271 * LineNumber - Caller's line number (for error output)
272 * Pathname - Full pathname to the node
273 * NodeFlags - From Namespace node for the method/object
274 * Format - Printf format string + additional args
278 * DESCRIPTION: Warnings for the predefined validation module. Messages are
279 * only emitted the first time a problem with a particular
280 * method/object is detected. This prevents a flood of error
281 * messages for methods that are repeatedly evaluated.
283 ******************************************************************************/
285 void ACPI_INTERNAL_VAR_XFACE
286 AcpiUtPredefinedWarning (
287 const char *ModuleName,
298 * Warning messages for this method/object will be disabled after the
299 * first time a validation fails or an object is successfully repaired.
301 if (NodeFlags & ANOBJ_EVALUATED)
306 AcpiOsPrintf (ACPI_MSG_WARNING "For %s: ", Pathname);
308 va_start (ArgList, Format);
309 AcpiOsVprintf (Format, ArgList);
315 /*******************************************************************************
317 * FUNCTION: AcpiUtPredefinedInfo
319 * PARAMETERS: ModuleName - Caller's module name (for error output)
320 * LineNumber - Caller's line number (for error output)
321 * Pathname - Full pathname to the node
322 * NodeFlags - From Namespace node for the method/object
323 * Format - Printf format string + additional args
327 * DESCRIPTION: Info messages for the predefined validation module. Messages
328 * are only emitted the first time a problem with a particular
329 * method/object is detected. This prevents a flood of
330 * messages for methods that are repeatedly evaluated.
332 ******************************************************************************/
334 void ACPI_INTERNAL_VAR_XFACE
335 AcpiUtPredefinedInfo (
336 const char *ModuleName,
347 * Warning messages for this method/object will be disabled after the
348 * first time a validation fails or an object is successfully repaired.
350 if (NodeFlags & ANOBJ_EVALUATED)
355 AcpiOsPrintf (ACPI_MSG_INFO "For %s: ", Pathname);
357 va_start (ArgList, Format);
358 AcpiOsVprintf (Format, ArgList);
364 /*******************************************************************************
366 * FUNCTION: AcpiUtNamespaceError
368 * PARAMETERS: ModuleName - Caller's module name (for error output)
369 * LineNumber - Caller's line number (for error output)
370 * InternalName - Name or path of the namespace node
371 * LookupStatus - Exception code from NS lookup
375 * DESCRIPTION: Print error message with the full pathname for the NS node.
377 ******************************************************************************/
380 AcpiUtNamespaceError (
381 const char *ModuleName,
383 const char *InternalName,
384 ACPI_STATUS LookupStatus)
391 ACPI_MSG_REDIRECT_BEGIN;
392 AcpiOsPrintf (ACPI_MSG_ERROR);
394 if (LookupStatus == AE_BAD_CHARACTER)
396 /* There is a non-ascii character in the name */
398 ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR (UINT32, InternalName));
399 AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)", BadName);
403 /* Convert path to external format */
405 Status = AcpiNsExternalizeName (ACPI_UINT32_MAX,
406 InternalName, NULL, &Name);
408 /* Print target name */
410 if (ACPI_SUCCESS (Status))
412 AcpiOsPrintf ("[%s]", Name);
416 AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]");
425 AcpiOsPrintf (" Namespace lookup failure, %s",
426 AcpiFormatException (LookupStatus));
429 ACPI_MSG_REDIRECT_END;
433 /*******************************************************************************
435 * FUNCTION: AcpiUtMethodError
437 * PARAMETERS: ModuleName - Caller's module name (for error output)
438 * LineNumber - Caller's line number (for error output)
439 * Message - Error message to use on failure
440 * PrefixNode - Prefix relative to the path
441 * Path - Path to the node (optional)
442 * MethodStatus - Execution status
446 * DESCRIPTION: Print error message with the full pathname for the method.
448 ******************************************************************************/
452 const char *ModuleName,
455 ACPI_NAMESPACE_NODE *PrefixNode,
457 ACPI_STATUS MethodStatus)
460 ACPI_NAMESPACE_NODE *Node = PrefixNode;
463 ACPI_MSG_REDIRECT_BEGIN;
464 AcpiOsPrintf (ACPI_MSG_ERROR);
468 Status = AcpiNsGetNode (PrefixNode, Path, ACPI_NS_NO_UPSEARCH,
470 if (ACPI_FAILURE (Status))
472 AcpiOsPrintf ("[Could not get node by pathname]");
476 AcpiNsPrintNodePathname (Node, Message);
477 AcpiOsPrintf (", %s", AcpiFormatException (MethodStatus));
480 ACPI_MSG_REDIRECT_END;
483 #endif /* ACPI_NO_ERROR_MESSAGES */