Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Greg Ungerer | 6f4a885 | 2014-08-21 22:10:31 +1000 | [diff] [blame] | 2 | * entry.S -- non-mmu 68000 interrupt and exception entry points |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | .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 | |
| 39 | badsys: |
Greg Ungerer | c84b564 | 2009-09-20 21:32:32 +1000 | [diff] [blame] | 40 | movel #-ENOSYS,%sp@(PT_OFF_D0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | jra ret_from_exception |
| 42 | |
| 43 | do_trace: |
Philippe De Muyter | 5061ea2c | 2010-08-17 18:52:39 +0200 | [diff] [blame] | 44 | movel #-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | subql #4,%sp |
| 46 | SAVE_SWITCH_STACK |
Greg Ungerer | 55f411d | 2010-10-22 15:12:34 +1000 | [diff] [blame] | 47 | jbsr syscall_trace_enter |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | RESTORE_SWITCH_STACK |
| 49 | addql #4,%sp |
Greg Ungerer | c84b564 | 2009-09-20 21:32:32 +1000 | [diff] [blame] | 50 | movel %sp@(PT_OFF_ORIG_D0),%d1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | 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 Muyter | 5061ea2c | 2010-08-17 18:52:39 +0200 | [diff] [blame] | 58 | 1: movel %d0,%sp@(PT_OFF_D0) /* save the return value */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | subql #4,%sp /* dummy return address */ |
| 60 | SAVE_SWITCH_STACK |
Greg Ungerer | 55f411d | 2010-10-22 15:12:34 +1000 | [diff] [blame] | 61 | jbsr syscall_trace_leave |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | ret_from_signal: |
| 64 | RESTORE_SWITCH_STACK |
| 65 | addql #4,%sp |
| 66 | jra ret_from_exception |
| 67 | |
| 68 | ENTRY(system_call) |
Greg Ungerer | 61619b1 | 2011-06-22 13:50:44 +1000 | [diff] [blame] | 69 | SAVE_ALL_SYS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | /* save top of frame*/ |
Philippe De Muyter | 5061ea2c | 2010-08-17 18:52:39 +0200 | [diff] [blame] | 72 | pea %sp@ |
| 73 | jbsr set_esp0 |
| 74 | addql #4,%sp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Greg Ungerer | c84b564 | 2009-09-20 21:32:32 +1000 | [diff] [blame] | 76 | movel %sp@(PT_OFF_ORIG_D0),%d0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
| 78 | movel %sp,%d1 /* get thread_info pointer */ |
Greg Ungerer | 8410a54 | 2005-09-02 10:42:52 +1000 | [diff] [blame] | 79 | andl #-THREAD_SIZE,%d1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | movel %d1,%a2 |
Greg Ungerer | aa4d1f8 | 2011-03-29 15:55:36 +1000 | [diff] [blame] | 81 | btst #(TIF_SYSCALL_TRACE%8),%a2@(TINFO_FLAGS+(31-TIF_SYSCALL_TRACE)/8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | 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 Muyter | 5061ea2c | 2010-08-17 18:52:39 +0200 | [diff] [blame] | 89 | movel %d0,%sp@(PT_OFF_D0) /* save the return value*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | |
| 91 | ret_from_exception: |
Philippe De Muyter | 5061ea2c | 2010-08-17 18:52:39 +0200 | [diff] [blame] | 92 | btst #5,%sp@(PT_OFF_SR) /* check if returning to kernel*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | jeq Luser_return /* if so, skip resched, signals*/ |
| 94 | |
| 95 | Lkernel_return: |
| 96 | RESTORE_ALL |
| 97 | |
| 98 | Luser_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 Ungerer | 8410a54 | 2005-09-02 10:42:52 +1000 | [diff] [blame] | 105 | andl #-THREAD_SIZE,%d1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | movel %d1,%a2 |
Al Viro | d1574df | 2010-10-11 23:29:28 -0400 | [diff] [blame] | 107 | 1: |
Greg Ungerer | aa4d1f8 | 2011-03-29 15:55:36 +1000 | [diff] [blame] | 108 | move %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | jne Lwork_to_do |
| 110 | RESTORE_ALL |
| 111 | |
| 112 | Lwork_to_do: |
Greg Ungerer | aa4d1f8 | 2011-03-29 15:55:36 +1000 | [diff] [blame] | 113 | movel %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | btst #TIF_NEED_RESCHED,%d1 |
| 115 | jne reschedule |
| 116 | |
| 117 | Lsignal_return: |
| 118 | subql #4,%sp /* dummy return address*/ |
| 119 | SAVE_SWITCH_STACK |
| 120 | pea %sp@(SWITCH_STACK_SIZE) |
Al Viro | a54f165 | 2012-04-24 01:46:23 -0400 | [diff] [blame] | 121 | bsrw do_notify_resume |
Al Viro | 710e91e | 2010-10-11 17:09:20 -0400 | [diff] [blame] | 122 | addql #4,%sp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | RESTORE_SWITCH_STACK |
| 124 | addql #4,%sp |
Al Viro | d1574df | 2010-10-11 23:29:28 -0400 | [diff] [blame] | 125 | jra 1b |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | |
| 127 | /* |
| 128 | * This is the main interrupt handler, responsible for calling process_int() |
| 129 | */ |
| 130 | inthandler1: |
Greg Ungerer | 61619b1 | 2011-06-22 13:50:44 +1000 | [diff] [blame] | 131 | SAVE_ALL_INT |
Philippe De Muyter | eb497e7 | 2010-08-30 13:17:17 +0200 | [diff] [blame] | 132 | movew %sp@(PT_OFF_FORMATVEC), %d0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | and #0x3ff, %d0 |
| 134 | |
| 135 | movel %sp,%sp@- |
| 136 | movel #65,%sp@- /* put vector # on stack*/ |
| 137 | jbsr process_int /* process the IRQ*/ |
| 138 | 3: addql #8,%sp /* pop parameters off stack*/ |
Thomas Gleixner | 09f90f6 | 2013-11-11 21:01:03 +0100 | [diff] [blame] | 139 | bra ret_from_exception |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
| 141 | inthandler2: |
Greg Ungerer | 61619b1 | 2011-06-22 13:50:44 +1000 | [diff] [blame] | 142 | SAVE_ALL_INT |
Philippe De Muyter | eb497e7 | 2010-08-30 13:17:17 +0200 | [diff] [blame] | 143 | movew %sp@(PT_OFF_FORMATVEC), %d0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | and #0x3ff, %d0 |
| 145 | |
| 146 | movel %sp,%sp@- |
| 147 | movel #66,%sp@- /* put vector # on stack*/ |
| 148 | jbsr process_int /* process the IRQ*/ |
| 149 | 3: addql #8,%sp /* pop parameters off stack*/ |
Thomas Gleixner | 09f90f6 | 2013-11-11 21:01:03 +0100 | [diff] [blame] | 150 | bra ret_from_exception |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | |
| 152 | inthandler3: |
Greg Ungerer | 61619b1 | 2011-06-22 13:50:44 +1000 | [diff] [blame] | 153 | SAVE_ALL_INT |
Philippe De Muyter | eb497e7 | 2010-08-30 13:17:17 +0200 | [diff] [blame] | 154 | movew %sp@(PT_OFF_FORMATVEC), %d0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | and #0x3ff, %d0 |
| 156 | |
| 157 | movel %sp,%sp@- |
| 158 | movel #67,%sp@- /* put vector # on stack*/ |
| 159 | jbsr process_int /* process the IRQ*/ |
| 160 | 3: addql #8,%sp /* pop parameters off stack*/ |
Thomas Gleixner | 09f90f6 | 2013-11-11 21:01:03 +0100 | [diff] [blame] | 161 | bra ret_from_exception |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
| 163 | inthandler4: |
Greg Ungerer | 61619b1 | 2011-06-22 13:50:44 +1000 | [diff] [blame] | 164 | SAVE_ALL_INT |
Philippe De Muyter | eb497e7 | 2010-08-30 13:17:17 +0200 | [diff] [blame] | 165 | movew %sp@(PT_OFF_FORMATVEC), %d0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | and #0x3ff, %d0 |
| 167 | |
| 168 | movel %sp,%sp@- |
| 169 | movel #68,%sp@- /* put vector # on stack*/ |
| 170 | jbsr process_int /* process the IRQ*/ |
| 171 | 3: addql #8,%sp /* pop parameters off stack*/ |
Thomas Gleixner | 09f90f6 | 2013-11-11 21:01:03 +0100 | [diff] [blame] | 172 | bra ret_from_exception |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | |
| 174 | inthandler5: |
Greg Ungerer | 61619b1 | 2011-06-22 13:50:44 +1000 | [diff] [blame] | 175 | SAVE_ALL_INT |
Philippe De Muyter | eb497e7 | 2010-08-30 13:17:17 +0200 | [diff] [blame] | 176 | movew %sp@(PT_OFF_FORMATVEC), %d0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | and #0x3ff, %d0 |
| 178 | |
| 179 | movel %sp,%sp@- |
| 180 | movel #69,%sp@- /* put vector # on stack*/ |
| 181 | jbsr process_int /* process the IRQ*/ |
| 182 | 3: addql #8,%sp /* pop parameters off stack*/ |
Thomas Gleixner | 09f90f6 | 2013-11-11 21:01:03 +0100 | [diff] [blame] | 183 | bra ret_from_exception |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | |
| 185 | inthandler6: |
Greg Ungerer | 61619b1 | 2011-06-22 13:50:44 +1000 | [diff] [blame] | 186 | SAVE_ALL_INT |
Philippe De Muyter | eb497e7 | 2010-08-30 13:17:17 +0200 | [diff] [blame] | 187 | movew %sp@(PT_OFF_FORMATVEC), %d0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | and #0x3ff, %d0 |
| 189 | |
| 190 | movel %sp,%sp@- |
| 191 | movel #70,%sp@- /* put vector # on stack*/ |
| 192 | jbsr process_int /* process the IRQ*/ |
| 193 | 3: addql #8,%sp /* pop parameters off stack*/ |
Thomas Gleixner | 09f90f6 | 2013-11-11 21:01:03 +0100 | [diff] [blame] | 194 | bra ret_from_exception |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | |
| 196 | inthandler7: |
Greg Ungerer | 61619b1 | 2011-06-22 13:50:44 +1000 | [diff] [blame] | 197 | SAVE_ALL_INT |
Philippe De Muyter | eb497e7 | 2010-08-30 13:17:17 +0200 | [diff] [blame] | 198 | movew %sp@(PT_OFF_FORMATVEC), %d0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | and #0x3ff, %d0 |
| 200 | |
| 201 | movel %sp,%sp@- |
| 202 | movel #71,%sp@- /* put vector # on stack*/ |
| 203 | jbsr process_int /* process the IRQ*/ |
| 204 | 3: addql #8,%sp /* pop parameters off stack*/ |
Thomas Gleixner | 09f90f6 | 2013-11-11 21:01:03 +0100 | [diff] [blame] | 205 | bra ret_from_exception |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | |
| 207 | inthandler: |
Greg Ungerer | 61619b1 | 2011-06-22 13:50:44 +1000 | [diff] [blame] | 208 | SAVE_ALL_INT |
Philippe De Muyter | eb497e7 | 2010-08-30 13:17:17 +0200 | [diff] [blame] | 209 | movew %sp@(PT_OFF_FORMATVEC), %d0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | and #0x3ff, %d0 |
| 211 | |
| 212 | movel %sp,%sp@- |
| 213 | movel %d0,%sp@- /* put vector # on stack*/ |
| 214 | jbsr process_int /* process the IRQ*/ |
| 215 | 3: addql #8,%sp /* pop parameters off stack*/ |
Thomas Gleixner | 09f90f6 | 2013-11-11 21:01:03 +0100 | [diff] [blame] | 216 | bra ret_from_exception |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | |
| 218 | /* |
| 219 | * Handler for uninitialized and spurious interrupts. |
| 220 | */ |
| 221 | ENTRY(bad_interrupt) |
Geert Uytterhoeven | 8c9f08f | 2011-07-13 20:29:24 +0200 | [diff] [blame] | 222 | addql #1,irq_err_count |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | rte |
| 224 | |
| 225 | /* |
| 226 | * Beware - when entering resume, prev (the current task) is |
Greg Ungerer | f941f5c | 2011-05-05 22:32:12 +1000 | [diff] [blame] | 227 | * in a0, next (the new task) is in a1, so don't change these |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | * registers until their contents are no longer needed. |
| 229 | */ |
| 230 | ENTRY(resume) |
| 231 | movel %a0,%d1 /* save prev thread in d1 */ |
| 232 | movew %sr,%a0@(TASK_THREAD+THREAD_SR) /* save sr */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | SAVE_SWITCH_STACK |
| 234 | movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */ |
Greg Ungerer | f941f5c | 2011-05-05 22:32:12 +1000 | [diff] [blame] | 235 | 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */ |
| 241 | RESTORE_SWITCH_STACK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | movew %a1@(TASK_THREAD+THREAD_SR),%sr /* restore thread status reg */ |
| 243 | rts |
| 244 | |