blob: 259b3661b614168ff8ab377587c66b1478222218 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Greg Ungerer6f4a8852014-08-21 22:10:31 +10002 * entry.S -- non-mmu 68000 interrupt and exception entry points
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070030.globl bad_interrupt
31.globl inthandler1
32.globl inthandler2
33.globl inthandler3
34.globl inthandler4
35.globl inthandler5
36.globl inthandler6
37.globl inthandler7
38
39badsys:
Greg Ungererc84b5642009-09-20 21:32:32 +100040 movel #-ENOSYS,%sp@(PT_OFF_D0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 jra ret_from_exception
42
43do_trace:
Philippe De Muyter5061ea2c2010-08-17 18:52:39 +020044 movel #-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 subql #4,%sp
46 SAVE_SWITCH_STACK
Greg Ungerer55f411d2010-10-22 15:12:34 +100047 jbsr syscall_trace_enter
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 RESTORE_SWITCH_STACK
49 addql #4,%sp
Greg Ungererc84b5642009-09-20 21:32:32 +100050 movel %sp@(PT_OFF_ORIG_D0),%d1
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 movel #-ENOSYS,%d0
52 cmpl #NR_syscalls,%d1
53 jcc 1f
54 lsl #2,%d1
55 lea sys_call_table, %a0
56 jbsr %a0@(%d1)
57
Philippe De Muyter5061ea2c2010-08-17 18:52:39 +0200581: movel %d0,%sp@(PT_OFF_D0) /* save the return value */
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 subql #4,%sp /* dummy return address */
60 SAVE_SWITCH_STACK
Greg Ungerer55f411d2010-10-22 15:12:34 +100061 jbsr syscall_trace_leave
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63ret_from_signal:
64 RESTORE_SWITCH_STACK
65 addql #4,%sp
66 jra ret_from_exception
67
68ENTRY(system_call)
Greg Ungerer61619b12011-06-22 13:50:44 +100069 SAVE_ALL_SYS
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71 /* save top of frame*/
Philippe De Muyter5061ea2c2010-08-17 18:52:39 +020072 pea %sp@
73 jbsr set_esp0
74 addql #4,%sp
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Greg Ungererc84b5642009-09-20 21:32:32 +100076 movel %sp@(PT_OFF_ORIG_D0),%d0
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
78 movel %sp,%d1 /* get thread_info pointer */
Greg Ungerer8410a542005-09-02 10:42:52 +100079 andl #-THREAD_SIZE,%d1
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 movel %d1,%a2
Greg Ungereraa4d1f82011-03-29 15:55:36 +100081 btst #(TIF_SYSCALL_TRACE%8),%a2@(TINFO_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 jne do_trace
83 cmpl #NR_syscalls,%d0
84 jcc badsys
85 lsl #2,%d0
86 lea sys_call_table,%a0
87 movel %a0@(%d0), %a0
88 jbsr %a0@
Philippe De Muyter5061ea2c2010-08-17 18:52:39 +020089 movel %d0,%sp@(PT_OFF_D0) /* save the return value*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
91ret_from_exception:
Philippe De Muyter5061ea2c2010-08-17 18:52:39 +020092 btst #5,%sp@(PT_OFF_SR) /* check if returning to kernel*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 jeq Luser_return /* if so, skip resched, signals*/
94
95Lkernel_return:
96 RESTORE_ALL
97
98Luser_return:
99 /* only allow interrupts when we are really the last one on the*/
100 /* kernel stack, otherwise stack overflow can occur during*/
101 /* heavy interrupt load*/
102 andw #ALLOWINT,%sr
103
104 movel %sp,%d1 /* get thread_info pointer */
Greg Ungerer8410a542005-09-02 10:42:52 +1000105 andl #-THREAD_SIZE,%d1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 movel %d1,%a2
Al Virod1574df2010-10-11 23:29:28 -04001071:
Greg Ungereraa4d1f82011-03-29 15:55:36 +1000108 move %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 jne Lwork_to_do
110 RESTORE_ALL
111
112Lwork_to_do:
Greg Ungereraa4d1f82011-03-29 15:55:36 +1000113 movel %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 btst #TIF_NEED_RESCHED,%d1
115 jne reschedule
116
117Lsignal_return:
118 subql #4,%sp /* dummy return address*/
119 SAVE_SWITCH_STACK
120 pea %sp@(SWITCH_STACK_SIZE)
Al Viroa54f1652012-04-24 01:46:23 -0400121 bsrw do_notify_resume
Al Viro710e91e2010-10-11 17:09:20 -0400122 addql #4,%sp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 RESTORE_SWITCH_STACK
124 addql #4,%sp
Al Virod1574df2010-10-11 23:29:28 -0400125 jra 1b
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
127/*
128 * This is the main interrupt handler, responsible for calling process_int()
129 */
130inthandler1:
Greg Ungerer61619b12011-06-22 13:50:44 +1000131 SAVE_ALL_INT
Philippe De Muytereb497e72010-08-30 13:17:17 +0200132 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 and #0x3ff, %d0
134
135 movel %sp,%sp@-
136 movel #65,%sp@- /* put vector # on stack*/
137 jbsr process_int /* process the IRQ*/
1383: addql #8,%sp /* pop parameters off stack*/
Thomas Gleixner09f90f62013-11-11 21:01:03 +0100139 bra ret_from_exception
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
141inthandler2:
Greg Ungerer61619b12011-06-22 13:50:44 +1000142 SAVE_ALL_INT
Philippe De Muytereb497e72010-08-30 13:17:17 +0200143 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 and #0x3ff, %d0
145
146 movel %sp,%sp@-
147 movel #66,%sp@- /* put vector # on stack*/
148 jbsr process_int /* process the IRQ*/
1493: addql #8,%sp /* pop parameters off stack*/
Thomas Gleixner09f90f62013-11-11 21:01:03 +0100150 bra ret_from_exception
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151
152inthandler3:
Greg Ungerer61619b12011-06-22 13:50:44 +1000153 SAVE_ALL_INT
Philippe De Muytereb497e72010-08-30 13:17:17 +0200154 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 and #0x3ff, %d0
156
157 movel %sp,%sp@-
158 movel #67,%sp@- /* put vector # on stack*/
159 jbsr process_int /* process the IRQ*/
1603: addql #8,%sp /* pop parameters off stack*/
Thomas Gleixner09f90f62013-11-11 21:01:03 +0100161 bra ret_from_exception
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
163inthandler4:
Greg Ungerer61619b12011-06-22 13:50:44 +1000164 SAVE_ALL_INT
Philippe De Muytereb497e72010-08-30 13:17:17 +0200165 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 and #0x3ff, %d0
167
168 movel %sp,%sp@-
169 movel #68,%sp@- /* put vector # on stack*/
170 jbsr process_int /* process the IRQ*/
1713: addql #8,%sp /* pop parameters off stack*/
Thomas Gleixner09f90f62013-11-11 21:01:03 +0100172 bra ret_from_exception
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
174inthandler5:
Greg Ungerer61619b12011-06-22 13:50:44 +1000175 SAVE_ALL_INT
Philippe De Muytereb497e72010-08-30 13:17:17 +0200176 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 and #0x3ff, %d0
178
179 movel %sp,%sp@-
180 movel #69,%sp@- /* put vector # on stack*/
181 jbsr process_int /* process the IRQ*/
1823: addql #8,%sp /* pop parameters off stack*/
Thomas Gleixner09f90f62013-11-11 21:01:03 +0100183 bra ret_from_exception
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184
185inthandler6:
Greg Ungerer61619b12011-06-22 13:50:44 +1000186 SAVE_ALL_INT
Philippe De Muytereb497e72010-08-30 13:17:17 +0200187 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 and #0x3ff, %d0
189
190 movel %sp,%sp@-
191 movel #70,%sp@- /* put vector # on stack*/
192 jbsr process_int /* process the IRQ*/
1933: addql #8,%sp /* pop parameters off stack*/
Thomas Gleixner09f90f62013-11-11 21:01:03 +0100194 bra ret_from_exception
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195
196inthandler7:
Greg Ungerer61619b12011-06-22 13:50:44 +1000197 SAVE_ALL_INT
Philippe De Muytereb497e72010-08-30 13:17:17 +0200198 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 and #0x3ff, %d0
200
201 movel %sp,%sp@-
202 movel #71,%sp@- /* put vector # on stack*/
203 jbsr process_int /* process the IRQ*/
2043: addql #8,%sp /* pop parameters off stack*/
Thomas Gleixner09f90f62013-11-11 21:01:03 +0100205 bra ret_from_exception
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206
207inthandler:
Greg Ungerer61619b12011-06-22 13:50:44 +1000208 SAVE_ALL_INT
Philippe De Muytereb497e72010-08-30 13:17:17 +0200209 movew %sp@(PT_OFF_FORMATVEC), %d0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 and #0x3ff, %d0
211
212 movel %sp,%sp@-
213 movel %d0,%sp@- /* put vector # on stack*/
214 jbsr process_int /* process the IRQ*/
2153: addql #8,%sp /* pop parameters off stack*/
Thomas Gleixner09f90f62013-11-11 21:01:03 +0100216 bra ret_from_exception
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217
218/*
219 * Handler for uninitialized and spurious interrupts.
220 */
221ENTRY(bad_interrupt)
Geert Uytterhoeven8c9f08f2011-07-13 20:29:24 +0200222 addql #1,irq_err_count
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 rte
224
225/*
226 * Beware - when entering resume, prev (the current task) is
Greg Ungererf941f5c2011-05-05 22:32:12 +1000227 * in a0, next (the new task) is in a1, so don't change these
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 * registers until their contents are no longer needed.
229 */
230ENTRY(resume)
231 movel %a0,%d1 /* save prev thread in d1 */
232 movew %sr,%a0@(TASK_THREAD+THREAD_SR) /* save sr */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 SAVE_SWITCH_STACK
234 movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */
Greg Ungererf941f5c2011-05-05 22:32:12 +1000235 movel %usp,%a3 /* save usp */
236 movel %a3,%a0@(TASK_THREAD+THREAD_USP)
237
238 movel %a1@(TASK_THREAD+THREAD_USP),%a3 /* restore user stack */
239 movel %a3,%usp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */
241 RESTORE_SWITCH_STACK
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 movew %a1@(TASK_THREAD+THREAD_SR),%sr /* restore thread status reg */
243 rts
244