1 /* SPDX-License-Identifier: GPL-2.0 */
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
4 #include <linux/linkage.h>
5 #include <asm/ftrace.h>
7 #include <asm/asm-offsets.h>
10 * csky-gcc with -pg will put the following asm after prologue:
14 * stack layout after mcount_enter in _mcount():
16 * current sp => 0:+-------+
17 * | a0-a3 | -> must save all argument regs
19 * | lr | -> _mcount lr (instrumente function's pc)
21 * | fp=r8 | -> instrumented function fp
23 * | plr | -> instrumented function lr (parent's pc)
49 .macro mcount_enter_regs
56 .macro mcount_exit_regs
65 .macro save_return_regs
73 .macro restore_return_regs
92 #ifndef CONFIG_DYNAMIC_FTRACE
96 /* r26 is link register, only used with jsri translation */
97 lrw r26, ftrace_trace_function
106 lrw a2, function_trace_op
111 #ifndef CONFIG_FUNCTION_GRAPH_TRACER
116 lrw a0, ftrace_graph_return
120 bt ftrace_graph_caller
122 lrw a0, ftrace_graph_entry
124 lrw a1, ftrace_graph_entry_stub
126 bt ftrace_graph_caller
131 #else /* CONFIG_DYNAMIC_FTRACE */
145 lrw a2, function_trace_op
152 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
154 GLOBAL(ftrace_graph_call)
159 ENDPROC(ftrace_caller)
160 #endif /* CONFIG_DYNAMIC_FTRACE */
162 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
163 ENTRY(ftrace_graph_caller)
169 lrw r26, prepare_ftrace_return
172 END(ftrace_graph_caller)
174 ENTRY(return_to_handler)
177 jsri ftrace_return_to_handler
180 END(return_to_handler)
183 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
184 ENTRY(ftrace_regs_caller)
187 lrw t1, PT_FRAME_SIZE
193 lrw a2, function_trace_op
198 GLOBAL(ftrace_regs_call)
201 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
203 GLOBAL(ftrace_graph_regs_call)
208 ENDPROC(ftrace_regs_caller)
209 #endif /* CONFIG_DYNAMIC_FTRACE */