Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
utxferror.c
Go to the documentation of this file.
1 /*******************************************************************************
2  *
3  * Module Name: utxferror - Various error/warning output functions
4  *
5  ******************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2012, 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 #include <linux/export.h>
45 #include <acpi/acpi.h>
46 #include "accommon.h"
47 #include "acnamesp.h"
48 
49 #define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME("utxferror")
51 
52 /*
53  * This module is used for the in-kernel ACPICA as well as the ACPICA
54  * tools/applications.
55  *
56  * For the iASL compiler case, the output is redirected to stderr so that
57  * any of the various ACPI errors and warnings do not appear in the output
58  * files, for either the compiler or disassembler portions of the tool.
59  */
60 #ifdef ACPI_ASL_COMPILER
61 #include <stdio.h>
62 extern FILE *acpi_gbl_output_file;
63 
64 #define ACPI_MSG_REDIRECT_BEGIN \
65  FILE *output_file = acpi_gbl_output_file; \
66  acpi_os_redirect_output (stderr);
67 
68 #define ACPI_MSG_REDIRECT_END \
69  acpi_os_redirect_output (output_file);
70 
71 #else
72 /*
73  * non-iASL case - no redirection, nothing to do
74  */
75 #define ACPI_MSG_REDIRECT_BEGIN
76 #define ACPI_MSG_REDIRECT_END
77 #endif
78 /*
79  * Common message prefixes
80  */
81 #define ACPI_MSG_ERROR "ACPI Error: "
82 #define ACPI_MSG_EXCEPTION "ACPI Exception: "
83 #define ACPI_MSG_WARNING "ACPI Warning: "
84 #define ACPI_MSG_INFO "ACPI: "
85 #define ACPI_MSG_BIOS_ERROR "ACPI BIOS Bug: Error: "
86 #define ACPI_MSG_BIOS_WARNING "ACPI BIOS Bug: Warning: "
87 /*
88  * Common message suffix
89  */
90 #define ACPI_MSG_SUFFIX \
91  acpi_os_printf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, module_name, line_number)
92 /*******************************************************************************
93  *
94  * FUNCTION: acpi_error
95  *
96  * PARAMETERS: module_name - Caller's module name (for error output)
97  * line_number - Caller's line number (for error output)
98  * format - Printf format string + additional args
99  *
100  * RETURN: None
101  *
102  * DESCRIPTION: Print "ACPI Error" message with module/line/version info
103  *
104  ******************************************************************************/
106 acpi_error(const char *module_name, u32 line_number, const char *format, ...)
107 {
108  va_list arg_list;
109 
112 
113  va_start(arg_list, format);
114  acpi_os_vprintf(format, arg_list);
116  va_end(arg_list);
117 
119 }
120 
122 
123 /*******************************************************************************
124  *
125  * FUNCTION: acpi_exception
126  *
127  * PARAMETERS: module_name - Caller's module name (for error output)
128  * line_number - Caller's line number (for error output)
129  * status - Status to be formatted
130  * format - Printf format string + additional args
131  *
132  * RETURN: None
133  *
134  * DESCRIPTION: Print "ACPI Exception" message with module/line/version info
135  * and decoded acpi_status.
136  *
137  ******************************************************************************/
140  u32 line_number, acpi_status status, const char *format, ...)
141 {
142  va_list arg_list;
143 
146  acpi_format_exception(status));
147 
148  va_start(arg_list, format);
149  acpi_os_vprintf(format, arg_list);
151  va_end(arg_list);
152 
154 }
155 
157 
158 /*******************************************************************************
159  *
160  * FUNCTION: acpi_warning
161  *
162  * PARAMETERS: module_name - Caller's module name (for error output)
163  * line_number - Caller's line number (for error output)
164  * format - Printf format string + additional args
165  *
166  * RETURN: None
167  *
168  * DESCRIPTION: Print "ACPI Warning" message with module/line/version info
169  *
170  ******************************************************************************/
172 acpi_warning(const char *module_name, u32 line_number, const char *format, ...)
173 {
174  va_list arg_list;
175 
178 
179  va_start(arg_list, format);
180  acpi_os_vprintf(format, arg_list);
182  va_end(arg_list);
183 
185 }
186 
188 
189 /*******************************************************************************
190  *
191  * FUNCTION: acpi_info
192  *
193  * PARAMETERS: module_name - Caller's module name (for error output)
194  * line_number - Caller's line number (for error output)
195  * format - Printf format string + additional args
196  *
197  * RETURN: None
198  *
199  * DESCRIPTION: Print generic "ACPI:" information message. There is no
200  * module/line/version info in order to keep the message simple.
201  *
202  * TBD: module_name and line_number args are not needed, should be removed.
203  *
204  ******************************************************************************/
206 acpi_info(const char *module_name, u32 line_number, const char *format, ...)
207 {
208  va_list arg_list;
209 
212 
213  va_start(arg_list, format);
214  acpi_os_vprintf(format, arg_list);
215  acpi_os_printf("\n");
216  va_end(arg_list);
217 
219 }
220 
222 
223 /*******************************************************************************
224  *
225  * FUNCTION: acpi_bios_error
226  *
227  * PARAMETERS: module_name - Caller's module name (for error output)
228  * line_number - Caller's line number (for error output)
229  * format - Printf format string + additional args
230  *
231  * RETURN: None
232  *
233  * DESCRIPTION: Print "ACPI Firmware Error" message with module/line/version
234  * info
235  *
236  ******************************************************************************/
239  u32 line_number, const char *format, ...)
240 {
241  va_list arg_list;
242 
245 
246  va_start(arg_list, format);
247  acpi_os_vprintf(format, arg_list);
249  va_end(arg_list);
250 
252 }
253 
255 
256 /*******************************************************************************
257  *
258  * FUNCTION: acpi_bios_warning
259  *
260  * PARAMETERS: module_name - Caller's module name (for error output)
261  * line_number - Caller's line number (for error output)
262  * format - Printf format string + additional args
263  *
264  * RETURN: None
265  *
266  * DESCRIPTION: Print "ACPI Firmware Warning" message with module/line/version
267  * info
268  *
269  ******************************************************************************/
272  u32 line_number, const char *format, ...)
273 {
274  va_list arg_list;
275 
278 
279  va_start(arg_list, format);
280  acpi_os_vprintf(format, arg_list);
282  va_end(arg_list);
283 
285 }
286 
288 
289 /*
290  * The remainder of this module contains internal error functions that may
291  * be configured out.
292  */
293 #if !defined (ACPI_NO_ERROR_MESSAGES) && !defined (ACPI_BIN_APP)
294 /*******************************************************************************
295  *
296  * FUNCTION: acpi_ut_predefined_warning
297  *
298  * PARAMETERS: module_name - Caller's module name (for error output)
299  * line_number - Caller's line number (for error output)
300  * Pathname - Full pathname to the node
301  * node_flags - From Namespace node for the method/object
302  * Format - Printf format string + additional args
303  *
304  * RETURN: None
305  *
306  * DESCRIPTION: Warnings for the predefined validation module. Messages are
307  * only emitted the first time a problem with a particular
308  * method/object is detected. This prevents a flood of error
309  * messages for methods that are repeatedly evaluated.
310  *
311  ******************************************************************************/
314  u32 line_number,
315  char *pathname,
316  u8 node_flags, const char *format, ...)
317 {
318  va_list arg_list;
319 
320  /*
321  * Warning messages for this method/object will be disabled after the
322  * first time a validation fails or an object is successfully repaired.
323  */
324  if (node_flags & ANOBJ_EVALUATED) {
325  return;
326  }
327 
328  acpi_os_printf(ACPI_MSG_WARNING "For %s: ", pathname);
329 
330  va_start(arg_list, format);
331  acpi_os_vprintf(format, arg_list);
333  va_end(arg_list);
334 }
335 
336 /*******************************************************************************
337  *
338  * FUNCTION: acpi_ut_predefined_info
339  *
340  * PARAMETERS: module_name - Caller's module name (for error output)
341  * line_number - Caller's line number (for error output)
342  * pathname - Full pathname to the node
343  * node_flags - From Namespace node for the method/object
344  * format - Printf format string + additional args
345  *
346  * RETURN: None
347  *
348  * DESCRIPTION: Info messages for the predefined validation module. Messages
349  * are only emitted the first time a problem with a particular
350  * method/object is detected. This prevents a flood of
351  * messages for methods that are repeatedly evaluated.
352  *
353  ******************************************************************************/
354 
357  u32 line_number,
358  char *pathname, u8 node_flags, const char *format, ...)
359 {
360  va_list arg_list;
361 
362  /*
363  * Warning messages for this method/object will be disabled after the
364  * first time a validation fails or an object is successfully repaired.
365  */
366  if (node_flags & ANOBJ_EVALUATED) {
367  return;
368  }
369 
370  acpi_os_printf(ACPI_MSG_INFO "For %s: ", pathname);
371 
372  va_start(arg_list, format);
373  acpi_os_vprintf(format, arg_list);
375  va_end(arg_list);
376 }
377 
378 /*******************************************************************************
379  *
380  * FUNCTION: acpi_ut_namespace_error
381  *
382  * PARAMETERS: module_name - Caller's module name (for error output)
383  * line_number - Caller's line number (for error output)
384  * internal_name - Name or path of the namespace node
385  * lookup_status - Exception code from NS lookup
386  *
387  * RETURN: None
388  *
389  * DESCRIPTION: Print error message with the full pathname for the NS node.
390  *
391  ******************************************************************************/
392 
393 void
395  u32 line_number,
396  const char *internal_name, acpi_status lookup_status)
397 {
399  u32 bad_name;
400  char *name = NULL;
401 
404 
405  if (lookup_status == AE_BAD_CHARACTER) {
406 
407  /* There is a non-ascii character in the name */
408 
409  ACPI_MOVE_32_TO_32(&bad_name,
410  ACPI_CAST_PTR(u32, internal_name));
411  acpi_os_printf("[0x%4.4X] (NON-ASCII)", bad_name);
412  } else {
413  /* Convert path to external format */
414 
416  internal_name, NULL, &name);
417 
418  /* Print target name */
419 
420  if (ACPI_SUCCESS(status)) {
421  acpi_os_printf("[%s]", name);
422  } else {
423  acpi_os_printf("[COULD NOT EXTERNALIZE NAME]");
424  }
425 
426  if (name) {
427  ACPI_FREE(name);
428  }
429  }
430 
431  acpi_os_printf(" Namespace lookup failure, %s",
432  acpi_format_exception(lookup_status));
433 
436 }
437 
438 /*******************************************************************************
439  *
440  * FUNCTION: acpi_ut_method_error
441  *
442  * PARAMETERS: module_name - Caller's module name (for error output)
443  * line_number - Caller's line number (for error output)
444  * message - Error message to use on failure
445  * prefix_node - Prefix relative to the path
446  * path - Path to the node (optional)
447  * method_status - Execution status
448  *
449  * RETURN: None
450  *
451  * DESCRIPTION: Print error message with the full pathname for the method.
452  *
453  ******************************************************************************/
454 
455 void
457  u32 line_number,
458  const char *message,
459  struct acpi_namespace_node *prefix_node,
460  const char *path, acpi_status method_status)
461 {
463  struct acpi_namespace_node *node = prefix_node;
464 
467 
468  if (path) {
469  status =
470  acpi_ns_get_node(prefix_node, path, ACPI_NS_NO_UPSEARCH,
471  &node);
472  if (ACPI_FAILURE(status)) {
473  acpi_os_printf("[Could not get node by pathname]");
474  }
475  }
476 
477  acpi_ns_print_node_pathname(node, message);
478  acpi_os_printf(", %s", acpi_format_exception(method_status));
479 
482 }
483 
484 #endif /* ACPI_NO_ERROR_MESSAGES */