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