7 #include <asm/thread_info.h>
11 * Stack layout in 'ret_from_exception':
13 * This allows access to the syscall arguments in registers d1-d5
25 * 28(sp) - stack adjustment
26 * 2C(sp) - [ sr ] [ format & vector ]
27 * 2E(sp) - [ pc-hiword ] [ sr ]
28 * 30(sp) - [ pc-loword ] [ pc-hiword ]
29 * 32(sp) - [ format & vector ] [ pc-loword ]
30 * ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
34 /* the following macro is used when enabling interrupts */
35 #if defined(MACH_ATARI_ONLY)
36 /* block out HSYNC = ipl 2 on the atari */
37 #define ALLOWINT (~0x500)
39 /* portable version */
40 #define ALLOWINT (~0x700)
41 #endif /* machine compilation types */
45 * This defines the normal kernel pt-regs layout.
47 * regs a3-a6 and d6-d7 are preserved by C code
48 * the kernel doesn't mess with usp unless it needs to
50 #define SWITCH_STACK_SIZE (6*4+4) /* includes return address */
52 #ifdef CONFIG_COLDFIRE
53 #ifdef CONFIG_COLDFIRE_SW_A7
55 * This is made a little more tricky on older ColdFires. There is no
56 * separate supervisor and user stack pointers. Need to artificially
57 * construct a usp in software... When doing this we need to disable
58 * interrupts, otherwise bad things will happen.
64 move
#0x2700,%sr /* disable intrs */
65 btst
#5,%sp@(2) /* from user? */
66 bnes
6f
/* no, skip */
67 movel
%sp
,sw_usp
/* save user sp */
68 addql
#8,sw_usp /* remove exception */
69 movel sw_ksp
,%sp
/* kernel sp */
70 subql
#8,%sp /* room for exception */
71 clrl
%sp@
- /* stkadj */
72 movel
%d0
,%sp@
- /* orig d0 */
73 movel
%d0
,%sp@
- /* d0 */
74 lea
%sp@
(-32),%sp
/* space for 8 regs */
75 moveml
%d1
-%d5
/%a0
-%a2
,%sp@
76 movel sw_usp
,%a0
/* get usp */
77 movel
%a0@
-,%sp@
(PT_OFF_PC
) /* copy exception program counter */
78 movel
%a0@
-,%sp@
(PT_OFF_FORMATVEC
)/*copy exception format/vector/sr */
81 clrl
%sp@
- /* stkadj */
82 movel
%d0
,%sp@
- /* orig d0 */
83 movel
%d0
,%sp@
- /* d0 */
84 lea
%sp@
(-32),%sp
/* space for 8 regs */
85 moveml
%d1
-%d5
/%a0
-%a2
,%sp@
91 moveq
#-1,%d0 /* not system call entry */
92 movel
%d0
,%sp@
(PT_OFF_ORIG_D0
)
96 move
#0x2700,%sr /* disable intrs */
97 movel sw_usp
,%a0
/* get usp */
98 movel
%sp@
(PT_OFF_PC
),%a0@
- /* copy exception program counter */
99 movel
%sp@
(PT_OFF_FORMATVEC
),%a0@
-/*copy exception format/vector/sr */
100 moveml
%sp@
,%d1
-%d5
/%a0
-%a2
101 lea
%sp@
(32),%sp
/* space for 8 regs */
103 addql
#4,%sp /* orig d0 */
104 addl
%sp@
+,%sp
/* stkadj */
105 addql
#8,%sp /* remove exception */
106 movel
%sp
,sw_ksp
/* save ksp */
107 subql
#8,sw_usp /* set exception */
108 movel sw_usp
,%sp
/* restore usp */
120 #else /* !CONFIG_COLDFIRE_SW_A7 */
122 * Modern ColdFire parts have separate supervisor and user stack
123 * pointers. Simple load and restore macros for this case.
126 move
#0x2700,%sr /* disable intrs */
127 clrl
%sp@
- /* stkadj */
128 movel
%d0
,%sp@
- /* orig d0 */
129 movel
%d0
,%sp@
- /* d0 */
130 lea
%sp@
(-32),%sp
/* space for 8 regs */
131 moveml
%d1
-%d5
/%a0
-%a2
,%sp@
135 move
#0x2700,%sr /* disable intrs */
136 clrl
%sp@
- /* stkadj */
137 pea
-1:w
/* orig d0 */
138 movel
%d0
,%sp@
- /* d0 */
139 lea
%sp@
(-32),%sp
/* space for 8 regs */
140 moveml
%d1
-%d5
/%a0
-%a2
,%sp@
144 moveml
%sp@
,%d1
-%d5
/%a0
-%a2
145 lea
%sp@
(32),%sp
/* space for 8 regs */
147 addql
#4,%sp /* orig d0 */
148 addl
%sp@
+,%sp
/* stkadj */
162 #endif /* !CONFIG_COLDFIRE_SW_A7 */
164 .macro SAVE_SWITCH_STACK
165 lea
%sp@
(-24),%sp
/* 6 regs */
166 moveml
%a3
-%a6
/%d6
-%d7
,%sp@
169 .macro RESTORE_SWITCH_STACK
170 moveml
%sp@
,%a3
-%a6
/%d6
-%d7
171 lea
%sp@
(24),%sp
/* 6 regs */
174 #else /* !CONFIG_COLDFIRE */
177 * All other types of m68k parts (68000, 680x0, CPU32) have the same
178 * entry and exit code.
182 * a -1 in the orig_d0 field signifies
183 * that the stack frame is NOT for syscall
186 clrl
%sp@
- /* stk_adj */
187 pea
-1:w
/* orig d0 */
188 movel
%d0
,%sp@
- /* d0 */
189 moveml
%d1
-%d5
/%a0
-%a2
,%sp@
-
193 clrl
%sp@
- /* stk_adj */
194 movel
%d0
,%sp@
- /* orig d0 */
195 movel
%d0
,%sp@
- /* d0 */
196 moveml
%d1
-%d5
/%a0
-%a2
,%sp@
-
200 moveml
%sp@
+,%a0
-%a2
/%d1
-%d5
202 addql
#4,%sp /* orig d0 */
203 addl
%sp@
+,%sp
/* stk adj */
208 .macro SAVE_SWITCH_STACK
209 moveml
%a3
-%a6
/%d6
-%d7
,%sp@
-
212 .macro RESTORE_SWITCH_STACK
213 moveml
%sp@
+,%a3
-%a6
/%d6
-%d7
216 #endif /* !CONFIG_COLDFIRE */
219 * Register %a2 is reserved and set to current task on MMU enabled systems.
220 * Non-MMU systems do not reserve %a2 in this way, and this definition is
227 #define GET_CURRENT(tmp) get_current tmp
228 .macro get_current reg
=%d0
230 andl
#-THREAD_SIZE,\reg
232 movel
%curptr@
,%curptr
237 #define GET_CURRENT(tmp)
239 #endif /* CONFIG_MMU */
243 #define STR(X) STR1(X)
246 #define SAVE_ALL_INT \
247 "clrl %%sp@-;" /* stk_adj */ \
248 "pea -1:w;" /* orig d0 = -1 */ \
249 "movel %%d0,%%sp@-;" /* d0 */ \
250 "moveml %%d1-%%d5/%%a0-%%a2,%%sp@-"
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" \
260 #endif /* __M68K_ENTRY_H */