2 * Low-level ftrace handling
4 * Copyright (C) 2009 Michal Simek <monstr@monstr.eu>
5 * Copyright (C) 2009 PetaLogix
7 * This file is subject to the terms and conditions of the GNU General
8 * Public License. See the file COPYING in the main directory of this
9 * archive for more details.
12 #include <linux/linkage.h>
14 #define NOALIGN_ENTRY(name) .globl name; name:
16 /* FIXME MS: I think that I don't need to save all regs */
49 #define RESTORE_REGS \
86 #ifdef CONFIG_DYNAMIC_FTRACE
88 /* MS: It is just barrier which is removed from C code */
91 #endif /* CONFIG_DYNAMIC_FTRACE */
94 /* MS: HAVE_FUNCTION_TRACE_MCOUNT_TEST begin of checking */
95 lwi r5, r0, function_trace_stop;
98 /* MS: HAVE_FUNCTION_TRACE_MCOUNT_TEST end of checking */
99 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
100 #ifndef CONFIG_DYNAMIC_FTRACE
101 lwi r5, r0, ftrace_graph_return;
102 addik r6, r0, ftrace_stub; /* asm implementation */
103 cmpu r5, r5, r6; /* ftrace_graph_return != ftrace_stub */
104 beqid r5, end_graph_tracer;
107 lwi r6, r0, ftrace_graph_entry;
108 addik r5, r0, ftrace_graph_entry_stub; /* implemented in C */
109 cmpu r5, r5, r6; /* ftrace_graph_entry != ftrace_graph_entry_stub */
110 beqid r5, end_graph_tracer;
112 #else /* CONFIG_DYNAMIC_FTRACE */
113 NOALIGN_ENTRY(ftrace_call_graph)
114 /* MS: jump over graph function - replaced from C code */
116 #endif /* CONFIG_DYNAMIC_FTRACE */
117 addik r5, r1, 120; /* MS: load parent addr */
118 addik r6, r15, 0; /* MS: load current function addr */
119 bralid r15, prepare_ftrace_return;
121 /* MS: graph was taken that's why - can jump over function trace */
125 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
126 #ifndef CONFIG_DYNAMIC_FTRACE
127 /* MS: test function trace if is taken or not */
128 lwi r20, r0, ftrace_trace_function;
129 addik r6, r0, ftrace_stub;
130 cmpu r5, r20, r6; /* ftrace_trace_function != ftrace_stub */
131 beqid r5, end; /* MS: not taken -> jump over */
133 #else /* CONFIG_DYNAMIC_FTRACE */
134 NOALIGN_ENTRY(ftrace_call)
135 /* instruction for setup imm FUNC_part1, addik r20, r0, FUNC_part2 */
138 #endif /* CONFIG_DYNAMIC_FTRACE */
139 /* static normal trace */
140 lwi r6, r1, 120; /* MS: load parent addr */
141 addik r5, r15, 0; /* MS: load current function addr */
142 /* MS: here is dependency on previous code */
143 brald r15, r20; /* MS: jump to ftrace handler */
149 rtsd r15, 8; /* MS: jump back */
152 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
153 ENTRY(return_to_handler)
154 nop; /* MS: just barrier for rtsd r15, 8 */
159 /* MS: find out returning address */
160 bralid r15, ftrace_return_to_handler;
163 /* MS: return value from ftrace_return_to_handler is my returning addr
164 * must be before restore regs because I have to restore r3 content */
168 rtsd r15, 8; /* MS: jump back */
170 #endif /* CONFIG_FUNCTION_TRACER */