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