Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 177897
b: refs/heads/master
c: d2bb076
h: refs/heads/master
i:
  177895: 43f8299
v: v3
  • Loading branch information
Wu Zhangjin authored and Ralf Baechle committed Dec 17, 2009
1 parent c9e772a commit f0fedc8
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8922f79ee56e9dab6fc144defc0bc901ff0a7f8a
refs/heads/master: d2bb0762993e11363d8343127516b8fe88f9006f
1 change: 1 addition & 0 deletions trunk/arch/mips/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ config MIPS
select HAVE_IDE
select HAVE_OPROFILE
select HAVE_ARCH_KGDB
select HAVE_FUNCTION_TRACER
# Horrible source of confusion. Die, die, die ...
select EMBEDDED
select RTC_LIB if !MACH_LOONGSON
Expand Down
2 changes: 2 additions & 0 deletions trunk/arch/mips/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ ifneq ($(SUBARCH),$(ARCH))
endif
endif

ifndef CONFIG_FUNCTION_TRACER
cflags-y := -ffunction-sections
endif
cflags-y += $(call cc-option, -mno-check-zero-division)

ifdef CONFIG_32BIT
Expand Down
25 changes: 24 additions & 1 deletion trunk/arch/mips/include/asm/ftrace.h
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
/* empty */
/*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive for
* more details.
*
* Copyright (C) 2009 DSLab, Lanzhou University, China
* Author: Wu Zhangjin <wuzj@lemote.com>
*/

#ifndef _ASM_MIPS_FTRACE_H
#define _ASM_MIPS_FTRACE_H

#ifdef CONFIG_FUNCTION_TRACER

#define MCOUNT_ADDR ((unsigned long)(_mcount))
#define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */

#ifndef __ASSEMBLY__
extern void _mcount(void);
#define mcount _mcount

#endif /* __ASSEMBLY__ */
#endif /* CONFIG_FUNCTION_TRACER */
#endif /* _ASM_MIPS_FTRACE_H */
6 changes: 6 additions & 0 deletions trunk/arch/mips/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ obj-y += cpu-probe.o branch.o entry.o genex.o irq.o process.o \
ptrace.o reset.o setup.o signal.o syscall.o \
time.o topology.o traps.o unaligned.o watch.o

ifdef CONFIG_FUNCTION_TRACER
CFLAGS_REMOVE_early_printk.o = -pg
endif

obj-$(CONFIG_CEVT_BCM1480) += cevt-bcm1480.o
obj-$(CONFIG_CEVT_R4K_LIB) += cevt-r4k.o
obj-$(CONFIG_MIPS_MT_SMTC) += cevt-smtc.o
Expand All @@ -27,6 +31,8 @@ obj-$(CONFIG_SYNC_R4K) += sync-r4k.o
obj-$(CONFIG_STACKTRACE) += stacktrace.o
obj-$(CONFIG_MODULES) += mips_ksyms.o module.o

obj-$(CONFIG_FUNCTION_TRACER) += mcount.o

obj-$(CONFIG_CPU_LOONGSON2) += r4k_fpu.o r4k_switch.o
obj-$(CONFIG_CPU_MIPS32) += r4k_fpu.o r4k_switch.o
obj-$(CONFIG_CPU_MIPS64) += r4k_fpu.o r4k_switch.o
Expand Down
83 changes: 83 additions & 0 deletions trunk/arch/mips/kernel/mcount.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* MIPS specific _mcount support
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive for
* more details.
*
* Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University, China
* Author: Wu Zhangjin <wuzj@lemote.com>
*/

#include <asm/regdef.h>
#include <asm/stackframe.h>
#include <asm/ftrace.h>

.text
.set noreorder
.set noat

.macro MCOUNT_SAVE_REGS
PTR_SUBU sp, PT_SIZE
PTR_S ra, PT_R31(sp)
PTR_S AT, PT_R1(sp)
PTR_S a0, PT_R4(sp)
PTR_S a1, PT_R5(sp)
PTR_S a2, PT_R6(sp)
PTR_S a3, PT_R7(sp)
#ifdef CONFIG_64BIT
PTR_S a4, PT_R8(sp)
PTR_S a5, PT_R9(sp)
PTR_S a6, PT_R10(sp)
PTR_S a7, PT_R11(sp)
#endif
.endm

.macro MCOUNT_RESTORE_REGS
PTR_L ra, PT_R31(sp)
PTR_L AT, PT_R1(sp)
PTR_L a0, PT_R4(sp)
PTR_L a1, PT_R5(sp)
PTR_L a2, PT_R6(sp)
PTR_L a3, PT_R7(sp)
#ifdef CONFIG_64BIT
PTR_L a4, PT_R8(sp)
PTR_L a5, PT_R9(sp)
PTR_L a6, PT_R10(sp)
PTR_L a7, PT_R11(sp)
#endif
#ifdef CONFIG_64BIT
PTR_ADDIU sp, PT_SIZE
#else
PTR_ADDIU sp, (PT_SIZE + 8)
#endif
.endm

.macro RETURN_BACK
jr ra
move ra, AT
.endm

NESTED(_mcount, PT_SIZE, ra)
PTR_LA t0, ftrace_stub
PTR_L t1, ftrace_trace_function /* Prepare t1 for (1) */
bne t0, t1, static_trace
nop
b ftrace_stub
nop

static_trace:
MCOUNT_SAVE_REGS

move a0, ra /* arg1: next ip, selfaddr */
jalr t1 /* (1) call *ftrace_trace_function */
move a1, AT /* arg2: the caller's next ip, parent */

MCOUNT_RESTORE_REGS
.globl ftrace_stub
ftrace_stub:
RETURN_BACK
END(_mcount)

.set at
.set reorder
5 changes: 5 additions & 0 deletions trunk/arch/mips/kernel/mips_ksyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <asm/checksum.h>
#include <asm/pgtable.h>
#include <asm/uaccess.h>
#include <asm/ftrace.h>

extern void *__bzero(void *__s, size_t __count);
extern long __strncpy_from_user_nocheck_asm(char *__to,
Expand Down Expand Up @@ -51,3 +52,7 @@ EXPORT_SYMBOL(csum_partial_copy_nocheck);
EXPORT_SYMBOL(__csum_partial_copy_user);

EXPORT_SYMBOL(invalid_pte_table);
#ifdef CONFIG_FUNCTION_TRACER
/* _mcount is defined in arch/mips/kernel/mcount.S */
EXPORT_SYMBOL(_mcount);
#endif

0 comments on commit f0fedc8

Please sign in to comment.