xref: /linux/drivers/acpi/acpica/utxferror.c (revision c0c914eca7f251c70facc37dfebeaf176601918d)
1 /*******************************************************************************
2  *
3  * Module Name: utxferror - Various 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 #define EXPORT_ACPI_INTERFACES
45 
46 #include <acpi/acpi.h>
47 #include "accommon.h"
48 
49 #define _COMPONENT          ACPI_UTILITIES
50 ACPI_MODULE_NAME("utxferror")
51 
52 /*
53  * This module is used for the in-kernel ACPICA as well as the ACPICA
54  * tools/applications.
55  */
56 #ifndef ACPI_NO_ERROR_MESSAGES	/* Entire module */
57 /*******************************************************************************
58  *
59  * FUNCTION:    acpi_error
60  *
61  * PARAMETERS:  module_name         - Caller's module name (for error output)
62  *              line_number         - Caller's line number (for error output)
63  *              format              - Printf format string + additional args
64  *
65  * RETURN:      None
66  *
67  * DESCRIPTION: Print "ACPI Error" message with module/line/version info
68  *
69  ******************************************************************************/
70 void ACPI_INTERNAL_VAR_XFACE
71 acpi_error(const char *module_name, u32 line_number, const char *format, ...)
72 {
73 	va_list arg_list;
74 
75 	ACPI_MSG_REDIRECT_BEGIN;
76 	acpi_os_printf(ACPI_MSG_ERROR);
77 
78 	va_start(arg_list, format);
79 	acpi_os_vprintf(format, arg_list);
80 	ACPI_MSG_SUFFIX;
81 	va_end(arg_list);
82 
83 	ACPI_MSG_REDIRECT_END;
84 }
85 
86 ACPI_EXPORT_SYMBOL(acpi_error)
87 
88 /*******************************************************************************
89  *
90  * FUNCTION:    acpi_exception
91  *
92  * PARAMETERS:  module_name         - Caller's module name (for error output)
93  *              line_number         - Caller's line number (for error output)
94  *              status              - Status to be formatted
95  *              format              - Printf format string + additional args
96  *
97  * RETURN:      None
98  *
99  * DESCRIPTION: Print "ACPI Exception" message with module/line/version info
100  *              and decoded acpi_status.
101  *
102  ******************************************************************************/
103 void ACPI_INTERNAL_VAR_XFACE
104 acpi_exception(const char *module_name,
105 	       u32 line_number, acpi_status status, const char *format, ...)
106 {
107 	va_list arg_list;
108 
109 	ACPI_MSG_REDIRECT_BEGIN;
110 
111 	/* For AE_OK, just print the message */
112 
113 	if (ACPI_SUCCESS(status)) {
114 		acpi_os_printf(ACPI_MSG_EXCEPTION);
115 
116 	} else {
117 		acpi_os_printf(ACPI_MSG_EXCEPTION "%s, ",
118 			       acpi_format_exception(status));
119 	}
120 
121 	va_start(arg_list, format);
122 	acpi_os_vprintf(format, arg_list);
123 	ACPI_MSG_SUFFIX;
124 	va_end(arg_list);
125 
126 	ACPI_MSG_REDIRECT_END;
127 }
128 
129 ACPI_EXPORT_SYMBOL(acpi_exception)
130 
131 /*******************************************************************************
132  *
133  * FUNCTION:    acpi_warning
134  *
135  * PARAMETERS:  module_name         - Caller's module name (for error output)
136  *              line_number         - Caller's line number (for error output)
137  *              format              - Printf format string + additional args
138  *
139  * RETURN:      None
140  *
141  * DESCRIPTION: Print "ACPI Warning" message with module/line/version info
142  *
143  ******************************************************************************/
144 void ACPI_INTERNAL_VAR_XFACE
145 acpi_warning(const char *module_name, u32 line_number, const char *format, ...)
146 {
147 	va_list arg_list;
148 
149 	ACPI_MSG_REDIRECT_BEGIN;
150 	acpi_os_printf(ACPI_MSG_WARNING);
151 
152 	va_start(arg_list, format);
153 	acpi_os_vprintf(format, arg_list);
154 	ACPI_MSG_SUFFIX;
155 	va_end(arg_list);
156 
157 	ACPI_MSG_REDIRECT_END;
158 }
159 
160 ACPI_EXPORT_SYMBOL(acpi_warning)
161 
162 /*******************************************************************************
163  *
164  * FUNCTION:    acpi_info
165  *
166  * PARAMETERS:  module_name         - Caller's module name (for error output)
167  *              line_number         - Caller's line number (for error output)
168  *              format              - Printf format string + additional args
169  *
170  * RETURN:      None
171  *
172  * DESCRIPTION: Print generic "ACPI:" information message. There is no
173  *              module/line/version info in order to keep the message simple.
174  *
175  * TBD: module_name and line_number args are not needed, should be removed.
176  *
177  ******************************************************************************/
178 void ACPI_INTERNAL_VAR_XFACE
179 acpi_info(const char *module_name, u32 line_number, const char *format, ...)
180 {
181 	va_list arg_list;
182 
183 	ACPI_MSG_REDIRECT_BEGIN;
184 	acpi_os_printf(ACPI_MSG_INFO);
185 
186 	va_start(arg_list, format);
187 	acpi_os_vprintf(format, arg_list);
188 	acpi_os_printf("\n");
189 	va_end(arg_list);
190 
191 	ACPI_MSG_REDIRECT_END;
192 }
193 
194 ACPI_EXPORT_SYMBOL(acpi_info)
195 
196 /*******************************************************************************
197  *
198  * FUNCTION:    acpi_bios_error
199  *
200  * PARAMETERS:  module_name         - Caller's module name (for error output)
201  *              line_number         - Caller's line number (for error output)
202  *              format              - Printf format string + additional args
203  *
204  * RETURN:      None
205  *
206  * DESCRIPTION: Print "ACPI Firmware Error" message with module/line/version
207  *              info
208  *
209  ******************************************************************************/
210 void ACPI_INTERNAL_VAR_XFACE
211 acpi_bios_error(const char *module_name,
212 		u32 line_number, const char *format, ...)
213 {
214 	va_list arg_list;
215 
216 	ACPI_MSG_REDIRECT_BEGIN;
217 	acpi_os_printf(ACPI_MSG_BIOS_ERROR);
218 
219 	va_start(arg_list, format);
220 	acpi_os_vprintf(format, arg_list);
221 	ACPI_MSG_SUFFIX;
222 	va_end(arg_list);
223 
224 	ACPI_MSG_REDIRECT_END;
225 }
226 
227 ACPI_EXPORT_SYMBOL(acpi_bios_error)
228 
229 /*******************************************************************************
230  *
231  * FUNCTION:    acpi_bios_warning
232  *
233  * PARAMETERS:  module_name         - Caller's module name (for error output)
234  *              line_number         - Caller's line number (for error output)
235  *              format              - Printf format string + additional args
236  *
237  * RETURN:      None
238  *
239  * DESCRIPTION: Print "ACPI Firmware Warning" message with module/line/version
240  *              info
241  *
242  ******************************************************************************/
243 void ACPI_INTERNAL_VAR_XFACE
244 acpi_bios_warning(const char *module_name,
245 		  u32 line_number, const char *format, ...)
246 {
247 	va_list arg_list;
248 
249 	ACPI_MSG_REDIRECT_BEGIN;
250 	acpi_os_printf(ACPI_MSG_BIOS_WARNING);
251 
252 	va_start(arg_list, format);
253 	acpi_os_vprintf(format, arg_list);
254 	ACPI_MSG_SUFFIX;
255 	va_end(arg_list);
256 
257 	ACPI_MSG_REDIRECT_END;
258 }
259 
260 ACPI_EXPORT_SYMBOL(acpi_bios_warning)
261 #endif				/* ACPI_NO_ERROR_MESSAGES */
262