Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /****************************************************************************** |
2 | * | |
3 | * Module Name: utdebug - Debug print routines | |
4 | * | |
5 | *****************************************************************************/ | |
6 | ||
7 | /* | |
77848130 | 8 | * Copyright (C) 2000 - 2012, 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 LT |
168 | |
169 | /* | |
170 | * Stay silent if the debug level or component ID is disabled | |
171 | */ | |
172 | if (!(requested_debug_level & acpi_dbg_level) || | |
4be44fcd | 173 | !(component_id & acpi_dbg_layer)) { |
1da177e4 LT |
174 | return; |
175 | } | |
176 | ||
177 | /* | |
178 | * Thread tracking and context switch notification | |
179 | */ | |
4be44fcd | 180 | thread_id = acpi_os_get_thread_id(); |
1da177e4 LT |
181 | if (thread_id != acpi_gbl_prev_thread_id) { |
182 | if (ACPI_LV_THREADS & acpi_dbg_level) { | |
4be44fcd | 183 | acpi_os_printf |
28eb3fcf LM |
184 | ("\n**** Context Switch from TID %u to TID %u ****\n\n", |
185 | (u32)acpi_gbl_prev_thread_id, (u32)thread_id); | |
1da177e4 LT |
186 | } |
187 | ||
188 | acpi_gbl_prev_thread_id = thread_id; | |
189 | } | |
190 | ||
191 | /* | |
192 | * Display the module name, current line number, thread ID (if requested), | |
193 | * current procedure nesting level, and the current procedure name | |
194 | */ | |
4be44fcd | 195 | acpi_os_printf("%8s-%04ld ", module_name, line_number); |
1da177e4 LT |
196 | |
197 | if (ACPI_LV_THREADS & acpi_dbg_level) { | |
28eb3fcf | 198 | acpi_os_printf("[%u] ", (u32)thread_id); |
1da177e4 LT |
199 | } |
200 | ||
4be44fcd LB |
201 | acpi_os_printf("[%02ld] %-22.22s: ", |
202 | acpi_gbl_nesting_level, | |
203 | acpi_ut_trim_function_name(function_name)); | |
1da177e4 | 204 | |
4be44fcd LB |
205 | va_start(args, format); |
206 | acpi_os_vprintf(format, args); | |
507f046c | 207 | va_end(args); |
1da177e4 | 208 | } |
1da177e4 | 209 | |
50df4d8b | 210 | ACPI_EXPORT_SYMBOL(acpi_debug_print) |
1da177e4 | 211 | |
44f6c012 | 212 | /******************************************************************************* |
1da177e4 | 213 | * |
50df4d8b | 214 | * FUNCTION: acpi_debug_print_raw |
1da177e4 LT |
215 | * |
216 | * PARAMETERS: requested_debug_level - Requested debug print level | |
217 | * line_number - Caller's line number | |
f9f4601f RM |
218 | * function_name - Caller's procedure name |
219 | * module_name - Caller's module name | |
220 | * component_id - Caller's component ID | |
ba494bee | 221 | * format - Printf format field |
1da177e4 LT |
222 | * ... - Optional printf arguments |
223 | * | |
224 | * RETURN: None | |
225 | * | |
73a3090a | 226 | * DESCRIPTION: Print message with no headers. Has same interface as |
1da177e4 LT |
227 | * debug_print so that the same macros can be used. |
228 | * | |
44f6c012 | 229 | ******************************************************************************/ |
4be44fcd | 230 | void ACPI_INTERNAL_VAR_XFACE |
50df4d8b BM |
231 | acpi_debug_print_raw(u32 requested_debug_level, |
232 | u32 line_number, | |
233 | const char *function_name, | |
234 | const char *module_name, | |
235 | u32 component_id, const char *format, ...) | |
1da177e4 | 236 | { |
4be44fcd | 237 | va_list args; |
1da177e4 LT |
238 | |
239 | if (!(requested_debug_level & acpi_dbg_level) || | |
4be44fcd | 240 | !(component_id & acpi_dbg_layer)) { |
1da177e4 LT |
241 | return; |
242 | } | |
243 | ||
4be44fcd LB |
244 | va_start(args, format); |
245 | acpi_os_vprintf(format, args); | |
507f046c | 246 | va_end(args); |
1da177e4 | 247 | } |
1da177e4 | 248 | |
50df4d8b | 249 | ACPI_EXPORT_SYMBOL(acpi_debug_print_raw) |
1da177e4 | 250 | |
44f6c012 | 251 | /******************************************************************************* |
1da177e4 LT |
252 | * |
253 | * FUNCTION: acpi_ut_trace | |
254 | * | |
255 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
256 | * function_name - Caller's procedure name |
257 | * module_name - Caller's module name | |
258 | * component_id - Caller's component ID | |
1da177e4 LT |
259 | * |
260 | * RETURN: None | |
261 | * | |
73a3090a | 262 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is |
1da177e4 LT |
263 | * set in debug_level |
264 | * | |
44f6c012 | 265 | ******************************************************************************/ |
1da177e4 | 266 | void |
4be44fcd | 267 | acpi_ut_trace(u32 line_number, |
4b8ed631 BM |
268 | const char *function_name, |
269 | const char *module_name, u32 component_id) | |
1da177e4 LT |
270 | { |
271 | ||
272 | acpi_gbl_nesting_level++; | |
4be44fcd | 273 | acpi_ut_track_stack_ptr(); |
1da177e4 | 274 | |
50df4d8b BM |
275 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
276 | line_number, function_name, module_name, component_id, | |
277 | "%s\n", acpi_gbl_fn_entry_str); | |
1da177e4 | 278 | } |
1da177e4 | 279 | |
8313524a | 280 | ACPI_EXPORT_SYMBOL(acpi_ut_trace) |
1da177e4 | 281 | |
44f6c012 | 282 | /******************************************************************************* |
1da177e4 LT |
283 | * |
284 | * FUNCTION: acpi_ut_trace_ptr | |
285 | * | |
286 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
287 | * function_name - Caller's procedure name |
288 | * module_name - Caller's module name | |
289 | * component_id - Caller's component ID | |
ba494bee | 290 | * pointer - Pointer to display |
1da177e4 LT |
291 | * |
292 | * RETURN: None | |
293 | * | |
73a3090a | 294 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is |
1da177e4 LT |
295 | * set in debug_level |
296 | * | |
44f6c012 | 297 | ******************************************************************************/ |
1da177e4 | 298 | void |
4be44fcd LB |
299 | acpi_ut_trace_ptr(u32 line_number, |
300 | const char *function_name, | |
4b8ed631 | 301 | const char *module_name, u32 component_id, void *pointer) |
1da177e4 | 302 | { |
68aafc35 | 303 | |
1da177e4 | 304 | acpi_gbl_nesting_level++; |
4be44fcd | 305 | acpi_ut_track_stack_ptr(); |
1da177e4 | 306 | |
50df4d8b BM |
307 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
308 | line_number, function_name, module_name, component_id, | |
309 | "%s %p\n", acpi_gbl_fn_entry_str, pointer); | |
1da177e4 LT |
310 | } |
311 | ||
44f6c012 | 312 | /******************************************************************************* |
1da177e4 LT |
313 | * |
314 | * FUNCTION: acpi_ut_trace_str | |
315 | * | |
316 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
317 | * function_name - Caller's procedure name |
318 | * module_name - Caller's module name | |
319 | * component_id - Caller's component ID | |
ba494bee | 320 | * string - Additional string to display |
1da177e4 LT |
321 | * |
322 | * RETURN: None | |
323 | * | |
73a3090a | 324 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is |
1da177e4 LT |
325 | * set in debug_level |
326 | * | |
44f6c012 | 327 | ******************************************************************************/ |
1da177e4 LT |
328 | |
329 | void | |
4be44fcd LB |
330 | acpi_ut_trace_str(u32 line_number, |
331 | const char *function_name, | |
4b8ed631 | 332 | const char *module_name, u32 component_id, char *string) |
1da177e4 LT |
333 | { |
334 | ||
335 | acpi_gbl_nesting_level++; | |
4be44fcd | 336 | acpi_ut_track_stack_ptr(); |
1da177e4 | 337 | |
50df4d8b BM |
338 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
339 | line_number, function_name, module_name, component_id, | |
340 | "%s %s\n", acpi_gbl_fn_entry_str, string); | |
1da177e4 LT |
341 | } |
342 | ||
44f6c012 | 343 | /******************************************************************************* |
1da177e4 LT |
344 | * |
345 | * FUNCTION: acpi_ut_trace_u32 | |
346 | * | |
347 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
348 | * function_name - Caller's procedure name |
349 | * module_name - Caller's module name | |
350 | * component_id - Caller's component ID | |
ba494bee | 351 | * integer - Integer to display |
1da177e4 LT |
352 | * |
353 | * RETURN: None | |
354 | * | |
73a3090a | 355 | * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is |
1da177e4 LT |
356 | * set in debug_level |
357 | * | |
44f6c012 | 358 | ******************************************************************************/ |
1da177e4 LT |
359 | |
360 | void | |
4be44fcd LB |
361 | acpi_ut_trace_u32(u32 line_number, |
362 | const char *function_name, | |
4b8ed631 | 363 | const char *module_name, u32 component_id, u32 integer) |
1da177e4 LT |
364 | { |
365 | ||
366 | acpi_gbl_nesting_level++; | |
4be44fcd | 367 | acpi_ut_track_stack_ptr(); |
1da177e4 | 368 | |
50df4d8b BM |
369 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
370 | line_number, function_name, module_name, component_id, | |
371 | "%s %08X\n", acpi_gbl_fn_entry_str, integer); | |
1da177e4 LT |
372 | } |
373 | ||
44f6c012 | 374 | /******************************************************************************* |
1da177e4 LT |
375 | * |
376 | * FUNCTION: acpi_ut_exit | |
377 | * | |
378 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
379 | * function_name - Caller's procedure name |
380 | * module_name - Caller's module name | |
381 | * component_id - Caller's component ID | |
1da177e4 LT |
382 | * |
383 | * RETURN: None | |
384 | * | |
73a3090a | 385 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is |
1da177e4 LT |
386 | * set in debug_level |
387 | * | |
44f6c012 | 388 | ******************************************************************************/ |
1da177e4 LT |
389 | |
390 | void | |
4be44fcd | 391 | acpi_ut_exit(u32 line_number, |
4b8ed631 BM |
392 | const char *function_name, |
393 | const char *module_name, u32 component_id) | |
1da177e4 LT |
394 | { |
395 | ||
50df4d8b BM |
396 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
397 | line_number, function_name, module_name, component_id, | |
398 | "%s\n", acpi_gbl_fn_exit_str); | |
1da177e4 LT |
399 | |
400 | acpi_gbl_nesting_level--; | |
401 | } | |
1da177e4 | 402 | |
8313524a | 403 | ACPI_EXPORT_SYMBOL(acpi_ut_exit) |
1da177e4 | 404 | |
44f6c012 | 405 | /******************************************************************************* |
1da177e4 LT |
406 | * |
407 | * FUNCTION: acpi_ut_status_exit | |
408 | * | |
409 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
410 | * function_name - Caller's procedure name |
411 | * module_name - Caller's module name | |
412 | * component_id - Caller's component ID | |
ba494bee | 413 | * status - Exit status code |
1da177e4 LT |
414 | * |
415 | * RETURN: None | |
416 | * | |
73a3090a | 417 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is |
1da177e4 LT |
418 | * set in debug_level. Prints exit status also. |
419 | * | |
44f6c012 | 420 | ******************************************************************************/ |
1da177e4 | 421 | void |
4be44fcd LB |
422 | acpi_ut_status_exit(u32 line_number, |
423 | const char *function_name, | |
4b8ed631 BM |
424 | const char *module_name, |
425 | u32 component_id, acpi_status status) | |
1da177e4 LT |
426 | { |
427 | ||
4be44fcd | 428 | if (ACPI_SUCCESS(status)) { |
50df4d8b BM |
429 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
430 | line_number, function_name, module_name, | |
431 | component_id, "%s %s\n", acpi_gbl_fn_exit_str, | |
432 | acpi_format_exception(status)); | |
4be44fcd | 433 | } else { |
50df4d8b BM |
434 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
435 | line_number, function_name, module_name, | |
436 | component_id, "%s ****Exception****: %s\n", | |
437 | acpi_gbl_fn_exit_str, | |
438 | acpi_format_exception(status)); | |
1da177e4 LT |
439 | } |
440 | ||
441 | acpi_gbl_nesting_level--; | |
442 | } | |
1da177e4 | 443 | |
8313524a | 444 | ACPI_EXPORT_SYMBOL(acpi_ut_status_exit) |
1da177e4 | 445 | |
44f6c012 | 446 | /******************************************************************************* |
1da177e4 LT |
447 | * |
448 | * FUNCTION: acpi_ut_value_exit | |
449 | * | |
450 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
451 | * function_name - Caller's procedure name |
452 | * module_name - Caller's module name | |
453 | * component_id - Caller's component ID | |
ba494bee | 454 | * value - Value to be printed with exit msg |
1da177e4 LT |
455 | * |
456 | * RETURN: None | |
457 | * | |
73a3090a | 458 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is |
1da177e4 LT |
459 | * set in debug_level. Prints exit value also. |
460 | * | |
44f6c012 | 461 | ******************************************************************************/ |
1da177e4 | 462 | void |
4be44fcd LB |
463 | acpi_ut_value_exit(u32 line_number, |
464 | const char *function_name, | |
5df7e6cb | 465 | const char *module_name, u32 component_id, u64 value) |
1da177e4 LT |
466 | { |
467 | ||
50df4d8b BM |
468 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
469 | line_number, function_name, module_name, component_id, | |
470 | "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str, | |
471 | ACPI_FORMAT_UINT64(value)); | |
1da177e4 LT |
472 | |
473 | acpi_gbl_nesting_level--; | |
474 | } | |
1da177e4 | 475 | |
8313524a | 476 | ACPI_EXPORT_SYMBOL(acpi_ut_value_exit) |
1da177e4 | 477 | |
44f6c012 | 478 | /******************************************************************************* |
1da177e4 LT |
479 | * |
480 | * FUNCTION: acpi_ut_ptr_exit | |
481 | * | |
482 | * PARAMETERS: line_number - Caller's line number | |
f9f4601f RM |
483 | * function_name - Caller's procedure name |
484 | * module_name - Caller's module name | |
485 | * component_id - Caller's component ID | |
ba494bee | 486 | * ptr - Pointer to display |
1da177e4 LT |
487 | * |
488 | * RETURN: None | |
489 | * | |
73a3090a | 490 | * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is |
1da177e4 LT |
491 | * set in debug_level. Prints exit value also. |
492 | * | |
44f6c012 | 493 | ******************************************************************************/ |
1da177e4 | 494 | void |
4be44fcd LB |
495 | acpi_ut_ptr_exit(u32 line_number, |
496 | const char *function_name, | |
4b8ed631 | 497 | const char *module_name, u32 component_id, u8 *ptr) |
1da177e4 LT |
498 | { |
499 | ||
50df4d8b BM |
500 | acpi_debug_print(ACPI_LV_FUNCTIONS, |
501 | line_number, function_name, module_name, component_id, | |
502 | "%s %p\n", acpi_gbl_fn_exit_str, ptr); | |
1da177e4 LT |
503 | |
504 | acpi_gbl_nesting_level--; | |
505 | } | |
506 | ||
507 | #endif | |
508 | ||
44f6c012 | 509 | /******************************************************************************* |
1da177e4 LT |
510 | * |
511 | * FUNCTION: acpi_ut_dump_buffer | |
512 | * | |
ba494bee BM |
513 | * PARAMETERS: buffer - Buffer to dump |
514 | * count - Amount to dump, in bytes | |
515 | * display - BYTE, WORD, DWORD, or QWORD display | |
97171c6b | 516 | * offset - Beginning buffer offset (display only) |
1da177e4 LT |
517 | * |
518 | * RETURN: None | |
519 | * | |
520 | * DESCRIPTION: Generic dump buffer in both hex and ascii. | |
521 | * | |
44f6c012 | 522 | ******************************************************************************/ |
1da177e4 | 523 | |
97171c6b | 524 | void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset) |
1da177e4 | 525 | { |
67a119f9 BM |
526 | u32 i = 0; |
527 | u32 j; | |
4be44fcd LB |
528 | u32 temp32; |
529 | u8 buf_char; | |
1da177e4 | 530 | |
5eb69180 BM |
531 | if (!buffer) { |
532 | acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n"); | |
533 | return; | |
534 | } | |
535 | ||
1da177e4 LT |
536 | if ((count < 4) || (count & 0x01)) { |
537 | display = DB_BYTE_DISPLAY; | |
538 | } | |
539 | ||
44f6c012 | 540 | /* Nasty little dump buffer routine! */ |
1da177e4 | 541 | |
1da177e4 | 542 | while (i < count) { |
52fc0b02 | 543 | |
1da177e4 LT |
544 | /* Print current offset */ |
545 | ||
97171c6b | 546 | acpi_os_printf("%6.4X: ", (base_offset + i)); |
1da177e4 LT |
547 | |
548 | /* Print 16 hex chars */ | |
549 | ||
550 | for (j = 0; j < 16;) { | |
551 | if (i + j >= count) { | |
52fc0b02 | 552 | |
44f6c012 | 553 | /* Dump fill spaces */ |
1da177e4 | 554 | |
4be44fcd | 555 | acpi_os_printf("%*s", ((display * 2) + 1), " "); |
67a119f9 | 556 | j += display; |
44f6c012 RM |
557 | continue; |
558 | } | |
1da177e4 LT |
559 | |
560 | switch (display) { | |
793c2388 | 561 | case DB_BYTE_DISPLAY: |
4be44fcd | 562 | default: /* Default is BYTE display */ |
1da177e4 | 563 | |
67a119f9 BM |
564 | acpi_os_printf("%02X ", |
565 | buffer[(acpi_size) i + j]); | |
1da177e4 LT |
566 | break; |
567 | ||
1da177e4 LT |
568 | case DB_WORD_DISPLAY: |
569 | ||
67a119f9 BM |
570 | ACPI_MOVE_16_TO_32(&temp32, |
571 | &buffer[(acpi_size) i + j]); | |
4be44fcd | 572 | acpi_os_printf("%04X ", temp32); |
1da177e4 LT |
573 | break; |
574 | ||
1da177e4 LT |
575 | case DB_DWORD_DISPLAY: |
576 | ||
67a119f9 BM |
577 | ACPI_MOVE_32_TO_32(&temp32, |
578 | &buffer[(acpi_size) i + j]); | |
4be44fcd | 579 | acpi_os_printf("%08X ", temp32); |
1da177e4 LT |
580 | break; |
581 | ||
1da177e4 LT |
582 | case DB_QWORD_DISPLAY: |
583 | ||
67a119f9 BM |
584 | ACPI_MOVE_32_TO_32(&temp32, |
585 | &buffer[(acpi_size) i + j]); | |
4be44fcd | 586 | acpi_os_printf("%08X", temp32); |
1da177e4 | 587 | |
67a119f9 BM |
588 | ACPI_MOVE_32_TO_32(&temp32, |
589 | &buffer[(acpi_size) i + j + | |
590 | 4]); | |
4be44fcd | 591 | acpi_os_printf("%08X ", temp32); |
1da177e4 LT |
592 | break; |
593 | } | |
44f6c012 | 594 | |
67a119f9 | 595 | j += display; |
1da177e4 LT |
596 | } |
597 | ||
598 | /* | |
0c9938cc RM |
599 | * Print the ASCII equivalent characters but watch out for the bad |
600 | * unprintable ones (printable chars are 0x20 through 0x7E) | |
1da177e4 | 601 | */ |
4be44fcd | 602 | acpi_os_printf(" "); |
1da177e4 LT |
603 | for (j = 0; j < 16; j++) { |
604 | if (i + j >= count) { | |
4be44fcd | 605 | acpi_os_printf("\n"); |
1da177e4 LT |
606 | return; |
607 | } | |
608 | ||
67a119f9 | 609 | buf_char = buffer[(acpi_size) i + j]; |
4be44fcd LB |
610 | if (ACPI_IS_PRINT(buf_char)) { |
611 | acpi_os_printf("%c", buf_char); | |
612 | } else { | |
613 | acpi_os_printf("."); | |
1da177e4 LT |
614 | } |
615 | } | |
616 | ||
617 | /* Done with that line. */ | |
618 | ||
4be44fcd | 619 | acpi_os_printf("\n"); |
1da177e4 LT |
620 | i += 16; |
621 | } | |
622 | ||
623 | return; | |
624 | } | |
793c2388 BM |
625 | |
626 | /******************************************************************************* | |
627 | * | |
97171c6b | 628 | * FUNCTION: acpi_ut_debug_dump_buffer |
793c2388 | 629 | * |
ba494bee BM |
630 | * PARAMETERS: buffer - Buffer to dump |
631 | * count - Amount to dump, in bytes | |
632 | * display - BYTE, WORD, DWORD, or QWORD display | |
633 | * component_ID - Caller's component ID | |
793c2388 BM |
634 | * |
635 | * RETURN: None | |
636 | * | |
637 | * DESCRIPTION: Generic dump buffer in both hex and ascii. | |
638 | * | |
639 | ******************************************************************************/ | |
640 | ||
97171c6b BM |
641 | void |
642 | acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id) | |
793c2388 BM |
643 | { |
644 | ||
645 | /* Only dump the buffer if tracing is enabled */ | |
646 | ||
647 | if (!((ACPI_LV_TABLES & acpi_dbg_level) && | |
648 | (component_id & acpi_dbg_layer))) { | |
649 | return; | |
650 | } | |
651 | ||
97171c6b | 652 | acpi_ut_dump_buffer(buffer, count, display, 0); |
793c2388 | 653 | } |