2 * Copyright 2012 Tilera Corporation. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
14 * TILE-Gx specific __mcount support
17 #include <linux/linkage.h>
18 #include <asm/ftrace.h>
25 .macro MCOUNT_SAVE_REGS
26 addli sp, sp, -REGSIZE
29 addli r29, sp, - (12 * REGSIZE)
32 addli sp, sp, - (13 * REGSIZE)
35 addli r29, r29, REGSIZE
36 { st r29, r0; addli r29, r29, REGSIZE }
37 { st r29, r1; addli r29, r29, REGSIZE }
38 { st r29, r2; addli r29, r29, REGSIZE }
39 { st r29, r3; addli r29, r29, REGSIZE }
40 { st r29, r4; addli r29, r29, REGSIZE }
41 { st r29, r5; addli r29, r29, REGSIZE }
42 { st r29, r6; addli r29, r29, REGSIZE }
43 { st r29, r7; addli r29, r29, REGSIZE }
44 { st r29, r8; addli r29, r29, REGSIZE }
45 { st r29, r9; addli r29, r29, REGSIZE }
46 { st r29, r10; addli r29, r29, REGSIZE }
49 .macro MCOUNT_RESTORE_REGS
50 addli r29, sp, (2 * REGSIZE)
51 { ld r0, r29; addli r29, r29, REGSIZE }
52 { ld r1, r29; addli r29, r29, REGSIZE }
53 { ld r2, r29; addli r29, r29, REGSIZE }
54 { ld r3, r29; addli r29, r29, REGSIZE }
55 { ld r4, r29; addli r29, r29, REGSIZE }
56 { ld r5, r29; addli r29, r29, REGSIZE }
57 { ld r6, r29; addli r29, r29, REGSIZE }
58 { ld r7, r29; addli r29, r29, REGSIZE }
59 { ld r8, r29; addli r29, r29, REGSIZE }
60 { ld r9, r29; addli r29, r29, REGSIZE }
61 { ld r10, r29; addli lr, sp, (13 * REGSIZE) }
62 { ld lr, lr; addli sp, sp, (14 * REGSIZE) }
66 { move r12, lr; move lr, r10 }
70 #ifdef CONFIG_DYNAMIC_FTRACE
79 STD_ENTRY(ftrace_caller)
82 /* arg1: self return address */
83 /* arg2: parent's return address */
84 /* arg3: ftrace_ops */
85 /* arg4: regs (but make it NULL) */
86 { move r0, lr; moveli r2, hw2_last(function_trace_op) }
87 { move r1, r10; shl16insli r2, r2, hw1(function_trace_op) }
88 { movei r3, 0; shl16insli r2, r2, hw0(function_trace_op) }
94 * a placeholder for the call to a real tracing function, i.e.
95 * ftrace_trace_function()
99 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
100 .global ftrace_graph_call
103 * a placeholder for the call to a real tracing function, i.e.
104 * ftrace_graph_caller()
112 STD_ENDPROC(ftrace_caller)
114 #else /* ! CONFIG_DYNAMIC_FTRACE */
119 moveli r11, hw2_last(ftrace_trace_function)
120 moveli r13, hw2_last(ftrace_stub)
123 shl16insli r11, r11, hw1(ftrace_trace_function)
124 shl16insli r13, r13, hw1(ftrace_stub)
127 shl16insli r11, r11, hw0(ftrace_trace_function)
128 shl16insli r13, r13, hw0(ftrace_stub)
133 bnez r14, static_trace
135 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
136 moveli r15, hw2_last(ftrace_graph_return)
137 shl16insli r15, r15, hw1(ftrace_graph_return)
138 shl16insli r15, r15, hw0(ftrace_graph_return)
141 bnez r15, ftrace_graph_caller
144 moveli r16, hw2_last(ftrace_graph_entry)
145 moveli r17, hw2_last(ftrace_graph_entry_stub)
148 shl16insli r16, r16, hw1(ftrace_graph_entry)
149 shl16insli r17, r17, hw1(ftrace_graph_entry_stub)
152 shl16insli r16, r16, hw0(ftrace_graph_entry)
153 shl16insli r17, r17, hw0(ftrace_graph_entry_stub)
157 bnez r17, ftrace_graph_caller
165 /* arg1: self return address */
166 /* arg2: parent's return address */
167 { move r0, lr; move r1, r10 }
169 /* call ftrace_trace_function() */
177 STD_ENDPROC(__mcount)
179 #endif /* ! CONFIG_DYNAMIC_FTRACE */
181 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
183 STD_ENTRY(ftrace_graph_caller)
185 #ifndef CONFIG_DYNAMIC_FTRACE
189 /* arg1: Get the location of the parent's return address */
190 addi r0, sp, 12 * REGSIZE
191 /* arg2: Get self return address */
194 jal prepare_ftrace_return
198 STD_ENDPROC(ftrace_graph_caller)
200 .global return_to_handler
204 jal ftrace_return_to_handler
205 /* restore the real parent address */
211 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */