1 /*******************************************************************************
2  *
3  * Module Name: utxferror - Various error/warning output functions
4  *
5  ******************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2022, 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 MERCHANTABILITY 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 EXPORT_ACPI_INTERFACES
45 
46 #include "acpi.h"
47 #include "accommon.h"
48 
49 
50 #define _COMPONENT          ACPI_UTILITIES
51         ACPI_MODULE_NAME    ("utxferror")
52 
53 /*
54  * This module is used for the in-kernel ACPICA as well as the ACPICA
55  * tools/applications.
56  */
57 
58 #ifndef ACPI_NO_ERROR_MESSAGES /* Entire module */
59 
60 /*******************************************************************************
61  *
62  * FUNCTION:    AcpiError
63  *
64  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
65  *              LineNumber          - Caller's line number (for error output)
66  *              Format              - Printf format string + additional args
67  *
68  * RETURN:      None
69  *
70  * DESCRIPTION: Print "ACPI Error" message with module/line/version info
71  *
72  ******************************************************************************/
73 
74 void ACPI_INTERNAL_VAR_XFACE
75 AcpiError (
76     const char              *ModuleName,
77     UINT32                  LineNumber,
78     const char              *Format,
79     ...)
80 {
81     va_list                 ArgList;
82 
83 
84     ACPI_MSG_REDIRECT_BEGIN;
85     AcpiOsPrintf (ACPI_MSG_ERROR);
86 
87     va_start (ArgList, Format);
88     AcpiOsVprintf (Format, ArgList);
89     ACPI_MSG_SUFFIX;
90     va_end (ArgList);
91 
92     ACPI_MSG_REDIRECT_END;
93 }
94 
95 ACPI_EXPORT_SYMBOL (AcpiError)
96 
97 
98 /*******************************************************************************
99  *
100  * FUNCTION:    AcpiException
101  *
102  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
103  *              LineNumber          - Caller's line number (for error output)
104  *              Status              - Status value to be decoded/formatted
105  *              Format              - Printf format string + additional args
106  *
107  * RETURN:      None
108  *
109  * DESCRIPTION: Print an "ACPI Error" message with module/line/version
110  *              info as well as decoded ACPI_STATUS.
111  *
112  ******************************************************************************/
113 
114 void ACPI_INTERNAL_VAR_XFACE
115 AcpiException (
116     const char              *ModuleName,
117     UINT32                  LineNumber,
118     ACPI_STATUS             Status,
119     const char              *Format,
120     ...)
121 {
122     va_list                 ArgList;
123 
124 
125     ACPI_MSG_REDIRECT_BEGIN;
126 
127     /* For AE_OK, just print the message */
128 
129     if (ACPI_SUCCESS (Status))
130     {
131         AcpiOsPrintf (ACPI_MSG_ERROR);
132 
133     }
134     else
135     {
136         AcpiOsPrintf (ACPI_MSG_ERROR "%s, ",
137             AcpiFormatException (Status));
138     }
139 
140     va_start (ArgList, Format);
141     AcpiOsVprintf (Format, ArgList);
142     ACPI_MSG_SUFFIX;
143     va_end (ArgList);
144 
145     ACPI_MSG_REDIRECT_END;
146 }
147 
148 ACPI_EXPORT_SYMBOL (AcpiException)
149 
150 
151 /*******************************************************************************
152  *
153  * FUNCTION:    AcpiWarning
154  *
155  * PARAMETERS:  ModuleName          - Caller's module name (for warning output)
156  *              LineNumber          - Caller's line number (for warning output)
157  *              Format              - Printf format string + additional args
158  *
159  * RETURN:      None
160  *
161  * DESCRIPTION: Print "ACPI Warning" message with module/line/version info
162  *
163  ******************************************************************************/
164 
165 void ACPI_INTERNAL_VAR_XFACE
166 AcpiWarning (
167     const char              *ModuleName,
168     UINT32                  LineNumber,
169     const char              *Format,
170     ...)
171 {
172     va_list                 ArgList;
173 
174 
175     ACPI_MSG_REDIRECT_BEGIN;
176     AcpiOsPrintf (ACPI_MSG_WARNING);
177 
178     va_start (ArgList, Format);
179     AcpiOsVprintf (Format, ArgList);
180     ACPI_MSG_SUFFIX;
181     va_end (ArgList);
182 
183     ACPI_MSG_REDIRECT_END;
184 }
185 
186 ACPI_EXPORT_SYMBOL (AcpiWarning)
187 
188 
189 /*******************************************************************************
190  *
191  * FUNCTION:    AcpiInfo
192  *
193  * PARAMETERS:  Format              - Printf format string + additional args
194  *
195  * RETURN:      None
196  *
197  * DESCRIPTION: Print generic "ACPI:" information message. There is no
198  *              module/line/version info in order to keep the message simple.
199  *
200  ******************************************************************************/
201 
202 void ACPI_INTERNAL_VAR_XFACE
203 AcpiInfo (
204     const char              *Format,
205     ...)
206 {
207     va_list                 ArgList;
208 
209 
210     ACPI_MSG_REDIRECT_BEGIN;
211     AcpiOsPrintf (ACPI_MSG_INFO);
212 
213     va_start (ArgList, Format);
214     AcpiOsVprintf (Format, ArgList);
215     AcpiOsPrintf ("\n");
216     va_end (ArgList);
217 
218     ACPI_MSG_REDIRECT_END;
219 }
220 
221 ACPI_EXPORT_SYMBOL (AcpiInfo)
222 
223 
224 /*******************************************************************************
225  *
226  * FUNCTION:    AcpiBiosError
227  *
228  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
229  *              LineNumber          - Caller's line number (for error output)
230  *              Format              - Printf format string + additional args
231  *
232  * RETURN:      None
233  *
234  * DESCRIPTION: Print "ACPI Firmware Error" message with module/line/version
235  *              info
236  *
237  ******************************************************************************/
238 
239 void ACPI_INTERNAL_VAR_XFACE
240 AcpiBiosError (
241     const char              *ModuleName,
242     UINT32                  LineNumber,
243     const char              *Format,
244     ...)
245 {
246     va_list                 ArgList;
247 
248 
249     ACPI_MSG_REDIRECT_BEGIN;
250     AcpiOsPrintf (ACPI_MSG_BIOS_ERROR);
251 
252     va_start (ArgList, Format);
253     AcpiOsVprintf (Format, ArgList);
254     ACPI_MSG_SUFFIX;
255     va_end (ArgList);
256 
257     ACPI_MSG_REDIRECT_END;
258 }
259 
260 ACPI_EXPORT_SYMBOL (AcpiBiosError)
261 
262 
263 /*******************************************************************************
264  *
265  * FUNCTION:    AcpiBiosException
266  *
267  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
268  *              LineNumber          - Caller's line number (for error output)
269  *              Status              - Status value to be decoded/formatted
270  *              Format              - Printf format string + additional args
271  *
272  * RETURN:      None
273  *
274  * DESCRIPTION: Print an "ACPI Firmware Error" message with module/line/version
275  *              info as well as decoded ACPI_STATUS.
276  *
277  ******************************************************************************/
278 
279 void ACPI_INTERNAL_VAR_XFACE
280 AcpiBiosException (
281     const char              *ModuleName,
282     UINT32                  LineNumber,
283     ACPI_STATUS             Status,
284     const char              *Format,
285     ...)
286 {
287     va_list                 ArgList;
288 
289 
290     ACPI_MSG_REDIRECT_BEGIN;
291 
292     /* For AE_OK, just print the message */
293 
294     if (ACPI_SUCCESS (Status))
295     {
296         AcpiOsPrintf (ACPI_MSG_BIOS_ERROR);
297 
298     }
299     else
300     {
301         AcpiOsPrintf (ACPI_MSG_BIOS_ERROR "%s, ",
302             AcpiFormatException (Status));
303     }
304 
305     va_start (ArgList, Format);
306     AcpiOsVprintf (Format, ArgList);
307     ACPI_MSG_SUFFIX;
308     va_end (ArgList);
309 
310     ACPI_MSG_REDIRECT_END;
311 }
312 
313 ACPI_EXPORT_SYMBOL (AcpiBiosException)
314 
315 
316 /*******************************************************************************
317  *
318  * FUNCTION:    AcpiBiosWarning
319  *
320  * PARAMETERS:  ModuleName          - Caller's module name (for warning output)
321  *              LineNumber          - Caller's line number (for warning output)
322  *              Format              - Printf format string + additional args
323  *
324  * RETURN:      None
325  *
326  * DESCRIPTION: Print "ACPI Firmware Warning" message with module/line/version
327  *              info
328  *
329  ******************************************************************************/
330 
331 void ACPI_INTERNAL_VAR_XFACE
332 AcpiBiosWarning (
333     const char              *ModuleName,
334     UINT32                  LineNumber,
335     const char              *Format,
336     ...)
337 {
338     va_list                 ArgList;
339 
340 
341     ACPI_MSG_REDIRECT_BEGIN;
342     AcpiOsPrintf (ACPI_MSG_BIOS_WARNING);
343 
344     va_start (ArgList, Format);
345     AcpiOsVprintf (Format, ArgList);
346     ACPI_MSG_SUFFIX;
347     va_end (ArgList);
348 
349     ACPI_MSG_REDIRECT_END;
350 }
351 
352 ACPI_EXPORT_SYMBOL (AcpiBiosWarning)
353 
354 #endif /* ACPI_NO_ERROR_MESSAGES */
355