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 t1, 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 */
80 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
81 .globl ftrace_graph_call
93 #else /* ! CONFIG_DYNAMIC_FTRACE */
95 NESTED(_mcount, PT_SIZE, ra)
96 lw t1, function_trace_stop
99 PTR_LA t1, ftrace_stub
100 PTR_L t2, ftrace_trace_function /* Prepare t2 for (1) */
101 bne t1, t2, static_trace
104 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
105 PTR_L t3, ftrace_graph_return
106 bne t1, t3, ftrace_graph_caller
108 PTR_LA t1, ftrace_graph_entry_stub
109 PTR_L t3, ftrace_graph_entry
110 bne t1, t3, ftrace_graph_caller
119 move a0, ra /* arg1: next ip, selfaddr */
120 jalr t2 /* (1) call *ftrace_trace_function */
121 move a1, AT /* arg2: the caller's next ip, parent */
129 #endif /* ! CONFIG_DYNAMIC_FTRACE */
131 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
133 NESTED(ftrace_graph_caller, PT_SIZE, ra)
134 #ifdef CONFIG_DYNAMIC_FTRACE
135 PTR_L a1, PT_R31(sp) /* load the original ra from the stack */
138 move a1, ra /* arg2: next ip, selfaddr */
140 PTR_LA a0, PT_R1(sp) /* arg1: &AT -> a0 */
141 jal prepare_ftrace_return
142 #ifdef CONFIG_FRAME_POINTER
143 move a2, fp /* arg3: frame pointer */
146 PTR_LA a2, PT_SIZE(sp)
148 PTR_LA a2, (PT_SIZE+8)(sp)
154 END(ftrace_graph_caller)
157 .globl return_to_handler
162 jal ftrace_return_to_handler
165 /* restore the real parent address: v0 -> ra */
171 PTR_ADDIU sp, PT_SIZE
172 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */