1 /*******************************************************************************
2 *
3 * Module Name: utxferror - Various error/warning output functions
4 *
5 ******************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44 #define __UTXFERROR_C__
45
46 #include <contrib/dev/acpica/include/acpi.h>
47 #include <contrib/dev/acpica/include/accommon.h>
48 #include <contrib/dev/acpica/include/acnamesp.h>
49
50
51 #define _COMPONENT ACPI_UTILITIES
52 ACPI_MODULE_NAME ("utxferror")
53
54 /*
55 * This module is used for the in-kernel ACPICA as well as the ACPICA
56 * tools/applications.
57 *
58 * For the iASL compiler case, the output is redirected to stderr so that
59 * any of the various ACPI errors and warnings do not appear in the output
60 * files, for either the compiler or disassembler portions of the tool.
61 */
62 #ifdef ACPI_ASL_COMPILER
63 #include <stdio.h>
64
65 extern FILE *AcpiGbl_OutputFile;
66
67 #define ACPI_MSG_REDIRECT_BEGIN \
68 FILE *OutputFile = AcpiGbl_OutputFile; \
69 AcpiOsRedirectOutput (stderr);
70
71 #define ACPI_MSG_REDIRECT_END \
72 AcpiOsRedirectOutput (OutputFile);
73
74 #else
75 /*
76 * non-iASL case - no redirection, nothing to do
77 */
78 #define ACPI_MSG_REDIRECT_BEGIN
79 #define ACPI_MSG_REDIRECT_END
80 #endif
81
82 /*
83 * Common message prefixes
84 */
85 #define ACPI_MSG_ERROR "ACPI Error: "
86 #define ACPI_MSG_EXCEPTION "ACPI Exception: "
87 #define ACPI_MSG_WARNING "ACPI Warning: "
88 #define ACPI_MSG_INFO "ACPI: "
89
90 /*
91 * Common message suffix
92 */
93 #define ACPI_MSG_SUFFIX \
94 AcpiOsPrintf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, ModuleName, LineNumber)
95
96
97 /*******************************************************************************
98 *
99 * FUNCTION: AcpiError
100 *
101 * PARAMETERS: ModuleName - Caller's module name (for error output)
102 * LineNumber - Caller's line number (for error output)
103 * Format - Printf format string + additional args
104 *
105 * RETURN: None
106 *
107 * DESCRIPTION: Print "ACPI Error" message with module/line/version info
108 *
109 ******************************************************************************/
110
111 void ACPI_INTERNAL_VAR_XFACE
AcpiError(const char * ModuleName,UINT32 LineNumber,const char * Format,...)112 AcpiError (
113 const char *ModuleName,
114 UINT32 LineNumber,
115 const char *Format,
116 ...)
117 {
118 va_list ArgList;
119
120
121 ACPI_MSG_REDIRECT_BEGIN;
122 AcpiOsPrintf (ACPI_MSG_ERROR);
123
124 va_start (ArgList, Format);
125 AcpiOsVprintf (Format, ArgList);
126 ACPI_MSG_SUFFIX;
127 va_end (ArgList);
128
129 ACPI_MSG_REDIRECT_END;
130 }
131
ACPI_EXPORT_SYMBOL(AcpiError)132 ACPI_EXPORT_SYMBOL (AcpiError)
133
134
135 /*******************************************************************************
136 *
137 * FUNCTION: AcpiException
138 *
139 * PARAMETERS: ModuleName - Caller's module name (for error output)
140 * LineNumber - Caller's line number (for error output)
141 * Status - Status to be formatted
142 * Format - Printf format string + additional args
143 *
144 * RETURN: None
145 *
146 * DESCRIPTION: Print "ACPI Exception" message with module/line/version info
147 * and decoded ACPI_STATUS.
148 *
149 ******************************************************************************/
150
151 void ACPI_INTERNAL_VAR_XFACE
152 AcpiException (
153 const char *ModuleName,
154 UINT32 LineNumber,
155 ACPI_STATUS Status,
156 const char *Format,
157 ...)
158 {
159 va_list ArgList;
160
161
162 ACPI_MSG_REDIRECT_BEGIN;
163 AcpiOsPrintf (ACPI_MSG_EXCEPTION "%s, ", AcpiFormatException (Status));
164
165 va_start (ArgList, Format);
166 AcpiOsVprintf (Format, ArgList);
167 ACPI_MSG_SUFFIX;
168 va_end (ArgList);
169
170 ACPI_MSG_REDIRECT_END;
171 }
172
ACPI_EXPORT_SYMBOL(AcpiException)173 ACPI_EXPORT_SYMBOL (AcpiException)
174
175
176 /*******************************************************************************
177 *
178 * FUNCTION: AcpiWarning
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 "ACPI Warning" message with module/line/version info
187 *
188 ******************************************************************************/
189
190 void ACPI_INTERNAL_VAR_XFACE
191 AcpiWarning (
192 const char *ModuleName,
193 UINT32 LineNumber,
194 const char *Format,
195 ...)
196 {
197 va_list ArgList;
198
199
200 ACPI_MSG_REDIRECT_BEGIN;
201 AcpiOsPrintf (ACPI_MSG_WARNING);
202
203 va_start (ArgList, Format);
204 AcpiOsVprintf (Format, ArgList);
205 ACPI_MSG_SUFFIX;
206 va_end (ArgList);
207
208 ACPI_MSG_REDIRECT_END;
209 }
210
ACPI_EXPORT_SYMBOL(AcpiWarning)211 ACPI_EXPORT_SYMBOL (AcpiWarning)
212
213
214 /*******************************************************************************
215 *
216 * FUNCTION: AcpiInfo
217 *
218 * PARAMETERS: ModuleName - Caller's module name (for error output)
219 * LineNumber - Caller's line number (for error output)
220 * Format - Printf format string + additional args
221 *
222 * RETURN: None
223 *
224 * DESCRIPTION: Print generic "ACPI:" information message. There is no
225 * module/line/version info in order to keep the message simple.
226 *
227 * TBD: ModuleName and LineNumber args are not needed, should be removed.
228 *
229 ******************************************************************************/
230
231 void ACPI_INTERNAL_VAR_XFACE
232 AcpiInfo (
233 const char *ModuleName,
234 UINT32 LineNumber,
235 const char *Format,
236 ...)
237 {
238 va_list ArgList;
239
240 #ifdef _KERNEL
241 /* Temporarily hide too verbose printfs. */
242 if (!bootverbose)
243 return;
244 #endif
245
246 ACPI_MSG_REDIRECT_BEGIN;
247 AcpiOsPrintf (ACPI_MSG_INFO);
248
249 va_start (ArgList, Format);
250 AcpiOsVprintf (Format, ArgList);
251 AcpiOsPrintf ("\n");
252 va_end (ArgList);
253
254 ACPI_MSG_REDIRECT_END;
255 }
256
ACPI_EXPORT_SYMBOL(AcpiInfo)257 ACPI_EXPORT_SYMBOL (AcpiInfo)
258
259
260 /*
261 * The remainder of this module contains internal error functions that may
262 * be configured out.
263 */
264 #if !defined (ACPI_NO_ERROR_MESSAGES) && !defined (ACPI_BIN_APP)
265
266 /*******************************************************************************
267 *
268 * FUNCTION: AcpiUtPredefinedWarning
269 *
270 * PARAMETERS: ModuleName - Caller's module name (for error output)
271 * LineNumber - Caller's line number (for error output)
272 * Pathname - Full pathname to the node
273 * NodeFlags - From Namespace node for the method/object
274 * Format - Printf format string + additional args
275 *
276 * RETURN: None
277 *
278 * DESCRIPTION: Warnings for the predefined validation module. Messages are
279 * only emitted the first time a problem with a particular
280 * method/object is detected. This prevents a flood of error
281 * messages for methods that are repeatedly evaluated.
282 *
283 ******************************************************************************/
284
285 void ACPI_INTERNAL_VAR_XFACE
286 AcpiUtPredefinedWarning (
287 const char *ModuleName,
288 UINT32 LineNumber,
289 char *Pathname,
290 UINT8 NodeFlags,
291 const char *Format,
292 ...)
293 {
294 va_list ArgList;
295
296
297 /*
298 * Warning messages for this method/object will be disabled after the
299 * first time a validation fails or an object is successfully repaired.
300 */
301 if (NodeFlags & ANOBJ_EVALUATED)
302 {
303 return;
304 }
305
306 AcpiOsPrintf (ACPI_MSG_WARNING "For %s: ", Pathname);
307
308 va_start (ArgList, Format);
309 AcpiOsVprintf (Format, ArgList);
310 ACPI_MSG_SUFFIX;
311 va_end (ArgList);
312 }
313
314
315 /*******************************************************************************
316 *
317 * FUNCTION: AcpiUtPredefinedInfo
318 *
319 * PARAMETERS: ModuleName - Caller's module name (for error output)
320 * LineNumber - Caller's line number (for error output)
321 * Pathname - Full pathname to the node
322 * NodeFlags - From Namespace node for the method/object
323 * Format - Printf format string + additional args
324 *
325 * RETURN: None
326 *
327 * DESCRIPTION: Info messages for the predefined validation module. Messages
328 * are only emitted the first time a problem with a particular
329 * method/object is detected. This prevents a flood of
330 * messages for methods that are repeatedly evaluated.
331 *
332 ******************************************************************************/
333
334 void ACPI_INTERNAL_VAR_XFACE
AcpiUtPredefinedInfo(const char * ModuleName,UINT32 LineNumber,char * Pathname,UINT8 NodeFlags,const char * Format,...)335 AcpiUtPredefinedInfo (
336 const char *ModuleName,
337 UINT32 LineNumber,
338 char *Pathname,
339 UINT8 NodeFlags,
340 const char *Format,
341 ...)
342 {
343 va_list ArgList;
344
345
346 /*
347 * Warning messages for this method/object will be disabled after the
348 * first time a validation fails or an object is successfully repaired.
349 */
350 if (NodeFlags & ANOBJ_EVALUATED)
351 {
352 return;
353 }
354
355 AcpiOsPrintf (ACPI_MSG_INFO "For %s: ", Pathname);
356
357 va_start (ArgList, Format);
358 AcpiOsVprintf (Format, ArgList);
359 ACPI_MSG_SUFFIX;
360 va_end (ArgList);
361 }
362
363
364 /*******************************************************************************
365 *
366 * FUNCTION: AcpiUtNamespaceError
367 *
368 * PARAMETERS: ModuleName - Caller's module name (for error output)
369 * LineNumber - Caller's line number (for error output)
370 * InternalName - Name or path of the namespace node
371 * LookupStatus - Exception code from NS lookup
372 *
373 * RETURN: None
374 *
375 * DESCRIPTION: Print error message with the full pathname for the NS node.
376 *
377 ******************************************************************************/
378
379 void
AcpiUtNamespaceError(const char * ModuleName,UINT32 LineNumber,const char * InternalName,ACPI_STATUS LookupStatus)380 AcpiUtNamespaceError (
381 const char *ModuleName,
382 UINT32 LineNumber,
383 const char *InternalName,
384 ACPI_STATUS LookupStatus)
385 {
386 ACPI_STATUS Status;
387 UINT32 BadName;
388 char *Name = NULL;
389
390
391 ACPI_MSG_REDIRECT_BEGIN;
392 AcpiOsPrintf (ACPI_MSG_ERROR);
393
394 if (LookupStatus == AE_BAD_CHARACTER)
395 {
396 /* There is a non-ascii character in the name */
397
398 ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR (UINT32, InternalName));
399 AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)", BadName);
400 }
401 else
402 {
403 /* Convert path to external format */
404
405 Status = AcpiNsExternalizeName (ACPI_UINT32_MAX,
406 InternalName, NULL, &Name);
407
408 /* Print target name */
409
410 if (ACPI_SUCCESS (Status))
411 {
412 AcpiOsPrintf ("[%s]", Name);
413 }
414 else
415 {
416 AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]");
417 }
418
419 if (Name)
420 {
421 ACPI_FREE (Name);
422 }
423 }
424
425 AcpiOsPrintf (" Namespace lookup failure, %s",
426 AcpiFormatException (LookupStatus));
427
428 ACPI_MSG_SUFFIX;
429 ACPI_MSG_REDIRECT_END;
430 }
431
432
433 /*******************************************************************************
434 *
435 * FUNCTION: AcpiUtMethodError
436 *
437 * PARAMETERS: ModuleName - Caller's module name (for error output)
438 * LineNumber - Caller's line number (for error output)
439 * Message - Error message to use on failure
440 * PrefixNode - Prefix relative to the path
441 * Path - Path to the node (optional)
442 * MethodStatus - Execution status
443 *
444 * RETURN: None
445 *
446 * DESCRIPTION: Print error message with the full pathname for the method.
447 *
448 ******************************************************************************/
449
450 void
AcpiUtMethodError(const char * ModuleName,UINT32 LineNumber,const char * Message,ACPI_NAMESPACE_NODE * PrefixNode,const char * Path,ACPI_STATUS MethodStatus)451 AcpiUtMethodError (
452 const char *ModuleName,
453 UINT32 LineNumber,
454 const char *Message,
455 ACPI_NAMESPACE_NODE *PrefixNode,
456 const char *Path,
457 ACPI_STATUS MethodStatus)
458 {
459 ACPI_STATUS Status;
460 ACPI_NAMESPACE_NODE *Node = PrefixNode;
461
462
463 ACPI_MSG_REDIRECT_BEGIN;
464 AcpiOsPrintf (ACPI_MSG_ERROR);
465
466 if (Path)
467 {
468 Status = AcpiNsGetNode (PrefixNode, Path, ACPI_NS_NO_UPSEARCH,
469 &Node);
470 if (ACPI_FAILURE (Status))
471 {
472 AcpiOsPrintf ("[Could not get node by pathname]");
473 }
474 }
475
476 AcpiNsPrintNodePathname (Node, Message);
477 AcpiOsPrintf (", %s", AcpiFormatException (MethodStatus));
478
479 ACPI_MSG_SUFFIX;
480 ACPI_MSG_REDIRECT_END;
481 }
482
483 #endif /* ACPI_NO_ERROR_MESSAGES */
484