2 * linux/arch/m68knommu/platform/5307/entry.S
4 * Copyright (C) 1999-2007, Greg Ungerer (gerg@snapgear.com)
5 * Copyright (C) 1998 D. Jeff Dionne <jeff@lineo.ca>,
6 * Kenneth Albanowski <kjahds@kjahds.com>,
7 * Copyright (C) 2000 Lineo Inc. (www.lineo.com)
8 * Copyright (C) 2004-2006 Macq Electronique SA. (www.macqel.com)
12 * linux/arch/m68k/kernel/entry.S
14 * Copyright (C) 1991, 1992 Linus Torvalds
16 * This file is subject to the terms and conditions of the GNU General Public
17 * License. See the file README.legal in the main directory of this archive
20 * Linux/m68k support by Hamish Macdonald
22 * 68060 fixes by Jesper Skov
23 * ColdFire support by Greg Ungerer (gerg@snapgear.com)
24 * 5307 fixes by David W. Miller
25 * linux 2.4 support David McCullough <davidm@snapgear.com>
26 * Bug, speed and maintainability fixes by Philippe De Muyter <phdm@macqel.be>
29 #include <linux/sys.h>
30 #include <linux/linkage.h>
31 #include <asm/unistd.h>
32 #include <asm/thread_info.h>
33 #include <asm/errno.h>
34 #include <asm/setup.h>
35 #include <asm/segment.h>
36 #include <asm/asm-offsets.h>
37 #include <asm/entry.h>
51 .globl ret_from_exception
52 .globl ret_from_signal
54 .globl ret_from_interrupt
59 mov.l #sys_ni_syscall,%d3
64 move #0x2000,%sr /* enable intrs again */
68 lea sys_call_table,%a0
69 lsll #2,%d0 /* movel %a0@(%d0:l:4),%d3 */
74 movel %sp,%d2 /* get thread_info pointer */
75 andl #-THREAD_SIZE,%d2 /* at start of kernel stack */
77 movel %a0@,%a1 /* save top of frame */
78 movel %sp,%a1@(TASK_THREAD+THREAD_ESP0)
79 btst #(TIF_SYSCALL_TRACE%8),%a0@(TI_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
84 movel %d0,%sp@(PT_D0) /* save the return value */
85 jra ret_from_exception
87 movel #-ENOSYS,%d2 /* strace needs -ENOSYS in PT_D0 */
88 movel %d2,PT_D0(%sp) /* on syscall entry */
96 movel %d0,%sp@(PT_D0) /* save the return value */
97 subql #4,%sp /* dummy return address */
106 move #0x2700,%sr /* disable intrs */
107 btst #5,%sp@(PT_SR) /* check if returning to kernel */
108 jeq Luser_return /* if so, skip resched, signals */
110 #ifdef CONFIG_PREEMPT
111 movel %sp,%d1 /* get thread_info pointer */
112 andl #-THREAD_SIZE,%d1 /* at base of kernel stack */
114 movel %a0@(TI_FLAGS),%d1 /* get thread_info->flags */
115 andl #_TIF_NEED_RESCHED,%d1
118 movel %a0@(TI_PREEMPTCOUNT),%d1
123 jmp preempt_schedule_irq /* preempt the kernel */
127 moveml %sp@,%d1-%d5/%a0-%a2
128 lea %sp@(32),%sp /* space for 8 regs */
130 addql #4,%sp /* orig d0 */
131 addl %sp@+,%sp /* stk adj */
135 movel %sp,%d1 /* get thread_info pointer */
136 andl #-THREAD_SIZE,%d1 /* at base of kernel stack */
138 movel %a0@(TI_FLAGS),%d1 /* get thread_info->flags */
139 andl #_TIF_WORK_MASK,%d1
140 jne Lwork_to_do /* still work to do */
143 move #0x2700,%sr /* disable intrs */
144 movel sw_usp,%a0 /* get usp */
145 movel %sp@(PT_PC),%a0@- /* copy exception program counter */
146 movel %sp@(PT_FORMATVEC),%a0@-/* copy exception format/vector/sr */
147 moveml %sp@,%d1-%d5/%a0-%a2
148 lea %sp@(32),%sp /* space for 8 regs */
150 addql #4,%sp /* orig d0 */
151 addl %sp@+,%sp /* stk adj */
152 addql #8,%sp /* remove exception */
153 movel %sp,sw_ksp /* save ksp */
154 subql #8,sw_usp /* set exception */
155 movel sw_usp,%sp /* restore usp */
159 movel %a0@(TI_FLAGS),%d1 /* get thread_info->flags */
160 move #0x2000,%sr /* enable intrs again */
161 btst #TIF_NEED_RESCHED,%d1
164 /* GERG: do we need something here for TRACEing?? */
167 subql #4,%sp /* dummy return address */
169 pea %sp@(SWITCH_STACK_SIZE)
178 * This is the generic interrupt handler (for all hardware interrupt
179 * sources). Calls upto high level code to do all the work.
184 movel %d0,%sp@(PT_ORIG_D0)
186 movew %sp@(PT_FORMATVEC),%d0 /* put exception # in d0 */
187 andl #0x03fc,%d0 /* mask out vector only */
189 movel %sp,%sp@- /* push regs arg */
190 lsrl #2,%d0 /* calculate real vector # */
191 movel %d0,%sp@- /* push vector number */
192 jbsr do_IRQ /* call high level irq handler */
193 lea %sp@(8),%sp /* pop args off stack */
195 bra ret_from_interrupt /* this was fallthrough */
198 * This is the fast interrupt handler (for certain hardware interrupt
199 * sources). Unlike the normal interrupt handler it just uses the
200 * current stack (doesn't care if it is user or kernel). It also
201 * doesn't bother doing the bottom half handlers.
206 movew %sp@(PT_FORMATVEC),%d0
207 andl #0x03fc,%d0 /* mask out vector only */
209 movel %sp,%sp@- /* push regs arg */
210 lsrl #2,%d0 /* calculate real vector # */
211 movel %d0,%sp@- /* push vector number */
212 jbsr do_IRQ /* call high level irq handler */
213 lea %sp@(8),%sp /* pop args off stack */
217 ENTRY(ret_from_interrupt)
218 moveb %sp@(PT_SR),%d0
225 /* check if we need to do software interrupts */
226 movel irq_stat+CPUSTAT_SOFTIRQ_PENDING,%d0
227 jeq ret_from_exception
229 pea ret_from_exception
233 * Beware - when entering resume, prev (the current task) is
234 * in a0, next (the new task) is in a1,so don't change these
235 * registers until their contents are no longer needed.
236 * This is always called in supervisor mode, so don't bother to save
237 * and restore sr; user's process sr is actually in the stack.
240 movel %a0, %d1 /* get prev thread in d1 */
242 movel sw_usp,%d0 /* save usp */
243 movel %d0,%a0@(TASK_THREAD+THREAD_USP)
246 movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack pointer */
247 movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */
250 movel %a1@(TASK_THREAD+THREAD_USP),%a0 /* restore thread user stack */