H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_FTRACE_H |
| 2 | #define _ASM_X86_FTRACE_H |
Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 3 | |
Cyrill Gorcunov | d680fe4 | 2008-12-13 00:09:08 +0300 | [diff] [blame] | 4 | #ifdef __ASSEMBLY__ |
| 5 | |
| 6 | .macro MCOUNT_SAVE_FRAME |
| 7 | /* taken from glibc */ |
| 8 | subq $0x38, %rsp |
| 9 | movq %rax, (%rsp) |
| 10 | movq %rcx, 8(%rsp) |
| 11 | movq %rdx, 16(%rsp) |
| 12 | movq %rsi, 24(%rsp) |
| 13 | movq %rdi, 32(%rsp) |
| 14 | movq %r8, 40(%rsp) |
| 15 | movq %r9, 48(%rsp) |
| 16 | .endm |
| 17 | |
| 18 | .macro MCOUNT_RESTORE_FRAME |
| 19 | movq 48(%rsp), %r9 |
| 20 | movq 40(%rsp), %r8 |
| 21 | movq 32(%rsp), %rdi |
| 22 | movq 24(%rsp), %rsi |
| 23 | movq 16(%rsp), %rdx |
| 24 | movq 8(%rsp), %rcx |
| 25 | movq (%rsp), %rax |
| 26 | addq $0x38, %rsp |
| 27 | .endm |
| 28 | |
| 29 | #endif |
| 30 | |
Ingo Molnar | 4944dd6 | 2008-10-27 10:50:54 +0100 | [diff] [blame] | 31 | #ifdef CONFIG_FUNCTION_TRACER |
Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 32 | #define MCOUNT_ADDR ((long)(mcount)) |
| 33 | #define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */ |
| 34 | |
| 35 | #ifndef __ASSEMBLY__ |
| 36 | extern void mcount(void); |
Steven Rostedt | 68bf21a | 2008-08-14 15:45:08 -0400 | [diff] [blame] | 37 | |
| 38 | static inline unsigned long ftrace_call_adjust(unsigned long addr) |
| 39 | { |
| 40 | /* |
| 41 | * call mcount is "e8 <4 byte offset>" |
| 42 | * The addr points to the 4 byte offset and the caller of this |
| 43 | * function wants the pointer to e8. Simply subtract one. |
| 44 | */ |
| 45 | return addr - 1; |
| 46 | } |
Steven Rostedt | 31e8890 | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 47 | |
| 48 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 49 | |
| 50 | struct dyn_arch_ftrace { |
| 51 | /* No extra data needed for x86 */ |
| 52 | }; |
| 53 | |
| 54 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
Steven Rostedt | a26a2a2 | 2008-10-31 00:03:22 -0400 | [diff] [blame] | 55 | #endif /* __ASSEMBLY__ */ |
Ingo Molnar | 4944dd6 | 2008-10-27 10:50:54 +0100 | [diff] [blame] | 56 | #endif /* CONFIG_FUNCTION_TRACER */ |
Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 57 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 58 | #endif /* _ASM_X86_FTRACE_H */ |