uterror.c 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /*******************************************************************************
  3. *
  4. * Module Name: uterror - Various internal error/warning output functions
  5. *
  6. ******************************************************************************/
  7. #include <acpi/acpi.h>
  8. #include "accommon.h"
  9. #include "acnamesp.h"
  10. #define _COMPONENT ACPI_UTILITIES
  11. ACPI_MODULE_NAME("uterror")
  12. /*
  13. * This module contains internal error functions that may
  14. * be configured out.
  15. */
  16. #if !defined (ACPI_NO_ERROR_MESSAGES)
  17. /*******************************************************************************
  18. *
  19. * FUNCTION: acpi_ut_predefined_warning
  20. *
  21. * PARAMETERS: module_name - Caller's module name (for error output)
  22. * line_number - Caller's line number (for error output)
  23. * pathname - Full pathname to the node
  24. * node_flags - From Namespace node for the method/object
  25. * format - Printf format string + additional args
  26. *
  27. * RETURN: None
  28. *
  29. * DESCRIPTION: Warnings for the predefined validation module. Messages are
  30. * only emitted the first time a problem with a particular
  31. * method/object is detected. This prevents a flood of error
  32. * messages for methods that are repeatedly evaluated.
  33. *
  34. ******************************************************************************/
  35. void ACPI_INTERNAL_VAR_XFACE
  36. acpi_ut_predefined_warning(const char *module_name,
  37. u32 line_number,
  38. char *pathname,
  39. u16 node_flags, const char *format, ...)
  40. {
  41. va_list arg_list;
  42. /*
  43. * Warning messages for this method/object will be disabled after the
  44. * first time a validation fails or an object is successfully repaired.
  45. */
  46. if (node_flags & ANOBJ_EVALUATED) {
  47. return;
  48. }
  49. acpi_os_printf(ACPI_MSG_WARNING "%s: ", pathname);
  50. va_start(arg_list, format);
  51. acpi_os_vprintf(format, arg_list);
  52. ACPI_MSG_SUFFIX;
  53. va_end(arg_list);
  54. }
  55. /*******************************************************************************
  56. *
  57. * FUNCTION: acpi_ut_predefined_info
  58. *
  59. * PARAMETERS: module_name - Caller's module name (for error output)
  60. * line_number - Caller's line number (for error output)
  61. * pathname - Full pathname to the node
  62. * node_flags - From Namespace node for the method/object
  63. * format - Printf format string + additional args
  64. *
  65. * RETURN: None
  66. *
  67. * DESCRIPTION: Info messages for the predefined validation module. Messages
  68. * are only emitted the first time a problem with a particular
  69. * method/object is detected. This prevents a flood of
  70. * messages for methods that are repeatedly evaluated.
  71. *
  72. ******************************************************************************/
  73. void ACPI_INTERNAL_VAR_XFACE
  74. acpi_ut_predefined_info(const char *module_name,
  75. u32 line_number,
  76. char *pathname, u16 node_flags, const char *format, ...)
  77. {
  78. va_list arg_list;
  79. /*
  80. * Warning messages for this method/object will be disabled after the
  81. * first time a validation fails or an object is successfully repaired.
  82. */
  83. if (node_flags & ANOBJ_EVALUATED) {
  84. return;
  85. }
  86. acpi_os_printf(ACPI_MSG_INFO "%s: ", pathname);
  87. va_start(arg_list, format);
  88. acpi_os_vprintf(format, arg_list);
  89. ACPI_MSG_SUFFIX;
  90. va_end(arg_list);
  91. }
  92. /*******************************************************************************
  93. *
  94. * FUNCTION: acpi_ut_predefined_bios_error
  95. *
  96. * PARAMETERS: module_name - Caller's module name (for error output)
  97. * line_number - Caller's line number (for error output)
  98. * pathname - Full pathname to the node
  99. * node_flags - From Namespace node for the method/object
  100. * format - Printf format string + additional args
  101. *
  102. * RETURN: None
  103. *
  104. * DESCRIPTION: BIOS error message for predefined names. Messages
  105. * are only emitted the first time a problem with a particular
  106. * method/object is detected. This prevents a flood of
  107. * messages for methods that are repeatedly evaluated.
  108. *
  109. ******************************************************************************/
  110. void ACPI_INTERNAL_VAR_XFACE
  111. acpi_ut_predefined_bios_error(const char *module_name,
  112. u32 line_number,
  113. char *pathname,
  114. u16 node_flags, const char *format, ...)
  115. {
  116. va_list arg_list;
  117. /*
  118. * Warning messages for this method/object will be disabled after the
  119. * first time a validation fails or an object is successfully repaired.
  120. */
  121. if (node_flags & ANOBJ_EVALUATED) {
  122. return;
  123. }
  124. acpi_os_printf(ACPI_MSG_BIOS_ERROR "%s: ", pathname);
  125. va_start(arg_list, format);
  126. acpi_os_vprintf(format, arg_list);
  127. ACPI_MSG_SUFFIX;
  128. va_end(arg_list);
  129. }
  130. /*******************************************************************************
  131. *
  132. * FUNCTION: acpi_ut_prefixed_namespace_error
  133. *
  134. * PARAMETERS: module_name - Caller's module name (for error output)
  135. * line_number - Caller's line number (for error output)
  136. * prefix_scope - Scope/Path that prefixes the internal path
  137. * internal_path - Name or path of the namespace node
  138. * lookup_status - Exception code from NS lookup
  139. *
  140. * RETURN: None
  141. *
  142. * DESCRIPTION: Print error message with the full pathname constructed this way:
  143. *
  144. * prefix_scope_node_full_path.externalized_internal_path
  145. *
  146. * NOTE: 10/2017: Treat the major ns_lookup errors as firmware errors
  147. *
  148. ******************************************************************************/
  149. void
  150. acpi_ut_prefixed_namespace_error(const char *module_name,
  151. u32 line_number,
  152. union acpi_generic_state *prefix_scope,
  153. const char *internal_path,
  154. acpi_status lookup_status)
  155. {
  156. char *full_path;
  157. const char *message;
  158. /*
  159. * Main cases:
  160. * 1) Object creation, object must not already exist
  161. * 2) Object lookup, object must exist
  162. */
  163. switch (lookup_status) {
  164. case AE_ALREADY_EXISTS:
  165. acpi_os_printf(ACPI_MSG_BIOS_ERROR);
  166. message = "Failure creating named object";
  167. break;
  168. case AE_NOT_FOUND:
  169. acpi_os_printf(ACPI_MSG_BIOS_ERROR);
  170. message = "Could not resolve symbol";
  171. break;
  172. default:
  173. acpi_os_printf(ACPI_MSG_ERROR);
  174. message = "Failure resolving symbol";
  175. break;
  176. }
  177. /* Concatenate the prefix path and the internal path */
  178. full_path =
  179. acpi_ns_build_prefixed_pathname(prefix_scope, internal_path);
  180. acpi_os_printf("%s [%s], %s", message,
  181. full_path ? full_path : "Could not get pathname",
  182. acpi_format_exception(lookup_status));
  183. if (full_path) {
  184. ACPI_FREE(full_path);
  185. }
  186. ACPI_MSG_SUFFIX;
  187. }
  188. #ifdef __OBSOLETE_FUNCTION
  189. /*******************************************************************************
  190. *
  191. * FUNCTION: acpi_ut_namespace_error
  192. *
  193. * PARAMETERS: module_name - Caller's module name (for error output)
  194. * line_number - Caller's line number (for error output)
  195. * internal_name - Name or path of the namespace node
  196. * lookup_status - Exception code from NS lookup
  197. *
  198. * RETURN: None
  199. *
  200. * DESCRIPTION: Print error message with the full pathname for the NS node.
  201. *
  202. ******************************************************************************/
  203. void
  204. acpi_ut_namespace_error(const char *module_name,
  205. u32 line_number,
  206. const char *internal_name, acpi_status lookup_status)
  207. {
  208. acpi_status status;
  209. u32 bad_name;
  210. char *name = NULL;
  211. ACPI_MSG_REDIRECT_BEGIN;
  212. acpi_os_printf(ACPI_MSG_ERROR);
  213. if (lookup_status == AE_BAD_CHARACTER) {
  214. /* There is a non-ascii character in the name */
  215. ACPI_MOVE_32_TO_32(&bad_name,
  216. ACPI_CAST_PTR(u32, internal_name));
  217. acpi_os_printf("[0x%.8X] (NON-ASCII)", bad_name);
  218. } else {
  219. /* Convert path to external format */
  220. status =
  221. acpi_ns_externalize_name(ACPI_UINT32_MAX, internal_name,
  222. NULL, &name);
  223. /* Print target name */
  224. if (ACPI_SUCCESS(status)) {
  225. acpi_os_printf("[%s]", name);
  226. } else {
  227. acpi_os_printf("[COULD NOT EXTERNALIZE NAME]");
  228. }
  229. if (name) {
  230. ACPI_FREE(name);
  231. }
  232. }
  233. acpi_os_printf(" Namespace lookup failure, %s",
  234. acpi_format_exception(lookup_status));
  235. ACPI_MSG_SUFFIX;
  236. ACPI_MSG_REDIRECT_END;
  237. }
  238. #endif
  239. /*******************************************************************************
  240. *
  241. * FUNCTION: acpi_ut_method_error
  242. *
  243. * PARAMETERS: module_name - Caller's module name (for error output)
  244. * line_number - Caller's line number (for error output)
  245. * message - Error message to use on failure
  246. * prefix_node - Prefix relative to the path
  247. * path - Path to the node (optional)
  248. * method_status - Execution status
  249. *
  250. * RETURN: None
  251. *
  252. * DESCRIPTION: Print error message with the full pathname for the method.
  253. *
  254. ******************************************************************************/
  255. void
  256. acpi_ut_method_error(const char *module_name,
  257. u32 line_number,
  258. const char *message,
  259. struct acpi_namespace_node *prefix_node,
  260. const char *path, acpi_status method_status)
  261. {
  262. acpi_status status;
  263. struct acpi_namespace_node *node = prefix_node;
  264. ACPI_MSG_REDIRECT_BEGIN;
  265. acpi_os_printf(ACPI_MSG_ERROR);
  266. if (path) {
  267. status = acpi_ns_get_node(prefix_node, path,
  268. ACPI_NS_NO_UPSEARCH, &node);
  269. if (ACPI_FAILURE(status)) {
  270. acpi_os_printf("[Could not get node by pathname]");
  271. }
  272. }
  273. acpi_ns_print_node_pathname(node, message);
  274. acpi_os_printf(" due to previous error (%s)",
  275. acpi_format_exception(method_status));
  276. ACPI_MSG_SUFFIX;
  277. ACPI_MSG_REDIRECT_END;
  278. }
  279. #endif /* ACPI_NO_ERROR_MESSAGES */