Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /****************************************************************************** |
2 | * | |
3 | * Module Name: utdebug - Debug print routines | |
4 | * | |
5 | *****************************************************************************/ | |
6 | ||
7 | /* | |
75a44ce0 | 8 | * Copyright (C) 2000 - 2008, Intel Corp. |
1da177e4 LT |
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 | ||
1da177e4 | 44 | #include <acpi/acpi.h> |
e2f7a777 | 45 | #include "accommon.h" |
1da177e4 LT |
46 | |
47 | #define _COMPONENT ACPI_UTILITIES | |
4be44fcd | 48 | ACPI_MODULE_NAME("utdebug") |
1da177e4 | 49 | #ifdef ACPI_DEBUG_OUTPUT |
ab8aa06a | 50 | static acpi_thread_id acpi_gbl_prev_thread_id; |
4be44fcd LB |
51 | static char *acpi_gbl_fn_entry_str = "----Entry"; |
52 | static char *acpi_gbl_fn_exit_str = "----Exit-"; | |
1da177e4 | 53 | |
0c9938cc RM |
54 | /* Local prototypes */ |
55 | ||
4be44fcd | 56 | static const char *acpi_ut_trim_function_name(const char *function_name); |
1da177e4 | 57 | |
44f6c012 | 58 | /******************************************************************************* |
1da177e4 LT |
59 | * |
60 | * FUNCTION: acpi_ut_init_stack_ptr_trace | |
61 | * | |
62 | * PARAMETERS: None | |
63 | * | |
64 | * RETURN: None | |
65 | * | |
44f6c012 | 66 | * DESCRIPTION: Save the current CPU stack pointer at subsystem startup |
1da177e4 | 67 | * |
44f6c012 | 68 | ******************************************************************************/ |
1da177e4 | 69 | |
4be44fcd | 70 | void acpi_ut_init_stack_ptr_trace(void) |
1da177e4 | 71 | { |
1d18c058 | 72 | acpi_size current_sp; |
1da177e4 | 73 | |
1d18c058 | 74 | acpi_gbl_entry_stack_pointer = ¤t_sp; |
1da177e4 LT |
75 | } |
76 | ||
44f6c012 | 77 | /******************************************************************************* |
1da177e4 LT |
78 | * |
79 | * FUNCTION: acpi_ut_track_stack_ptr | |
80 | * | |
81 | * PARAMETERS: None | |
82 | * | |
83 | * RETURN: None | |
84 | * | |
44f6c012 | 85 | * DESCRIPTION: Save the current CPU stack pointer |
1da177e4 | 86 | * |
44f6c012 | 87 | ******************************************************************************/ |
1da177e4 | 88 | |
4be44fcd | 89 | void acpi_ut_track_stack_ptr(void) |
1da177e4 | 90 | { |
4be44fcd | 91 | acpi_size current_sp; |
1da177e4 | 92 | |
1d18c058 BM |
93 | if (¤t_sp < acpi_gbl_lowest_stack_pointer) { |
94 | acpi_gbl_lowest_stack_pointer = ¤t_sp; | |
1da177e4 LT |
95 | } |
96 | ||
97 | if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) { | |
98 | acpi_gbl_deepest_nesting = acpi_gbl_nesting_level; | |
99 | } | |
100 | } | |
101 | ||
0c9938cc RM |
102 | /******************************************************************************* |
103 | * | |
104 | * FUNCTION: acpi_ut_trim_function_name | |
105 | * | |
106 | * PARAMETERS: function_name - Ascii string containing a procedure name | |
107 | * | |
108 | * RETURN: Updated pointer to the function name | |
109 | * | |
110 | * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present. | |
96b2dd1f | 111 | * This allows compiler macros such as __func__ to be used |
0c9938cc RM |
112 | * with no change to the debug output. |
113 | * | |
114 | ******************************************************************************/ | |
115 | ||
4be44fcd | 116 | static const char *acpi_ut_trim_function_name(const char *function_name) |
0c9938cc RM |
117 | { |
118 | ||
119 | /* All Function names are longer than 4 chars, check is safe */ | |
120 | ||
a18ecf41 | 121 | if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) { |
52fc0b02 | 122 | |
0c9938cc RM |
123 | /* This is the case where the original source has not been modified */ |
124 | ||
125 | return (function_name + 4); | |
126 | } | |
127 | ||
a18ecf41 | 128 | if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) { |
52fc0b02 | 129 | |
0c9938cc RM |
130 | /* This is the case where the source has been 'linuxized' */ |
131 | ||
132 | return (function_name + 5); | |
133 | } | |
134 | ||
135 | return (function_name); | |
136 | } | |
137 | ||
44f6c012 | 138 | /******************************************************************************* |
1da177e4 | 139 | * |
50df4d8b | 140 | * FUNCTION: acpi_debug_print |
1da177e4 | 141 | * |
44f6c012 | 142 | * PARAMETERS: requested_debug_level - Requested debug print level |
1da177e4 | 143 | * line_number - Caller's line number (for error output) |
f9f4601f RM |
144 | * function_name - Caller's procedure name |
145 | * module_name - Caller's module name | |
146 | * component_id - Caller's component ID | |
1da177e4 LT |
147 | * Format - Printf format field |
148 | * ... - Optional printf arguments | |
149 | * | |
150 | * RETURN: None | |
151 | * | |
152 | * DESCRIPTION: Print error message with prefix consisting of the module name, | |
153 | * line number, and component ID. | |
154 | * | |
44f6c012 | 155 | ******************************************************************************/ |
1da177e4 | 156 | |
4be44fcd | 157 | void ACPI_INTERNAL_VAR_XFACE |
50df4d8b BM |
158 | acpi_debug_print(u32 requested_debug_level, |
159 | u32 line_number, | |
160 | const char *function_name, | |
161 | const char *module_name, | |
162 | u32 component_id, const char *format, ...) | |
1da177e4 | 163 | { |
8313524a | 164 | acpi_thread_id thread_id; |
4be44fcd | 165 | va_list args; |
1da177e4 LT |
166 | |
167 | /* | |
168 | * Stay silent if the debug level or component ID is disabled | |
169 | */ | |
170 | if (!(requested_debug_level & acpi_dbg_level) || | |
4be44fcd | 171 | !(component_id & acpi_dbg_layer)) { |
1da177e4 LT |
172 | return; |
173 | } | |
174 | ||
175 | /* | |
176 | * Thread tracking and context switch notification | |
177 | */ | |
4be44fcd | 178 | thread_id = acpi_os_get_thread_id(); |
1da177e4 LT |
179 | if (thread_id != acpi_gbl_prev_thread_id) { |
180 | if (ACPI_LV_THREADS & acpi_dbg_level) { | |
4be44fcd | 181 | acpi_os_printf |
b0b7eaaf | 182 | ("\n**** Context Switch from TID %lX to TID %lX ****\n\n", |
fd350943 LB |
183 | (unsigned long)acpi_gbl_prev_thread_id, |
184 | (unsigned long)thread_id); | |
1da177e4 LT |
185 | } |
186 | ||
187 | acpi_gbl_prev_thread_id = thread_id; | |
188 | } | |
189 | ||
190 | /* | |
191 | * Display the module name, current line number, thread ID (if requested), | |
192 | * current procedure nesting level, and the current procedure name | |
193 | */ | |
4be44fcd | 194 | acpi_os_printf("%8s-%04ld ", module_name, line_number); |
1da177e4 LT |
195 | |
196 | if (ACPI_LV_THREADS & acpi_dbg_level) { | |
b0b7eaaf | 197 | acpi_os_printf("[%04lX] ", (unsigned long)thread_id); |
1da177e4 LT |
198 | } |
199 | ||
4be44fcd LB |
200 | acpi_os_printf("[%02ld] %-22.22s: ", |
201 | acpi_gbl_nesting_level, | |
202 | acpi_ut_trim_function_name(function_name)); | |
1da177e4 | 203 | |
4be44fcd LB |
204 | va_start(args, format); |
205 | acpi_os_vprintf(format, args); | |
507f046c | 206 | va_end(args); |
1da177e4 | 207 | } |
1da177e4 | 208 | |
50df4d8b | 209 | ACPI_EXPORT_SYMBOL(acpi_debug_print) |
1da177e4 | 210 | |
44f6c012 | 211 | /******************************************************************************* |
1da177e4 | 212 | * |
50df4d8b | 213 | * FUNCTION: acpi_debug_print_raw |
1da177e4 LT |
214 | * |
215 | * PARAMETERS: requested_debug_level - Requested debug print level | |
216 | * line_number - Caller's line number | |
f9f4601f RM |
217 | * function_name - Caller's procedure name |
218 | * module_name - Caller's module name | |
219 | * component_id - Caller's component ID | |
1da177e4 LT |
220 | * Format - Printf format field |
221 | * ... - Optional printf arguments | |
222 | * | |
223 | * RETURN: None | |
224 | * | |
225 | * DESCRIPTION: Print message with no headers. Has same interface as | |
226 | * debug_print so that the same macros can be used. | |
227 | * | |
44f6c012 | 228 | ******************************************************************************/ |
4be44fcd | 229 | void ACPI_INTERNAL_VAR_XFACE |
50df4d8b BM |
230 | acpi_debug_print_raw(u32 requested_debug_level, |
231 | u32 line_number, | |
232 | const char *function_name, | |
233 | const char *module_name, | |
234 | u32 component_id, const char *format, ...) | |
1da177e4 | 235 | { |
4be44fcd | 236 | va_list args; |
1da177e4 LT |
237 | |
238 | if (!(requested_debug_level & acpi_dbg_level) || | |
4be44fcd | 239 | !(component_id & acpi_dbg_layer)) { |
1da177e4 LT |
240 | return; |
241 | } | |
242 | ||
4be44fcd LB |
243 | va_start(args, format); |
244 | acpi_os_vprintf(format, args); | |
507f046c | 245 | va_end(args); |
1da177e4 | 246 | } |
1da177e4 | 247 | |
50df4d8b | 248 | ACPI_EXPORT_SYMBOL(acpi_debug_print_raw) |
1da177e4 | 249 | |
44f6c012 | 250 | /******************************************************************************* |
1da177e4 LT |
251 | * |
252 | * FUNCTION: acpi_ut_trace | |
253 | * | |
254 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
255 | * function_name - Caller's procedure name |
256 | * module_name - Caller's module name | |
257 | * component_id - Caller's component ID | |
1da177e4 LT |
258 | * |
259 | * RETURN: None | |
260 | * | |
261 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is | |
262 | * set in debug_level | |
263 | * | |
44f6c012 | 264 | ******************************************************************************/ |
1da177e4 | 265 | void |
4be44fcd | 266 | acpi_ut_trace(u32 line_number, |
4b8ed631 BM |
267 | const char *function_name, |
268 | const char *module_name, u32 component_id) | |
1da177e4 LT |
269 | { |
270 | ||
271 | acpi_gbl_nesting_level++; | |
4be44fcd | 272 | acpi_ut_track_stack_ptr(); |
1da177e4 | 273 | |
50df4d8b BM |
274 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
275 | line_number, function_name, module_name, component_id, | |
276 | "%s\n", acpi_gbl_fn_entry_str); | |
1da177e4 | 277 | } |
1da177e4 | 278 | |
8313524a | 279 | ACPI_EXPORT_SYMBOL(acpi_ut_trace) |
1da177e4 | 280 | |
44f6c012 | 281 | /******************************************************************************* |
1da177e4 LT |
282 | * |
283 | * FUNCTION: acpi_ut_trace_ptr | |
284 | * | |
285 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
286 | * function_name - Caller's procedure name |
287 | * module_name - Caller's module name | |
288 | * component_id - Caller's component ID | |
1da177e4 LT |
289 | * Pointer - Pointer to display |
290 | * | |
291 | * RETURN: None | |
292 | * | |
293 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is | |
294 | * set in debug_level | |
295 | * | |
44f6c012 | 296 | ******************************************************************************/ |
1da177e4 | 297 | void |
4be44fcd LB |
298 | acpi_ut_trace_ptr(u32 line_number, |
299 | const char *function_name, | |
4b8ed631 | 300 | const char *module_name, u32 component_id, void *pointer) |
1da177e4 LT |
301 | { |
302 | acpi_gbl_nesting_level++; | |
4be44fcd | 303 | acpi_ut_track_stack_ptr(); |
1da177e4 | 304 | |
50df4d8b BM |
305 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
306 | line_number, function_name, module_name, component_id, | |
307 | "%s %p\n", acpi_gbl_fn_entry_str, pointer); | |
1da177e4 LT |
308 | } |
309 | ||
44f6c012 | 310 | /******************************************************************************* |
1da177e4 LT |
311 | * |
312 | * FUNCTION: acpi_ut_trace_str | |
313 | * | |
314 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
315 | * function_name - Caller's procedure name |
316 | * module_name - Caller's module name | |
317 | * component_id - Caller's component ID | |
1da177e4 LT |
318 | * String - Additional string to display |
319 | * | |
320 | * RETURN: None | |
321 | * | |
322 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is | |
323 | * set in debug_level | |
324 | * | |
44f6c012 | 325 | ******************************************************************************/ |
1da177e4 LT |
326 | |
327 | void | |
4be44fcd LB |
328 | acpi_ut_trace_str(u32 line_number, |
329 | const char *function_name, | |
4b8ed631 | 330 | const char *module_name, u32 component_id, char *string) |
1da177e4 LT |
331 | { |
332 | ||
333 | acpi_gbl_nesting_level++; | |
4be44fcd | 334 | acpi_ut_track_stack_ptr(); |
1da177e4 | 335 | |
50df4d8b BM |
336 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
337 | line_number, function_name, module_name, component_id, | |
338 | "%s %s\n", acpi_gbl_fn_entry_str, string); | |
1da177e4 LT |
339 | } |
340 | ||
44f6c012 | 341 | /******************************************************************************* |
1da177e4 LT |
342 | * |
343 | * FUNCTION: acpi_ut_trace_u32 | |
344 | * | |
345 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
346 | * function_name - Caller's procedure name |
347 | * module_name - Caller's module name | |
348 | * component_id - Caller's component ID | |
1da177e4 LT |
349 | * Integer - Integer to display |
350 | * | |
351 | * RETURN: None | |
352 | * | |
353 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is | |
354 | * set in debug_level | |
355 | * | |
44f6c012 | 356 | ******************************************************************************/ |
1da177e4 LT |
357 | |
358 | void | |
4be44fcd LB |
359 | acpi_ut_trace_u32(u32 line_number, |
360 | const char *function_name, | |
4b8ed631 | 361 | const char *module_name, u32 component_id, u32 integer) |
1da177e4 LT |
362 | { |
363 | ||
364 | acpi_gbl_nesting_level++; | |
4be44fcd | 365 | acpi_ut_track_stack_ptr(); |
1da177e4 | 366 | |
50df4d8b BM |
367 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
368 | line_number, function_name, module_name, component_id, | |
369 | "%s %08X\n", acpi_gbl_fn_entry_str, integer); | |
1da177e4 LT |
370 | } |
371 | ||
44f6c012 | 372 | /******************************************************************************* |
1da177e4 LT |
373 | * |
374 | * FUNCTION: acpi_ut_exit | |
375 | * | |
376 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
377 | * function_name - Caller's procedure name |
378 | * module_name - Caller's module name | |
379 | * component_id - Caller's component ID | |
1da177e4 LT |
380 | * |
381 | * RETURN: None | |
382 | * | |
383 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is | |
384 | * set in debug_level | |
385 | * | |
44f6c012 | 386 | ******************************************************************************/ |
1da177e4 LT |
387 | |
388 | void | |
4be44fcd | 389 | acpi_ut_exit(u32 line_number, |
4b8ed631 BM |
390 | const char *function_name, |
391 | const char *module_name, u32 component_id) | |
1da177e4 LT |
392 | { |
393 | ||
50df4d8b BM |
394 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
395 | line_number, function_name, module_name, component_id, | |
396 | "%s\n", acpi_gbl_fn_exit_str); | |
1da177e4 LT |
397 | |
398 | acpi_gbl_nesting_level--; | |
399 | } | |
1da177e4 | 400 | |
8313524a | 401 | ACPI_EXPORT_SYMBOL(acpi_ut_exit) |
1da177e4 | 402 | |
44f6c012 | 403 | /******************************************************************************* |
1da177e4 LT |
404 | * |
405 | * FUNCTION: acpi_ut_status_exit | |
406 | * | |
407 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
408 | * function_name - Caller's procedure name |
409 | * module_name - Caller's module name | |
410 | * component_id - Caller's component ID | |
1da177e4 LT |
411 | * Status - Exit status code |
412 | * | |
413 | * RETURN: None | |
414 | * | |
415 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is | |
416 | * set in debug_level. Prints exit status also. | |
417 | * | |
44f6c012 | 418 | ******************************************************************************/ |
1da177e4 | 419 | void |
4be44fcd LB |
420 | acpi_ut_status_exit(u32 line_number, |
421 | const char *function_name, | |
4b8ed631 BM |
422 | const char *module_name, |
423 | u32 component_id, acpi_status status) | |
1da177e4 LT |
424 | { |
425 | ||
4be44fcd | 426 | if (ACPI_SUCCESS(status)) { |
50df4d8b BM |
427 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
428 | line_number, function_name, module_name, | |
429 | component_id, "%s %s\n", acpi_gbl_fn_exit_str, | |
430 | acpi_format_exception(status)); | |
4be44fcd | 431 | } else { |
50df4d8b BM |
432 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
433 | line_number, function_name, module_name, | |
434 | component_id, "%s ****Exception****: %s\n", | |
435 | acpi_gbl_fn_exit_str, | |
436 | acpi_format_exception(status)); | |
1da177e4 LT |
437 | } |
438 | ||
439 | acpi_gbl_nesting_level--; | |
440 | } | |
1da177e4 | 441 | |
8313524a | 442 | ACPI_EXPORT_SYMBOL(acpi_ut_status_exit) |
1da177e4 | 443 | |
44f6c012 | 444 | /******************************************************************************* |
1da177e4 LT |
445 | * |
446 | * FUNCTION: acpi_ut_value_exit | |
447 | * | |
448 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
449 | * function_name - Caller's procedure name |
450 | * module_name - Caller's module name | |
451 | * component_id - Caller's component ID | |
1da177e4 LT |
452 | * Value - Value to be printed with exit msg |
453 | * | |
454 | * RETURN: None | |
455 | * | |
456 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is | |
457 | * set in debug_level. Prints exit value also. | |
458 | * | |
44f6c012 | 459 | ******************************************************************************/ |
1da177e4 | 460 | void |
4be44fcd LB |
461 | acpi_ut_value_exit(u32 line_number, |
462 | const char *function_name, | |
4b8ed631 BM |
463 | const char *module_name, |
464 | u32 component_id, acpi_integer value) | |
1da177e4 LT |
465 | { |
466 | ||
50df4d8b BM |
467 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
468 | line_number, function_name, module_name, component_id, | |
469 | "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str, | |
470 | ACPI_FORMAT_UINT64(value)); | |
1da177e4 LT |
471 | |
472 | acpi_gbl_nesting_level--; | |
473 | } | |
1da177e4 | 474 | |
8313524a | 475 | ACPI_EXPORT_SYMBOL(acpi_ut_value_exit) |
1da177e4 | 476 | |
44f6c012 | 477 | /******************************************************************************* |
1da177e4 LT |
478 | * |
479 | * FUNCTION: acpi_ut_ptr_exit | |
480 | * | |
481 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
482 | * function_name - Caller's procedure name |
483 | * module_name - Caller's module name | |
484 | * component_id - Caller's component ID | |
44f6c012 | 485 | * Ptr - Pointer to display |
1da177e4 LT |
486 | * |
487 | * RETURN: None | |
488 | * | |
489 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is | |
490 | * set in debug_level. Prints exit value also. | |
491 | * | |
44f6c012 | 492 | ******************************************************************************/ |
1da177e4 | 493 | void |
4be44fcd LB |
494 | acpi_ut_ptr_exit(u32 line_number, |
495 | const char *function_name, | |
4b8ed631 | 496 | const char *module_name, u32 component_id, u8 *ptr) |
1da177e4 LT |
497 | { |
498 | ||
50df4d8b BM |
499 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
500 | line_number, function_name, module_name, component_id, | |
501 | "%s %p\n", acpi_gbl_fn_exit_str, ptr); | |
1da177e4 LT |
502 | |
503 | acpi_gbl_nesting_level--; | |
504 | } | |
505 | ||
506 | #endif | |
507 | ||
44f6c012 | 508 | /******************************************************************************* |
1da177e4 LT |
509 | * |
510 | * FUNCTION: acpi_ut_dump_buffer | |
511 | * | |
512 | * PARAMETERS: Buffer - Buffer to dump | |
513 | * Count - Amount to dump, in bytes | |
514 | * Display - BYTE, WORD, DWORD, or QWORD display | |
515 | * component_iD - Caller's component ID | |
516 | * | |
517 | * RETURN: None | |
518 | * | |
519 | * DESCRIPTION: Generic dump buffer in both hex and ascii. | |
520 | * | |
44f6c012 | 521 | ******************************************************************************/ |
1da177e4 | 522 | |
793c2388 | 523 | void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display) |
1da177e4 | 524 | { |
67a119f9 BM |
525 | u32 i = 0; |
526 | u32 j; | |
4be44fcd LB |
527 | u32 temp32; |
528 | u8 buf_char; | |
1da177e4 | 529 | |
5eb69180 BM |
530 | if (!buffer) { |
531 | acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n"); | |
532 | return; | |
533 | } | |
534 | ||
1da177e4 LT |
535 | if ((count < 4) || (count & 0x01)) { |
536 | display = DB_BYTE_DISPLAY; | |
537 | } | |
538 | ||
44f6c012 | 539 | /* Nasty little dump buffer routine! */ |
1da177e4 | 540 | |
1da177e4 | 541 | while (i < count) { |
52fc0b02 | 542 | |
1da177e4 LT |
543 | /* Print current offset */ |
544 | ||
67a119f9 | 545 | acpi_os_printf("%6.4X: ", i); |
1da177e4 LT |
546 | |
547 | /* Print 16 hex chars */ | |
548 | ||
549 | for (j = 0; j < 16;) { | |
550 | if (i + j >= count) { | |
52fc0b02 | 551 | |
44f6c012 | 552 | /* Dump fill spaces */ |
1da177e4 | 553 | |
4be44fcd | 554 | acpi_os_printf("%*s", ((display * 2) + 1), " "); |
67a119f9 | 555 | j += display; |
44f6c012 RM |
556 | continue; |
557 | } | |
1da177e4 LT |
558 | |
559 | switch (display) { | |
793c2388 | 560 | case DB_BYTE_DISPLAY: |
4be44fcd | 561 | default: /* Default is BYTE display */ |
1da177e4 | 562 | |
67a119f9 BM |
563 | acpi_os_printf("%02X ", |
564 | buffer[(acpi_size) i + j]); | |
1da177e4 LT |
565 | break; |
566 | ||
1da177e4 LT |
567 | case DB_WORD_DISPLAY: |
568 | ||
67a119f9 BM |
569 | ACPI_MOVE_16_TO_32(&temp32, |
570 | &buffer[(acpi_size) i + j]); | |
4be44fcd | 571 | acpi_os_printf("%04X ", temp32); |
1da177e4 LT |
572 | break; |
573 | ||
1da177e4 LT |
574 | case DB_DWORD_DISPLAY: |
575 | ||
67a119f9 BM |
576 | ACPI_MOVE_32_TO_32(&temp32, |
577 | &buffer[(acpi_size) i + j]); | |
4be44fcd | 578 | acpi_os_printf("%08X ", temp32); |
1da177e4 LT |
579 | break; |
580 | ||
1da177e4 LT |
581 | case DB_QWORD_DISPLAY: |
582 | ||
67a119f9 BM |
583 | ACPI_MOVE_32_TO_32(&temp32, |
584 | &buffer[(acpi_size) i + j]); | |
4be44fcd | 585 | acpi_os_printf("%08X", temp32); |
1da177e4 | 586 | |
67a119f9 BM |
587 | ACPI_MOVE_32_TO_32(&temp32, |
588 | &buffer[(acpi_size) i + j + | |
589 | 4]); | |
4be44fcd | 590 | acpi_os_printf("%08X ", temp32); |
1da177e4 LT |
591 | break; |
592 | } | |
44f6c012 | 593 | |
67a119f9 | 594 | j += display; |
1da177e4 LT |
595 | } |
596 | ||
597 | /* | |
0c9938cc RM |
598 | * Print the ASCII equivalent characters but watch out for the bad |
599 | * unprintable ones (printable chars are 0x20 through 0x7E) | |
1da177e4 | 600 | */ |
4be44fcd | 601 | acpi_os_printf(" "); |
1da177e4 LT |
602 | for (j = 0; j < 16; j++) { |
603 | if (i + j >= count) { | |
4be44fcd | 604 | acpi_os_printf("\n"); |
1da177e4 LT |
605 | return; |
606 | } | |
607 | ||
67a119f9 | 608 | buf_char = buffer[(acpi_size) i + j]; |
4be44fcd LB |
609 | if (ACPI_IS_PRINT(buf_char)) { |
610 | acpi_os_printf("%c", buf_char); | |
611 | } else { | |
612 | acpi_os_printf("."); | |
1da177e4 LT |
613 | } |
614 | } | |
615 | ||
616 | /* Done with that line. */ | |
617 | ||
4be44fcd | 618 | acpi_os_printf("\n"); |
1da177e4 LT |
619 | i += 16; |
620 | } | |
621 | ||
622 | return; | |
623 | } | |
793c2388 BM |
624 | |
625 | /******************************************************************************* | |
626 | * | |
627 | * FUNCTION: acpi_ut_dump_buffer | |
628 | * | |
629 | * PARAMETERS: Buffer - Buffer to dump | |
630 | * Count - Amount to dump, in bytes | |
631 | * Display - BYTE, WORD, DWORD, or QWORD display | |
632 | * component_iD - Caller's component ID | |
633 | * | |
634 | * RETURN: None | |
635 | * | |
636 | * DESCRIPTION: Generic dump buffer in both hex and ascii. | |
637 | * | |
638 | ******************************************************************************/ | |
639 | ||
640 | void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id) | |
641 | { | |
642 | ||
643 | /* Only dump the buffer if tracing is enabled */ | |
644 | ||
645 | if (!((ACPI_LV_TABLES & acpi_dbg_level) && | |
646 | (component_id & acpi_dbg_layer))) { | |
647 | return; | |
648 | } | |
649 | ||
650 | acpi_ut_dump_buffer2(buffer, count, display); | |
651 | } |