1 /* SPDX-License-Identifier: GPL-2.0-or-later 1 /* SPDX-License-Identifier: GPL-2.0-or-later 2 * 2 * 3 * entry.S -- non-mmu 68000 interrupt and exc 3 * entry.S -- non-mmu 68000 interrupt and exception entry points 4 * 4 * 5 * Copyright (C) 1991, 1992 Linus Torvalds 5 * Copyright (C) 1991, 1992 Linus Torvalds 6 * 6 * 7 * Linux/m68k support by Hamish Macdonald 7 * Linux/m68k support by Hamish Macdonald 8 */ 8 */ 9 9 10 #include <linux/linkage.h> 10 #include <linux/linkage.h> 11 #include <asm/thread_info.h> 11 #include <asm/thread_info.h> 12 #include <asm/unistd.h> 12 #include <asm/unistd.h> 13 #include <asm/errno.h> 13 #include <asm/errno.h> 14 #include <asm/setup.h> 14 #include <asm/setup.h> 15 #include <asm/traps.h> 15 #include <asm/traps.h> 16 #include <asm/asm-offsets.h> 16 #include <asm/asm-offsets.h> 17 #include <asm/entry.h> 17 #include <asm/entry.h> 18 18 19 .text 19 .text 20 20 21 .globl system_call 21 .globl system_call 22 .globl resume 22 .globl resume 23 .globl ret_from_exception 23 .globl ret_from_exception 24 .globl sys_call_table 24 .globl sys_call_table 25 .globl bad_interrupt 25 .globl bad_interrupt 26 .globl inthandler1 26 .globl inthandler1 27 .globl inthandler2 27 .globl inthandler2 28 .globl inthandler3 28 .globl inthandler3 29 .globl inthandler4 29 .globl inthandler4 30 .globl inthandler5 30 .globl inthandler5 31 .globl inthandler6 31 .globl inthandler6 32 .globl inthandler7 32 .globl inthandler7 33 33 34 badsys: 34 badsys: 35 movel #-ENOSYS,%sp@(PT_OFF_D0) 35 movel #-ENOSYS,%sp@(PT_OFF_D0) 36 jra ret_from_exception 36 jra ret_from_exception 37 37 38 do_trace: 38 do_trace: 39 movel #-ENOSYS,%sp@(PT_OFF_D0) /* ne 39 movel #-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/ 40 subql #4,%sp 40 subql #4,%sp 41 SAVE_SWITCH_STACK 41 SAVE_SWITCH_STACK 42 jbsr syscall_trace_enter 42 jbsr syscall_trace_enter 43 RESTORE_SWITCH_STACK 43 RESTORE_SWITCH_STACK 44 addql #4,%sp 44 addql #4,%sp 45 addql #1,%d0 45 addql #1,%d0 46 jeq ret_from_exception 46 jeq ret_from_exception 47 movel %sp@(PT_OFF_ORIG_D0),%d1 47 movel %sp@(PT_OFF_ORIG_D0),%d1 48 movel #-ENOSYS,%d0 48 movel #-ENOSYS,%d0 49 cmpl #NR_syscalls,%d1 49 cmpl #NR_syscalls,%d1 50 jcc 1f 50 jcc 1f 51 lsl #2,%d1 51 lsl #2,%d1 52 lea sys_call_table, %a0 52 lea sys_call_table, %a0 53 jbsr %a0@(%d1) 53 jbsr %a0@(%d1) 54 54 55 1: movel %d0,%sp@(PT_OFF_D0) /* sav 55 1: movel %d0,%sp@(PT_OFF_D0) /* save the return value */ 56 subql #4,%sp /* dum 56 subql #4,%sp /* dummy return address */ 57 SAVE_SWITCH_STACK 57 SAVE_SWITCH_STACK 58 jbsr syscall_trace_leave 58 jbsr syscall_trace_leave 59 RESTORE_SWITCH_STACK 59 RESTORE_SWITCH_STACK 60 addql #4,%sp 60 addql #4,%sp 61 jra ret_from_exception 61 jra ret_from_exception 62 62 63 ENTRY(system_call) 63 ENTRY(system_call) 64 SAVE_ALL_SYS 64 SAVE_ALL_SYS 65 65 66 /* save top of frame*/ 66 /* save top of frame*/ 67 pea %sp@ 67 pea %sp@ 68 jbsr set_esp0 68 jbsr set_esp0 69 addql #4,%sp 69 addql #4,%sp 70 70 71 movel %sp@(PT_OFF_ORIG_D0),%d0 71 movel %sp@(PT_OFF_ORIG_D0),%d0 72 72 73 movel %sp,%d1 /* get 73 movel %sp,%d1 /* get thread_info pointer */ 74 andl #-THREAD_SIZE,%d1 74 andl #-THREAD_SIZE,%d1 75 movel %d1,%a2 75 movel %d1,%a2 76 btst #(TIF_SYSCALL_TRACE%8),%a2@(TI 76 btst #(TIF_SYSCALL_TRACE%8),%a2@(TINFO_FLAGS+(31-TIF_SYSCALL_TRACE)/8) 77 jne do_trace 77 jne do_trace 78 cmpl #NR_syscalls,%d0 78 cmpl #NR_syscalls,%d0 79 jcc badsys 79 jcc badsys 80 lsl #2,%d0 80 lsl #2,%d0 81 lea sys_call_table,%a0 81 lea sys_call_table,%a0 82 movel %a0@(%d0), %a0 82 movel %a0@(%d0), %a0 83 jbsr %a0@ 83 jbsr %a0@ 84 movel %d0,%sp@(PT_OFF_D0) /* sav 84 movel %d0,%sp@(PT_OFF_D0) /* save the return value*/ 85 85 86 ret_from_exception: 86 ret_from_exception: 87 btst #5,%sp@(PT_OFF_SR) /* che 87 btst #5,%sp@(PT_OFF_SR) /* check if returning to kernel*/ 88 jeq Luser_return /* if 88 jeq Luser_return /* if so, skip resched, signals*/ 89 89 90 Lkernel_return: 90 Lkernel_return: 91 RESTORE_ALL 91 RESTORE_ALL 92 92 93 Luser_return: 93 Luser_return: 94 /* only allow interrupts when we are r 94 /* only allow interrupts when we are really the last one on the*/ 95 /* kernel stack, otherwise stack overf 95 /* kernel stack, otherwise stack overflow can occur during*/ 96 /* heavy interrupt load*/ 96 /* heavy interrupt load*/ 97 andw #ALLOWINT,%sr 97 andw #ALLOWINT,%sr 98 98 99 movel %sp,%d1 /* get 99 movel %sp,%d1 /* get thread_info pointer */ 100 andl #-THREAD_SIZE,%d1 100 andl #-THREAD_SIZE,%d1 101 movel %d1,%a2 101 movel %d1,%a2 102 1: 102 1: 103 move %a2@(TINFO_FLAGS),%d1 /* thr 103 move %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */ 104 jne Lwork_to_do 104 jne Lwork_to_do 105 RESTORE_ALL 105 RESTORE_ALL 106 106 107 Lwork_to_do: 107 Lwork_to_do: 108 movel %a2@(TINFO_FLAGS),%d1 /* thr 108 movel %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */ 109 btst #TIF_NEED_RESCHED,%d1 109 btst #TIF_NEED_RESCHED,%d1 110 jne reschedule 110 jne reschedule 111 111 112 Lsignal_return: 112 Lsignal_return: 113 subql #4,%sp /* dum 113 subql #4,%sp /* dummy return address*/ 114 SAVE_SWITCH_STACK 114 SAVE_SWITCH_STACK 115 pea %sp@(SWITCH_STACK_SIZE) 115 pea %sp@(SWITCH_STACK_SIZE) 116 bsrw do_notify_resume 116 bsrw do_notify_resume 117 addql #4,%sp 117 addql #4,%sp 118 RESTORE_SWITCH_STACK 118 RESTORE_SWITCH_STACK 119 addql #4,%sp 119 addql #4,%sp 120 jra 1b 120 jra 1b 121 121 122 /* 122 /* 123 * This is the main interrupt handler, respons 123 * This is the main interrupt handler, responsible for calling process_int() 124 */ 124 */ 125 inthandler1: 125 inthandler1: 126 SAVE_ALL_INT 126 SAVE_ALL_INT 127 movew %sp@(PT_OFF_FORMATVEC), %d0 127 movew %sp@(PT_OFF_FORMATVEC), %d0 128 and #0x3ff, %d0 128 and #0x3ff, %d0 129 129 130 movel %sp,%sp@- 130 movel %sp,%sp@- 131 movel #65,%sp@- /* pu 131 movel #65,%sp@- /* put vector # on stack*/ 132 jbsr process_int /* pr 132 jbsr process_int /* process the IRQ*/ 133 3: addql #8,%sp /* po 133 3: addql #8,%sp /* pop parameters off stack*/ 134 bra ret_from_exception 134 bra ret_from_exception 135 135 136 inthandler2: 136 inthandler2: 137 SAVE_ALL_INT 137 SAVE_ALL_INT 138 movew %sp@(PT_OFF_FORMATVEC), %d0 138 movew %sp@(PT_OFF_FORMATVEC), %d0 139 and #0x3ff, %d0 139 and #0x3ff, %d0 140 140 141 movel %sp,%sp@- 141 movel %sp,%sp@- 142 movel #66,%sp@- /* pu 142 movel #66,%sp@- /* put vector # on stack*/ 143 jbsr process_int /* pr 143 jbsr process_int /* process the IRQ*/ 144 3: addql #8,%sp /* po 144 3: addql #8,%sp /* pop parameters off stack*/ 145 bra ret_from_exception 145 bra ret_from_exception 146 146 147 inthandler3: 147 inthandler3: 148 SAVE_ALL_INT 148 SAVE_ALL_INT 149 movew %sp@(PT_OFF_FORMATVEC), %d0 149 movew %sp@(PT_OFF_FORMATVEC), %d0 150 and #0x3ff, %d0 150 and #0x3ff, %d0 151 151 152 movel %sp,%sp@- 152 movel %sp,%sp@- 153 movel #67,%sp@- /* pu 153 movel #67,%sp@- /* put vector # on stack*/ 154 jbsr process_int /* pr 154 jbsr process_int /* process the IRQ*/ 155 3: addql #8,%sp /* po 155 3: addql #8,%sp /* pop parameters off stack*/ 156 bra ret_from_exception 156 bra ret_from_exception 157 157 158 inthandler4: 158 inthandler4: 159 SAVE_ALL_INT 159 SAVE_ALL_INT 160 movew %sp@(PT_OFF_FORMATVEC), %d0 160 movew %sp@(PT_OFF_FORMATVEC), %d0 161 and #0x3ff, %d0 161 and #0x3ff, %d0 162 162 163 movel %sp,%sp@- 163 movel %sp,%sp@- 164 movel #68,%sp@- /* pu 164 movel #68,%sp@- /* put vector # on stack*/ 165 jbsr process_int /* pr 165 jbsr process_int /* process the IRQ*/ 166 3: addql #8,%sp /* po 166 3: addql #8,%sp /* pop parameters off stack*/ 167 bra ret_from_exception 167 bra ret_from_exception 168 168 169 inthandler5: 169 inthandler5: 170 SAVE_ALL_INT 170 SAVE_ALL_INT 171 movew %sp@(PT_OFF_FORMATVEC), %d0 171 movew %sp@(PT_OFF_FORMATVEC), %d0 172 and #0x3ff, %d0 172 and #0x3ff, %d0 173 173 174 movel %sp,%sp@- 174 movel %sp,%sp@- 175 movel #69,%sp@- /* pu 175 movel #69,%sp@- /* put vector # on stack*/ 176 jbsr process_int /* pr 176 jbsr process_int /* process the IRQ*/ 177 3: addql #8,%sp /* po 177 3: addql #8,%sp /* pop parameters off stack*/ 178 bra ret_from_exception 178 bra ret_from_exception 179 179 180 inthandler6: 180 inthandler6: 181 SAVE_ALL_INT 181 SAVE_ALL_INT 182 movew %sp@(PT_OFF_FORMATVEC), %d0 182 movew %sp@(PT_OFF_FORMATVEC), %d0 183 and #0x3ff, %d0 183 and #0x3ff, %d0 184 184 185 movel %sp,%sp@- 185 movel %sp,%sp@- 186 movel #70,%sp@- /* pu 186 movel #70,%sp@- /* put vector # on stack*/ 187 jbsr process_int /* pr 187 jbsr process_int /* process the IRQ*/ 188 3: addql #8,%sp /* po 188 3: addql #8,%sp /* pop parameters off stack*/ 189 bra ret_from_exception 189 bra ret_from_exception 190 190 191 inthandler7: 191 inthandler7: 192 SAVE_ALL_INT 192 SAVE_ALL_INT 193 movew %sp@(PT_OFF_FORMATVEC), %d0 193 movew %sp@(PT_OFF_FORMATVEC), %d0 194 and #0x3ff, %d0 194 and #0x3ff, %d0 195 195 196 movel %sp,%sp@- 196 movel %sp,%sp@- 197 movel #71,%sp@- /* pu 197 movel #71,%sp@- /* put vector # on stack*/ 198 jbsr process_int /* pr 198 jbsr process_int /* process the IRQ*/ 199 3: addql #8,%sp /* po 199 3: addql #8,%sp /* pop parameters off stack*/ 200 bra ret_from_exception 200 bra ret_from_exception 201 201 202 inthandler: 202 inthandler: 203 SAVE_ALL_INT 203 SAVE_ALL_INT 204 movew %sp@(PT_OFF_FORMATVEC), %d0 204 movew %sp@(PT_OFF_FORMATVEC), %d0 205 and #0x3ff, %d0 205 and #0x3ff, %d0 206 206 207 movel %sp,%sp@- 207 movel %sp,%sp@- 208 movel %d0,%sp@- /* pu 208 movel %d0,%sp@- /* put vector # on stack*/ 209 jbsr process_int /* pr 209 jbsr process_int /* process the IRQ*/ 210 3: addql #8,%sp /* po 210 3: addql #8,%sp /* pop parameters off stack*/ 211 bra ret_from_exception 211 bra ret_from_exception 212 212 213 /* 213 /* 214 * Handler for uninitialized and spurious inte 214 * Handler for uninitialized and spurious interrupts. 215 */ 215 */ 216 ENTRY(bad_interrupt) 216 ENTRY(bad_interrupt) 217 addql #1,irq_err_count 217 addql #1,irq_err_count 218 rte 218 rte 219 219 220 /* 220 /* 221 * Beware - when entering resume, prev (the cu 221 * Beware - when entering resume, prev (the current task) is 222 * in a0, next (the new task) is in a1, so don 222 * in a0, next (the new task) is in a1, so don't change these 223 * registers until their contents are no longe 223 * registers until their contents are no longer needed. 224 */ 224 */ 225 ENTRY(resume) 225 ENTRY(resume) 226 movel %a0,%d1 226 movel %a0,%d1 /* save prev thread in d1 */ 227 movew %sr,%a0@(TASK_THREAD+THREAD_SR 227 movew %sr,%a0@(TASK_THREAD+THREAD_SR) /* save sr */ 228 SAVE_SWITCH_STACK 228 SAVE_SWITCH_STACK 229 movel %sp,%a0@(TASK_THREAD+THREAD_KS 229 movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */ 230 movel %usp,%a3 230 movel %usp,%a3 /* save usp */ 231 movel %a3,%a0@(TASK_THREAD+THREAD_US 231 movel %a3,%a0@(TASK_THREAD+THREAD_USP) 232 232 233 movel %a1@(TASK_THREAD+THREAD_USP),% 233 movel %a1@(TASK_THREAD+THREAD_USP),%a3 /* restore user stack */ 234 movel %a3,%usp 234 movel %a3,%usp 235 movel %a1@(TASK_THREAD+THREAD_KSP),% 235 movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */ 236 RESTORE_SWITCH_STACK 236 RESTORE_SWITCH_STACK 237 movew %a1@(TASK_THREAD+THREAD_SR),%s 237 movew %a1@(TASK_THREAD+THREAD_SR),%sr /* restore thread status reg */ 238 rts 238 rts 239 239
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.