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 | |
| 13 | #include <linux/config.h> |
| 14 | #include <linux/sys.h> |
| 15 | #include <linux/linkage.h> |
| 16 | #include <asm/thread_info.h> |
| 17 | #include <asm/unistd.h> |
| 18 | #include <asm/errno.h> |
| 19 | #include <asm/setup.h> |
| 20 | #include <asm/segment.h> |
| 21 | #include <asm/traps.h> |
| 22 | #include <asm/asm-offsets.h> |
| 23 | #include <asm/entry.h> |
| 24 | |
| 25 | .text |
| 26 | |
| 27 | .globl system_call |
| 28 | .globl resume |
| 29 | .globl ret_from_exception |
| 30 | .globl ret_from_signal |
| 31 | .globl sys_call_table |
| 32 | .globl ret_from_interrupt |
| 33 | .globl bad_interrupt |
| 34 | .globl inthandler1 |
| 35 | .globl inthandler2 |
| 36 | .globl inthandler3 |
| 37 | .globl inthandler4 |
| 38 | .globl inthandler5 |
| 39 | .globl inthandler6 |
| 40 | .globl inthandler7 |
| 41 | |
| 42 | badsys: |
| 43 | movel #-ENOSYS,%sp@(PT_D0) |
| 44 | jra ret_from_exception |
| 45 | |
| 46 | do_trace: |
| 47 | movel #-ENOSYS,%sp@(PT_D0) /* needed for strace*/ |
| 48 | subql #4,%sp |
| 49 | SAVE_SWITCH_STACK |
| 50 | jbsr syscall_trace |
| 51 | RESTORE_SWITCH_STACK |
| 52 | addql #4,%sp |
| 53 | movel %sp@(PT_ORIG_D0),%d1 |
| 54 | movel #-ENOSYS,%d0 |
| 55 | cmpl #NR_syscalls,%d1 |
| 56 | jcc 1f |
| 57 | lsl #2,%d1 |
| 58 | lea sys_call_table, %a0 |
| 59 | jbsr %a0@(%d1) |
| 60 | |
| 61 | 1: movel %d0,%sp@(PT_D0) /* save the return value */ |
| 62 | subql #4,%sp /* dummy return address */ |
| 63 | SAVE_SWITCH_STACK |
| 64 | jbsr syscall_trace |
| 65 | |
| 66 | ret_from_signal: |
| 67 | RESTORE_SWITCH_STACK |
| 68 | addql #4,%sp |
| 69 | jra ret_from_exception |
| 70 | |
| 71 | ENTRY(system_call) |
| 72 | SAVE_ALL |
| 73 | |
| 74 | /* save top of frame*/ |
| 75 | pea %sp@ |
| 76 | jbsr set_esp0 |
| 77 | addql #4,%sp |
| 78 | |
| 79 | movel %sp@(PT_ORIG_D0),%d0 |
| 80 | |
| 81 | movel %sp,%d1 /* get thread_info pointer */ |
| 82 | andl #0xffffe000,%d1 |
| 83 | movel %d1,%a2 |
| 84 | btst #TIF_SYSCALL_TRACE,%a2@(TI_FLAGS) |
| 85 | jne do_trace |
| 86 | cmpl #NR_syscalls,%d0 |
| 87 | jcc badsys |
| 88 | lsl #2,%d0 |
| 89 | lea sys_call_table,%a0 |
| 90 | movel %a0@(%d0), %a0 |
| 91 | jbsr %a0@ |
| 92 | movel %d0,%sp@(PT_D0) /* save the return value*/ |
| 93 | |
| 94 | ret_from_exception: |
| 95 | btst #5,%sp@(PT_SR) /* check if returning to kernel*/ |
| 96 | jeq Luser_return /* if so, skip resched, signals*/ |
| 97 | |
| 98 | Lkernel_return: |
| 99 | RESTORE_ALL |
| 100 | |
| 101 | Luser_return: |
| 102 | /* only allow interrupts when we are really the last one on the*/ |
| 103 | /* kernel stack, otherwise stack overflow can occur during*/ |
| 104 | /* heavy interrupt load*/ |
| 105 | andw #ALLOWINT,%sr |
| 106 | |
| 107 | movel %sp,%d1 /* get thread_info pointer */ |
| 108 | andl #0xffffe000,%d1 |
| 109 | movel %d1,%a2 |
| 110 | move %a2@(TI_FLAGS),%d1 /* thread_info->flags */ |
| 111 | andl #_TIF_WORK_MASK,%d1 |
| 112 | jne Lwork_to_do |
| 113 | RESTORE_ALL |
| 114 | |
| 115 | Lwork_to_do: |
| 116 | movel %a2@(TI_FLAGS),%d1 /* thread_info->flags */ |
| 117 | btst #TIF_NEED_RESCHED,%d1 |
| 118 | jne reschedule |
| 119 | |
| 120 | Lsignal_return: |
| 121 | subql #4,%sp /* dummy return address*/ |
| 122 | SAVE_SWITCH_STACK |
| 123 | pea %sp@(SWITCH_STACK_SIZE) |
| 124 | clrl %sp@- |
| 125 | bsrw do_signal |
| 126 | addql #8,%sp |
| 127 | RESTORE_SWITCH_STACK |
| 128 | addql #4,%sp |
| 129 | Lreturn: |
| 130 | RESTORE_ALL |
| 131 | |
| 132 | /* |
| 133 | * This is the main interrupt handler, responsible for calling process_int() |
| 134 | */ |
| 135 | inthandler1: |
| 136 | SAVE_ALL |
| 137 | addql #1,local_irq_count /* put exception # in d0*/ |
| 138 | movew %sp@(PT_VECTOR), %d0 |
| 139 | and #0x3ff, %d0 |
| 140 | |
| 141 | movel %sp,%sp@- |
| 142 | movel #65,%sp@- /* put vector # on stack*/ |
| 143 | jbsr process_int /* process the IRQ*/ |
| 144 | 3: addql #8,%sp /* pop parameters off stack*/ |
| 145 | bra ret_from_interrupt |
| 146 | |
| 147 | inthandler2: |
| 148 | SAVE_ALL |
| 149 | addql #1,local_irq_count /* put exception # in d0*/ |
| 150 | movew %sp@(PT_VECTOR), %d0 |
| 151 | and #0x3ff, %d0 |
| 152 | |
| 153 | movel %sp,%sp@- |
| 154 | movel #66,%sp@- /* put vector # on stack*/ |
| 155 | jbsr process_int /* process the IRQ*/ |
| 156 | 3: addql #8,%sp /* pop parameters off stack*/ |
| 157 | bra ret_from_interrupt |
| 158 | |
| 159 | inthandler3: |
| 160 | SAVE_ALL |
| 161 | addql #1,local_irq_count /* put exception # in d0*/ |
| 162 | movew %sp@(PT_VECTOR), %d0 |
| 163 | and #0x3ff, %d0 |
| 164 | |
| 165 | movel %sp,%sp@- |
| 166 | movel #67,%sp@- /* put vector # on stack*/ |
| 167 | jbsr process_int /* process the IRQ*/ |
| 168 | 3: addql #8,%sp /* pop parameters off stack*/ |
| 169 | bra ret_from_interrupt |
| 170 | |
| 171 | inthandler4: |
| 172 | SAVE_ALL |
| 173 | addql #1,local_irq_count /* put exception # in d0*/ |
| 174 | movew %sp@(PT_VECTOR), %d0 |
| 175 | and #0x3ff, %d0 |
| 176 | |
| 177 | movel %sp,%sp@- |
| 178 | movel #68,%sp@- /* put vector # on stack*/ |
| 179 | jbsr process_int /* process the IRQ*/ |
| 180 | 3: addql #8,%sp /* pop parameters off stack*/ |
| 181 | bra ret_from_interrupt |
| 182 | |
| 183 | inthandler5: |
| 184 | SAVE_ALL |
| 185 | addql #1,local_irq_count /* put exception # in d0*/ |
| 186 | movew %sp@(PT_VECTOR), %d0 |
| 187 | and #0x3ff, %d0 |
| 188 | |
| 189 | movel %sp,%sp@- |
| 190 | movel #69,%sp@- /* put vector # on stack*/ |
| 191 | jbsr process_int /* process the IRQ*/ |
| 192 | 3: addql #8,%sp /* pop parameters off stack*/ |
| 193 | bra ret_from_interrupt |
| 194 | |
| 195 | inthandler6: |
| 196 | SAVE_ALL |
| 197 | addql #1,local_irq_count /* put exception # in d0*/ |
| 198 | movew %sp@(PT_VECTOR), %d0 |
| 199 | and #0x3ff, %d0 |
| 200 | |
| 201 | movel %sp,%sp@- |
| 202 | movel #70,%sp@- /* put vector # on stack*/ |
| 203 | jbsr process_int /* process the IRQ*/ |
| 204 | 3: addql #8,%sp /* pop parameters off stack*/ |
| 205 | bra ret_from_interrupt |
| 206 | |
| 207 | inthandler7: |
| 208 | SAVE_ALL |
| 209 | addql #1,local_irq_count /* put exception # in d0*/ |
| 210 | movew %sp@(PT_VECTOR), %d0 |
| 211 | and #0x3ff, %d0 |
| 212 | |
| 213 | movel %sp,%sp@- |
| 214 | movel #71,%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 | inthandler: |
| 220 | SAVE_ALL |
| 221 | addql #1,local_irq_count /* put exception # in d0*/ |
| 222 | movew %sp@(PT_VECTOR), %d0 |
| 223 | and #0x3ff, %d0 |
| 224 | |
| 225 | movel %sp,%sp@- |
| 226 | movel %d0,%sp@- /* put vector # on stack*/ |
| 227 | jbsr process_int /* process the IRQ*/ |
| 228 | 3: addql #8,%sp /* pop parameters off stack*/ |
| 229 | bra ret_from_interrupt |
| 230 | |
| 231 | ret_from_interrupt: |
| 232 | subql #1,local_irq_count |
| 233 | jeq 1f |
| 234 | 2: |
| 235 | RESTORE_ALL |
| 236 | 1: |
| 237 | moveb %sp@(PT_SR), %d0 |
| 238 | and #7, %d0 |
| 239 | jhi 2b |
| 240 | |
| 241 | /* check if we need to do software interrupts */ |
| 242 | movel local_irq_count,%d0 |
| 243 | jeq ret_from_exception |
| 244 | |
| 245 | pea ret_from_exception |
| 246 | jra do_softirq |
| 247 | |
| 248 | |
| 249 | /* |
| 250 | * Handler for uninitialized and spurious interrupts. |
| 251 | */ |
| 252 | ENTRY(bad_interrupt) |
| 253 | addql #1,num_spurious |
| 254 | rte |
| 255 | |
| 256 | /* |
| 257 | * Beware - when entering resume, prev (the current task) is |
| 258 | * in a0, next (the new task) is in a1,so don't change these |
| 259 | * registers until their contents are no longer needed. |
| 260 | */ |
| 261 | ENTRY(resume) |
| 262 | movel %a0,%d1 /* save prev thread in d1 */ |
| 263 | movew %sr,%a0@(TASK_THREAD+THREAD_SR) /* save sr */ |
| 264 | movel %usp,%a2 /* save usp */ |
| 265 | movel %a2,%a0@(TASK_THREAD+THREAD_USP) |
| 266 | |
| 267 | SAVE_SWITCH_STACK |
| 268 | movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */ |
| 269 | movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */ |
| 270 | RESTORE_SWITCH_STACK |
| 271 | |
| 272 | movel %a1@(TASK_THREAD+THREAD_USP),%a0 /* restore user stack */ |
| 273 | movel %a0,%usp |
| 274 | movew %a1@(TASK_THREAD+THREAD_SR),%sr /* restore thread status reg */ |
| 275 | rts |
| 276 | |