blob: fd66ecb6741e3a2675a0e2c0358192807c8b2e5e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: utdebug - Debug print routines
4 *
5 *****************************************************************************/
6
7/*
Len Brown75a44ce2008-04-23 23:00:13 -04008 * Copyright (C) 2000 - 2008, Intel Corp.
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,
Bob Moore4b8ed632008-06-10 13:55:53 +0800160 const char *module_name,
161 u32 component_id, const char *format, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162{
Bob Moore83135242006-10-03 00:00:00 -0400163 acpi_thread_id thread_id;
Len Brown4be44fc2005-08-05 00:44:28 -0400164 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165
166 /*
167 * Stay silent if the debug level or component ID is disabled
168 */
169 if (!(requested_debug_level & acpi_dbg_level) ||
Len Brown4be44fc2005-08-05 00:44:28 -0400170 !(component_id & acpi_dbg_layer)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 return;
172 }
173
174 /*
175 * Thread tracking and context switch notification
176 */
Len Brown4be44fc2005-08-05 00:44:28 -0400177 thread_id = acpi_os_get_thread_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 if (thread_id != acpi_gbl_prev_thread_id) {
179 if (ACPI_LV_THREADS & acpi_dbg_level) {
Len Brown4be44fc2005-08-05 00:44:28 -0400180 acpi_os_printf
Alexey Starikovskiyb0b7eaa2007-01-25 22:39:44 -0500181 ("\n**** Context Switch from TID %lX to TID %lX ****\n\n",
Len Brownfd350942007-05-09 23:34:35 -0400182 (unsigned long)acpi_gbl_prev_thread_id,
183 (unsigned long)thread_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 }
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 */
Len Brown4be44fc2005-08-05 00:44:28 -0400193 acpi_os_printf("%8s-%04ld ", module_name, line_number);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
195 if (ACPI_LV_THREADS & acpi_dbg_level) {
Alexey Starikovskiyb0b7eaa2007-01-25 22:39:44 -0500196 acpi_os_printf("[%04lX] ", (unsigned long)thread_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 }
198
Len Brown4be44fc2005-08-05 00:44:28 -0400199 acpi_os_printf("[%02ld] %-22.22s: ",
200 acpi_gbl_nesting_level,
201 acpi_ut_trim_function_name(function_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
Len Brown4be44fc2005-08-05 00:44:28 -0400203 va_start(args, format);
204 acpi_os_vprintf(format, args);
Bob Moore507f0462008-04-10 19:06:42 +0400205 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206}
Robert Moore44f6c012005-04-18 22:49:35 -0400207
Bob Moore83135242006-10-03 00:00:00 -0400208ACPI_EXPORT_SYMBOL(acpi_ut_debug_print)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
Robert Moore44f6c012005-04-18 22:49:35 -0400210/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 *
212 * FUNCTION: acpi_ut_debug_print_raw
213 *
214 * PARAMETERS: requested_debug_level - Requested debug print level
215 * line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400216 * function_name - Caller's procedure name
217 * module_name - Caller's module name
218 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 * Format - Printf format field
220 * ... - Optional printf arguments
221 *
222 * RETURN: None
223 *
224 * DESCRIPTION: Print message with no headers. Has same interface as
225 * debug_print so that the same macros can be used.
226 *
Robert Moore44f6c012005-04-18 22:49:35 -0400227 ******************************************************************************/
Len Brown4be44fc2005-08-05 00:44:28 -0400228void ACPI_INTERNAL_VAR_XFACE
229acpi_ut_debug_print_raw(u32 requested_debug_level,
230 u32 line_number,
231 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800232 const char *module_name,
233 u32 component_id, const char *format, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234{
Len Brown4be44fc2005-08-05 00:44:28 -0400235 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
237 if (!(requested_debug_level & acpi_dbg_level) ||
Len Brown4be44fc2005-08-05 00:44:28 -0400238 !(component_id & acpi_dbg_layer)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 return;
240 }
241
Len Brown4be44fc2005-08-05 00:44:28 -0400242 va_start(args, format);
243 acpi_os_vprintf(format, args);
Bob Moore507f0462008-04-10 19:06:42 +0400244 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
Bob Moore83135242006-10-03 00:00:00 -0400247ACPI_EXPORT_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 -0700264void
Len Brown4be44fc2005-08-05 00:44:28 -0400265acpi_ut_trace(u32 line_number,
Bob Moore4b8ed632008-06-10 13:55:53 +0800266 const char *function_name,
267 const 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
Bob Moore83135242006-10-03 00:00:00 -0400278ACPI_EXPORT_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 -0700296void
Len Brown4be44fc2005-08-05 00:44:28 -0400297acpi_ut_trace_ptr(u32 line_number,
298 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800299 const char *module_name, u32 component_id, void *pointer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300{
301 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400302 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303
Len Brown4be44fc2005-08-05 00:44:28 -0400304 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
305 line_number, function_name, module_name,
306 component_id, "%s %p\n", acpi_gbl_fn_entry_str,
307 pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308}
309
Robert Moore44f6c012005-04-18 22:49:35 -0400310/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 *
312 * FUNCTION: acpi_ut_trace_str
313 *
314 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400315 * function_name - Caller's procedure name
316 * module_name - Caller's module name
317 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 * String - Additional string to display
319 *
320 * RETURN: None
321 *
322 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
323 * set in debug_level
324 *
Robert Moore44f6c012005-04-18 22:49:35 -0400325 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326
327void
Len Brown4be44fc2005-08-05 00:44:28 -0400328acpi_ut_trace_str(u32 line_number,
329 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800330 const char *module_name, u32 component_id, char *string)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331{
332
333 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400334 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335
Len Brown4be44fc2005-08-05 00:44:28 -0400336 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
337 line_number, function_name, module_name,
338 component_id, "%s %s\n", acpi_gbl_fn_entry_str,
339 string);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340}
341
Robert Moore44f6c012005-04-18 22:49:35 -0400342/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 *
344 * FUNCTION: acpi_ut_trace_u32
345 *
346 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400347 * function_name - Caller's procedure name
348 * module_name - Caller's module name
349 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 * Integer - Integer to display
351 *
352 * RETURN: None
353 *
354 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
355 * set in debug_level
356 *
Robert Moore44f6c012005-04-18 22:49:35 -0400357 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358
359void
Len Brown4be44fc2005-08-05 00:44:28 -0400360acpi_ut_trace_u32(u32 line_number,
361 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800362 const char *module_name, u32 component_id, u32 integer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363{
364
365 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400366 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367
Len Brown4be44fc2005-08-05 00:44:28 -0400368 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
369 line_number, function_name, module_name,
370 component_id, "%s %08X\n", acpi_gbl_fn_entry_str,
371 integer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372}
373
Robert Moore44f6c012005-04-18 22:49:35 -0400374/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 *
376 * FUNCTION: acpi_ut_exit
377 *
378 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400379 * function_name - Caller's procedure name
380 * module_name - Caller's module name
381 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382 *
383 * RETURN: None
384 *
385 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
386 * set in debug_level
387 *
Robert Moore44f6c012005-04-18 22:49:35 -0400388 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389
390void
Len Brown4be44fc2005-08-05 00:44:28 -0400391acpi_ut_exit(u32 line_number,
Bob Moore4b8ed632008-06-10 13:55:53 +0800392 const char *function_name,
393 const 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
Bob Moore83135242006-10-03 00:00:00 -0400403ACPI_EXPORT_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 -0700421void
Len Brown4be44fc2005-08-05 00:44:28 -0400422acpi_ut_status_exit(u32 line_number,
423 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800424 const char *module_name,
425 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
Bob Moore83135242006-10-03 00:00:00 -0400445ACPI_EXPORT_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 -0700463void
Len Brown4be44fc2005-08-05 00:44:28 -0400464acpi_ut_value_exit(u32 line_number,
465 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800466 const char *module_name,
467 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
Bob Moore83135242006-10-03 00:00:00 -0400478ACPI_EXPORT_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 -0700496void
Len Brown4be44fc2005-08-05 00:44:28 -0400497acpi_ut_ptr_exit(u32 line_number,
498 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800499 const char *module_name, u32 component_id, u8 *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500{
501
Len Brown4be44fc2005-08-05 00:44:28 -0400502 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
503 line_number, function_name, module_name,
504 component_id, "%s %p\n", acpi_gbl_fn_exit_str, ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505
506 acpi_gbl_nesting_level--;
507}
508
509#endif
510
Robert Moore44f6c012005-04-18 22:49:35 -0400511/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 *
513 * FUNCTION: acpi_ut_dump_buffer
514 *
515 * PARAMETERS: Buffer - Buffer to dump
516 * Count - Amount to dump, in bytes
517 * Display - BYTE, WORD, DWORD, or QWORD display
518 * component_iD - Caller's component ID
519 *
520 * RETURN: None
521 *
522 * DESCRIPTION: Generic dump buffer in both hex and ascii.
523 *
Robert Moore44f6c012005-04-18 22:49:35 -0400524 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525
Bob Moore793c2382006-03-31 00:00:00 -0500526void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527{
Bob Moore67a119f2008-06-10 13:42:13 +0800528 u32 i = 0;
529 u32 j;
Len Brown4be44fc2005-08-05 00:44:28 -0400530 u32 temp32;
531 u8 buf_char;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532
Bob Moore5eb69182008-04-10 19:06:39 +0400533 if (!buffer) {
534 acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n");
535 return;
536 }
537
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 if ((count < 4) || (count & 0x01)) {
539 display = DB_BYTE_DISPLAY;
540 }
541
Robert Moore44f6c012005-04-18 22:49:35 -0400542 /* Nasty little dump buffer routine! */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 while (i < count) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400545
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 /* Print current offset */
547
Bob Moore67a119f2008-06-10 13:42:13 +0800548 acpi_os_printf("%6.4X: ", i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549
550 /* Print 16 hex chars */
551
552 for (j = 0; j < 16;) {
553 if (i + j >= count) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400554
Robert Moore44f6c012005-04-18 22:49:35 -0400555 /* Dump fill spaces */
556
Len Brown4be44fc2005-08-05 00:44:28 -0400557 acpi_os_printf("%*s", ((display * 2) + 1), " ");
Bob Moore67a119f2008-06-10 13:42:13 +0800558 j += display;
Robert Moore44f6c012005-04-18 22:49:35 -0400559 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 }
561
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 switch (display) {
Bob Moore793c2382006-03-31 00:00:00 -0500563 case DB_BYTE_DISPLAY:
Len Brown4be44fc2005-08-05 00:44:28 -0400564 default: /* Default is BYTE display */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565
Bob Moore67a119f2008-06-10 13:42:13 +0800566 acpi_os_printf("%02X ",
567 buffer[(acpi_size) i + j]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 break;
569
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 case DB_WORD_DISPLAY:
571
Bob Moore67a119f2008-06-10 13:42:13 +0800572 ACPI_MOVE_16_TO_32(&temp32,
573 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400574 acpi_os_printf("%04X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 break;
576
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 case DB_DWORD_DISPLAY:
578
Bob Moore67a119f2008-06-10 13:42:13 +0800579 ACPI_MOVE_32_TO_32(&temp32,
580 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400581 acpi_os_printf("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 break;
583
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 case DB_QWORD_DISPLAY:
585
Bob Moore67a119f2008-06-10 13:42:13 +0800586 ACPI_MOVE_32_TO_32(&temp32,
587 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400588 acpi_os_printf("%08X", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589
Bob Moore67a119f2008-06-10 13:42:13 +0800590 ACPI_MOVE_32_TO_32(&temp32,
591 &buffer[(acpi_size) i + j +
592 4]);
Len Brown4be44fc2005-08-05 00:44:28 -0400593 acpi_os_printf("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 break;
595 }
Robert Moore44f6c012005-04-18 22:49:35 -0400596
Bob Moore67a119f2008-06-10 13:42:13 +0800597 j += display;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 }
599
600 /*
Robert Moore0c9938c2005-07-29 15:15:00 -0700601 * Print the ASCII equivalent characters but watch out for the bad
602 * unprintable ones (printable chars are 0x20 through 0x7E)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 */
Len Brown4be44fc2005-08-05 00:44:28 -0400604 acpi_os_printf(" ");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 for (j = 0; j < 16; j++) {
606 if (i + j >= count) {
Len Brown4be44fc2005-08-05 00:44:28 -0400607 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 return;
609 }
610
Bob Moore67a119f2008-06-10 13:42:13 +0800611 buf_char = buffer[(acpi_size) i + j];
Len Brown4be44fc2005-08-05 00:44:28 -0400612 if (ACPI_IS_PRINT(buf_char)) {
613 acpi_os_printf("%c", buf_char);
614 } else {
615 acpi_os_printf(".");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 }
617 }
618
619 /* Done with that line. */
620
Len Brown4be44fc2005-08-05 00:44:28 -0400621 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 i += 16;
623 }
624
625 return;
626}
Bob Moore793c2382006-03-31 00:00:00 -0500627
628/*******************************************************************************
629 *
630 * FUNCTION: acpi_ut_dump_buffer
631 *
632 * PARAMETERS: Buffer - Buffer to dump
633 * Count - Amount to dump, in bytes
634 * Display - BYTE, WORD, DWORD, or QWORD display
635 * component_iD - Caller's component ID
636 *
637 * RETURN: None
638 *
639 * DESCRIPTION: Generic dump buffer in both hex and ascii.
640 *
641 ******************************************************************************/
642
643void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id)
644{
645
646 /* Only dump the buffer if tracing is enabled */
647
648 if (!((ACPI_LV_TABLES & acpi_dbg_level) &&
649 (component_id & acpi_dbg_layer))) {
650 return;
651 }
652
653 acpi_ut_dump_buffer2(buffer, count, display);
654}