2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2014-08-21 20:10:31 +08:00
|
|
|
* entry.S -- non-mmu 68000 interrupt and exception entry points
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* Copyright (C) 1991, 1992 Linus Torvalds
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file README.legal in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* Linux/m68k support by Hamish Macdonald
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/linkage.h>
|
|
|
|
#include <asm/thread_info.h>
|
|
|
|
#include <asm/unistd.h>
|
|
|
|
#include <asm/errno.h>
|
|
|
|
#include <asm/setup.h>
|
|
|
|
#include <asm/segment.h>
|
|
|
|
#include <asm/traps.h>
|
|
|
|
#include <asm/asm-offsets.h>
|
|
|
|
#include <asm/entry.h>
|
|
|
|
|
|
|
|
.text
|
|
|
|
|
|
|
|
.globl system_call
|
|
|
|
.globl resume
|
|
|
|
.globl ret_from_exception
|
|
|
|
.globl ret_from_signal
|
|
|
|
.globl sys_call_table
|
|
|
|
.globl bad_interrupt
|
|
|
|
.globl inthandler1
|
|
|
|
.globl inthandler2
|
|
|
|
.globl inthandler3
|
|
|
|
.globl inthandler4
|
|
|
|
.globl inthandler5
|
|
|
|
.globl inthandler6
|
|
|
|
.globl inthandler7
|
|
|
|
|
|
|
|
badsys:
|
2009-09-20 19:32:32 +08:00
|
|
|
movel #-ENOSYS,%sp@(PT_OFF_D0)
|
2005-04-17 06:20:36 +08:00
|
|
|
jra ret_from_exception
|
|
|
|
|
|
|
|
do_trace:
|
2010-08-18 00:52:39 +08:00
|
|
|
movel #-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/
|
2005-04-17 06:20:36 +08:00
|
|
|
subql #4,%sp
|
|
|
|
SAVE_SWITCH_STACK
|
2010-10-22 13:12:34 +08:00
|
|
|
jbsr syscall_trace_enter
|
2005-04-17 06:20:36 +08:00
|
|
|
RESTORE_SWITCH_STACK
|
|
|
|
addql #4,%sp
|
2009-09-20 19:32:32 +08:00
|
|
|
movel %sp@(PT_OFF_ORIG_D0),%d1
|
2005-04-17 06:20:36 +08:00
|
|
|
movel #-ENOSYS,%d0
|
|
|
|
cmpl #NR_syscalls,%d1
|
|
|
|
jcc 1f
|
|
|
|
lsl #2,%d1
|
|
|
|
lea sys_call_table, %a0
|
|
|
|
jbsr %a0@(%d1)
|
|
|
|
|
2010-08-18 00:52:39 +08:00
|
|
|
1: movel %d0,%sp@(PT_OFF_D0) /* save the return value */
|
2005-04-17 06:20:36 +08:00
|
|
|
subql #4,%sp /* dummy return address */
|
|
|
|
SAVE_SWITCH_STACK
|
2010-10-22 13:12:34 +08:00
|
|
|
jbsr syscall_trace_leave
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
ret_from_signal:
|
|
|
|
RESTORE_SWITCH_STACK
|
|
|
|
addql #4,%sp
|
|
|
|
jra ret_from_exception
|
|
|
|
|
|
|
|
ENTRY(system_call)
|
2011-06-22 11:50:44 +08:00
|
|
|
SAVE_ALL_SYS
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* save top of frame*/
|
2010-08-18 00:52:39 +08:00
|
|
|
pea %sp@
|
|
|
|
jbsr set_esp0
|
|
|
|
addql #4,%sp
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-09-20 19:32:32 +08:00
|
|
|
movel %sp@(PT_OFF_ORIG_D0),%d0
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
movel %sp,%d1 /* get thread_info pointer */
|
2005-09-02 08:42:52 +08:00
|
|
|
andl #-THREAD_SIZE,%d1
|
2005-04-17 06:20:36 +08:00
|
|
|
movel %d1,%a2
|
2011-03-29 13:55:36 +08:00
|
|
|
btst #(TIF_SYSCALL_TRACE%8),%a2@(TINFO_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
|
2005-04-17 06:20:36 +08:00
|
|
|
jne do_trace
|
|
|
|
cmpl #NR_syscalls,%d0
|
|
|
|
jcc badsys
|
|
|
|
lsl #2,%d0
|
|
|
|
lea sys_call_table,%a0
|
|
|
|
movel %a0@(%d0), %a0
|
|
|
|
jbsr %a0@
|
2010-08-18 00:52:39 +08:00
|
|
|
movel %d0,%sp@(PT_OFF_D0) /* save the return value*/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
ret_from_exception:
|
2010-08-18 00:52:39 +08:00
|
|
|
btst #5,%sp@(PT_OFF_SR) /* check if returning to kernel*/
|
2005-04-17 06:20:36 +08:00
|
|
|
jeq Luser_return /* if so, skip resched, signals*/
|
|
|
|
|
|
|
|
Lkernel_return:
|
|
|
|
RESTORE_ALL
|
|
|
|
|
|
|
|
Luser_return:
|
|
|
|
/* only allow interrupts when we are really the last one on the*/
|
|
|
|
/* kernel stack, otherwise stack overflow can occur during*/
|
|
|
|
/* heavy interrupt load*/
|
|
|
|
andw #ALLOWINT,%sr
|
|
|
|
|
|
|
|
movel %sp,%d1 /* get thread_info pointer */
|
2005-09-02 08:42:52 +08:00
|
|
|
andl #-THREAD_SIZE,%d1
|
2005-04-17 06:20:36 +08:00
|
|
|
movel %d1,%a2
|
2010-10-12 11:29:28 +08:00
|
|
|
1:
|
2011-03-29 13:55:36 +08:00
|
|
|
move %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */
|
2005-04-17 06:20:36 +08:00
|
|
|
jne Lwork_to_do
|
|
|
|
RESTORE_ALL
|
|
|
|
|
|
|
|
Lwork_to_do:
|
2011-03-29 13:55:36 +08:00
|
|
|
movel %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */
|
2005-04-17 06:20:36 +08:00
|
|
|
btst #TIF_NEED_RESCHED,%d1
|
|
|
|
jne reschedule
|
|
|
|
|
|
|
|
Lsignal_return:
|
|
|
|
subql #4,%sp /* dummy return address*/
|
|
|
|
SAVE_SWITCH_STACK
|
|
|
|
pea %sp@(SWITCH_STACK_SIZE)
|
2012-04-24 13:46:23 +08:00
|
|
|
bsrw do_notify_resume
|
2010-10-12 05:09:20 +08:00
|
|
|
addql #4,%sp
|
2005-04-17 06:20:36 +08:00
|
|
|
RESTORE_SWITCH_STACK
|
|
|
|
addql #4,%sp
|
2010-10-12 11:29:28 +08:00
|
|
|
jra 1b
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the main interrupt handler, responsible for calling process_int()
|
|
|
|
*/
|
|
|
|
inthandler1:
|
2011-06-22 11:50:44 +08:00
|
|
|
SAVE_ALL_INT
|
2010-08-30 19:17:17 +08:00
|
|
|
movew %sp@(PT_OFF_FORMATVEC), %d0
|
2005-04-17 06:20:36 +08:00
|
|
|
and #0x3ff, %d0
|
|
|
|
|
|
|
|
movel %sp,%sp@-
|
|
|
|
movel #65,%sp@- /* put vector # on stack*/
|
|
|
|
jbsr process_int /* process the IRQ*/
|
|
|
|
3: addql #8,%sp /* pop parameters off stack*/
|
2013-11-12 04:01:03 +08:00
|
|
|
bra ret_from_exception
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
inthandler2:
|
2011-06-22 11:50:44 +08:00
|
|
|
SAVE_ALL_INT
|
2010-08-30 19:17:17 +08:00
|
|
|
movew %sp@(PT_OFF_FORMATVEC), %d0
|
2005-04-17 06:20:36 +08:00
|
|
|
and #0x3ff, %d0
|
|
|
|
|
|
|
|
movel %sp,%sp@-
|
|
|
|
movel #66,%sp@- /* put vector # on stack*/
|
|
|
|
jbsr process_int /* process the IRQ*/
|
|
|
|
3: addql #8,%sp /* pop parameters off stack*/
|
2013-11-12 04:01:03 +08:00
|
|
|
bra ret_from_exception
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
inthandler3:
|
2011-06-22 11:50:44 +08:00
|
|
|
SAVE_ALL_INT
|
2010-08-30 19:17:17 +08:00
|
|
|
movew %sp@(PT_OFF_FORMATVEC), %d0
|
2005-04-17 06:20:36 +08:00
|
|
|
and #0x3ff, %d0
|
|
|
|
|
|
|
|
movel %sp,%sp@-
|
|
|
|
movel #67,%sp@- /* put vector # on stack*/
|
|
|
|
jbsr process_int /* process the IRQ*/
|
|
|
|
3: addql #8,%sp /* pop parameters off stack*/
|
2013-11-12 04:01:03 +08:00
|
|
|
bra ret_from_exception
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
inthandler4:
|
2011-06-22 11:50:44 +08:00
|
|
|
SAVE_ALL_INT
|
2010-08-30 19:17:17 +08:00
|
|
|
movew %sp@(PT_OFF_FORMATVEC), %d0
|
2005-04-17 06:20:36 +08:00
|
|
|
and #0x3ff, %d0
|
|
|
|
|
|
|
|
movel %sp,%sp@-
|
|
|
|
movel #68,%sp@- /* put vector # on stack*/
|
|
|
|
jbsr process_int /* process the IRQ*/
|
|
|
|
3: addql #8,%sp /* pop parameters off stack*/
|
2013-11-12 04:01:03 +08:00
|
|
|
bra ret_from_exception
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
inthandler5:
|
2011-06-22 11:50:44 +08:00
|
|
|
SAVE_ALL_INT
|
2010-08-30 19:17:17 +08:00
|
|
|
movew %sp@(PT_OFF_FORMATVEC), %d0
|
2005-04-17 06:20:36 +08:00
|
|
|
and #0x3ff, %d0
|
|
|
|
|
|
|
|
movel %sp,%sp@-
|
|
|
|
movel #69,%sp@- /* put vector # on stack*/
|
|
|
|
jbsr process_int /* process the IRQ*/
|
|
|
|
3: addql #8,%sp /* pop parameters off stack*/
|
2013-11-12 04:01:03 +08:00
|
|
|
bra ret_from_exception
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
inthandler6:
|
2011-06-22 11:50:44 +08:00
|
|
|
SAVE_ALL_INT
|
2010-08-30 19:17:17 +08:00
|
|
|
movew %sp@(PT_OFF_FORMATVEC), %d0
|
2005-04-17 06:20:36 +08:00
|
|
|
and #0x3ff, %d0
|
|
|
|
|
|
|
|
movel %sp,%sp@-
|
|
|
|
movel #70,%sp@- /* put vector # on stack*/
|
|
|
|
jbsr process_int /* process the IRQ*/
|
|
|
|
3: addql #8,%sp /* pop parameters off stack*/
|
2013-11-12 04:01:03 +08:00
|
|
|
bra ret_from_exception
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
inthandler7:
|
2011-06-22 11:50:44 +08:00
|
|
|
SAVE_ALL_INT
|
2010-08-30 19:17:17 +08:00
|
|
|
movew %sp@(PT_OFF_FORMATVEC), %d0
|
2005-04-17 06:20:36 +08:00
|
|
|
and #0x3ff, %d0
|
|
|
|
|
|
|
|
movel %sp,%sp@-
|
|
|
|
movel #71,%sp@- /* put vector # on stack*/
|
|
|
|
jbsr process_int /* process the IRQ*/
|
|
|
|
3: addql #8,%sp /* pop parameters off stack*/
|
2013-11-12 04:01:03 +08:00
|
|
|
bra ret_from_exception
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
inthandler:
|
2011-06-22 11:50:44 +08:00
|
|
|
SAVE_ALL_INT
|
2010-08-30 19:17:17 +08:00
|
|
|
movew %sp@(PT_OFF_FORMATVEC), %d0
|
2005-04-17 06:20:36 +08:00
|
|
|
and #0x3ff, %d0
|
|
|
|
|
|
|
|
movel %sp,%sp@-
|
|
|
|
movel %d0,%sp@- /* put vector # on stack*/
|
|
|
|
jbsr process_int /* process the IRQ*/
|
|
|
|
3: addql #8,%sp /* pop parameters off stack*/
|
2013-11-12 04:01:03 +08:00
|
|
|
bra ret_from_exception
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Handler for uninitialized and spurious interrupts.
|
|
|
|
*/
|
|
|
|
ENTRY(bad_interrupt)
|
2011-07-14 02:29:24 +08:00
|
|
|
addql #1,irq_err_count
|
2005-04-17 06:20:36 +08:00
|
|
|
rte
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Beware - when entering resume, prev (the current task) is
|
2011-05-05 20:32:12 +08:00
|
|
|
* in a0, next (the new task) is in a1, so don't change these
|
2005-04-17 06:20:36 +08:00
|
|
|
* registers until their contents are no longer needed.
|
|
|
|
*/
|
|
|
|
ENTRY(resume)
|
|
|
|
movel %a0,%d1 /* save prev thread in d1 */
|
|
|
|
movew %sr,%a0@(TASK_THREAD+THREAD_SR) /* save sr */
|
|
|
|
SAVE_SWITCH_STACK
|
|
|
|
movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */
|
2011-05-05 20:32:12 +08:00
|
|
|
movel %usp,%a3 /* save usp */
|
|
|
|
movel %a3,%a0@(TASK_THREAD+THREAD_USP)
|
|
|
|
|
|
|
|
movel %a1@(TASK_THREAD+THREAD_USP),%a3 /* restore user stack */
|
|
|
|
movel %a3,%usp
|
2005-04-17 06:20:36 +08:00
|
|
|
movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */
|
|
|
|
RESTORE_SWITCH_STACK
|
|
|
|
movew %a1@(TASK_THREAD+THREAD_SR),%sr /* restore thread status reg */
|
|
|
|
rts
|
|
|
|
|