Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright (C) 2000 Anton Blanchard (anton@linuxcare.com) | |
3 | * | |
4 | * This file implements mcount(), which is used to collect profiling data. | |
5 | * This can also be tweaked for kernel stack overflow detection. | |
6 | */ | |
7 | ||
1da177e4 | 8 | #include <linux/linkage.h> |
d3867f04 | 9 | #include <asm/export.h> |
1da177e4 | 10 | |
1da177e4 LT |
11 | /* |
12 | * This is the main variant and is called by C code. GCC's -pg option | |
13 | * automatically instruments every C function with a call to this. | |
14 | */ | |
15 | ||
1da177e4 | 16 | .text |
d05f5f99 DM |
17 | .align 32 |
18 | .globl _mcount | |
19 | .type _mcount,#function | |
d3867f04 | 20 | EXPORT_SYMBOL(_mcount) |
d05f5f99 DM |
21 | .globl mcount |
22 | .type mcount,#function | |
1da177e4 | 23 | _mcount: |
d05f5f99 | 24 | mcount: |
606576ce | 25 | #ifdef CONFIG_FUNCTION_TRACER |
d05f5f99 | 26 | #ifdef CONFIG_DYNAMIC_FTRACE |
63b75495 | 27 | /* Do nothing, the retl/nop below is all we need. */ |
d05f5f99 | 28 | #else |
2563b9d9 | 29 | sethi %hi(ftrace_trace_function), %g1 |
d05f5f99 DM |
30 | sethi %hi(ftrace_stub), %g2 |
31 | ldx [%g1 + %lo(ftrace_trace_function)], %g1 | |
32 | or %g2, %lo(ftrace_stub), %g2 | |
33 | cmp %g1, %g2 | |
34 | be,pn %icc, 1f | |
9960e9e8 | 35 | mov %i7, %g3 |
035df35d | 36 | save %sp, -176, %sp |
9960e9e8 | 37 | mov %g3, %o1 |
a71d1d6b DM |
38 | jmpl %g1, %o7 |
39 | mov %i7, %o0 | |
40 | ret | |
41 | restore | |
d05f5f99 DM |
42 | /* not reached */ |
43 | 1: | |
9960e9e8 DM |
44 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
45 | sethi %hi(ftrace_graph_return), %g1 | |
46 | ldx [%g1 + %lo(ftrace_graph_return)], %g3 | |
47 | cmp %g2, %g3 | |
48 | bne,pn %xcc, 5f | |
49 | sethi %hi(ftrace_graph_entry_stub), %g2 | |
50 | sethi %hi(ftrace_graph_entry), %g1 | |
51 | or %g2, %lo(ftrace_graph_entry_stub), %g2 | |
52 | ldx [%g1 + %lo(ftrace_graph_entry)], %g1 | |
53 | cmp %g1, %g2 | |
54 | be,pt %xcc, 2f | |
55 | nop | |
56 | 5: mov %i7, %g2 | |
57 | mov %fp, %g3 | |
035df35d | 58 | save %sp, -176, %sp |
9960e9e8 DM |
59 | mov %g2, %l0 |
60 | ba,pt %xcc, ftrace_graph_caller | |
61 | mov %g3, %l1 | |
62 | #endif | |
63 | 2: | |
1da177e4 | 64 | #endif |
d05f5f99 DM |
65 | #endif |
66 | retl | |
1da177e4 | 67 | nop |
d05f5f99 DM |
68 | .size _mcount,.-_mcount |
69 | .size mcount,.-mcount | |
70 | ||
606576ce | 71 | #ifdef CONFIG_FUNCTION_TRACER |
d05f5f99 DM |
72 | .globl ftrace_stub |
73 | .type ftrace_stub,#function | |
74 | ftrace_stub: | |
75 | retl | |
76 | nop | |
77 | .size ftrace_stub,.-ftrace_stub | |
78 | #ifdef CONFIG_DYNAMIC_FTRACE | |
79 | .globl ftrace_caller | |
80 | .type ftrace_caller,#function | |
81 | ftrace_caller: | |
a71d1d6b | 82 | mov %i7, %g2 |
2563b9d9 | 83 | mov %fp, %g3 |
035df35d | 84 | save %sp, -176, %sp |
a71d1d6b | 85 | mov %g2, %o1 |
9960e9e8 DM |
86 | mov %g2, %l0 |
87 | mov %g3, %l1 | |
d05f5f99 DM |
88 | .globl ftrace_call |
89 | ftrace_call: | |
90 | call ftrace_stub | |
a71d1d6b | 91 | mov %i7, %o0 |
9960e9e8 DM |
92 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
93 | .globl ftrace_graph_call | |
94 | ftrace_graph_call: | |
95 | call ftrace_stub | |
96 | nop | |
97 | #endif | |
a71d1d6b DM |
98 | ret |
99 | restore | |
9960e9e8 DM |
100 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
101 | .size ftrace_graph_call,.-ftrace_graph_call | |
102 | #endif | |
63b75495 | 103 | .size ftrace_call,.-ftrace_call |
d05f5f99 DM |
104 | .size ftrace_caller,.-ftrace_caller |
105 | #endif | |
106 | #endif | |
9960e9e8 DM |
107 | |
108 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | |
109 | ENTRY(ftrace_graph_caller) | |
110 | mov %l0, %o0 | |
111 | mov %i7, %o1 | |
112 | call prepare_ftrace_return | |
113 | mov %l1, %o2 | |
114 | ret | |
115 | restore %o0, -8, %i7 | |
116 | END(ftrace_graph_caller) | |
117 | ||
118 | ENTRY(return_to_handler) | |
035df35d | 119 | save %sp, -176, %sp |
9960e9e8 DM |
120 | call ftrace_return_to_handler |
121 | mov %fp, %o0 | |
122 | jmpl %o0 + 8, %g0 | |
123 | restore | |
124 | END(return_to_handler) | |
125 | #endif |