Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/m68knommu/platform/68360/entry.S |
| 3 | * |
| 4 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 5 | * Copyright (C) 2001 SED Systems, a Division of Calian Ltd. |
| 6 | * |
| 7 | * This file is subject to the terms and conditions of the GNU General Public |
| 8 | * License. See the file README.legal in the main directory of this archive |
| 9 | * for more details. |
| 10 | * |
| 11 | * Linux/m68k support by Hamish Macdonald |
| 12 | * M68360 Port by SED Systems, and Lineo. |
| 13 | */ |
| 14 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/sys.h> |
| 16 | #include <linux/linkage.h> |
| 17 | #include <asm/thread_info.h> |
| 18 | #include <asm/unistd.h> |
| 19 | #include <asm/errno.h> |
| 20 | #include <asm/setup.h> |
| 21 | #include <asm/segment.h> |
| 22 | #include <asm/traps.h> |
| 23 | #include <asm/asm-offsets.h> |
| 24 | #include <asm/entry.h> |
| 25 | |
| 26 | .text |
| 27 | |
| 28 | .globl system_call |
| 29 | .globl resume |
| 30 | .globl ret_from_exception |
| 31 | .globl ret_from_signal |
| 32 | .globl sys_call_table |
| 33 | .globl ret_from_interrupt |
| 34 | .globl bad_interrupt |
| 35 | .globl inthandler |
| 36 | |
| 37 | badsys: |
Greg Ungerer | c84b564 | 2009-09-20 21:32:32 +1000 | [diff] [blame] | 38 | movel #-ENOSYS,%sp@(PT_OFF_D0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | jra ret_from_exception |
| 40 | |
| 41 | do_trace: |
Greg Ungerer | c84b564 | 2009-09-20 21:32:32 +1000 | [diff] [blame] | 42 | movel #-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | subql #4,%sp |
| 44 | SAVE_SWITCH_STACK |
Greg Ungerer | 55f411d | 2010-10-22 15:12:34 +1000 | [diff] [blame] | 45 | jbsr syscall_trace_enter |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | RESTORE_SWITCH_STACK |
| 47 | addql #4,%sp |
Greg Ungerer | c84b564 | 2009-09-20 21:32:32 +1000 | [diff] [blame] | 48 | movel %sp@(PT_OFF_ORIG_D0),%d1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | movel #-ENOSYS,%d0 |
| 50 | cmpl #NR_syscalls,%d1 |
| 51 | jcc 1f |
| 52 | lsl #2,%d1 |
| 53 | lea sys_call_table, %a0 |
| 54 | jbsr %a0@(%d1) |
| 55 | |
Greg Ungerer | c84b564 | 2009-09-20 21:32:32 +1000 | [diff] [blame] | 56 | 1: movel %d0,%sp@(PT_OFF_D0) /* save the return value */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | subql #4,%sp /* dummy return address */ |
| 58 | SAVE_SWITCH_STACK |
Greg Ungerer | 55f411d | 2010-10-22 15:12:34 +1000 | [diff] [blame] | 59 | jbsr syscall_trace_leave |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | |
| 61 | ret_from_signal: |
| 62 | RESTORE_SWITCH_STACK |
| 63 | addql #4,%sp |
| 64 | jra ret_from_exception |
| 65 | |
| 66 | ENTRY(system_call) |
| 67 | SAVE_ALL |
| 68 | |
| 69 | /* save top of frame*/ |
| 70 | pea %sp@ |
| 71 | jbsr set_esp0 |
| 72 | addql #4,%sp |
| 73 | |
Philippe De Muyter | c8a2786 | 2010-08-17 18:58:29 +0200 | [diff] [blame] | 74 | movel %sp@(PT_OFF_ORIG_D0),%d0 |
| 75 | |
| 76 | movel %sp,%d1 /* get thread_info pointer */ |
| 77 | andl #-THREAD_SIZE,%d1 |
| 78 | movel %d1,%a2 |
| 79 | btst #(TIF_SYSCALL_TRACE%8),%a2@(TI_FLAGS+(31-TIF_SYSCALL_TRACE)/8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | jne do_trace |
| 81 | cmpl #NR_syscalls,%d0 |
| 82 | jcc badsys |
| 83 | lsl #2,%d0 |
| 84 | lea sys_call_table,%a0 |
| 85 | movel %a0@(%d0), %a0 |
| 86 | jbsr %a0@ |
Greg Ungerer | c84b564 | 2009-09-20 21:32:32 +1000 | [diff] [blame] | 87 | movel %d0,%sp@(PT_OFF_D0) /* save the return value*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
| 89 | ret_from_exception: |
Greg Ungerer | c84b564 | 2009-09-20 21:32:32 +1000 | [diff] [blame] | 90 | btst #5,%sp@(PT_OFF_SR) /* check if returning to kernel*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | jeq Luser_return /* if so, skip resched, signals*/ |
| 92 | |
| 93 | Lkernel_return: |
| 94 | RESTORE_ALL |
| 95 | |
| 96 | Luser_return: |
| 97 | /* only allow interrupts when we are really the last one on the*/ |
| 98 | /* kernel stack, otherwise stack overflow can occur during*/ |
| 99 | /* heavy interrupt load*/ |
| 100 | andw #ALLOWINT,%sr |
| 101 | |
| 102 | movel %sp,%d1 /* get thread_info pointer */ |
Greg Ungerer | 8410a54 | 2005-09-02 10:42:52 +1000 | [diff] [blame] | 103 | andl #-THREAD_SIZE,%d1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | movel %d1,%a2 |
| 105 | move %a2@(TI_FLAGS),%d1 /* thread_info->flags */ |
| 106 | andl #_TIF_WORK_MASK,%d1 |
| 107 | jne Lwork_to_do |
| 108 | RESTORE_ALL |
| 109 | |
| 110 | Lwork_to_do: |
| 111 | movel %a2@(TI_FLAGS),%d1 /* thread_info->flags */ |
| 112 | btst #TIF_NEED_RESCHED,%d1 |
| 113 | jne reschedule |
| 114 | |
| 115 | Lsignal_return: |
| 116 | subql #4,%sp /* dummy return address*/ |
| 117 | SAVE_SWITCH_STACK |
| 118 | pea %sp@(SWITCH_STACK_SIZE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | bsrw do_signal |
Al Viro | 710e91e | 2010-10-11 17:09:20 -0400 | [diff] [blame^] | 120 | addql #4,%sp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | RESTORE_SWITCH_STACK |
| 122 | addql #4,%sp |
| 123 | Lreturn: |
| 124 | RESTORE_ALL |
| 125 | |
| 126 | /* |
Greg Ungerer | 2502b667 | 2007-07-19 01:49:12 -0700 | [diff] [blame] | 127 | * This is the main interrupt handler, responsible for calling do_IRQ() |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | */ |
| 129 | inthandler: |
| 130 | SAVE_ALL |
Philippe De Muyter | eb497e7 | 2010-08-30 13:17:17 +0200 | [diff] [blame] | 131 | movew %sp@(PT_OFF_FORMATVEC), %d0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | and.l #0x3ff, %d0 |
| 133 | lsr.l #0x02, %d0 |
| 134 | |
| 135 | movel %sp,%sp@- |
| 136 | movel %d0,%sp@- /* put vector # on stack*/ |
Greg Ungerer | 2502b667 | 2007-07-19 01:49:12 -0700 | [diff] [blame] | 137 | jbsr do_IRQ /* process the IRQ*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | 3: addql #8,%sp /* pop parameters off stack*/ |
| 139 | bra ret_from_interrupt |
| 140 | |
| 141 | ret_from_interrupt: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | jeq 1f |
| 143 | 2: |
| 144 | RESTORE_ALL |
| 145 | 1: |
Greg Ungerer | c84b564 | 2009-09-20 21:32:32 +1000 | [diff] [blame] | 146 | moveb %sp@(PT_OFF_SR), %d0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | and #7, %d0 |
| 148 | jhi 2b |
| 149 | /* check if we need to do software interrupts */ |
| 150 | |
| 151 | movel irq_stat+CPUSTAT_SOFTIRQ_PENDING,%d0 |
| 152 | jeq ret_from_exception |
| 153 | |
| 154 | pea ret_from_exception |
| 155 | jra do_softirq |
| 156 | |
| 157 | |
| 158 | /* |
| 159 | * Handler for uninitialized and spurious interrupts. |
| 160 | */ |
| 161 | bad_interrupt: |
| 162 | addql #1,num_spurious |
| 163 | rte |
| 164 | |
| 165 | /* |
| 166 | * Beware - when entering resume, prev (the current task) is |
| 167 | * in a0, next (the new task) is in a1,so don't change these |
| 168 | * registers until their contents are no longer needed. |
| 169 | */ |
| 170 | ENTRY(resume) |
| 171 | movel %a0,%d1 /* save prev thread in d1 */ |
| 172 | movew %sr,%a0@(TASK_THREAD+THREAD_SR) /* save sr */ |
| 173 | movel %usp,%a2 /* save usp */ |
| 174 | movel %a2,%a0@(TASK_THREAD+THREAD_USP) |
| 175 | |
| 176 | SAVE_SWITCH_STACK |
| 177 | movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */ |
| 178 | movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */ |
| 179 | RESTORE_SWITCH_STACK |
| 180 | |
| 181 | movel %a1@(TASK_THREAD+THREAD_USP),%a0 /* restore user stack */ |
| 182 | movel %a0,%usp |
| 183 | movew %a1@(TASK_THREAD+THREAD_SR),%sr /* restore thread status reg */ |
| 184 | rts |
| 185 | |