2 * MIPS specific _mcount support
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive for
8 * Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University, China
9 * Author: Wu Zhangjin <wuzj@lemote.com>
12 #include <asm/regdef.h>
13 #include <asm/stackframe.h>
14 #include <asm/ftrace.h>
20 .macro MCOUNT_SAVE_REGS
36 .macro MCOUNT_RESTORE_REGS
52 PTR_ADDIU sp, (PT_SIZE + 8)
61 #ifdef CONFIG_DYNAMIC_FTRACE
63 NESTED(ftrace_caller, PT_SIZE, ra)
68 lw t0, function_trace_stop
74 move a0, ra /* arg1: next ip, selfaddr */
77 nop /* a placeholder for the call to a real tracing function */
78 move a1, AT /* arg2: the caller's next ip, parent */
86 #else /* ! CONFIG_DYNAMIC_FTRACE */
88 NESTED(_mcount, PT_SIZE, ra)
89 lw t0, function_trace_stop
92 PTR_LA t0, ftrace_stub
93 PTR_L t1, ftrace_trace_function /* Prepare t1 for (1) */
94 bne t0, t1, static_trace
97 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
98 PTR_L t2, ftrace_graph_return
99 bne t0, t2, ftrace_graph_caller
101 PTR_LA t0, ftrace_graph_entry_stub
102 PTR_L t2, ftrace_graph_entry
103 bne t0, t2, ftrace_graph_caller
112 move a0, ra /* arg1: next ip, selfaddr */
113 jalr t1 /* (1) call *ftrace_trace_function */
114 move a1, AT /* arg2: the caller's next ip, parent */
122 #endif /* ! CONFIG_DYNAMIC_FTRACE */
124 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
126 NESTED(ftrace_graph_caller, PT_SIZE, ra)
129 PTR_LA a0, PT_R1(sp) /* arg1: &AT -> a0 */
130 move a1, ra /* arg2: next ip, selfaddr */
131 jal prepare_ftrace_return
132 move a2, fp /* arg3: frame pointer */
136 END(ftrace_graph_caller)
139 .globl return_to_handler
144 jal ftrace_return_to_handler
147 /* restore the real parent address: v0 -> ra */
153 PTR_ADDIU sp, PT_SIZE
154 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */