aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/Kconfig1
-rw-r--r--arch/mips/Makefile2
-rw-r--r--arch/mips/include/asm/ftrace.h25
-rw-r--r--arch/mips/kernel/Makefile6
-rw-r--r--arch/mips/kernel/mcount.S83
-rw-r--r--arch/mips/kernel/mips_ksyms.c5
6 files changed, 121 insertions, 1 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 435838ec9591..632dba2ac300 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -5,6 +5,7 @@ config MIPS
5 select HAVE_IDE 5 select HAVE_IDE
6 select HAVE_OPROFILE 6 select HAVE_OPROFILE
7 select HAVE_ARCH_KGDB 7 select HAVE_ARCH_KGDB
8 select HAVE_FUNCTION_TRACER
8 # Horrible source of confusion. Die, die, die ... 9 # Horrible source of confusion. Die, die, die ...
9 select EMBEDDED 10 select EMBEDDED
10 select RTC_LIB if !MACH_LOONGSON 11 select RTC_LIB if !MACH_LOONGSON
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 0a7e6146bb4b..3725ee923d05 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -48,7 +48,9 @@ ifneq ($(SUBARCH),$(ARCH))
48 endif 48 endif
49endif 49endif
50 50
51ifndef CONFIG_FUNCTION_TRACER
51cflags-y := -ffunction-sections 52cflags-y := -ffunction-sections
53endif
52cflags-y += $(call cc-option, -mno-check-zero-division) 54cflags-y += $(call cc-option, -mno-check-zero-division)
53 55
54ifdef CONFIG_32BIT 56ifdef CONFIG_32BIT
diff --git a/arch/mips/include/asm/ftrace.h b/arch/mips/include/asm/ftrace.h
index 40a8c178f10d..5f8ebcf9fa61 100644
--- a/arch/mips/include/asm/ftrace.h
+++ b/arch/mips/include/asm/ftrace.h
@@ -1 +1,24 @@
1/* empty */ 1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive for
4 * more details.
5 *
6 * Copyright (C) 2009 DSLab, Lanzhou University, China
7 * Author: Wu Zhangjin <wuzj@lemote.com>
8 */
9
10#ifndef _ASM_MIPS_FTRACE_H
11#define _ASM_MIPS_FTRACE_H
12
13#ifdef CONFIG_FUNCTION_TRACER
14
15#define MCOUNT_ADDR ((unsigned long)(_mcount))
16#define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
17
18#ifndef __ASSEMBLY__
19extern void _mcount(void);
20#define mcount _mcount
21
22#endif /* __ASSEMBLY__ */
23#endif /* CONFIG_FUNCTION_TRACER */
24#endif /* _ASM_MIPS_FTRACE_H */
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index f442de804d8a..1340ba3dd38d 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -10,6 +10,10 @@ obj-y += cpu-probe.o branch.o entry.o genex.o irq.o process.o \
10 ptrace.o reset.o setup.o signal.o syscall.o \ 10 ptrace.o reset.o setup.o signal.o syscall.o \
11 time.o topology.o traps.o unaligned.o watch.o 11 time.o topology.o traps.o unaligned.o watch.o
12 12
13ifdef CONFIG_FUNCTION_TRACER
14CFLAGS_REMOVE_early_printk.o = -pg
15endif
16
13obj-$(CONFIG_CEVT_BCM1480) += cevt-bcm1480.o 17obj-$(CONFIG_CEVT_BCM1480) += cevt-bcm1480.o
14obj-$(CONFIG_CEVT_R4K_LIB) += cevt-r4k.o 18obj-$(CONFIG_CEVT_R4K_LIB) += cevt-r4k.o
15obj-$(CONFIG_MIPS_MT_SMTC) += cevt-smtc.o 19obj-$(CONFIG_MIPS_MT_SMTC) += cevt-smtc.o
@@ -27,6 +31,8 @@ obj-$(CONFIG_SYNC_R4K) += sync-r4k.o
27obj-$(CONFIG_STACKTRACE) += stacktrace.o 31obj-$(CONFIG_STACKTRACE) += stacktrace.o
28obj-$(CONFIG_MODULES) += mips_ksyms.o module.o 32obj-$(CONFIG_MODULES) += mips_ksyms.o module.o
29 33
34obj-$(CONFIG_FUNCTION_TRACER) += mcount.o
35
30obj-$(CONFIG_CPU_LOONGSON2) += r4k_fpu.o r4k_switch.o 36obj-$(CONFIG_CPU_LOONGSON2) += r4k_fpu.o r4k_switch.o
31obj-$(CONFIG_CPU_MIPS32) += r4k_fpu.o r4k_switch.o 37obj-$(CONFIG_CPU_MIPS32) += r4k_fpu.o r4k_switch.o
32obj-$(CONFIG_CPU_MIPS64) += r4k_fpu.o r4k_switch.o 38obj-$(CONFIG_CPU_MIPS64) += r4k_fpu.o r4k_switch.o
diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S
new file mode 100644
index 000000000000..cebcc3c11305
--- /dev/null
+++ b/arch/mips/kernel/mcount.S
@@ -0,0 +1,83 @@
1/*
2 * MIPS specific _mcount support
3 *
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
6 * more details.
7 *
8 * Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University, China
9 * Author: Wu Zhangjin <wuzj@lemote.com>
10 */
11
12#include <asm/regdef.h>
13#include <asm/stackframe.h>
14#include <asm/ftrace.h>
15
16 .text
17 .set noreorder
18 .set noat
19
20 .macro MCOUNT_SAVE_REGS
21 PTR_SUBU sp, PT_SIZE
22 PTR_S ra, PT_R31(sp)
23 PTR_S AT, PT_R1(sp)
24 PTR_S a0, PT_R4(sp)
25 PTR_S a1, PT_R5(sp)
26 PTR_S a2, PT_R6(sp)
27 PTR_S a3, PT_R7(sp)
28#ifdef CONFIG_64BIT
29 PTR_S a4, PT_R8(sp)
30 PTR_S a5, PT_R9(sp)
31 PTR_S a6, PT_R10(sp)
32 PTR_S a7, PT_R11(sp)
33#endif
34 .endm
35
36 .macro MCOUNT_RESTORE_REGS
37 PTR_L ra, PT_R31(sp)
38 PTR_L AT, PT_R1(sp)
39 PTR_L a0, PT_R4(sp)
40 PTR_L a1, PT_R5(sp)
41 PTR_L a2, PT_R6(sp)
42 PTR_L a3, PT_R7(sp)
43#ifdef CONFIG_64BIT
44 PTR_L a4, PT_R8(sp)
45 PTR_L a5, PT_R9(sp)
46 PTR_L a6, PT_R10(sp)
47 PTR_L a7, PT_R11(sp)
48#endif
49#ifdef CONFIG_64BIT
50 PTR_ADDIU sp, PT_SIZE
51#else
52 PTR_ADDIU sp, (PT_SIZE + 8)
53#endif
54.endm
55
56 .macro RETURN_BACK
57 jr ra
58 move ra, AT
59 .endm
60
61NESTED(_mcount, PT_SIZE, ra)
62 PTR_LA t0, ftrace_stub
63 PTR_L t1, ftrace_trace_function /* Prepare t1 for (1) */
64 bne t0, t1, static_trace
65 nop
66 b ftrace_stub
67 nop
68
69static_trace:
70 MCOUNT_SAVE_REGS
71
72 move a0, ra /* arg1: next ip, selfaddr */
73 jalr t1 /* (1) call *ftrace_trace_function */
74 move a1, AT /* arg2: the caller's next ip, parent */
75
76 MCOUNT_RESTORE_REGS
77 .globl ftrace_stub
78ftrace_stub:
79 RETURN_BACK
80 END(_mcount)
81
82 .set at
83 .set reorder
diff --git a/arch/mips/kernel/mips_ksyms.c b/arch/mips/kernel/mips_ksyms.c
index 225755d0c1f6..1d04807874db 100644
--- a/arch/mips/kernel/mips_ksyms.c
+++ b/arch/mips/kernel/mips_ksyms.c
@@ -13,6 +13,7 @@
13#include <asm/checksum.h> 13#include <asm/checksum.h>
14#include <asm/pgtable.h> 14#include <asm/pgtable.h>
15#include <asm/uaccess.h> 15#include <asm/uaccess.h>
16#include <asm/ftrace.h>
16 17
17extern void *__bzero(void *__s, size_t __count); 18extern void *__bzero(void *__s, size_t __count);
18extern long __strncpy_from_user_nocheck_asm(char *__to, 19extern long __strncpy_from_user_nocheck_asm(char *__to,
@@ -51,3 +52,7 @@ EXPORT_SYMBOL(csum_partial_copy_nocheck);
51EXPORT_SYMBOL(__csum_partial_copy_user); 52EXPORT_SYMBOL(__csum_partial_copy_user);
52 53
53EXPORT_SYMBOL(invalid_pte_table); 54EXPORT_SYMBOL(invalid_pte_table);
55#ifdef CONFIG_FUNCTION_TRACER
56/* _mcount is defined in arch/mips/kernel/mcount.S */
57EXPORT_SYMBOL(_mcount);
58#endif