xref: /linux/drivers/acpi/acpica/utdebug.c (revision 621cde16e49b3ecf7d59a8106a20aaebfb4a59a9)
195857638SErik Schmauss // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
295b482a8SLen Brown /******************************************************************************
395b482a8SLen Brown  *
488ec2860SBob Moore  * Module Name: utdebug - Debug print/trace routines
595b482a8SLen Brown  *
6612c2932SBob Moore  * Copyright (C) 2000 - 2023, Intel Corp.
795b482a8SLen Brown  *
895857638SErik Schmauss  *****************************************************************************/
995b482a8SLen Brown 
10839e928fSLv Zheng #define EXPORT_ACPI_INTERFACES
11839e928fSLv Zheng 
1295b482a8SLen Brown #include <acpi/acpi.h>
13e2f7a777SLen Brown #include "accommon.h"
14bab04824SLv Zheng #include "acinterp.h"
1595b482a8SLen Brown 
1695b482a8SLen Brown #define _COMPONENT          ACPI_UTILITIES
1795b482a8SLen Brown ACPI_MODULE_NAME("utdebug")
186d33b6beSLv Zheng 
1995b482a8SLen Brown #ifdef ACPI_DEBUG_OUTPUT
200dfaaa3dSBob Moore static acpi_thread_id acpi_gbl_previous_thread_id = (acpi_thread_id) 0xFFFFFFFF;
210dfaaa3dSBob Moore static const char *acpi_gbl_function_entry_prefix = "----Entry";
220dfaaa3dSBob Moore static const char *acpi_gbl_function_exit_prefix = "----Exit-";
2395b482a8SLen Brown 
2495b482a8SLen Brown /*******************************************************************************
2595b482a8SLen Brown  *
2695b482a8SLen Brown  * FUNCTION:    acpi_ut_init_stack_ptr_trace
2795b482a8SLen Brown  *
2895b482a8SLen Brown  * PARAMETERS:  None
2995b482a8SLen Brown  *
3095b482a8SLen Brown  * RETURN:      None
3195b482a8SLen Brown  *
3295b482a8SLen Brown  * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
3395b482a8SLen Brown  *
3495b482a8SLen Brown  ******************************************************************************/
3595b482a8SLen Brown 
acpi_ut_init_stack_ptr_trace(void)3695b482a8SLen Brown void acpi_ut_init_stack_ptr_trace(void)
3795b482a8SLen Brown {
3895b482a8SLen Brown 	acpi_size current_sp;
3995b482a8SLen Brown 
407c94858eSPhilip Prindeville #pragma GCC diagnostic push
417c94858eSPhilip Prindeville #if defined(__GNUC__) && __GNUC__ >= 12
427c94858eSPhilip Prindeville #pragma GCC diagnostic ignored "-Wdangling-pointer="
437c94858eSPhilip Prindeville #endif
4495b482a8SLen Brown 	acpi_gbl_entry_stack_pointer = &current_sp;
455a025277SSaket Dumbre #pragma GCC diagnostic pop
4695b482a8SLen Brown }
4795b482a8SLen Brown 
4895b482a8SLen Brown /*******************************************************************************
4995b482a8SLen Brown  *
5095b482a8SLen Brown  * FUNCTION:    acpi_ut_track_stack_ptr
5195b482a8SLen Brown  *
5295b482a8SLen Brown  * PARAMETERS:  None
5395b482a8SLen Brown  *
5495b482a8SLen Brown  * RETURN:      None
5595b482a8SLen Brown  *
5695b482a8SLen Brown  * DESCRIPTION: Save the current CPU stack pointer
5795b482a8SLen Brown  *
5895b482a8SLen Brown  ******************************************************************************/
5995b482a8SLen Brown 
acpi_ut_track_stack_ptr(void)6095b482a8SLen Brown void acpi_ut_track_stack_ptr(void)
6195b482a8SLen Brown {
6295b482a8SLen Brown 	acpi_size current_sp;
6395b482a8SLen Brown 
6495b482a8SLen Brown 	if (&current_sp < acpi_gbl_lowest_stack_pointer) {
655a025277SSaket Dumbre #pragma GCC diagnostic push
665a025277SSaket Dumbre #if defined(__GNUC__) && __GNUC__ >= 12
675a025277SSaket Dumbre #pragma GCC diagnostic ignored "-Wdangling-pointer="
685a025277SSaket Dumbre #endif
6995b482a8SLen Brown 		acpi_gbl_lowest_stack_pointer = &current_sp;
70*ed5addd0SSaket Dumbre #pragma GCC diagnostic pop
7195b482a8SLen Brown 	}
7295b482a8SLen Brown 
7395b482a8SLen Brown 	if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) {
7495b482a8SLen Brown 		acpi_gbl_deepest_nesting = acpi_gbl_nesting_level;
7595b482a8SLen Brown 	}
7695b482a8SLen Brown }
7795b482a8SLen Brown 
7895b482a8SLen Brown /*******************************************************************************
7995b482a8SLen Brown  *
8095b482a8SLen Brown  * FUNCTION:    acpi_ut_trim_function_name
8195b482a8SLen Brown  *
8295b482a8SLen Brown  * PARAMETERS:  function_name       - Ascii string containing a procedure name
8395b482a8SLen Brown  *
8495b482a8SLen Brown  * RETURN:      Updated pointer to the function name
8595b482a8SLen Brown  *
8695b482a8SLen Brown  * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
877011bf4eSLv Zheng  *              This allows compiler macros such as __func__ to be used
887011bf4eSLv Zheng  *              with no change to the debug output.
8995b482a8SLen Brown  *
9095b482a8SLen Brown  ******************************************************************************/
9195b482a8SLen Brown 
acpi_ut_trim_function_name(const char * function_name)9295b482a8SLen Brown static const char *acpi_ut_trim_function_name(const char *function_name)
9395b482a8SLen Brown {
9495b482a8SLen Brown 
9595b482a8SLen Brown 	/* All Function names are longer than 4 chars, check is safe */
9695b482a8SLen Brown 
9795b482a8SLen Brown 	if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) {
9895b482a8SLen Brown 
9995b482a8SLen Brown 		/* This is the case where the original source has not been modified */
10095b482a8SLen Brown 
10195b482a8SLen Brown 		return (function_name + 4);
10295b482a8SLen Brown 	}
10395b482a8SLen Brown 
10495b482a8SLen Brown 	if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) {
10595b482a8SLen Brown 
10695b482a8SLen Brown 		/* This is the case where the source has been 'linuxized' */
10795b482a8SLen Brown 
10895b482a8SLen Brown 		return (function_name + 5);
10995b482a8SLen Brown 	}
11095b482a8SLen Brown 
11195b482a8SLen Brown 	return (function_name);
11295b482a8SLen Brown }
11395b482a8SLen Brown 
11495b482a8SLen Brown /*******************************************************************************
11595b482a8SLen Brown  *
11695b482a8SLen Brown  * FUNCTION:    acpi_debug_print
11795b482a8SLen Brown  *
11895b482a8SLen Brown  * PARAMETERS:  requested_debug_level - Requested debug print level
11995b482a8SLen Brown  *              line_number         - Caller's line number (for error output)
12095b482a8SLen Brown  *              function_name       - Caller's procedure name
12195b482a8SLen Brown  *              module_name         - Caller's module name
12295b482a8SLen Brown  *              component_id        - Caller's component ID
123ba494beeSBob Moore  *              format              - Printf format field
12495b482a8SLen Brown  *              ...                 - Optional printf arguments
12595b482a8SLen Brown  *
12695b482a8SLen Brown  * RETURN:      None
12795b482a8SLen Brown  *
12895b482a8SLen Brown  * DESCRIPTION: Print error message with prefix consisting of the module name,
12995b482a8SLen Brown  *              line number, and component ID.
13095b482a8SLen Brown  *
13195b482a8SLen Brown  ******************************************************************************/
13295b482a8SLen Brown 
13395b482a8SLen Brown void ACPI_INTERNAL_VAR_XFACE
acpi_debug_print(u32 requested_debug_level,u32 line_number,const char * function_name,const char * module_name,u32 component_id,const char * format,...)13495b482a8SLen Brown acpi_debug_print(u32 requested_debug_level,
13595b482a8SLen Brown 		 u32 line_number,
13695b482a8SLen Brown 		 const char *function_name,
13795b482a8SLen Brown 		 const char *module_name,
13895b482a8SLen Brown 		 u32 component_id, const char *format, ...)
13995b482a8SLen Brown {
14095b482a8SLen Brown 	acpi_thread_id thread_id;
14195b482a8SLen Brown 	va_list args;
1422cb0ba70SBob Moore #ifdef ACPI_APPLICATION
1436be2d72bSBob Moore 	int fill_count;
1442cb0ba70SBob Moore #endif
14595b482a8SLen Brown 
146db38bf5aSBob Moore 	/* Check if debug output enabled */
147db38bf5aSBob Moore 
148db38bf5aSBob Moore 	if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
14995b482a8SLen Brown 		return;
15095b482a8SLen Brown 	}
15195b482a8SLen Brown 
15295b482a8SLen Brown 	/*
15395b482a8SLen Brown 	 * Thread tracking and context switch notification
15495b482a8SLen Brown 	 */
15595b482a8SLen Brown 	thread_id = acpi_os_get_thread_id();
1560dfaaa3dSBob Moore 	if (thread_id != acpi_gbl_previous_thread_id) {
15795b482a8SLen Brown 		if (ACPI_LV_THREADS & acpi_dbg_level) {
15895b482a8SLen Brown 			acpi_os_printf
15928eb3fcfSLin Ming 			    ("\n**** Context Switch from TID %u to TID %u ****\n\n",
1600dfaaa3dSBob Moore 			     (u32)acpi_gbl_previous_thread_id, (u32)thread_id);
16195b482a8SLen Brown 		}
16295b482a8SLen Brown 
1630dfaaa3dSBob Moore 		acpi_gbl_previous_thread_id = thread_id;
164bf9b448eSBob Moore 		acpi_gbl_nesting_level = 0;
16595b482a8SLen Brown 	}
16695b482a8SLen Brown 
16795b482a8SLen Brown 	/*
16895b482a8SLen Brown 	 * Display the module name, current line number, thread ID (if requested),
16995b482a8SLen Brown 	 * current procedure nesting level, and the current procedure name
17095b482a8SLen Brown 	 */
17136056d0cSBob Moore 	acpi_os_printf("%9s-%04d ", module_name, line_number);
17295b482a8SLen Brown 
1735076f005SBob Moore #ifdef ACPI_APPLICATION
174bf9b448eSBob Moore 	/*
1755076f005SBob Moore 	 * For acpi_exec/iASL only, emit the thread ID and nesting level.
176bf9b448eSBob Moore 	 * Note: nesting level is really only useful during a single-thread
177bf9b448eSBob Moore 	 * execution. Otherwise, multiple threads will keep resetting the
178bf9b448eSBob Moore 	 * level.
179bf9b448eSBob Moore 	 */
18095b482a8SLen Brown 	if (ACPI_LV_THREADS & acpi_dbg_level) {
18128eb3fcfSLin Ming 		acpi_os_printf("[%u] ", (u32)thread_id);
18295b482a8SLen Brown 	}
18395b482a8SLen Brown 
1846be2d72bSBob Moore 	fill_count = 48 - acpi_gbl_nesting_level -
1856be2d72bSBob Moore 	    strlen(acpi_ut_trim_function_name(function_name));
1866be2d72bSBob Moore 	if (fill_count < 0) {
1876be2d72bSBob Moore 		fill_count = 0;
1886be2d72bSBob Moore 	}
189bf9b448eSBob Moore 
19036056d0cSBob Moore 	acpi_os_printf("[%02d] %*s",
1916e875fa0SErik Schmauss 		       acpi_gbl_nesting_level, acpi_gbl_nesting_level + 1, " ");
1926be2d72bSBob Moore 	acpi_os_printf("%s%*s: ",
1936be2d72bSBob Moore 		       acpi_ut_trim_function_name(function_name), fill_count,
1946be2d72bSBob Moore 		       " ");
1956be2d72bSBob Moore 
1966be2d72bSBob Moore #else
197bf9b448eSBob Moore 	acpi_os_printf("%-22.22s: ", acpi_ut_trim_function_name(function_name));
1986be2d72bSBob Moore #endif
19995b482a8SLen Brown 
20095b482a8SLen Brown 	va_start(args, format);
20195b482a8SLen Brown 	acpi_os_vprintf(format, args);
20295b482a8SLen Brown 	va_end(args);
20395b482a8SLen Brown }
20495b482a8SLen Brown 
ACPI_EXPORT_SYMBOL(acpi_debug_print)20595b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_debug_print)
20695b482a8SLen Brown 
20795b482a8SLen Brown /*******************************************************************************
20895b482a8SLen Brown  *
20995b482a8SLen Brown  * FUNCTION:    acpi_debug_print_raw
21095b482a8SLen Brown  *
21195b482a8SLen Brown  * PARAMETERS:  requested_debug_level - Requested debug print level
21295b482a8SLen Brown  *              line_number         - Caller's line number
21395b482a8SLen Brown  *              function_name       - Caller's procedure name
21495b482a8SLen Brown  *              module_name         - Caller's module name
21595b482a8SLen Brown  *              component_id        - Caller's component ID
216ba494beeSBob Moore  *              format              - Printf format field
21795b482a8SLen Brown  *              ...                 - Optional printf arguments
21895b482a8SLen Brown  *
21995b482a8SLen Brown  * RETURN:      None
22095b482a8SLen Brown  *
22195b482a8SLen Brown  * DESCRIPTION: Print message with no headers. Has same interface as
22295b482a8SLen Brown  *              debug_print so that the same macros can be used.
22395b482a8SLen Brown  *
22495b482a8SLen Brown  ******************************************************************************/
22595b482a8SLen Brown void ACPI_INTERNAL_VAR_XFACE
22695b482a8SLen Brown acpi_debug_print_raw(u32 requested_debug_level,
22795b482a8SLen Brown 		     u32 line_number,
22895b482a8SLen Brown 		     const char *function_name,
22995b482a8SLen Brown 		     const char *module_name,
23095b482a8SLen Brown 		     u32 component_id, const char *format, ...)
23195b482a8SLen Brown {
23295b482a8SLen Brown 	va_list args;
23395b482a8SLen Brown 
234db38bf5aSBob Moore 	/* Check if debug output enabled */
235db38bf5aSBob Moore 
236db38bf5aSBob Moore 	if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
23795b482a8SLen Brown 		return;
23895b482a8SLen Brown 	}
23995b482a8SLen Brown 
24095b482a8SLen Brown 	va_start(args, format);
24195b482a8SLen Brown 	acpi_os_vprintf(format, args);
24295b482a8SLen Brown 	va_end(args);
24395b482a8SLen Brown }
24495b482a8SLen Brown 
ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)24595b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
24695b482a8SLen Brown 
24795b482a8SLen Brown /*******************************************************************************
24895b482a8SLen Brown  *
24995b482a8SLen Brown  * FUNCTION:    acpi_ut_trace
25095b482a8SLen Brown  *
25195b482a8SLen Brown  * PARAMETERS:  line_number         - Caller's line number
25295b482a8SLen Brown  *              function_name       - Caller's procedure name
25395b482a8SLen Brown  *              module_name         - Caller's module name
25495b482a8SLen Brown  *              component_id        - Caller's component ID
25595b482a8SLen Brown  *
25695b482a8SLen Brown  * RETURN:      None
25795b482a8SLen Brown  *
25895b482a8SLen Brown  * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
25995b482a8SLen Brown  *              set in debug_level
26095b482a8SLen Brown  *
26195b482a8SLen Brown  ******************************************************************************/
26295b482a8SLen Brown void
26395b482a8SLen Brown acpi_ut_trace(u32 line_number,
26495b482a8SLen Brown 	      const char *function_name,
26595b482a8SLen Brown 	      const char *module_name, u32 component_id)
26695b482a8SLen Brown {
26795b482a8SLen Brown 
26895b482a8SLen Brown 	acpi_gbl_nesting_level++;
26995b482a8SLen Brown 	acpi_ut_track_stack_ptr();
27095b482a8SLen Brown 
271db38bf5aSBob Moore 	/* Check if enabled up-front for performance */
272db38bf5aSBob Moore 
273db38bf5aSBob Moore 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
27495b482a8SLen Brown 		acpi_debug_print(ACPI_LV_FUNCTIONS,
275db38bf5aSBob Moore 				 line_number, function_name, module_name,
2760dfaaa3dSBob Moore 				 component_id, "%s\n",
2770dfaaa3dSBob Moore 				 acpi_gbl_function_entry_prefix);
278db38bf5aSBob Moore 	}
27995b482a8SLen Brown }
28095b482a8SLen Brown 
ACPI_EXPORT_SYMBOL(acpi_ut_trace)28195b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_ut_trace)
28295b482a8SLen Brown 
28395b482a8SLen Brown /*******************************************************************************
28495b482a8SLen Brown  *
28595b482a8SLen Brown  * FUNCTION:    acpi_ut_trace_ptr
28695b482a8SLen Brown  *
28795b482a8SLen Brown  * PARAMETERS:  line_number         - Caller's line number
28895b482a8SLen Brown  *              function_name       - Caller's procedure name
28995b482a8SLen Brown  *              module_name         - Caller's module name
29095b482a8SLen Brown  *              component_id        - Caller's component ID
291ba494beeSBob Moore  *              pointer             - Pointer to display
29295b482a8SLen Brown  *
29395b482a8SLen Brown  * RETURN:      None
29495b482a8SLen Brown  *
29595b482a8SLen Brown  * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
29695b482a8SLen Brown  *              set in debug_level
29795b482a8SLen Brown  *
29895b482a8SLen Brown  ******************************************************************************/
29995b482a8SLen Brown void
30095b482a8SLen Brown acpi_ut_trace_ptr(u32 line_number,
30195b482a8SLen Brown 		  const char *function_name,
3020dfaaa3dSBob Moore 		  const char *module_name,
3030dfaaa3dSBob Moore 		  u32 component_id, const void *pointer)
30495b482a8SLen Brown {
30568aafc35SBob Moore 
30695b482a8SLen Brown 	acpi_gbl_nesting_level++;
30795b482a8SLen Brown 	acpi_ut_track_stack_ptr();
30895b482a8SLen Brown 
309db38bf5aSBob Moore 	/* Check if enabled up-front for performance */
310db38bf5aSBob Moore 
311db38bf5aSBob Moore 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
31295b482a8SLen Brown 		acpi_debug_print(ACPI_LV_FUNCTIONS,
313db38bf5aSBob Moore 				 line_number, function_name, module_name,
3140dfaaa3dSBob Moore 				 component_id, "%s %p\n",
3150dfaaa3dSBob Moore 				 acpi_gbl_function_entry_prefix, pointer);
316db38bf5aSBob Moore 	}
31795b482a8SLen Brown }
31895b482a8SLen Brown 
31995b482a8SLen Brown /*******************************************************************************
32095b482a8SLen Brown  *
32195b482a8SLen Brown  * FUNCTION:    acpi_ut_trace_str
32295b482a8SLen Brown  *
32395b482a8SLen Brown  * PARAMETERS:  line_number         - Caller's line number
32495b482a8SLen Brown  *              function_name       - Caller's procedure name
32595b482a8SLen Brown  *              module_name         - Caller's module name
32695b482a8SLen Brown  *              component_id        - Caller's component ID
327ba494beeSBob Moore  *              string              - Additional string to display
32895b482a8SLen Brown  *
32995b482a8SLen Brown  * RETURN:      None
33095b482a8SLen Brown  *
33195b482a8SLen Brown  * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
33295b482a8SLen Brown  *              set in debug_level
33395b482a8SLen Brown  *
33495b482a8SLen Brown  ******************************************************************************/
33595b482a8SLen Brown 
33695b482a8SLen Brown void
acpi_ut_trace_str(u32 line_number,const char * function_name,const char * module_name,u32 component_id,const char * string)33795b482a8SLen Brown acpi_ut_trace_str(u32 line_number,
33895b482a8SLen Brown 		  const char *function_name,
3390dfaaa3dSBob Moore 		  const char *module_name, u32 component_id, const char *string)
34095b482a8SLen Brown {
34195b482a8SLen Brown 
34295b482a8SLen Brown 	acpi_gbl_nesting_level++;
34395b482a8SLen Brown 	acpi_ut_track_stack_ptr();
34495b482a8SLen Brown 
345db38bf5aSBob Moore 	/* Check if enabled up-front for performance */
346db38bf5aSBob Moore 
347db38bf5aSBob Moore 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
34895b482a8SLen Brown 		acpi_debug_print(ACPI_LV_FUNCTIONS,
349db38bf5aSBob Moore 				 line_number, function_name, module_name,
3500dfaaa3dSBob Moore 				 component_id, "%s %s\n",
3510dfaaa3dSBob Moore 				 acpi_gbl_function_entry_prefix, string);
352db38bf5aSBob Moore 	}
35395b482a8SLen Brown }
35495b482a8SLen Brown 
35595b482a8SLen Brown /*******************************************************************************
35695b482a8SLen Brown  *
35795b482a8SLen Brown  * FUNCTION:    acpi_ut_trace_u32
35895b482a8SLen Brown  *
35995b482a8SLen Brown  * PARAMETERS:  line_number         - Caller's line number
36095b482a8SLen Brown  *              function_name       - Caller's procedure name
36195b482a8SLen Brown  *              module_name         - Caller's module name
36295b482a8SLen Brown  *              component_id        - Caller's component ID
363ba494beeSBob Moore  *              integer             - Integer to display
36495b482a8SLen Brown  *
36595b482a8SLen Brown  * RETURN:      None
36695b482a8SLen Brown  *
36795b482a8SLen Brown  * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
36895b482a8SLen Brown  *              set in debug_level
36995b482a8SLen Brown  *
37095b482a8SLen Brown  ******************************************************************************/
37195b482a8SLen Brown 
37295b482a8SLen Brown void
acpi_ut_trace_u32(u32 line_number,const char * function_name,const char * module_name,u32 component_id,u32 integer)37395b482a8SLen Brown acpi_ut_trace_u32(u32 line_number,
37495b482a8SLen Brown 		  const char *function_name,
37595b482a8SLen Brown 		  const char *module_name, u32 component_id, u32 integer)
37695b482a8SLen Brown {
37795b482a8SLen Brown 
37895b482a8SLen Brown 	acpi_gbl_nesting_level++;
37995b482a8SLen Brown 	acpi_ut_track_stack_ptr();
38095b482a8SLen Brown 
381db38bf5aSBob Moore 	/* Check if enabled up-front for performance */
382db38bf5aSBob Moore 
383db38bf5aSBob Moore 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
38495b482a8SLen Brown 		acpi_debug_print(ACPI_LV_FUNCTIONS,
385db38bf5aSBob Moore 				 line_number, function_name, module_name,
386db38bf5aSBob Moore 				 component_id, "%s %08X\n",
3870dfaaa3dSBob Moore 				 acpi_gbl_function_entry_prefix, integer);
388db38bf5aSBob Moore 	}
38995b482a8SLen Brown }
39095b482a8SLen Brown 
39195b482a8SLen Brown /*******************************************************************************
39295b482a8SLen Brown  *
39395b482a8SLen Brown  * FUNCTION:    acpi_ut_exit
39495b482a8SLen Brown  *
39595b482a8SLen Brown  * PARAMETERS:  line_number         - Caller's line number
39695b482a8SLen Brown  *              function_name       - Caller's procedure name
39795b482a8SLen Brown  *              module_name         - Caller's module name
39895b482a8SLen Brown  *              component_id        - Caller's component ID
39995b482a8SLen Brown  *
40095b482a8SLen Brown  * RETURN:      None
40195b482a8SLen Brown  *
40295b482a8SLen Brown  * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
40395b482a8SLen Brown  *              set in debug_level
40495b482a8SLen Brown  *
40595b482a8SLen Brown  ******************************************************************************/
40695b482a8SLen Brown 
40795b482a8SLen Brown void
acpi_ut_exit(u32 line_number,const char * function_name,const char * module_name,u32 component_id)40895b482a8SLen Brown acpi_ut_exit(u32 line_number,
40995b482a8SLen Brown 	     const char *function_name,
41095b482a8SLen Brown 	     const char *module_name, u32 component_id)
41195b482a8SLen Brown {
41295b482a8SLen Brown 
413db38bf5aSBob Moore 	/* Check if enabled up-front for performance */
414db38bf5aSBob Moore 
415db38bf5aSBob Moore 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
41695b482a8SLen Brown 		acpi_debug_print(ACPI_LV_FUNCTIONS,
417db38bf5aSBob Moore 				 line_number, function_name, module_name,
4180dfaaa3dSBob Moore 				 component_id, "%s\n",
4190dfaaa3dSBob Moore 				 acpi_gbl_function_exit_prefix);
420db38bf5aSBob Moore 	}
42195b482a8SLen Brown 
422bf9b448eSBob Moore 	if (acpi_gbl_nesting_level) {
42395b482a8SLen Brown 		acpi_gbl_nesting_level--;
42495b482a8SLen Brown 	}
425bf9b448eSBob Moore }
42695b482a8SLen Brown 
ACPI_EXPORT_SYMBOL(acpi_ut_exit)42795b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_ut_exit)
42895b482a8SLen Brown 
42995b482a8SLen Brown /*******************************************************************************
43095b482a8SLen Brown  *
43195b482a8SLen Brown  * FUNCTION:    acpi_ut_status_exit
43295b482a8SLen Brown  *
43395b482a8SLen Brown  * PARAMETERS:  line_number         - Caller's line number
43495b482a8SLen Brown  *              function_name       - Caller's procedure name
43595b482a8SLen Brown  *              module_name         - Caller's module name
43695b482a8SLen Brown  *              component_id        - Caller's component ID
437ba494beeSBob Moore  *              status              - Exit status code
43895b482a8SLen Brown  *
43995b482a8SLen Brown  * RETURN:      None
44095b482a8SLen Brown  *
44195b482a8SLen Brown  * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
44295b482a8SLen Brown  *              set in debug_level. Prints exit status also.
44395b482a8SLen Brown  *
44495b482a8SLen Brown  ******************************************************************************/
44595b482a8SLen Brown void
44695b482a8SLen Brown acpi_ut_status_exit(u32 line_number,
44795b482a8SLen Brown 		    const char *function_name,
44895b482a8SLen Brown 		    const char *module_name,
44995b482a8SLen Brown 		    u32 component_id, acpi_status status)
45095b482a8SLen Brown {
45195b482a8SLen Brown 
452db38bf5aSBob Moore 	/* Check if enabled up-front for performance */
453db38bf5aSBob Moore 
454db38bf5aSBob Moore 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
45595b482a8SLen Brown 		if (ACPI_SUCCESS(status)) {
45695b482a8SLen Brown 			acpi_debug_print(ACPI_LV_FUNCTIONS,
457db38bf5aSBob Moore 					 line_number, function_name,
458db38bf5aSBob Moore 					 module_name, component_id, "%s %s\n",
4590dfaaa3dSBob Moore 					 acpi_gbl_function_exit_prefix,
46095b482a8SLen Brown 					 acpi_format_exception(status));
46195b482a8SLen Brown 		} else {
46295b482a8SLen Brown 			acpi_debug_print(ACPI_LV_FUNCTIONS,
463db38bf5aSBob Moore 					 line_number, function_name,
464db38bf5aSBob Moore 					 module_name, component_id,
465db38bf5aSBob Moore 					 "%s ****Exception****: %s\n",
4660dfaaa3dSBob Moore 					 acpi_gbl_function_exit_prefix,
46795b482a8SLen Brown 					 acpi_format_exception(status));
46895b482a8SLen Brown 		}
469db38bf5aSBob Moore 	}
47095b482a8SLen Brown 
471bf9b448eSBob Moore 	if (acpi_gbl_nesting_level) {
47295b482a8SLen Brown 		acpi_gbl_nesting_level--;
47395b482a8SLen Brown 	}
474bf9b448eSBob Moore }
47595b482a8SLen Brown 
ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)47695b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
47795b482a8SLen Brown 
47895b482a8SLen Brown /*******************************************************************************
47995b482a8SLen Brown  *
48095b482a8SLen Brown  * FUNCTION:    acpi_ut_value_exit
48195b482a8SLen Brown  *
48295b482a8SLen Brown  * PARAMETERS:  line_number         - Caller's line number
48395b482a8SLen Brown  *              function_name       - Caller's procedure name
48495b482a8SLen Brown  *              module_name         - Caller's module name
48595b482a8SLen Brown  *              component_id        - Caller's component ID
486ba494beeSBob Moore  *              value               - Value to be printed with exit msg
48795b482a8SLen Brown  *
48895b482a8SLen Brown  * RETURN:      None
48995b482a8SLen Brown  *
49095b482a8SLen Brown  * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
49195b482a8SLen Brown  *              set in debug_level. Prints exit value also.
49295b482a8SLen Brown  *
49395b482a8SLen Brown  ******************************************************************************/
49495b482a8SLen Brown void
49595b482a8SLen Brown acpi_ut_value_exit(u32 line_number,
49695b482a8SLen Brown 		   const char *function_name,
4975df7e6cbSBob Moore 		   const char *module_name, u32 component_id, u64 value)
49895b482a8SLen Brown {
49995b482a8SLen Brown 
500db38bf5aSBob Moore 	/* Check if enabled up-front for performance */
501db38bf5aSBob Moore 
502db38bf5aSBob Moore 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
50395b482a8SLen Brown 		acpi_debug_print(ACPI_LV_FUNCTIONS,
504db38bf5aSBob Moore 				 line_number, function_name, module_name,
505db38bf5aSBob Moore 				 component_id, "%s %8.8X%8.8X\n",
5060dfaaa3dSBob Moore 				 acpi_gbl_function_exit_prefix,
50795b482a8SLen Brown 				 ACPI_FORMAT_UINT64(value));
508db38bf5aSBob Moore 	}
50995b482a8SLen Brown 
510bf9b448eSBob Moore 	if (acpi_gbl_nesting_level) {
51195b482a8SLen Brown 		acpi_gbl_nesting_level--;
51295b482a8SLen Brown 	}
513bf9b448eSBob Moore }
51495b482a8SLen Brown 
ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)51595b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)
51695b482a8SLen Brown 
51795b482a8SLen Brown /*******************************************************************************
51895b482a8SLen Brown  *
51995b482a8SLen Brown  * FUNCTION:    acpi_ut_ptr_exit
52095b482a8SLen Brown  *
52195b482a8SLen Brown  * PARAMETERS:  line_number         - Caller's line number
52295b482a8SLen Brown  *              function_name       - Caller's procedure name
52395b482a8SLen Brown  *              module_name         - Caller's module name
52495b482a8SLen Brown  *              component_id        - Caller's component ID
525ba494beeSBob Moore  *              ptr                 - Pointer to display
52695b482a8SLen Brown  *
52795b482a8SLen Brown  * RETURN:      None
52895b482a8SLen Brown  *
52995b482a8SLen Brown  * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
53095b482a8SLen Brown  *              set in debug_level. Prints exit value also.
53195b482a8SLen Brown  *
53295b482a8SLen Brown  ******************************************************************************/
53395b482a8SLen Brown void
53495b482a8SLen Brown acpi_ut_ptr_exit(u32 line_number,
53595b482a8SLen Brown 		 const char *function_name,
53695b482a8SLen Brown 		 const char *module_name, u32 component_id, u8 *ptr)
53795b482a8SLen Brown {
53895b482a8SLen Brown 
539db38bf5aSBob Moore 	/* Check if enabled up-front for performance */
540db38bf5aSBob Moore 
541db38bf5aSBob Moore 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
54295b482a8SLen Brown 		acpi_debug_print(ACPI_LV_FUNCTIONS,
543db38bf5aSBob Moore 				 line_number, function_name, module_name,
5440dfaaa3dSBob Moore 				 component_id, "%s %p\n",
5450dfaaa3dSBob Moore 				 acpi_gbl_function_exit_prefix, ptr);
546db38bf5aSBob Moore 	}
54795b482a8SLen Brown 
548bf9b448eSBob Moore 	if (acpi_gbl_nesting_level) {
54995b482a8SLen Brown 		acpi_gbl_nesting_level--;
55095b482a8SLen Brown 	}
551bf9b448eSBob Moore }
55295b482a8SLen Brown 
553bab04824SLv Zheng /*******************************************************************************
554bab04824SLv Zheng  *
5554857a94dSJung-uk Kim  * FUNCTION:    acpi_ut_str_exit
5564857a94dSJung-uk Kim  *
5574857a94dSJung-uk Kim  * PARAMETERS:  line_number         - Caller's line number
5584857a94dSJung-uk Kim  *              function_name       - Caller's procedure name
5594857a94dSJung-uk Kim  *              module_name         - Caller's module name
5604857a94dSJung-uk Kim  *              component_id        - Caller's component ID
5614857a94dSJung-uk Kim  *              string              - String to display
5624857a94dSJung-uk Kim  *
5634857a94dSJung-uk Kim  * RETURN:      None
5644857a94dSJung-uk Kim  *
5654857a94dSJung-uk Kim  * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
5664857a94dSJung-uk Kim  *              set in debug_level. Prints exit value also.
5674857a94dSJung-uk Kim  *
5684857a94dSJung-uk Kim  ******************************************************************************/
5694857a94dSJung-uk Kim 
5704857a94dSJung-uk Kim void
acpi_ut_str_exit(u32 line_number,const char * function_name,const char * module_name,u32 component_id,const char * string)5714857a94dSJung-uk Kim acpi_ut_str_exit(u32 line_number,
5724857a94dSJung-uk Kim 		 const char *function_name,
5734857a94dSJung-uk Kim 		 const char *module_name, u32 component_id, const char *string)
5744857a94dSJung-uk Kim {
5754857a94dSJung-uk Kim 
5764857a94dSJung-uk Kim 	/* Check if enabled up-front for performance */
5774857a94dSJung-uk Kim 
5784857a94dSJung-uk Kim 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
5794857a94dSJung-uk Kim 		acpi_debug_print(ACPI_LV_FUNCTIONS,
5804857a94dSJung-uk Kim 				 line_number, function_name, module_name,
5814857a94dSJung-uk Kim 				 component_id, "%s %s\n",
5824857a94dSJung-uk Kim 				 acpi_gbl_function_exit_prefix, string);
5834857a94dSJung-uk Kim 	}
5844857a94dSJung-uk Kim 
5854857a94dSJung-uk Kim 	if (acpi_gbl_nesting_level) {
5864857a94dSJung-uk Kim 		acpi_gbl_nesting_level--;
5874857a94dSJung-uk Kim 	}
5884857a94dSJung-uk Kim }
5894857a94dSJung-uk Kim 
5904857a94dSJung-uk Kim /*******************************************************************************
5914857a94dSJung-uk Kim  *
592bab04824SLv Zheng  * FUNCTION:    acpi_trace_point
593bab04824SLv Zheng  *
594bab04824SLv Zheng  * PARAMETERS:  type                - Trace event type
595bab04824SLv Zheng  *              begin               - TRUE if before execution
596bab04824SLv Zheng  *              aml                 - Executed AML address
597bab04824SLv Zheng  *              pathname            - Object path
598bab04824SLv Zheng  *              pointer             - Pointer to the related object
599bab04824SLv Zheng  *
600bab04824SLv Zheng  * RETURN:      None
601bab04824SLv Zheng  *
602bab04824SLv Zheng  * DESCRIPTION: Interpreter execution trace.
603bab04824SLv Zheng  *
604bab04824SLv Zheng  ******************************************************************************/
6052e70da4cSLv Zheng 
606bab04824SLv Zheng void
acpi_trace_point(acpi_trace_event_type type,u8 begin,u8 * aml,char * pathname)607bab04824SLv Zheng acpi_trace_point(acpi_trace_event_type type, u8 begin, u8 *aml, char *pathname)
608bab04824SLv Zheng {
609bab04824SLv Zheng 
610bab04824SLv Zheng 	ACPI_FUNCTION_ENTRY();
611bab04824SLv Zheng 
612bab04824SLv Zheng 	acpi_ex_trace_point(type, begin, aml, pathname);
613bab04824SLv Zheng 
614bab04824SLv Zheng #ifdef ACPI_USE_SYSTEM_TRACER
615bab04824SLv Zheng 	acpi_os_trace_point(type, begin, aml, pathname);
616bab04824SLv Zheng #endif
617bab04824SLv Zheng }
618bab04824SLv Zheng 
619bab04824SLv Zheng ACPI_EXPORT_SYMBOL(acpi_trace_point)
6209cf7adecSBob Moore 
621bab04824SLv Zheng #endif
622