blob: 3919fe599f947d1e25a357b0a6a3ea3889ca10e6 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: utdebug - Debug print routines
4 *
5 *****************************************************************************/
6
7/*
Len Brown75a44ce2008-04-23 23:00:13 -04008 * Copyright (C) 2000 - 2008, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
45
46#define _COMPONENT ACPI_UTILITIES
Len Brown4be44fc2005-08-05 00:44:28 -040047ACPI_MODULE_NAME("utdebug")
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#ifdef ACPI_DEBUG_OUTPUT
Len Brownab8aa062006-07-07 20:11:07 -040049static acpi_thread_id acpi_gbl_prev_thread_id;
Len Brown4be44fc2005-08-05 00:44:28 -040050static char *acpi_gbl_fn_entry_str = "----Entry";
51static char *acpi_gbl_fn_exit_str = "----Exit-";
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Robert Moore0c9938c2005-07-29 15:15:00 -070053/* Local prototypes */
54
Len Brown4be44fc2005-08-05 00:44:28 -040055static const char *acpi_ut_trim_function_name(const char *function_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Robert Moore44f6c012005-04-18 22:49:35 -040057/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 *
59 * FUNCTION: acpi_ut_init_stack_ptr_trace
60 *
61 * PARAMETERS: None
62 *
63 * RETURN: None
64 *
Robert Moore44f6c012005-04-18 22:49:35 -040065 * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 *
Robert Moore44f6c012005-04-18 22:49:35 -040067 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Len Brown4be44fc2005-08-05 00:44:28 -040069void acpi_ut_init_stack_ptr_trace(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070070{
Bob Moore1d18c052008-04-10 19:06:40 +040071 acpi_size current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Bob Moore1d18c052008-04-10 19:06:40 +040073 acpi_gbl_entry_stack_pointer = &current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074}
75
Robert Moore44f6c012005-04-18 22:49:35 -040076/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 *
78 * FUNCTION: acpi_ut_track_stack_ptr
79 *
80 * PARAMETERS: None
81 *
82 * RETURN: None
83 *
Robert Moore44f6c012005-04-18 22:49:35 -040084 * DESCRIPTION: Save the current CPU stack pointer
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 *
Robert Moore44f6c012005-04-18 22:49:35 -040086 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
Len Brown4be44fc2005-08-05 00:44:28 -040088void acpi_ut_track_stack_ptr(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070089{
Len Brown4be44fc2005-08-05 00:44:28 -040090 acpi_size current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
Bob Moore1d18c052008-04-10 19:06:40 +040092 if (&current_sp < acpi_gbl_lowest_stack_pointer) {
93 acpi_gbl_lowest_stack_pointer = &current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 }
95
96 if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) {
97 acpi_gbl_deepest_nesting = acpi_gbl_nesting_level;
98 }
99}
100
Robert Moore44f6c012005-04-18 22:49:35 -0400101/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 *
Robert Moore0c9938c2005-07-29 15:15:00 -0700103 * FUNCTION: acpi_ut_trim_function_name
104 *
105 * PARAMETERS: function_name - Ascii string containing a procedure name
106 *
107 * RETURN: Updated pointer to the function name
108 *
109 * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
Harvey Harrison96b2dd12008-03-05 18:24:51 -0800110 * This allows compiler macros such as __func__ to be used
Robert Moore0c9938c2005-07-29 15:15:00 -0700111 * with no change to the debug output.
112 *
113 ******************************************************************************/
114
Len Brown4be44fc2005-08-05 00:44:28 -0400115static const char *acpi_ut_trim_function_name(const char *function_name)
Robert Moore0c9938c2005-07-29 15:15:00 -0700116{
117
118 /* All Function names are longer than 4 chars, check is safe */
119
Bob Moorea18ecf42005-08-15 03:42:00 -0800120 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400121
Robert Moore0c9938c2005-07-29 15:15:00 -0700122 /* This is the case where the original source has not been modified */
123
124 return (function_name + 4);
125 }
126
Bob Moorea18ecf42005-08-15 03:42:00 -0800127 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400128
Robert Moore0c9938c2005-07-29 15:15:00 -0700129 /* This is the case where the source has been 'linuxized' */
130
131 return (function_name + 5);
132 }
133
134 return (function_name);
135}
136
Robert Moore0c9938c2005-07-29 15:15:00 -0700137/*******************************************************************************
138 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 * FUNCTION: acpi_ut_debug_print
140 *
Robert Moore44f6c012005-04-18 22:49:35 -0400141 * PARAMETERS: requested_debug_level - Requested debug print level
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 * line_number - Caller's line number (for error output)
Robert Mooref9f46012005-07-08 00:00:00 -0400143 * function_name - Caller's procedure name
144 * module_name - Caller's module name
145 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 * Format - Printf format field
147 * ... - Optional printf arguments
148 *
149 * RETURN: None
150 *
151 * DESCRIPTION: Print error message with prefix consisting of the module name,
152 * line number, and component ID.
153 *
Robert Moore44f6c012005-04-18 22:49:35 -0400154 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155
Len Brown4be44fc2005-08-05 00:44:28 -0400156void ACPI_INTERNAL_VAR_XFACE
157acpi_ut_debug_print(u32 requested_debug_level,
158 u32 line_number,
159 const char *function_name,
160 char *module_name, u32 component_id, char *format, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161{
Bob Moore83135242006-10-03 00:00:00 -0400162 acpi_thread_id thread_id;
Len Brown4be44fc2005-08-05 00:44:28 -0400163 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164
165 /*
166 * Stay silent if the debug level or component ID is disabled
167 */
168 if (!(requested_debug_level & acpi_dbg_level) ||
Len Brown4be44fc2005-08-05 00:44:28 -0400169 !(component_id & acpi_dbg_layer)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 return;
171 }
172
173 /*
174 * Thread tracking and context switch notification
175 */
Len Brown4be44fc2005-08-05 00:44:28 -0400176 thread_id = acpi_os_get_thread_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 if (thread_id != acpi_gbl_prev_thread_id) {
178 if (ACPI_LV_THREADS & acpi_dbg_level) {
Len Brown4be44fc2005-08-05 00:44:28 -0400179 acpi_os_printf
Alexey Starikovskiyb0b7eaa2007-01-25 22:39:44 -0500180 ("\n**** Context Switch from TID %lX to TID %lX ****\n\n",
Len Brownfd350942007-05-09 23:34:35 -0400181 (unsigned long)acpi_gbl_prev_thread_id,
182 (unsigned long)thread_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 }
184
185 acpi_gbl_prev_thread_id = thread_id;
186 }
187
188 /*
189 * Display the module name, current line number, thread ID (if requested),
190 * current procedure nesting level, and the current procedure name
191 */
Len Brown4be44fc2005-08-05 00:44:28 -0400192 acpi_os_printf("%8s-%04ld ", module_name, line_number);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193
194 if (ACPI_LV_THREADS & acpi_dbg_level) {
Alexey Starikovskiyb0b7eaa2007-01-25 22:39:44 -0500195 acpi_os_printf("[%04lX] ", (unsigned long)thread_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 }
197
Len Brown4be44fc2005-08-05 00:44:28 -0400198 acpi_os_printf("[%02ld] %-22.22s: ",
199 acpi_gbl_nesting_level,
200 acpi_ut_trim_function_name(function_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
Len Brown4be44fc2005-08-05 00:44:28 -0400202 va_start(args, format);
203 acpi_os_vprintf(format, args);
Bob Moore507f0462008-04-10 19:06:42 +0400204 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205}
Robert Moore44f6c012005-04-18 22:49:35 -0400206
Bob Moore83135242006-10-03 00:00:00 -0400207ACPI_EXPORT_SYMBOL(acpi_ut_debug_print)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208
Robert Moore44f6c012005-04-18 22:49:35 -0400209/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 *
211 * FUNCTION: acpi_ut_debug_print_raw
212 *
213 * PARAMETERS: requested_debug_level - Requested debug print level
214 * line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400215 * function_name - Caller's procedure name
216 * module_name - Caller's module name
217 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 * Format - Printf format field
219 * ... - Optional printf arguments
220 *
221 * RETURN: None
222 *
223 * DESCRIPTION: Print message with no headers. Has same interface as
224 * debug_print so that the same macros can be used.
225 *
Robert Moore44f6c012005-04-18 22:49:35 -0400226 ******************************************************************************/
Len Brown4be44fc2005-08-05 00:44:28 -0400227void ACPI_INTERNAL_VAR_XFACE
228acpi_ut_debug_print_raw(u32 requested_debug_level,
229 u32 line_number,
230 const char *function_name,
231 char *module_name, u32 component_id, char *format, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232{
Len Brown4be44fc2005-08-05 00:44:28 -0400233 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234
235 if (!(requested_debug_level & acpi_dbg_level) ||
Len Brown4be44fc2005-08-05 00:44:28 -0400236 !(component_id & acpi_dbg_layer)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 return;
238 }
239
Len Brown4be44fc2005-08-05 00:44:28 -0400240 va_start(args, format);
241 acpi_os_vprintf(format, args);
Bob Moore507f0462008-04-10 19:06:42 +0400242 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244
Bob Moore83135242006-10-03 00:00:00 -0400245ACPI_EXPORT_SYMBOL(acpi_ut_debug_print_raw)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
Robert Moore44f6c012005-04-18 22:49:35 -0400247/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 *
249 * FUNCTION: acpi_ut_trace
250 *
251 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400252 * function_name - Caller's procedure name
253 * module_name - Caller's module name
254 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 *
256 * RETURN: None
257 *
258 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
259 * set in debug_level
260 *
Robert Moore44f6c012005-04-18 22:49:35 -0400261 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262void
Len Brown4be44fc2005-08-05 00:44:28 -0400263acpi_ut_trace(u32 line_number,
264 const char *function_name, char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265{
266
267 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400268 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269
Len Brown4be44fc2005-08-05 00:44:28 -0400270 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
271 line_number, function_name, module_name,
272 component_id, "%s\n", acpi_gbl_fn_entry_str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274
Bob Moore83135242006-10-03 00:00:00 -0400275ACPI_EXPORT_SYMBOL(acpi_ut_trace)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
Robert Moore44f6c012005-04-18 22:49:35 -0400277/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 *
279 * FUNCTION: acpi_ut_trace_ptr
280 *
281 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400282 * function_name - Caller's procedure name
283 * module_name - Caller's module name
284 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 * Pointer - Pointer to display
286 *
287 * RETURN: None
288 *
289 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
290 * set in debug_level
291 *
Robert Moore44f6c012005-04-18 22:49:35 -0400292 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293void
Len Brown4be44fc2005-08-05 00:44:28 -0400294acpi_ut_trace_ptr(u32 line_number,
295 const char *function_name,
296 char *module_name, u32 component_id, void *pointer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297{
298 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400299 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
Len Brown4be44fc2005-08-05 00:44:28 -0400301 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
302 line_number, function_name, module_name,
303 component_id, "%s %p\n", acpi_gbl_fn_entry_str,
304 pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305}
306
Robert Moore44f6c012005-04-18 22:49:35 -0400307/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 *
309 * FUNCTION: acpi_ut_trace_str
310 *
311 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400312 * function_name - Caller's procedure name
313 * module_name - Caller's module name
314 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 * String - Additional string to display
316 *
317 * RETURN: None
318 *
319 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
320 * set in debug_level
321 *
Robert Moore44f6c012005-04-18 22:49:35 -0400322 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323
324void
Len Brown4be44fc2005-08-05 00:44:28 -0400325acpi_ut_trace_str(u32 line_number,
326 const char *function_name,
327 char *module_name, u32 component_id, char *string)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328{
329
330 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400331 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332
Len Brown4be44fc2005-08-05 00:44:28 -0400333 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
334 line_number, function_name, module_name,
335 component_id, "%s %s\n", acpi_gbl_fn_entry_str,
336 string);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337}
338
Robert Moore44f6c012005-04-18 22:49:35 -0400339/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 *
341 * FUNCTION: acpi_ut_trace_u32
342 *
343 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400344 * function_name - Caller's procedure name
345 * module_name - Caller's module name
346 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 * Integer - Integer to display
348 *
349 * RETURN: None
350 *
351 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
352 * set in debug_level
353 *
Robert Moore44f6c012005-04-18 22:49:35 -0400354 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355
356void
Len Brown4be44fc2005-08-05 00:44:28 -0400357acpi_ut_trace_u32(u32 line_number,
358 const char *function_name,
359 char *module_name, u32 component_id, u32 integer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360{
361
362 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400363 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364
Len Brown4be44fc2005-08-05 00:44:28 -0400365 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
366 line_number, function_name, module_name,
367 component_id, "%s %08X\n", acpi_gbl_fn_entry_str,
368 integer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369}
370
Robert Moore44f6c012005-04-18 22:49:35 -0400371/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 *
373 * FUNCTION: acpi_ut_exit
374 *
375 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400376 * function_name - Caller's procedure name
377 * module_name - Caller's module name
378 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 *
380 * RETURN: None
381 *
382 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
383 * set in debug_level
384 *
Robert Moore44f6c012005-04-18 22:49:35 -0400385 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386
387void
Len Brown4be44fc2005-08-05 00:44:28 -0400388acpi_ut_exit(u32 line_number,
389 const char *function_name, char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390{
391
Len Brown4be44fc2005-08-05 00:44:28 -0400392 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
393 line_number, function_name, module_name,
394 component_id, "%s\n", acpi_gbl_fn_exit_str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395
396 acpi_gbl_nesting_level--;
397}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398
Bob Moore83135242006-10-03 00:00:00 -0400399ACPI_EXPORT_SYMBOL(acpi_ut_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400
Robert Moore44f6c012005-04-18 22:49:35 -0400401/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 *
403 * FUNCTION: acpi_ut_status_exit
404 *
405 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400406 * function_name - Caller's procedure name
407 * module_name - Caller's module name
408 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 * Status - Exit status code
410 *
411 * RETURN: None
412 *
413 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
414 * set in debug_level. Prints exit status also.
415 *
Robert Moore44f6c012005-04-18 22:49:35 -0400416 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417void
Len Brown4be44fc2005-08-05 00:44:28 -0400418acpi_ut_status_exit(u32 line_number,
419 const char *function_name,
420 char *module_name, u32 component_id, acpi_status status)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421{
422
Len Brown4be44fc2005-08-05 00:44:28 -0400423 if (ACPI_SUCCESS(status)) {
424 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
425 line_number, function_name, module_name,
426 component_id, "%s %s\n",
427 acpi_gbl_fn_exit_str,
428 acpi_format_exception(status));
429 } else {
430 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
431 line_number, function_name, module_name,
432 component_id, "%s ****Exception****: %s\n",
433 acpi_gbl_fn_exit_str,
434 acpi_format_exception(status));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 }
436
437 acpi_gbl_nesting_level--;
438}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439
Bob Moore83135242006-10-03 00:00:00 -0400440ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
Robert Moore44f6c012005-04-18 22:49:35 -0400442/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 *
444 * FUNCTION: acpi_ut_value_exit
445 *
446 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400447 * function_name - Caller's procedure name
448 * module_name - Caller's module name
449 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 * Value - Value to be printed with exit msg
451 *
452 * RETURN: None
453 *
454 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
455 * set in debug_level. Prints exit value also.
456 *
Robert Moore44f6c012005-04-18 22:49:35 -0400457 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458void
Len Brown4be44fc2005-08-05 00:44:28 -0400459acpi_ut_value_exit(u32 line_number,
460 const char *function_name,
461 char *module_name, u32 component_id, acpi_integer value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462{
463
Len Brown4be44fc2005-08-05 00:44:28 -0400464 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
465 line_number, function_name, module_name,
466 component_id, "%s %8.8X%8.8X\n",
467 acpi_gbl_fn_exit_str, ACPI_FORMAT_UINT64(value));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468
469 acpi_gbl_nesting_level--;
470}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471
Bob Moore83135242006-10-03 00:00:00 -0400472ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473
Robert Moore44f6c012005-04-18 22:49:35 -0400474/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 *
476 * FUNCTION: acpi_ut_ptr_exit
477 *
478 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400479 * function_name - Caller's procedure name
480 * module_name - Caller's module name
481 * component_id - Caller's component ID
Robert Moore44f6c012005-04-18 22:49:35 -0400482 * Ptr - Pointer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 *
484 * RETURN: None
485 *
486 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
487 * set in debug_level. Prints exit value also.
488 *
Robert Moore44f6c012005-04-18 22:49:35 -0400489 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490void
Len Brown4be44fc2005-08-05 00:44:28 -0400491acpi_ut_ptr_exit(u32 line_number,
492 const char *function_name,
493 char *module_name, u32 component_id, u8 * ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494{
495
Len Brown4be44fc2005-08-05 00:44:28 -0400496 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
497 line_number, function_name, module_name,
498 component_id, "%s %p\n", acpi_gbl_fn_exit_str, ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499
500 acpi_gbl_nesting_level--;
501}
502
503#endif
504
Robert Moore44f6c012005-04-18 22:49:35 -0400505/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 *
507 * FUNCTION: acpi_ut_dump_buffer
508 *
509 * PARAMETERS: Buffer - Buffer to dump
510 * Count - Amount to dump, in bytes
511 * Display - BYTE, WORD, DWORD, or QWORD display
512 * component_iD - Caller's component ID
513 *
514 * RETURN: None
515 *
516 * DESCRIPTION: Generic dump buffer in both hex and ascii.
517 *
Robert Moore44f6c012005-04-18 22:49:35 -0400518 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519
Bob Moore793c2382006-03-31 00:00:00 -0500520void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521{
Bob Moore67a119f2008-06-10 13:42:13 +0800522 u32 i = 0;
523 u32 j;
Len Brown4be44fc2005-08-05 00:44:28 -0400524 u32 temp32;
525 u8 buf_char;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526
Bob Moore5eb69182008-04-10 19:06:39 +0400527 if (!buffer) {
528 acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n");
529 return;
530 }
531
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 if ((count < 4) || (count & 0x01)) {
533 display = DB_BYTE_DISPLAY;
534 }
535
Robert Moore44f6c012005-04-18 22:49:35 -0400536 /* Nasty little dump buffer routine! */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 while (i < count) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400539
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 /* Print current offset */
541
Bob Moore67a119f2008-06-10 13:42:13 +0800542 acpi_os_printf("%6.4X: ", i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543
544 /* Print 16 hex chars */
545
546 for (j = 0; j < 16;) {
547 if (i + j >= count) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400548
Robert Moore44f6c012005-04-18 22:49:35 -0400549 /* Dump fill spaces */
550
Len Brown4be44fc2005-08-05 00:44:28 -0400551 acpi_os_printf("%*s", ((display * 2) + 1), " ");
Bob Moore67a119f2008-06-10 13:42:13 +0800552 j += display;
Robert Moore44f6c012005-04-18 22:49:35 -0400553 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 }
555
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 switch (display) {
Bob Moore793c2382006-03-31 00:00:00 -0500557 case DB_BYTE_DISPLAY:
Len Brown4be44fc2005-08-05 00:44:28 -0400558 default: /* Default is BYTE display */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559
Bob Moore67a119f2008-06-10 13:42:13 +0800560 acpi_os_printf("%02X ",
561 buffer[(acpi_size) i + j]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 break;
563
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 case DB_WORD_DISPLAY:
565
Bob Moore67a119f2008-06-10 13:42:13 +0800566 ACPI_MOVE_16_TO_32(&temp32,
567 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400568 acpi_os_printf("%04X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 break;
570
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 case DB_DWORD_DISPLAY:
572
Bob Moore67a119f2008-06-10 13:42:13 +0800573 ACPI_MOVE_32_TO_32(&temp32,
574 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400575 acpi_os_printf("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 break;
577
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 case DB_QWORD_DISPLAY:
579
Bob Moore67a119f2008-06-10 13:42:13 +0800580 ACPI_MOVE_32_TO_32(&temp32,
581 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400582 acpi_os_printf("%08X", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583
Bob Moore67a119f2008-06-10 13:42:13 +0800584 ACPI_MOVE_32_TO_32(&temp32,
585 &buffer[(acpi_size) i + j +
586 4]);
Len Brown4be44fc2005-08-05 00:44:28 -0400587 acpi_os_printf("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 break;
589 }
Robert Moore44f6c012005-04-18 22:49:35 -0400590
Bob Moore67a119f2008-06-10 13:42:13 +0800591 j += display;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 }
593
594 /*
Robert Moore0c9938c2005-07-29 15:15:00 -0700595 * Print the ASCII equivalent characters but watch out for the bad
596 * unprintable ones (printable chars are 0x20 through 0x7E)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 */
Len Brown4be44fc2005-08-05 00:44:28 -0400598 acpi_os_printf(" ");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 for (j = 0; j < 16; j++) {
600 if (i + j >= count) {
Len Brown4be44fc2005-08-05 00:44:28 -0400601 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 return;
603 }
604
Bob Moore67a119f2008-06-10 13:42:13 +0800605 buf_char = buffer[(acpi_size) i + j];
Len Brown4be44fc2005-08-05 00:44:28 -0400606 if (ACPI_IS_PRINT(buf_char)) {
607 acpi_os_printf("%c", buf_char);
608 } else {
609 acpi_os_printf(".");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 }
611 }
612
613 /* Done with that line. */
614
Len Brown4be44fc2005-08-05 00:44:28 -0400615 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 i += 16;
617 }
618
619 return;
620}
Bob Moore793c2382006-03-31 00:00:00 -0500621
622/*******************************************************************************
623 *
624 * FUNCTION: acpi_ut_dump_buffer
625 *
626 * PARAMETERS: Buffer - Buffer to dump
627 * Count - Amount to dump, in bytes
628 * Display - BYTE, WORD, DWORD, or QWORD display
629 * component_iD - Caller's component ID
630 *
631 * RETURN: None
632 *
633 * DESCRIPTION: Generic dump buffer in both hex and ascii.
634 *
635 ******************************************************************************/
636
637void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id)
638{
639
640 /* Only dump the buffer if tracing is enabled */
641
642 if (!((ACPI_LV_TABLES & acpi_dbg_level) &&
643 (component_id & acpi_dbg_layer))) {
644 return;
645 }
646
647 acpi_ut_dump_buffer2(buffer, count, display);
648}