blob: 2d6a78fb01cf63055baab9516a657570347cc174 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: utdebug - Debug print routines
4 *
5 *****************************************************************************/
6
7/*
Bob Moore6c9deb72007-02-02 19:48:24 +03008 * Copyright (C) 2000 - 2007, R. Byron Moore
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
45
46#define _COMPONENT ACPI_UTILITIES
Len Brown4be44fc2005-08-05 00:44:28 -040047ACPI_MODULE_NAME("utdebug")
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#ifdef ACPI_DEBUG_OUTPUT
Len Brownab8aa062006-07-07 20:11:07 -040049static acpi_thread_id acpi_gbl_prev_thread_id;
Len Brown4be44fc2005-08-05 00:44:28 -040050static char *acpi_gbl_fn_entry_str = "----Entry";
51static char *acpi_gbl_fn_exit_str = "----Exit-";
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Robert Moore0c9938c2005-07-29 15:15:00 -070053/* Local prototypes */
54
Len Brown4be44fc2005-08-05 00:44:28 -040055static const char *acpi_ut_trim_function_name(const char *function_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Robert Moore44f6c012005-04-18 22:49:35 -040057/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 *
59 * FUNCTION: acpi_ut_init_stack_ptr_trace
60 *
61 * PARAMETERS: None
62 *
63 * RETURN: None
64 *
Robert Moore44f6c012005-04-18 22:49:35 -040065 * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 *
Robert Moore44f6c012005-04-18 22:49:35 -040067 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Len Brown4be44fc2005-08-05 00:44:28 -040069void acpi_ut_init_stack_ptr_trace(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070070{
Bob Moore1d18c052008-04-10 19:06:40 +040071 acpi_size current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Bob Moore1d18c052008-04-10 19:06:40 +040073 acpi_gbl_entry_stack_pointer = &current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074}
75
Robert Moore44f6c012005-04-18 22:49:35 -040076/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 *
78 * FUNCTION: acpi_ut_track_stack_ptr
79 *
80 * PARAMETERS: None
81 *
82 * RETURN: None
83 *
Robert Moore44f6c012005-04-18 22:49:35 -040084 * DESCRIPTION: Save the current CPU stack pointer
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 *
Robert Moore44f6c012005-04-18 22:49:35 -040086 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
Len Brown4be44fc2005-08-05 00:44:28 -040088void acpi_ut_track_stack_ptr(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070089{
Len Brown4be44fc2005-08-05 00:44:28 -040090 acpi_size current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
Bob Moore1d18c052008-04-10 19:06:40 +040092 if (&current_sp < acpi_gbl_lowest_stack_pointer) {
93 acpi_gbl_lowest_stack_pointer = &current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 }
95
96 if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) {
97 acpi_gbl_deepest_nesting = acpi_gbl_nesting_level;
98 }
99}
100
Robert Moore44f6c012005-04-18 22:49:35 -0400101/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 *
Robert Moore0c9938c2005-07-29 15:15:00 -0700103 * FUNCTION: acpi_ut_trim_function_name
104 *
105 * PARAMETERS: function_name - Ascii string containing a procedure name
106 *
107 * RETURN: Updated pointer to the function name
108 *
109 * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
Harvey Harrison96b2dd12008-03-05 18:24:51 -0800110 * This allows compiler macros such as __func__ to be used
Robert Moore0c9938c2005-07-29 15:15:00 -0700111 * with no change to the debug output.
112 *
113 ******************************************************************************/
114
Len Brown4be44fc2005-08-05 00:44:28 -0400115static const char *acpi_ut_trim_function_name(const char *function_name)
Robert Moore0c9938c2005-07-29 15:15:00 -0700116{
117
118 /* All Function names are longer than 4 chars, check is safe */
119
Bob Moorea18ecf42005-08-15 03:42:00 -0800120 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400121
Robert Moore0c9938c2005-07-29 15:15:00 -0700122 /* This is the case where the original source has not been modified */
123
124 return (function_name + 4);
125 }
126
Bob Moorea18ecf42005-08-15 03:42:00 -0800127 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400128
Robert Moore0c9938c2005-07-29 15:15:00 -0700129 /* This is the case where the source has been 'linuxized' */
130
131 return (function_name + 5);
132 }
133
134 return (function_name);
135}
136
Robert Moore0c9938c2005-07-29 15:15:00 -0700137/*******************************************************************************
138 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 * FUNCTION: acpi_ut_debug_print
140 *
Robert Moore44f6c012005-04-18 22:49:35 -0400141 * PARAMETERS: requested_debug_level - Requested debug print level
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 * line_number - Caller's line number (for error output)
Robert Mooref9f46012005-07-08 00:00:00 -0400143 * function_name - Caller's procedure name
144 * module_name - Caller's module name
145 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 * Format - Printf format field
147 * ... - Optional printf arguments
148 *
149 * RETURN: None
150 *
151 * DESCRIPTION: Print error message with prefix consisting of the module name,
152 * line number, and component ID.
153 *
Robert Moore44f6c012005-04-18 22:49:35 -0400154 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155
Len Brown4be44fc2005-08-05 00:44:28 -0400156void ACPI_INTERNAL_VAR_XFACE
157acpi_ut_debug_print(u32 requested_debug_level,
158 u32 line_number,
159 const char *function_name,
160 char *module_name, u32 component_id, char *format, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161{
Bob Moore83135242006-10-03 00:00:00 -0400162 acpi_thread_id thread_id;
Len Brown4be44fc2005-08-05 00:44:28 -0400163 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164
165 /*
166 * Stay silent if the debug level or component ID is disabled
167 */
168 if (!(requested_debug_level & acpi_dbg_level) ||
Len Brown4be44fc2005-08-05 00:44:28 -0400169 !(component_id & acpi_dbg_layer)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 return;
171 }
172
173 /*
174 * Thread tracking and context switch notification
175 */
Len Brown4be44fc2005-08-05 00:44:28 -0400176 thread_id = acpi_os_get_thread_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 if (thread_id != acpi_gbl_prev_thread_id) {
178 if (ACPI_LV_THREADS & acpi_dbg_level) {
Len Brown4be44fc2005-08-05 00:44:28 -0400179 acpi_os_printf
Alexey Starikovskiyb0b7eaa2007-01-25 22:39:44 -0500180 ("\n**** Context Switch from TID %lX to TID %lX ****\n\n",
Len Brownfd350942007-05-09 23:34:35 -0400181 (unsigned long)acpi_gbl_prev_thread_id,
182 (unsigned long)thread_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 }
184
185 acpi_gbl_prev_thread_id = thread_id;
186 }
187
188 /*
189 * Display the module name, current line number, thread ID (if requested),
190 * current procedure nesting level, and the current procedure name
191 */
Len Brown4be44fc2005-08-05 00:44:28 -0400192 acpi_os_printf("%8s-%04ld ", module_name, line_number);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193
194 if (ACPI_LV_THREADS & acpi_dbg_level) {
Alexey Starikovskiyb0b7eaa2007-01-25 22:39:44 -0500195 acpi_os_printf("[%04lX] ", (unsigned long)thread_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 }
197
Len Brown4be44fc2005-08-05 00:44:28 -0400198 acpi_os_printf("[%02ld] %-22.22s: ",
199 acpi_gbl_nesting_level,
200 acpi_ut_trim_function_name(function_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
Len Brown4be44fc2005-08-05 00:44:28 -0400202 va_start(args, format);
203 acpi_os_vprintf(format, args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204}
Robert Moore44f6c012005-04-18 22:49:35 -0400205
Bob Moore83135242006-10-03 00:00:00 -0400206ACPI_EXPORT_SYMBOL(acpi_ut_debug_print)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
Robert Moore44f6c012005-04-18 22:49:35 -0400208/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 *
210 * FUNCTION: acpi_ut_debug_print_raw
211 *
212 * PARAMETERS: requested_debug_level - Requested debug print level
213 * line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400214 * function_name - Caller's procedure name
215 * module_name - Caller's module name
216 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 * Format - Printf format field
218 * ... - Optional printf arguments
219 *
220 * RETURN: None
221 *
222 * DESCRIPTION: Print message with no headers. Has same interface as
223 * debug_print so that the same macros can be used.
224 *
Robert Moore44f6c012005-04-18 22:49:35 -0400225 ******************************************************************************/
Len Brown4be44fc2005-08-05 00:44:28 -0400226void ACPI_INTERNAL_VAR_XFACE
227acpi_ut_debug_print_raw(u32 requested_debug_level,
228 u32 line_number,
229 const char *function_name,
230 char *module_name, u32 component_id, char *format, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231{
Len Brown4be44fc2005-08-05 00:44:28 -0400232 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233
234 if (!(requested_debug_level & acpi_dbg_level) ||
Len Brown4be44fc2005-08-05 00:44:28 -0400235 !(component_id & acpi_dbg_layer)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 return;
237 }
238
Len Brown4be44fc2005-08-05 00:44:28 -0400239 va_start(args, format);
240 acpi_os_vprintf(format, args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242
Bob Moore83135242006-10-03 00:00:00 -0400243ACPI_EXPORT_SYMBOL(acpi_ut_debug_print_raw)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244
Robert Moore44f6c012005-04-18 22:49:35 -0400245/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 *
247 * FUNCTION: acpi_ut_trace
248 *
249 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400250 * function_name - Caller's procedure name
251 * module_name - Caller's module name
252 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 *
254 * RETURN: None
255 *
256 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
257 * set in debug_level
258 *
Robert Moore44f6c012005-04-18 22:49:35 -0400259 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260void
Len Brown4be44fc2005-08-05 00:44:28 -0400261acpi_ut_trace(u32 line_number,
262 const char *function_name, char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263{
264
265 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400266 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267
Len Brown4be44fc2005-08-05 00:44:28 -0400268 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
269 line_number, function_name, module_name,
270 component_id, "%s\n", acpi_gbl_fn_entry_str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
Bob Moore83135242006-10-03 00:00:00 -0400273ACPI_EXPORT_SYMBOL(acpi_ut_trace)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274
Robert Moore44f6c012005-04-18 22:49:35 -0400275/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 *
277 * FUNCTION: acpi_ut_trace_ptr
278 *
279 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400280 * function_name - Caller's procedure name
281 * module_name - Caller's module name
282 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 * Pointer - Pointer to display
284 *
285 * RETURN: None
286 *
287 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
288 * set in debug_level
289 *
Robert Moore44f6c012005-04-18 22:49:35 -0400290 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291void
Len Brown4be44fc2005-08-05 00:44:28 -0400292acpi_ut_trace_ptr(u32 line_number,
293 const char *function_name,
294 char *module_name, u32 component_id, void *pointer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295{
296 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400297 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298
Len Brown4be44fc2005-08-05 00:44:28 -0400299 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
300 line_number, function_name, module_name,
301 component_id, "%s %p\n", acpi_gbl_fn_entry_str,
302 pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303}
304
Robert Moore44f6c012005-04-18 22:49:35 -0400305/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 *
307 * FUNCTION: acpi_ut_trace_str
308 *
309 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400310 * function_name - Caller's procedure name
311 * module_name - Caller's module name
312 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 * String - Additional string to display
314 *
315 * RETURN: None
316 *
317 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
318 * set in debug_level
319 *
Robert Moore44f6c012005-04-18 22:49:35 -0400320 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321
322void
Len Brown4be44fc2005-08-05 00:44:28 -0400323acpi_ut_trace_str(u32 line_number,
324 const char *function_name,
325 char *module_name, u32 component_id, char *string)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326{
327
328 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400329 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330
Len Brown4be44fc2005-08-05 00:44:28 -0400331 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
332 line_number, function_name, module_name,
333 component_id, "%s %s\n", acpi_gbl_fn_entry_str,
334 string);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335}
336
Robert Moore44f6c012005-04-18 22:49:35 -0400337/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 *
339 * FUNCTION: acpi_ut_trace_u32
340 *
341 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400342 * function_name - Caller's procedure name
343 * module_name - Caller's module name
344 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 * Integer - Integer to display
346 *
347 * RETURN: None
348 *
349 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
350 * set in debug_level
351 *
Robert Moore44f6c012005-04-18 22:49:35 -0400352 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353
354void
Len Brown4be44fc2005-08-05 00:44:28 -0400355acpi_ut_trace_u32(u32 line_number,
356 const char *function_name,
357 char *module_name, u32 component_id, u32 integer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358{
359
360 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400361 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362
Len Brown4be44fc2005-08-05 00:44:28 -0400363 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
364 line_number, function_name, module_name,
365 component_id, "%s %08X\n", acpi_gbl_fn_entry_str,
366 integer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367}
368
Robert Moore44f6c012005-04-18 22:49:35 -0400369/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 *
371 * FUNCTION: acpi_ut_exit
372 *
373 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400374 * function_name - Caller's procedure name
375 * module_name - Caller's module name
376 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 *
378 * RETURN: None
379 *
380 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
381 * set in debug_level
382 *
Robert Moore44f6c012005-04-18 22:49:35 -0400383 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384
385void
Len Brown4be44fc2005-08-05 00:44:28 -0400386acpi_ut_exit(u32 line_number,
387 const char *function_name, char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388{
389
Len Brown4be44fc2005-08-05 00:44:28 -0400390 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
391 line_number, function_name, module_name,
392 component_id, "%s\n", acpi_gbl_fn_exit_str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393
394 acpi_gbl_nesting_level--;
395}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396
Bob Moore83135242006-10-03 00:00:00 -0400397ACPI_EXPORT_SYMBOL(acpi_ut_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398
Robert Moore44f6c012005-04-18 22:49:35 -0400399/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 *
401 * FUNCTION: acpi_ut_status_exit
402 *
403 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400404 * function_name - Caller's procedure name
405 * module_name - Caller's module name
406 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 * Status - Exit status code
408 *
409 * RETURN: None
410 *
411 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
412 * set in debug_level. Prints exit status also.
413 *
Robert Moore44f6c012005-04-18 22:49:35 -0400414 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415void
Len Brown4be44fc2005-08-05 00:44:28 -0400416acpi_ut_status_exit(u32 line_number,
417 const char *function_name,
418 char *module_name, u32 component_id, acpi_status status)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419{
420
Len Brown4be44fc2005-08-05 00:44:28 -0400421 if (ACPI_SUCCESS(status)) {
422 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
423 line_number, function_name, module_name,
424 component_id, "%s %s\n",
425 acpi_gbl_fn_exit_str,
426 acpi_format_exception(status));
427 } else {
428 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
429 line_number, function_name, module_name,
430 component_id, "%s ****Exception****: %s\n",
431 acpi_gbl_fn_exit_str,
432 acpi_format_exception(status));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 }
434
435 acpi_gbl_nesting_level--;
436}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437
Bob Moore83135242006-10-03 00:00:00 -0400438ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439
Robert Moore44f6c012005-04-18 22:49:35 -0400440/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 *
442 * FUNCTION: acpi_ut_value_exit
443 *
444 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400445 * function_name - Caller's procedure name
446 * module_name - Caller's module name
447 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 * Value - Value to be printed with exit msg
449 *
450 * RETURN: None
451 *
452 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
453 * set in debug_level. Prints exit value also.
454 *
Robert Moore44f6c012005-04-18 22:49:35 -0400455 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456void
Len Brown4be44fc2005-08-05 00:44:28 -0400457acpi_ut_value_exit(u32 line_number,
458 const char *function_name,
459 char *module_name, u32 component_id, acpi_integer value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460{
461
Len Brown4be44fc2005-08-05 00:44:28 -0400462 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
463 line_number, function_name, module_name,
464 component_id, "%s %8.8X%8.8X\n",
465 acpi_gbl_fn_exit_str, ACPI_FORMAT_UINT64(value));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466
467 acpi_gbl_nesting_level--;
468}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469
Bob Moore83135242006-10-03 00:00:00 -0400470ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471
Robert Moore44f6c012005-04-18 22:49:35 -0400472/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 *
474 * FUNCTION: acpi_ut_ptr_exit
475 *
476 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400477 * function_name - Caller's procedure name
478 * module_name - Caller's module name
479 * component_id - Caller's component ID
Robert Moore44f6c012005-04-18 22:49:35 -0400480 * Ptr - Pointer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 *
482 * RETURN: None
483 *
484 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
485 * set in debug_level. Prints exit value also.
486 *
Robert Moore44f6c012005-04-18 22:49:35 -0400487 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488void
Len Brown4be44fc2005-08-05 00:44:28 -0400489acpi_ut_ptr_exit(u32 line_number,
490 const char *function_name,
491 char *module_name, u32 component_id, u8 * ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492{
493
Len Brown4be44fc2005-08-05 00:44:28 -0400494 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
495 line_number, function_name, module_name,
496 component_id, "%s %p\n", acpi_gbl_fn_exit_str, ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497
498 acpi_gbl_nesting_level--;
499}
500
501#endif
502
Robert Moore44f6c012005-04-18 22:49:35 -0400503/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 *
505 * FUNCTION: acpi_ut_dump_buffer
506 *
507 * PARAMETERS: Buffer - Buffer to dump
508 * Count - Amount to dump, in bytes
509 * Display - BYTE, WORD, DWORD, or QWORD display
510 * component_iD - Caller's component ID
511 *
512 * RETURN: None
513 *
514 * DESCRIPTION: Generic dump buffer in both hex and ascii.
515 *
Robert Moore44f6c012005-04-18 22:49:35 -0400516 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517
Bob Moore793c2382006-03-31 00:00:00 -0500518void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519{
Len Brown4be44fc2005-08-05 00:44:28 -0400520 acpi_native_uint i = 0;
521 acpi_native_uint j;
522 u32 temp32;
523 u8 buf_char;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524
Bob Moore5eb69182008-04-10 19:06:39 +0400525 if (!buffer) {
526 acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n");
527 return;
528 }
529
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 if ((count < 4) || (count & 0x01)) {
531 display = DB_BYTE_DISPLAY;
532 }
533
Robert Moore44f6c012005-04-18 22:49:35 -0400534 /* Nasty little dump buffer routine! */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 while (i < count) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400537
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 /* Print current offset */
539
Len Brown4be44fc2005-08-05 00:44:28 -0400540 acpi_os_printf("%6.4X: ", (u32) i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541
542 /* Print 16 hex chars */
543
544 for (j = 0; j < 16;) {
545 if (i + j >= count) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400546
Robert Moore44f6c012005-04-18 22:49:35 -0400547 /* Dump fill spaces */
548
Len Brown4be44fc2005-08-05 00:44:28 -0400549 acpi_os_printf("%*s", ((display * 2) + 1), " ");
Robert Moore73459f72005-06-24 00:00:00 -0400550 j += (acpi_native_uint) display;
Robert Moore44f6c012005-04-18 22:49:35 -0400551 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 }
553
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 switch (display) {
Bob Moore793c2382006-03-31 00:00:00 -0500555 case DB_BYTE_DISPLAY:
Len Brown4be44fc2005-08-05 00:44:28 -0400556 default: /* Default is BYTE display */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557
Len Brown4be44fc2005-08-05 00:44:28 -0400558 acpi_os_printf("%02X ", buffer[i + j]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 break;
560
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 case DB_WORD_DISPLAY:
562
Len Brown4be44fc2005-08-05 00:44:28 -0400563 ACPI_MOVE_16_TO_32(&temp32, &buffer[i + j]);
564 acpi_os_printf("%04X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 break;
566
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 case DB_DWORD_DISPLAY:
568
Len Brown4be44fc2005-08-05 00:44:28 -0400569 ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j]);
570 acpi_os_printf("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 break;
572
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 case DB_QWORD_DISPLAY:
574
Len Brown4be44fc2005-08-05 00:44:28 -0400575 ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j]);
576 acpi_os_printf("%08X", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577
Len Brown4be44fc2005-08-05 00:44:28 -0400578 ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j + 4]);
579 acpi_os_printf("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 break;
581 }
Robert Moore44f6c012005-04-18 22:49:35 -0400582
Robert Moore73459f72005-06-24 00:00:00 -0400583 j += (acpi_native_uint) display;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 }
585
586 /*
Robert Moore0c9938c2005-07-29 15:15:00 -0700587 * Print the ASCII equivalent characters but watch out for the bad
588 * unprintable ones (printable chars are 0x20 through 0x7E)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 */
Len Brown4be44fc2005-08-05 00:44:28 -0400590 acpi_os_printf(" ");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 for (j = 0; j < 16; j++) {
592 if (i + j >= count) {
Len Brown4be44fc2005-08-05 00:44:28 -0400593 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 return;
595 }
596
597 buf_char = buffer[i + j];
Len Brown4be44fc2005-08-05 00:44:28 -0400598 if (ACPI_IS_PRINT(buf_char)) {
599 acpi_os_printf("%c", buf_char);
600 } else {
601 acpi_os_printf(".");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 }
603 }
604
605 /* Done with that line. */
606
Len Brown4be44fc2005-08-05 00:44:28 -0400607 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 i += 16;
609 }
610
611 return;
612}
Bob Moore793c2382006-03-31 00:00:00 -0500613
614/*******************************************************************************
615 *
616 * FUNCTION: acpi_ut_dump_buffer
617 *
618 * PARAMETERS: Buffer - Buffer to dump
619 * Count - Amount to dump, in bytes
620 * Display - BYTE, WORD, DWORD, or QWORD display
621 * component_iD - Caller's component ID
622 *
623 * RETURN: None
624 *
625 * DESCRIPTION: Generic dump buffer in both hex and ascii.
626 *
627 ******************************************************************************/
628
629void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id)
630{
631
632 /* Only dump the buffer if tracing is enabled */
633
634 if (!((ACPI_LV_TABLES & acpi_dbg_level) &&
635 (component_id & acpi_dbg_layer))) {
636 return;
637 }
638
639 acpi_ut_dump_buffer2(buffer, count, display);
640}