[ARM] pxa: update defconfig for Verdex Pro
[linux-2.6/verdex.git] / drivers / acpi / acpica / utdebug.c
blob527d729f681506d160c0e93611f60439c0dcb740
1 /******************************************************************************
3 * Module Name: utdebug - Debug print routines
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
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.
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.
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.
44 #include <acpi/acpi.h>
45 #include "accommon.h"
47 #define _COMPONENT ACPI_UTILITIES
48 ACPI_MODULE_NAME("utdebug")
49 #ifdef ACPI_DEBUG_OUTPUT
50 static acpi_thread_id acpi_gbl_prev_thread_id;
51 static char *acpi_gbl_fn_entry_str = "----Entry";
52 static char *acpi_gbl_fn_exit_str = "----Exit-";
54 /* Local prototypes */
56 static const char *acpi_ut_trim_function_name(const char *function_name);
58 /*******************************************************************************
60 * FUNCTION: acpi_ut_init_stack_ptr_trace
62 * PARAMETERS: None
64 * RETURN: None
66 * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
68 ******************************************************************************/
70 void acpi_ut_init_stack_ptr_trace(void)
72 acpi_size current_sp;
74 acpi_gbl_entry_stack_pointer = &current_sp;
77 /*******************************************************************************
79 * FUNCTION: acpi_ut_track_stack_ptr
81 * PARAMETERS: None
83 * RETURN: None
85 * DESCRIPTION: Save the current CPU stack pointer
87 ******************************************************************************/
89 void acpi_ut_track_stack_ptr(void)
91 acpi_size current_sp;
93 if (&current_sp < acpi_gbl_lowest_stack_pointer) {
94 acpi_gbl_lowest_stack_pointer = &current_sp;
97 if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) {
98 acpi_gbl_deepest_nesting = acpi_gbl_nesting_level;
102 /*******************************************************************************
104 * FUNCTION: acpi_ut_trim_function_name
106 * PARAMETERS: function_name - Ascii string containing a procedure name
108 * RETURN: Updated pointer to the function name
110 * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
111 * This allows compiler macros such as __func__ to be used
112 * with no change to the debug output.
114 ******************************************************************************/
116 static const char *acpi_ut_trim_function_name(const char *function_name)
119 /* All Function names are longer than 4 chars, check is safe */
121 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) {
123 /* This is the case where the original source has not been modified */
125 return (function_name + 4);
128 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) {
130 /* This is the case where the source has been 'linuxized' */
132 return (function_name + 5);
135 return (function_name);
138 /*******************************************************************************
140 * FUNCTION: acpi_debug_print
142 * PARAMETERS: requested_debug_level - Requested debug print level
143 * line_number - Caller's line number (for error output)
144 * function_name - Caller's procedure name
145 * module_name - Caller's module name
146 * component_id - Caller's component ID
147 * Format - Printf format field
148 * ... - Optional printf arguments
150 * RETURN: None
152 * DESCRIPTION: Print error message with prefix consisting of the module name,
153 * line number, and component ID.
155 ******************************************************************************/
157 void ACPI_INTERNAL_VAR_XFACE
158 acpi_debug_print(u32 requested_debug_level,
159 u32 line_number,
160 const char *function_name,
161 const char *module_name,
162 u32 component_id, const char *format, ...)
164 acpi_thread_id thread_id;
165 va_list args;
168 * Stay silent if the debug level or component ID is disabled
170 if (!(requested_debug_level & acpi_dbg_level) ||
171 !(component_id & acpi_dbg_layer)) {
172 return;
176 * Thread tracking and context switch notification
178 thread_id = acpi_os_get_thread_id();
179 if (thread_id != acpi_gbl_prev_thread_id) {
180 if (ACPI_LV_THREADS & acpi_dbg_level) {
181 acpi_os_printf
182 ("\n**** Context Switch from TID %p to TID %p ****\n\n",
183 ACPI_CAST_PTR(void, acpi_gbl_prev_thread_id),
184 ACPI_CAST_PTR(void, thread_id));
187 acpi_gbl_prev_thread_id = thread_id;
191 * Display the module name, current line number, thread ID (if requested),
192 * current procedure nesting level, and the current procedure name
194 acpi_os_printf("%8s-%04ld ", module_name, line_number);
196 if (ACPI_LV_THREADS & acpi_dbg_level) {
197 acpi_os_printf("[%p] ", ACPI_CAST_PTR(void, thread_id));
200 acpi_os_printf("[%02ld] %-22.22s: ",
201 acpi_gbl_nesting_level,
202 acpi_ut_trim_function_name(function_name));
204 va_start(args, format);
205 acpi_os_vprintf(format, args);
206 va_end(args);
209 ACPI_EXPORT_SYMBOL(acpi_debug_print)
211 /*******************************************************************************
213 * FUNCTION: acpi_debug_print_raw
215 * PARAMETERS: requested_debug_level - Requested debug print level
216 * line_number - Caller's line number
217 * function_name - Caller's procedure name
218 * module_name - Caller's module name
219 * component_id - Caller's component ID
220 * Format - Printf format field
221 * ... - Optional printf arguments
223 * RETURN: None
225 * DESCRIPTION: Print message with no headers. Has same interface as
226 * debug_print so that the same macros can be used.
228 ******************************************************************************/
229 void ACPI_INTERNAL_VAR_XFACE
230 acpi_debug_print_raw(u32 requested_debug_level,
231 u32 line_number,
232 const char *function_name,
233 const char *module_name,
234 u32 component_id, const char *format, ...)
236 va_list args;
238 if (!(requested_debug_level & acpi_dbg_level) ||
239 !(component_id & acpi_dbg_layer)) {
240 return;
243 va_start(args, format);
244 acpi_os_vprintf(format, args);
245 va_end(args);
248 ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
250 /*******************************************************************************
252 * FUNCTION: acpi_ut_trace
254 * PARAMETERS: line_number - Caller's line number
255 * function_name - Caller's procedure name
256 * module_name - Caller's module name
257 * component_id - Caller's component ID
259 * RETURN: None
261 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
262 * set in debug_level
264 ******************************************************************************/
265 void
266 acpi_ut_trace(u32 line_number,
267 const char *function_name,
268 const char *module_name, u32 component_id)
271 acpi_gbl_nesting_level++;
272 acpi_ut_track_stack_ptr();
274 acpi_debug_print(ACPI_LV_FUNCTIONS,
275 line_number, function_name, module_name, component_id,
276 "%s\n", acpi_gbl_fn_entry_str);
279 ACPI_EXPORT_SYMBOL(acpi_ut_trace)
281 /*******************************************************************************
283 * FUNCTION: acpi_ut_trace_ptr
285 * PARAMETERS: line_number - Caller's line number
286 * function_name - Caller's procedure name
287 * module_name - Caller's module name
288 * component_id - Caller's component ID
289 * Pointer - Pointer to display
291 * RETURN: None
293 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
294 * set in debug_level
296 ******************************************************************************/
297 void
298 acpi_ut_trace_ptr(u32 line_number,
299 const char *function_name,
300 const char *module_name, u32 component_id, void *pointer)
302 acpi_gbl_nesting_level++;
303 acpi_ut_track_stack_ptr();
305 acpi_debug_print(ACPI_LV_FUNCTIONS,
306 line_number, function_name, module_name, component_id,
307 "%s %p\n", acpi_gbl_fn_entry_str, pointer);
310 /*******************************************************************************
312 * FUNCTION: acpi_ut_trace_str
314 * PARAMETERS: line_number - Caller's line number
315 * function_name - Caller's procedure name
316 * module_name - Caller's module name
317 * component_id - Caller's component ID
318 * String - Additional string to display
320 * RETURN: None
322 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
323 * set in debug_level
325 ******************************************************************************/
327 void
328 acpi_ut_trace_str(u32 line_number,
329 const char *function_name,
330 const char *module_name, u32 component_id, char *string)
333 acpi_gbl_nesting_level++;
334 acpi_ut_track_stack_ptr();
336 acpi_debug_print(ACPI_LV_FUNCTIONS,
337 line_number, function_name, module_name, component_id,
338 "%s %s\n", acpi_gbl_fn_entry_str, string);
341 /*******************************************************************************
343 * FUNCTION: acpi_ut_trace_u32
345 * PARAMETERS: line_number - Caller's line number
346 * function_name - Caller's procedure name
347 * module_name - Caller's module name
348 * component_id - Caller's component ID
349 * Integer - Integer to display
351 * RETURN: None
353 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
354 * set in debug_level
356 ******************************************************************************/
358 void
359 acpi_ut_trace_u32(u32 line_number,
360 const char *function_name,
361 const char *module_name, u32 component_id, u32 integer)
364 acpi_gbl_nesting_level++;
365 acpi_ut_track_stack_ptr();
367 acpi_debug_print(ACPI_LV_FUNCTIONS,
368 line_number, function_name, module_name, component_id,
369 "%s %08X\n", acpi_gbl_fn_entry_str, integer);
372 /*******************************************************************************
374 * FUNCTION: acpi_ut_exit
376 * PARAMETERS: line_number - Caller's line number
377 * function_name - Caller's procedure name
378 * module_name - Caller's module name
379 * component_id - Caller's component ID
381 * RETURN: None
383 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
384 * set in debug_level
386 ******************************************************************************/
388 void
389 acpi_ut_exit(u32 line_number,
390 const char *function_name,
391 const char *module_name, u32 component_id)
394 acpi_debug_print(ACPI_LV_FUNCTIONS,
395 line_number, function_name, module_name, component_id,
396 "%s\n", acpi_gbl_fn_exit_str);
398 acpi_gbl_nesting_level--;
401 ACPI_EXPORT_SYMBOL(acpi_ut_exit)
403 /*******************************************************************************
405 * FUNCTION: acpi_ut_status_exit
407 * PARAMETERS: line_number - Caller's line number
408 * function_name - Caller's procedure name
409 * module_name - Caller's module name
410 * component_id - Caller's component ID
411 * Status - Exit status code
413 * RETURN: None
415 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
416 * set in debug_level. Prints exit status also.
418 ******************************************************************************/
419 void
420 acpi_ut_status_exit(u32 line_number,
421 const char *function_name,
422 const char *module_name,
423 u32 component_id, acpi_status status)
426 if (ACPI_SUCCESS(status)) {
427 acpi_debug_print(ACPI_LV_FUNCTIONS,
428 line_number, function_name, module_name,
429 component_id, "%s %s\n", acpi_gbl_fn_exit_str,
430 acpi_format_exception(status));
431 } else {
432 acpi_debug_print(ACPI_LV_FUNCTIONS,
433 line_number, function_name, module_name,
434 component_id, "%s ****Exception****: %s\n",
435 acpi_gbl_fn_exit_str,
436 acpi_format_exception(status));
439 acpi_gbl_nesting_level--;
442 ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
444 /*******************************************************************************
446 * FUNCTION: acpi_ut_value_exit
448 * PARAMETERS: line_number - Caller's line number
449 * function_name - Caller's procedure name
450 * module_name - Caller's module name
451 * component_id - Caller's component ID
452 * Value - Value to be printed with exit msg
454 * RETURN: None
456 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
457 * set in debug_level. Prints exit value also.
459 ******************************************************************************/
460 void
461 acpi_ut_value_exit(u32 line_number,
462 const char *function_name,
463 const char *module_name,
464 u32 component_id, acpi_integer value)
467 acpi_debug_print(ACPI_LV_FUNCTIONS,
468 line_number, function_name, module_name, component_id,
469 "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str,
470 ACPI_FORMAT_UINT64(value));
472 acpi_gbl_nesting_level--;
475 ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)
477 /*******************************************************************************
479 * FUNCTION: acpi_ut_ptr_exit
481 * PARAMETERS: line_number - Caller's line number
482 * function_name - Caller's procedure name
483 * module_name - Caller's module name
484 * component_id - Caller's component ID
485 * Ptr - Pointer to display
487 * RETURN: None
489 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
490 * set in debug_level. Prints exit value also.
492 ******************************************************************************/
493 void
494 acpi_ut_ptr_exit(u32 line_number,
495 const char *function_name,
496 const char *module_name, u32 component_id, u8 *ptr)
499 acpi_debug_print(ACPI_LV_FUNCTIONS,
500 line_number, function_name, module_name, component_id,
501 "%s %p\n", acpi_gbl_fn_exit_str, ptr);
503 acpi_gbl_nesting_level--;
506 #endif
508 /*******************************************************************************
510 * FUNCTION: acpi_ut_dump_buffer
512 * PARAMETERS: Buffer - Buffer to dump
513 * Count - Amount to dump, in bytes
514 * Display - BYTE, WORD, DWORD, or QWORD display
515 * component_iD - Caller's component ID
517 * RETURN: None
519 * DESCRIPTION: Generic dump buffer in both hex and ascii.
521 ******************************************************************************/
523 void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display)
525 u32 i = 0;
526 u32 j;
527 u32 temp32;
528 u8 buf_char;
530 if (!buffer) {
531 acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n");
532 return;
535 if ((count < 4) || (count & 0x01)) {
536 display = DB_BYTE_DISPLAY;
539 /* Nasty little dump buffer routine! */
541 while (i < count) {
543 /* Print current offset */
545 acpi_os_printf("%6.4X: ", i);
547 /* Print 16 hex chars */
549 for (j = 0; j < 16;) {
550 if (i + j >= count) {
552 /* Dump fill spaces */
554 acpi_os_printf("%*s", ((display * 2) + 1), " ");
555 j += display;
556 continue;
559 switch (display) {
560 case DB_BYTE_DISPLAY:
561 default: /* Default is BYTE display */
563 acpi_os_printf("%02X ",
564 buffer[(acpi_size) i + j]);
565 break;
567 case DB_WORD_DISPLAY:
569 ACPI_MOVE_16_TO_32(&temp32,
570 &buffer[(acpi_size) i + j]);
571 acpi_os_printf("%04X ", temp32);
572 break;
574 case DB_DWORD_DISPLAY:
576 ACPI_MOVE_32_TO_32(&temp32,
577 &buffer[(acpi_size) i + j]);
578 acpi_os_printf("%08X ", temp32);
579 break;
581 case DB_QWORD_DISPLAY:
583 ACPI_MOVE_32_TO_32(&temp32,
584 &buffer[(acpi_size) i + j]);
585 acpi_os_printf("%08X", temp32);
587 ACPI_MOVE_32_TO_32(&temp32,
588 &buffer[(acpi_size) i + j +
589 4]);
590 acpi_os_printf("%08X ", temp32);
591 break;
594 j += display;
598 * Print the ASCII equivalent characters but watch out for the bad
599 * unprintable ones (printable chars are 0x20 through 0x7E)
601 acpi_os_printf(" ");
602 for (j = 0; j < 16; j++) {
603 if (i + j >= count) {
604 acpi_os_printf("\n");
605 return;
608 buf_char = buffer[(acpi_size) i + j];
609 if (ACPI_IS_PRINT(buf_char)) {
610 acpi_os_printf("%c", buf_char);
611 } else {
612 acpi_os_printf(".");
616 /* Done with that line. */
618 acpi_os_printf("\n");
619 i += 16;
622 return;
625 /*******************************************************************************
627 * FUNCTION: acpi_ut_dump_buffer
629 * PARAMETERS: Buffer - Buffer to dump
630 * Count - Amount to dump, in bytes
631 * Display - BYTE, WORD, DWORD, or QWORD display
632 * component_iD - Caller's component ID
634 * RETURN: None
636 * DESCRIPTION: Generic dump buffer in both hex and ascii.
638 ******************************************************************************/
640 void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id)
643 /* Only dump the buffer if tracing is enabled */
645 if (!((ACPI_LV_TABLES & acpi_dbg_level) &&
646 (component_id & acpi_dbg_layer))) {
647 return;
650 acpi_ut_dump_buffer2(buffer, count, display);