xref: /openbmc/linux/drivers/acpi/acpica/utdebug.c (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
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 
40*7c94858eSPhilip Prindeville #pragma GCC diagnostic push
41*7c94858eSPhilip Prindeville #if defined(__GNUC__) && __GNUC__ >= 12
42*7c94858eSPhilip Prindeville #pragma GCC diagnostic ignored "-Wdangling-pointer="
43*7c94858eSPhilip Prindeville #endif
4495b482a8SLen Brown 	acpi_gbl_entry_stack_pointer = &current_sp;
45*7c94858eSPhilip Prindeville #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) {
6595b482a8SLen Brown 		acpi_gbl_lowest_stack_pointer = &current_sp;
6695b482a8SLen Brown 	}
6795b482a8SLen Brown 
6895b482a8SLen Brown 	if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) {
6995b482a8SLen Brown 		acpi_gbl_deepest_nesting = acpi_gbl_nesting_level;
7095b482a8SLen Brown 	}
7195b482a8SLen Brown }
7295b482a8SLen Brown 
7395b482a8SLen Brown /*******************************************************************************
7495b482a8SLen Brown  *
7595b482a8SLen Brown  * FUNCTION:    acpi_ut_trim_function_name
7695b482a8SLen Brown  *
7795b482a8SLen Brown  * PARAMETERS:  function_name       - Ascii string containing a procedure name
7895b482a8SLen Brown  *
7995b482a8SLen Brown  * RETURN:      Updated pointer to the function name
8095b482a8SLen Brown  *
8195b482a8SLen Brown  * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
827011bf4eSLv Zheng  *              This allows compiler macros such as __func__ to be used
837011bf4eSLv Zheng  *              with no change to the debug output.
8495b482a8SLen Brown  *
8595b482a8SLen Brown  ******************************************************************************/
8695b482a8SLen Brown 
acpi_ut_trim_function_name(const char * function_name)8795b482a8SLen Brown static const char *acpi_ut_trim_function_name(const char *function_name)
8895b482a8SLen Brown {
8995b482a8SLen Brown 
9095b482a8SLen Brown 	/* All Function names are longer than 4 chars, check is safe */
9195b482a8SLen Brown 
9295b482a8SLen Brown 	if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) {
9395b482a8SLen Brown 
9495b482a8SLen Brown 		/* This is the case where the original source has not been modified */
9595b482a8SLen Brown 
9695b482a8SLen Brown 		return (function_name + 4);
9795b482a8SLen Brown 	}
9895b482a8SLen Brown 
9995b482a8SLen Brown 	if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) {
10095b482a8SLen Brown 
10195b482a8SLen Brown 		/* This is the case where the source has been 'linuxized' */
10295b482a8SLen Brown 
10395b482a8SLen Brown 		return (function_name + 5);
10495b482a8SLen Brown 	}
10595b482a8SLen Brown 
10695b482a8SLen Brown 	return (function_name);
10795b482a8SLen Brown }
10895b482a8SLen Brown 
10995b482a8SLen Brown /*******************************************************************************
11095b482a8SLen Brown  *
11195b482a8SLen Brown  * FUNCTION:    acpi_debug_print
11295b482a8SLen Brown  *
11395b482a8SLen Brown  * PARAMETERS:  requested_debug_level - Requested debug print level
11495b482a8SLen Brown  *              line_number         - Caller's line number (for error output)
11595b482a8SLen Brown  *              function_name       - Caller's procedure name
11695b482a8SLen Brown  *              module_name         - Caller's module name
11795b482a8SLen Brown  *              component_id        - Caller's component ID
118ba494beeSBob Moore  *              format              - Printf format field
11995b482a8SLen Brown  *              ...                 - Optional printf arguments
12095b482a8SLen Brown  *
12195b482a8SLen Brown  * RETURN:      None
12295b482a8SLen Brown  *
12395b482a8SLen Brown  * DESCRIPTION: Print error message with prefix consisting of the module name,
12495b482a8SLen Brown  *              line number, and component ID.
12595b482a8SLen Brown  *
12695b482a8SLen Brown  ******************************************************************************/
12795b482a8SLen Brown 
12895b482a8SLen 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,...)12995b482a8SLen Brown acpi_debug_print(u32 requested_debug_level,
13095b482a8SLen Brown 		 u32 line_number,
13195b482a8SLen Brown 		 const char *function_name,
13295b482a8SLen Brown 		 const char *module_name,
13395b482a8SLen Brown 		 u32 component_id, const char *format, ...)
13495b482a8SLen Brown {
13595b482a8SLen Brown 	acpi_thread_id thread_id;
13695b482a8SLen Brown 	va_list args;
1372cb0ba70SBob Moore #ifdef ACPI_APPLICATION
1386be2d72bSBob Moore 	int fill_count;
1392cb0ba70SBob Moore #endif
14095b482a8SLen Brown 
141db38bf5aSBob Moore 	/* Check if debug output enabled */
142db38bf5aSBob Moore 
143db38bf5aSBob Moore 	if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
14495b482a8SLen Brown 		return;
14595b482a8SLen Brown 	}
14695b482a8SLen Brown 
14795b482a8SLen Brown 	/*
14895b482a8SLen Brown 	 * Thread tracking and context switch notification
14995b482a8SLen Brown 	 */
15095b482a8SLen Brown 	thread_id = acpi_os_get_thread_id();
1510dfaaa3dSBob Moore 	if (thread_id != acpi_gbl_previous_thread_id) {
15295b482a8SLen Brown 		if (ACPI_LV_THREADS & acpi_dbg_level) {
15395b482a8SLen Brown 			acpi_os_printf
15428eb3fcfSLin Ming 			    ("\n**** Context Switch from TID %u to TID %u ****\n\n",
1550dfaaa3dSBob Moore 			     (u32)acpi_gbl_previous_thread_id, (u32)thread_id);
15695b482a8SLen Brown 		}
15795b482a8SLen Brown 
1580dfaaa3dSBob Moore 		acpi_gbl_previous_thread_id = thread_id;
159bf9b448eSBob Moore 		acpi_gbl_nesting_level = 0;
16095b482a8SLen Brown 	}
16195b482a8SLen Brown 
16295b482a8SLen Brown 	/*
16395b482a8SLen Brown 	 * Display the module name, current line number, thread ID (if requested),
16495b482a8SLen Brown 	 * current procedure nesting level, and the current procedure name
16595b482a8SLen Brown 	 */
16636056d0cSBob Moore 	acpi_os_printf("%9s-%04d ", module_name, line_number);
16795b482a8SLen Brown 
1685076f005SBob Moore #ifdef ACPI_APPLICATION
169bf9b448eSBob Moore 	/*
1705076f005SBob Moore 	 * For acpi_exec/iASL only, emit the thread ID and nesting level.
171bf9b448eSBob Moore 	 * Note: nesting level is really only useful during a single-thread
172bf9b448eSBob Moore 	 * execution. Otherwise, multiple threads will keep resetting the
173bf9b448eSBob Moore 	 * level.
174bf9b448eSBob Moore 	 */
17595b482a8SLen Brown 	if (ACPI_LV_THREADS & acpi_dbg_level) {
17628eb3fcfSLin Ming 		acpi_os_printf("[%u] ", (u32)thread_id);
17795b482a8SLen Brown 	}
17895b482a8SLen Brown 
1796be2d72bSBob Moore 	fill_count = 48 - acpi_gbl_nesting_level -
1806be2d72bSBob Moore 	    strlen(acpi_ut_trim_function_name(function_name));
1816be2d72bSBob Moore 	if (fill_count < 0) {
1826be2d72bSBob Moore 		fill_count = 0;
1836be2d72bSBob Moore 	}
184bf9b448eSBob Moore 
18536056d0cSBob Moore 	acpi_os_printf("[%02d] %*s",
1866e875fa0SErik Schmauss 		       acpi_gbl_nesting_level, acpi_gbl_nesting_level + 1, " ");
1876be2d72bSBob Moore 	acpi_os_printf("%s%*s: ",
1886be2d72bSBob Moore 		       acpi_ut_trim_function_name(function_name), fill_count,
1896be2d72bSBob Moore 		       " ");
1906be2d72bSBob Moore 
1916be2d72bSBob Moore #else
192bf9b448eSBob Moore 	acpi_os_printf("%-22.22s: ", acpi_ut_trim_function_name(function_name));
1936be2d72bSBob Moore #endif
19495b482a8SLen Brown 
19595b482a8SLen Brown 	va_start(args, format);
19695b482a8SLen Brown 	acpi_os_vprintf(format, args);
19795b482a8SLen Brown 	va_end(args);
19895b482a8SLen Brown }
19995b482a8SLen Brown 
ACPI_EXPORT_SYMBOL(acpi_debug_print)20095b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_debug_print)
20195b482a8SLen Brown 
20295b482a8SLen Brown /*******************************************************************************
20395b482a8SLen Brown  *
20495b482a8SLen Brown  * FUNCTION:    acpi_debug_print_raw
20595b482a8SLen Brown  *
20695b482a8SLen Brown  * PARAMETERS:  requested_debug_level - Requested debug print level
20795b482a8SLen Brown  *              line_number         - Caller's line number
20895b482a8SLen Brown  *              function_name       - Caller's procedure name
20995b482a8SLen Brown  *              module_name         - Caller's module name
21095b482a8SLen Brown  *              component_id        - Caller's component ID
211ba494beeSBob Moore  *              format              - Printf format field
21295b482a8SLen Brown  *              ...                 - Optional printf arguments
21395b482a8SLen Brown  *
21495b482a8SLen Brown  * RETURN:      None
21595b482a8SLen Brown  *
21695b482a8SLen Brown  * DESCRIPTION: Print message with no headers. Has same interface as
21795b482a8SLen Brown  *              debug_print so that the same macros can be used.
21895b482a8SLen Brown  *
21995b482a8SLen Brown  ******************************************************************************/
22095b482a8SLen Brown void ACPI_INTERNAL_VAR_XFACE
22195b482a8SLen Brown acpi_debug_print_raw(u32 requested_debug_level,
22295b482a8SLen Brown 		     u32 line_number,
22395b482a8SLen Brown 		     const char *function_name,
22495b482a8SLen Brown 		     const char *module_name,
22595b482a8SLen Brown 		     u32 component_id, const char *format, ...)
22695b482a8SLen Brown {
22795b482a8SLen Brown 	va_list args;
22895b482a8SLen Brown 
229db38bf5aSBob Moore 	/* Check if debug output enabled */
230db38bf5aSBob Moore 
231db38bf5aSBob Moore 	if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
23295b482a8SLen Brown 		return;
23395b482a8SLen Brown 	}
23495b482a8SLen Brown 
23595b482a8SLen Brown 	va_start(args, format);
23695b482a8SLen Brown 	acpi_os_vprintf(format, args);
23795b482a8SLen Brown 	va_end(args);
23895b482a8SLen Brown }
23995b482a8SLen Brown 
ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)24095b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
24195b482a8SLen Brown 
24295b482a8SLen Brown /*******************************************************************************
24395b482a8SLen Brown  *
24495b482a8SLen Brown  * FUNCTION:    acpi_ut_trace
24595b482a8SLen Brown  *
24695b482a8SLen Brown  * PARAMETERS:  line_number         - Caller's line number
24795b482a8SLen Brown  *              function_name       - Caller's procedure name
24895b482a8SLen Brown  *              module_name         - Caller's module name
24995b482a8SLen Brown  *              component_id        - Caller's component ID
25095b482a8SLen Brown  *
25195b482a8SLen Brown  * RETURN:      None
25295b482a8SLen Brown  *
25395b482a8SLen Brown  * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
25495b482a8SLen Brown  *              set in debug_level
25595b482a8SLen Brown  *
25695b482a8SLen Brown  ******************************************************************************/
25795b482a8SLen Brown void
25895b482a8SLen Brown acpi_ut_trace(u32 line_number,
25995b482a8SLen Brown 	      const char *function_name,
26095b482a8SLen Brown 	      const char *module_name, u32 component_id)
26195b482a8SLen Brown {
26295b482a8SLen Brown 
26395b482a8SLen Brown 	acpi_gbl_nesting_level++;
26495b482a8SLen Brown 	acpi_ut_track_stack_ptr();
26595b482a8SLen Brown 
266db38bf5aSBob Moore 	/* Check if enabled up-front for performance */
267db38bf5aSBob Moore 
268db38bf5aSBob Moore 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
26995b482a8SLen Brown 		acpi_debug_print(ACPI_LV_FUNCTIONS,
270db38bf5aSBob Moore 				 line_number, function_name, module_name,
2710dfaaa3dSBob Moore 				 component_id, "%s\n",
2720dfaaa3dSBob Moore 				 acpi_gbl_function_entry_prefix);
273db38bf5aSBob Moore 	}
27495b482a8SLen Brown }
27595b482a8SLen Brown 
ACPI_EXPORT_SYMBOL(acpi_ut_trace)27695b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_ut_trace)
27795b482a8SLen Brown 
27895b482a8SLen Brown /*******************************************************************************
27995b482a8SLen Brown  *
28095b482a8SLen Brown  * FUNCTION:    acpi_ut_trace_ptr
28195b482a8SLen Brown  *
28295b482a8SLen Brown  * PARAMETERS:  line_number         - Caller's line number
28395b482a8SLen Brown  *              function_name       - Caller's procedure name
28495b482a8SLen Brown  *              module_name         - Caller's module name
28595b482a8SLen Brown  *              component_id        - Caller's component ID
286ba494beeSBob Moore  *              pointer             - Pointer to display
28795b482a8SLen Brown  *
28895b482a8SLen Brown  * RETURN:      None
28995b482a8SLen Brown  *
29095b482a8SLen Brown  * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
29195b482a8SLen Brown  *              set in debug_level
29295b482a8SLen Brown  *
29395b482a8SLen Brown  ******************************************************************************/
29495b482a8SLen Brown void
29595b482a8SLen Brown acpi_ut_trace_ptr(u32 line_number,
29695b482a8SLen Brown 		  const char *function_name,
2970dfaaa3dSBob Moore 		  const char *module_name,
2980dfaaa3dSBob Moore 		  u32 component_id, const void *pointer)
29995b482a8SLen Brown {
30068aafc35SBob Moore 
30195b482a8SLen Brown 	acpi_gbl_nesting_level++;
30295b482a8SLen Brown 	acpi_ut_track_stack_ptr();
30395b482a8SLen Brown 
304db38bf5aSBob Moore 	/* Check if enabled up-front for performance */
305db38bf5aSBob Moore 
306db38bf5aSBob Moore 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
30795b482a8SLen Brown 		acpi_debug_print(ACPI_LV_FUNCTIONS,
308db38bf5aSBob Moore 				 line_number, function_name, module_name,
3090dfaaa3dSBob Moore 				 component_id, "%s %p\n",
3100dfaaa3dSBob Moore 				 acpi_gbl_function_entry_prefix, pointer);
311db38bf5aSBob Moore 	}
31295b482a8SLen Brown }
31395b482a8SLen Brown 
31495b482a8SLen Brown /*******************************************************************************
31595b482a8SLen Brown  *
31695b482a8SLen Brown  * FUNCTION:    acpi_ut_trace_str
31795b482a8SLen Brown  *
31895b482a8SLen Brown  * PARAMETERS:  line_number         - Caller's line number
31995b482a8SLen Brown  *              function_name       - Caller's procedure name
32095b482a8SLen Brown  *              module_name         - Caller's module name
32195b482a8SLen Brown  *              component_id        - Caller's component ID
322ba494beeSBob Moore  *              string              - Additional string to display
32395b482a8SLen Brown  *
32495b482a8SLen Brown  * RETURN:      None
32595b482a8SLen Brown  *
32695b482a8SLen Brown  * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
32795b482a8SLen Brown  *              set in debug_level
32895b482a8SLen Brown  *
32995b482a8SLen Brown  ******************************************************************************/
33095b482a8SLen Brown 
33195b482a8SLen Brown void
acpi_ut_trace_str(u32 line_number,const char * function_name,const char * module_name,u32 component_id,const char * string)33295b482a8SLen Brown acpi_ut_trace_str(u32 line_number,
33395b482a8SLen Brown 		  const char *function_name,
3340dfaaa3dSBob Moore 		  const char *module_name, u32 component_id, const char *string)
33595b482a8SLen Brown {
33695b482a8SLen Brown 
33795b482a8SLen Brown 	acpi_gbl_nesting_level++;
33895b482a8SLen Brown 	acpi_ut_track_stack_ptr();
33995b482a8SLen Brown 
340db38bf5aSBob Moore 	/* Check if enabled up-front for performance */
341db38bf5aSBob Moore 
342db38bf5aSBob Moore 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
34395b482a8SLen Brown 		acpi_debug_print(ACPI_LV_FUNCTIONS,
344db38bf5aSBob Moore 				 line_number, function_name, module_name,
3450dfaaa3dSBob Moore 				 component_id, "%s %s\n",
3460dfaaa3dSBob Moore 				 acpi_gbl_function_entry_prefix, string);
347db38bf5aSBob Moore 	}
34895b482a8SLen Brown }
34995b482a8SLen Brown 
35095b482a8SLen Brown /*******************************************************************************
35195b482a8SLen Brown  *
35295b482a8SLen Brown  * FUNCTION:    acpi_ut_trace_u32
35395b482a8SLen Brown  *
35495b482a8SLen Brown  * PARAMETERS:  line_number         - Caller's line number
35595b482a8SLen Brown  *              function_name       - Caller's procedure name
35695b482a8SLen Brown  *              module_name         - Caller's module name
35795b482a8SLen Brown  *              component_id        - Caller's component ID
358ba494beeSBob Moore  *              integer             - Integer to display
35995b482a8SLen Brown  *
36095b482a8SLen Brown  * RETURN:      None
36195b482a8SLen Brown  *
36295b482a8SLen Brown  * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
36395b482a8SLen Brown  *              set in debug_level
36495b482a8SLen Brown  *
36595b482a8SLen Brown  ******************************************************************************/
36695b482a8SLen Brown 
36795b482a8SLen Brown void
acpi_ut_trace_u32(u32 line_number,const char * function_name,const char * module_name,u32 component_id,u32 integer)36895b482a8SLen Brown acpi_ut_trace_u32(u32 line_number,
36995b482a8SLen Brown 		  const char *function_name,
37095b482a8SLen Brown 		  const char *module_name, u32 component_id, u32 integer)
37195b482a8SLen Brown {
37295b482a8SLen Brown 
37395b482a8SLen Brown 	acpi_gbl_nesting_level++;
37495b482a8SLen Brown 	acpi_ut_track_stack_ptr();
37595b482a8SLen Brown 
376db38bf5aSBob Moore 	/* Check if enabled up-front for performance */
377db38bf5aSBob Moore 
378db38bf5aSBob Moore 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
37995b482a8SLen Brown 		acpi_debug_print(ACPI_LV_FUNCTIONS,
380db38bf5aSBob Moore 				 line_number, function_name, module_name,
381db38bf5aSBob Moore 				 component_id, "%s %08X\n",
3820dfaaa3dSBob Moore 				 acpi_gbl_function_entry_prefix, integer);
383db38bf5aSBob Moore 	}
38495b482a8SLen Brown }
38595b482a8SLen Brown 
38695b482a8SLen Brown /*******************************************************************************
38795b482a8SLen Brown  *
38895b482a8SLen Brown  * FUNCTION:    acpi_ut_exit
38995b482a8SLen Brown  *
39095b482a8SLen Brown  * PARAMETERS:  line_number         - Caller's line number
39195b482a8SLen Brown  *              function_name       - Caller's procedure name
39295b482a8SLen Brown  *              module_name         - Caller's module name
39395b482a8SLen Brown  *              component_id        - Caller's component ID
39495b482a8SLen Brown  *
39595b482a8SLen Brown  * RETURN:      None
39695b482a8SLen Brown  *
39795b482a8SLen Brown  * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
39895b482a8SLen Brown  *              set in debug_level
39995b482a8SLen Brown  *
40095b482a8SLen Brown  ******************************************************************************/
40195b482a8SLen Brown 
40295b482a8SLen Brown void
acpi_ut_exit(u32 line_number,const char * function_name,const char * module_name,u32 component_id)40395b482a8SLen Brown acpi_ut_exit(u32 line_number,
40495b482a8SLen Brown 	     const char *function_name,
40595b482a8SLen Brown 	     const char *module_name, u32 component_id)
40695b482a8SLen Brown {
40795b482a8SLen Brown 
408db38bf5aSBob Moore 	/* Check if enabled up-front for performance */
409db38bf5aSBob Moore 
410db38bf5aSBob Moore 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
41195b482a8SLen Brown 		acpi_debug_print(ACPI_LV_FUNCTIONS,
412db38bf5aSBob Moore 				 line_number, function_name, module_name,
4130dfaaa3dSBob Moore 				 component_id, "%s\n",
4140dfaaa3dSBob Moore 				 acpi_gbl_function_exit_prefix);
415db38bf5aSBob Moore 	}
41695b482a8SLen Brown 
417bf9b448eSBob Moore 	if (acpi_gbl_nesting_level) {
41895b482a8SLen Brown 		acpi_gbl_nesting_level--;
41995b482a8SLen Brown 	}
420bf9b448eSBob Moore }
42195b482a8SLen Brown 
ACPI_EXPORT_SYMBOL(acpi_ut_exit)42295b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_ut_exit)
42395b482a8SLen Brown 
42495b482a8SLen Brown /*******************************************************************************
42595b482a8SLen Brown  *
42695b482a8SLen Brown  * FUNCTION:    acpi_ut_status_exit
42795b482a8SLen Brown  *
42895b482a8SLen Brown  * PARAMETERS:  line_number         - Caller's line number
42995b482a8SLen Brown  *              function_name       - Caller's procedure name
43095b482a8SLen Brown  *              module_name         - Caller's module name
43195b482a8SLen Brown  *              component_id        - Caller's component ID
432ba494beeSBob Moore  *              status              - Exit status code
43395b482a8SLen Brown  *
43495b482a8SLen Brown  * RETURN:      None
43595b482a8SLen Brown  *
43695b482a8SLen Brown  * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
43795b482a8SLen Brown  *              set in debug_level. Prints exit status also.
43895b482a8SLen Brown  *
43995b482a8SLen Brown  ******************************************************************************/
44095b482a8SLen Brown void
44195b482a8SLen Brown acpi_ut_status_exit(u32 line_number,
44295b482a8SLen Brown 		    const char *function_name,
44395b482a8SLen Brown 		    const char *module_name,
44495b482a8SLen Brown 		    u32 component_id, acpi_status status)
44595b482a8SLen Brown {
44695b482a8SLen Brown 
447db38bf5aSBob Moore 	/* Check if enabled up-front for performance */
448db38bf5aSBob Moore 
449db38bf5aSBob Moore 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
45095b482a8SLen Brown 		if (ACPI_SUCCESS(status)) {
45195b482a8SLen Brown 			acpi_debug_print(ACPI_LV_FUNCTIONS,
452db38bf5aSBob Moore 					 line_number, function_name,
453db38bf5aSBob Moore 					 module_name, component_id, "%s %s\n",
4540dfaaa3dSBob Moore 					 acpi_gbl_function_exit_prefix,
45595b482a8SLen Brown 					 acpi_format_exception(status));
45695b482a8SLen Brown 		} else {
45795b482a8SLen Brown 			acpi_debug_print(ACPI_LV_FUNCTIONS,
458db38bf5aSBob Moore 					 line_number, function_name,
459db38bf5aSBob Moore 					 module_name, component_id,
460db38bf5aSBob Moore 					 "%s ****Exception****: %s\n",
4610dfaaa3dSBob Moore 					 acpi_gbl_function_exit_prefix,
46295b482a8SLen Brown 					 acpi_format_exception(status));
46395b482a8SLen Brown 		}
464db38bf5aSBob Moore 	}
46595b482a8SLen Brown 
466bf9b448eSBob Moore 	if (acpi_gbl_nesting_level) {
46795b482a8SLen Brown 		acpi_gbl_nesting_level--;
46895b482a8SLen Brown 	}
469bf9b448eSBob Moore }
47095b482a8SLen Brown 
ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)47195b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
47295b482a8SLen Brown 
47395b482a8SLen Brown /*******************************************************************************
47495b482a8SLen Brown  *
47595b482a8SLen Brown  * FUNCTION:    acpi_ut_value_exit
47695b482a8SLen Brown  *
47795b482a8SLen Brown  * PARAMETERS:  line_number         - Caller's line number
47895b482a8SLen Brown  *              function_name       - Caller's procedure name
47995b482a8SLen Brown  *              module_name         - Caller's module name
48095b482a8SLen Brown  *              component_id        - Caller's component ID
481ba494beeSBob Moore  *              value               - Value to be printed with exit msg
48295b482a8SLen Brown  *
48395b482a8SLen Brown  * RETURN:      None
48495b482a8SLen Brown  *
48595b482a8SLen Brown  * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
48695b482a8SLen Brown  *              set in debug_level. Prints exit value also.
48795b482a8SLen Brown  *
48895b482a8SLen Brown  ******************************************************************************/
48995b482a8SLen Brown void
49095b482a8SLen Brown acpi_ut_value_exit(u32 line_number,
49195b482a8SLen Brown 		   const char *function_name,
4925df7e6cbSBob Moore 		   const char *module_name, u32 component_id, u64 value)
49395b482a8SLen Brown {
49495b482a8SLen Brown 
495db38bf5aSBob Moore 	/* Check if enabled up-front for performance */
496db38bf5aSBob Moore 
497db38bf5aSBob Moore 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
49895b482a8SLen Brown 		acpi_debug_print(ACPI_LV_FUNCTIONS,
499db38bf5aSBob Moore 				 line_number, function_name, module_name,
500db38bf5aSBob Moore 				 component_id, "%s %8.8X%8.8X\n",
5010dfaaa3dSBob Moore 				 acpi_gbl_function_exit_prefix,
50295b482a8SLen Brown 				 ACPI_FORMAT_UINT64(value));
503db38bf5aSBob Moore 	}
50495b482a8SLen Brown 
505bf9b448eSBob Moore 	if (acpi_gbl_nesting_level) {
50695b482a8SLen Brown 		acpi_gbl_nesting_level--;
50795b482a8SLen Brown 	}
508bf9b448eSBob Moore }
50995b482a8SLen Brown 
ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)51095b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)
51195b482a8SLen Brown 
51295b482a8SLen Brown /*******************************************************************************
51395b482a8SLen Brown  *
51495b482a8SLen Brown  * FUNCTION:    acpi_ut_ptr_exit
51595b482a8SLen Brown  *
51695b482a8SLen Brown  * PARAMETERS:  line_number         - Caller's line number
51795b482a8SLen Brown  *              function_name       - Caller's procedure name
51895b482a8SLen Brown  *              module_name         - Caller's module name
51995b482a8SLen Brown  *              component_id        - Caller's component ID
520ba494beeSBob Moore  *              ptr                 - Pointer to display
52195b482a8SLen Brown  *
52295b482a8SLen Brown  * RETURN:      None
52395b482a8SLen Brown  *
52495b482a8SLen Brown  * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
52595b482a8SLen Brown  *              set in debug_level. Prints exit value also.
52695b482a8SLen Brown  *
52795b482a8SLen Brown  ******************************************************************************/
52895b482a8SLen Brown void
52995b482a8SLen Brown acpi_ut_ptr_exit(u32 line_number,
53095b482a8SLen Brown 		 const char *function_name,
53195b482a8SLen Brown 		 const char *module_name, u32 component_id, u8 *ptr)
53295b482a8SLen Brown {
53395b482a8SLen Brown 
534db38bf5aSBob Moore 	/* Check if enabled up-front for performance */
535db38bf5aSBob Moore 
536db38bf5aSBob Moore 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
53795b482a8SLen Brown 		acpi_debug_print(ACPI_LV_FUNCTIONS,
538db38bf5aSBob Moore 				 line_number, function_name, module_name,
5390dfaaa3dSBob Moore 				 component_id, "%s %p\n",
5400dfaaa3dSBob Moore 				 acpi_gbl_function_exit_prefix, ptr);
541db38bf5aSBob Moore 	}
54295b482a8SLen Brown 
543bf9b448eSBob Moore 	if (acpi_gbl_nesting_level) {
54495b482a8SLen Brown 		acpi_gbl_nesting_level--;
54595b482a8SLen Brown 	}
546bf9b448eSBob Moore }
54795b482a8SLen Brown 
548bab04824SLv Zheng /*******************************************************************************
549bab04824SLv Zheng  *
5504857a94dSJung-uk Kim  * FUNCTION:    acpi_ut_str_exit
5514857a94dSJung-uk Kim  *
5524857a94dSJung-uk Kim  * PARAMETERS:  line_number         - Caller's line number
5534857a94dSJung-uk Kim  *              function_name       - Caller's procedure name
5544857a94dSJung-uk Kim  *              module_name         - Caller's module name
5554857a94dSJung-uk Kim  *              component_id        - Caller's component ID
5564857a94dSJung-uk Kim  *              string              - String to display
5574857a94dSJung-uk Kim  *
5584857a94dSJung-uk Kim  * RETURN:      None
5594857a94dSJung-uk Kim  *
5604857a94dSJung-uk Kim  * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
5614857a94dSJung-uk Kim  *              set in debug_level. Prints exit value also.
5624857a94dSJung-uk Kim  *
5634857a94dSJung-uk Kim  ******************************************************************************/
5644857a94dSJung-uk Kim 
5654857a94dSJung-uk Kim void
acpi_ut_str_exit(u32 line_number,const char * function_name,const char * module_name,u32 component_id,const char * string)5664857a94dSJung-uk Kim acpi_ut_str_exit(u32 line_number,
5674857a94dSJung-uk Kim 		 const char *function_name,
5684857a94dSJung-uk Kim 		 const char *module_name, u32 component_id, const char *string)
5694857a94dSJung-uk Kim {
5704857a94dSJung-uk Kim 
5714857a94dSJung-uk Kim 	/* Check if enabled up-front for performance */
5724857a94dSJung-uk Kim 
5734857a94dSJung-uk Kim 	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
5744857a94dSJung-uk Kim 		acpi_debug_print(ACPI_LV_FUNCTIONS,
5754857a94dSJung-uk Kim 				 line_number, function_name, module_name,
5764857a94dSJung-uk Kim 				 component_id, "%s %s\n",
5774857a94dSJung-uk Kim 				 acpi_gbl_function_exit_prefix, string);
5784857a94dSJung-uk Kim 	}
5794857a94dSJung-uk Kim 
5804857a94dSJung-uk Kim 	if (acpi_gbl_nesting_level) {
5814857a94dSJung-uk Kim 		acpi_gbl_nesting_level--;
5824857a94dSJung-uk Kim 	}
5834857a94dSJung-uk Kim }
5844857a94dSJung-uk Kim 
5854857a94dSJung-uk Kim /*******************************************************************************
5864857a94dSJung-uk Kim  *
587bab04824SLv Zheng  * FUNCTION:    acpi_trace_point
588bab04824SLv Zheng  *
589bab04824SLv Zheng  * PARAMETERS:  type                - Trace event type
590bab04824SLv Zheng  *              begin               - TRUE if before execution
591bab04824SLv Zheng  *              aml                 - Executed AML address
592bab04824SLv Zheng  *              pathname            - Object path
593bab04824SLv Zheng  *              pointer             - Pointer to the related object
594bab04824SLv Zheng  *
595bab04824SLv Zheng  * RETURN:      None
596bab04824SLv Zheng  *
597bab04824SLv Zheng  * DESCRIPTION: Interpreter execution trace.
598bab04824SLv Zheng  *
599bab04824SLv Zheng  ******************************************************************************/
6002e70da4cSLv Zheng 
601bab04824SLv Zheng void
acpi_trace_point(acpi_trace_event_type type,u8 begin,u8 * aml,char * pathname)602bab04824SLv Zheng acpi_trace_point(acpi_trace_event_type type, u8 begin, u8 *aml, char *pathname)
603bab04824SLv Zheng {
604bab04824SLv Zheng 
605bab04824SLv Zheng 	ACPI_FUNCTION_ENTRY();
606bab04824SLv Zheng 
607bab04824SLv Zheng 	acpi_ex_trace_point(type, begin, aml, pathname);
608bab04824SLv Zheng 
609bab04824SLv Zheng #ifdef ACPI_USE_SYSTEM_TRACER
610bab04824SLv Zheng 	acpi_os_trace_point(type, begin, aml, pathname);
611bab04824SLv Zheng #endif
612bab04824SLv Zheng }
613bab04824SLv Zheng 
614bab04824SLv Zheng ACPI_EXPORT_SYMBOL(acpi_trace_point)
6159cf7adecSBob Moore 
616bab04824SLv Zheng #endif
617