1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * This file is subject to the terms and conditions of the GNU General Public
4  * License.  See the file "COPYING" in the main directory of this archive for
5  * more details.
6  *
7  * Author: Huacai Chen <chenhuacai@loongson.cn>
8  * Copyright (C) 2020 Loongson Technology Co., Ltd.
9  */
10 
11 #ifndef _ASM_LOONGARCH_FTRACE_H
12 #define _ASM_LOONGARCH_FTRACE_H
13 
14 #define FTRACE_PLT_IDX		0
15 #define FTRACE_REGS_PLT_IDX	1
16 #define NR_FTRACE_PLTS		2
17 
18 #ifdef CONFIG_FUNCTION_TRACER
19 #define MCOUNT_INSN_SIZE 4		/* sizeof mcount call */
20 
21 #ifndef __ASSEMBLY__
22 #ifndef CONFIG_DYNAMIC_FTRACE
23 extern void _mcount(void);
24 #define mcount _mcount
25 #endif
26 
27 #ifdef CONFIG_DYNAMIC_FTRACE
28 #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
ftrace_call_adjust(unsigned long addr)29 static inline unsigned long ftrace_call_adjust(unsigned long addr)
30 {
31 	return addr;
32 }
33 
34 struct dyn_arch_ftrace {
35 };
36 
37 struct dyn_ftrace;
38 int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
39 #define ftrace_init_nop ftrace_init_nop
40 
41 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
42 #define ARCH_SUPPORTS_FTRACE_OPS 1
43 #endif
44 #endif /* CONFIG_DYNAMIC_FTRACE */
45 #endif /* __ASSEMBLY__ */
46 #endif /* CONFIG_FUNCTION_TRACER */
47 #endif /* _ASM_LOONGARCH_FTRACE_H */
48