blob: 7f91c2fde5096b9eaaef2e33334cf0339b896352 [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/linkage.h>
14#include <asm/thread_info.h>
15#include <asm/unistd.h>
16#include <asm/errno.h>
17#include <asm/setup.h>
18#include <asm/segment.h>
19#include <asm/traps.h>
20#include <asm/asm-offsets.h>
21#include <asm/entry.h>
22
23.text
24
25.globl system_call
26.globl resume
27.globl ret_from_exception
28.globl ret_from_signal
29.globl sys_call_table
30.globl ret_from_interrupt
31.globl bad_interrupt
32.globl inthandler1
33.globl inthandler2
34.globl inthandler3
35.globl inthandler4
36.globl inthandler5
37.globl inthandler6
38.globl inthandler7
39
40badsys:
Greg Ungererc84b5642009-09-20 21:32:32 +100041 movel #-ENOSYS,%sp@(PT_OFF_D0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 jra ret_from_exception
43
44do_trace:
Philippe De Muyter5061ea2c2010-08-17 18:52:39 +020045 movel #-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 subql #4,%sp
47 SAVE_SWITCH_STACK
Greg Ungerer55f411d2010-10-22 15:12:34 +100048 jbsr syscall_trace_enter
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 RESTORE_SWITCH_STACK
50 addql #4,%sp
Greg Ungererc84b5642009-09-20 21:32:32 +100051 movel %sp@(PT_OFF_ORIG_D0),%d1
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 movel #-ENOSYS,%d0
53 cmpl #NR_syscalls,%d1
54 jcc 1f
55 lsl #2,%d1
56 lea sys_call_table, %a0
57 jbsr %a0@(%d1)
58
Philippe De Muyter5061ea2c2010-08-17 18:52:39 +0200591: movel %d0,%sp@(PT_OFF_D0) /* save the return value */
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 subql #4,%sp /* dummy return address */
61 SAVE_SWITCH_STACK
Greg Ungerer55f411d2010-10-22 15:12:34 +100062 jbsr syscall_trace_leave
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64ret_from_signal:
65 RESTORE_SWITCH_STACK
66 addql #4,%sp
67 jra ret_from_exception
68
69ENTRY(system_call)
Greg Ungerer61619b12011-06-22 13:50:44 +100070 SAVE_ALL_SYS
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72 /* save top of frame*/
Philippe De Muyter5061ea2c2010-08-17 18:52:39 +020073 pea %sp@
74 jbsr set_esp0
75 addql #4,%sp
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Greg Ungererc84b5642009-09-20 21:32:32 +100077 movel %sp@(PT_OFF_ORIG_D0),%d0
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79 movel %sp,%d1 /* get thread_info pointer */
Greg Ungerer8410a542005-09-02 10:42:52 +100080 andl #-THREAD_SIZE,%d1
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 movel %d1,%a2
Greg Ungereraa4d1f82011-03-29 15:55:36 +100082 btst #(TIF_SYSCALL_TRACE%8),%a2@(TINFO_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 jne do_trace
84 cmpl #NR_syscalls,%d0
85 jcc badsys
86 lsl #2,%d0
87 lea sys_call_table,%a0
88 movel %a0@(%d0), %a0
89 jbsr %a0@
Philippe De Muyter5061ea2c2010-08-17 18:52:39 +020090 movel %d0,%sp@(PT_OFF_D0) /* save the return value*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
92ret_from_exception:
Philippe De Muyter5061ea2c2010-08-17 18:52:39 +020093 btst #5,%sp@(PT_OFF_SR) /* check if returning to kernel*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 jeq Luser_return /* if so, skip resched, signals*/
95
96Lkernel_return:
97 RESTORE_ALL
98
99Luser_return:
100 /* only allow interrupts when we are really the last one on the*/
101 /* kernel stack, otherwise stack overflow can occur during*/
102 /* heavy interrupt load*/
103 andw #ALLOWINT,%sr
104
105 movel %sp,%d1 /* get thread_info pointer */
Greg Ungerer8410a542005-09-02 10:42:52 +1000106 andl #-THREAD_SIZE,%d1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 movel %d1,%a2
Al Virod1574df2010-10-11 23:29:28 -04001081:
Greg Ungereraa4d1f82011-03-29 15:55:36 +1000109 move %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 jne Lwork_to_do
111 RESTORE_ALL
112
113Lwork_to_do:
Greg Ungereraa4d1f82011-03-29 15:55:36 +1000114 movel %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 btst #TIF_NEED_RESCHED,%d1
116 jne reschedule
117
118Lsignal_return:
119 subql #4,%sp /* dummy return address*/
120 SAVE_SWITCH_STACK
121 pea %sp@(SWITCH_STACK_SIZE)
Al Viroa54f1652012-04-24 01:46:23 -0400122 bsrw do_notify_resume
Al Viro710e91e2010-10-11 17:09:20 -0400123 addql #4,%sp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 RESTORE_SWITCH_STACK
125 addql #4,%sp
Al Virod1574df2010-10-11 23:29:28 -0400126 jra 1b
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128/*
129 * This is the main interrupt handler, responsible for calling process_int()
130 */
131inthandler1:
Greg Ungerer61619b12011-06-22 13:50:44 +1000132 SAVE_ALL_INT
Philippe De Muytereb497e72010-08-30 13:17:17 +0200133 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 and #0x3ff, %d0
135
136 movel %sp,%sp@-
137 movel #65,%sp@- /* put vector # on stack*/
138 jbsr process_int /* process the IRQ*/
1393: addql #8,%sp /* pop parameters off stack*/
140 bra ret_from_interrupt
141
142inthandler2:
Greg Ungerer61619b12011-06-22 13:50:44 +1000143 SAVE_ALL_INT
Philippe De Muytereb497e72010-08-30 13:17:17 +0200144 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 and #0x3ff, %d0
146
147 movel %sp,%sp@-
148 movel #66,%sp@- /* put vector # on stack*/
149 jbsr process_int /* process the IRQ*/
1503: addql #8,%sp /* pop parameters off stack*/
151 bra ret_from_interrupt
152
153inthandler3:
Greg Ungerer61619b12011-06-22 13:50:44 +1000154 SAVE_ALL_INT
Philippe De Muytereb497e72010-08-30 13:17:17 +0200155 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 and #0x3ff, %d0
157
158 movel %sp,%sp@-
159 movel #67,%sp@- /* put vector # on stack*/
160 jbsr process_int /* process the IRQ*/
1613: addql #8,%sp /* pop parameters off stack*/
162 bra ret_from_interrupt
163
164inthandler4:
Greg Ungerer61619b12011-06-22 13:50:44 +1000165 SAVE_ALL_INT
Philippe De Muytereb497e72010-08-30 13:17:17 +0200166 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167 and #0x3ff, %d0
168
169 movel %sp,%sp@-
170 movel #68,%sp@- /* put vector # on stack*/
171 jbsr process_int /* process the IRQ*/
1723: addql #8,%sp /* pop parameters off stack*/
173 bra ret_from_interrupt
174
175inthandler5:
Greg Ungerer61619b12011-06-22 13:50:44 +1000176 SAVE_ALL_INT
Philippe De Muytereb497e72010-08-30 13:17:17 +0200177 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 and #0x3ff, %d0
179
180 movel %sp,%sp@-
181 movel #69,%sp@- /* put vector # on stack*/
182 jbsr process_int /* process the IRQ*/
1833: addql #8,%sp /* pop parameters off stack*/
184 bra ret_from_interrupt
185
186inthandler6:
Greg Ungerer61619b12011-06-22 13:50:44 +1000187 SAVE_ALL_INT
Philippe De Muytereb497e72010-08-30 13:17:17 +0200188 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 and #0x3ff, %d0
190
191 movel %sp,%sp@-
192 movel #70,%sp@- /* put vector # on stack*/
193 jbsr process_int /* process the IRQ*/
1943: addql #8,%sp /* pop parameters off stack*/
195 bra ret_from_interrupt
196
197inthandler7:
Greg Ungerer61619b12011-06-22 13:50:44 +1000198 SAVE_ALL_INT
Philippe De Muytereb497e72010-08-30 13:17:17 +0200199 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 and #0x3ff, %d0
201
202 movel %sp,%sp@-
203 movel #71,%sp@- /* put vector # on stack*/
204 jbsr process_int /* process the IRQ*/
2053: addql #8,%sp /* pop parameters off stack*/
206 bra ret_from_interrupt
207
208inthandler:
Greg Ungerer61619b12011-06-22 13:50:44 +1000209 SAVE_ALL_INT
Philippe De Muytereb497e72010-08-30 13:17:17 +0200210 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 and #0x3ff, %d0
212
213 movel %sp,%sp@-
214 movel %d0,%sp@- /* put vector # on stack*/
215 jbsr process_int /* process the IRQ*/
2163: addql #8,%sp /* pop parameters off stack*/
217 bra ret_from_interrupt
218
219ret_from_interrupt:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 jeq 1f
2212:
222 RESTORE_ALL
2231:
Greg Ungererc84b5642009-09-20 21:32:32 +1000224 moveb %sp@(PT_OFF_SR), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 and #7, %d0
226 jhi 2b
227
228 /* check if we need to do software interrupts */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 jeq ret_from_exception
230
231 pea ret_from_exception
232 jra do_softirq
233
234
235/*
236 * Handler for uninitialized and spurious interrupts.
237 */
238ENTRY(bad_interrupt)
Geert Uytterhoeven8c9f08f2011-07-13 20:29:24 +0200239 addql #1,irq_err_count
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 rte
241
242/*
243 * Beware - when entering resume, prev (the current task) is
Greg Ungererf941f5c2011-05-05 22:32:12 +1000244 * in a0, next (the new task) is in a1, so don't change these
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 * registers until their contents are no longer needed.
246 */
247ENTRY(resume)
248 movel %a0,%d1 /* save prev thread in d1 */
249 movew %sr,%a0@(TASK_THREAD+THREAD_SR) /* save sr */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 SAVE_SWITCH_STACK
251 movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */
Greg Ungererf941f5c2011-05-05 22:32:12 +1000252 movel %usp,%a3 /* save usp */
253 movel %a3,%a0@(TASK_THREAD+THREAD_USP)
254
255 movel %a1@(TASK_THREAD+THREAD_USP),%a3 /* restore user stack */
256 movel %a3,%usp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */
258 RESTORE_SWITCH_STACK
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 movew %a1@(TASK_THREAD+THREAD_SR),%sr /* restore thread status reg */
260 rts
261