1#ifndef __M68K_ENTRY_H
2#define __M68K_ENTRY_H
3
4#include <asm/setup.h>
5#include <asm/page.h>
6#ifdef __ASSEMBLY__
7#include <asm/thread_info.h>
8#endif
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#if defined(MACH_ATARI_ONLY)
36
37#define ALLOWINT (~0x500)
38#else
39
40#define ALLOWINT (~0x700)
41#endif
42
43#ifdef __ASSEMBLY__
44
45
46
47
48
49
50#define SWITCH_STACK_SIZE (6*4+4)
51
52#ifdef CONFIG_COLDFIRE
53#ifdef CONFIG_COLDFIRE_SW_A7
54
55
56
57
58
59
60.globl sw_usp
61.globl sw_ksp
62
63.macro SAVE_ALL_SYS
64 move #0x2700,%sr
65 btst #5,%sp@(2)
66 bnes 6f
67 movel %sp,sw_usp
68 addql #8,sw_usp
69 movel sw_ksp,%sp
70 subql #8,%sp
71 clrl %sp@-
72 movel %d0,%sp@-
73 movel %d0,%sp@-
74 lea %sp@(-32),%sp
75 moveml %d1-%d5/%a0-%a2,%sp@
76 movel sw_usp,%a0
77 movel %a0@-,%sp@(PT_OFF_PC)
78 movel %a0@-,%sp@(PT_OFF_FORMATVEC)
79 bra 7f
80 6:
81 clrl %sp@-
82 movel %d0,%sp@-
83 movel %d0,%sp@-
84 lea %sp@(-32),%sp
85 moveml %d1-%d5/%a0-%a2,%sp@
86 7:
87.endm
88
89.macro SAVE_ALL_INT
90 SAVE_ALL_SYS
91 moveq #-1,%d0
92 movel %d0,%sp@(PT_OFF_ORIG_D0)
93.endm
94
95.macro RESTORE_USER
96 move #0x2700,%sr
97 movel sw_usp,%a0
98 movel %sp@(PT_OFF_PC),%a0@-
99 movel %sp@(PT_OFF_FORMATVEC),%a0@-
100 moveml %sp@,%d1-%d5/%a0-%a2
101 lea %sp@(32),%sp
102 movel %sp@+,%d0
103 addql #4,%sp
104 addl %sp@+,%sp
105 addql #8,%sp
106 movel %sp,sw_ksp
107 subql #8,sw_usp
108 movel sw_usp,%sp
109 rte
110.endm
111
112.macro RDUSP
113 movel sw_usp,%a3
114.endm
115
116.macro WRUSP
117 movel %a3,sw_usp
118.endm
119
120#else
121
122
123
124
125.macro SAVE_ALL_SYS
126 move #0x2700,%sr
127 clrl %sp@-
128 movel %d0,%sp@-
129 movel %d0,%sp@-
130 lea %sp@(-32),%sp
131 moveml %d1-%d5/%a0-%a2,%sp@
132.endm
133
134.macro SAVE_ALL_INT
135 move #0x2700,%sr
136 clrl %sp@-
137 pea -1:w
138 movel %d0,%sp@-
139 lea %sp@(-32),%sp
140 moveml %d1-%d5/%a0-%a2,%sp@
141.endm
142
143.macro RESTORE_USER
144 moveml %sp@,%d1-%d5/%a0-%a2
145 lea %sp@(32),%sp
146 movel %sp@+,%d0
147 addql #4,%sp
148 addl %sp@+,%sp
149 rte
150.endm
151
152.macro RDUSP
153
154 .word 0x4e6b
155.endm
156
157.macro WRUSP
158
159 .word 0x4e63
160.endm
161
162#endif
163
164.macro SAVE_SWITCH_STACK
165 lea %sp@(-24),%sp
166 moveml %a3-%a6/%d6-%d7,%sp@
167.endm
168
169.macro RESTORE_SWITCH_STACK
170 moveml %sp@,%a3-%a6/%d6-%d7
171 lea %sp@(24),%sp
172.endm
173
174#else
175
176
177
178
179
180
181
182
183
184
185.macro SAVE_ALL_INT
186 clrl %sp@-
187 pea -1:w
188 movel %d0,%sp@-
189 moveml %d1-%d5/%a0-%a2,%sp@-
190.endm
191
192.macro SAVE_ALL_SYS
193 clrl %sp@-
194 movel %d0,%sp@-
195 movel %d0,%sp@-
196 moveml %d1-%d5/%a0-%a2,%sp@-
197.endm
198
199.macro RESTORE_ALL
200 moveml %sp@+,%a0-%a2/%d1-%d5
201 movel %sp@+,%d0
202 addql #4,%sp
203 addl %sp@+,%sp
204 rte
205.endm
206
207
208.macro SAVE_SWITCH_STACK
209 moveml %a3-%a6/%d6-%d7,%sp@-
210.endm
211
212.macro RESTORE_SWITCH_STACK
213 moveml %sp@+,%a3-%a6/%d6-%d7
214.endm
215
216#endif
217
218
219
220
221
222
223#ifdef CONFIG_MMU
224
225#define curptr a2
226
227#define GET_CURRENT(tmp) get_current tmp
228.macro get_current reg=%d0
229 movel %sp,\reg
230 andl #-THREAD_SIZE,\reg
231 movel \reg,%curptr
232 movel %curptr@,%curptr
233.endm
234
235#else
236
237#define GET_CURRENT(tmp)
238
239#endif
240
241#else
242
243#define STR(X) STR1(X)
244#define STR1(X) #X
245
246#define SAVE_ALL_INT \
247 "clrl %%sp@-;" \
248 "pea -1:w;" \
249 "movel %%d0,%%sp@-;" \
250 "moveml %%d1-%%d5/%%a0-%%a2,%%sp@-"
251
252#define GET_CURRENT(tmp) \
253 "movel %%sp,"#tmp"\n\t" \
254 "andw #-"STR(THREAD_SIZE)","#tmp"\n\t" \
255 "movel "#tmp",%%a2\n\t" \
256 "movel %%a2@,%%a2"
257
258#endif
259
260#endif
261