Commit | Line | Data |
---|---|---|
fad57feb MF |
1 | /* |
2 | * arch/sh/lib/mcount.S | |
3 | * | |
4 | * Copyright (C) 2008 Paul Mundt | |
c1340c05 | 5 | * Copyright (C) 2008, 2009 Matt Fleming |
fad57feb MF |
6 | * |
7 | * This file is subject to the terms and conditions of the GNU General Public | |
8 | * License. See the file "COPYING" in the main directory of this archive | |
9 | * for more details. | |
10 | */ | |
11 | #include <asm/ftrace.h> | |
12 | ||
13 | #define MCOUNT_ENTER() \ | |
14 | mov.l r4, @-r15; \ | |
15 | mov.l r5, @-r15; \ | |
16 | mov.l r6, @-r15; \ | |
17 | mov.l r7, @-r15; \ | |
18 | sts.l pr, @-r15; \ | |
19 | \ | |
20 | mov.l @(20,r15),r4; \ | |
21 | sts pr, r5 | |
22 | ||
23 | #define MCOUNT_LEAVE() \ | |
24 | lds.l @r15+, pr; \ | |
25 | mov.l @r15+, r7; \ | |
26 | mov.l @r15+, r6; \ | |
27 | mov.l @r15+, r5; \ | |
28 | rts; \ | |
29 | mov.l @r15+, r4 | |
30 | ||
31 | .align 2 | |
32 | .globl _mcount | |
33 | .type _mcount,@function | |
34 | .globl mcount | |
35 | .type mcount,@function | |
36 | _mcount: | |
37 | mcount: | |
c1340c05 MF |
38 | #ifndef CONFIG_DYNAMIC_FTRACE |
39 | mov.l .Lfunction_trace_stop, r0 | |
40 | mov.l @r0, r0 | |
41 | tst r0, r0 | |
42 | bf ftrace_stub | |
43 | #endif | |
fad57feb MF |
44 | MCOUNT_ENTER() |
45 | ||
46 | #ifdef CONFIG_DYNAMIC_FTRACE | |
47 | .globl mcount_call | |
48 | mcount_call: | |
49 | mov.l .Lftrace_stub, r6 | |
50 | #else | |
51 | mov.l .Lftrace_trace_function, r6 | |
52 | mov.l ftrace_stub, r7 | |
53 | cmp/eq r6, r7 | |
54 | bt skip_trace | |
55 | mov.l @r6, r6 | |
56 | #endif | |
57 | ||
58 | jsr @r6 | |
59 | nop | |
60 | ||
61 | skip_trace: | |
62 | MCOUNT_LEAVE() | |
63 | ||
64 | .align 2 | |
65 | .Lftrace_trace_function: | |
66 | .long ftrace_trace_function | |
67 | ||
68 | #ifdef CONFIG_DYNAMIC_FTRACE | |
69 | .globl ftrace_caller | |
70 | ftrace_caller: | |
c1340c05 MF |
71 | mov.l .Lfunction_trace_stop, r0 |
72 | mov.l @r0, r0 | |
73 | tst r0, r0 | |
74 | bf ftrace_stub | |
c652d780 | 75 | |
fad57feb MF |
76 | MCOUNT_ENTER() |
77 | ||
78 | .globl ftrace_call | |
79 | ftrace_call: | |
80 | mov.l .Lftrace_stub, r6 | |
81 | jsr @r6 | |
82 | nop | |
83 | ||
84 | MCOUNT_LEAVE() | |
85 | #endif /* CONFIG_DYNAMIC_FTRACE */ | |
86 | ||
87 | /* | |
88 | * NOTE: From here on the locations of the .Lftrace_stub label and | |
89 | * ftrace_stub itself are fixed. Adding additional data here will skew | |
90 | * the displacement for the memory table and break the block replacement. | |
91 | * Place new labels either after the ftrace_stub body, or before | |
92 | * ftrace_caller. You have been warned. | |
93 | */ | |
94 | .align 2 | |
95 | .Lftrace_stub: | |
96 | .long ftrace_stub | |
97 | ||
98 | .globl ftrace_stub | |
99 | ftrace_stub: | |
100 | rts | |
101 | nop | |
c1340c05 MF |
102 | |
103 | .align 2 | |
104 | .Lfunction_trace_stop: | |
105 | .long function_trace_stop |