1 /******************************************************************************
3 * Module Name: cmdebug - Debug print routines
6 *****************************************************************************/
9 * Copyright (C) 2000, 2001 R. Byron Moore
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #define _COMPONENT ACPI_UTILITIES
30 MODULE_NAME ("cmdebug")
33 /*****************************************************************************
35 * FUNCTION: Get/Set debug level
37 * DESCRIPTION: Get or set value of the debug flag
39 * These are used to allow user's to get/set the debug level
41 ****************************************************************************/
45 get_debug_level (void)
48 return (acpi_dbg_level
);
56 acpi_dbg_level
= new_debug_level
;
60 /*****************************************************************************
62 * FUNCTION: Function_trace
64 * PARAMETERS: Module_name - Caller's module name (for error output)
65 * Line_number - Caller's line number (for error output)
66 * Component_id - Caller's component ID (for error output)
67 * Function_name - Name of Caller's function
71 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
74 ****************************************************************************/
78 NATIVE_CHAR
*module_name
,
81 NATIVE_CHAR
*function_name
)
84 acpi_gbl_nesting_level
++;
86 debug_print (module_name
, line_number
, component_id
,
88 " %2.2ld Entered Function: %s\n",
89 acpi_gbl_nesting_level
, function_name
);
93 /*****************************************************************************
95 * FUNCTION: Function_trace_ptr
97 * PARAMETERS: Module_name - Caller's module name (for error output)
98 * Line_number - Caller's line number (for error output)
99 * Component_id - Caller's component ID (for error output)
100 * Function_name - Name of Caller's function
101 * Pointer - Pointer to display
105 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
108 ****************************************************************************/
112 NATIVE_CHAR
*module_name
,
115 NATIVE_CHAR
*function_name
,
119 acpi_gbl_nesting_level
++;
120 debug_print (module_name
, line_number
, component_id
, TRACE_FUNCTIONS
,
121 " %2.2ld Entered Function: %s, %p\n",
122 acpi_gbl_nesting_level
, function_name
, pointer
);
126 /*****************************************************************************
128 * FUNCTION: Function_trace_str
130 * PARAMETERS: Module_name - Caller's module name (for error output)
131 * Line_number - Caller's line number (for error output)
132 * Component_id - Caller's component ID (for error output)
133 * Function_name - Name of Caller's function
134 * String - Additional string to display
138 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
141 ****************************************************************************/
145 NATIVE_CHAR
*module_name
,
148 NATIVE_CHAR
*function_name
,
152 acpi_gbl_nesting_level
++;
153 debug_print (module_name
, line_number
, component_id
, TRACE_FUNCTIONS
,
154 " %2.2ld Entered Function: %s, %s\n",
155 acpi_gbl_nesting_level
, function_name
, string
);
159 /*****************************************************************************
161 * FUNCTION: Function_trace_u32
163 * PARAMETERS: Module_name - Caller's module name (for error output)
164 * Line_number - Caller's line number (for error output)
165 * Component_id - Caller's component ID (for error output)
166 * Function_name - Name of Caller's function
167 * Integer - Integer to display
171 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
174 ****************************************************************************/
178 NATIVE_CHAR
*module_name
,
181 NATIVE_CHAR
*function_name
,
185 acpi_gbl_nesting_level
++;
186 debug_print (module_name
, line_number
, component_id
, TRACE_FUNCTIONS
,
187 " %2.2ld Entered Function: %s, %lX\n",
188 acpi_gbl_nesting_level
, function_name
, integer
);
192 /*****************************************************************************
194 * FUNCTION: Function_exit
196 * PARAMETERS: Module_name - Caller's module name (for error output)
197 * Line_number - Caller's line number (for error output)
198 * Component_id - Caller's component ID (for error output)
199 * Function_name - Name of Caller's function
203 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
206 ****************************************************************************/
210 NATIVE_CHAR
*module_name
,
213 NATIVE_CHAR
*function_name
)
216 debug_print (module_name
, line_number
, component_id
, TRACE_FUNCTIONS
,
217 " %2.2ld Exiting Function: %s\n",
218 acpi_gbl_nesting_level
, function_name
);
220 acpi_gbl_nesting_level
--;
224 /*****************************************************************************
226 * FUNCTION: Function_status_exit
228 * PARAMETERS: Module_name - Caller's module name (for error output)
229 * Line_number - Caller's line number (for error output)
230 * Component_id - Caller's component ID (for error output)
231 * Function_name - Name of Caller's function
232 * Status - Exit status code
236 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
237 * set in Debug_level. Prints exit status also.
239 ****************************************************************************/
242 function_status_exit (
243 NATIVE_CHAR
*module_name
,
246 NATIVE_CHAR
*function_name
,
250 debug_print (module_name
, line_number
, component_id
,
252 " %2.2ld Exiting Function: %s, %s\n",
253 acpi_gbl_nesting_level
,
255 acpi_cm_format_exception (status
));
257 acpi_gbl_nesting_level
--;
261 /*****************************************************************************
263 * FUNCTION: Function_value_exit
265 * PARAMETERS: Module_name - Caller's module name (for error output)
266 * Line_number - Caller's line number (for error output)
267 * Component_id - Caller's component ID (for error output)
268 * Function_name - Name of Caller's function
269 * Value - Value to be printed with exit msg
273 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
274 * set in Debug_level. Prints exit value also.
276 ****************************************************************************/
279 function_value_exit (
280 NATIVE_CHAR
*module_name
,
283 NATIVE_CHAR
*function_name
,
287 debug_print (module_name
, line_number
, component_id
, TRACE_FUNCTIONS
,
288 " %2.2ld Exiting Function: %s, %X\n",
289 acpi_gbl_nesting_level
, function_name
, value
);
291 acpi_gbl_nesting_level
--;
295 /*****************************************************************************
297 * FUNCTION: Function_ptr_exit
299 * PARAMETERS: Module_name - Caller's module name (for error output)
300 * Line_number - Caller's line number (for error output)
301 * Component_id - Caller's component ID (for error output)
302 * Function_name - Name of Caller's function
303 * Value - Value to be printed with exit msg
307 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
308 * set in Debug_level. Prints exit value also.
310 ****************************************************************************/
314 NATIVE_CHAR
*module_name
,
317 NATIVE_CHAR
*function_name
,
321 debug_print (module_name
, line_number
, component_id
, TRACE_FUNCTIONS
,
322 " %2.2ld Exiting Function: %s, %p\n",
323 acpi_gbl_nesting_level
, function_name
, ptr
);
325 acpi_gbl_nesting_level
--;
329 /*****************************************************************************
331 * FUNCTION: Debug_print
333 * PARAMETERS: Module_name - Caller's module name (for error output)
334 * Line_number - Caller's line number (for error output)
335 * Component_id - Caller's component ID (for error output)
336 * Print_level - Requested debug print level
337 * Format - Printf format field
338 * ... - Optional printf arguments
342 * DESCRIPTION: Print error message with prefix consisting of the module name,
343 * line number, and component ID.
345 ****************************************************************************/
349 NATIVE_CHAR
*module_name
,
359 /* Both the level and the component must be enabled */
361 if ((print_level
& acpi_dbg_level
) &&
362 (component_id
& acpi_dbg_layer
)) {
363 va_start (args
, format
);
365 acpi_os_printf ("%8s-%04d: ", module_name
, line_number
);
366 acpi_os_vprintf (format
, args
);
371 /*****************************************************************************
373 * FUNCTION: Debug_print_prefix
375 * PARAMETERS: Module_name - Caller's module name (for error output)
376 * Line_number - Caller's line number (for error output)
377 * Component_id - Caller's component ID (for error output)
381 * DESCRIPTION: Print the prefix part of an error message, consisting of the
382 * module name, and line number
384 ****************************************************************************/
388 NATIVE_CHAR
*module_name
,
393 acpi_os_printf ("%8s-%04d: ", module_name
, line_number
);
397 /*****************************************************************************
399 * FUNCTION: Debug_print_raw
401 * PARAMETERS: Format - Printf format field
402 * ... - Optional printf arguments
406 * DESCRIPTION: Print error message -- without module/line indentifiers
408 ****************************************************************************/
418 va_start (args
, format
);
420 acpi_os_vprintf (format
, args
);
426 /*****************************************************************************
428 * FUNCTION: Acpi_cm_dump_buffer
430 * PARAMETERS: Buffer - Buffer to dump
431 * Count - Amount to dump, in bytes
432 * Component_iD - Caller's component ID
436 * DESCRIPTION: Generic dump buffer in both hex and ascii.
438 ****************************************************************************/
441 acpi_cm_dump_buffer (
453 /* Only dump the buffer if tracing is enabled */
455 if (!((TRACE_TABLES
& acpi_dbg_level
) &&
456 (component_id
& acpi_dbg_layer
))) {
462 * Nasty little dump buffer routine!
465 /* Print current offset */
467 acpi_os_printf ("%05X ", i
);
470 /* Print 16 hex chars */
472 for (j
= 0; j
< 16;) {
473 if (i
+ j
>= count
) {
474 acpi_os_printf ("\n");
478 /* Make sure that the s8 doesn't get sign-extended! */
481 /* Default is BYTE display */
485 acpi_os_printf ("%02X ",
486 *((u8
*) &buffer
[i
+ j
]));
491 case DB_WORD_DISPLAY
:
493 MOVE_UNALIGNED16_TO_32 (&temp32
,
495 acpi_os_printf ("%04X ", temp32
);
500 case DB_DWORD_DISPLAY
:
502 MOVE_UNALIGNED32_TO_32 (&temp32
,
504 acpi_os_printf ("%08X ", temp32
);
509 case DB_QWORD_DISPLAY
:
511 MOVE_UNALIGNED32_TO_32 (&temp32
,
513 acpi_os_printf ("%08X", temp32
);
515 MOVE_UNALIGNED32_TO_32 (&temp32
,
517 acpi_os_printf ("%08X ", temp32
);
525 * Print the ASCII equivalent characters
526 * But watch out for the bad unprintable ones...
529 for (j
= 0; j
< 16; j
++) {
530 if (i
+ j
>= count
) {
531 acpi_os_printf ("\n");
535 buf_char
= buffer
[i
+ j
];
536 if ((buf_char
> 0x1F && buf_char
< 0x2E) ||
537 (buf_char
> 0x2F && buf_char
< 0x61) ||
538 (buf_char
> 0x60 && buf_char
< 0x7F)) {
539 acpi_os_printf ("%c", buf_char
);
542 acpi_os_printf (".");
546 /* Done with that line. */
548 acpi_os_printf ("\n");