Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /****************************************************************************** |
2 | * | |
3 | * Module Name: utdebug - Debug print routines | |
4 | * | |
5 | *****************************************************************************/ | |
6 | ||
7 | /* | |
25f044e6 | 8 | * Copyright (C) 2000 - 2013, Intel Corp. |
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 | ||
214f2c90 | 44 | #include <linux/export.h> |
1da177e4 | 45 | #include <acpi/acpi.h> |
e2f7a777 | 46 | #include "accommon.h" |
1da177e4 LT |
47 | |
48 | #define _COMPONENT ACPI_UTILITIES | |
4be44fcd | 49 | ACPI_MODULE_NAME("utdebug") |
6d33b6be | 50 | |
1da177e4 | 51 | #ifdef ACPI_DEBUG_OUTPUT |
6d33b6be | 52 | static acpi_thread_id acpi_gbl_prev_thread_id = (acpi_thread_id) 0xFFFFFFFF; |
4be44fcd LB |
53 | static char *acpi_gbl_fn_entry_str = "----Entry"; |
54 | static char *acpi_gbl_fn_exit_str = "----Exit-"; | |
1da177e4 | 55 | |
0c9938cc RM |
56 | /* Local prototypes */ |
57 | ||
4be44fcd | 58 | static const char *acpi_ut_trim_function_name(const char *function_name); |
1da177e4 | 59 | |
44f6c012 | 60 | /******************************************************************************* |
1da177e4 LT |
61 | * |
62 | * FUNCTION: acpi_ut_init_stack_ptr_trace | |
63 | * | |
64 | * PARAMETERS: None | |
65 | * | |
66 | * RETURN: None | |
67 | * | |
44f6c012 | 68 | * DESCRIPTION: Save the current CPU stack pointer at subsystem startup |
1da177e4 | 69 | * |
44f6c012 | 70 | ******************************************************************************/ |
1da177e4 | 71 | |
4be44fcd | 72 | void acpi_ut_init_stack_ptr_trace(void) |
1da177e4 | 73 | { |
1d18c058 | 74 | acpi_size current_sp; |
1da177e4 | 75 | |
1d18c058 | 76 | acpi_gbl_entry_stack_pointer = ¤t_sp; |
1da177e4 LT |
77 | } |
78 | ||
44f6c012 | 79 | /******************************************************************************* |
1da177e4 LT |
80 | * |
81 | * FUNCTION: acpi_ut_track_stack_ptr | |
82 | * | |
83 | * PARAMETERS: None | |
84 | * | |
85 | * RETURN: None | |
86 | * | |
44f6c012 | 87 | * DESCRIPTION: Save the current CPU stack pointer |
1da177e4 | 88 | * |
44f6c012 | 89 | ******************************************************************************/ |
1da177e4 | 90 | |
4be44fcd | 91 | void acpi_ut_track_stack_ptr(void) |
1da177e4 | 92 | { |
4be44fcd | 93 | acpi_size current_sp; |
1da177e4 | 94 | |
1d18c058 BM |
95 | if (¤t_sp < acpi_gbl_lowest_stack_pointer) { |
96 | acpi_gbl_lowest_stack_pointer = ¤t_sp; | |
1da177e4 LT |
97 | } |
98 | ||
99 | if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) { | |
100 | acpi_gbl_deepest_nesting = acpi_gbl_nesting_level; | |
101 | } | |
102 | } | |
103 | ||
0c9938cc RM |
104 | /******************************************************************************* |
105 | * | |
106 | * FUNCTION: acpi_ut_trim_function_name | |
107 | * | |
108 | * PARAMETERS: function_name - Ascii string containing a procedure name | |
109 | * | |
110 | * RETURN: Updated pointer to the function name | |
111 | * | |
112 | * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present. | |
6d33b6be | 113 | * This allows compiler macros such as __FUNCTION__ to be used |
0c9938cc RM |
114 | * with no change to the debug output. |
115 | * | |
116 | ******************************************************************************/ | |
117 | ||
4be44fcd | 118 | static const char *acpi_ut_trim_function_name(const char *function_name) |
0c9938cc RM |
119 | { |
120 | ||
121 | /* All Function names are longer than 4 chars, check is safe */ | |
122 | ||
a18ecf41 | 123 | if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) { |
52fc0b02 | 124 | |
0c9938cc RM |
125 | /* This is the case where the original source has not been modified */ |
126 | ||
127 | return (function_name + 4); | |
128 | } | |
129 | ||
a18ecf41 | 130 | if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) { |
52fc0b02 | 131 | |
0c9938cc RM |
132 | /* This is the case where the source has been 'linuxized' */ |
133 | ||
134 | return (function_name + 5); | |
135 | } | |
136 | ||
137 | return (function_name); | |
138 | } | |
139 | ||
44f6c012 | 140 | /******************************************************************************* |
1da177e4 | 141 | * |
50df4d8b | 142 | * FUNCTION: acpi_debug_print |
1da177e4 | 143 | * |
44f6c012 | 144 | * PARAMETERS: requested_debug_level - Requested debug print level |
1da177e4 | 145 | * line_number - Caller's line number (for error output) |
f9f4601f RM |
146 | * function_name - Caller's procedure name |
147 | * module_name - Caller's module name | |
148 | * component_id - Caller's component ID | |
ba494bee | 149 | * format - Printf format field |
1da177e4 LT |
150 | * ... - Optional printf arguments |
151 | * | |
152 | * RETURN: None | |
153 | * | |
154 | * DESCRIPTION: Print error message with prefix consisting of the module name, | |
155 | * line number, and component ID. | |
156 | * | |
44f6c012 | 157 | ******************************************************************************/ |
1da177e4 | 158 | |
4be44fcd | 159 | void ACPI_INTERNAL_VAR_XFACE |
50df4d8b BM |
160 | acpi_debug_print(u32 requested_debug_level, |
161 | u32 line_number, | |
162 | const char *function_name, | |
163 | const char *module_name, | |
164 | u32 component_id, const char *format, ...) | |
1da177e4 | 165 | { |
8313524a | 166 | acpi_thread_id thread_id; |
4be44fcd | 167 | va_list args; |
1da177e4 | 168 | |
db38bf5a BM |
169 | /* Check if debug output enabled */ |
170 | ||
171 | if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) { | |
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 |
28eb3fcf LM |
182 | ("\n**** Context Switch from TID %u to TID %u ****\n\n", |
183 | (u32)acpi_gbl_prev_thread_id, (u32)thread_id); | |
1da177e4 LT |
184 | } |
185 | ||
186 | acpi_gbl_prev_thread_id = thread_id; | |
187 | } | |
188 | ||
189 | /* | |
190 | * Display the module name, current line number, thread ID (if requested), | |
191 | * current procedure nesting level, and the current procedure name | |
192 | */ | |
4be44fcd | 193 | acpi_os_printf("%8s-%04ld ", module_name, line_number); |
1da177e4 LT |
194 | |
195 | if (ACPI_LV_THREADS & acpi_dbg_level) { | |
28eb3fcf | 196 | acpi_os_printf("[%u] ", (u32)thread_id); |
1da177e4 LT |
197 | } |
198 | ||
4be44fcd LB |
199 | acpi_os_printf("[%02ld] %-22.22s: ", |
200 | acpi_gbl_nesting_level, | |
201 | acpi_ut_trim_function_name(function_name)); | |
1da177e4 | 202 | |
4be44fcd LB |
203 | va_start(args, format); |
204 | acpi_os_vprintf(format, args); | |
507f046c | 205 | va_end(args); |
1da177e4 | 206 | } |
1da177e4 | 207 | |
50df4d8b | 208 | ACPI_EXPORT_SYMBOL(acpi_debug_print) |
1da177e4 | 209 | |
44f6c012 | 210 | /******************************************************************************* |
1da177e4 | 211 | * |
50df4d8b | 212 | * FUNCTION: acpi_debug_print_raw |
1da177e4 LT |
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 | |
ba494bee | 219 | * format - Printf format field |
1da177e4 LT |
220 | * ... - Optional printf arguments |
221 | * | |
222 | * RETURN: None | |
223 | * | |
73a3090a | 224 | * DESCRIPTION: Print message with no headers. Has same interface as |
1da177e4 LT |
225 | * debug_print so that the same macros can be used. |
226 | * | |
44f6c012 | 227 | ******************************************************************************/ |
4be44fcd | 228 | void ACPI_INTERNAL_VAR_XFACE |
50df4d8b BM |
229 | acpi_debug_print_raw(u32 requested_debug_level, |
230 | u32 line_number, | |
231 | const char *function_name, | |
232 | const char *module_name, | |
233 | u32 component_id, const char *format, ...) | |
1da177e4 | 234 | { |
4be44fcd | 235 | va_list args; |
1da177e4 | 236 | |
db38bf5a BM |
237 | /* Check if debug output enabled */ |
238 | ||
239 | if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) { | |
1da177e4 LT |
240 | return; |
241 | } | |
242 | ||
4be44fcd LB |
243 | va_start(args, format); |
244 | acpi_os_vprintf(format, args); | |
507f046c | 245 | va_end(args); |
1da177e4 | 246 | } |
1da177e4 | 247 | |
50df4d8b | 248 | ACPI_EXPORT_SYMBOL(acpi_debug_print_raw) |
1da177e4 | 249 | |
44f6c012 | 250 | /******************************************************************************* |
1da177e4 LT |
251 | * |
252 | * FUNCTION: acpi_ut_trace | |
253 | * | |
254 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
255 | * function_name - Caller's procedure name |
256 | * module_name - Caller's module name | |
257 | * component_id - Caller's component ID | |
1da177e4 LT |
258 | * |
259 | * RETURN: None | |
260 | * | |
73a3090a | 261 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is |
1da177e4 LT |
262 | * set in debug_level |
263 | * | |
44f6c012 | 264 | ******************************************************************************/ |
1da177e4 | 265 | void |
4be44fcd | 266 | acpi_ut_trace(u32 line_number, |
4b8ed631 BM |
267 | const char *function_name, |
268 | const char *module_name, u32 component_id) | |
1da177e4 LT |
269 | { |
270 | ||
271 | acpi_gbl_nesting_level++; | |
4be44fcd | 272 | acpi_ut_track_stack_ptr(); |
1da177e4 | 273 | |
db38bf5a BM |
274 | /* Check if enabled up-front for performance */ |
275 | ||
276 | if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) { | |
277 | acpi_debug_print(ACPI_LV_FUNCTIONS, | |
278 | line_number, function_name, module_name, | |
279 | component_id, "%s\n", acpi_gbl_fn_entry_str); | |
280 | } | |
1da177e4 | 281 | } |
1da177e4 | 282 | |
8313524a | 283 | ACPI_EXPORT_SYMBOL(acpi_ut_trace) |
1da177e4 | 284 | |
44f6c012 | 285 | /******************************************************************************* |
1da177e4 LT |
286 | * |
287 | * FUNCTION: acpi_ut_trace_ptr | |
288 | * | |
289 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
290 | * function_name - Caller's procedure name |
291 | * module_name - Caller's module name | |
292 | * component_id - Caller's component ID | |
ba494bee | 293 | * pointer - Pointer to display |
1da177e4 LT |
294 | * |
295 | * RETURN: None | |
296 | * | |
73a3090a | 297 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is |
1da177e4 LT |
298 | * set in debug_level |
299 | * | |
44f6c012 | 300 | ******************************************************************************/ |
1da177e4 | 301 | void |
4be44fcd LB |
302 | acpi_ut_trace_ptr(u32 line_number, |
303 | const char *function_name, | |
4b8ed631 | 304 | const char *module_name, u32 component_id, void *pointer) |
1da177e4 | 305 | { |
68aafc35 | 306 | |
1da177e4 | 307 | acpi_gbl_nesting_level++; |
4be44fcd | 308 | acpi_ut_track_stack_ptr(); |
1da177e4 | 309 | |
db38bf5a BM |
310 | /* Check if enabled up-front for performance */ |
311 | ||
312 | if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) { | |
313 | acpi_debug_print(ACPI_LV_FUNCTIONS, | |
314 | line_number, function_name, module_name, | |
315 | component_id, "%s %p\n", acpi_gbl_fn_entry_str, | |
316 | pointer); | |
317 | } | |
1da177e4 LT |
318 | } |
319 | ||
44f6c012 | 320 | /******************************************************************************* |
1da177e4 LT |
321 | * |
322 | * FUNCTION: acpi_ut_trace_str | |
323 | * | |
324 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
325 | * function_name - Caller's procedure name |
326 | * module_name - Caller's module name | |
327 | * component_id - Caller's component ID | |
ba494bee | 328 | * string - Additional string to display |
1da177e4 LT |
329 | * |
330 | * RETURN: None | |
331 | * | |
73a3090a | 332 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is |
1da177e4 LT |
333 | * set in debug_level |
334 | * | |
44f6c012 | 335 | ******************************************************************************/ |
1da177e4 LT |
336 | |
337 | void | |
4be44fcd LB |
338 | acpi_ut_trace_str(u32 line_number, |
339 | const char *function_name, | |
4b8ed631 | 340 | const char *module_name, u32 component_id, char *string) |
1da177e4 LT |
341 | { |
342 | ||
343 | acpi_gbl_nesting_level++; | |
4be44fcd | 344 | acpi_ut_track_stack_ptr(); |
1da177e4 | 345 | |
db38bf5a BM |
346 | /* Check if enabled up-front for performance */ |
347 | ||
348 | if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) { | |
349 | acpi_debug_print(ACPI_LV_FUNCTIONS, | |
350 | line_number, function_name, module_name, | |
351 | component_id, "%s %s\n", acpi_gbl_fn_entry_str, | |
352 | string); | |
353 | } | |
1da177e4 LT |
354 | } |
355 | ||
44f6c012 | 356 | /******************************************************************************* |
1da177e4 LT |
357 | * |
358 | * FUNCTION: acpi_ut_trace_u32 | |
359 | * | |
360 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
361 | * function_name - Caller's procedure name |
362 | * module_name - Caller's module name | |
363 | * component_id - Caller's component ID | |
ba494bee | 364 | * integer - Integer to display |
1da177e4 LT |
365 | * |
366 | * RETURN: None | |
367 | * | |
73a3090a | 368 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is |
1da177e4 LT |
369 | * set in debug_level |
370 | * | |
44f6c012 | 371 | ******************************************************************************/ |
1da177e4 LT |
372 | |
373 | void | |
4be44fcd LB |
374 | acpi_ut_trace_u32(u32 line_number, |
375 | const char *function_name, | |
4b8ed631 | 376 | const char *module_name, u32 component_id, u32 integer) |
1da177e4 LT |
377 | { |
378 | ||
379 | acpi_gbl_nesting_level++; | |
4be44fcd | 380 | acpi_ut_track_stack_ptr(); |
1da177e4 | 381 | |
db38bf5a BM |
382 | /* Check if enabled up-front for performance */ |
383 | ||
384 | if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) { | |
385 | acpi_debug_print(ACPI_LV_FUNCTIONS, | |
386 | line_number, function_name, module_name, | |
387 | component_id, "%s %08X\n", | |
388 | acpi_gbl_fn_entry_str, integer); | |
389 | } | |
1da177e4 LT |
390 | } |
391 | ||
44f6c012 | 392 | /******************************************************************************* |
1da177e4 LT |
393 | * |
394 | * FUNCTION: acpi_ut_exit | |
395 | * | |
396 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
397 | * function_name - Caller's procedure name |
398 | * module_name - Caller's module name | |
399 | * component_id - Caller's component ID | |
1da177e4 LT |
400 | * |
401 | * RETURN: None | |
402 | * | |
73a3090a | 403 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is |
1da177e4 LT |
404 | * set in debug_level |
405 | * | |
44f6c012 | 406 | ******************************************************************************/ |
1da177e4 LT |
407 | |
408 | void | |
4be44fcd | 409 | acpi_ut_exit(u32 line_number, |
4b8ed631 BM |
410 | const char *function_name, |
411 | const char *module_name, u32 component_id) | |
1da177e4 LT |
412 | { |
413 | ||
db38bf5a BM |
414 | /* Check if enabled up-front for performance */ |
415 | ||
416 | if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) { | |
417 | acpi_debug_print(ACPI_LV_FUNCTIONS, | |
418 | line_number, function_name, module_name, | |
419 | component_id, "%s\n", acpi_gbl_fn_exit_str); | |
420 | } | |
1da177e4 LT |
421 | |
422 | acpi_gbl_nesting_level--; | |
423 | } | |
1da177e4 | 424 | |
8313524a | 425 | ACPI_EXPORT_SYMBOL(acpi_ut_exit) |
1da177e4 | 426 | |
44f6c012 | 427 | /******************************************************************************* |
1da177e4 LT |
428 | * |
429 | * FUNCTION: acpi_ut_status_exit | |
430 | * | |
431 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
432 | * function_name - Caller's procedure name |
433 | * module_name - Caller's module name | |
434 | * component_id - Caller's component ID | |
ba494bee | 435 | * status - Exit status code |
1da177e4 LT |
436 | * |
437 | * RETURN: None | |
438 | * | |
73a3090a | 439 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is |
1da177e4 LT |
440 | * set in debug_level. Prints exit status also. |
441 | * | |
44f6c012 | 442 | ******************************************************************************/ |
1da177e4 | 443 | void |
4be44fcd LB |
444 | acpi_ut_status_exit(u32 line_number, |
445 | const char *function_name, | |
4b8ed631 BM |
446 | const char *module_name, |
447 | u32 component_id, acpi_status status) | |
1da177e4 LT |
448 | { |
449 | ||
db38bf5a BM |
450 | /* Check if enabled up-front for performance */ |
451 | ||
452 | if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) { | |
453 | if (ACPI_SUCCESS(status)) { | |
454 | acpi_debug_print(ACPI_LV_FUNCTIONS, | |
455 | line_number, function_name, | |
456 | module_name, component_id, "%s %s\n", | |
457 | acpi_gbl_fn_exit_str, | |
458 | acpi_format_exception(status)); | |
459 | } else { | |
460 | acpi_debug_print(ACPI_LV_FUNCTIONS, | |
461 | line_number, function_name, | |
462 | module_name, component_id, | |
463 | "%s ****Exception****: %s\n", | |
464 | acpi_gbl_fn_exit_str, | |
465 | acpi_format_exception(status)); | |
466 | } | |
1da177e4 LT |
467 | } |
468 | ||
469 | acpi_gbl_nesting_level--; | |
470 | } | |
1da177e4 | 471 | |
8313524a | 472 | ACPI_EXPORT_SYMBOL(acpi_ut_status_exit) |
1da177e4 | 473 | |
44f6c012 | 474 | /******************************************************************************* |
1da177e4 LT |
475 | * |
476 | * FUNCTION: acpi_ut_value_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 | |
ba494bee | 482 | * value - Value to be printed with exit msg |
1da177e4 LT |
483 | * |
484 | * RETURN: None | |
485 | * | |
73a3090a | 486 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is |
1da177e4 LT |
487 | * set in debug_level. Prints exit value also. |
488 | * | |
44f6c012 | 489 | ******************************************************************************/ |
1da177e4 | 490 | void |
4be44fcd LB |
491 | acpi_ut_value_exit(u32 line_number, |
492 | const char *function_name, | |
5df7e6cb | 493 | const char *module_name, u32 component_id, u64 value) |
1da177e4 LT |
494 | { |
495 | ||
db38bf5a BM |
496 | /* Check if enabled up-front for performance */ |
497 | ||
498 | if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) { | |
499 | acpi_debug_print(ACPI_LV_FUNCTIONS, | |
500 | line_number, function_name, module_name, | |
501 | component_id, "%s %8.8X%8.8X\n", | |
502 | acpi_gbl_fn_exit_str, | |
503 | ACPI_FORMAT_UINT64(value)); | |
504 | } | |
1da177e4 LT |
505 | |
506 | acpi_gbl_nesting_level--; | |
507 | } | |
1da177e4 | 508 | |
8313524a | 509 | ACPI_EXPORT_SYMBOL(acpi_ut_value_exit) |
1da177e4 | 510 | |
44f6c012 | 511 | /******************************************************************************* |
1da177e4 LT |
512 | * |
513 | * FUNCTION: acpi_ut_ptr_exit | |
514 | * | |
515 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
516 | * function_name - Caller's procedure name |
517 | * module_name - Caller's module name | |
518 | * component_id - Caller's component ID | |
ba494bee | 519 | * ptr - Pointer to display |
1da177e4 LT |
520 | * |
521 | * RETURN: None | |
522 | * | |
73a3090a | 523 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is |
1da177e4 LT |
524 | * set in debug_level. Prints exit value also. |
525 | * | |
44f6c012 | 526 | ******************************************************************************/ |
1da177e4 | 527 | void |
4be44fcd LB |
528 | acpi_ut_ptr_exit(u32 line_number, |
529 | const char *function_name, | |
4b8ed631 | 530 | const char *module_name, u32 component_id, u8 *ptr) |
1da177e4 LT |
531 | { |
532 | ||
db38bf5a BM |
533 | /* Check if enabled up-front for performance */ |
534 | ||
535 | if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) { | |
536 | acpi_debug_print(ACPI_LV_FUNCTIONS, | |
537 | line_number, function_name, module_name, | |
538 | component_id, "%s %p\n", acpi_gbl_fn_exit_str, | |
539 | ptr); | |
540 | } | |
1da177e4 LT |
541 | |
542 | acpi_gbl_nesting_level--; | |
543 | } | |
544 | ||
545 | #endif | |
546 | ||
44f6c012 | 547 | /******************************************************************************* |
1da177e4 LT |
548 | * |
549 | * FUNCTION: acpi_ut_dump_buffer | |
550 | * | |
ba494bee BM |
551 | * PARAMETERS: buffer - Buffer to dump |
552 | * count - Amount to dump, in bytes | |
553 | * display - BYTE, WORD, DWORD, or QWORD display | |
97171c6b | 554 | * offset - Beginning buffer offset (display only) |
1da177e4 LT |
555 | * |
556 | * RETURN: None | |
557 | * | |
558 | * DESCRIPTION: Generic dump buffer in both hex and ascii. | |
559 | * | |
44f6c012 | 560 | ******************************************************************************/ |
1da177e4 | 561 | |
97171c6b | 562 | void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset) |
1da177e4 | 563 | { |
67a119f9 BM |
564 | u32 i = 0; |
565 | u32 j; | |
4be44fcd LB |
566 | u32 temp32; |
567 | u8 buf_char; | |
1da177e4 | 568 | |
5eb69180 BM |
569 | if (!buffer) { |
570 | acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n"); | |
571 | return; | |
572 | } | |
573 | ||
1da177e4 LT |
574 | if ((count < 4) || (count & 0x01)) { |
575 | display = DB_BYTE_DISPLAY; | |
576 | } | |
577 | ||
44f6c012 | 578 | /* Nasty little dump buffer routine! */ |
1da177e4 | 579 | |
1da177e4 | 580 | while (i < count) { |
52fc0b02 | 581 | |
1da177e4 LT |
582 | /* Print current offset */ |
583 | ||
97171c6b | 584 | acpi_os_printf("%6.4X: ", (base_offset + i)); |
1da177e4 LT |
585 | |
586 | /* Print 16 hex chars */ | |
587 | ||
588 | for (j = 0; j < 16;) { | |
589 | if (i + j >= count) { | |
52fc0b02 | 590 | |
44f6c012 | 591 | /* Dump fill spaces */ |
1da177e4 | 592 | |
4be44fcd | 593 | acpi_os_printf("%*s", ((display * 2) + 1), " "); |
67a119f9 | 594 | j += display; |
44f6c012 RM |
595 | continue; |
596 | } | |
1da177e4 LT |
597 | |
598 | switch (display) { | |
793c2388 | 599 | case DB_BYTE_DISPLAY: |
4be44fcd | 600 | default: /* Default is BYTE display */ |
1da177e4 | 601 | |
67a119f9 BM |
602 | acpi_os_printf("%02X ", |
603 | buffer[(acpi_size) i + j]); | |
1da177e4 LT |
604 | break; |
605 | ||
1da177e4 LT |
606 | case DB_WORD_DISPLAY: |
607 | ||
67a119f9 BM |
608 | ACPI_MOVE_16_TO_32(&temp32, |
609 | &buffer[(acpi_size) i + j]); | |
4be44fcd | 610 | acpi_os_printf("%04X ", temp32); |
1da177e4 LT |
611 | break; |
612 | ||
1da177e4 LT |
613 | case DB_DWORD_DISPLAY: |
614 | ||
67a119f9 BM |
615 | ACPI_MOVE_32_TO_32(&temp32, |
616 | &buffer[(acpi_size) i + j]); | |
4be44fcd | 617 | acpi_os_printf("%08X ", temp32); |
1da177e4 LT |
618 | break; |
619 | ||
1da177e4 LT |
620 | case DB_QWORD_DISPLAY: |
621 | ||
67a119f9 BM |
622 | ACPI_MOVE_32_TO_32(&temp32, |
623 | &buffer[(acpi_size) i + j]); | |
4be44fcd | 624 | acpi_os_printf("%08X", temp32); |
1da177e4 | 625 | |
67a119f9 BM |
626 | ACPI_MOVE_32_TO_32(&temp32, |
627 | &buffer[(acpi_size) i + j + | |
628 | 4]); | |
4be44fcd | 629 | acpi_os_printf("%08X ", temp32); |
1da177e4 LT |
630 | break; |
631 | } | |
44f6c012 | 632 | |
67a119f9 | 633 | j += display; |
1da177e4 LT |
634 | } |
635 | ||
636 | /* | |
0c9938cc RM |
637 | * Print the ASCII equivalent characters but watch out for the bad |
638 | * unprintable ones (printable chars are 0x20 through 0x7E) | |
1da177e4 | 639 | */ |
4be44fcd | 640 | acpi_os_printf(" "); |
1da177e4 LT |
641 | for (j = 0; j < 16; j++) { |
642 | if (i + j >= count) { | |
4be44fcd | 643 | acpi_os_printf("\n"); |
1da177e4 LT |
644 | return; |
645 | } | |
646 | ||
67a119f9 | 647 | buf_char = buffer[(acpi_size) i + j]; |
4be44fcd LB |
648 | if (ACPI_IS_PRINT(buf_char)) { |
649 | acpi_os_printf("%c", buf_char); | |
650 | } else { | |
651 | acpi_os_printf("."); | |
1da177e4 LT |
652 | } |
653 | } | |
654 | ||
655 | /* Done with that line. */ | |
656 | ||
4be44fcd | 657 | acpi_os_printf("\n"); |
1da177e4 LT |
658 | i += 16; |
659 | } | |
660 | ||
661 | return; | |
662 | } | |
793c2388 BM |
663 | |
664 | /******************************************************************************* | |
665 | * | |
97171c6b | 666 | * FUNCTION: acpi_ut_debug_dump_buffer |
793c2388 | 667 | * |
ba494bee BM |
668 | * PARAMETERS: buffer - Buffer to dump |
669 | * count - Amount to dump, in bytes | |
670 | * display - BYTE, WORD, DWORD, or QWORD display | |
671 | * component_ID - Caller's component ID | |
793c2388 BM |
672 | * |
673 | * RETURN: None | |
674 | * | |
675 | * DESCRIPTION: Generic dump buffer in both hex and ascii. | |
676 | * | |
677 | ******************************************************************************/ | |
678 | ||
97171c6b BM |
679 | void |
680 | acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id) | |
793c2388 BM |
681 | { |
682 | ||
683 | /* Only dump the buffer if tracing is enabled */ | |
684 | ||
685 | if (!((ACPI_LV_TABLES & acpi_dbg_level) && | |
686 | (component_id & acpi_dbg_layer))) { | |
687 | return; | |
688 | } | |
689 | ||
97171c6b | 690 | acpi_ut_dump_buffer(buffer, count, display, 0); |
793c2388 | 691 | } |