utxferror.c 15 KB

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