blob: 3d5fbc810b0ba30ecfc12dcb80f7d982fd58a8f4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
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
54static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF;
55static char *acpi_gbl_fn_entry_str = "----Entry";
56static char *acpi_gbl_fn_exit_str = "----Exit-";
57
58
Robert Moore44f6c012005-04-18 22:49:35 -040059/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 *
61 * FUNCTION: acpi_ut_init_stack_ptr_trace
62 *
63 * PARAMETERS: None
64 *
65 * RETURN: None
66 *
Robert Moore44f6c012005-04-18 22:49:35 -040067 * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 *
Robert Moore44f6c012005-04-18 22:49:35 -040069 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71void
72acpi_ut_init_stack_ptr_trace (
73 void)
74{
75 u32 current_sp;
76
77
78 acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF (&current_sp, NULL);
79}
80
81
Robert Moore44f6c012005-04-18 22:49:35 -040082/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 *
84 * FUNCTION: acpi_ut_track_stack_ptr
85 *
86 * PARAMETERS: None
87 *
88 * RETURN: None
89 *
Robert Moore44f6c012005-04-18 22:49:35 -040090 * DESCRIPTION: Save the current CPU stack pointer
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 *
Robert Moore44f6c012005-04-18 22:49:35 -040092 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
94void
95acpi_ut_track_stack_ptr (
96 void)
97{
98 acpi_size current_sp;
99
100
101 current_sp = ACPI_PTR_DIFF (&current_sp, NULL);
102
103 if (current_sp < acpi_gbl_lowest_stack_pointer) {
104 acpi_gbl_lowest_stack_pointer = current_sp;
105 }
106
107 if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) {
108 acpi_gbl_deepest_nesting = acpi_gbl_nesting_level;
109 }
110}
111
112
Robert Moore44f6c012005-04-18 22:49:35 -0400113/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 *
115 * FUNCTION: acpi_ut_debug_print
116 *
Robert Moore44f6c012005-04-18 22:49:35 -0400117 * PARAMETERS: requested_debug_level - Requested debug print level
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 * line_number - Caller's line number (for error output)
Robert Mooref9f46012005-07-08 00:00:00 -0400119 * function_name - Caller's procedure name
120 * module_name - Caller's module name
121 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 * Format - Printf format field
123 * ... - Optional printf arguments
124 *
125 * RETURN: None
126 *
127 * DESCRIPTION: Print error message with prefix consisting of the module name,
128 * line number, and component ID.
129 *
Robert Moore44f6c012005-04-18 22:49:35 -0400130 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
132void ACPI_INTERNAL_VAR_XFACE
133acpi_ut_debug_print (
134 u32 requested_debug_level,
135 u32 line_number,
Robert Mooref9f46012005-07-08 00:00:00 -0400136 char *function_name,
137 char *module_name,
138 u32 component_id,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 char *format,
140 ...)
141{
142 u32 thread_id;
143 va_list args;
144
145
146 /*
147 * Stay silent if the debug level or component ID is disabled
148 */
149 if (!(requested_debug_level & acpi_dbg_level) ||
Robert Mooref9f46012005-07-08 00:00:00 -0400150 !(component_id & acpi_dbg_layer)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 return;
152 }
153
154 /*
155 * Thread tracking and context switch notification
156 */
157 thread_id = acpi_os_get_thread_id ();
158
159 if (thread_id != acpi_gbl_prev_thread_id) {
160 if (ACPI_LV_THREADS & acpi_dbg_level) {
Robert Moore44f6c012005-04-18 22:49:35 -0400161 acpi_os_printf (
162 "\n**** Context Switch from TID %X to TID %X ****\n\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 acpi_gbl_prev_thread_id, thread_id);
164 }
165
166 acpi_gbl_prev_thread_id = thread_id;
167 }
168
169 /*
170 * Display the module name, current line number, thread ID (if requested),
171 * current procedure nesting level, and the current procedure name
172 */
Robert Mooref9f46012005-07-08 00:00:00 -0400173 acpi_os_printf ("%8s-%04ld ", module_name, line_number);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
175 if (ACPI_LV_THREADS & acpi_dbg_level) {
176 acpi_os_printf ("[%04lX] ", thread_id);
177 }
178
Robert Moore44f6c012005-04-18 22:49:35 -0400179 acpi_os_printf ("[%02ld] %-22.22s: ",
Robert Mooref9f46012005-07-08 00:00:00 -0400180 acpi_gbl_nesting_level, function_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
182 va_start (args, format);
183 acpi_os_vprintf (format, args);
184}
Robert Moore44f6c012005-04-18 22:49:35 -0400185
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186EXPORT_SYMBOL(acpi_ut_debug_print);
187
Robert Moore44f6c012005-04-18 22:49:35 -0400188/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 *
190 * FUNCTION: acpi_ut_debug_print_raw
191 *
192 * PARAMETERS: requested_debug_level - Requested debug print level
193 * line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400194 * function_name - Caller's procedure name
195 * module_name - Caller's module name
196 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 * Format - Printf format field
198 * ... - Optional printf arguments
199 *
200 * RETURN: None
201 *
202 * DESCRIPTION: Print message with no headers. Has same interface as
203 * debug_print so that the same macros can be used.
204 *
Robert Moore44f6c012005-04-18 22:49:35 -0400205 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206
207void ACPI_INTERNAL_VAR_XFACE
208acpi_ut_debug_print_raw (
209 u32 requested_debug_level,
210 u32 line_number,
Robert Mooref9f46012005-07-08 00:00:00 -0400211 char *function_name,
212 char *module_name,
213 u32 component_id,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 char *format,
215 ...)
216{
217 va_list args;
218
219
220 if (!(requested_debug_level & acpi_dbg_level) ||
Robert Mooref9f46012005-07-08 00:00:00 -0400221 !(component_id & acpi_dbg_layer)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 return;
223 }
224
225 va_start (args, format);
226 acpi_os_vprintf (format, args);
227}
228EXPORT_SYMBOL(acpi_ut_debug_print_raw);
229
230
Robert Moore44f6c012005-04-18 22:49:35 -0400231/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 *
233 * FUNCTION: acpi_ut_trace
234 *
235 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400236 * function_name - Caller's procedure name
237 * module_name - Caller's module name
238 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 *
240 * RETURN: None
241 *
242 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
243 * set in debug_level
244 *
Robert Moore44f6c012005-04-18 22:49:35 -0400245 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
247void
248acpi_ut_trace (
249 u32 line_number,
Robert Mooref9f46012005-07-08 00:00:00 -0400250 char *function_name,
251 char *module_name,
252 u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253{
254
255 acpi_gbl_nesting_level++;
256 acpi_ut_track_stack_ptr ();
257
Robert Mooref9f46012005-07-08 00:00:00 -0400258 acpi_ut_debug_print (ACPI_LV_FUNCTIONS,
259 line_number, function_name, module_name, component_id,
260 "%s\n", acpi_gbl_fn_entry_str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261}
262EXPORT_SYMBOL(acpi_ut_trace);
263
264
Robert Moore44f6c012005-04-18 22:49:35 -0400265/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266 *
267 * FUNCTION: acpi_ut_trace_ptr
268 *
269 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400270 * function_name - Caller's procedure name
271 * module_name - Caller's module name
272 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 * Pointer - Pointer to display
274 *
275 * RETURN: None
276 *
277 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
278 * set in debug_level
279 *
Robert Moore44f6c012005-04-18 22:49:35 -0400280 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
282void
283acpi_ut_trace_ptr (
284 u32 line_number,
Robert Mooref9f46012005-07-08 00:00:00 -0400285 char *function_name,
286 char *module_name,
287 u32 component_id,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 void *pointer)
289{
290 acpi_gbl_nesting_level++;
291 acpi_ut_track_stack_ptr ();
292
Robert Mooref9f46012005-07-08 00:00:00 -0400293 acpi_ut_debug_print (ACPI_LV_FUNCTIONS,
294 line_number, function_name, module_name, component_id,
295 "%s %p\n", acpi_gbl_fn_entry_str, pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296}
297
298
Robert Moore44f6c012005-04-18 22:49:35 -0400299/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300 *
301 * FUNCTION: acpi_ut_trace_str
302 *
303 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400304 * function_name - Caller's procedure name
305 * module_name - Caller's module name
306 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 * String - Additional string to display
308 *
309 * RETURN: None
310 *
311 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
312 * set in debug_level
313 *
Robert Moore44f6c012005-04-18 22:49:35 -0400314 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315
316void
317acpi_ut_trace_str (
318 u32 line_number,
Robert Mooref9f46012005-07-08 00:00:00 -0400319 char *function_name,
320 char *module_name,
321 u32 component_id,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 char *string)
323{
324
325 acpi_gbl_nesting_level++;
326 acpi_ut_track_stack_ptr ();
327
Robert Mooref9f46012005-07-08 00:00:00 -0400328 acpi_ut_debug_print (ACPI_LV_FUNCTIONS,
329 line_number, function_name, module_name, component_id,
330 "%s %s\n", acpi_gbl_fn_entry_str, string);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331}
332
333
Robert Moore44f6c012005-04-18 22:49:35 -0400334/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 *
336 * FUNCTION: acpi_ut_trace_u32
337 *
338 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400339 * function_name - Caller's procedure name
340 * module_name - Caller's module name
341 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 * Integer - Integer to display
343 *
344 * RETURN: None
345 *
346 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
347 * set in debug_level
348 *
Robert Moore44f6c012005-04-18 22:49:35 -0400349 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350
351void
352acpi_ut_trace_u32 (
353 u32 line_number,
Robert Mooref9f46012005-07-08 00:00:00 -0400354 char *function_name,
355 char *module_name,
356 u32 component_id,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 u32 integer)
358{
359
360 acpi_gbl_nesting_level++;
361 acpi_ut_track_stack_ptr ();
362
Robert Mooref9f46012005-07-08 00:00:00 -0400363 acpi_ut_debug_print (ACPI_LV_FUNCTIONS,
364 line_number, function_name, module_name, component_id,
365 "%s %08X\n", acpi_gbl_fn_entry_str, integer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366}
367
368
Robert Moore44f6c012005-04-18 22:49:35 -0400369/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 *
371 * FUNCTION: acpi_ut_exit
372 *
373 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400374 * function_name - Caller's procedure name
375 * module_name - Caller's module name
376 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 *
378 * RETURN: None
379 *
380 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
381 * set in debug_level
382 *
Robert Moore44f6c012005-04-18 22:49:35 -0400383 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384
385void
386acpi_ut_exit (
387 u32 line_number,
Robert Mooref9f46012005-07-08 00:00:00 -0400388 char *function_name,
389 char *module_name,
390 u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391{
392
Robert Mooref9f46012005-07-08 00:00:00 -0400393 acpi_ut_debug_print (ACPI_LV_FUNCTIONS,
394 line_number, function_name, module_name, component_id,
395 "%s\n", acpi_gbl_fn_exit_str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396
397 acpi_gbl_nesting_level--;
398}
399EXPORT_SYMBOL(acpi_ut_exit);
400
401
Robert Moore44f6c012005-04-18 22:49:35 -0400402/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 *
404 * FUNCTION: acpi_ut_status_exit
405 *
406 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400407 * function_name - Caller's procedure name
408 * module_name - Caller's module name
409 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 * Status - Exit status code
411 *
412 * RETURN: None
413 *
414 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
415 * set in debug_level. Prints exit status also.
416 *
Robert Moore44f6c012005-04-18 22:49:35 -0400417 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418
419void
420acpi_ut_status_exit (
421 u32 line_number,
Robert Mooref9f46012005-07-08 00:00:00 -0400422 char *function_name,
423 char *module_name,
424 u32 component_id,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 acpi_status status)
426{
427
428 if (ACPI_SUCCESS (status)) {
Robert Mooref9f46012005-07-08 00:00:00 -0400429 acpi_ut_debug_print (ACPI_LV_FUNCTIONS,
430 line_number, function_name, module_name, component_id,
431 "%s %s\n", acpi_gbl_fn_exit_str,
432 acpi_format_exception (status));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 }
434 else {
Robert Mooref9f46012005-07-08 00:00:00 -0400435 acpi_ut_debug_print (ACPI_LV_FUNCTIONS,
436 line_number, function_name, module_name, component_id,
437 "%s ****Exception****: %s\n", acpi_gbl_fn_exit_str,
438 acpi_format_exception (status));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 }
440
441 acpi_gbl_nesting_level--;
442}
443EXPORT_SYMBOL(acpi_ut_status_exit);
444
445
Robert Moore44f6c012005-04-18 22:49:35 -0400446/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 *
448 * FUNCTION: acpi_ut_value_exit
449 *
450 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400451 * function_name - Caller's procedure name
452 * module_name - Caller's module name
453 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 * Value - Value to be printed with exit msg
455 *
456 * RETURN: None
457 *
458 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
459 * set in debug_level. Prints exit value also.
460 *
Robert Moore44f6c012005-04-18 22:49:35 -0400461 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462
463void
464acpi_ut_value_exit (
465 u32 line_number,
Robert Mooref9f46012005-07-08 00:00:00 -0400466 char *function_name,
467 char *module_name,
468 u32 component_id,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 acpi_integer value)
470{
471
Robert Mooref9f46012005-07-08 00:00:00 -0400472 acpi_ut_debug_print (ACPI_LV_FUNCTIONS,
473 line_number, function_name, module_name, component_id,
474 "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str,
475 ACPI_FORMAT_UINT64 (value));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476
477 acpi_gbl_nesting_level--;
478}
479EXPORT_SYMBOL(acpi_ut_value_exit);
480
481
Robert Moore44f6c012005-04-18 22:49:35 -0400482/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 *
484 * FUNCTION: acpi_ut_ptr_exit
485 *
486 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400487 * function_name - Caller's procedure name
488 * module_name - Caller's module name
489 * component_id - Caller's component ID
Robert Moore44f6c012005-04-18 22:49:35 -0400490 * Ptr - Pointer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 *
492 * RETURN: None
493 *
494 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
495 * set in debug_level. Prints exit value also.
496 *
Robert Moore44f6c012005-04-18 22:49:35 -0400497 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498
499void
500acpi_ut_ptr_exit (
501 u32 line_number,
Robert Mooref9f46012005-07-08 00:00:00 -0400502 char *function_name,
503 char *module_name,
504 u32 component_id,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 u8 *ptr)
506{
507
Robert Mooref9f46012005-07-08 00:00:00 -0400508 acpi_ut_debug_print (ACPI_LV_FUNCTIONS,
509 line_number, function_name, module_name, component_id,
510 "%s %p\n", acpi_gbl_fn_exit_str, ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511
512 acpi_gbl_nesting_level--;
513}
514
515#endif
516
517
Robert Moore44f6c012005-04-18 22:49:35 -0400518/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 *
520 * FUNCTION: acpi_ut_dump_buffer
521 *
522 * PARAMETERS: Buffer - Buffer to dump
523 * Count - Amount to dump, in bytes
524 * Display - BYTE, WORD, DWORD, or QWORD display
525 * component_iD - Caller's component ID
526 *
527 * RETURN: None
528 *
529 * DESCRIPTION: Generic dump buffer in both hex and ascii.
530 *
Robert Moore44f6c012005-04-18 22:49:35 -0400531 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532
533void
534acpi_ut_dump_buffer (
535 u8 *buffer,
536 u32 count,
537 u32 display,
538 u32 component_id)
539{
540 acpi_native_uint i = 0;
541 acpi_native_uint j;
542 u32 temp32;
543 u8 buf_char;
544
545
546 /* Only dump the buffer if tracing is enabled */
547
548 if (!((ACPI_LV_TABLES & acpi_dbg_level) &&
549 (component_id & acpi_dbg_layer))) {
550 return;
551 }
552
553 if ((count < 4) || (count & 0x01)) {
554 display = DB_BYTE_DISPLAY;
555 }
556
Robert Moore44f6c012005-04-18 22:49:35 -0400557 /* Nasty little dump buffer routine! */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 while (i < count) {
560 /* Print current offset */
561
Robert Moore44f6c012005-04-18 22:49:35 -0400562 acpi_os_printf ("%6.4X: ", (u32) i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563
564 /* Print 16 hex chars */
565
566 for (j = 0; j < 16;) {
567 if (i + j >= count) {
Robert Moore44f6c012005-04-18 22:49:35 -0400568 /* Dump fill spaces */
569
570 acpi_os_printf ("%*s", ((display * 2) + 1), " ");
Robert Moore73459f72005-06-24 00:00:00 -0400571 j += (acpi_native_uint) display;
Robert Moore44f6c012005-04-18 22:49:35 -0400572 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 }
574
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 switch (display) {
Robert Moore44f6c012005-04-18 22:49:35 -0400576 default: /* Default is BYTE display */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577
Robert Moore44f6c012005-04-18 22:49:35 -0400578 acpi_os_printf ("%02X ", buffer[i + j]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 break;
580
581
582 case DB_WORD_DISPLAY:
583
584 ACPI_MOVE_16_TO_32 (&temp32, &buffer[i + j]);
585 acpi_os_printf ("%04X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 break;
587
588
589 case DB_DWORD_DISPLAY:
590
591 ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]);
592 acpi_os_printf ("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 break;
594
595
596 case DB_QWORD_DISPLAY:
597
598 ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]);
599 acpi_os_printf ("%08X", temp32);
600
601 ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j + 4]);
602 acpi_os_printf ("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 break;
604 }
Robert Moore44f6c012005-04-18 22:49:35 -0400605
Robert Moore73459f72005-06-24 00:00:00 -0400606 j += (acpi_native_uint) display;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 }
608
609 /*
610 * Print the ASCII equivalent characters
611 * But watch out for the bad unprintable ones...
612 */
Robert Moore44f6c012005-04-18 22:49:35 -0400613 acpi_os_printf (" ");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 for (j = 0; j < 16; j++) {
615 if (i + j >= count) {
616 acpi_os_printf ("\n");
617 return;
618 }
619
620 buf_char = buffer[i + j];
621 if ((buf_char > 0x1F && buf_char < 0x2E) ||
622 (buf_char > 0x2F && buf_char < 0x61) ||
623 (buf_char > 0x60 && buf_char < 0x7F)) {
624 acpi_os_printf ("%c", buf_char);
625 }
626 else {
627 acpi_os_printf (".");
628 }
629 }
630
631 /* Done with that line. */
632
633 acpi_os_printf ("\n");
634 i += 16;
635 }
636
637 return;
638}
639