summaryrefslogtreecommitdiffstats
path: root/target/linux/coldfire/files-2.6.31/arch/m68k/include/asm/cf_entry.h
blob: c8f37a4105e5efea3e720538d57da9635e05367e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#ifndef __CF_M68K_ENTRY_H
#define __CF_M68K_ENTRY_H

#include <asm/setup.h>
#include <asm/page.h>
#include <asm/coldfire.h>
#include <asm/cfmmu.h>
#include <asm/asm-offsets.h>

/*
 * Stack layout in 'ret_from_exception':
 *
 *	This allows access to the syscall arguments in registers d1-d5
 *
 *	 0(sp) - d1
 *	 4(sp) - d2
 *	 8(sp) - d3
 *	 C(sp) - d4
 *	10(sp) - d5
 *	14(sp) - a0
 *	18(sp) - a1
 *	1C(sp) - a2
 *	20(sp) - d0
 *	24(sp) - orig_d0
 *	28(sp) - stack adjustment
 *	2C(sp) - sr
 *	2E(sp) - pc
 *	32(sp) - format & vector
 *	36(sp) - MMUSR
 *	3A(sp) - MMUAR
 */

/*
 * 97/05/14 Andreas: Register %a2 is now set to the current task throughout
 *		     the whole kernel.
 */

/* the following macro is used when enabling interrupts */
/* portable version */
#define ALLOWINT	(~0x700)
#define	MAX_NOINT_IPL	0

#ifdef __ASSEMBLY__

#define curptr a2

LFLUSH_I_AND_D = 0x00000808
LSIGTRAP = 5

/* process bits for task_struct.ptrace */
PT_TRACESYS_OFF = 3
PT_TRACESYS_BIT = 1
PT_PTRACED_OFF = 3
PT_PTRACED_BIT = 0
PT_DTRACE_OFF = 3
PT_DTRACE_BIT = 2

#define SAVE_ALL_INT save_all_int
#define SAVE_ALL_SYS save_all_sys
#define RESTORE_ALL restore_all
/*
 * This defines the normal kernel pt-regs layout.
 *
 * regs a3-a6 and d6-d7 are preserved by C code
 * the kernel doesn't mess with usp unless it needs to
 */

/*
 * a -1 in the orig_d0 field signifies
 * that the stack frame is NOT for syscall
 */
.macro	save_all_int
	movel	MMUSR,%sp@-
	movel	MMUAR,%sp@-
	clrl	%sp@-		| stk_adj
	pea	-1:w		| orig d0
	movel	%d0,%sp@-	| d0
	subal	#(8*4), %sp
	moveml	%d1-%d5/%a0-%a1/%curptr,%sp@
.endm

.macro	save_all_sys
	movel	MMUSR,%sp@-
	movel	MMUAR,%sp@-
	clrl	%sp@-		| stk_adj
	movel	%d0,%sp@-	| orig d0
	movel	%d0,%sp@-	| d0
	subal	#(8*4), %sp
	moveml	%d1-%d5/%a0-%a1/%curptr,%sp@
.endm

.macro	restore_all
	moveml	%sp@,%a0-%a1/%curptr/%d1-%d5
	addal	#(8*4), %sp
	movel	%sp@+,%d0	| d0
	addql	#4,%sp		| orig d0
	addl	%sp@+,%sp	| stk_adj
	addql	#8,%sp		| MMUAR & MMUSR
	rte
.endm

#define SWITCH_STACK_SIZE (6*4+4)	/* includes return address */

#define SAVE_SWITCH_STACK save_switch_stack
#define RESTORE_SWITCH_STACK restore_switch_stack
#define GET_CURRENT(tmp) get_current tmp

.macro	save_switch_stack
	subal	#(6*4), %sp
	moveml	%a3-%a6/%d6-%d7,%sp@
.endm

.macro	restore_switch_stack
	moveml	%sp@,%a3-%a6/%d6-%d7
	addal	#(6*4), %sp
.endm

.macro	get_current reg=%d0
	movel	%sp,\reg
	andl	#-THREAD_SIZE,\reg
	movel	\reg,%curptr
	movel	%curptr@,%curptr
.endm

#else /* C source */

#define STR(X) STR1(X)
#define STR1(X) #X

#define PT_OFF_ORIG_D0	 0x24
#define PT_OFF_FORMATVEC 0x32
#define PT_OFF_SR	 0x2C
#define SAVE_ALL_INT				\
	"clrl	%%sp@-;"    /* stk_adj */	\
	"pea	-1:w;"	    /* orig d0 = -1 */	\
	"movel	%%d0,%%sp@-;" /* d0 */		\
	"subal	#(8*4),%sp"			\
	"moveml	%%d1-%%d5/%%a0-%%a2,%%sp@"
#define GET_CURRENT(tmp) \
	"movel	%%sp,"#tmp"\n\t" \
	"andw	#-"STR(THREAD_SIZE)","#tmp"\n\t" \
	"movel	"#tmp",%%a2\n\t"

#endif

#endif /* __CF_M68K_ENTRY_H */