entry.S 5.8 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
/*
 *  linux/arch/m68knommu/platform/68328/entry.S
 *
 *  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 ret_from_interrupt
.globl bad_interrupt
.globl inthandler1
.globl inthandler2
.globl inthandler3
.globl inthandler4
.globl inthandler5
.globl inthandler6
.globl inthandler7

badsys:
41
	movel	#-ENOSYS,%sp@(PT_OFF_D0)
L
Linus Torvalds 已提交
42 43 44
	jra	ret_from_exception

do_trace:
45
	movel	#-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/
L
Linus Torvalds 已提交
46 47
	subql	#4,%sp
	SAVE_SWITCH_STACK
48
	jbsr	syscall_trace_enter
L
Linus Torvalds 已提交
49 50
	RESTORE_SWITCH_STACK
	addql	#4,%sp
51
	movel	%sp@(PT_OFF_ORIG_D0),%d1
L
Linus Torvalds 已提交
52 53 54 55 56 57 58
	movel	#-ENOSYS,%d0
	cmpl	#NR_syscalls,%d1
	jcc	1f
	lsl	#2,%d1
	lea	sys_call_table, %a0
	jbsr	%a0@(%d1)

59
1:	movel	%d0,%sp@(PT_OFF_D0)	/* save the return value */
L
Linus Torvalds 已提交
60 61
	subql	#4,%sp			/* dummy return address */
	SAVE_SWITCH_STACK
62
	jbsr	syscall_trace_leave
L
Linus Torvalds 已提交
63 64 65 66 67 68 69

ret_from_signal:
	RESTORE_SWITCH_STACK
	addql	#4,%sp
	jra	ret_from_exception

ENTRY(system_call)
70
	SAVE_ALL_SYS
L
Linus Torvalds 已提交
71 72

	/* save top of frame*/
73 74 75
	pea	%sp@
	jbsr	set_esp0
	addql	#4,%sp
L
Linus Torvalds 已提交
76

77
	movel	%sp@(PT_OFF_ORIG_D0),%d0
L
Linus Torvalds 已提交
78 79

	movel	%sp,%d1			/* get thread_info pointer */
80
	andl	#-THREAD_SIZE,%d1
L
Linus Torvalds 已提交
81
	movel	%d1,%a2
82
	btst	#(TIF_SYSCALL_TRACE%8),%a2@(TINFO_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
L
Linus Torvalds 已提交
83 84 85 86 87 88 89
	jne	do_trace
	cmpl	#NR_syscalls,%d0
	jcc	badsys
	lsl	#2,%d0
	lea	sys_call_table,%a0
	movel	%a0@(%d0), %a0
	jbsr	%a0@
90
	movel	%d0,%sp@(PT_OFF_D0)	/* save the return value*/
L
Linus Torvalds 已提交
91 92

ret_from_exception:
93
	btst	#5,%sp@(PT_OFF_SR)	/* check if returning to kernel*/
L
Linus Torvalds 已提交
94 95 96 97 98 99 100 101 102 103 104 105
	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 */
106
	andl	#-THREAD_SIZE,%d1
L
Linus Torvalds 已提交
107
	movel	%d1,%a2
108
1:
109
	move	%a2@(TINFO_FLAGS),%d1	/* thread_info->flags */
L
Linus Torvalds 已提交
110 111 112 113
	jne	Lwork_to_do
	RESTORE_ALL

Lwork_to_do:
114
	movel	%a2@(TINFO_FLAGS),%d1	/* thread_info->flags */
L
Linus Torvalds 已提交
115 116 117 118 119 120 121
	btst	#TIF_NEED_RESCHED,%d1
	jne	reschedule

Lsignal_return:
	subql	#4,%sp			/* dummy return address*/
	SAVE_SWITCH_STACK
	pea	%sp@(SWITCH_STACK_SIZE)
122
	bsrw	do_notify_resume
A
Al Viro 已提交
123
	addql	#4,%sp
L
Linus Torvalds 已提交
124 125
	RESTORE_SWITCH_STACK
	addql	#4,%sp
126
	jra	1b
L
Linus Torvalds 已提交
127 128 129 130 131

/*
 * This is the main interrupt handler, responsible for calling process_int()
 */
inthandler1:
132
	SAVE_ALL_INT
133
	movew	%sp@(PT_OFF_FORMATVEC), %d0
L
Linus Torvalds 已提交
134 135 136 137 138 139 140 141 142
	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*/
	bra	ret_from_interrupt

inthandler2:
143
	SAVE_ALL_INT
144
	movew	%sp@(PT_OFF_FORMATVEC), %d0
L
Linus Torvalds 已提交
145 146 147 148 149 150 151 152 153
	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*/
	bra	ret_from_interrupt

inthandler3:
154
	SAVE_ALL_INT
155
	movew	%sp@(PT_OFF_FORMATVEC), %d0
L
Linus Torvalds 已提交
156 157 158 159 160 161 162 163 164
	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*/
	bra	ret_from_interrupt

inthandler4:
165
	SAVE_ALL_INT
166
	movew	%sp@(PT_OFF_FORMATVEC), %d0
L
Linus Torvalds 已提交
167 168 169 170 171 172 173 174 175
	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*/
	bra	ret_from_interrupt

inthandler5:
176
	SAVE_ALL_INT
177
	movew	%sp@(PT_OFF_FORMATVEC), %d0
L
Linus Torvalds 已提交
178 179 180 181 182 183 184 185 186
	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*/
	bra	ret_from_interrupt

inthandler6:
187
	SAVE_ALL_INT
188
	movew	%sp@(PT_OFF_FORMATVEC), %d0
L
Linus Torvalds 已提交
189 190 191 192 193 194 195 196 197
	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*/
	bra	ret_from_interrupt

inthandler7:
198
	SAVE_ALL_INT
199
	movew	%sp@(PT_OFF_FORMATVEC), %d0
L
Linus Torvalds 已提交
200 201 202 203 204 205 206 207 208
	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*/
	bra	ret_from_interrupt

inthandler:
209
	SAVE_ALL_INT
210
	movew	%sp@(PT_OFF_FORMATVEC), %d0
L
Linus Torvalds 已提交
211 212 213 214 215 216 217 218 219 220 221 222 223
	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*/
	bra	ret_from_interrupt

ret_from_interrupt:
	jeq	1f
2:
	RESTORE_ALL
1:
224
	moveb	%sp@(PT_OFF_SR), %d0
L
Linus Torvalds 已提交
225 226 227 228 229 230 231 232 233 234 235 236 237 238
	and	#7, %d0
	jhi	2b

	/* check if we need to do software interrupts */
	jeq	ret_from_exception

	pea	ret_from_exception
	jra	do_softirq


/*
 * Handler for uninitialized and spurious interrupts.
 */
ENTRY(bad_interrupt)
239
	addql	#1,irq_err_count
L
Linus Torvalds 已提交
240 241 242 243
	rte

/*
 * Beware - when entering resume, prev (the current task) is
244
 * in a0, next (the new task) is in a1, so don't change these
L
Linus Torvalds 已提交
245 246 247 248 249 250 251
 * 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 */
252 253 254 255 256
	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
L
Linus Torvalds 已提交
257 258 259 260 261
	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