uterror.c 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /*******************************************************************************
  2. *
  3. * Module Name: uterror - Various internal error/warning output functions
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2015, 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("uterror")
  47. /*
  48. * This module contains internal error functions that may
  49. * be configured out.
  50. */
  51. #if !defined (ACPI_NO_ERROR_MESSAGES)
  52. /*******************************************************************************
  53. *
  54. * FUNCTION: acpi_ut_predefined_warning
  55. *
  56. * PARAMETERS: module_name - Caller's module name (for error output)
  57. * line_number - Caller's line number (for error output)
  58. * pathname - Full pathname to the node
  59. * node_flags - From Namespace node for the method/object
  60. * format - Printf format string + additional args
  61. *
  62. * RETURN: None
  63. *
  64. * DESCRIPTION: Warnings for the predefined validation module. Messages are
  65. * only emitted the first time a problem with a particular
  66. * method/object is detected. This prevents a flood of error
  67. * messages for methods that are repeatedly evaluated.
  68. *
  69. ******************************************************************************/
  70. void ACPI_INTERNAL_VAR_XFACE
  71. acpi_ut_predefined_warning(const char *module_name,
  72. u32 line_number,
  73. char *pathname,
  74. u8 node_flags, const char *format, ...)
  75. {
  76. va_list arg_list;
  77. /*
  78. * Warning messages for this method/object will be disabled after the
  79. * first time a validation fails or an object is successfully repaired.
  80. */
  81. if (node_flags & ANOBJ_EVALUATED) {
  82. return;
  83. }
  84. acpi_os_printf(ACPI_MSG_WARNING "%s: ", pathname);
  85. va_start(arg_list, format);
  86. acpi_os_vprintf(format, arg_list);
  87. ACPI_MSG_SUFFIX;
  88. va_end(arg_list);
  89. }
  90. /*******************************************************************************
  91. *
  92. * FUNCTION: acpi_ut_predefined_info
  93. *
  94. * PARAMETERS: module_name - Caller's module name (for error output)
  95. * line_number - Caller's line number (for error output)
  96. * pathname - Full pathname to the node
  97. * node_flags - From Namespace node for the method/object
  98. * format - Printf format string + additional args
  99. *
  100. * RETURN: None
  101. *
  102. * DESCRIPTION: Info messages for the predefined validation module. Messages
  103. * are only emitted the first time a problem with a particular
  104. * method/object is detected. This prevents a flood of
  105. * messages for methods that are repeatedly evaluated.
  106. *
  107. ******************************************************************************/
  108. void ACPI_INTERNAL_VAR_XFACE
  109. acpi_ut_predefined_info(const char *module_name,
  110. u32 line_number,
  111. char *pathname, u8 node_flags, const char *format, ...)
  112. {
  113. va_list arg_list;
  114. /*
  115. * Warning messages for this method/object will be disabled after the
  116. * first time a validation fails or an object is successfully repaired.
  117. */
  118. if (node_flags & ANOBJ_EVALUATED) {
  119. return;
  120. }
  121. acpi_os_printf(ACPI_MSG_INFO "%s: ", pathname);
  122. va_start(arg_list, format);
  123. acpi_os_vprintf(format, arg_list);
  124. ACPI_MSG_SUFFIX;
  125. va_end(arg_list);
  126. }
  127. /*******************************************************************************
  128. *
  129. * FUNCTION: acpi_ut_predefined_bios_error
  130. *
  131. * PARAMETERS: module_name - Caller's module name (for error output)
  132. * line_number - Caller's line number (for error output)
  133. * pathname - Full pathname to the node
  134. * node_flags - From Namespace node for the method/object
  135. * format - Printf format string + additional args
  136. *
  137. * RETURN: None
  138. *
  139. * DESCRIPTION: BIOS error message for predefined names. Messages
  140. * are only emitted the first time a problem with a particular
  141. * method/object is detected. This prevents a flood of
  142. * messages for methods that are repeatedly evaluated.
  143. *
  144. ******************************************************************************/
  145. void ACPI_INTERNAL_VAR_XFACE
  146. acpi_ut_predefined_bios_error(const char *module_name,
  147. u32 line_number,
  148. char *pathname,
  149. u8 node_flags, const char *format, ...)
  150. {
  151. va_list arg_list;
  152. /*
  153. * Warning messages for this method/object will be disabled after the
  154. * first time a validation fails or an object is successfully repaired.
  155. */
  156. if (node_flags & ANOBJ_EVALUATED) {
  157. return;
  158. }
  159. acpi_os_printf(ACPI_MSG_BIOS_ERROR "%s: ", pathname);
  160. va_start(arg_list, format);
  161. acpi_os_vprintf(format, arg_list);
  162. ACPI_MSG_SUFFIX;
  163. va_end(arg_list);
  164. }
  165. /*******************************************************************************
  166. *
  167. * FUNCTION: acpi_ut_namespace_error
  168. *
  169. * PARAMETERS: module_name - Caller's module name (for error output)
  170. * line_number - Caller's line number (for error output)
  171. * internal_name - Name or path of the namespace node
  172. * lookup_status - Exception code from NS lookup
  173. *
  174. * RETURN: None
  175. *
  176. * DESCRIPTION: Print error message with the full pathname for the NS node.
  177. *
  178. ******************************************************************************/
  179. void
  180. acpi_ut_namespace_error(const char *module_name,
  181. u32 line_number,
  182. const char *internal_name, acpi_status lookup_status)
  183. {
  184. acpi_status status;
  185. u32 bad_name;
  186. char *name = NULL;
  187. ACPI_MSG_REDIRECT_BEGIN;
  188. acpi_os_printf(ACPI_MSG_ERROR);
  189. if (lookup_status == AE_BAD_CHARACTER) {
  190. /* There is a non-ascii character in the name */
  191. ACPI_MOVE_32_TO_32(&bad_name,
  192. ACPI_CAST_PTR(u32, internal_name));
  193. acpi_os_printf("[0x%.8X] (NON-ASCII)", bad_name);
  194. } else {
  195. /* Convert path to external format */
  196. status = acpi_ns_externalize_name(ACPI_UINT32_MAX,
  197. internal_name, NULL, &name);
  198. /* Print target name */
  199. if (ACPI_SUCCESS(status)) {
  200. acpi_os_printf("[%s]", name);
  201. } else {
  202. acpi_os_printf("[COULD NOT EXTERNALIZE NAME]");
  203. }
  204. if (name) {
  205. ACPI_FREE(name);
  206. }
  207. }
  208. acpi_os_printf(" Namespace lookup failure, %s",
  209. acpi_format_exception(lookup_status));
  210. ACPI_MSG_SUFFIX;
  211. ACPI_MSG_REDIRECT_END;
  212. }
  213. /*******************************************************************************
  214. *
  215. * FUNCTION: acpi_ut_method_error
  216. *
  217. * PARAMETERS: module_name - Caller's module name (for error output)
  218. * line_number - Caller's line number (for error output)
  219. * message - Error message to use on failure
  220. * prefix_node - Prefix relative to the path
  221. * path - Path to the node (optional)
  222. * method_status - Execution status
  223. *
  224. * RETURN: None
  225. *
  226. * DESCRIPTION: Print error message with the full pathname for the method.
  227. *
  228. ******************************************************************************/
  229. void
  230. acpi_ut_method_error(const char *module_name,
  231. u32 line_number,
  232. const char *message,
  233. struct acpi_namespace_node *prefix_node,
  234. const char *path, acpi_status method_status)
  235. {
  236. acpi_status status;
  237. struct acpi_namespace_node *node = prefix_node;
  238. ACPI_MSG_REDIRECT_BEGIN;
  239. acpi_os_printf(ACPI_MSG_ERROR);
  240. if (path) {
  241. status =
  242. acpi_ns_get_node(prefix_node, path, ACPI_NS_NO_UPSEARCH,
  243. &node);
  244. if (ACPI_FAILURE(status)) {
  245. acpi_os_printf("[Could not get node by pathname]");
  246. }
  247. }
  248. acpi_ns_print_node_pathname(node, message);
  249. acpi_os_printf(", %s", acpi_format_exception(method_status));
  250. ACPI_MSG_SUFFIX;
  251. ACPI_MSG_REDIRECT_END;
  252. }
  253. #endif /* ACPI_NO_ERROR_MESSAGES */