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