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>
8 * csky-gcc with -pg will put the following asm after prologue:
12 * stack layout after mcount_enter in _mcount():
14 * current sp => 0:+-------+
15 * | a0-a3 | -> must save all argument regs
17 * | lr | -> _mcount lr (instrumente function's pc)
19 * | fp=r8 | -> instrumented function fp
21 * | plr | -> instrumented function lr (parent's pc)
47 .macro save_return_regs
55 .macro restore_return_regs
74 #ifndef CONFIG_DYNAMIC_FTRACE
78 /* r26 is link register, only used with jsri translation */
79 lrw r26, ftrace_trace_function
91 #ifndef CONFIG_FUNCTION_GRAPH_TRACER
96 lrw a0, ftrace_graph_return
100 bt ftrace_graph_caller
102 lrw a0, ftrace_graph_entry
104 lrw a1, ftrace_graph_entry_stub
106 bt ftrace_graph_caller
111 #else /* CONFIG_DYNAMIC_FTRACE */
130 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
132 GLOBAL(ftrace_graph_call)
137 ENDPROC(ftrace_caller)
138 #endif /* CONFIG_DYNAMIC_FTRACE */
140 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
141 ENTRY(ftrace_graph_caller)
147 lrw r26, prepare_ftrace_return
150 END(ftrace_graph_caller)
152 ENTRY(return_to_handler)
155 jsri ftrace_return_to_handler
158 END(return_to_handler)