Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Greg Ungerer | 6f4a885 | 2014-08-21 22:10:31 +1000 | [diff] [blame] | 2 | * entry.S - non-mmu 68360 interrupt and exceptions entry points |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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/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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | .globl bad_interrupt |
| 33 | .globl inthandler |
| 34 | |
| 35 | badsys: |
Greg Ungerer | c84b564 | 2009-09-20 21:32:32 +1000 | [diff] [blame] | 36 | movel #-ENOSYS,%sp@(PT_OFF_D0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | jra ret_from_exception |
| 38 | |
| 39 | do_trace: |
Greg Ungerer | c84b564 | 2009-09-20 21:32:32 +1000 | [diff] [blame] | 40 | movel #-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | subql #4,%sp |
| 42 | SAVE_SWITCH_STACK |
Greg Ungerer | 55f411d | 2010-10-22 15:12:34 +1000 | [diff] [blame] | 43 | jbsr syscall_trace_enter |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | RESTORE_SWITCH_STACK |
| 45 | addql #4,%sp |
Greg Ungerer | c84b564 | 2009-09-20 21:32:32 +1000 | [diff] [blame] | 46 | movel %sp@(PT_OFF_ORIG_D0),%d1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | movel #-ENOSYS,%d0 |
| 48 | cmpl #NR_syscalls,%d1 |
| 49 | jcc 1f |
| 50 | lsl #2,%d1 |
| 51 | lea sys_call_table, %a0 |
| 52 | jbsr %a0@(%d1) |
| 53 | |
Greg Ungerer | c84b564 | 2009-09-20 21:32:32 +1000 | [diff] [blame] | 54 | 1: movel %d0,%sp@(PT_OFF_D0) /* save the return value */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | subql #4,%sp /* dummy return address */ |
| 56 | SAVE_SWITCH_STACK |
Greg Ungerer | 55f411d | 2010-10-22 15:12:34 +1000 | [diff] [blame] | 57 | jbsr syscall_trace_leave |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | ret_from_signal: |
| 60 | RESTORE_SWITCH_STACK |
| 61 | addql #4,%sp |
| 62 | jra ret_from_exception |
| 63 | |
| 64 | ENTRY(system_call) |
Greg Ungerer | 61619b1 | 2011-06-22 13:50:44 +1000 | [diff] [blame] | 65 | SAVE_ALL_SYS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
| 67 | /* save top of frame*/ |
| 68 | pea %sp@ |
| 69 | jbsr set_esp0 |
| 70 | addql #4,%sp |
| 71 | |
Philippe De Muyter | c8a2786 | 2010-08-17 18:58:29 +0200 | [diff] [blame] | 72 | movel %sp@(PT_OFF_ORIG_D0),%d0 |
| 73 | |
| 74 | movel %sp,%d1 /* get thread_info pointer */ |
| 75 | andl #-THREAD_SIZE,%d1 |
| 76 | movel %d1,%a2 |
Greg Ungerer | aa4d1f8 | 2011-03-29 15:55:36 +1000 | [diff] [blame] | 77 | 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] | 78 | jne do_trace |
| 79 | cmpl #NR_syscalls,%d0 |
| 80 | jcc badsys |
| 81 | lsl #2,%d0 |
| 82 | lea sys_call_table,%a0 |
| 83 | movel %a0@(%d0), %a0 |
| 84 | jbsr %a0@ |
Greg Ungerer | c84b564 | 2009-09-20 21:32:32 +1000 | [diff] [blame] | 85 | movel %d0,%sp@(PT_OFF_D0) /* save the return value*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | |
| 87 | ret_from_exception: |
Greg Ungerer | c84b564 | 2009-09-20 21:32:32 +1000 | [diff] [blame] | 88 | btst #5,%sp@(PT_OFF_SR) /* check if returning to kernel*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | jeq Luser_return /* if so, skip resched, signals*/ |
| 90 | |
| 91 | Lkernel_return: |
| 92 | RESTORE_ALL |
| 93 | |
| 94 | Luser_return: |
| 95 | /* only allow interrupts when we are really the last one on the*/ |
| 96 | /* kernel stack, otherwise stack overflow can occur during*/ |
| 97 | /* heavy interrupt load*/ |
| 98 | andw #ALLOWINT,%sr |
| 99 | |
| 100 | movel %sp,%d1 /* get thread_info pointer */ |
Greg Ungerer | 8410a54 | 2005-09-02 10:42:52 +1000 | [diff] [blame] | 101 | andl #-THREAD_SIZE,%d1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | movel %d1,%a2 |
Al Viro | d1574df | 2010-10-11 23:29:28 -0400 | [diff] [blame] | 103 | 1: |
Greg Ungerer | aa4d1f8 | 2011-03-29 15:55:36 +1000 | [diff] [blame] | 104 | move %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | jne Lwork_to_do |
| 106 | RESTORE_ALL |
| 107 | |
| 108 | Lwork_to_do: |
Greg Ungerer | aa4d1f8 | 2011-03-29 15:55:36 +1000 | [diff] [blame] | 109 | movel %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | btst #TIF_NEED_RESCHED,%d1 |
| 111 | jne reschedule |
| 112 | |
| 113 | Lsignal_return: |
| 114 | subql #4,%sp /* dummy return address*/ |
| 115 | SAVE_SWITCH_STACK |
| 116 | pea %sp@(SWITCH_STACK_SIZE) |
Al Viro | a54f165 | 2012-04-24 01:46:23 -0400 | [diff] [blame] | 117 | bsrw do_notify_resume |
Al Viro | 710e91e | 2010-10-11 17:09:20 -0400 | [diff] [blame] | 118 | addql #4,%sp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | RESTORE_SWITCH_STACK |
| 120 | addql #4,%sp |
Al Viro | d1574df | 2010-10-11 23:29:28 -0400 | [diff] [blame] | 121 | jra 1b |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | |
| 123 | /* |
Greg Ungerer | 2502b667 | 2007-07-19 01:49:12 -0700 | [diff] [blame] | 124 | * This is the main interrupt handler, responsible for calling do_IRQ() |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | */ |
| 126 | inthandler: |
Greg Ungerer | 61619b1 | 2011-06-22 13:50:44 +1000 | [diff] [blame] | 127 | SAVE_ALL_INT |
Philippe De Muyter | eb497e7 | 2010-08-30 13:17:17 +0200 | [diff] [blame] | 128 | movew %sp@(PT_OFF_FORMATVEC), %d0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | and.l #0x3ff, %d0 |
| 130 | lsr.l #0x02, %d0 |
| 131 | |
| 132 | movel %sp,%sp@- |
| 133 | movel %d0,%sp@- /* put vector # on stack*/ |
Thomas Gleixner | 09f90f6 | 2013-11-11 21:01:03 +0100 | [diff] [blame] | 134 | jbsr do_IRQ /* process the IRQ */ |
| 135 | addql #8,%sp /* pop parameters off stack*/ |
| 136 | jra ret_from_exception |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | |
| 138 | /* |
| 139 | * Handler for uninitialized and spurious interrupts. |
| 140 | */ |
| 141 | bad_interrupt: |
Geert Uytterhoeven | 8c9f08f | 2011-07-13 20:29:24 +0200 | [diff] [blame] | 142 | addql #1,irq_err_count |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | rte |
| 144 | |
| 145 | /* |
| 146 | * Beware - when entering resume, prev (the current task) is |
Greg Ungerer | f941f5c | 2011-05-05 22:32:12 +1000 | [diff] [blame] | 147 | * 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] | 148 | * registers until their contents are no longer needed. |
| 149 | */ |
| 150 | ENTRY(resume) |
| 151 | movel %a0,%d1 /* save prev thread in d1 */ |
| 152 | movew %sr,%a0@(TASK_THREAD+THREAD_SR) /* save sr */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | SAVE_SWITCH_STACK |
| 154 | movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */ |
Greg Ungerer | f941f5c | 2011-05-05 22:32:12 +1000 | [diff] [blame] | 155 | movel %usp,%a3 /* save usp */ |
| 156 | movel %a3,%a0@(TASK_THREAD+THREAD_USP) |
| 157 | |
| 158 | movel %a1@(TASK_THREAD+THREAD_USP),%a3 /* restore user stack */ |
| 159 | movel %a3,%usp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */ |
| 161 | RESTORE_SWITCH_STACK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | movew %a1@(TASK_THREAD+THREAD_SR),%sr /* restore thread status reg */ |
| 163 | rts |
| 164 | |