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