blob: 686c5f70eb8408059ec8d7f5b0635ac9c71690d3 [file] [log] [blame]
Steven Rostedtccbfac22008-05-22 14:31:07 -04001#ifndef _ASM_POWERPC_FTRACE
2#define _ASM_POWERPC_FTRACE
3
Michael Ellermanf55d9662016-06-06 22:26:10 +05304#include <asm/types.h>
5
Steven Rostedt606576c2008-10-06 19:06:12 -04006#ifdef CONFIG_FUNCTION_TRACER
Minfei Huangc93bf922015-07-12 17:52:24 +08007#define MCOUNT_ADDR ((unsigned long)(_mcount))
Abhishek Sagar395a59d2008-06-21 23:47:27 +05308#define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
9
Steven Rostedtbf528a32009-02-11 15:01:18 -050010#ifdef __ASSEMBLY__
11
12/* Based off of objdump optput from glibc */
13
14#define MCOUNT_SAVE_FRAME \
15 stwu r1,-48(r1); \
16 stw r3, 12(r1); \
17 stw r4, 16(r1); \
18 stw r5, 20(r1); \
19 stw r6, 24(r1); \
20 mflr r3; \
21 lwz r4, 52(r1); \
22 mfcr r5; \
23 stw r7, 28(r1); \
24 stw r8, 32(r1); \
25 stw r9, 36(r1); \
26 stw r10,40(r1); \
27 stw r3, 44(r1); \
28 stw r5, 8(r1)
29
30#define MCOUNT_RESTORE_FRAME \
31 lwz r6, 8(r1); \
32 lwz r0, 44(r1); \
33 lwz r3, 12(r1); \
34 mtctr r0; \
35 lwz r4, 16(r1); \
36 mtcr r6; \
37 lwz r5, 20(r1); \
38 lwz r6, 24(r1); \
39 lwz r0, 52(r1); \
40 lwz r7, 28(r1); \
41 lwz r8, 32(r1); \
42 mtlr r0; \
43 lwz r9, 36(r1); \
44 lwz r10,40(r1); \
45 addi r1, r1, 48
46
47#else /* !__ASSEMBLY__ */
Steven Rostedtccbfac22008-05-22 14:31:07 -040048extern void _mcount(void);
Steven Rostedt8fd6e5a2008-11-14 16:21:19 -080049
50#ifdef CONFIG_DYNAMIC_FTRACE
Torsten Duwe15308662016-03-03 15:26:59 +110051# define FTRACE_ADDR ((unsigned long)ftrace_caller)
52# define FTRACE_REGS_ADDR FTRACE_ADDR
Steven Rostedt8fd6e5a2008-11-14 16:21:19 -080053static inline unsigned long ftrace_call_adjust(unsigned long addr)
54{
55 /* reloction of mcount call site is the same as the address */
56 return addr;
57}
58
59struct dyn_arch_ftrace {
Steven Rostedtf48cb8b2008-11-14 20:47:03 -080060 struct module *mod;
Steven Rostedt8fd6e5a2008-11-14 16:21:19 -080061};
62#endif /* CONFIG_DYNAMIC_FTRACE */
63#endif /* __ASSEMBLY__ */
Steven Rostedtccbfac22008-05-22 14:31:07 -040064
Torsten Duwe15308662016-03-03 15:26:59 +110065#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
66#define ARCH_SUPPORTS_FTRACE_OPS 1
67#endif
Steven Rostedtccbfac22008-05-22 14:31:07 -040068#endif
Abhishek Sagar395a59d2008-06-21 23:47:27 +053069
Michael Ellermanf55d9662016-06-06 22:26:10 +053070#if defined(CONFIG_FTRACE_SYSCALLS) && !defined(__ASSEMBLY__)
71#ifdef PPC64_ELF_ABI_v1
Ian Munsie02424d82011-02-02 17:27:24 +000072#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
73static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
74{
75 /*
76 * Compare the symbol name with the system call name. Skip the .sys or .SyS
77 * prefix from the symbol name and the sys prefix from the system call name and
78 * just match the rest. This is only needed on ppc64 since symbol names on
79 * 32bit do not start with a period so the generic function will work.
80 */
81 return !strcmp(sym + 4, name + 3);
82}
Anton Blanchard7167af72014-02-04 16:07:20 +110083#endif
Michael Ellermanf55d9662016-06-06 22:26:10 +053084#endif /* CONFIG_FTRACE_SYSCALLS && !__ASSEMBLY__ */
Ian Munsie02424d82011-02-02 17:27:24 +000085
Abhishek Sagar395a59d2008-06-21 23:47:27 +053086#endif /* _ASM_POWERPC_FTRACE */