1/*
2 * Copyright (C) 2008 Imagination Technologies Ltd.
3 * Licensed under the GPL
4 *
5 */
6
7#include <asm/ftrace.h>
8
9	.text
10#ifdef CONFIG_DYNAMIC_FTRACE
11	.global	_mcount_wrapper
12	.type	_mcount_wrapper,function
13_mcount_wrapper:
14	MOV	PC,D0.4
15
16	.global _ftrace_caller
17	.type	_ftrace_caller,function
18_ftrace_caller:
19	MSETL   [A0StP], D0Ar6, D0Ar4, D0Ar2, D0.4
20	MOV     D1Ar1, D0.4
21	MOV     D0Ar2, D1RtP
22	SUB	D1Ar1,D1Ar1,#MCOUNT_INSN_SIZE
23
24	.global _ftrace_call
25_ftrace_call:
26	MOVT	D1RtP,#HI(_ftrace_stub)
27	CALL	D1RtP,#LO(_ftrace_stub)
28	GETL    D0.4,  D1RtP, [A0StP++#(-8)]
29	GETL    D0Ar2, D1Ar1, [A0StP++#(-8)]
30	GETL    D0Ar4, D1Ar3, [A0StP++#(-8)]
31	GETL    D0Ar6, D1Ar5, [A0StP++#(-8)]
32	MOV     PC, D0.4
33#else
34
35	.global	_mcount_wrapper
36	.type	_mcount_wrapper,function
37_mcount_wrapper:
38	MSETL   [A0StP], D0Ar6, D0Ar4, D0Ar2, D0.4
39	MOV     D1Ar1, D0.4
40	MOV     D0Ar2, D1RtP
41	MOVT    D0Re0,#HI(_ftrace_trace_function)
42	ADD	D0Re0,D0Re0,#LO(_ftrace_trace_function)
43	GET	D1Ar3,[D0Re0]
44	MOVT	D1Re0,#HI(_ftrace_stub)
45	ADD	D1Re0,D1Re0,#LO(_ftrace_stub)
46	CMP	D1Ar3,D1Re0
47	BEQ	$Ltrace_exit
48	MOV	D1RtP,D1Ar3
49	SUB	D1Ar1,D1Ar1,#MCOUNT_INSN_SIZE
50	SWAP	PC,D1RtP
51$Ltrace_exit:
52	GETL    D0.4,  D1RtP, [A0StP++#(-8)]
53	GETL    D0Ar2, D1Ar1, [A0StP++#(-8)]
54	GETL    D0Ar4, D1Ar3, [A0StP++#(-8)]
55	GETL    D0Ar6, D1Ar5, [A0StP++#(-8)]
56	MOV     PC, D0.4
57
58#endif	/* CONFIG_DYNAMIC_FTRACE */
59
60	.global _ftrace_stub
61_ftrace_stub:
62	MOV 	PC,D1RtP
63