blob: 5d95166245ae9dbae0cfba65553541c5a28a6601 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: utdebug - Debug print routines
4 *
5 *****************************************************************************/
6
7/*
Bob Moore77848132012-01-12 13:27:23 +08008 * Copyright (C) 2000 - 2012, 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
Paul Gortmaker214f2c92011-10-26 16:22:14 -040044#include <linux/export.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <acpi/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -050046#include "accommon.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
48#define _COMPONENT ACPI_UTILITIES
Len Brown4be44fc2005-08-05 00:44:28 -040049ACPI_MODULE_NAME("utdebug")
Lv Zheng6d33b6b2012-10-31 02:25:05 +000050
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#ifdef ACPI_DEBUG_OUTPUT
Lv Zheng6d33b6b2012-10-31 02:25:05 +000052static acpi_thread_id acpi_gbl_prev_thread_id = (acpi_thread_id) 0xFFFFFFFF;
Len Brown4be44fc2005-08-05 00:44:28 -040053static 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{
Bob Moore1d18c052008-04-10 19:06:40 +040074 acpi_size current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Bob Moore1d18c052008-04-10 19:06:40 +040076 acpi_gbl_entry_stack_pointer = &current_sp;
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
Bob Moore1d18c052008-04-10 19:06:40 +040095 if (&current_sp < acpi_gbl_lowest_stack_pointer) {
96 acpi_gbl_lowest_stack_pointer = &current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 }
98
99 if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) {
100 acpi_gbl_deepest_nesting = acpi_gbl_nesting_level;
101 }
102}
103
Robert Moore44f6c012005-04-18 22:49:35 -0400104/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 *
Robert Moore0c9938c2005-07-29 15:15:00 -0700106 * 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.
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000113 * This allows compiler macros such as __FUNCTION__ to be used
Robert Moore0c9938c2005-07-29 15:15:00 -0700114 * with no change to the debug output.
115 *
116 ******************************************************************************/
117
Len Brown4be44fc2005-08-05 00:44:28 -0400118static const char *acpi_ut_trim_function_name(const char *function_name)
Robert Moore0c9938c2005-07-29 15:15:00 -0700119{
120
121 /* All Function names are longer than 4 chars, check is safe */
122
Bob Moorea18ecf42005-08-15 03:42:00 -0800123 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400124
Robert Moore0c9938c2005-07-29 15:15:00 -0700125 /* This is the case where the original source has not been modified */
126
127 return (function_name + 4);
128 }
129
Bob Moorea18ecf42005-08-15 03:42:00 -0800130 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400131
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 *
Bob Moore50df4d82008-12-31 03:01:23 +0800142 * FUNCTION: acpi_debug_print
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 *
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
Bob Mooreba494be2012-07-12 09:40:10 +0800149 * format - Printf format field
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 * ... - 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
Bob Moore50df4d82008-12-31 03:01:23 +0800160acpi_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, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165{
Bob Moore83135242006-10-03 00:00:00 -0400166 acpi_thread_id thread_id;
Len Brown4be44fc2005-08-05 00:44:28 -0400167 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168
169 /*
170 * Stay silent if the debug level or component ID is disabled
171 */
172 if (!(requested_debug_level & acpi_dbg_level) ||
Len Brown4be44fc2005-08-05 00:44:28 -0400173 !(component_id & acpi_dbg_layer)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 return;
175 }
176
177 /*
178 * Thread tracking and context switch notification
179 */
Len Brown4be44fc2005-08-05 00:44:28 -0400180 thread_id = acpi_os_get_thread_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 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
Lin Ming28eb3fc2010-09-15 13:55:13 +0800184 ("\n**** Context Switch from TID %u to TID %u ****\n\n",
185 (u32)acpi_gbl_prev_thread_id, (u32)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) {
Lin Ming28eb3fc2010-09-15 13:55:13 +0800198 acpi_os_printf("[%u] ", (u32)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);
Bob Moore507f0462008-04-10 19:06:42 +0400207 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208}
Robert Moore44f6c012005-04-18 22:49:35 -0400209
Bob Moore50df4d82008-12-31 03:01:23 +0800210ACPI_EXPORT_SYMBOL(acpi_debug_print)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211
Robert Moore44f6c012005-04-18 22:49:35 -0400212/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 *
Bob Moore50df4d82008-12-31 03:01:23 +0800214 * FUNCTION: acpi_debug_print_raw
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 *
216 * PARAMETERS: requested_debug_level - Requested debug print level
217 * line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400218 * function_name - Caller's procedure name
219 * module_name - Caller's module name
220 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800221 * format - Printf format field
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 * ... - Optional printf arguments
223 *
224 * RETURN: None
225 *
Bob Moore73a30902012-10-31 02:26:55 +0000226 * DESCRIPTION: Print message with no headers. Has same interface as
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 * debug_print so that the same macros can be used.
228 *
Robert Moore44f6c012005-04-18 22:49:35 -0400229 ******************************************************************************/
Len Brown4be44fc2005-08-05 00:44:28 -0400230void ACPI_INTERNAL_VAR_XFACE
Bob Moore50df4d82008-12-31 03:01:23 +0800231acpi_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, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236{
Len Brown4be44fc2005-08-05 00:44:28 -0400237 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238
239 if (!(requested_debug_level & acpi_dbg_level) ||
Len Brown4be44fc2005-08-05 00:44:28 -0400240 !(component_id & acpi_dbg_layer)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 return;
242 }
243
Len Brown4be44fc2005-08-05 00:44:28 -0400244 va_start(args, format);
245 acpi_os_vprintf(format, args);
Bob Moore507f0462008-04-10 19:06:42 +0400246 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248
Bob Moore50df4d82008-12-31 03:01:23 +0800249ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250
Robert Moore44f6c012005-04-18 22:49:35 -0400251/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 *
253 * FUNCTION: acpi_ut_trace
254 *
255 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400256 * function_name - Caller's procedure name
257 * module_name - Caller's module name
258 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 *
260 * RETURN: None
261 *
Bob Moore73a30902012-10-31 02:26:55 +0000262 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 * set in debug_level
264 *
Robert Moore44f6c012005-04-18 22:49:35 -0400265 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266void
Len Brown4be44fc2005-08-05 00:44:28 -0400267acpi_ut_trace(u32 line_number,
Bob Moore4b8ed632008-06-10 13:55:53 +0800268 const char *function_name,
269 const char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270{
271
272 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400273 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274
Bob Moore50df4d82008-12-31 03:01:23 +0800275 acpi_debug_print(ACPI_LV_FUNCTIONS,
276 line_number, function_name, module_name, component_id,
277 "%s\n", acpi_gbl_fn_entry_str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
Bob Moore83135242006-10-03 00:00:00 -0400280ACPI_EXPORT_SYMBOL(acpi_ut_trace)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
Robert Moore44f6c012005-04-18 22:49:35 -0400282/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 *
284 * FUNCTION: acpi_ut_trace_ptr
285 *
286 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400287 * function_name - Caller's procedure name
288 * module_name - Caller's module name
289 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800290 * pointer - Pointer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 *
292 * RETURN: None
293 *
Bob Moore73a30902012-10-31 02:26:55 +0000294 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 * set in debug_level
296 *
Robert Moore44f6c012005-04-18 22:49:35 -0400297 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298void
Len Brown4be44fc2005-08-05 00:44:28 -0400299acpi_ut_trace_ptr(u32 line_number,
300 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800301 const char *module_name, u32 component_id, void *pointer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302{
Bob Moore68aafc32012-10-31 02:26:01 +0000303
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400305 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
Bob Moore50df4d82008-12-31 03:01:23 +0800307 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);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310}
311
Robert Moore44f6c012005-04-18 22:49:35 -0400312/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 *
314 * FUNCTION: acpi_ut_trace_str
315 *
316 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400317 * function_name - Caller's procedure name
318 * module_name - Caller's module name
319 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800320 * string - Additional string to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 *
322 * RETURN: None
323 *
Bob Moore73a30902012-10-31 02:26:55 +0000324 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 * set in debug_level
326 *
Robert Moore44f6c012005-04-18 22:49:35 -0400327 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
329void
Len Brown4be44fc2005-08-05 00:44:28 -0400330acpi_ut_trace_str(u32 line_number,
331 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800332 const char *module_name, u32 component_id, char *string)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333{
334
335 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400336 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337
Bob Moore50df4d82008-12-31 03:01:23 +0800338 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);
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
Bob Mooreba494be2012-07-12 09:40:10 +0800351 * integer - Integer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 *
353 * RETURN: None
354 *
Bob Moore73a30902012-10-31 02:26:55 +0000355 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 * 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,
Bob Moore4b8ed632008-06-10 13:55:53 +0800363 const 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
Bob Moore50df4d82008-12-31 03:01:23 +0800369 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);
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 *
Bob Moore73a30902012-10-31 02:26:55 +0000385 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 * 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
Bob Moore50df4d82008-12-31 03:01:23 +0800396 acpi_debug_print(ACPI_LV_FUNCTIONS,
397 line_number, function_name, module_name, component_id,
398 "%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
Bob Mooreba494be2012-07-12 09:40:10 +0800413 * status - Exit status code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 *
415 * RETURN: None
416 *
Bob Moore73a30902012-10-31 02:26:55 +0000417 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 * 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)) {
Bob Moore50df4d82008-12-31 03:01:23 +0800429 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));
Len Brown4be44fc2005-08-05 00:44:28 -0400433 } else {
Bob Moore50df4d82008-12-31 03:01:23 +0800434 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));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 }
440
441 acpi_gbl_nesting_level--;
442}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443
Bob Moore83135242006-10-03 00:00:00 -0400444ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445
Robert Moore44f6c012005-04-18 22:49:35 -0400446/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 *
448 * FUNCTION: acpi_ut_value_exit
449 *
450 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400451 * function_name - Caller's procedure name
452 * module_name - Caller's module name
453 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800454 * value - Value to be printed with exit msg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 *
456 * RETURN: None
457 *
Bob Moore73a30902012-10-31 02:26:55 +0000458 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 * set in debug_level. Prints exit value also.
460 *
Robert Moore44f6c012005-04-18 22:49:35 -0400461 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462void
Len Brown4be44fc2005-08-05 00:44:28 -0400463acpi_ut_value_exit(u32 line_number,
464 const char *function_name,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800465 const char *module_name, u32 component_id, u64 value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466{
467
Bob Moore50df4d82008-12-31 03:01:23 +0800468 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));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472
473 acpi_gbl_nesting_level--;
474}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475
Bob Moore83135242006-10-03 00:00:00 -0400476ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477
Robert Moore44f6c012005-04-18 22:49:35 -0400478/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 *
480 * FUNCTION: acpi_ut_ptr_exit
481 *
482 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400483 * function_name - Caller's procedure name
484 * module_name - Caller's module name
485 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800486 * ptr - Pointer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 *
488 * RETURN: None
489 *
Bob Moore73a30902012-10-31 02:26:55 +0000490 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 * set in debug_level. Prints exit value also.
492 *
Robert Moore44f6c012005-04-18 22:49:35 -0400493 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494void
Len Brown4be44fc2005-08-05 00:44:28 -0400495acpi_ut_ptr_exit(u32 line_number,
496 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800497 const char *module_name, u32 component_id, u8 *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498{
499
Bob Moore50df4d82008-12-31 03:01:23 +0800500 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);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503
504 acpi_gbl_nesting_level--;
505}
506
507#endif
508
Robert Moore44f6c012005-04-18 22:49:35 -0400509/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 *
511 * FUNCTION: acpi_ut_dump_buffer
512 *
Bob Mooreba494be2012-07-12 09:40:10 +0800513 * PARAMETERS: buffer - Buffer to dump
514 * count - Amount to dump, in bytes
515 * display - BYTE, WORD, DWORD, or QWORD display
Bob Moore97171c62012-10-31 02:28:11 +0000516 * offset - Beginning buffer offset (display only)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 *
518 * RETURN: None
519 *
520 * DESCRIPTION: Generic dump buffer in both hex and ascii.
521 *
Robert Moore44f6c012005-04-18 22:49:35 -0400522 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523
Bob Moore97171c62012-10-31 02:28:11 +0000524void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525{
Bob Moore67a119f2008-06-10 13:42:13 +0800526 u32 i = 0;
527 u32 j;
Len Brown4be44fc2005-08-05 00:44:28 -0400528 u32 temp32;
529 u8 buf_char;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530
Bob Moore5eb69182008-04-10 19:06:39 +0400531 if (!buffer) {
532 acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n");
533 return;
534 }
535
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 if ((count < 4) || (count & 0x01)) {
537 display = DB_BYTE_DISPLAY;
538 }
539
Robert Moore44f6c012005-04-18 22:49:35 -0400540 /* Nasty little dump buffer routine! */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 while (i < count) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400543
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 /* Print current offset */
545
Bob Moore97171c62012-10-31 02:28:11 +0000546 acpi_os_printf("%6.4X: ", (base_offset + i));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547
548 /* Print 16 hex chars */
549
550 for (j = 0; j < 16;) {
551 if (i + j >= count) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400552
Robert Moore44f6c012005-04-18 22:49:35 -0400553 /* Dump fill spaces */
554
Len Brown4be44fc2005-08-05 00:44:28 -0400555 acpi_os_printf("%*s", ((display * 2) + 1), " ");
Bob Moore67a119f2008-06-10 13:42:13 +0800556 j += display;
Robert Moore44f6c012005-04-18 22:49:35 -0400557 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 }
559
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 switch (display) {
Bob Moore793c2382006-03-31 00:00:00 -0500561 case DB_BYTE_DISPLAY:
Len Brown4be44fc2005-08-05 00:44:28 -0400562 default: /* Default is BYTE display */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563
Bob Moore67a119f2008-06-10 13:42:13 +0800564 acpi_os_printf("%02X ",
565 buffer[(acpi_size) i + j]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 break;
567
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 case DB_WORD_DISPLAY:
569
Bob Moore67a119f2008-06-10 13:42:13 +0800570 ACPI_MOVE_16_TO_32(&temp32,
571 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400572 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
Bob Moore67a119f2008-06-10 13:42:13 +0800577 ACPI_MOVE_32_TO_32(&temp32,
578 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400579 acpi_os_printf("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 break;
581
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 case DB_QWORD_DISPLAY:
583
Bob Moore67a119f2008-06-10 13:42:13 +0800584 ACPI_MOVE_32_TO_32(&temp32,
585 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400586 acpi_os_printf("%08X", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587
Bob Moore67a119f2008-06-10 13:42:13 +0800588 ACPI_MOVE_32_TO_32(&temp32,
589 &buffer[(acpi_size) i + j +
590 4]);
Len Brown4be44fc2005-08-05 00:44:28 -0400591 acpi_os_printf("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 break;
593 }
Robert Moore44f6c012005-04-18 22:49:35 -0400594
Bob Moore67a119f2008-06-10 13:42:13 +0800595 j += display;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 }
597
598 /*
Robert Moore0c9938c2005-07-29 15:15:00 -0700599 * Print the ASCII equivalent characters but watch out for the bad
600 * unprintable ones (printable chars are 0x20 through 0x7E)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 */
Len Brown4be44fc2005-08-05 00:44:28 -0400602 acpi_os_printf(" ");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 for (j = 0; j < 16; j++) {
604 if (i + j >= count) {
Len Brown4be44fc2005-08-05 00:44:28 -0400605 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 return;
607 }
608
Bob Moore67a119f2008-06-10 13:42:13 +0800609 buf_char = buffer[(acpi_size) i + j];
Len Brown4be44fc2005-08-05 00:44:28 -0400610 if (ACPI_IS_PRINT(buf_char)) {
611 acpi_os_printf("%c", buf_char);
612 } else {
613 acpi_os_printf(".");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 }
615 }
616
617 /* Done with that line. */
618
Len Brown4be44fc2005-08-05 00:44:28 -0400619 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 i += 16;
621 }
622
623 return;
624}
Bob Moore793c2382006-03-31 00:00:00 -0500625
626/*******************************************************************************
627 *
Bob Moore97171c62012-10-31 02:28:11 +0000628 * FUNCTION: acpi_ut_debug_dump_buffer
Bob Moore793c2382006-03-31 00:00:00 -0500629 *
Bob Mooreba494be2012-07-12 09:40:10 +0800630 * 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
Bob Moore793c2382006-03-31 00:00:00 -0500634 *
635 * RETURN: None
636 *
637 * DESCRIPTION: Generic dump buffer in both hex and ascii.
638 *
639 ******************************************************************************/
640
Bob Moore97171c62012-10-31 02:28:11 +0000641void
642acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id)
Bob Moore793c2382006-03-31 00:00:00 -0500643{
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
Bob Moore97171c62012-10-31 02:28:11 +0000652 acpi_ut_dump_buffer(buffer, count, display, 0);
Bob Moore793c2382006-03-31 00:00:00 -0500653}