2 * Split from entry_32.S
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; either version
7 * 2 of the License, or (at your option) any later version.
10 #include <linux/magic.h>
12 #include <asm/ppc_asm.h>
13 #include <asm/asm-offsets.h>
14 #include <asm/ftrace.h>
15 #include <asm/export.h>
17 #ifdef CONFIG_DYNAMIC_FTRACE
21 * It is required that _mcount on PPC32 must preserve the
22 * link register. But we have r0 to play with. We use r0
23 * to push the return address back to the caller of mcount
24 * into the ctr register, restore the link register and
25 * then jump back using the ctr register.
33 _GLOBAL(ftrace_caller)
35 /* r3 ends up with link register */
36 subi r3, r3, MCOUNT_INSN_SIZE
41 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
42 .globl ftrace_graph_call
45 _GLOBAL(ftrace_graph_stub)
48 /* old link register ends up in ctr reg */
56 subi r3, r3, MCOUNT_INSN_SIZE
57 LOAD_REG_ADDR(r5, ftrace_trace_function)
64 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
70 EXPORT_SYMBOL(_mcount)
75 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
76 _GLOBAL(ftrace_graph_caller)
77 /* load r4 with local address */
79 subi r4, r4, MCOUNT_INSN_SIZE
81 /* Grab the LR out of the caller stack frame */
84 bl prepare_ftrace_return
88 * prepare_ftrace_return gives us the address we divert to.
89 * Change the LR in the callers stack frame to this.
94 /* old link register ends up in ctr reg */
97 _GLOBAL(return_to_handler)
98 /* need to save return values */
105 bl ftrace_return_to_handler
108 /* return value has real return address */
116 /* Jump back to real return address */
118 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */