2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1994 - 2000, 2001, 2003 Ralf Baechle
|
|
|
|
* Copyright (C) 1999, 2000 Silicon Graphics, Inc.
|
|
|
|
* Copyright (C) 2001 MIPS Technologies, Inc.
|
|
|
|
*/
|
|
|
|
#include <linux/config.h>
|
|
|
|
|
|
|
|
#include <asm/asm.h>
|
|
|
|
#include <asm/asmmacro.h>
|
|
|
|
#include <asm/regdef.h>
|
|
|
|
#include <asm/mipsregs.h>
|
|
|
|
#include <asm/stackframe.h>
|
|
|
|
#include <asm/isadep.h>
|
|
|
|
#include <asm/thread_info.h>
|
|
|
|
#include <asm/war.h>
|
|
|
|
|
|
|
|
#ifdef CONFIG_PREEMPT
|
2004-12-10 20:56:33 +08:00
|
|
|
.macro preempt_stop
|
2005-04-17 06:20:36 +08:00
|
|
|
.endm
|
|
|
|
#else
|
2004-12-10 20:56:33 +08:00
|
|
|
.macro preempt_stop
|
|
|
|
local_irq_disable
|
2005-04-17 06:20:36 +08:00
|
|
|
.endm
|
|
|
|
#define resume_kernel restore_all
|
|
|
|
#endif
|
|
|
|
|
|
|
|
.text
|
|
|
|
.align 5
|
|
|
|
FEXPORT(ret_from_exception)
|
|
|
|
preempt_stop
|
|
|
|
FEXPORT(ret_from_irq)
|
|
|
|
LONG_L t0, PT_STATUS(sp) # returning to kernel mode?
|
|
|
|
andi t0, t0, KU_USER
|
|
|
|
beqz t0, resume_kernel
|
|
|
|
|
2004-12-10 20:56:33 +08:00
|
|
|
resume_userspace:
|
|
|
|
local_irq_disable # make sure we dont miss an
|
2005-04-17 06:20:36 +08:00
|
|
|
# interrupt setting need_resched
|
|
|
|
# between sampling and return
|
|
|
|
LONG_L a2, TI_FLAGS($28) # current->work
|
2004-12-10 20:56:33 +08:00
|
|
|
andi t0, a2, _TIF_WORK_MASK # (ignoring syscall_trace)
|
|
|
|
bnez t0, work_pending
|
2005-04-17 06:20:36 +08:00
|
|
|
j restore_all
|
|
|
|
|
|
|
|
#ifdef CONFIG_PREEMPT
|
2004-12-10 20:56:33 +08:00
|
|
|
resume_kernel:
|
2005-04-17 06:20:36 +08:00
|
|
|
lw t0, TI_PRE_COUNT($28)
|
|
|
|
bnez t0, restore_all
|
|
|
|
need_resched:
|
|
|
|
LONG_L t0, TI_FLAGS($28)
|
|
|
|
andi t1, t0, _TIF_NEED_RESCHED
|
|
|
|
beqz t1, restore_all
|
|
|
|
LONG_L t0, PT_STATUS(sp) # Interrupts off?
|
|
|
|
andi t0, 1
|
|
|
|
beqz t0, restore_all
|
|
|
|
li t0, PREEMPT_ACTIVE
|
|
|
|
sw t0, TI_PRE_COUNT($28)
|
2004-12-10 20:56:33 +08:00
|
|
|
local_irq_enable
|
2005-04-17 06:20:36 +08:00
|
|
|
jal schedule
|
|
|
|
sw zero, TI_PRE_COUNT($28)
|
2004-12-10 20:56:33 +08:00
|
|
|
local_irq_disable
|
2005-04-17 06:20:36 +08:00
|
|
|
b need_resched
|
|
|
|
#endif
|
|
|
|
|
|
|
|
FEXPORT(ret_from_fork)
|
|
|
|
jal schedule_tail # a0 = task_t *prev
|
|
|
|
|
|
|
|
FEXPORT(syscall_exit)
|
|
|
|
local_irq_disable # make sure need_resched and
|
|
|
|
# signals dont change between
|
|
|
|
# sampling and return
|
|
|
|
LONG_L a2, TI_FLAGS($28) # current->work
|
|
|
|
li t0, _TIF_ALLWORK_MASK
|
|
|
|
and t0, a2, t0
|
|
|
|
bnez t0, syscall_exit_work
|
|
|
|
|
|
|
|
FEXPORT(restore_all) # restore full frame
|
|
|
|
.set noat
|
|
|
|
RESTORE_TEMP
|
|
|
|
RESTORE_AT
|
|
|
|
RESTORE_STATIC
|
|
|
|
FEXPORT(restore_partial) # restore partial frame
|
|
|
|
RESTORE_SOME
|
|
|
|
RESTORE_SP_AND_RET
|
|
|
|
.set at
|
|
|
|
|
2004-12-10 20:56:33 +08:00
|
|
|
work_pending:
|
|
|
|
andi t0, a2, _TIF_NEED_RESCHED # a2 is preloaded with TI_FLAGS
|
2005-04-17 06:20:36 +08:00
|
|
|
beqz t0, work_notifysig
|
|
|
|
work_resched:
|
|
|
|
jal schedule
|
|
|
|
|
2004-12-10 20:56:33 +08:00
|
|
|
local_irq_disable # make sure need_resched and
|
2005-04-17 06:20:36 +08:00
|
|
|
# signals dont change between
|
|
|
|
# sampling and return
|
|
|
|
LONG_L a2, TI_FLAGS($28)
|
|
|
|
andi t0, a2, _TIF_WORK_MASK # is there any work to be done
|
|
|
|
# other than syscall tracing?
|
|
|
|
beqz t0, restore_all
|
|
|
|
andi t0, a2, _TIF_NEED_RESCHED
|
|
|
|
bnez t0, work_resched
|
|
|
|
|
|
|
|
work_notifysig: # deal with pending signals and
|
|
|
|
# notify-resume requests
|
|
|
|
move a0, sp
|
|
|
|
li a1, 0
|
|
|
|
jal do_notify_resume # a2 already loaded
|
|
|
|
j restore_all
|
|
|
|
|
|
|
|
FEXPORT(syscall_exit_work_partial)
|
|
|
|
SAVE_STATIC
|
2004-12-10 20:56:33 +08:00
|
|
|
syscall_exit_work:
|
|
|
|
li t0, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
|
|
|
|
and t0, a2 # a2 is preloaded with TI_FLAGS
|
|
|
|
beqz t0, work_pending # trace bit set?
|
2005-04-17 06:20:36 +08:00
|
|
|
local_irq_enable # could let do_syscall_trace()
|
|
|
|
# call schedule() instead
|
|
|
|
move a0, sp
|
|
|
|
li a1, 1
|
|
|
|
jal do_syscall_trace
|
|
|
|
b resume_userspace
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Common spurious interrupt handler.
|
|
|
|
*/
|
|
|
|
LEAF(spurious_interrupt)
|
|
|
|
/*
|
|
|
|
* Someone tried to fool us by sending an interrupt but we
|
|
|
|
* couldn't find a cause for it.
|
|
|
|
*/
|
2004-12-05 05:35:05 +08:00
|
|
|
PTR_LA t1, irq_err_count
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef CONFIG_SMP
|
2004-12-05 05:35:05 +08:00
|
|
|
1: ll t0, (t1)
|
2005-04-17 06:20:36 +08:00
|
|
|
addiu t0, 1
|
2004-12-05 05:35:05 +08:00
|
|
|
sc t0, (t1)
|
2005-04-17 06:20:36 +08:00
|
|
|
#if R10000_LLSC_WAR
|
|
|
|
beqzl t0, 1b
|
|
|
|
#else
|
|
|
|
beqz t0, 1b
|
|
|
|
#endif
|
|
|
|
#else
|
2004-12-05 05:35:05 +08:00
|
|
|
lw t0, (t1)
|
2005-04-17 06:20:36 +08:00
|
|
|
addiu t0, 1
|
2004-12-05 05:35:05 +08:00
|
|
|
sw t0, (t1)
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
j ret_from_irq
|
|
|
|
END(spurious_interrupt)
|