blob: cff7154b7feeae988406e4aed2c3518178009563 [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 Moore7735ca02017-02-08 11:00:08 +08008 * Copyright (C) 2000 - 2017, 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"
Lv Zhengbab04822015-07-23 12:53:07 +080048#include "acinterp.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50#define _COMPONENT ACPI_UTILITIES
Len Brown4be44fc2005-08-05 00:44:28 -040051ACPI_MODULE_NAME("utdebug")
Lv Zheng6d33b6b2012-10-31 02:25:05 +000052
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#ifdef ACPI_DEBUG_OUTPUT
Bob Moore0dfaaa32016-03-24 09:40:40 +080054static acpi_thread_id acpi_gbl_previous_thread_id = (acpi_thread_id) 0xFFFFFFFF;
55static const char *acpi_gbl_function_entry_prefix = "----Entry";
56static const char *acpi_gbl_function_exit_prefix = "----Exit-";
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Robert Moore44f6c012005-04-18 22:49:35 -040058/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 *
60 * FUNCTION: acpi_ut_init_stack_ptr_trace
61 *
62 * PARAMETERS: None
63 *
64 * RETURN: None
65 *
Robert Moore44f6c012005-04-18 22:49:35 -040066 * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 *
Robert Moore44f6c012005-04-18 22:49:35 -040068 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Len Brown4be44fc2005-08-05 00:44:28 -040070void acpi_ut_init_stack_ptr_trace(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071{
Bob Moore1d18c052008-04-10 19:06:40 +040072 acpi_size current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
Bob Moore1d18c052008-04-10 19:06:40 +040074 acpi_gbl_entry_stack_pointer = &current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075}
76
Robert Moore44f6c012005-04-18 22:49:35 -040077/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 *
79 * FUNCTION: acpi_ut_track_stack_ptr
80 *
81 * PARAMETERS: None
82 *
83 * RETURN: None
84 *
Robert Moore44f6c012005-04-18 22:49:35 -040085 * DESCRIPTION: Save the current CPU stack pointer
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 *
Robert Moore44f6c012005-04-18 22:49:35 -040087 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
Len Brown4be44fc2005-08-05 00:44:28 -040089void acpi_ut_track_stack_ptr(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070090{
Len Brown4be44fc2005-08-05 00:44:28 -040091 acpi_size current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
Bob Moore1d18c052008-04-10 19:06:40 +040093 if (&current_sp < acpi_gbl_lowest_stack_pointer) {
94 acpi_gbl_lowest_stack_pointer = &current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 }
96
97 if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) {
98 acpi_gbl_deepest_nesting = acpi_gbl_nesting_level;
99 }
100}
101
Robert Moore44f6c012005-04-18 22:49:35 -0400102/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 *
Robert Moore0c9938c2005-07-29 15:15:00 -0700104 * FUNCTION: acpi_ut_trim_function_name
105 *
106 * PARAMETERS: function_name - Ascii string containing a procedure name
107 *
108 * RETURN: Updated pointer to the function name
109 *
110 * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
Lv Zheng7011bf42015-06-19 11:38:22 +0800111 * This allows compiler macros such as __func__ to be used
112 * with no change to the debug output.
Robert Moore0c9938c2005-07-29 15:15:00 -0700113 *
114 ******************************************************************************/
115
Len Brown4be44fc2005-08-05 00:44:28 -0400116static const char *acpi_ut_trim_function_name(const char *function_name)
Robert Moore0c9938c2005-07-29 15:15:00 -0700117{
118
119 /* All Function names are longer than 4 chars, check is safe */
120
Bob Moorea18ecf42005-08-15 03:42:00 -0800121 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400122
Robert Moore0c9938c2005-07-29 15:15:00 -0700123 /* This is the case where the original source has not been modified */
124
125 return (function_name + 4);
126 }
127
Bob Moorea18ecf42005-08-15 03:42:00 -0800128 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400129
Robert Moore0c9938c2005-07-29 15:15:00 -0700130 /* This is the case where the source has been 'linuxized' */
131
132 return (function_name + 5);
133 }
134
135 return (function_name);
136}
137
Robert Moore0c9938c2005-07-29 15:15:00 -0700138/*******************************************************************************
139 *
Bob Moore50df4d82008-12-31 03:01:23 +0800140 * FUNCTION: acpi_debug_print
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 *
Robert Moore44f6c012005-04-18 22:49:35 -0400142 * PARAMETERS: requested_debug_level - Requested debug print level
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 * line_number - Caller's line number (for error output)
Robert Mooref9f46012005-07-08 00:00:00 -0400144 * function_name - Caller's procedure name
145 * module_name - Caller's module name
146 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800147 * format - Printf format field
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 * ... - Optional printf arguments
149 *
150 * RETURN: None
151 *
152 * DESCRIPTION: Print error message with prefix consisting of the module name,
153 * line number, and component ID.
154 *
Robert Moore44f6c012005-04-18 22:49:35 -0400155 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156
Len Brown4be44fc2005-08-05 00:44:28 -0400157void ACPI_INTERNAL_VAR_XFACE
Bob Moore50df4d82008-12-31 03:01:23 +0800158acpi_debug_print(u32 requested_debug_level,
159 u32 line_number,
160 const char *function_name,
161 const char *module_name,
162 u32 component_id, const char *format, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163{
Bob Moore83135242006-10-03 00:00:00 -0400164 acpi_thread_id thread_id;
Len Brown4be44fc2005-08-05 00:44:28 -0400165 va_list args;
Bob Moore2cb0ba72018-01-03 15:06:24 -0800166#ifdef ACPI_APPLICATION
Bob Moore6be2d722018-01-03 15:06:21 -0800167 int fill_count;
Bob Moore2cb0ba72018-01-03 15:06:24 -0800168#endif
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();
Bob Moore0dfaaa32016-03-24 09:40:40 +0800180 if (thread_id != acpi_gbl_previous_thread_id) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 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",
Bob Moore0dfaaa32016-03-24 09:40:40 +0800184 (u32)acpi_gbl_previous_thread_id, (u32)thread_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 }
186
Bob Moore0dfaaa32016-03-24 09:40:40 +0800187 acpi_gbl_previous_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 Moore6be2d722018-01-03 15:06:21 -0800208 fill_count = 48 - acpi_gbl_nesting_level -
209 strlen(acpi_ut_trim_function_name(function_name));
210 if (fill_count < 0) {
211 fill_count = 0;
212 }
Bob Moorebf9b4482013-11-21 12:17:20 +0800213
Bob Moore6be2d722018-01-03 15:06:21 -0800214 acpi_os_printf("[%02ld] %*s",
Erik Schmauss6e875fa042018-01-03 15:06:23 -0800215 acpi_gbl_nesting_level, acpi_gbl_nesting_level + 1, " ");
Bob Moore6be2d722018-01-03 15:06:21 -0800216 acpi_os_printf("%s%*s: ",
217 acpi_ut_trim_function_name(function_name), fill_count,
218 " ");
219
220#else
Bob Moorebf9b4482013-11-21 12:17:20 +0800221 acpi_os_printf("%-22.22s: ", acpi_ut_trim_function_name(function_name));
Bob Moore6be2d722018-01-03 15:06:21 -0800222#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
Len Brown4be44fc2005-08-05 00:44:28 -0400224 va_start(args, format);
225 acpi_os_vprintf(format, args);
Bob Moore507f0462008-04-10 19:06:42 +0400226 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227}
Robert Moore44f6c012005-04-18 22:49:35 -0400228
Bob Moore50df4d82008-12-31 03:01:23 +0800229ACPI_EXPORT_SYMBOL(acpi_debug_print)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230
Robert Moore44f6c012005-04-18 22:49:35 -0400231/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 *
Bob Moore50df4d82008-12-31 03:01:23 +0800233 * FUNCTION: acpi_debug_print_raw
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 *
235 * PARAMETERS: requested_debug_level - Requested debug print level
236 * line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400237 * function_name - Caller's procedure name
238 * module_name - Caller's module name
239 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800240 * format - Printf format field
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 * ... - Optional printf arguments
242 *
243 * RETURN: None
244 *
Bob Moore73a30902012-10-31 02:26:55 +0000245 * DESCRIPTION: Print message with no headers. Has same interface as
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 * debug_print so that the same macros can be used.
247 *
Robert Moore44f6c012005-04-18 22:49:35 -0400248 ******************************************************************************/
Len Brown4be44fc2005-08-05 00:44:28 -0400249void ACPI_INTERNAL_VAR_XFACE
Bob Moore50df4d82008-12-31 03:01:23 +0800250acpi_debug_print_raw(u32 requested_debug_level,
251 u32 line_number,
252 const char *function_name,
253 const char *module_name,
254 u32 component_id, const char *format, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255{
Len Brown4be44fc2005-08-05 00:44:28 -0400256 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257
Bob Mooredb38bf52012-12-31 00:06:10 +0000258 /* Check if debug output enabled */
259
260 if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 return;
262 }
263
Len Brown4be44fc2005-08-05 00:44:28 -0400264 va_start(args, format);
265 acpi_os_vprintf(format, args);
Bob Moore507f0462008-04-10 19:06:42 +0400266 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268
Bob Moore50df4d82008-12-31 03:01:23 +0800269ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
Robert Moore44f6c012005-04-18 22:49:35 -0400271/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 *
273 * FUNCTION: acpi_ut_trace
274 *
275 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400276 * function_name - Caller's procedure name
277 * module_name - Caller's module name
278 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 *
280 * RETURN: None
281 *
Bob Moore73a30902012-10-31 02:26:55 +0000282 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 * set in debug_level
284 *
Robert Moore44f6c012005-04-18 22:49:35 -0400285 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286void
Len Brown4be44fc2005-08-05 00:44:28 -0400287acpi_ut_trace(u32 line_number,
Bob Moore4b8ed632008-06-10 13:55:53 +0800288 const char *function_name,
289 const char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290{
291
292 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400293 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294
Bob Mooredb38bf52012-12-31 00:06:10 +0000295 /* Check if enabled up-front for performance */
296
297 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
298 acpi_debug_print(ACPI_LV_FUNCTIONS,
299 line_number, function_name, module_name,
Bob Moore0dfaaa32016-03-24 09:40:40 +0800300 component_id, "%s\n",
301 acpi_gbl_function_entry_prefix);
Bob Mooredb38bf52012-12-31 00:06:10 +0000302 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304
Bob Moore83135242006-10-03 00:00:00 -0400305ACPI_EXPORT_SYMBOL(acpi_ut_trace)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
Robert Moore44f6c012005-04-18 22:49:35 -0400307/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 *
309 * FUNCTION: acpi_ut_trace_ptr
310 *
311 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400312 * function_name - Caller's procedure name
313 * module_name - Caller's module name
314 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800315 * pointer - Pointer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 *
317 * RETURN: None
318 *
Bob Moore73a30902012-10-31 02:26:55 +0000319 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 * set in debug_level
321 *
Robert Moore44f6c012005-04-18 22:49:35 -0400322 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323void
Len Brown4be44fc2005-08-05 00:44:28 -0400324acpi_ut_trace_ptr(u32 line_number,
325 const char *function_name,
Bob Moore0dfaaa32016-03-24 09:40:40 +0800326 const char *module_name,
327 u32 component_id, const void *pointer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328{
Bob Moore68aafc32012-10-31 02:26:01 +0000329
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400331 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332
Bob Mooredb38bf52012-12-31 00:06:10 +0000333 /* Check if enabled up-front for performance */
334
335 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
336 acpi_debug_print(ACPI_LV_FUNCTIONS,
337 line_number, function_name, module_name,
Bob Moore0dfaaa32016-03-24 09:40:40 +0800338 component_id, "%s %p\n",
339 acpi_gbl_function_entry_prefix, pointer);
Bob Mooredb38bf52012-12-31 00:06:10 +0000340 }
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_str
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 * string - Additional string 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_str(u32 line_number,
362 const char *function_name,
Bob Moore0dfaaa32016-03-24 09:40:40 +0800363 const char *module_name, u32 component_id, const char *string)
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 Mooredb38bf52012-12-31 00:06:10 +0000369 /* Check if enabled up-front for performance */
370
371 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
372 acpi_debug_print(ACPI_LV_FUNCTIONS,
373 line_number, function_name, module_name,
Bob Moore0dfaaa32016-03-24 09:40:40 +0800374 component_id, "%s %s\n",
375 acpi_gbl_function_entry_prefix, string);
Bob Mooredb38bf52012-12-31 00:06:10 +0000376 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377}
378
Robert Moore44f6c012005-04-18 22:49:35 -0400379/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 *
381 * FUNCTION: acpi_ut_trace_u32
382 *
383 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400384 * function_name - Caller's procedure name
385 * module_name - Caller's module name
386 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800387 * integer - Integer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 *
389 * RETURN: None
390 *
Bob Moore73a30902012-10-31 02:26:55 +0000391 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 * set in debug_level
393 *
Robert Moore44f6c012005-04-18 22:49:35 -0400394 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395
396void
Len Brown4be44fc2005-08-05 00:44:28 -0400397acpi_ut_trace_u32(u32 line_number,
398 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800399 const char *module_name, u32 component_id, u32 integer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400{
401
402 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400403 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404
Bob Mooredb38bf52012-12-31 00:06:10 +0000405 /* Check if enabled up-front for performance */
406
407 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
408 acpi_debug_print(ACPI_LV_FUNCTIONS,
409 line_number, function_name, module_name,
410 component_id, "%s %08X\n",
Bob Moore0dfaaa32016-03-24 09:40:40 +0800411 acpi_gbl_function_entry_prefix, integer);
Bob Mooredb38bf52012-12-31 00:06:10 +0000412 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413}
414
Robert Moore44f6c012005-04-18 22:49:35 -0400415/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 *
417 * FUNCTION: acpi_ut_exit
418 *
419 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400420 * function_name - Caller's procedure name
421 * module_name - Caller's module name
422 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 *
424 * RETURN: None
425 *
Bob Moore73a30902012-10-31 02:26:55 +0000426 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 * set in debug_level
428 *
Robert Moore44f6c012005-04-18 22:49:35 -0400429 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430
431void
Len Brown4be44fc2005-08-05 00:44:28 -0400432acpi_ut_exit(u32 line_number,
Bob Moore4b8ed632008-06-10 13:55:53 +0800433 const char *function_name,
434 const char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435{
436
Bob Mooredb38bf52012-12-31 00:06:10 +0000437 /* Check if enabled up-front for performance */
438
439 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
440 acpi_debug_print(ACPI_LV_FUNCTIONS,
441 line_number, function_name, module_name,
Bob Moore0dfaaa32016-03-24 09:40:40 +0800442 component_id, "%s\n",
443 acpi_gbl_function_exit_prefix);
Bob Mooredb38bf52012-12-31 00:06:10 +0000444 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445
Bob Moorebf9b4482013-11-21 12:17:20 +0800446 if (acpi_gbl_nesting_level) {
447 acpi_gbl_nesting_level--;
448 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450
Bob Moore83135242006-10-03 00:00:00 -0400451ACPI_EXPORT_SYMBOL(acpi_ut_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452
Robert Moore44f6c012005-04-18 22:49:35 -0400453/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 *
455 * FUNCTION: acpi_ut_status_exit
456 *
457 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400458 * function_name - Caller's procedure name
459 * module_name - Caller's module name
460 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800461 * status - Exit status code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 *
463 * RETURN: None
464 *
Bob Moore73a30902012-10-31 02:26:55 +0000465 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 * set in debug_level. Prints exit status also.
467 *
Robert Moore44f6c012005-04-18 22:49:35 -0400468 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469void
Len Brown4be44fc2005-08-05 00:44:28 -0400470acpi_ut_status_exit(u32 line_number,
471 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800472 const char *module_name,
473 u32 component_id, acpi_status status)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474{
475
Bob Mooredb38bf52012-12-31 00:06:10 +0000476 /* Check if enabled up-front for performance */
477
478 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
479 if (ACPI_SUCCESS(status)) {
480 acpi_debug_print(ACPI_LV_FUNCTIONS,
481 line_number, function_name,
482 module_name, component_id, "%s %s\n",
Bob Moore0dfaaa32016-03-24 09:40:40 +0800483 acpi_gbl_function_exit_prefix,
Bob Mooredb38bf52012-12-31 00:06:10 +0000484 acpi_format_exception(status));
485 } else {
486 acpi_debug_print(ACPI_LV_FUNCTIONS,
487 line_number, function_name,
488 module_name, component_id,
489 "%s ****Exception****: %s\n",
Bob Moore0dfaaa32016-03-24 09:40:40 +0800490 acpi_gbl_function_exit_prefix,
Bob Mooredb38bf52012-12-31 00:06:10 +0000491 acpi_format_exception(status));
492 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 }
494
Bob Moorebf9b4482013-11-21 12:17:20 +0800495 if (acpi_gbl_nesting_level) {
496 acpi_gbl_nesting_level--;
497 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499
Bob Moore83135242006-10-03 00:00:00 -0400500ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501
Robert Moore44f6c012005-04-18 22:49:35 -0400502/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 *
504 * FUNCTION: acpi_ut_value_exit
505 *
506 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400507 * function_name - Caller's procedure name
508 * module_name - Caller's module name
509 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800510 * value - Value to be printed with exit msg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 *
512 * RETURN: None
513 *
Bob Moore73a30902012-10-31 02:26:55 +0000514 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 * set in debug_level. Prints exit value also.
516 *
Robert Moore44f6c012005-04-18 22:49:35 -0400517 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518void
Len Brown4be44fc2005-08-05 00:44:28 -0400519acpi_ut_value_exit(u32 line_number,
520 const char *function_name,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800521 const char *module_name, u32 component_id, u64 value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522{
523
Bob Mooredb38bf52012-12-31 00:06:10 +0000524 /* Check if enabled up-front for performance */
525
526 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
527 acpi_debug_print(ACPI_LV_FUNCTIONS,
528 line_number, function_name, module_name,
529 component_id, "%s %8.8X%8.8X\n",
Bob Moore0dfaaa32016-03-24 09:40:40 +0800530 acpi_gbl_function_exit_prefix,
Bob Mooredb38bf52012-12-31 00:06:10 +0000531 ACPI_FORMAT_UINT64(value));
532 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533
Bob Moorebf9b4482013-11-21 12:17:20 +0800534 if (acpi_gbl_nesting_level) {
535 acpi_gbl_nesting_level--;
536 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538
Bob Moore83135242006-10-03 00:00:00 -0400539ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540
Robert Moore44f6c012005-04-18 22:49:35 -0400541/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 *
543 * FUNCTION: acpi_ut_ptr_exit
544 *
545 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400546 * function_name - Caller's procedure name
547 * module_name - Caller's module name
548 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800549 * ptr - Pointer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 *
551 * RETURN: None
552 *
Bob Moore73a30902012-10-31 02:26:55 +0000553 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 * set in debug_level. Prints exit value also.
555 *
Robert Moore44f6c012005-04-18 22:49:35 -0400556 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557void
Len Brown4be44fc2005-08-05 00:44:28 -0400558acpi_ut_ptr_exit(u32 line_number,
559 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800560 const char *module_name, u32 component_id, u8 *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561{
562
Bob Mooredb38bf52012-12-31 00:06:10 +0000563 /* Check if enabled up-front for performance */
564
565 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
566 acpi_debug_print(ACPI_LV_FUNCTIONS,
567 line_number, function_name, module_name,
Bob Moore0dfaaa32016-03-24 09:40:40 +0800568 component_id, "%s %p\n",
569 acpi_gbl_function_exit_prefix, ptr);
Bob Mooredb38bf52012-12-31 00:06:10 +0000570 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571
Bob Moorebf9b4482013-11-21 12:17:20 +0800572 if (acpi_gbl_nesting_level) {
573 acpi_gbl_nesting_level--;
574 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575}
576
Lv Zhengbab04822015-07-23 12:53:07 +0800577/*******************************************************************************
578 *
Jung-uk Kim4857a942016-08-04 16:42:19 +0800579 * FUNCTION: acpi_ut_str_exit
580 *
581 * PARAMETERS: line_number - Caller's line number
582 * function_name - Caller's procedure name
583 * module_name - Caller's module name
584 * component_id - Caller's component ID
585 * string - String to display
586 *
587 * RETURN: None
588 *
589 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
590 * set in debug_level. Prints exit value also.
591 *
592 ******************************************************************************/
593
594void
595acpi_ut_str_exit(u32 line_number,
596 const char *function_name,
597 const char *module_name, u32 component_id, const char *string)
598{
599
600 /* Check if enabled up-front for performance */
601
602 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
603 acpi_debug_print(ACPI_LV_FUNCTIONS,
604 line_number, function_name, module_name,
605 component_id, "%s %s\n",
606 acpi_gbl_function_exit_prefix, string);
607 }
608
609 if (acpi_gbl_nesting_level) {
610 acpi_gbl_nesting_level--;
611 }
612}
613
614/*******************************************************************************
615 *
Lv Zhengbab04822015-07-23 12:53:07 +0800616 * FUNCTION: acpi_trace_point
617 *
618 * PARAMETERS: type - Trace event type
619 * begin - TRUE if before execution
620 * aml - Executed AML address
621 * pathname - Object path
622 * pointer - Pointer to the related object
623 *
624 * RETURN: None
625 *
626 * DESCRIPTION: Interpreter execution trace.
627 *
628 ******************************************************************************/
Lv Zheng2e70da42014-07-08 10:07:06 +0800629
Lv Zhengbab04822015-07-23 12:53:07 +0800630void
631acpi_trace_point(acpi_trace_event_type type, u8 begin, u8 *aml, char *pathname)
632{
633
634 ACPI_FUNCTION_ENTRY();
635
636 acpi_ex_trace_point(type, begin, aml, pathname);
637
638#ifdef ACPI_USE_SYSTEM_TRACER
639 acpi_os_trace_point(type, begin, aml, pathname);
640#endif
641}
642
643ACPI_EXPORT_SYMBOL(acpi_trace_point)
Bob Moore9cf7ade2017-04-28 08:53:22 +0800644
Lv Zhengbab04822015-07-23 12:53:07 +0800645#endif