blob: 615a885e2ca3c6fc276d5eae53793242adbf56b8 [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;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166
Bob Mooredb38bf52012-12-31 00:06:10 +0000167 /* Check if debug output enabled */
168
169 if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 return;
171 }
172
173 /*
174 * Thread tracking and context switch notification
175 */
Len Brown4be44fc2005-08-05 00:44:28 -0400176 thread_id = acpi_os_get_thread_id();
Bob Moore0dfaaa32016-03-24 09:40:40 +0800177 if (thread_id != acpi_gbl_previous_thread_id) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 if (ACPI_LV_THREADS & acpi_dbg_level) {
Len Brown4be44fc2005-08-05 00:44:28 -0400179 acpi_os_printf
Lin Ming28eb3fc2010-09-15 13:55:13 +0800180 ("\n**** Context Switch from TID %u to TID %u ****\n\n",
Bob Moore0dfaaa32016-03-24 09:40:40 +0800181 (u32)acpi_gbl_previous_thread_id, (u32)thread_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 }
183
Bob Moore0dfaaa32016-03-24 09:40:40 +0800184 acpi_gbl_previous_thread_id = thread_id;
Bob Moorebf9b4482013-11-21 12:17:20 +0800185 acpi_gbl_nesting_level = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 }
187
188 /*
189 * Display the module name, current line number, thread ID (if requested),
190 * current procedure nesting level, and the current procedure name
191 */
Bob Moore28568462013-09-23 09:51:39 +0800192 acpi_os_printf("%9s-%04ld ", module_name, line_number);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193
Bob Moore5076f002014-01-08 13:43:12 +0800194#ifdef ACPI_APPLICATION
Bob Moorebf9b4482013-11-21 12:17:20 +0800195 /*
Bob Moore5076f002014-01-08 13:43:12 +0800196 * For acpi_exec/iASL only, emit the thread ID and nesting level.
Bob Moorebf9b4482013-11-21 12:17:20 +0800197 * Note: nesting level is really only useful during a single-thread
198 * execution. Otherwise, multiple threads will keep resetting the
199 * level.
200 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 if (ACPI_LV_THREADS & acpi_dbg_level) {
Lin Ming28eb3fc2010-09-15 13:55:13 +0800202 acpi_os_printf("[%u] ", (u32)thread_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 }
204
Bob Moorebf9b4482013-11-21 12:17:20 +0800205 acpi_os_printf("[%02ld] ", acpi_gbl_nesting_level);
206#endif
207
208 acpi_os_printf("%-22.22s: ", acpi_ut_trim_function_name(function_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
Len Brown4be44fc2005-08-05 00:44:28 -0400210 va_start(args, format);
211 acpi_os_vprintf(format, args);
Bob Moore507f0462008-04-10 19:06:42 +0400212 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213}
Robert Moore44f6c012005-04-18 22:49:35 -0400214
Bob Moore50df4d82008-12-31 03:01:23 +0800215ACPI_EXPORT_SYMBOL(acpi_debug_print)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
Robert Moore44f6c012005-04-18 22:49:35 -0400217/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 *
Bob Moore50df4d82008-12-31 03:01:23 +0800219 * FUNCTION: acpi_debug_print_raw
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 *
221 * PARAMETERS: requested_debug_level - Requested debug print level
222 * line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400223 * function_name - Caller's procedure name
224 * module_name - Caller's module name
225 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800226 * format - Printf format field
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 * ... - Optional printf arguments
228 *
229 * RETURN: None
230 *
Bob Moore73a30902012-10-31 02:26:55 +0000231 * DESCRIPTION: Print message with no headers. Has same interface as
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 * debug_print so that the same macros can be used.
233 *
Robert Moore44f6c012005-04-18 22:49:35 -0400234 ******************************************************************************/
Len Brown4be44fc2005-08-05 00:44:28 -0400235void ACPI_INTERNAL_VAR_XFACE
Bob Moore50df4d82008-12-31 03:01:23 +0800236acpi_debug_print_raw(u32 requested_debug_level,
237 u32 line_number,
238 const char *function_name,
239 const char *module_name,
240 u32 component_id, const char *format, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241{
Len Brown4be44fc2005-08-05 00:44:28 -0400242 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243
Bob Mooredb38bf52012-12-31 00:06:10 +0000244 /* Check if debug output enabled */
245
246 if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 return;
248 }
249
Len Brown4be44fc2005-08-05 00:44:28 -0400250 va_start(args, format);
251 acpi_os_vprintf(format, args);
Bob Moore507f0462008-04-10 19:06:42 +0400252 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254
Bob Moore50df4d82008-12-31 03:01:23 +0800255ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256
Robert Moore44f6c012005-04-18 22:49:35 -0400257/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 *
259 * FUNCTION: acpi_ut_trace
260 *
261 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400262 * function_name - Caller's procedure name
263 * module_name - Caller's module name
264 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 *
266 * RETURN: None
267 *
Bob Moore73a30902012-10-31 02:26:55 +0000268 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 * set in debug_level
270 *
Robert Moore44f6c012005-04-18 22:49:35 -0400271 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272void
Len Brown4be44fc2005-08-05 00:44:28 -0400273acpi_ut_trace(u32 line_number,
Bob Moore4b8ed632008-06-10 13:55:53 +0800274 const char *function_name,
275 const char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276{
277
278 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400279 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280
Bob Mooredb38bf52012-12-31 00:06:10 +0000281 /* Check if enabled up-front for performance */
282
283 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
284 acpi_debug_print(ACPI_LV_FUNCTIONS,
285 line_number, function_name, module_name,
Bob Moore0dfaaa32016-03-24 09:40:40 +0800286 component_id, "%s\n",
287 acpi_gbl_function_entry_prefix);
Bob Mooredb38bf52012-12-31 00:06:10 +0000288 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290
Bob Moore83135242006-10-03 00:00:00 -0400291ACPI_EXPORT_SYMBOL(acpi_ut_trace)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
Robert Moore44f6c012005-04-18 22:49:35 -0400293/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 *
295 * FUNCTION: acpi_ut_trace_ptr
296 *
297 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400298 * function_name - Caller's procedure name
299 * module_name - Caller's module name
300 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800301 * pointer - Pointer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 *
303 * RETURN: None
304 *
Bob Moore73a30902012-10-31 02:26:55 +0000305 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 * set in debug_level
307 *
Robert Moore44f6c012005-04-18 22:49:35 -0400308 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309void
Len Brown4be44fc2005-08-05 00:44:28 -0400310acpi_ut_trace_ptr(u32 line_number,
311 const char *function_name,
Bob Moore0dfaaa32016-03-24 09:40:40 +0800312 const char *module_name,
313 u32 component_id, const void *pointer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314{
Bob Moore68aafc32012-10-31 02:26:01 +0000315
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400317 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
Bob Mooredb38bf52012-12-31 00:06:10 +0000319 /* Check if enabled up-front for performance */
320
321 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
322 acpi_debug_print(ACPI_LV_FUNCTIONS,
323 line_number, function_name, module_name,
Bob Moore0dfaaa32016-03-24 09:40:40 +0800324 component_id, "%s %p\n",
325 acpi_gbl_function_entry_prefix, pointer);
Bob Mooredb38bf52012-12-31 00:06:10 +0000326 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327}
328
Robert Moore44f6c012005-04-18 22:49:35 -0400329/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 *
331 * FUNCTION: acpi_ut_trace_str
332 *
333 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400334 * function_name - Caller's procedure name
335 * module_name - Caller's module name
336 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800337 * string - Additional string to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 *
339 * RETURN: None
340 *
Bob Moore73a30902012-10-31 02:26:55 +0000341 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 * set in debug_level
343 *
Robert Moore44f6c012005-04-18 22:49:35 -0400344 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345
346void
Len Brown4be44fc2005-08-05 00:44:28 -0400347acpi_ut_trace_str(u32 line_number,
348 const char *function_name,
Bob Moore0dfaaa32016-03-24 09:40:40 +0800349 const char *module_name, u32 component_id, const char *string)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350{
351
352 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400353 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354
Bob Mooredb38bf52012-12-31 00:06:10 +0000355 /* Check if enabled up-front for performance */
356
357 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
358 acpi_debug_print(ACPI_LV_FUNCTIONS,
359 line_number, function_name, module_name,
Bob Moore0dfaaa32016-03-24 09:40:40 +0800360 component_id, "%s %s\n",
361 acpi_gbl_function_entry_prefix, string);
Bob Mooredb38bf52012-12-31 00:06:10 +0000362 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363}
364
Robert Moore44f6c012005-04-18 22:49:35 -0400365/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 *
367 * FUNCTION: acpi_ut_trace_u32
368 *
369 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400370 * function_name - Caller's procedure name
371 * module_name - Caller's module name
372 * component_id - Caller's component ID
Bob Mooreba494be2012-07-12 09:40:10 +0800373 * integer - Integer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 *
375 * RETURN: None
376 *
Bob Moore73a30902012-10-31 02:26:55 +0000377 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 * set in debug_level
379 *
Robert Moore44f6c012005-04-18 22:49:35 -0400380 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381
382void
Len Brown4be44fc2005-08-05 00:44:28 -0400383acpi_ut_trace_u32(u32 line_number,
384 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800385 const char *module_name, u32 component_id, u32 integer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386{
387
388 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400389 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390
Bob Mooredb38bf52012-12-31 00:06:10 +0000391 /* Check if enabled up-front for performance */
392
393 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
394 acpi_debug_print(ACPI_LV_FUNCTIONS,
395 line_number, function_name, module_name,
396 component_id, "%s %08X\n",
Bob Moore0dfaaa32016-03-24 09:40:40 +0800397 acpi_gbl_function_entry_prefix, integer);
Bob Mooredb38bf52012-12-31 00:06:10 +0000398 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399}
400
Robert Moore44f6c012005-04-18 22:49:35 -0400401/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 *
403 * FUNCTION: acpi_ut_exit
404 *
405 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400406 * function_name - Caller's procedure name
407 * module_name - Caller's module name
408 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 *
410 * RETURN: None
411 *
Bob Moore73a30902012-10-31 02:26:55 +0000412 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 * set in debug_level
414 *
Robert Moore44f6c012005-04-18 22:49:35 -0400415 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416
417void
Len Brown4be44fc2005-08-05 00:44:28 -0400418acpi_ut_exit(u32 line_number,
Bob Moore4b8ed632008-06-10 13:55:53 +0800419 const char *function_name,
420 const char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421{
422
Bob Mooredb38bf52012-12-31 00:06:10 +0000423 /* Check if enabled up-front for performance */
424
425 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
426 acpi_debug_print(ACPI_LV_FUNCTIONS,
427 line_number, function_name, module_name,
Bob Moore0dfaaa32016-03-24 09:40:40 +0800428 component_id, "%s\n",
429 acpi_gbl_function_exit_prefix);
Bob Mooredb38bf52012-12-31 00:06:10 +0000430 }
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",
Bob Moore0dfaaa32016-03-24 09:40:40 +0800469 acpi_gbl_function_exit_prefix,
Bob Mooredb38bf52012-12-31 00:06:10 +0000470 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",
Bob Moore0dfaaa32016-03-24 09:40:40 +0800476 acpi_gbl_function_exit_prefix,
Bob Mooredb38bf52012-12-31 00:06:10 +0000477 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",
Bob Moore0dfaaa32016-03-24 09:40:40 +0800516 acpi_gbl_function_exit_prefix,
Bob Mooredb38bf52012-12-31 00:06:10 +0000517 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,
Bob Moore0dfaaa32016-03-24 09:40:40 +0800554 component_id, "%s %p\n",
555 acpi_gbl_function_exit_prefix, ptr);
Bob Mooredb38bf52012-12-31 00:06:10 +0000556 }
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
Lv Zhengbab04822015-07-23 12:53:07 +0800563/*******************************************************************************
564 *
Jung-uk Kim4857a942016-08-04 16:42:19 +0800565 * FUNCTION: acpi_ut_str_exit
566 *
567 * PARAMETERS: line_number - Caller's line number
568 * function_name - Caller's procedure name
569 * module_name - Caller's module name
570 * component_id - Caller's component ID
571 * string - String to display
572 *
573 * RETURN: None
574 *
575 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
576 * set in debug_level. Prints exit value also.
577 *
578 ******************************************************************************/
579
580void
581acpi_ut_str_exit(u32 line_number,
582 const char *function_name,
583 const char *module_name, u32 component_id, const char *string)
584{
585
586 /* Check if enabled up-front for performance */
587
588 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
589 acpi_debug_print(ACPI_LV_FUNCTIONS,
590 line_number, function_name, module_name,
591 component_id, "%s %s\n",
592 acpi_gbl_function_exit_prefix, string);
593 }
594
595 if (acpi_gbl_nesting_level) {
596 acpi_gbl_nesting_level--;
597 }
598}
599
600/*******************************************************************************
601 *
Lv Zhengbab04822015-07-23 12:53:07 +0800602 * FUNCTION: acpi_trace_point
603 *
604 * PARAMETERS: type - Trace event type
605 * begin - TRUE if before execution
606 * aml - Executed AML address
607 * pathname - Object path
608 * pointer - Pointer to the related object
609 *
610 * RETURN: None
611 *
612 * DESCRIPTION: Interpreter execution trace.
613 *
614 ******************************************************************************/
Lv Zheng2e70da42014-07-08 10:07:06 +0800615
Lv Zhengbab04822015-07-23 12:53:07 +0800616void
617acpi_trace_point(acpi_trace_event_type type, u8 begin, u8 *aml, char *pathname)
618{
619
620 ACPI_FUNCTION_ENTRY();
621
622 acpi_ex_trace_point(type, begin, aml, pathname);
623
624#ifdef ACPI_USE_SYSTEM_TRACER
625 acpi_os_trace_point(type, begin, aml, pathname);
626#endif
627}
628
629ACPI_EXPORT_SYMBOL(acpi_trace_point)
Bob Moore9cf7ade2017-04-28 08:53:22 +0800630
Lv Zhengbab04822015-07-23 12:53:07 +0800631#endif