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
67 .macro save_return_regs
75 .macro restore_return_regs
94 #ifndef CONFIG_DYNAMIC_FTRACE
98 /* r26 is link register, only used with jsri translation */
99 lrw r26, ftrace_trace_function
108 lrw a2, function_trace_op
113 #ifndef CONFIG_FUNCTION_GRAPH_TRACER
118 lrw a0, ftrace_graph_return
122 bt ftrace_graph_caller
124 lrw a0, ftrace_graph_entry
126 lrw a1, ftrace_graph_entry_stub
128 bt ftrace_graph_caller
133 #else /* CONFIG_DYNAMIC_FTRACE */
147 lrw a2, function_trace_op
154 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
156 GLOBAL(ftrace_graph_call)
161 ENDPROC(ftrace_caller)
162 #endif /* CONFIG_DYNAMIC_FTRACE */
164 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
165 ENTRY(ftrace_graph_caller)
171 lrw r26, prepare_ftrace_return
174 END(ftrace_graph_caller)
176 ENTRY(return_to_handler)
179 jsri ftrace_return_to_handler
182 END(return_to_handler)
185 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
186 ENTRY(ftrace_regs_caller)
189 lrw t1, PT_FRAME_SIZE
195 lrw a2, function_trace_op
200 GLOBAL(ftrace_regs_call)
203 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
205 GLOBAL(ftrace_graph_regs_call)
210 ENDPROC(ftrace_regs_caller)
211 #endif /* CONFIG_DYNAMIC_FTRACE */