blob: 3e4675996a71496c67c479149bd4fc8e45868223 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/m68knommu/platform/68328/entry.S
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file README.legal in the main directory of this archive
8 * for more details.
9 *
10 * Linux/m68k support by Hamish Macdonald
11 */
12
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/sys.h>
14#include <linux/linkage.h>
15#include <asm/thread_info.h>
16#include <asm/unistd.h>
17#include <asm/errno.h>
18#include <asm/setup.h>
19#include <asm/segment.h>
20#include <asm/traps.h>
21#include <asm/asm-offsets.h>
22#include <asm/entry.h>
23
24.text
25
26.globl system_call
27.globl resume
28.globl ret_from_exception
29.globl ret_from_signal
30.globl sys_call_table
31.globl ret_from_interrupt
32.globl bad_interrupt
33.globl inthandler1
34.globl inthandler2
35.globl inthandler3
36.globl inthandler4
37.globl inthandler5
38.globl inthandler6
39.globl inthandler7
40
41badsys:
Greg Ungererc84b5642009-09-20 21:32:32 +100042 movel #-ENOSYS,%sp@(PT_OFF_D0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 jra ret_from_exception
44
45do_trace:
Philippe De Muyter5061ea2c2010-08-17 18:52:39 +020046 movel #-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 subql #4,%sp
48 SAVE_SWITCH_STACK
Greg Ungerer55f411d2010-10-22 15:12:34 +100049 jbsr syscall_trace_enter
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 RESTORE_SWITCH_STACK
51 addql #4,%sp
Greg Ungererc84b5642009-09-20 21:32:32 +100052 movel %sp@(PT_OFF_ORIG_D0),%d1
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 movel #-ENOSYS,%d0
54 cmpl #NR_syscalls,%d1
55 jcc 1f
56 lsl #2,%d1
57 lea sys_call_table, %a0
58 jbsr %a0@(%d1)
59
Philippe De Muyter5061ea2c2010-08-17 18:52:39 +0200601: movel %d0,%sp@(PT_OFF_D0) /* save the return value */
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 subql #4,%sp /* dummy return address */
62 SAVE_SWITCH_STACK
Greg Ungerer55f411d2010-10-22 15:12:34 +100063 jbsr syscall_trace_leave
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65ret_from_signal:
66 RESTORE_SWITCH_STACK
67 addql #4,%sp
68 jra ret_from_exception
69
70ENTRY(system_call)
71 SAVE_ALL
72
73 /* save top of frame*/
Philippe De Muyter5061ea2c2010-08-17 18:52:39 +020074 pea %sp@
75 jbsr set_esp0
76 addql #4,%sp
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
Greg Ungererc84b5642009-09-20 21:32:32 +100078 movel %sp@(PT_OFF_ORIG_D0),%d0
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
80 movel %sp,%d1 /* get thread_info pointer */
Greg Ungerer8410a542005-09-02 10:42:52 +100081 andl #-THREAD_SIZE,%d1
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 movel %d1,%a2
Greg Ungereraa4d1f82011-03-29 15:55:36 +100083 btst #(TIF_SYSCALL_TRACE%8),%a2@(TINFO_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 jne do_trace
85 cmpl #NR_syscalls,%d0
86 jcc badsys
87 lsl #2,%d0
88 lea sys_call_table,%a0
89 movel %a0@(%d0), %a0
90 jbsr %a0@
Philippe De Muyter5061ea2c2010-08-17 18:52:39 +020091 movel %d0,%sp@(PT_OFF_D0) /* save the return value*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
93ret_from_exception:
Philippe De Muyter5061ea2c2010-08-17 18:52:39 +020094 btst #5,%sp@(PT_OFF_SR) /* check if returning to kernel*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 jeq Luser_return /* if so, skip resched, signals*/
96
97Lkernel_return:
98 RESTORE_ALL
99
100Luser_return:
101 /* only allow interrupts when we are really the last one on the*/
102 /* kernel stack, otherwise stack overflow can occur during*/
103 /* heavy interrupt load*/
104 andw #ALLOWINT,%sr
105
106 movel %sp,%d1 /* get thread_info pointer */
Greg Ungerer8410a542005-09-02 10:42:52 +1000107 andl #-THREAD_SIZE,%d1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 movel %d1,%a2
Al Virod1574df2010-10-11 23:29:28 -04001091:
Greg Ungereraa4d1f82011-03-29 15:55:36 +1000110 move %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 jne Lwork_to_do
112 RESTORE_ALL
113
114Lwork_to_do:
Greg Ungereraa4d1f82011-03-29 15:55:36 +1000115 movel %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 btst #TIF_NEED_RESCHED,%d1
117 jne reschedule
118
119Lsignal_return:
120 subql #4,%sp /* dummy return address*/
121 SAVE_SWITCH_STACK
122 pea %sp@(SWITCH_STACK_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 bsrw do_signal
Al Viro710e91e2010-10-11 17:09:20 -0400124 addql #4,%sp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 RESTORE_SWITCH_STACK
126 addql #4,%sp
Al Virod1574df2010-10-11 23:29:28 -0400127 jra 1b
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
129/*
130 * This is the main interrupt handler, responsible for calling process_int()
131 */
132inthandler1:
133 SAVE_ALL
Philippe De Muytereb497e72010-08-30 13:17:17 +0200134 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 and #0x3ff, %d0
136
137 movel %sp,%sp@-
138 movel #65,%sp@- /* put vector # on stack*/
139 jbsr process_int /* process the IRQ*/
1403: addql #8,%sp /* pop parameters off stack*/
141 bra ret_from_interrupt
142
143inthandler2:
144 SAVE_ALL
Philippe De Muytereb497e72010-08-30 13:17:17 +0200145 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 and #0x3ff, %d0
147
148 movel %sp,%sp@-
149 movel #66,%sp@- /* put vector # on stack*/
150 jbsr process_int /* process the IRQ*/
1513: addql #8,%sp /* pop parameters off stack*/
152 bra ret_from_interrupt
153
154inthandler3:
155 SAVE_ALL
Philippe De Muytereb497e72010-08-30 13:17:17 +0200156 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 and #0x3ff, %d0
158
159 movel %sp,%sp@-
160 movel #67,%sp@- /* put vector # on stack*/
161 jbsr process_int /* process the IRQ*/
1623: addql #8,%sp /* pop parameters off stack*/
163 bra ret_from_interrupt
164
165inthandler4:
166 SAVE_ALL
Philippe De Muytereb497e72010-08-30 13:17:17 +0200167 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 and #0x3ff, %d0
169
170 movel %sp,%sp@-
171 movel #68,%sp@- /* put vector # on stack*/
172 jbsr process_int /* process the IRQ*/
1733: addql #8,%sp /* pop parameters off stack*/
174 bra ret_from_interrupt
175
176inthandler5:
177 SAVE_ALL
Philippe De Muytereb497e72010-08-30 13:17:17 +0200178 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 and #0x3ff, %d0
180
181 movel %sp,%sp@-
182 movel #69,%sp@- /* put vector # on stack*/
183 jbsr process_int /* process the IRQ*/
1843: addql #8,%sp /* pop parameters off stack*/
185 bra ret_from_interrupt
186
187inthandler6:
188 SAVE_ALL
Philippe De Muytereb497e72010-08-30 13:17:17 +0200189 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 and #0x3ff, %d0
191
192 movel %sp,%sp@-
193 movel #70,%sp@- /* put vector # on stack*/
194 jbsr process_int /* process the IRQ*/
1953: addql #8,%sp /* pop parameters off stack*/
196 bra ret_from_interrupt
197
198inthandler7:
199 SAVE_ALL
Philippe De Muytereb497e72010-08-30 13:17:17 +0200200 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 and #0x3ff, %d0
202
203 movel %sp,%sp@-
204 movel #71,%sp@- /* put vector # on stack*/
205 jbsr process_int /* process the IRQ*/
2063: addql #8,%sp /* pop parameters off stack*/
207 bra ret_from_interrupt
208
209inthandler:
210 SAVE_ALL
Philippe De Muytereb497e72010-08-30 13:17:17 +0200211 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 and #0x3ff, %d0
213
214 movel %sp,%sp@-
215 movel %d0,%sp@- /* put vector # on stack*/
216 jbsr process_int /* process the IRQ*/
2173: addql #8,%sp /* pop parameters off stack*/
218 bra ret_from_interrupt
219
220ret_from_interrupt:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 jeq 1f
2222:
223 RESTORE_ALL
2241:
Greg Ungererc84b5642009-09-20 21:32:32 +1000225 moveb %sp@(PT_OFF_SR), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 and #7, %d0
227 jhi 2b
228
229 /* check if we need to do software interrupts */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 jeq ret_from_exception
231
232 pea ret_from_exception
233 jra do_softirq
234
235
236/*
237 * Handler for uninitialized and spurious interrupts.
238 */
239ENTRY(bad_interrupt)
240 addql #1,num_spurious
241 rte
242
243/*
244 * Beware - when entering resume, prev (the current task) is
245 * in a0, next (the new task) is in a1,so don't change these
246 * registers until their contents are no longer needed.
247 */
248ENTRY(resume)
249 movel %a0,%d1 /* save prev thread in d1 */
250 movew %sr,%a0@(TASK_THREAD+THREAD_SR) /* save sr */
251 movel %usp,%a2 /* save usp */
252 movel %a2,%a0@(TASK_THREAD+THREAD_USP)
253
254 SAVE_SWITCH_STACK
255 movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */
256 movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */
257 RESTORE_SWITCH_STACK
258
259 movel %a1@(TASK_THREAD+THREAD_USP),%a0 /* restore user stack */
260 movel %a0,%usp
261 movew %a1@(TASK_THREAD+THREAD_SR),%sr /* restore thread status reg */
262 rts
263