1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2022 Loongson Technology Corporation Limited
6 #ifndef _ASM_LOONGARCH_FTRACE_H
7 #define _ASM_LOONGARCH_FTRACE_H
9 #define FTRACE_PLT_IDX 0
10 #define FTRACE_REGS_PLT_IDX 1
11 #define NR_FTRACE_PLTS 2
13 #ifdef CONFIG_FUNCTION_TRACER
15 #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
19 #ifndef CONFIG_DYNAMIC_FTRACE
21 #define mcount _mcount
22 extern void _mcount(void);
23 extern void prepare_ftrace_return(unsigned long self_addr, unsigned long callsite_sp, unsigned long old);
28 struct dyn_arch_ftrace { };
30 #define ARCH_SUPPORTS_FTRACE_OPS 1
31 #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
33 #define ftrace_init_nop ftrace_init_nop
34 int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
36 static inline unsigned long ftrace_call_adjust(unsigned long addr)
41 void prepare_ftrace_return(unsigned long self_addr, unsigned long *parent);
43 #endif /* CONFIG_DYNAMIC_FTRACE */
45 #ifdef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS
52 static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs)
57 #define ftrace_graph_func ftrace_graph_func
58 void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
59 struct ftrace_ops *op, struct ftrace_regs *fregs);
62 #endif /* __ASSEMBLY__ */
64 #endif /* CONFIG_FUNCTION_TRACER */
66 #endif /* _ASM_LOONGARCH_FTRACE_H */