utxferror.c 13 KB

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