blob: 47857c41906c02a31b94c468fd4011609fdcd645 [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
Bob Mooredb38bf52012-12-31 00:06:10 +0000169 /* Check if debug output enabled */
170
171 if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 return;
173 }
174
175 /*
176 * Thread tracking and context switch notification
177 */
Len Brown4be44fc2005-08-05 00:44:28 -0400178 thread_id = acpi_os_get_thread_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 if (thread_id != acpi_gbl_prev_thread_id) {
180 if (ACPI_LV_THREADS & acpi_dbg_level) {
Len Brown4be44fc2005-08-05 00:44:28 -0400181 acpi_os_printf
Lin Ming28eb3fc2010-09-15 13:55:13 +0800182 ("\n**** Context Switch from TID %u to TID %u ****\n\n",
183 (u32)acpi_gbl_prev_thread_id, (u32)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) {
Lin Ming28eb3fc2010-09-15 13:55:13 +0800196 acpi_os_printf("[%u] ", (u32)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 Moore50df4d82008-12-31 03:01:23 +0800208ACPI_EXPORT_SYMBOL(acpi_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 *
Bob Moore50df4d82008-12-31 03:01:23 +0800212 * FUNCTION: acpi_debug_print_raw
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 *
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
Bob Mooreba494be2012-07-12 09:40:10 +0800219 * format - Printf format field
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 * ... - Optional printf arguments
221 *
222 * RETURN: None
223 *
Bob Moore73a30902012-10-31 02:26:55 +0000224 * DESCRIPTION: Print message with no headers. Has same interface as
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 * 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
Bob Moore50df4d82008-12-31 03:01:23 +0800229acpi_debug_print_raw(u32 requested_debug_level,
230 u32 line_number,
231 const char *function_name,
232 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
Bob Mooredb38bf52012-12-31 00:06:10 +0000237 /* Check if debug output enabled */
238
239 if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
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);
Bob Moore507f0462008-04-10 19:06:42 +0400245 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247
Bob Moore50df4d82008-12-31 03:01:23 +0800248ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
Robert Moore44f6c012005-04-18 22:49:35 -0400250/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 *
252 * FUNCTION: acpi_ut_trace
253 *
254 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400255 * function_name - Caller's procedure name
256 * module_name - Caller's module name
257 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 *
259 * RETURN: None
260 *
Bob Moore73a30902012-10-31 02:26:55 +0000261 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 * set in debug_level
263 *
Robert Moore44f6c012005-04-18 22:49:35 -0400264 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265void
Len Brown4be44fc2005-08-05 00:44:28 -0400266acpi_ut_trace(u32 line_number,
Bob Moore4b8ed632008-06-10 13:55:53 +0800267 const char *function_name,
268 const char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269{
270
271 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400272 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
Bob Mooredb38bf52012-12-31 00:06:10 +0000274 /* Check if enabled up-front for performance */
275
276 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
277 acpi_debug_print(ACPI_LV_FUNCTIONS,
278 line_number, function_name, module_name,
279 component_id, "%s\n", acpi_gbl_fn_entry_str);
280 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
Bob Moore83135242006-10-03 00:00:00 -0400283ACPI_EXPORT_SYMBOL(acpi_ut_trace)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
Robert Moore44f6c012005-04-18 22:49:35 -0400285/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 *
287 * FUNCTION: acpi_ut_trace_ptr
288 *
289 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400290 * function_name - Caller's procedure name
291 * module_name - Caller's module name
292 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800293 * pointer - Pointer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 *
295 * RETURN: None
296 *
Bob Moore73a30902012-10-31 02:26:55 +0000297 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 * set in debug_level
299 *
Robert Moore44f6c012005-04-18 22:49:35 -0400300 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301void
Len Brown4be44fc2005-08-05 00:44:28 -0400302acpi_ut_trace_ptr(u32 line_number,
303 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800304 const char *module_name, u32 component_id, void *pointer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305{
Bob Moore68aafc32012-10-31 02:26:01 +0000306
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400308 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
Bob Mooredb38bf52012-12-31 00:06:10 +0000310 /* Check if enabled up-front for performance */
311
312 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
313 acpi_debug_print(ACPI_LV_FUNCTIONS,
314 line_number, function_name, module_name,
315 component_id, "%s %p\n", acpi_gbl_fn_entry_str,
316 pointer);
317 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318}
319
Robert Moore44f6c012005-04-18 22:49:35 -0400320/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 *
322 * FUNCTION: acpi_ut_trace_str
323 *
324 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400325 * function_name - Caller's procedure name
326 * module_name - Caller's module name
327 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800328 * string - Additional string to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 *
330 * RETURN: None
331 *
Bob Moore73a30902012-10-31 02:26:55 +0000332 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 * set in debug_level
334 *
Robert Moore44f6c012005-04-18 22:49:35 -0400335 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336
337void
Len Brown4be44fc2005-08-05 00:44:28 -0400338acpi_ut_trace_str(u32 line_number,
339 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800340 const char *module_name, u32 component_id, char *string)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341{
342
343 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400344 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345
Bob Mooredb38bf52012-12-31 00:06:10 +0000346 /* Check if enabled up-front for performance */
347
348 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
349 acpi_debug_print(ACPI_LV_FUNCTIONS,
350 line_number, function_name, module_name,
351 component_id, "%s %s\n", acpi_gbl_fn_entry_str,
352 string);
353 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354}
355
Robert Moore44f6c012005-04-18 22:49:35 -0400356/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 *
358 * FUNCTION: acpi_ut_trace_u32
359 *
360 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400361 * function_name - Caller's procedure name
362 * module_name - Caller's module name
363 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800364 * integer - Integer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 *
366 * RETURN: None
367 *
Bob Moore73a30902012-10-31 02:26:55 +0000368 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 * set in debug_level
370 *
Robert Moore44f6c012005-04-18 22:49:35 -0400371 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372
373void
Len Brown4be44fc2005-08-05 00:44:28 -0400374acpi_ut_trace_u32(u32 line_number,
375 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800376 const char *module_name, u32 component_id, u32 integer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377{
378
379 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400380 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381
Bob Mooredb38bf52012-12-31 00:06:10 +0000382 /* Check if enabled up-front for performance */
383
384 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
385 acpi_debug_print(ACPI_LV_FUNCTIONS,
386 line_number, function_name, module_name,
387 component_id, "%s %08X\n",
388 acpi_gbl_fn_entry_str, integer);
389 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390}
391
Robert Moore44f6c012005-04-18 22:49:35 -0400392/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 *
394 * FUNCTION: acpi_ut_exit
395 *
396 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400397 * function_name - Caller's procedure name
398 * module_name - Caller's module name
399 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 *
401 * RETURN: None
402 *
Bob Moore73a30902012-10-31 02:26:55 +0000403 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 * set in debug_level
405 *
Robert Moore44f6c012005-04-18 22:49:35 -0400406 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407
408void
Len Brown4be44fc2005-08-05 00:44:28 -0400409acpi_ut_exit(u32 line_number,
Bob Moore4b8ed632008-06-10 13:55:53 +0800410 const char *function_name,
411 const char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412{
413
Bob Mooredb38bf52012-12-31 00:06:10 +0000414 /* Check if enabled up-front for performance */
415
416 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
417 acpi_debug_print(ACPI_LV_FUNCTIONS,
418 line_number, function_name, module_name,
419 component_id, "%s\n", acpi_gbl_fn_exit_str);
420 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421
422 acpi_gbl_nesting_level--;
423}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424
Bob Moore83135242006-10-03 00:00:00 -0400425ACPI_EXPORT_SYMBOL(acpi_ut_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426
Robert Moore44f6c012005-04-18 22:49:35 -0400427/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 *
429 * FUNCTION: acpi_ut_status_exit
430 *
431 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400432 * function_name - Caller's procedure name
433 * module_name - Caller's module name
434 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800435 * status - Exit status code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 *
437 * RETURN: None
438 *
Bob Moore73a30902012-10-31 02:26:55 +0000439 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 * set in debug_level. Prints exit status also.
441 *
Robert Moore44f6c012005-04-18 22:49:35 -0400442 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443void
Len Brown4be44fc2005-08-05 00:44:28 -0400444acpi_ut_status_exit(u32 line_number,
445 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800446 const char *module_name,
447 u32 component_id, acpi_status status)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448{
449
Bob Mooredb38bf52012-12-31 00:06:10 +0000450 /* Check if enabled up-front for performance */
451
452 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
453 if (ACPI_SUCCESS(status)) {
454 acpi_debug_print(ACPI_LV_FUNCTIONS,
455 line_number, function_name,
456 module_name, component_id, "%s %s\n",
457 acpi_gbl_fn_exit_str,
458 acpi_format_exception(status));
459 } else {
460 acpi_debug_print(ACPI_LV_FUNCTIONS,
461 line_number, function_name,
462 module_name, component_id,
463 "%s ****Exception****: %s\n",
464 acpi_gbl_fn_exit_str,
465 acpi_format_exception(status));
466 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 }
468
469 acpi_gbl_nesting_level--;
470}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471
Bob Moore83135242006-10-03 00:00:00 -0400472ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473
Robert Moore44f6c012005-04-18 22:49:35 -0400474/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 *
476 * FUNCTION: acpi_ut_value_exit
477 *
478 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400479 * function_name - Caller's procedure name
480 * module_name - Caller's module name
481 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800482 * value - Value to be printed with exit msg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 *
484 * RETURN: None
485 *
Bob Moore73a30902012-10-31 02:26:55 +0000486 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 * set in debug_level. Prints exit value also.
488 *
Robert Moore44f6c012005-04-18 22:49:35 -0400489 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490void
Len Brown4be44fc2005-08-05 00:44:28 -0400491acpi_ut_value_exit(u32 line_number,
492 const char *function_name,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800493 const char *module_name, u32 component_id, u64 value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494{
495
Bob Mooredb38bf52012-12-31 00:06:10 +0000496 /* Check if enabled up-front for performance */
497
498 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
499 acpi_debug_print(ACPI_LV_FUNCTIONS,
500 line_number, function_name, module_name,
501 component_id, "%s %8.8X%8.8X\n",
502 acpi_gbl_fn_exit_str,
503 ACPI_FORMAT_UINT64(value));
504 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505
506 acpi_gbl_nesting_level--;
507}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508
Bob Moore83135242006-10-03 00:00:00 -0400509ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510
Robert Moore44f6c012005-04-18 22:49:35 -0400511/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 *
513 * FUNCTION: acpi_ut_ptr_exit
514 *
515 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400516 * function_name - Caller's procedure name
517 * module_name - Caller's module name
518 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800519 * ptr - Pointer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 *
521 * RETURN: None
522 *
Bob Moore73a30902012-10-31 02:26:55 +0000523 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 * set in debug_level. Prints exit value also.
525 *
Robert Moore44f6c012005-04-18 22:49:35 -0400526 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527void
Len Brown4be44fc2005-08-05 00:44:28 -0400528acpi_ut_ptr_exit(u32 line_number,
529 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800530 const char *module_name, u32 component_id, u8 *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531{
532
Bob Mooredb38bf52012-12-31 00:06:10 +0000533 /* Check if enabled up-front for performance */
534
535 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
536 acpi_debug_print(ACPI_LV_FUNCTIONS,
537 line_number, function_name, module_name,
538 component_id, "%s %p\n", acpi_gbl_fn_exit_str,
539 ptr);
540 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541
542 acpi_gbl_nesting_level--;
543}
544
545#endif
546
Robert Moore44f6c012005-04-18 22:49:35 -0400547/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 *
549 * FUNCTION: acpi_ut_dump_buffer
550 *
Bob Mooreba494be2012-07-12 09:40:10 +0800551 * PARAMETERS: buffer - Buffer to dump
552 * count - Amount to dump, in bytes
553 * display - BYTE, WORD, DWORD, or QWORD display
Bob Moore97171c62012-10-31 02:28:11 +0000554 * offset - Beginning buffer offset (display only)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 *
556 * RETURN: None
557 *
558 * DESCRIPTION: Generic dump buffer in both hex and ascii.
559 *
Robert Moore44f6c012005-04-18 22:49:35 -0400560 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561
Bob Moore97171c62012-10-31 02:28:11 +0000562void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563{
Bob Moore67a119f2008-06-10 13:42:13 +0800564 u32 i = 0;
565 u32 j;
Len Brown4be44fc2005-08-05 00:44:28 -0400566 u32 temp32;
567 u8 buf_char;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568
Bob Moore5eb69182008-04-10 19:06:39 +0400569 if (!buffer) {
570 acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n");
571 return;
572 }
573
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 if ((count < 4) || (count & 0x01)) {
575 display = DB_BYTE_DISPLAY;
576 }
577
Robert Moore44f6c012005-04-18 22:49:35 -0400578 /* Nasty little dump buffer routine! */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 while (i < count) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400581
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 /* Print current offset */
583
Bob Moore97171c62012-10-31 02:28:11 +0000584 acpi_os_printf("%6.4X: ", (base_offset + i));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585
586 /* Print 16 hex chars */
587
588 for (j = 0; j < 16;) {
589 if (i + j >= count) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400590
Robert Moore44f6c012005-04-18 22:49:35 -0400591 /* Dump fill spaces */
592
Len Brown4be44fc2005-08-05 00:44:28 -0400593 acpi_os_printf("%*s", ((display * 2) + 1), " ");
Bob Moore67a119f2008-06-10 13:42:13 +0800594 j += display;
Robert Moore44f6c012005-04-18 22:49:35 -0400595 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 }
597
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 switch (display) {
Bob Moore793c2382006-03-31 00:00:00 -0500599 case DB_BYTE_DISPLAY:
Len Brown4be44fc2005-08-05 00:44:28 -0400600 default: /* Default is BYTE display */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601
Bob Moore67a119f2008-06-10 13:42:13 +0800602 acpi_os_printf("%02X ",
603 buffer[(acpi_size) i + j]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 break;
605
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 case DB_WORD_DISPLAY:
607
Bob Moore67a119f2008-06-10 13:42:13 +0800608 ACPI_MOVE_16_TO_32(&temp32,
609 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400610 acpi_os_printf("%04X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 break;
612
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 case DB_DWORD_DISPLAY:
614
Bob Moore67a119f2008-06-10 13:42:13 +0800615 ACPI_MOVE_32_TO_32(&temp32,
616 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400617 acpi_os_printf("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 break;
619
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 case DB_QWORD_DISPLAY:
621
Bob Moore67a119f2008-06-10 13:42:13 +0800622 ACPI_MOVE_32_TO_32(&temp32,
623 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400624 acpi_os_printf("%08X", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625
Bob Moore67a119f2008-06-10 13:42:13 +0800626 ACPI_MOVE_32_TO_32(&temp32,
627 &buffer[(acpi_size) i + j +
628 4]);
Len Brown4be44fc2005-08-05 00:44:28 -0400629 acpi_os_printf("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 break;
631 }
Robert Moore44f6c012005-04-18 22:49:35 -0400632
Bob Moore67a119f2008-06-10 13:42:13 +0800633 j += display;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 }
635
636 /*
Robert Moore0c9938c2005-07-29 15:15:00 -0700637 * Print the ASCII equivalent characters but watch out for the bad
638 * unprintable ones (printable chars are 0x20 through 0x7E)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 */
Len Brown4be44fc2005-08-05 00:44:28 -0400640 acpi_os_printf(" ");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 for (j = 0; j < 16; j++) {
642 if (i + j >= count) {
Len Brown4be44fc2005-08-05 00:44:28 -0400643 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 return;
645 }
646
Bob Moore67a119f2008-06-10 13:42:13 +0800647 buf_char = buffer[(acpi_size) i + j];
Len Brown4be44fc2005-08-05 00:44:28 -0400648 if (ACPI_IS_PRINT(buf_char)) {
649 acpi_os_printf("%c", buf_char);
650 } else {
651 acpi_os_printf(".");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 }
653 }
654
655 /* Done with that line. */
656
Len Brown4be44fc2005-08-05 00:44:28 -0400657 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 i += 16;
659 }
660
661 return;
662}
Bob Moore793c2382006-03-31 00:00:00 -0500663
664/*******************************************************************************
665 *
Bob Moore97171c62012-10-31 02:28:11 +0000666 * FUNCTION: acpi_ut_debug_dump_buffer
Bob Moore793c2382006-03-31 00:00:00 -0500667 *
Bob Mooreba494be2012-07-12 09:40:10 +0800668 * PARAMETERS: buffer - Buffer to dump
669 * count - Amount to dump, in bytes
670 * display - BYTE, WORD, DWORD, or QWORD display
671 * component_ID - Caller's component ID
Bob Moore793c2382006-03-31 00:00:00 -0500672 *
673 * RETURN: None
674 *
675 * DESCRIPTION: Generic dump buffer in both hex and ascii.
676 *
677 ******************************************************************************/
678
Bob Moore97171c62012-10-31 02:28:11 +0000679void
680acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id)
Bob Moore793c2382006-03-31 00:00:00 -0500681{
682
683 /* Only dump the buffer if tracing is enabled */
684
685 if (!((ACPI_LV_TABLES & acpi_dbg_level) &&
686 (component_id & acpi_dbg_layer))) {
687 return;
688 }
689
Bob Moore97171c62012-10-31 02:28:11 +0000690 acpi_ut_dump_buffer(buffer, count, display, 0);
Bob Moore793c2382006-03-31 00:00:00 -0500691}