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 on the atari */
37 #define ALLOWINT (~0x400)
38 #define MAX_NOINT_IPL 3
40 /* portable version */
41 #define ALLOWINT (~0x700)
42 #define MAX_NOINT_IPL 0
43 #endif /* machine compilation types */
47 * This defines the normal kernel pt-regs layout.
49 * regs a3-a6 and d6-d7 are preserved by C code
50 * the kernel doesn't mess with usp unless it needs to
52 #define SWITCH_STACK_SIZE (6*4+4) /* includes return address */
54 #ifdef CONFIG_COLDFIRE
55 #ifdef CONFIG_COLDFIRE_SW_A7
57 * This is made a little more tricky on older ColdFires. There is no
58 * separate supervisor and user stack pointers. Need to artificially
59 * construct a usp in software... When doing this we need to disable
60 * interrupts, otherwise bad things will happen.
66 move
#0x2700,%sr /* disable intrs */
67 btst
#5,%sp@(2) /* from user? */
68 bnes
6f
/* no, skip */
69 movel
%sp
,sw_usp
/* save user sp */
70 addql
#8,sw_usp /* remove exception */
71 movel sw_ksp
,%sp
/* kernel sp */
72 subql
#8,%sp /* room for exception */
73 clrl
%sp@
- /* stkadj */
74 movel
%d0
,%sp@
- /* orig d0 */
75 movel
%d0
,%sp@
- /* d0 */
76 lea
%sp@
(-32),%sp
/* space for 8 regs */
77 moveml
%d1
-%d5
/%a0
-%a2
,%sp@
78 movel sw_usp
,%a0
/* get usp */
79 movel
%a0@
-,%sp@
(PT_OFF_PC
) /* copy exception program counter */
80 movel
%a0@
-,%sp@
(PT_OFF_FORMATVEC
)/*copy exception format/vector/sr */
83 clrl
%sp@
- /* stkadj */
84 movel
%d0
,%sp@
- /* orig d0 */
85 movel
%d0
,%sp@
- /* d0 */
86 lea
%sp@
(-32),%sp
/* space for 8 regs */
87 moveml
%d1
-%d5
/%a0
-%a2
,%sp@
93 moveq
#-1,%d0 /* not system call entry */
94 movel
%d0
,%sp@
(PT_OFF_ORIG_D0
)
98 move
#0x2700,%sr /* disable intrs */
99 movel sw_usp
,%a0
/* get usp */
100 movel
%sp@
(PT_OFF_PC
),%a0@
- /* copy exception program counter */
101 movel
%sp@
(PT_OFF_FORMATVEC
),%a0@
-/*copy exception format/vector/sr */
102 moveml
%sp@
,%d1
-%d5
/%a0
-%a2
103 lea
%sp@
(32),%sp
/* space for 8 regs */
105 addql
#4,%sp /* orig d0 */
106 addl
%sp@
+,%sp
/* stkadj */
107 addql
#8,%sp /* remove exception */
108 movel
%sp
,sw_ksp
/* save ksp */
109 subql
#8,sw_usp /* set exception */
110 movel sw_usp
,%sp
/* restore usp */
122 #else /* !CONFIG_COLDFIRE_SW_A7 */
124 * Modern ColdFire parts have separate supervisor and user stack
125 * pointers. Simple load and restore macros for this case.
128 move
#0x2700,%sr /* disable intrs */
129 clrl
%sp@
- /* stkadj */
130 movel
%d0
,%sp@
- /* orig d0 */
131 movel
%d0
,%sp@
- /* d0 */
132 lea
%sp@
(-32),%sp
/* space for 8 regs */
133 moveml
%d1
-%d5
/%a0
-%a2
,%sp@
137 move
#0x2700,%sr /* disable intrs */
138 clrl
%sp@
- /* stkadj */
139 pea
-1:w
/* orig d0 */
140 movel
%d0
,%sp@
- /* d0 */
141 lea
%sp@
(-32),%sp
/* space for 8 regs */
142 moveml
%d1
-%d5
/%a0
-%a2
,%sp@
146 moveml
%sp@
,%d1
-%d5
/%a0
-%a2
147 lea
%sp@
(32),%sp
/* space for 8 regs */
149 addql
#4,%sp /* orig d0 */
150 addl
%sp@
+,%sp
/* stkadj */
164 #endif /* !CONFIG_COLDFIRE_SW_A7 */
166 .macro SAVE_SWITCH_STACK
167 lea
%sp@
(-24),%sp
/* 6 regs */
168 moveml
%a3
-%a6
/%d6
-%d7
,%sp@
171 .macro RESTORE_SWITCH_STACK
172 moveml
%sp@
,%a3
-%a6
/%d6
-%d7
173 lea
%sp@
(24),%sp
/* 6 regs */
176 #else /* !CONFIG_COLDFIRE */
179 * All other types of m68k parts (68000, 680x0, CPU32) have the same
180 * entry and exit code.
184 * a -1 in the orig_d0 field signifies
185 * that the stack frame is NOT for syscall
188 clrl
%sp@
- /* stk_adj */
189 pea
-1:w
/* orig d0 */
190 movel
%d0
,%sp@
- /* d0 */
191 moveml
%d1
-%d5
/%a0
-%a2
,%sp@
-
195 clrl
%sp@
- /* stk_adj */
196 movel
%d0
,%sp@
- /* orig d0 */
197 movel
%d0
,%sp@
- /* d0 */
198 moveml
%d1
-%d5
/%a0
-%a2
,%sp@
-
202 moveml
%sp@
+,%a0
-%a2
/%d1
-%d5
204 addql
#4,%sp /* orig d0 */
205 addl
%sp@
+,%sp
/* stk adj */
210 .macro SAVE_SWITCH_STACK
211 moveml
%a3
-%a6
/%d6
-%d7
,%sp@
-
214 .macro RESTORE_SWITCH_STACK
215 moveml
%sp@
+,%a3
-%a6
/%d6
-%d7
218 #endif /* !CONFIG_COLDFIRE */
221 * Register %a2 is reserved and set to current task on MMU enabled systems.
222 * Non-MMU systems do not reserve %a2 in this way, and this definition is
229 #define GET_CURRENT(tmp) get_current tmp
230 .macro get_current reg
=%d0
232 andl
#-THREAD_SIZE,\reg
234 movel
%curptr@
,%curptr
239 #define GET_CURRENT(tmp)
241 #endif /* CONFIG_MMU */
245 #define STR(X) STR1(X)
248 #define SAVE_ALL_INT \
249 "clrl %%sp@-;" /* stk_adj */ \
250 "pea -1:w;" /* orig d0 = -1 */ \
251 "movel %%d0,%%sp@-;" /* d0 */ \
252 "moveml %%d1-%%d5/%%a0-%%a2,%%sp@-"
254 #define GET_CURRENT(tmp) \
255 "movel %%sp,"#tmp"\n\t" \
256 "andw #-"STR(THREAD_SIZE)","#tmp"\n\t" \
257 "movel "#tmp",%%a2\n\t" \
262 #endif /* __M68K_ENTRY_H */