• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 *  linux/arch/m68knommu/platform/68360/entry.S
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
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
32.globl ret_from_interrupt
33.globl bad_interrupt
34.globl inthandler
35
36badsys:
37	movel	#-ENOSYS,%sp@(PT_OFF_D0)
38	jra	ret_from_exception
39
40do_trace:
41	movel	#-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/
42	subql	#4,%sp
43	SAVE_SWITCH_STACK
44	jbsr	syscall_trace_enter
45	RESTORE_SWITCH_STACK
46	addql	#4,%sp
47	movel	%sp@(PT_OFF_ORIG_D0),%d1
48	movel	#-ENOSYS,%d0
49	cmpl	#NR_syscalls,%d1
50	jcc	1f
51	lsl	#2,%d1
52	lea	sys_call_table, %a0
53	jbsr	%a0@(%d1)
54
551:	movel	%d0,%sp@(PT_OFF_D0)	/* save the return value */
56	subql	#4,%sp			/* dummy return address */
57	SAVE_SWITCH_STACK
58	jbsr	syscall_trace_leave
59
60ret_from_signal:
61	RESTORE_SWITCH_STACK
62	addql	#4,%sp
63	jra	ret_from_exception
64
65ENTRY(system_call)
66	SAVE_ALL_SYS
67
68	/* save top of frame*/
69	pea	%sp@
70	jbsr	set_esp0
71	addql	#4,%sp
72
73	movel	%sp@(PT_OFF_ORIG_D0),%d0
74
75	movel	%sp,%d1			/* get thread_info pointer */
76	andl	#-THREAD_SIZE,%d1
77	movel	%d1,%a2
78	btst	#(TIF_SYSCALL_TRACE%8),%a2@(TINFO_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
79	jne	do_trace
80	cmpl	#NR_syscalls,%d0
81	jcc	badsys
82	lsl	#2,%d0
83	lea	sys_call_table,%a0
84	movel	%a0@(%d0), %a0
85	jbsr	%a0@
86	movel	%d0,%sp@(PT_OFF_D0)	/* save the return value*/
87
88ret_from_exception:
89	btst	#5,%sp@(PT_OFF_SR)	/* check if returning to kernel*/
90	jeq	Luser_return		/* if so, skip resched, signals*/
91
92Lkernel_return:
93	RESTORE_ALL
94
95Luser_return:
96	/* only allow interrupts when we are really the last one on the*/
97	/* kernel stack, otherwise stack overflow can occur during*/
98	/* heavy interrupt load*/
99	andw	#ALLOWINT,%sr
100
101	movel	%sp,%d1			/* get thread_info pointer */
102	andl	#-THREAD_SIZE,%d1
103	movel	%d1,%a2
1041:
105	move	%a2@(TINFO_FLAGS),%d1	/* thread_info->flags */
106	jne	Lwork_to_do
107	RESTORE_ALL
108
109Lwork_to_do:
110	movel	%a2@(TINFO_FLAGS),%d1	/* thread_info->flags */
111	btst	#TIF_NEED_RESCHED,%d1
112	jne	reschedule
113
114Lsignal_return:
115	subql	#4,%sp			/* dummy return address*/
116	SAVE_SWITCH_STACK
117	pea	%sp@(SWITCH_STACK_SIZE)
118	bsrw	do_notify_resume
119	addql	#4,%sp
120	RESTORE_SWITCH_STACK
121	addql	#4,%sp
122	jra	1b
123
124/*
125 * This is the main interrupt handler, responsible for calling do_IRQ()
126 */
127inthandler:
128	SAVE_ALL_INT
129	movew	%sp@(PT_OFF_FORMATVEC), %d0
130	and.l	#0x3ff, %d0
131	lsr.l   #0x02,  %d0
132
133	movel	%sp,%sp@-
134	movel	%d0,%sp@- 		/*  put vector # on stack*/
135	jbsr	do_IRQ			/*  process the IRQ*/
1363:     	addql	#8,%sp			/*  pop parameters off stack*/
137	bra	ret_from_interrupt
138
139ret_from_interrupt:
140	jeq	1f
1412:
142	RESTORE_ALL
1431:
144	moveb	%sp@(PT_OFF_SR), %d0
145	and	#7, %d0
146	jhi	2b
147	/* check if we need to do software interrupts */
148
149	movel	irq_stat+CPUSTAT_SOFTIRQ_PENDING,%d0
150	jeq	ret_from_exception
151
152	pea	ret_from_exception
153	jra	do_softirq
154
155
156/*
157 * Handler for uninitialized and spurious interrupts.
158 */
159bad_interrupt:
160	addql	#1,irq_err_count
161	rte
162
163/*
164 * Beware - when entering resume, prev (the current task) is
165 * in a0, next (the new task) is in a1, so don't change these
166 * registers until their contents are no longer needed.
167 */
168ENTRY(resume)
169	movel	%a0,%d1				/* save prev thread in d1 */
170	movew	%sr,%a0@(TASK_THREAD+THREAD_SR)	/* save sr */
171	SAVE_SWITCH_STACK
172	movel	%sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */
173	movel	%usp,%a3			/* save usp */
174	movel	%a3,%a0@(TASK_THREAD+THREAD_USP)
175
176	movel	%a1@(TASK_THREAD+THREAD_USP),%a3 /* restore user stack */
177	movel	%a3,%usp
178	movel	%a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */
179	RESTORE_SWITCH_STACK
180	movew	%a1@(TASK_THREAD+THREAD_SR),%sr	/* restore thread status reg */
181	rts
182
183