]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /****************************************************************************** |
2 | * | |
3 | * Module Name: utdebug - Debug print routines | |
4 | * | |
5 | *****************************************************************************/ | |
6 | ||
7 | /* | |
6c9deb72 | 8 | * Copyright (C) 2000 - 2007, R. Byron Moore |
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 LT |
44 | #include <acpi/acpi.h> |
45 | ||
46 | #define _COMPONENT ACPI_UTILITIES | |
4be44fcd | 47 | ACPI_MODULE_NAME("utdebug") |
1da177e4 | 48 | #ifdef ACPI_DEBUG_OUTPUT |
ab8aa06a | 49 | static acpi_thread_id acpi_gbl_prev_thread_id; |
4be44fcd LB |
50 | static char *acpi_gbl_fn_entry_str = "----Entry"; |
51 | static char *acpi_gbl_fn_exit_str = "----Exit-"; | |
1da177e4 | 52 | |
0c9938cc RM |
53 | /* Local prototypes */ |
54 | ||
4be44fcd | 55 | static const char *acpi_ut_trim_function_name(const char *function_name); |
1da177e4 | 56 | |
44f6c012 | 57 | /******************************************************************************* |
1da177e4 LT |
58 | * |
59 | * FUNCTION: acpi_ut_init_stack_ptr_trace | |
60 | * | |
61 | * PARAMETERS: None | |
62 | * | |
63 | * RETURN: None | |
64 | * | |
44f6c012 | 65 | * DESCRIPTION: Save the current CPU stack pointer at subsystem startup |
1da177e4 | 66 | * |
44f6c012 | 67 | ******************************************************************************/ |
1da177e4 | 68 | |
4be44fcd | 69 | void acpi_ut_init_stack_ptr_trace(void) |
1da177e4 | 70 | { |
4be44fcd | 71 | u32 current_sp; |
1da177e4 | 72 | |
4be44fcd | 73 | acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF(¤t_sp, NULL); |
1da177e4 LT |
74 | } |
75 | ||
44f6c012 | 76 | /******************************************************************************* |
1da177e4 LT |
77 | * |
78 | * FUNCTION: acpi_ut_track_stack_ptr | |
79 | * | |
80 | * PARAMETERS: None | |
81 | * | |
82 | * RETURN: None | |
83 | * | |
44f6c012 | 84 | * DESCRIPTION: Save the current CPU stack pointer |
1da177e4 | 85 | * |
44f6c012 | 86 | ******************************************************************************/ |
1da177e4 | 87 | |
4be44fcd | 88 | void acpi_ut_track_stack_ptr(void) |
1da177e4 | 89 | { |
4be44fcd | 90 | acpi_size current_sp; |
1da177e4 | 91 | |
4be44fcd | 92 | current_sp = ACPI_PTR_DIFF(¤t_sp, NULL); |
1da177e4 LT |
93 | |
94 | if (current_sp < acpi_gbl_lowest_stack_pointer) { | |
95 | acpi_gbl_lowest_stack_pointer = current_sp; | |
96 | } | |
97 | ||
98 | if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) { | |
99 | acpi_gbl_deepest_nesting = acpi_gbl_nesting_level; | |
100 | } | |
101 | } | |
102 | ||
0c9938cc RM |
103 | /******************************************************************************* |
104 | * | |
105 | * FUNCTION: acpi_ut_trim_function_name | |
106 | * | |
107 | * PARAMETERS: function_name - Ascii string containing a procedure name | |
108 | * | |
109 | * RETURN: Updated pointer to the function name | |
110 | * | |
111 | * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present. | |
112 | * This allows compiler macros such as __FUNCTION__ to be used | |
113 | * with no change to the debug output. | |
114 | * | |
115 | ******************************************************************************/ | |
116 | ||
4be44fcd | 117 | static const char *acpi_ut_trim_function_name(const char *function_name) |
0c9938cc RM |
118 | { |
119 | ||
120 | /* All Function names are longer than 4 chars, check is safe */ | |
121 | ||
a18ecf41 | 122 | if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) { |
52fc0b02 | 123 | |
0c9938cc RM |
124 | /* This is the case where the original source has not been modified */ |
125 | ||
126 | return (function_name + 4); | |
127 | } | |
128 | ||
a18ecf41 | 129 | if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) { |
52fc0b02 | 130 | |
0c9938cc RM |
131 | /* This is the case where the source has been 'linuxized' */ |
132 | ||
133 | return (function_name + 5); | |
134 | } | |
135 | ||
136 | return (function_name); | |
137 | } | |
138 | ||
44f6c012 | 139 | /******************************************************************************* |
1da177e4 LT |
140 | * |
141 | * FUNCTION: acpi_ut_debug_print | |
142 | * | |
44f6c012 | 143 | * PARAMETERS: requested_debug_level - Requested debug print level |
1da177e4 | 144 | * line_number - Caller's line number (for error output) |
f9f4601f RM |
145 | * function_name - Caller's procedure name |
146 | * module_name - Caller's module name | |
147 | * component_id - Caller's component ID | |
1da177e4 LT |
148 | * Format - Printf format field |
149 | * ... - Optional printf arguments | |
150 | * | |
151 | * RETURN: None | |
152 | * | |
153 | * DESCRIPTION: Print error message with prefix consisting of the module name, | |
154 | * line number, and component ID. | |
155 | * | |
44f6c012 | 156 | ******************************************************************************/ |
1da177e4 | 157 | |
4be44fcd LB |
158 | void ACPI_INTERNAL_VAR_XFACE |
159 | acpi_ut_debug_print(u32 requested_debug_level, | |
160 | u32 line_number, | |
161 | const char *function_name, | |
162 | char *module_name, u32 component_id, 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); | |
1da177e4 | 206 | } |
1da177e4 | 207 | |
8313524a | 208 | ACPI_EXPORT_SYMBOL(acpi_ut_debug_print) |
1da177e4 | 209 | |
44f6c012 | 210 | /******************************************************************************* |
1da177e4 LT |
211 | * |
212 | * FUNCTION: acpi_ut_debug_print_raw | |
213 | * | |
214 | * PARAMETERS: requested_debug_level - Requested debug print level | |
215 | * line_number - Caller's line number | |
f9f4601f RM |
216 | * function_name - Caller's procedure name |
217 | * module_name - Caller's module name | |
218 | * component_id - Caller's component ID | |
1da177e4 LT |
219 | * Format - Printf format field |
220 | * ... - Optional printf arguments | |
221 | * | |
222 | * RETURN: None | |
223 | * | |
224 | * DESCRIPTION: Print message with no headers. Has same interface as | |
225 | * debug_print so that the same macros can be used. | |
226 | * | |
44f6c012 | 227 | ******************************************************************************/ |
4be44fcd LB |
228 | void ACPI_INTERNAL_VAR_XFACE |
229 | acpi_ut_debug_print_raw(u32 requested_debug_level, | |
230 | u32 line_number, | |
231 | const char *function_name, | |
232 | char *module_name, u32 component_id, char *format, ...) | |
1da177e4 | 233 | { |
4be44fcd | 234 | va_list args; |
1da177e4 LT |
235 | |
236 | if (!(requested_debug_level & acpi_dbg_level) || | |
4be44fcd | 237 | !(component_id & acpi_dbg_layer)) { |
1da177e4 LT |
238 | return; |
239 | } | |
240 | ||
4be44fcd LB |
241 | va_start(args, format); |
242 | acpi_os_vprintf(format, args); | |
1da177e4 | 243 | } |
1da177e4 | 244 | |
8313524a | 245 | ACPI_EXPORT_SYMBOL(acpi_ut_debug_print_raw) |
1da177e4 | 246 | |
44f6c012 | 247 | /******************************************************************************* |
1da177e4 LT |
248 | * |
249 | * FUNCTION: acpi_ut_trace | |
250 | * | |
251 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
252 | * function_name - Caller's procedure name |
253 | * module_name - Caller's module name | |
254 | * component_id - Caller's component ID | |
1da177e4 LT |
255 | * |
256 | * RETURN: None | |
257 | * | |
258 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is | |
259 | * set in debug_level | |
260 | * | |
44f6c012 | 261 | ******************************************************************************/ |
1da177e4 | 262 | void |
4be44fcd LB |
263 | acpi_ut_trace(u32 line_number, |
264 | const char *function_name, char *module_name, u32 component_id) | |
1da177e4 LT |
265 | { |
266 | ||
267 | acpi_gbl_nesting_level++; | |
4be44fcd | 268 | acpi_ut_track_stack_ptr(); |
1da177e4 | 269 | |
4be44fcd LB |
270 | acpi_ut_debug_print(ACPI_LV_FUNCTIONS, |
271 | line_number, function_name, module_name, | |
272 | component_id, "%s\n", acpi_gbl_fn_entry_str); | |
1da177e4 | 273 | } |
1da177e4 | 274 | |
8313524a | 275 | ACPI_EXPORT_SYMBOL(acpi_ut_trace) |
1da177e4 | 276 | |
44f6c012 | 277 | /******************************************************************************* |
1da177e4 LT |
278 | * |
279 | * FUNCTION: acpi_ut_trace_ptr | |
280 | * | |
281 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
282 | * function_name - Caller's procedure name |
283 | * module_name - Caller's module name | |
284 | * component_id - Caller's component ID | |
1da177e4 LT |
285 | * 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 | * | |
44f6c012 | 292 | ******************************************************************************/ |
1da177e4 | 293 | void |
4be44fcd LB |
294 | acpi_ut_trace_ptr(u32 line_number, |
295 | const char *function_name, | |
296 | char *module_name, u32 component_id, void *pointer) | |
1da177e4 LT |
297 | { |
298 | acpi_gbl_nesting_level++; | |
4be44fcd | 299 | acpi_ut_track_stack_ptr(); |
1da177e4 | 300 | |
4be44fcd LB |
301 | 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); | |
1da177e4 LT |
305 | } |
306 | ||
44f6c012 | 307 | /******************************************************************************* |
1da177e4 LT |
308 | * |
309 | * FUNCTION: acpi_ut_trace_str | |
310 | * | |
311 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
312 | * function_name - Caller's procedure name |
313 | * module_name - Caller's module name | |
314 | * component_id - Caller's component ID | |
1da177e4 LT |
315 | * 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 | * | |
44f6c012 | 322 | ******************************************************************************/ |
1da177e4 LT |
323 | |
324 | void | |
4be44fcd LB |
325 | acpi_ut_trace_str(u32 line_number, |
326 | const char *function_name, | |
327 | char *module_name, u32 component_id, char *string) | |
1da177e4 LT |
328 | { |
329 | ||
330 | acpi_gbl_nesting_level++; | |
4be44fcd | 331 | acpi_ut_track_stack_ptr(); |
1da177e4 | 332 | |
4be44fcd LB |
333 | 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); | |
1da177e4 LT |
337 | } |
338 | ||
44f6c012 | 339 | /******************************************************************************* |
1da177e4 LT |
340 | * |
341 | * FUNCTION: acpi_ut_trace_u32 | |
342 | * | |
343 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
344 | * function_name - Caller's procedure name |
345 | * module_name - Caller's module name | |
346 | * component_id - Caller's component ID | |
1da177e4 LT |
347 | * 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 | * | |
44f6c012 | 354 | ******************************************************************************/ |
1da177e4 LT |
355 | |
356 | void | |
4be44fcd LB |
357 | acpi_ut_trace_u32(u32 line_number, |
358 | const char *function_name, | |
359 | char *module_name, u32 component_id, u32 integer) | |
1da177e4 LT |
360 | { |
361 | ||
362 | acpi_gbl_nesting_level++; | |
4be44fcd | 363 | acpi_ut_track_stack_ptr(); |
1da177e4 | 364 | |
4be44fcd LB |
365 | 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); | |
1da177e4 LT |
369 | } |
370 | ||
44f6c012 | 371 | /******************************************************************************* |
1da177e4 LT |
372 | * |
373 | * FUNCTION: acpi_ut_exit | |
374 | * | |
375 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
376 | * function_name - Caller's procedure name |
377 | * module_name - Caller's module name | |
378 | * component_id - Caller's component ID | |
1da177e4 LT |
379 | * |
380 | * RETURN: None | |
381 | * | |
382 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is | |
383 | * set in debug_level | |
384 | * | |
44f6c012 | 385 | ******************************************************************************/ |
1da177e4 LT |
386 | |
387 | void | |
4be44fcd LB |
388 | acpi_ut_exit(u32 line_number, |
389 | const char *function_name, char *module_name, u32 component_id) | |
1da177e4 LT |
390 | { |
391 | ||
4be44fcd LB |
392 | acpi_ut_debug_print(ACPI_LV_FUNCTIONS, |
393 | line_number, function_name, module_name, | |
394 | component_id, "%s\n", acpi_gbl_fn_exit_str); | |
1da177e4 LT |
395 | |
396 | acpi_gbl_nesting_level--; | |
397 | } | |
1da177e4 | 398 | |
8313524a | 399 | ACPI_EXPORT_SYMBOL(acpi_ut_exit) |
1da177e4 | 400 | |
44f6c012 | 401 | /******************************************************************************* |
1da177e4 LT |
402 | * |
403 | * FUNCTION: acpi_ut_status_exit | |
404 | * | |
405 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
406 | * function_name - Caller's procedure name |
407 | * module_name - Caller's module name | |
408 | * component_id - Caller's component ID | |
1da177e4 LT |
409 | * 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 | * | |
44f6c012 | 416 | ******************************************************************************/ |
1da177e4 | 417 | void |
4be44fcd LB |
418 | acpi_ut_status_exit(u32 line_number, |
419 | const char *function_name, | |
420 | char *module_name, u32 component_id, acpi_status status) | |
1da177e4 LT |
421 | { |
422 | ||
4be44fcd LB |
423 | 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)); | |
1da177e4 LT |
435 | } |
436 | ||
437 | acpi_gbl_nesting_level--; | |
438 | } | |
1da177e4 | 439 | |
8313524a | 440 | ACPI_EXPORT_SYMBOL(acpi_ut_status_exit) |
1da177e4 | 441 | |
44f6c012 | 442 | /******************************************************************************* |
1da177e4 LT |
443 | * |
444 | * FUNCTION: acpi_ut_value_exit | |
445 | * | |
446 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
447 | * function_name - Caller's procedure name |
448 | * module_name - Caller's module name | |
449 | * component_id - Caller's component ID | |
1da177e4 LT |
450 | * 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 | * | |
44f6c012 | 457 | ******************************************************************************/ |
1da177e4 | 458 | void |
4be44fcd LB |
459 | acpi_ut_value_exit(u32 line_number, |
460 | const char *function_name, | |
461 | char *module_name, u32 component_id, acpi_integer value) | |
1da177e4 LT |
462 | { |
463 | ||
4be44fcd LB |
464 | 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)); | |
1da177e4 LT |
468 | |
469 | acpi_gbl_nesting_level--; | |
470 | } | |
1da177e4 | 471 | |
8313524a | 472 | ACPI_EXPORT_SYMBOL(acpi_ut_value_exit) |
1da177e4 | 473 | |
44f6c012 | 474 | /******************************************************************************* |
1da177e4 LT |
475 | * |
476 | * FUNCTION: acpi_ut_ptr_exit | |
477 | * | |
478 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
479 | * function_name - Caller's procedure name |
480 | * module_name - Caller's module name | |
481 | * component_id - Caller's component ID | |
44f6c012 | 482 | * Ptr - Pointer to display |
1da177e4 LT |
483 | * |
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 | * | |
44f6c012 | 489 | ******************************************************************************/ |
1da177e4 | 490 | void |
4be44fcd LB |
491 | acpi_ut_ptr_exit(u32 line_number, |
492 | const char *function_name, | |
493 | char *module_name, u32 component_id, u8 * ptr) | |
1da177e4 LT |
494 | { |
495 | ||
4be44fcd LB |
496 | 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); | |
1da177e4 LT |
499 | |
500 | acpi_gbl_nesting_level--; | |
501 | } | |
502 | ||
503 | #endif | |
504 | ||
44f6c012 | 505 | /******************************************************************************* |
1da177e4 LT |
506 | * |
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 | * | |
44f6c012 | 518 | ******************************************************************************/ |
1da177e4 | 519 | |
793c2388 | 520 | void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display) |
1da177e4 | 521 | { |
4be44fcd LB |
522 | acpi_native_uint i = 0; |
523 | acpi_native_uint j; | |
524 | u32 temp32; | |
525 | u8 buf_char; | |
1da177e4 | 526 | |
1da177e4 LT |
527 | if ((count < 4) || (count & 0x01)) { |
528 | display = DB_BYTE_DISPLAY; | |
529 | } | |
530 | ||
44f6c012 | 531 | /* Nasty little dump buffer routine! */ |
1da177e4 | 532 | |
1da177e4 | 533 | while (i < count) { |
52fc0b02 | 534 | |
1da177e4 LT |
535 | /* Print current offset */ |
536 | ||
4be44fcd | 537 | acpi_os_printf("%6.4X: ", (u32) i); |
1da177e4 LT |
538 | |
539 | /* Print 16 hex chars */ | |
540 | ||
541 | for (j = 0; j < 16;) { | |
542 | if (i + j >= count) { | |
52fc0b02 | 543 | |
44f6c012 | 544 | /* Dump fill spaces */ |
1da177e4 | 545 | |
4be44fcd | 546 | acpi_os_printf("%*s", ((display * 2) + 1), " "); |
73459f73 | 547 | j += (acpi_native_uint) display; |
44f6c012 RM |
548 | continue; |
549 | } | |
1da177e4 LT |
550 | |
551 | switch (display) { | |
793c2388 | 552 | case DB_BYTE_DISPLAY: |
4be44fcd | 553 | default: /* Default is BYTE display */ |
1da177e4 | 554 | |
4be44fcd | 555 | acpi_os_printf("%02X ", buffer[i + j]); |
1da177e4 LT |
556 | break; |
557 | ||
1da177e4 LT |
558 | case DB_WORD_DISPLAY: |
559 | ||
4be44fcd LB |
560 | ACPI_MOVE_16_TO_32(&temp32, &buffer[i + j]); |
561 | acpi_os_printf("%04X ", temp32); | |
1da177e4 LT |
562 | break; |
563 | ||
1da177e4 LT |
564 | case DB_DWORD_DISPLAY: |
565 | ||
4be44fcd LB |
566 | ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j]); |
567 | acpi_os_printf("%08X ", temp32); | |
1da177e4 LT |
568 | break; |
569 | ||
1da177e4 LT |
570 | case DB_QWORD_DISPLAY: |
571 | ||
4be44fcd LB |
572 | ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j]); |
573 | acpi_os_printf("%08X", temp32); | |
1da177e4 | 574 | |
4be44fcd LB |
575 | ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j + 4]); |
576 | acpi_os_printf("%08X ", temp32); | |
1da177e4 LT |
577 | break; |
578 | } | |
44f6c012 | 579 | |
73459f73 | 580 | j += (acpi_native_uint) display; |
1da177e4 LT |
581 | } |
582 | ||
583 | /* | |
0c9938cc RM |
584 | * Print the ASCII equivalent characters but watch out for the bad |
585 | * unprintable ones (printable chars are 0x20 through 0x7E) | |
1da177e4 | 586 | */ |
4be44fcd | 587 | acpi_os_printf(" "); |
1da177e4 LT |
588 | for (j = 0; j < 16; j++) { |
589 | if (i + j >= count) { | |
4be44fcd | 590 | acpi_os_printf("\n"); |
1da177e4 LT |
591 | return; |
592 | } | |
593 | ||
594 | buf_char = buffer[i + j]; | |
4be44fcd LB |
595 | if (ACPI_IS_PRINT(buf_char)) { |
596 | acpi_os_printf("%c", buf_char); | |
597 | } else { | |
598 | acpi_os_printf("."); | |
1da177e4 LT |
599 | } |
600 | } | |
601 | ||
602 | /* Done with that line. */ | |
603 | ||
4be44fcd | 604 | acpi_os_printf("\n"); |
1da177e4 LT |
605 | i += 16; |
606 | } | |
607 | ||
608 | return; | |
609 | } | |
793c2388 BM |
610 | |
611 | /******************************************************************************* | |
612 | * | |
613 | * FUNCTION: acpi_ut_dump_buffer | |
614 | * | |
615 | * PARAMETERS: Buffer - Buffer to dump | |
616 | * Count - Amount to dump, in bytes | |
617 | * Display - BYTE, WORD, DWORD, or QWORD display | |
618 | * component_iD - Caller's component ID | |
619 | * | |
620 | * RETURN: None | |
621 | * | |
622 | * DESCRIPTION: Generic dump buffer in both hex and ascii. | |
623 | * | |
624 | ******************************************************************************/ | |
625 | ||
626 | void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id) | |
627 | { | |
628 | ||
629 | /* Only dump the buffer if tracing is enabled */ | |
630 | ||
631 | if (!((ACPI_LV_TABLES & acpi_dbg_level) && | |
632 | (component_id & acpi_dbg_layer))) { | |
633 | return; | |
634 | } | |
635 | ||
636 | acpi_ut_dump_buffer2(buffer, count, display); | |
637 | } |