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 #include <acpi/acpi.h>
48 #define _COMPONENT ACPI_UTILITIES
49 ACPI_MODULE_NAME("utxferror")
52 * This module is used for the in-kernel ACPICA as well as the ACPICA
55 * For the i_aSL compiler case, the output is redirected to stderr so that
56 * any of the various ACPI errors and warnings do not appear in the output
57 * files, for either the compiler or disassembler portions of the tool.
59 #ifdef ACPI_ASL_COMPILER
61 extern FILE *acpi_gbl_output_file
;
63 #define ACPI_MSG_REDIRECT_BEGIN \
64 FILE *output_file = acpi_gbl_output_file; \
65 acpi_os_redirect_output (stderr);
67 #define ACPI_MSG_REDIRECT_END \
68 acpi_os_redirect_output (output_file);
72 * non-i_aSL case - no redirection, nothing to do
74 #define ACPI_MSG_REDIRECT_BEGIN
75 #define ACPI_MSG_REDIRECT_END
78 * Common message prefixes
80 #define ACPI_MSG_ERROR "ACPI Error: "
81 #define ACPI_MSG_EXCEPTION "ACPI Exception: "
82 #define ACPI_MSG_WARNING "ACPI Warning: "
83 #define ACPI_MSG_INFO "ACPI: "
85 * Common message suffix
87 #define ACPI_MSG_SUFFIX \
88 acpi_os_printf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, module_name, line_number)
89 /*******************************************************************************
91 * FUNCTION: acpi_error
93 * PARAMETERS: module_name - Caller's module name (for error output)
94 * line_number - Caller's line number (for error output)
95 * Format - Printf format string + additional args
99 * DESCRIPTION: Print "ACPI Error" message with module/line/version info
101 ******************************************************************************/
102 void ACPI_INTERNAL_VAR_XFACE
103 acpi_error(const char *module_name
, u32 line_number
, const char *format
, ...)
107 ACPI_MSG_REDIRECT_BEGIN
;
108 acpi_os_printf(ACPI_MSG_ERROR
);
110 va_start(arg_list
, format
);
111 acpi_os_vprintf(format
, arg_list
);
115 ACPI_MSG_REDIRECT_END
;
118 ACPI_EXPORT_SYMBOL(acpi_error
)
120 /*******************************************************************************
122 * FUNCTION: acpi_exception
124 * PARAMETERS: module_name - Caller's module name (for error output)
125 * line_number - Caller's line number (for error output)
126 * Status - Status to be formatted
127 * Format - Printf format string + additional args
131 * DESCRIPTION: Print "ACPI Exception" message with module/line/version info
132 * and decoded acpi_status.
134 ******************************************************************************/
135 void ACPI_INTERNAL_VAR_XFACE
136 acpi_exception(const char *module_name
,
137 u32 line_number
, acpi_status status
, const char *format
, ...)
141 ACPI_MSG_REDIRECT_BEGIN
;
142 acpi_os_printf(ACPI_MSG_EXCEPTION
"%s, ",
143 acpi_format_exception(status
));
145 va_start(arg_list
, format
);
146 acpi_os_vprintf(format
, arg_list
);
150 ACPI_MSG_REDIRECT_END
;
153 ACPI_EXPORT_SYMBOL(acpi_exception
)
155 /*******************************************************************************
157 * FUNCTION: acpi_warning
159 * PARAMETERS: module_name - Caller's module name (for error output)
160 * line_number - Caller's line number (for error output)
161 * Format - Printf format string + additional args
165 * DESCRIPTION: Print "ACPI Warning" message with module/line/version info
167 ******************************************************************************/
168 void ACPI_INTERNAL_VAR_XFACE
169 acpi_warning(const char *module_name
, u32 line_number
, const char *format
, ...)
173 ACPI_MSG_REDIRECT_BEGIN
;
174 acpi_os_printf(ACPI_MSG_WARNING
);
176 va_start(arg_list
, format
);
177 acpi_os_vprintf(format
, arg_list
);
181 ACPI_MSG_REDIRECT_END
;
184 ACPI_EXPORT_SYMBOL(acpi_warning
)
186 /*******************************************************************************
188 * FUNCTION: acpi_info
190 * PARAMETERS: module_name - Caller's module name (for error output)
191 * line_number - Caller's line number (for error output)
192 * Format - Printf format string + additional args
196 * DESCRIPTION: Print generic "ACPI:" information message. There is no
197 * module/line/version info in order to keep the message simple.
199 * TBD: module_name and line_number args are not needed, should be removed.
201 ******************************************************************************/
202 void ACPI_INTERNAL_VAR_XFACE
203 acpi_info(const char *module_name
, u32 line_number
, const char *format
, ...)
207 ACPI_MSG_REDIRECT_BEGIN
;
208 acpi_os_printf(ACPI_MSG_INFO
);
210 va_start(arg_list
, format
);
211 acpi_os_vprintf(format
, arg_list
);
212 acpi_os_printf("\n");
215 ACPI_MSG_REDIRECT_END
;
218 ACPI_EXPORT_SYMBOL(acpi_info
)
221 * The remainder of this module contains internal error functions that may
224 #if !defined (ACPI_NO_ERROR_MESSAGES) && !defined (ACPI_BIN_APP)
225 /*******************************************************************************
227 * FUNCTION: acpi_ut_predefined_warning
229 * PARAMETERS: module_name - Caller's module name (for error output)
230 * line_number - Caller's line number (for error output)
231 * Pathname - Full pathname to the node
232 * node_flags - From Namespace node for the method/object
233 * Format - Printf format string + additional args
237 * DESCRIPTION: Warnings for the predefined validation module. Messages are
238 * only emitted the first time a problem with a particular
239 * method/object is detected. This prevents a flood of error
240 * messages for methods that are repeatedly evaluated.
242 ******************************************************************************/
243 void ACPI_INTERNAL_VAR_XFACE
244 acpi_ut_predefined_warning(const char *module_name
,
247 u8 node_flags
, const char *format
, ...)
252 * Warning messages for this method/object will be disabled after the
253 * first time a validation fails or an object is successfully repaired.
255 if (node_flags
& ANOBJ_EVALUATED
) {
259 acpi_os_printf(ACPI_MSG_WARNING
"For %s: ", pathname
);
261 va_start(arg_list
, format
);
262 acpi_os_vprintf(format
, arg_list
);
267 /*******************************************************************************
269 * FUNCTION: acpi_ut_predefined_info
271 * PARAMETERS: module_name - Caller's module name (for error output)
272 * line_number - Caller's line number (for error output)
273 * Pathname - Full pathname to the node
274 * node_flags - From Namespace node for the method/object
275 * Format - Printf format string + additional args
279 * DESCRIPTION: Info messages for the predefined validation module. Messages
280 * are only emitted the first time a problem with a particular
281 * method/object is detected. This prevents a flood of
282 * messages for methods that are repeatedly evaluated.
284 ******************************************************************************/
286 void ACPI_INTERNAL_VAR_XFACE
287 acpi_ut_predefined_info(const char *module_name
,
289 char *pathname
, u8 node_flags
, const char *format
, ...)
294 * Warning messages for this method/object will be disabled after the
295 * first time a validation fails or an object is successfully repaired.
297 if (node_flags
& ANOBJ_EVALUATED
) {
301 acpi_os_printf(ACPI_MSG_INFO
"For %s: ", pathname
);
303 va_start(arg_list
, format
);
304 acpi_os_vprintf(format
, arg_list
);
309 /*******************************************************************************
311 * FUNCTION: acpi_ut_namespace_error
313 * PARAMETERS: module_name - Caller's module name (for error output)
314 * line_number - Caller's line number (for error output)
315 * internal_name - Name or path of the namespace node
316 * lookup_status - Exception code from NS lookup
320 * DESCRIPTION: Print error message with the full pathname for the NS node.
322 ******************************************************************************/
325 acpi_ut_namespace_error(const char *module_name
,
327 const char *internal_name
, acpi_status lookup_status
)
333 ACPI_MSG_REDIRECT_BEGIN
;
334 acpi_os_printf(ACPI_MSG_ERROR
);
336 if (lookup_status
== AE_BAD_CHARACTER
) {
338 /* There is a non-ascii character in the name */
340 ACPI_MOVE_32_TO_32(&bad_name
,
341 ACPI_CAST_PTR(u32
, internal_name
));
342 acpi_os_printf("[0x%4.4X] (NON-ASCII)", bad_name
);
344 /* Convert path to external format */
346 status
= acpi_ns_externalize_name(ACPI_UINT32_MAX
,
347 internal_name
, NULL
, &name
);
349 /* Print target name */
351 if (ACPI_SUCCESS(status
)) {
352 acpi_os_printf("[%s]", name
);
354 acpi_os_printf("[COULD NOT EXTERNALIZE NAME]");
362 acpi_os_printf(" Namespace lookup failure, %s",
363 acpi_format_exception(lookup_status
));
366 ACPI_MSG_REDIRECT_END
;
369 /*******************************************************************************
371 * FUNCTION: acpi_ut_method_error
373 * PARAMETERS: module_name - Caller's module name (for error output)
374 * line_number - Caller's line number (for error output)
375 * Message - Error message to use on failure
376 * prefix_node - Prefix relative to the path
377 * Path - Path to the node (optional)
378 * method_status - Execution status
382 * DESCRIPTION: Print error message with the full pathname for the method.
384 ******************************************************************************/
387 acpi_ut_method_error(const char *module_name
,
390 struct acpi_namespace_node
*prefix_node
,
391 const char *path
, acpi_status method_status
)
394 struct acpi_namespace_node
*node
= prefix_node
;
396 ACPI_MSG_REDIRECT_BEGIN
;
397 acpi_os_printf(ACPI_MSG_ERROR
);
401 acpi_ns_get_node(prefix_node
, path
, ACPI_NS_NO_UPSEARCH
,
403 if (ACPI_FAILURE(status
)) {
404 acpi_os_printf("[Could not get node by pathname]");
408 acpi_ns_print_node_pathname(node
, message
);
409 acpi_os_printf(", %s", acpi_format_exception(method_status
));
412 ACPI_MSG_REDIRECT_END
;
415 #endif /* ACPI_NO_ERROR_MESSAGES */