blob: 50ca7585abe2563af6e9c421d8050d2df5f82411 [file] [log] [blame]
Steven Rostedtccbfac22008-05-22 14:31:07 -04001#ifndef _ASM_POWERPC_FTRACE
2#define _ASM_POWERPC_FTRACE
3
Steven Rostedt606576c2008-10-06 19:06:12 -04004#ifdef CONFIG_FUNCTION_TRACER
Minfei Huangc93bf922015-07-12 17:52:24 +08005#define MCOUNT_ADDR ((unsigned long)(_mcount))
Abhishek Sagar395a59d2008-06-21 23:47:27 +05306#define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
7
Steven Rostedtbf528a32009-02-11 15:01:18 -05008#ifdef __ASSEMBLY__
9
10/* Based off of objdump optput from glibc */
11
12#define MCOUNT_SAVE_FRAME \
13 stwu r1,-48(r1); \
14 stw r3, 12(r1); \
15 stw r4, 16(r1); \
16 stw r5, 20(r1); \
17 stw r6, 24(r1); \
18 mflr r3; \
19 lwz r4, 52(r1); \
20 mfcr r5; \
21 stw r7, 28(r1); \
22 stw r8, 32(r1); \
23 stw r9, 36(r1); \
24 stw r10,40(r1); \
25 stw r3, 44(r1); \
26 stw r5, 8(r1)
27
28#define MCOUNT_RESTORE_FRAME \
29 lwz r6, 8(r1); \
30 lwz r0, 44(r1); \
31 lwz r3, 12(r1); \
32 mtctr r0; \
33 lwz r4, 16(r1); \
34 mtcr r6; \
35 lwz r5, 20(r1); \
36 lwz r6, 24(r1); \
37 lwz r0, 52(r1); \
38 lwz r7, 28(r1); \
39 lwz r8, 32(r1); \
40 mtlr r0; \
41 lwz r9, 36(r1); \
42 lwz r10,40(r1); \
43 addi r1, r1, 48
44
45#else /* !__ASSEMBLY__ */
Steven Rostedtccbfac22008-05-22 14:31:07 -040046extern void _mcount(void);
Steven Rostedt8fd6e5a2008-11-14 16:21:19 -080047
48#ifdef CONFIG_DYNAMIC_FTRACE
Torsten Duwe15308662016-03-03 15:26:59 +110049# define FTRACE_ADDR ((unsigned long)ftrace_caller)
50# define FTRACE_REGS_ADDR FTRACE_ADDR
Steven Rostedt8fd6e5a2008-11-14 16:21:19 -080051static inline unsigned long ftrace_call_adjust(unsigned long addr)
52{
53 /* reloction of mcount call site is the same as the address */
54 return addr;
55}
56
57struct dyn_arch_ftrace {
Steven Rostedtf48cb8b2008-11-14 20:47:03 -080058 struct module *mod;
Steven Rostedt8fd6e5a2008-11-14 16:21:19 -080059};
60#endif /* CONFIG_DYNAMIC_FTRACE */
61#endif /* __ASSEMBLY__ */
Steven Rostedtccbfac22008-05-22 14:31:07 -040062
Torsten Duwe15308662016-03-03 15:26:59 +110063#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
64#define ARCH_SUPPORTS_FTRACE_OPS 1
65#endif
Steven Rostedtccbfac22008-05-22 14:31:07 -040066#endif
Abhishek Sagar395a59d2008-06-21 23:47:27 +053067
Ian Munsie02424d82011-02-02 17:27:24 +000068#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64) && !defined(__ASSEMBLY__)
Anton Blanchard7167af72014-02-04 16:07:20 +110069#if !defined(_CALL_ELF) || _CALL_ELF != 2
Ian Munsie02424d82011-02-02 17:27:24 +000070#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
71static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
72{
73 /*
74 * Compare the symbol name with the system call name. Skip the .sys or .SyS
75 * prefix from the symbol name and the sys prefix from the system call name and
76 * just match the rest. This is only needed on ppc64 since symbol names on
77 * 32bit do not start with a period so the generic function will work.
78 */
79 return !strcmp(sym + 4, name + 3);
80}
Anton Blanchard7167af72014-02-04 16:07:20 +110081#endif
Ian Munsie02424d82011-02-02 17:27:24 +000082#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 && !__ASSEMBLY__ */
83
Abhishek Sagar395a59d2008-06-21 23:47:27 +053084#endif /* _ASM_POWERPC_FTRACE */