blob: 21a20ac5b1e1aec4f8654b03caab01ba26466c8a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
Bob Moore88ec2862013-06-08 00:57:47 +00003 * Module Name: utdebug - Debug print/trace routines
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
5 *****************************************************************************/
6
7/*
Bob Moorefbb7a2d2014-02-08 09:42:25 +08008 * Copyright (C) 2000 - 2014, 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
Lv Zheng839e9282013-10-29 09:29:51 +080044#define EXPORT_ACPI_INTERFACES
45
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include <acpi/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -050047#include "accommon.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49#define _COMPONENT ACPI_UTILITIES
Len Brown4be44fc2005-08-05 00:44:28 -040050ACPI_MODULE_NAME("utdebug")
Lv Zheng6d33b6b2012-10-31 02:25:05 +000051
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#ifdef ACPI_DEBUG_OUTPUT
Lv Zheng6d33b6b2012-10-31 02:25:05 +000053static acpi_thread_id acpi_gbl_prev_thread_id = (acpi_thread_id) 0xFFFFFFFF;
Len Brown4be44fc2005-08-05 00:44:28 -040054static char *acpi_gbl_fn_entry_str = "----Entry";
55static char *acpi_gbl_fn_exit_str = "----Exit-";
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Robert Moore0c9938c2005-07-29 15:15:00 -070057/* Local prototypes */
58
Len Brown4be44fc2005-08-05 00:44:28 -040059static const char *acpi_ut_trim_function_name(const char *function_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Robert Moore44f6c012005-04-18 22:49:35 -040061/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 *
63 * FUNCTION: acpi_ut_init_stack_ptr_trace
64 *
65 * PARAMETERS: None
66 *
67 * RETURN: None
68 *
Robert Moore44f6c012005-04-18 22:49:35 -040069 * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 *
Robert Moore44f6c012005-04-18 22:49:35 -040071 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Len Brown4be44fc2005-08-05 00:44:28 -040073void acpi_ut_init_stack_ptr_trace(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070074{
Bob Moore1d18c052008-04-10 19:06:40 +040075 acpi_size current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Bob Moore1d18c052008-04-10 19:06:40 +040077 acpi_gbl_entry_stack_pointer = &current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078}
79
Robert Moore44f6c012005-04-18 22:49:35 -040080/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 *
82 * FUNCTION: acpi_ut_track_stack_ptr
83 *
84 * PARAMETERS: None
85 *
86 * RETURN: None
87 *
Robert Moore44f6c012005-04-18 22:49:35 -040088 * DESCRIPTION: Save the current CPU stack pointer
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 *
Robert Moore44f6c012005-04-18 22:49:35 -040090 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
Len Brown4be44fc2005-08-05 00:44:28 -040092void acpi_ut_track_stack_ptr(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070093{
Len Brown4be44fc2005-08-05 00:44:28 -040094 acpi_size current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
Bob Moore1d18c052008-04-10 19:06:40 +040096 if (&current_sp < acpi_gbl_lowest_stack_pointer) {
97 acpi_gbl_lowest_stack_pointer = &current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 }
99
100 if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) {
101 acpi_gbl_deepest_nesting = acpi_gbl_nesting_level;
102 }
103}
104
Robert Moore44f6c012005-04-18 22:49:35 -0400105/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 *
Robert Moore0c9938c2005-07-29 15:15:00 -0700107 * FUNCTION: acpi_ut_trim_function_name
108 *
109 * PARAMETERS: function_name - Ascii string containing a procedure name
110 *
111 * RETURN: Updated pointer to the function name
112 *
113 * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000114 * This allows compiler macros such as __FUNCTION__ to be used
Robert Moore0c9938c2005-07-29 15:15:00 -0700115 * with no change to the debug output.
116 *
117 ******************************************************************************/
118
Len Brown4be44fc2005-08-05 00:44:28 -0400119static const char *acpi_ut_trim_function_name(const char *function_name)
Robert Moore0c9938c2005-07-29 15:15:00 -0700120{
121
122 /* All Function names are longer than 4 chars, check is safe */
123
Bob Moorea18ecf42005-08-15 03:42:00 -0800124 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400125
Robert Moore0c9938c2005-07-29 15:15:00 -0700126 /* This is the case where the original source has not been modified */
127
128 return (function_name + 4);
129 }
130
Bob Moorea18ecf42005-08-15 03:42:00 -0800131 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400132
Robert Moore0c9938c2005-07-29 15:15:00 -0700133 /* This is the case where the source has been 'linuxized' */
134
135 return (function_name + 5);
136 }
137
138 return (function_name);
139}
140
Robert Moore0c9938c2005-07-29 15:15:00 -0700141/*******************************************************************************
142 *
Bob Moore50df4d82008-12-31 03:01:23 +0800143 * FUNCTION: acpi_debug_print
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 *
Robert Moore44f6c012005-04-18 22:49:35 -0400145 * PARAMETERS: requested_debug_level - Requested debug print level
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 * line_number - Caller's line number (for error output)
Robert Mooref9f46012005-07-08 00:00:00 -0400147 * function_name - Caller's procedure name
148 * module_name - Caller's module name
149 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800150 * format - Printf format field
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 * ... - Optional printf arguments
152 *
153 * RETURN: None
154 *
155 * DESCRIPTION: Print error message with prefix consisting of the module name,
156 * line number, and component ID.
157 *
Robert Moore44f6c012005-04-18 22:49:35 -0400158 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
Len Brown4be44fc2005-08-05 00:44:28 -0400160void ACPI_INTERNAL_VAR_XFACE
Bob Moore50df4d82008-12-31 03:01:23 +0800161acpi_debug_print(u32 requested_debug_level,
162 u32 line_number,
163 const char *function_name,
164 const char *module_name,
165 u32 component_id, const char *format, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166{
Bob Moore83135242006-10-03 00:00:00 -0400167 acpi_thread_id thread_id;
Len Brown4be44fc2005-08-05 00:44:28 -0400168 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
Bob Mooredb38bf52012-12-31 00:06:10 +0000170 /* Check if debug output enabled */
171
172 if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 return;
174 }
175
176 /*
177 * Thread tracking and context switch notification
178 */
Len Brown4be44fc2005-08-05 00:44:28 -0400179 thread_id = acpi_os_get_thread_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 if (thread_id != acpi_gbl_prev_thread_id) {
181 if (ACPI_LV_THREADS & acpi_dbg_level) {
Len Brown4be44fc2005-08-05 00:44:28 -0400182 acpi_os_printf
Lin Ming28eb3fc2010-09-15 13:55:13 +0800183 ("\n**** Context Switch from TID %u to TID %u ****\n\n",
184 (u32)acpi_gbl_prev_thread_id, (u32)thread_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 }
186
187 acpi_gbl_prev_thread_id = thread_id;
Bob Moorebf9b4482013-11-21 12:17:20 +0800188 acpi_gbl_nesting_level = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 }
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 */
Bob Moore28568462013-09-23 09:51:39 +0800195 acpi_os_printf("%9s-%04ld ", module_name, line_number);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
Bob Moore5076f002014-01-08 13:43:12 +0800197#ifdef ACPI_APPLICATION
Bob Moorebf9b4482013-11-21 12:17:20 +0800198 /*
Bob Moore5076f002014-01-08 13:43:12 +0800199 * For acpi_exec/iASL only, emit the thread ID and nesting level.
Bob Moorebf9b4482013-11-21 12:17:20 +0800200 * Note: nesting level is really only useful during a single-thread
201 * execution. Otherwise, multiple threads will keep resetting the
202 * level.
203 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 if (ACPI_LV_THREADS & acpi_dbg_level) {
Lin Ming28eb3fc2010-09-15 13:55:13 +0800205 acpi_os_printf("[%u] ", (u32)thread_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 }
207
Bob Moorebf9b4482013-11-21 12:17:20 +0800208 acpi_os_printf("[%02ld] ", acpi_gbl_nesting_level);
209#endif
210
211 acpi_os_printf("%-22.22s: ", acpi_ut_trim_function_name(function_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212
Len Brown4be44fc2005-08-05 00:44:28 -0400213 va_start(args, format);
214 acpi_os_vprintf(format, args);
Bob Moore507f0462008-04-10 19:06:42 +0400215 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216}
Robert Moore44f6c012005-04-18 22:49:35 -0400217
Bob Moore50df4d82008-12-31 03:01:23 +0800218ACPI_EXPORT_SYMBOL(acpi_debug_print)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
Robert Moore44f6c012005-04-18 22:49:35 -0400220/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 *
Bob Moore50df4d82008-12-31 03:01:23 +0800222 * FUNCTION: acpi_debug_print_raw
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 *
224 * PARAMETERS: requested_debug_level - Requested debug print level
225 * line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400226 * function_name - Caller's procedure name
227 * module_name - Caller's module name
228 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800229 * format - Printf format field
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 * ... - Optional printf arguments
231 *
232 * RETURN: None
233 *
Bob Moore73a30902012-10-31 02:26:55 +0000234 * DESCRIPTION: Print message with no headers. Has same interface as
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 * debug_print so that the same macros can be used.
236 *
Robert Moore44f6c012005-04-18 22:49:35 -0400237 ******************************************************************************/
Len Brown4be44fc2005-08-05 00:44:28 -0400238void ACPI_INTERNAL_VAR_XFACE
Bob Moore50df4d82008-12-31 03:01:23 +0800239acpi_debug_print_raw(u32 requested_debug_level,
240 u32 line_number,
241 const char *function_name,
242 const char *module_name,
243 u32 component_id, const char *format, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244{
Len Brown4be44fc2005-08-05 00:44:28 -0400245 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
Bob Mooredb38bf52012-12-31 00:06:10 +0000247 /* Check if debug output enabled */
248
249 if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 return;
251 }
252
Len Brown4be44fc2005-08-05 00:44:28 -0400253 va_start(args, format);
254 acpi_os_vprintf(format, args);
Bob Moore507f0462008-04-10 19:06:42 +0400255 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257
Bob Moore50df4d82008-12-31 03:01:23 +0800258ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
Robert Moore44f6c012005-04-18 22:49:35 -0400260/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 *
262 * FUNCTION: acpi_ut_trace
263 *
264 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400265 * function_name - Caller's procedure name
266 * module_name - Caller's module name
267 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 *
269 * RETURN: None
270 *
Bob Moore73a30902012-10-31 02:26:55 +0000271 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 * set in debug_level
273 *
Robert Moore44f6c012005-04-18 22:49:35 -0400274 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275void
Len Brown4be44fc2005-08-05 00:44:28 -0400276acpi_ut_trace(u32 line_number,
Bob Moore4b8ed632008-06-10 13:55:53 +0800277 const char *function_name,
278 const char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279{
280
281 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400282 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
Bob Mooredb38bf52012-12-31 00:06:10 +0000284 /* Check if enabled up-front for performance */
285
286 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
287 acpi_debug_print(ACPI_LV_FUNCTIONS,
288 line_number, function_name, module_name,
289 component_id, "%s\n", acpi_gbl_fn_entry_str);
290 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
Bob Moore83135242006-10-03 00:00:00 -0400293ACPI_EXPORT_SYMBOL(acpi_ut_trace)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294
Robert Moore44f6c012005-04-18 22:49:35 -0400295/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 *
297 * FUNCTION: acpi_ut_trace_ptr
298 *
299 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400300 * function_name - Caller's procedure name
301 * module_name - Caller's module name
302 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800303 * pointer - Pointer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 *
305 * RETURN: None
306 *
Bob Moore73a30902012-10-31 02:26:55 +0000307 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 * set in debug_level
309 *
Robert Moore44f6c012005-04-18 22:49:35 -0400310 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311void
Len Brown4be44fc2005-08-05 00:44:28 -0400312acpi_ut_trace_ptr(u32 line_number,
313 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800314 const char *module_name, u32 component_id, void *pointer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315{
Bob Moore68aafc32012-10-31 02:26:01 +0000316
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400318 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319
Bob Mooredb38bf52012-12-31 00:06:10 +0000320 /* Check if enabled up-front for performance */
321
322 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
323 acpi_debug_print(ACPI_LV_FUNCTIONS,
324 line_number, function_name, module_name,
325 component_id, "%s %p\n", acpi_gbl_fn_entry_str,
326 pointer);
327 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328}
329
Robert Moore44f6c012005-04-18 22:49:35 -0400330/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 *
332 * FUNCTION: acpi_ut_trace_str
333 *
334 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400335 * function_name - Caller's procedure name
336 * module_name - Caller's module name
337 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800338 * string - Additional string to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 *
340 * RETURN: None
341 *
Bob Moore73a30902012-10-31 02:26:55 +0000342 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 * set in debug_level
344 *
Robert Moore44f6c012005-04-18 22:49:35 -0400345 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346
347void
Len Brown4be44fc2005-08-05 00:44:28 -0400348acpi_ut_trace_str(u32 line_number,
349 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800350 const char *module_name, u32 component_id, char *string)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351{
352
353 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400354 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355
Bob Mooredb38bf52012-12-31 00:06:10 +0000356 /* Check if enabled up-front for performance */
357
358 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
359 acpi_debug_print(ACPI_LV_FUNCTIONS,
360 line_number, function_name, module_name,
361 component_id, "%s %s\n", acpi_gbl_fn_entry_str,
362 string);
363 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364}
365
Robert Moore44f6c012005-04-18 22:49:35 -0400366/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 *
368 * FUNCTION: acpi_ut_trace_u32
369 *
370 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400371 * function_name - Caller's procedure name
372 * module_name - Caller's module name
373 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800374 * integer - Integer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 *
376 * RETURN: None
377 *
Bob Moore73a30902012-10-31 02:26:55 +0000378 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 * set in debug_level
380 *
Robert Moore44f6c012005-04-18 22:49:35 -0400381 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382
383void
Len Brown4be44fc2005-08-05 00:44:28 -0400384acpi_ut_trace_u32(u32 line_number,
385 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800386 const char *module_name, u32 component_id, u32 integer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387{
388
389 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400390 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391
Bob Mooredb38bf52012-12-31 00:06:10 +0000392 /* Check if enabled up-front for performance */
393
394 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
395 acpi_debug_print(ACPI_LV_FUNCTIONS,
396 line_number, function_name, module_name,
397 component_id, "%s %08X\n",
398 acpi_gbl_fn_entry_str, integer);
399 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400}
401
Robert Moore44f6c012005-04-18 22:49:35 -0400402/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 *
404 * FUNCTION: acpi_ut_exit
405 *
406 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400407 * function_name - Caller's procedure name
408 * module_name - Caller's module name
409 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 *
411 * RETURN: None
412 *
Bob Moore73a30902012-10-31 02:26:55 +0000413 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 * set in debug_level
415 *
Robert Moore44f6c012005-04-18 22:49:35 -0400416 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417
418void
Len Brown4be44fc2005-08-05 00:44:28 -0400419acpi_ut_exit(u32 line_number,
Bob Moore4b8ed632008-06-10 13:55:53 +0800420 const char *function_name,
421 const char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422{
423
Bob Mooredb38bf52012-12-31 00:06:10 +0000424 /* Check if enabled up-front for performance */
425
426 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
427 acpi_debug_print(ACPI_LV_FUNCTIONS,
428 line_number, function_name, module_name,
429 component_id, "%s\n", acpi_gbl_fn_exit_str);
430 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
Bob Moorebf9b4482013-11-21 12:17:20 +0800432 if (acpi_gbl_nesting_level) {
433 acpi_gbl_nesting_level--;
434 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436
Bob Moore83135242006-10-03 00:00:00 -0400437ACPI_EXPORT_SYMBOL(acpi_ut_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438
Robert Moore44f6c012005-04-18 22:49:35 -0400439/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 *
441 * FUNCTION: acpi_ut_status_exit
442 *
443 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400444 * function_name - Caller's procedure name
445 * module_name - Caller's module name
446 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800447 * status - Exit status code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 *
449 * RETURN: None
450 *
Bob Moore73a30902012-10-31 02:26:55 +0000451 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 * set in debug_level. Prints exit status also.
453 *
Robert Moore44f6c012005-04-18 22:49:35 -0400454 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455void
Len Brown4be44fc2005-08-05 00:44:28 -0400456acpi_ut_status_exit(u32 line_number,
457 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800458 const char *module_name,
459 u32 component_id, acpi_status status)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460{
461
Bob Mooredb38bf52012-12-31 00:06:10 +0000462 /* Check if enabled up-front for performance */
463
464 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
465 if (ACPI_SUCCESS(status)) {
466 acpi_debug_print(ACPI_LV_FUNCTIONS,
467 line_number, function_name,
468 module_name, component_id, "%s %s\n",
469 acpi_gbl_fn_exit_str,
470 acpi_format_exception(status));
471 } else {
472 acpi_debug_print(ACPI_LV_FUNCTIONS,
473 line_number, function_name,
474 module_name, component_id,
475 "%s ****Exception****: %s\n",
476 acpi_gbl_fn_exit_str,
477 acpi_format_exception(status));
478 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 }
480
Bob Moorebf9b4482013-11-21 12:17:20 +0800481 if (acpi_gbl_nesting_level) {
482 acpi_gbl_nesting_level--;
483 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485
Bob Moore83135242006-10-03 00:00:00 -0400486ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487
Robert Moore44f6c012005-04-18 22:49:35 -0400488/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 *
490 * FUNCTION: acpi_ut_value_exit
491 *
492 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400493 * function_name - Caller's procedure name
494 * module_name - Caller's module name
495 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800496 * value - Value to be printed with exit msg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 *
498 * RETURN: None
499 *
Bob Moore73a30902012-10-31 02:26:55 +0000500 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 * set in debug_level. Prints exit value also.
502 *
Robert Moore44f6c012005-04-18 22:49:35 -0400503 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504void
Len Brown4be44fc2005-08-05 00:44:28 -0400505acpi_ut_value_exit(u32 line_number,
506 const char *function_name,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800507 const char *module_name, u32 component_id, u64 value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508{
509
Bob Mooredb38bf52012-12-31 00:06:10 +0000510 /* Check if enabled up-front for performance */
511
512 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
513 acpi_debug_print(ACPI_LV_FUNCTIONS,
514 line_number, function_name, module_name,
515 component_id, "%s %8.8X%8.8X\n",
516 acpi_gbl_fn_exit_str,
517 ACPI_FORMAT_UINT64(value));
518 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519
Bob Moorebf9b4482013-11-21 12:17:20 +0800520 if (acpi_gbl_nesting_level) {
521 acpi_gbl_nesting_level--;
522 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524
Bob Moore83135242006-10-03 00:00:00 -0400525ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526
Robert Moore44f6c012005-04-18 22:49:35 -0400527/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 *
529 * FUNCTION: acpi_ut_ptr_exit
530 *
531 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400532 * function_name - Caller's procedure name
533 * module_name - Caller's module name
534 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800535 * ptr - Pointer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 *
537 * RETURN: None
538 *
Bob Moore73a30902012-10-31 02:26:55 +0000539 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 * set in debug_level. Prints exit value also.
541 *
Robert Moore44f6c012005-04-18 22:49:35 -0400542 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543void
Len Brown4be44fc2005-08-05 00:44:28 -0400544acpi_ut_ptr_exit(u32 line_number,
545 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800546 const char *module_name, u32 component_id, u8 *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547{
548
Bob Mooredb38bf52012-12-31 00:06:10 +0000549 /* Check if enabled up-front for performance */
550
551 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
552 acpi_debug_print(ACPI_LV_FUNCTIONS,
553 line_number, function_name, module_name,
554 component_id, "%s %p\n", acpi_gbl_fn_exit_str,
555 ptr);
556 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557
Bob Moorebf9b4482013-11-21 12:17:20 +0800558 if (acpi_gbl_nesting_level) {
559 acpi_gbl_nesting_level--;
560 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561}
562
563#endif