blob: 35f3d581e0346f1df55bd9a0f4db512bd3408033 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: utdebug - Debug print routines
4 *
5 *****************************************************************************/
6
7/*
Bob Moore4a90c7e2006-01-13 16:22:00 -05008 * Copyright (C) 2000 - 2006, 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
44#include <linux/module.h>
45
46#include <acpi/acpi.h>
47
48#define _COMPONENT ACPI_UTILITIES
Len Brown4be44fc2005-08-05 00:44:28 -040049ACPI_MODULE_NAME("utdebug")
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51#ifdef ACPI_DEBUG_OUTPUT
Len Brown4be44fc2005-08-05 00:44:28 -040052static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF;
53static char *acpi_gbl_fn_entry_str = "----Entry";
54static char *acpi_gbl_fn_exit_str = "----Exit-";
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Robert Moore0c9938c2005-07-29 15:15:00 -070056/* Local prototypes */
57
Len Brown4be44fc2005-08-05 00:44:28 -040058static const char *acpi_ut_trim_function_name(const char *function_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
Robert Moore44f6c012005-04-18 22:49:35 -040060/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 *
62 * FUNCTION: acpi_ut_init_stack_ptr_trace
63 *
64 * PARAMETERS: None
65 *
66 * RETURN: None
67 *
Robert Moore44f6c012005-04-18 22:49:35 -040068 * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 *
Robert Moore44f6c012005-04-18 22:49:35 -040070 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Len Brown4be44fc2005-08-05 00:44:28 -040072void acpi_ut_init_stack_ptr_trace(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070073{
Len Brown4be44fc2005-08-05 00:44:28 -040074 u32 current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Len Brown4be44fc2005-08-05 00:44:28 -040076 acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF(&current_sp, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077}
78
Robert Moore44f6c012005-04-18 22:49:35 -040079/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 *
81 * FUNCTION: acpi_ut_track_stack_ptr
82 *
83 * PARAMETERS: None
84 *
85 * RETURN: None
86 *
Robert Moore44f6c012005-04-18 22:49:35 -040087 * DESCRIPTION: Save the current CPU stack pointer
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 *
Robert Moore44f6c012005-04-18 22:49:35 -040089 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
Len Brown4be44fc2005-08-05 00:44:28 -040091void acpi_ut_track_stack_ptr(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092{
Len Brown4be44fc2005-08-05 00:44:28 -040093 acpi_size current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
Len Brown4be44fc2005-08-05 00:44:28 -040095 current_sp = ACPI_PTR_DIFF(&current_sp, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
97 if (current_sp < acpi_gbl_lowest_stack_pointer) {
98 acpi_gbl_lowest_stack_pointer = current_sp;
99 }
100
101 if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) {
102 acpi_gbl_deepest_nesting = acpi_gbl_nesting_level;
103 }
104}
105
Robert Moore44f6c012005-04-18 22:49:35 -0400106/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 *
Robert Moore0c9938c2005-07-29 15:15:00 -0700108 * FUNCTION: acpi_ut_trim_function_name
109 *
110 * PARAMETERS: function_name - Ascii string containing a procedure name
111 *
112 * RETURN: Updated pointer to the function name
113 *
114 * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
115 * This allows compiler macros such as __FUNCTION__ to be used
116 * with no change to the debug output.
117 *
118 ******************************************************************************/
119
Len Brown4be44fc2005-08-05 00:44:28 -0400120static const char *acpi_ut_trim_function_name(const char *function_name)
Robert Moore0c9938c2005-07-29 15:15:00 -0700121{
122
123 /* All Function names are longer than 4 chars, check is safe */
124
Bob Moorea18ecf42005-08-15 03:42:00 -0800125 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) {
Robert Moore0c9938c2005-07-29 15:15:00 -0700126 /* This is the case where the original source has not been modified */
127
128 return (function_name + 4);
129 }
130
Bob Moorea18ecf42005-08-15 03:42:00 -0800131 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) {
Robert Moore0c9938c2005-07-29 15:15:00 -0700132 /* This is the case where the source has been 'linuxized' */
133
134 return (function_name + 5);
135 }
136
137 return (function_name);
138}
139
Robert Moore0c9938c2005-07-29 15:15:00 -0700140/*******************************************************************************
141 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 * FUNCTION: acpi_ut_debug_print
143 *
Robert Moore44f6c012005-04-18 22:49:35 -0400144 * PARAMETERS: requested_debug_level - Requested debug print level
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 * line_number - Caller's line number (for error output)
Robert Mooref9f46012005-07-08 00:00:00 -0400146 * function_name - Caller's procedure name
147 * module_name - Caller's module name
148 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 * Format - Printf format field
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 *
Robert Moore44f6c012005-04-18 22:49:35 -0400157 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158
Len Brown4be44fc2005-08-05 00:44:28 -0400159void ACPI_INTERNAL_VAR_XFACE
160acpi_ut_debug_print(u32 requested_debug_level,
161 u32 line_number,
162 const char *function_name,
163 char *module_name, u32 component_id, char *format, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164{
Len Brown4be44fc2005-08-05 00:44:28 -0400165 u32 thread_id;
166 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
168 /*
169 * Stay silent if the debug level or component ID is disabled
170 */
171 if (!(requested_debug_level & acpi_dbg_level) ||
Len Brown4be44fc2005-08-05 00:44:28 -0400172 !(component_id & acpi_dbg_layer)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 return;
174 }
175
176 /*
177 * Thread tracking and context switch notification
178 */
Len Brown4be44fc2005-08-05 00:44:28 -0400179 thread_id = acpi_os_get_thread_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180
181 if (thread_id != acpi_gbl_prev_thread_id) {
182 if (ACPI_LV_THREADS & acpi_dbg_level) {
Len Brown4be44fc2005-08-05 00:44:28 -0400183 acpi_os_printf
184 ("\n**** Context Switch from TID %X to TID %X ****\n\n",
185 acpi_gbl_prev_thread_id, thread_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 }
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 */
Len Brown4be44fc2005-08-05 00:44:28 -0400195 acpi_os_printf("%8s-%04ld ", module_name, line_number);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
197 if (ACPI_LV_THREADS & acpi_dbg_level) {
Len Brown4be44fc2005-08-05 00:44:28 -0400198 acpi_os_printf("[%04lX] ", thread_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 }
200
Len Brown4be44fc2005-08-05 00:44:28 -0400201 acpi_os_printf("[%02ld] %-22.22s: ",
202 acpi_gbl_nesting_level,
203 acpi_ut_trim_function_name(function_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
Len Brown4be44fc2005-08-05 00:44:28 -0400205 va_start(args, format);
206 acpi_os_vprintf(format, args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207}
Robert Moore44f6c012005-04-18 22:49:35 -0400208
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209EXPORT_SYMBOL(acpi_ut_debug_print);
210
Robert Moore44f6c012005-04-18 22:49:35 -0400211/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 *
213 * FUNCTION: acpi_ut_debug_print_raw
214 *
215 * PARAMETERS: requested_debug_level - Requested debug print level
216 * line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400217 * function_name - Caller's procedure name
218 * module_name - Caller's module name
219 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 * Format - Printf format field
221 * ... - Optional printf arguments
222 *
223 * RETURN: None
224 *
225 * DESCRIPTION: Print message with no headers. Has same interface as
226 * debug_print so that the same macros can be used.
227 *
Robert Moore44f6c012005-04-18 22:49:35 -0400228 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229
Len Brown4be44fc2005-08-05 00:44:28 -0400230void ACPI_INTERNAL_VAR_XFACE
231acpi_ut_debug_print_raw(u32 requested_debug_level,
232 u32 line_number,
233 const char *function_name,
234 char *module_name, u32 component_id, char *format, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235{
Len Brown4be44fc2005-08-05 00:44:28 -0400236 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
238 if (!(requested_debug_level & acpi_dbg_level) ||
Len Brown4be44fc2005-08-05 00:44:28 -0400239 !(component_id & acpi_dbg_layer)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 return;
241 }
242
Len Brown4be44fc2005-08-05 00:44:28 -0400243 va_start(args, format);
244 acpi_os_vprintf(format, args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
Len Brown4be44fc2005-08-05 00:44:28 -0400247EXPORT_SYMBOL(acpi_ut_debug_print_raw);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248
Robert Moore44f6c012005-04-18 22:49:35 -0400249/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 *
251 * FUNCTION: acpi_ut_trace
252 *
253 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400254 * function_name - Caller's procedure name
255 * module_name - Caller's module name
256 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 *
258 * RETURN: None
259 *
260 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
261 * set in debug_level
262 *
Robert Moore44f6c012005-04-18 22:49:35 -0400263 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264
265void
Len Brown4be44fc2005-08-05 00:44:28 -0400266acpi_ut_trace(u32 line_number,
267 const char *function_name, char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268{
269
270 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400271 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
Len Brown4be44fc2005-08-05 00:44:28 -0400273 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
274 line_number, function_name, module_name,
275 component_id, "%s\n", acpi_gbl_fn_entry_str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Len Brown4be44fc2005-08-05 00:44:28 -0400278EXPORT_SYMBOL(acpi_ut_trace);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
Robert Moore44f6c012005-04-18 22:49:35 -0400280/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 *
282 * FUNCTION: acpi_ut_trace_ptr
283 *
284 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400285 * function_name - Caller's procedure name
286 * module_name - Caller's module name
287 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 * Pointer - Pointer to display
289 *
290 * RETURN: None
291 *
292 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
293 * set in debug_level
294 *
Robert Moore44f6c012005-04-18 22:49:35 -0400295 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
297void
Len Brown4be44fc2005-08-05 00:44:28 -0400298acpi_ut_trace_ptr(u32 line_number,
299 const char *function_name,
300 char *module_name, u32 component_id, void *pointer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301{
302 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400303 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304
Len Brown4be44fc2005-08-05 00:44:28 -0400305 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
306 line_number, function_name, module_name,
307 component_id, "%s %p\n", acpi_gbl_fn_entry_str,
308 pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309}
310
Robert Moore44f6c012005-04-18 22:49:35 -0400311/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 *
313 * FUNCTION: acpi_ut_trace_str
314 *
315 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400316 * function_name - Caller's procedure name
317 * module_name - Caller's module name
318 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 * String - Additional string to display
320 *
321 * RETURN: None
322 *
323 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
324 * set in debug_level
325 *
Robert Moore44f6c012005-04-18 22:49:35 -0400326 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327
328void
Len Brown4be44fc2005-08-05 00:44:28 -0400329acpi_ut_trace_str(u32 line_number,
330 const char *function_name,
331 char *module_name, u32 component_id, char *string)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332{
333
334 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400335 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336
Len Brown4be44fc2005-08-05 00:44:28 -0400337 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
338 line_number, function_name, module_name,
339 component_id, "%s %s\n", acpi_gbl_fn_entry_str,
340 string);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341}
342
Robert Moore44f6c012005-04-18 22:49:35 -0400343/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344 *
345 * FUNCTION: acpi_ut_trace_u32
346 *
347 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400348 * function_name - Caller's procedure name
349 * module_name - Caller's module name
350 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 * Integer - Integer to display
352 *
353 * RETURN: None
354 *
355 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
356 * set in debug_level
357 *
Robert Moore44f6c012005-04-18 22:49:35 -0400358 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359
360void
Len Brown4be44fc2005-08-05 00:44:28 -0400361acpi_ut_trace_u32(u32 line_number,
362 const char *function_name,
363 char *module_name, u32 component_id, u32 integer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364{
365
366 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400367 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368
Len Brown4be44fc2005-08-05 00:44:28 -0400369 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
370 line_number, function_name, module_name,
371 component_id, "%s %08X\n", acpi_gbl_fn_entry_str,
372 integer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373}
374
Robert Moore44f6c012005-04-18 22:49:35 -0400375/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 *
377 * FUNCTION: acpi_ut_exit
378 *
379 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400380 * function_name - Caller's procedure name
381 * module_name - Caller's module name
382 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 *
384 * RETURN: None
385 *
386 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
387 * set in debug_level
388 *
Robert Moore44f6c012005-04-18 22:49:35 -0400389 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390
391void
Len Brown4be44fc2005-08-05 00:44:28 -0400392acpi_ut_exit(u32 line_number,
393 const char *function_name, char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394{
395
Len Brown4be44fc2005-08-05 00:44:28 -0400396 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
397 line_number, function_name, module_name,
398 component_id, "%s\n", acpi_gbl_fn_exit_str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399
400 acpi_gbl_nesting_level--;
401}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402
Len Brown4be44fc2005-08-05 00:44:28 -0400403EXPORT_SYMBOL(acpi_ut_exit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404
Robert Moore44f6c012005-04-18 22:49:35 -0400405/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 *
407 * FUNCTION: acpi_ut_status_exit
408 *
409 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400410 * function_name - Caller's procedure name
411 * module_name - Caller's module name
412 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 * Status - Exit status code
414 *
415 * RETURN: None
416 *
417 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
418 * set in debug_level. Prints exit status also.
419 *
Robert Moore44f6c012005-04-18 22:49:35 -0400420 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421
422void
Len Brown4be44fc2005-08-05 00:44:28 -0400423acpi_ut_status_exit(u32 line_number,
424 const char *function_name,
425 char *module_name, u32 component_id, acpi_status status)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426{
427
Len Brown4be44fc2005-08-05 00:44:28 -0400428 if (ACPI_SUCCESS(status)) {
429 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
430 line_number, function_name, module_name,
431 component_id, "%s %s\n",
432 acpi_gbl_fn_exit_str,
433 acpi_format_exception(status));
434 } else {
435 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
436 line_number, function_name, module_name,
437 component_id, "%s ****Exception****: %s\n",
438 acpi_gbl_fn_exit_str,
439 acpi_format_exception(status));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 }
441
442 acpi_gbl_nesting_level--;
443}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444
Len Brown4be44fc2005-08-05 00:44:28 -0400445EXPORT_SYMBOL(acpi_ut_status_exit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446
Robert Moore44f6c012005-04-18 22:49:35 -0400447/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 *
449 * FUNCTION: acpi_ut_value_exit
450 *
451 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400452 * function_name - Caller's procedure name
453 * module_name - Caller's module name
454 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 * Value - Value to be printed with exit msg
456 *
457 * RETURN: None
458 *
459 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
460 * set in debug_level. Prints exit value also.
461 *
Robert Moore44f6c012005-04-18 22:49:35 -0400462 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463
464void
Len Brown4be44fc2005-08-05 00:44:28 -0400465acpi_ut_value_exit(u32 line_number,
466 const char *function_name,
467 char *module_name, u32 component_id, acpi_integer value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468{
469
Len Brown4be44fc2005-08-05 00:44:28 -0400470 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
471 line_number, function_name, module_name,
472 component_id, "%s %8.8X%8.8X\n",
473 acpi_gbl_fn_exit_str, ACPI_FORMAT_UINT64(value));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474
475 acpi_gbl_nesting_level--;
476}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477
Len Brown4be44fc2005-08-05 00:44:28 -0400478EXPORT_SYMBOL(acpi_ut_value_exit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
Robert Moore44f6c012005-04-18 22:49:35 -0400480/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 *
482 * FUNCTION: acpi_ut_ptr_exit
483 *
484 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400485 * function_name - Caller's procedure name
486 * module_name - Caller's module name
487 * component_id - Caller's component ID
Robert Moore44f6c012005-04-18 22:49:35 -0400488 * Ptr - Pointer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 *
490 * RETURN: None
491 *
492 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
493 * set in debug_level. Prints exit value also.
494 *
Robert Moore44f6c012005-04-18 22:49:35 -0400495 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496
497void
Len Brown4be44fc2005-08-05 00:44:28 -0400498acpi_ut_ptr_exit(u32 line_number,
499 const char *function_name,
500 char *module_name, u32 component_id, u8 * ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501{
502
Len Brown4be44fc2005-08-05 00:44:28 -0400503 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
504 line_number, function_name, module_name,
505 component_id, "%s %p\n", acpi_gbl_fn_exit_str, ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506
507 acpi_gbl_nesting_level--;
508}
509
510#endif
511
Robert Moore44f6c012005-04-18 22:49:35 -0400512/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 *
514 * FUNCTION: acpi_ut_dump_buffer
515 *
516 * PARAMETERS: Buffer - Buffer to dump
517 * Count - Amount to dump, in bytes
518 * Display - BYTE, WORD, DWORD, or QWORD display
519 * component_iD - Caller's component ID
520 *
521 * RETURN: None
522 *
523 * DESCRIPTION: Generic dump buffer in both hex and ascii.
524 *
Robert Moore44f6c012005-04-18 22:49:35 -0400525 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526
Len Brown4be44fc2005-08-05 00:44:28 -0400527void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528{
Len Brown4be44fc2005-08-05 00:44:28 -0400529 acpi_native_uint i = 0;
530 acpi_native_uint j;
531 u32 temp32;
532 u8 buf_char;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533
534 /* Only dump the buffer if tracing is enabled */
535
536 if (!((ACPI_LV_TABLES & acpi_dbg_level) &&
Len Brown4be44fc2005-08-05 00:44:28 -0400537 (component_id & acpi_dbg_layer))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 return;
539 }
540
541 if ((count < 4) || (count & 0x01)) {
542 display = DB_BYTE_DISPLAY;
543 }
544
Robert Moore44f6c012005-04-18 22:49:35 -0400545 /* Nasty little dump buffer routine! */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 while (i < count) {
548 /* Print current offset */
549
Len Brown4be44fc2005-08-05 00:44:28 -0400550 acpi_os_printf("%6.4X: ", (u32) i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551
552 /* Print 16 hex chars */
553
554 for (j = 0; j < 16;) {
555 if (i + j >= count) {
Robert Moore44f6c012005-04-18 22:49:35 -0400556 /* Dump fill spaces */
557
Len Brown4be44fc2005-08-05 00:44:28 -0400558 acpi_os_printf("%*s", ((display * 2) + 1), " ");
Robert Moore73459f72005-06-24 00:00:00 -0400559 j += (acpi_native_uint) display;
Robert Moore44f6c012005-04-18 22:49:35 -0400560 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 }
562
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 switch (display) {
Len Brown4be44fc2005-08-05 00:44:28 -0400564 default: /* Default is BYTE display */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565
Len Brown4be44fc2005-08-05 00:44:28 -0400566 acpi_os_printf("%02X ", buffer[i + j]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 break;
568
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 case DB_WORD_DISPLAY:
570
Len Brown4be44fc2005-08-05 00:44:28 -0400571 ACPI_MOVE_16_TO_32(&temp32, &buffer[i + j]);
572 acpi_os_printf("%04X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 break;
574
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 case DB_DWORD_DISPLAY:
576
Len Brown4be44fc2005-08-05 00:44:28 -0400577 ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j]);
578 acpi_os_printf("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 break;
580
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 case DB_QWORD_DISPLAY:
582
Len Brown4be44fc2005-08-05 00:44:28 -0400583 ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j]);
584 acpi_os_printf("%08X", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585
Len Brown4be44fc2005-08-05 00:44:28 -0400586 ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j + 4]);
587 acpi_os_printf("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 break;
589 }
Robert Moore44f6c012005-04-18 22:49:35 -0400590
Robert Moore73459f72005-06-24 00:00:00 -0400591 j += (acpi_native_uint) display;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 }
593
594 /*
Robert Moore0c9938c2005-07-29 15:15:00 -0700595 * Print the ASCII equivalent characters but watch out for the bad
596 * unprintable ones (printable chars are 0x20 through 0x7E)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 */
Len Brown4be44fc2005-08-05 00:44:28 -0400598 acpi_os_printf(" ");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 for (j = 0; j < 16; j++) {
600 if (i + j >= count) {
Len Brown4be44fc2005-08-05 00:44:28 -0400601 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 return;
603 }
604
605 buf_char = buffer[i + j];
Len Brown4be44fc2005-08-05 00:44:28 -0400606 if (ACPI_IS_PRINT(buf_char)) {
607 acpi_os_printf("%c", buf_char);
608 } else {
609 acpi_os_printf(".");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 }
611 }
612
613 /* Done with that line. */
614
Len Brown4be44fc2005-08-05 00:44:28 -0400615 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 i += 16;
617 }
618
619 return;
620}