[ACPICA]
[reactos.git] / reactos / drivers / bus / acpi / acpica / utilities / uterror.c
1 /*******************************************************************************
2 *
3 * Module Name: uterror - Various internal error/warning output functions
4 *
5 ******************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2016, 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 #include "acpi.h"
45 #include "accommon.h"
46 #include "acnamesp.h"
47
48
49 #define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("uterror")
51
52
53 /*
54 * This module contains internal error functions that may
55 * be configured out.
56 */
57 #if !defined (ACPI_NO_ERROR_MESSAGES)
58
59 /*******************************************************************************
60 *
61 * FUNCTION: AcpiUtPredefinedWarning
62 *
63 * PARAMETERS: ModuleName - Caller's module name (for error output)
64 * LineNumber - Caller's line number (for error output)
65 * Pathname - Full pathname to the node
66 * NodeFlags - From Namespace node for the method/object
67 * Format - Printf format string + additional args
68 *
69 * RETURN: None
70 *
71 * DESCRIPTION: Warnings for the predefined validation module. Messages are
72 * only emitted the first time a problem with a particular
73 * method/object is detected. This prevents a flood of error
74 * messages for methods that are repeatedly evaluated.
75 *
76 ******************************************************************************/
77
78 void ACPI_INTERNAL_VAR_XFACE
79 AcpiUtPredefinedWarning (
80 const char *ModuleName,
81 UINT32 LineNumber,
82 char *Pathname,
83 UINT8 NodeFlags,
84 const char *Format,
85 ...)
86 {
87 va_list ArgList;
88
89
90 /*
91 * Warning messages for this method/object will be disabled after the
92 * first time a validation fails or an object is successfully repaired.
93 */
94 if (NodeFlags & ANOBJ_EVALUATED)
95 {
96 return;
97 }
98
99 AcpiOsPrintf (ACPI_MSG_WARNING "%s: ", Pathname);
100
101 va_start (ArgList, Format);
102 AcpiOsVprintf (Format, ArgList);
103 ACPI_MSG_SUFFIX;
104 va_end (ArgList);
105 }
106
107
108 /*******************************************************************************
109 *
110 * FUNCTION: AcpiUtPredefinedInfo
111 *
112 * PARAMETERS: ModuleName - Caller's module name (for error output)
113 * LineNumber - Caller's line number (for error output)
114 * Pathname - Full pathname to the node
115 * NodeFlags - From Namespace node for the method/object
116 * Format - Printf format string + additional args
117 *
118 * RETURN: None
119 *
120 * DESCRIPTION: Info messages for the predefined validation module. Messages
121 * are only emitted the first time a problem with a particular
122 * method/object is detected. This prevents a flood of
123 * messages for methods that are repeatedly evaluated.
124 *
125 ******************************************************************************/
126
127 void ACPI_INTERNAL_VAR_XFACE
128 AcpiUtPredefinedInfo (
129 const char *ModuleName,
130 UINT32 LineNumber,
131 char *Pathname,
132 UINT8 NodeFlags,
133 const char *Format,
134 ...)
135 {
136 va_list ArgList;
137
138
139 /*
140 * Warning messages for this method/object will be disabled after the
141 * first time a validation fails or an object is successfully repaired.
142 */
143 if (NodeFlags & ANOBJ_EVALUATED)
144 {
145 return;
146 }
147
148 AcpiOsPrintf (ACPI_MSG_INFO "%s: ", Pathname);
149
150 va_start (ArgList, Format);
151 AcpiOsVprintf (Format, ArgList);
152 ACPI_MSG_SUFFIX;
153 va_end (ArgList);
154 }
155
156
157 /*******************************************************************************
158 *
159 * FUNCTION: AcpiUtPredefinedBiosError
160 *
161 * PARAMETERS: ModuleName - Caller's module name (for error output)
162 * LineNumber - Caller's line number (for error output)
163 * Pathname - Full pathname to the node
164 * NodeFlags - From Namespace node for the method/object
165 * Format - Printf format string + additional args
166 *
167 * RETURN: None
168 *
169 * DESCRIPTION: BIOS error message for predefined names. Messages
170 * are only emitted the first time a problem with a particular
171 * method/object is detected. This prevents a flood of
172 * messages for methods that are repeatedly evaluated.
173 *
174 ******************************************************************************/
175
176 void ACPI_INTERNAL_VAR_XFACE
177 AcpiUtPredefinedBiosError (
178 const char *ModuleName,
179 UINT32 LineNumber,
180 char *Pathname,
181 UINT8 NodeFlags,
182 const char *Format,
183 ...)
184 {
185 va_list ArgList;
186
187
188 /*
189 * Warning messages for this method/object will be disabled after the
190 * first time a validation fails or an object is successfully repaired.
191 */
192 if (NodeFlags & ANOBJ_EVALUATED)
193 {
194 return;
195 }
196
197 AcpiOsPrintf (ACPI_MSG_BIOS_ERROR "%s: ", Pathname);
198
199 va_start (ArgList, Format);
200 AcpiOsVprintf (Format, ArgList);
201 ACPI_MSG_SUFFIX;
202 va_end (ArgList);
203 }
204
205
206 /*******************************************************************************
207 *
208 * FUNCTION: AcpiUtNamespaceError
209 *
210 * PARAMETERS: ModuleName - Caller's module name (for error output)
211 * LineNumber - Caller's line number (for error output)
212 * InternalName - Name or path of the namespace node
213 * LookupStatus - Exception code from NS lookup
214 *
215 * RETURN: None
216 *
217 * DESCRIPTION: Print error message with the full pathname for the NS node.
218 *
219 ******************************************************************************/
220
221 void
222 AcpiUtNamespaceError (
223 const char *ModuleName,
224 UINT32 LineNumber,
225 const char *InternalName,
226 ACPI_STATUS LookupStatus)
227 {
228 ACPI_STATUS Status;
229 UINT32 BadName;
230 char *Name = NULL;
231
232
233 ACPI_MSG_REDIRECT_BEGIN;
234 AcpiOsPrintf (ACPI_MSG_ERROR);
235
236 if (LookupStatus == AE_BAD_CHARACTER)
237 {
238 /* There is a non-ascii character in the name */
239
240 ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR (UINT32, InternalName));
241 AcpiOsPrintf ("[0x%.8X] (NON-ASCII)", BadName);
242 }
243 else
244 {
245 /* Convert path to external format */
246
247 Status = AcpiNsExternalizeName (
248 ACPI_UINT32_MAX, InternalName, NULL, &Name);
249
250 /* Print target name */
251
252 if (ACPI_SUCCESS (Status))
253 {
254 AcpiOsPrintf ("[%s]", Name);
255 }
256 else
257 {
258 AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]");
259 }
260
261 if (Name)
262 {
263 ACPI_FREE (Name);
264 }
265 }
266
267 AcpiOsPrintf (" Namespace lookup failure, %s",
268 AcpiFormatException (LookupStatus));
269
270 ACPI_MSG_SUFFIX;
271 ACPI_MSG_REDIRECT_END;
272 }
273
274
275 /*******************************************************************************
276 *
277 * FUNCTION: AcpiUtMethodError
278 *
279 * PARAMETERS: ModuleName - Caller's module name (for error output)
280 * LineNumber - Caller's line number (for error output)
281 * Message - Error message to use on failure
282 * PrefixNode - Prefix relative to the path
283 * Path - Path to the node (optional)
284 * MethodStatus - Execution status
285 *
286 * RETURN: None
287 *
288 * DESCRIPTION: Print error message with the full pathname for the method.
289 *
290 ******************************************************************************/
291
292 void
293 AcpiUtMethodError (
294 const char *ModuleName,
295 UINT32 LineNumber,
296 const char *Message,
297 ACPI_NAMESPACE_NODE *PrefixNode,
298 const char *Path,
299 ACPI_STATUS MethodStatus)
300 {
301 ACPI_STATUS Status;
302 ACPI_NAMESPACE_NODE *Node = PrefixNode;
303
304
305 ACPI_MSG_REDIRECT_BEGIN;
306 AcpiOsPrintf (ACPI_MSG_ERROR);
307
308 if (Path)
309 {
310 Status = AcpiNsGetNode (PrefixNode, Path,
311 ACPI_NS_NO_UPSEARCH, &Node);
312 if (ACPI_FAILURE (Status))
313 {
314 AcpiOsPrintf ("[Could not get node by pathname]");
315 }
316 }
317
318 AcpiNsPrintNodePathname (Node, Message);
319 AcpiOsPrintf (", %s", AcpiFormatException (MethodStatus));
320
321 ACPI_MSG_SUFFIX;
322 ACPI_MSG_REDIRECT_END;
323 }
324
325 #endif /* ACPI_NO_ERROR_MESSAGES */