Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 58 | /* Local prototypes */ |
| 59 | |
| 60 | static const char * |
| 61 | acpi_ut_trim_function_name ( |
| 62 | const char *function_name); |
| 63 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 65 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | * |
| 67 | * FUNCTION: acpi_ut_init_stack_ptr_trace |
| 68 | * |
| 69 | * PARAMETERS: None |
| 70 | * |
| 71 | * RETURN: None |
| 72 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 73 | * DESCRIPTION: Save the current CPU stack pointer at subsystem startup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 75 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
| 77 | void |
| 78 | acpi_ut_init_stack_ptr_trace ( |
| 79 | void) |
| 80 | { |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 81 | u32 current_sp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
| 83 | |
| 84 | acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF (¤t_sp, NULL); |
| 85 | } |
| 86 | |
| 87 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 88 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | * |
| 90 | * FUNCTION: acpi_ut_track_stack_ptr |
| 91 | * |
| 92 | * PARAMETERS: None |
| 93 | * |
| 94 | * RETURN: None |
| 95 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 96 | * DESCRIPTION: Save the current CPU stack pointer |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 98 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
| 100 | void |
| 101 | acpi_ut_track_stack_ptr ( |
| 102 | void) |
| 103 | { |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 104 | acpi_size current_sp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 119 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | * |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 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 | |
| 156 | /******************************************************************************* |
| 157 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | * FUNCTION: acpi_ut_debug_print |
| 159 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 160 | * PARAMETERS: requested_debug_level - Requested debug print level |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | * line_number - Caller's line number (for error output) |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 162 | * function_name - Caller's procedure name |
| 163 | * module_name - Caller's module name |
| 164 | * component_id - Caller's component ID |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 173 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
| 175 | void ACPI_INTERNAL_VAR_XFACE |
| 176 | acpi_ut_debug_print ( |
| 177 | u32 requested_debug_level, |
| 178 | u32 line_number, |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 179 | const char *function_name, |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 180 | char *module_name, |
| 181 | u32 component_id, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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) || |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 193 | !(component_id & acpi_dbg_layer)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 204 | acpi_os_printf ( |
| 205 | "\n**** Context Switch from TID %X to TID %X ****\n\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | */ |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 216 | acpi_os_printf ("%8s-%04ld ", module_name, line_number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | |
| 218 | if (ACPI_LV_THREADS & acpi_dbg_level) { |
| 219 | acpi_os_printf ("[%04lX] ", thread_id); |
| 220 | } |
| 221 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 222 | acpi_os_printf ("[%02ld] %-22.22s: ", |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 223 | acpi_gbl_nesting_level, acpi_ut_trim_function_name (function_name)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
| 225 | va_start (args, format); |
| 226 | acpi_os_vprintf (format, args); |
| 227 | } |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 228 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | EXPORT_SYMBOL(acpi_ut_debug_print); |
| 230 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 231 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 237 | * function_name - Caller's procedure name |
| 238 | * module_name - Caller's module name |
| 239 | * component_id - Caller's component ID |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 248 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | |
| 250 | void ACPI_INTERNAL_VAR_XFACE |
| 251 | acpi_ut_debug_print_raw ( |
| 252 | u32 requested_debug_level, |
| 253 | u32 line_number, |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 254 | const char *function_name, |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 255 | char *module_name, |
| 256 | u32 component_id, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | char *format, |
| 258 | ...) |
| 259 | { |
| 260 | va_list args; |
| 261 | |
| 262 | |
| 263 | if (!(requested_debug_level & acpi_dbg_level) || |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 264 | !(component_id & acpi_dbg_layer)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 274 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | * |
| 276 | * FUNCTION: acpi_ut_trace |
| 277 | * |
| 278 | * PARAMETERS: line_number - Caller's line number |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 279 | * function_name - Caller's procedure name |
| 280 | * module_name - Caller's module name |
| 281 | * component_id - Caller's component ID |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | * |
| 283 | * RETURN: None |
| 284 | * |
| 285 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is |
| 286 | * set in debug_level |
| 287 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 288 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | |
| 290 | void |
| 291 | acpi_ut_trace ( |
| 292 | u32 line_number, |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 293 | const char *function_name, |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 294 | char *module_name, |
| 295 | u32 component_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | { |
| 297 | |
| 298 | acpi_gbl_nesting_level++; |
| 299 | acpi_ut_track_stack_ptr (); |
| 300 | |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 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); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | } |
| 305 | EXPORT_SYMBOL(acpi_ut_trace); |
| 306 | |
| 307 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 308 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | * |
| 310 | * FUNCTION: acpi_ut_trace_ptr |
| 311 | * |
| 312 | * PARAMETERS: line_number - Caller's line number |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 313 | * function_name - Caller's procedure name |
| 314 | * module_name - Caller's module name |
| 315 | * component_id - Caller's component ID |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 323 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | |
| 325 | void |
| 326 | acpi_ut_trace_ptr ( |
| 327 | u32 line_number, |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 328 | const char *function_name, |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 329 | char *module_name, |
| 330 | u32 component_id, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | void *pointer) |
| 332 | { |
| 333 | acpi_gbl_nesting_level++; |
| 334 | acpi_ut_track_stack_ptr (); |
| 335 | |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 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); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 342 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | * |
| 344 | * FUNCTION: acpi_ut_trace_str |
| 345 | * |
| 346 | * PARAMETERS: line_number - Caller's line number |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 347 | * function_name - Caller's procedure name |
| 348 | * module_name - Caller's module name |
| 349 | * component_id - Caller's component ID |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 357 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | |
| 359 | void |
| 360 | acpi_ut_trace_str ( |
| 361 | u32 line_number, |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 362 | const char *function_name, |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 363 | char *module_name, |
| 364 | u32 component_id, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | char *string) |
| 366 | { |
| 367 | |
| 368 | acpi_gbl_nesting_level++; |
| 369 | acpi_ut_track_stack_ptr (); |
| 370 | |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 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); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 377 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | * |
| 379 | * FUNCTION: acpi_ut_trace_u32 |
| 380 | * |
| 381 | * PARAMETERS: line_number - Caller's line number |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 382 | * function_name - Caller's procedure name |
| 383 | * module_name - Caller's module name |
| 384 | * component_id - Caller's component ID |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 392 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | |
| 394 | void |
| 395 | acpi_ut_trace_u32 ( |
| 396 | u32 line_number, |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 397 | const char *function_name, |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 398 | char *module_name, |
| 399 | u32 component_id, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | u32 integer) |
| 401 | { |
| 402 | |
| 403 | acpi_gbl_nesting_level++; |
| 404 | acpi_ut_track_stack_ptr (); |
| 405 | |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 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); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | } |
| 410 | |
| 411 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 412 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | * |
| 414 | * FUNCTION: acpi_ut_exit |
| 415 | * |
| 416 | * PARAMETERS: line_number - Caller's line number |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 417 | * function_name - Caller's procedure name |
| 418 | * module_name - Caller's module name |
| 419 | * component_id - Caller's component ID |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | * |
| 421 | * RETURN: None |
| 422 | * |
| 423 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is |
| 424 | * set in debug_level |
| 425 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 426 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | |
| 428 | void |
| 429 | acpi_ut_exit ( |
| 430 | u32 line_number, |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 431 | const char *function_name, |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 432 | char *module_name, |
| 433 | u32 component_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | { |
| 435 | |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 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); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | |
| 440 | acpi_gbl_nesting_level--; |
| 441 | } |
| 442 | EXPORT_SYMBOL(acpi_ut_exit); |
| 443 | |
| 444 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 445 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | * |
| 447 | * FUNCTION: acpi_ut_status_exit |
| 448 | * |
| 449 | * PARAMETERS: line_number - Caller's line number |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 450 | * function_name - Caller's procedure name |
| 451 | * module_name - Caller's module name |
| 452 | * component_id - Caller's component ID |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 460 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | |
| 462 | void |
| 463 | acpi_ut_status_exit ( |
| 464 | u32 line_number, |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 465 | const char *function_name, |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 466 | char *module_name, |
| 467 | u32 component_id, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | acpi_status status) |
| 469 | { |
| 470 | |
| 471 | if (ACPI_SUCCESS (status)) { |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 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)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | } |
| 477 | else { |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 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)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | acpi_gbl_nesting_level--; |
| 485 | } |
| 486 | EXPORT_SYMBOL(acpi_ut_status_exit); |
| 487 | |
| 488 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 489 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | * |
| 491 | * FUNCTION: acpi_ut_value_exit |
| 492 | * |
| 493 | * PARAMETERS: line_number - Caller's line number |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 494 | * function_name - Caller's procedure name |
| 495 | * module_name - Caller's module name |
| 496 | * component_id - Caller's component ID |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 504 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | |
| 506 | void |
| 507 | acpi_ut_value_exit ( |
| 508 | u32 line_number, |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 509 | const char *function_name, |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 510 | char *module_name, |
| 511 | u32 component_id, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | acpi_integer value) |
| 513 | { |
| 514 | |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 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)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | |
| 520 | acpi_gbl_nesting_level--; |
| 521 | } |
| 522 | EXPORT_SYMBOL(acpi_ut_value_exit); |
| 523 | |
| 524 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 525 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | * |
| 527 | * FUNCTION: acpi_ut_ptr_exit |
| 528 | * |
| 529 | * PARAMETERS: line_number - Caller's line number |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 530 | * function_name - Caller's procedure name |
| 531 | * module_name - Caller's module name |
| 532 | * component_id - Caller's component ID |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 533 | * Ptr - Pointer to display |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 540 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | |
| 542 | void |
| 543 | acpi_ut_ptr_exit ( |
| 544 | u32 line_number, |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 545 | const char *function_name, |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 546 | char *module_name, |
| 547 | u32 component_id, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | u8 *ptr) |
| 549 | { |
| 550 | |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 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); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | |
| 555 | acpi_gbl_nesting_level--; |
| 556 | } |
| 557 | |
| 558 | #endif |
| 559 | |
| 560 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 561 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 574 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 600 | /* Nasty little dump buffer routine! */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | while (i < count) { |
| 603 | /* Print current offset */ |
| 604 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 605 | acpi_os_printf ("%6.4X: ", (u32) i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | |
| 607 | /* Print 16 hex chars */ |
| 608 | |
| 609 | for (j = 0; j < 16;) { |
| 610 | if (i + j >= count) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 611 | /* Dump fill spaces */ |
| 612 | |
| 613 | acpi_os_printf ("%*s", ((display * 2) + 1), " "); |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 614 | j += (acpi_native_uint) display; |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 615 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | } |
| 617 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | switch (display) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 619 | default: /* Default is BYTE display */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 621 | acpi_os_printf ("%02X ", buffer[i + j]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | break; |
| 647 | } |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 648 | |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 649 | j += (acpi_native_uint) display; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | /* |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 653 | * Print the ASCII equivalent characters but watch out for the bad |
| 654 | * unprintable ones (printable chars are 0x20 through 0x7E) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 656 | acpi_os_printf (" "); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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]; |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame^] | 664 | if (ACPI_IS_PRINT (buf_char)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |