PageRenderTime 44ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/sys/contrib/dev/acpica/utilities/utxferror.c

https://github.com/blacklion/GEOM-Events
C | 483 lines | 205 code | 81 blank | 197 comment | 10 complexity | 7bdbe1365c48f1ea0f9f5e8377ee9a55 MD5 | raw file
  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. #define __UTXFERROR_C__
  43. #include <contrib/dev/acpica/include/acpi.h>
  44. #include <contrib/dev/acpica/include/accommon.h>
  45. #include <contrib/dev/acpica/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 *AcpiGbl_OutputFile;
  59. #define ACPI_MSG_REDIRECT_BEGIN \
  60. FILE *OutputFile = AcpiGbl_OutputFile; \
  61. AcpiOsRedirectOutput (stderr);
  62. #define ACPI_MSG_REDIRECT_END \
  63. AcpiOsRedirectOutput (OutputFile);
  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. /*
  79. * Common message suffix
  80. */
  81. #define ACPI_MSG_SUFFIX \
  82. AcpiOsPrintf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, ModuleName, LineNumber)
  83. /*******************************************************************************
  84. *
  85. * FUNCTION: AcpiError
  86. *
  87. * PARAMETERS: ModuleName - Caller's module name (for error output)
  88. * LineNumber - Caller's line number (for error output)
  89. * Format - Printf format string + additional args
  90. *
  91. * RETURN: None
  92. *
  93. * DESCRIPTION: Print "ACPI Error" message with module/line/version info
  94. *
  95. ******************************************************************************/
  96. void ACPI_INTERNAL_VAR_XFACE
  97. AcpiError (
  98. const char *ModuleName,
  99. UINT32 LineNumber,
  100. const char *Format,
  101. ...)
  102. {
  103. va_list ArgList;
  104. ACPI_MSG_REDIRECT_BEGIN;
  105. AcpiOsPrintf (ACPI_MSG_ERROR);
  106. va_start (ArgList, Format);
  107. AcpiOsVprintf (Format, ArgList);
  108. ACPI_MSG_SUFFIX;
  109. va_end (ArgList);
  110. ACPI_MSG_REDIRECT_END;
  111. }
  112. ACPI_EXPORT_SYMBOL (AcpiError)
  113. /*******************************************************************************
  114. *
  115. * FUNCTION: AcpiException
  116. *
  117. * PARAMETERS: ModuleName - Caller's module name (for error output)
  118. * LineNumber - Caller's line number (for error output)
  119. * Status - Status to be formatted
  120. * Format - Printf format string + additional args
  121. *
  122. * RETURN: None
  123. *
  124. * DESCRIPTION: Print "ACPI Exception" message with module/line/version info
  125. * and decoded ACPI_STATUS.
  126. *
  127. ******************************************************************************/
  128. void ACPI_INTERNAL_VAR_XFACE
  129. AcpiException (
  130. const char *ModuleName,
  131. UINT32 LineNumber,
  132. ACPI_STATUS Status,
  133. const char *Format,
  134. ...)
  135. {
  136. va_list ArgList;
  137. ACPI_MSG_REDIRECT_BEGIN;
  138. AcpiOsPrintf (ACPI_MSG_EXCEPTION "%s, ", AcpiFormatException (Status));
  139. va_start (ArgList, Format);
  140. AcpiOsVprintf (Format, ArgList);
  141. ACPI_MSG_SUFFIX;
  142. va_end (ArgList);
  143. ACPI_MSG_REDIRECT_END;
  144. }
  145. ACPI_EXPORT_SYMBOL (AcpiException)
  146. /*******************************************************************************
  147. *
  148. * FUNCTION: AcpiWarning
  149. *
  150. * PARAMETERS: ModuleName - Caller's module name (for error output)
  151. * LineNumber - Caller's line number (for error output)
  152. * Format - Printf format string + additional args
  153. *
  154. * RETURN: None
  155. *
  156. * DESCRIPTION: Print "ACPI Warning" message with module/line/version info
  157. *
  158. ******************************************************************************/
  159. void ACPI_INTERNAL_VAR_XFACE
  160. AcpiWarning (
  161. const char *ModuleName,
  162. UINT32 LineNumber,
  163. const char *Format,
  164. ...)
  165. {
  166. va_list ArgList;
  167. ACPI_MSG_REDIRECT_BEGIN;
  168. AcpiOsPrintf (ACPI_MSG_WARNING);
  169. va_start (ArgList, Format);
  170. AcpiOsVprintf (Format, ArgList);
  171. ACPI_MSG_SUFFIX;
  172. va_end (ArgList);
  173. ACPI_MSG_REDIRECT_END;
  174. }
  175. ACPI_EXPORT_SYMBOL (AcpiWarning)
  176. /*******************************************************************************
  177. *
  178. * FUNCTION: AcpiInfo
  179. *
  180. * PARAMETERS: ModuleName - Caller's module name (for error output)
  181. * LineNumber - Caller's line number (for error output)
  182. * Format - Printf format string + additional args
  183. *
  184. * RETURN: None
  185. *
  186. * DESCRIPTION: Print generic "ACPI:" information message. There is no
  187. * module/line/version info in order to keep the message simple.
  188. *
  189. * TBD: ModuleName and LineNumber args are not needed, should be removed.
  190. *
  191. ******************************************************************************/
  192. void ACPI_INTERNAL_VAR_XFACE
  193. AcpiInfo (
  194. const char *ModuleName,
  195. UINT32 LineNumber,
  196. const char *Format,
  197. ...)
  198. {
  199. va_list ArgList;
  200. #ifdef _KERNEL
  201. /* Temporarily hide too verbose printfs. */
  202. if (!bootverbose)
  203. return;
  204. #endif
  205. ACPI_MSG_REDIRECT_BEGIN;
  206. AcpiOsPrintf (ACPI_MSG_INFO);
  207. va_start (ArgList, Format);
  208. AcpiOsVprintf (Format, ArgList);
  209. AcpiOsPrintf ("\n");
  210. va_end (ArgList);
  211. ACPI_MSG_REDIRECT_END;
  212. }
  213. ACPI_EXPORT_SYMBOL (AcpiInfo)
  214. /*
  215. * The remainder of this module contains internal error functions that may
  216. * be configured out.
  217. */
  218. #if !defined (ACPI_NO_ERROR_MESSAGES) && !defined (ACPI_BIN_APP)
  219. /*******************************************************************************
  220. *
  221. * FUNCTION: AcpiUtPredefinedWarning
  222. *
  223. * PARAMETERS: ModuleName - Caller's module name (for error output)
  224. * LineNumber - Caller's line number (for error output)
  225. * Pathname - Full pathname to the node
  226. * NodeFlags - From Namespace node for the method/object
  227. * Format - Printf format string + additional args
  228. *
  229. * RETURN: None
  230. *
  231. * DESCRIPTION: Warnings for the predefined validation module. Messages are
  232. * only emitted the first time a problem with a particular
  233. * method/object is detected. This prevents a flood of error
  234. * messages for methods that are repeatedly evaluated.
  235. *
  236. ******************************************************************************/
  237. void ACPI_INTERNAL_VAR_XFACE
  238. AcpiUtPredefinedWarning (
  239. const char *ModuleName,
  240. UINT32 LineNumber,
  241. char *Pathname,
  242. UINT8 NodeFlags,
  243. const char *Format,
  244. ...)
  245. {
  246. va_list ArgList;
  247. /*
  248. * Warning messages for this method/object will be disabled after the
  249. * first time a validation fails or an object is successfully repaired.
  250. */
  251. if (NodeFlags & ANOBJ_EVALUATED)
  252. {
  253. return;
  254. }
  255. AcpiOsPrintf (ACPI_MSG_WARNING "For %s: ", Pathname);
  256. va_start (ArgList, Format);
  257. AcpiOsVprintf (Format, ArgList);
  258. ACPI_MSG_SUFFIX;
  259. va_end (ArgList);
  260. }
  261. /*******************************************************************************
  262. *
  263. * FUNCTION: AcpiUtPredefinedInfo
  264. *
  265. * PARAMETERS: ModuleName - Caller's module name (for error output)
  266. * LineNumber - Caller's line number (for error output)
  267. * Pathname - Full pathname to the node
  268. * NodeFlags - From Namespace node for the method/object
  269. * Format - Printf format string + additional args
  270. *
  271. * RETURN: None
  272. *
  273. * DESCRIPTION: Info messages for the predefined validation module. Messages
  274. * are only emitted the first time a problem with a particular
  275. * method/object is detected. This prevents a flood of
  276. * messages for methods that are repeatedly evaluated.
  277. *
  278. ******************************************************************************/
  279. void ACPI_INTERNAL_VAR_XFACE
  280. AcpiUtPredefinedInfo (
  281. const char *ModuleName,
  282. UINT32 LineNumber,
  283. char *Pathname,
  284. UINT8 NodeFlags,
  285. const char *Format,
  286. ...)
  287. {
  288. va_list ArgList;
  289. /*
  290. * Warning messages for this method/object will be disabled after the
  291. * first time a validation fails or an object is successfully repaired.
  292. */
  293. if (NodeFlags & ANOBJ_EVALUATED)
  294. {
  295. return;
  296. }
  297. AcpiOsPrintf (ACPI_MSG_INFO "For %s: ", Pathname);
  298. va_start (ArgList, Format);
  299. AcpiOsVprintf (Format, ArgList);
  300. ACPI_MSG_SUFFIX;
  301. va_end (ArgList);
  302. }
  303. /*******************************************************************************
  304. *
  305. * FUNCTION: AcpiUtNamespaceError
  306. *
  307. * PARAMETERS: ModuleName - Caller's module name (for error output)
  308. * LineNumber - Caller's line number (for error output)
  309. * InternalName - Name or path of the namespace node
  310. * LookupStatus - Exception code from NS lookup
  311. *
  312. * RETURN: None
  313. *
  314. * DESCRIPTION: Print error message with the full pathname for the NS node.
  315. *
  316. ******************************************************************************/
  317. void
  318. AcpiUtNamespaceError (
  319. const char *ModuleName,
  320. UINT32 LineNumber,
  321. const char *InternalName,
  322. ACPI_STATUS LookupStatus)
  323. {
  324. ACPI_STATUS Status;
  325. UINT32 BadName;
  326. char *Name = NULL;
  327. ACPI_MSG_REDIRECT_BEGIN;
  328. AcpiOsPrintf (ACPI_MSG_ERROR);
  329. if (LookupStatus == AE_BAD_CHARACTER)
  330. {
  331. /* There is a non-ascii character in the name */
  332. ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR (UINT32, InternalName));
  333. AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)", BadName);
  334. }
  335. else
  336. {
  337. /* Convert path to external format */
  338. Status = AcpiNsExternalizeName (ACPI_UINT32_MAX,
  339. InternalName, NULL, &Name);
  340. /* Print target name */
  341. if (ACPI_SUCCESS (Status))
  342. {
  343. AcpiOsPrintf ("[%s]", Name);
  344. }
  345. else
  346. {
  347. AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]");
  348. }
  349. if (Name)
  350. {
  351. ACPI_FREE (Name);
  352. }
  353. }
  354. AcpiOsPrintf (" Namespace lookup failure, %s",
  355. AcpiFormatException (LookupStatus));
  356. ACPI_MSG_SUFFIX;
  357. ACPI_MSG_REDIRECT_END;
  358. }
  359. /*******************************************************************************
  360. *
  361. * FUNCTION: AcpiUtMethodError
  362. *
  363. * PARAMETERS: ModuleName - Caller's module name (for error output)
  364. * LineNumber - Caller's line number (for error output)
  365. * Message - Error message to use on failure
  366. * PrefixNode - Prefix relative to the path
  367. * Path - Path to the node (optional)
  368. * MethodStatus - Execution status
  369. *
  370. * RETURN: None
  371. *
  372. * DESCRIPTION: Print error message with the full pathname for the method.
  373. *
  374. ******************************************************************************/
  375. void
  376. AcpiUtMethodError (
  377. const char *ModuleName,
  378. UINT32 LineNumber,
  379. const char *Message,
  380. ACPI_NAMESPACE_NODE *PrefixNode,
  381. const char *Path,
  382. ACPI_STATUS MethodStatus)
  383. {
  384. ACPI_STATUS Status;
  385. ACPI_NAMESPACE_NODE *Node = PrefixNode;
  386. ACPI_MSG_REDIRECT_BEGIN;
  387. AcpiOsPrintf (ACPI_MSG_ERROR);
  388. if (Path)
  389. {
  390. Status = AcpiNsGetNode (PrefixNode, Path, ACPI_NS_NO_UPSEARCH,
  391. &Node);
  392. if (ACPI_FAILURE (Status))
  393. {
  394. AcpiOsPrintf ("[Could not get node by pathname]");
  395. }
  396. }
  397. AcpiNsPrintNodePathname (Node, Message);
  398. AcpiOsPrintf (", %s", AcpiFormatException (MethodStatus));
  399. ACPI_MSG_SUFFIX;
  400. ACPI_MSG_REDIRECT_END;
  401. }
  402. #endif /* ACPI_NO_ERROR_MESSAGES */