• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/arch/m68knommu/platform/68360/
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/sys.h>
16#include <linux/linkage.h>
17#include <asm/thread_info.h>
18#include <asm/unistd.h>
19#include <asm/errno.h>
20#include <asm/setup.h>
21#include <asm/segment.h>
22#include <asm/traps.h>
23#include <asm/asm-offsets.h>
24#include <asm/entry.h>
25
26.text
27
28.globl system_call
29.globl resume
30.globl ret_from_exception
31.globl ret_from_signal
32.globl sys_call_table
33.globl ret_from_interrupt
34.globl bad_interrupt
35.globl inthandler
36
37badsys:
38	movel	#-ENOSYS,%sp@(PT_D0)
39	jra	ret_from_exception
40
41do_trace:
42	movel	#-ENOSYS,%sp@(PT_D0)	/* needed for strace*/
43	subql	#4,%sp
44	SAVE_SWITCH_STACK
45	jbsr	syscall_trace
46	RESTORE_SWITCH_STACK
47	addql	#4,%sp
48	movel	%sp@(PT_ORIG_D0),%d1
49	movel	#-ENOSYS,%d0
50	cmpl	#NR_syscalls,%d1
51	jcc	1f
52	lsl	#2,%d1
53	lea	sys_call_table, %a0
54	jbsr	%a0@(%d1)
55
561:	movel	%d0,%sp@(PT_D0)		/* save the return value */
57	subql	#4,%sp			/* dummy return address */
58	SAVE_SWITCH_STACK
59	jbsr	syscall_trace
60
61ret_from_signal:
62	RESTORE_SWITCH_STACK
63	addql	#4,%sp
64	jra	ret_from_exception
65
66ENTRY(system_call)
67	SAVE_ALL
68
69	/* save top of frame*/
70	pea	%sp@
71	jbsr	set_esp0
72	addql	#4,%sp
73
74	btst	#PF_TRACESYS_BIT,%a2@(TASK_FLAGS+PF_TRACESYS_OFF)
75	jne	do_trace
76	cmpl	#NR_syscalls,%d0
77	jcc	badsys
78	lsl	#2,%d0
79	lea	sys_call_table,%a0
80	movel	%a0@(%d0), %a0
81	jbsr	%a0@
82	movel	%d0,%sp@(PT_D0)		/* save the return value*/
83
84ret_from_exception:
85	btst	#5,%sp@(PT_SR)		/* check if returning to kernel*/
86	jeq	Luser_return		/* if so, skip resched, signals*/
87
88Lkernel_return:
89	RESTORE_ALL
90
91Luser_return:
92	/* only allow interrupts when we are really the last one on the*/
93	/* kernel stack, otherwise stack overflow can occur during*/
94	/* heavy interrupt load*/
95	andw	#ALLOWINT,%sr
96
97	movel	%sp,%d1			/* get thread_info pointer */
98	andl	#-THREAD_SIZE,%d1
99	movel	%d1,%a2
100	move	%a2@(TI_FLAGS),%d1	/* thread_info->flags */
101	andl	#_TIF_WORK_MASK,%d1
102	jne	Lwork_to_do
103	RESTORE_ALL
104
105Lwork_to_do:
106	movel	%a2@(TI_FLAGS),%d1	/* thread_info->flags */
107	btst	#TIF_NEED_RESCHED,%d1
108	jne	reschedule
109
110Lsignal_return:
111	subql	#4,%sp			/* dummy return address*/
112	SAVE_SWITCH_STACK
113	pea	%sp@(SWITCH_STACK_SIZE)
114	clrl	%sp@-
115	bsrw	do_signal
116	addql	#8,%sp
117	RESTORE_SWITCH_STACK
118	addql	#4,%sp
119Lreturn:
120	RESTORE_ALL
121
122/*
123 * This is the main interrupt handler, responsible for calling process_int()
124 */
125inthandler:
126	SAVE_ALL
127	addql	#1,local_irq_count	/*  put exception # in d0*/
128	movew	%sp@(PT_VECTOR), %d0
129	and.l	#0x3ff, %d0
130	lsr.l   #0x02,  %d0
131
132	movel	%sp,%sp@-
133	movel	%d0,%sp@- 		/*  put vector # on stack*/
134	jbsr	process_int		/*  process the IRQ*/
1353:     	addql	#8,%sp			/*  pop parameters off stack*/
136	bra	ret_from_interrupt
137
138ret_from_interrupt:
139	subql	#1,local_irq_count
140	jeq	1f
1412:
142	RESTORE_ALL
1431:
144	moveb	%sp@(PT_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,num_spurious
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	movel	%usp,%a2			/* save usp */
172	movel	%a2,%a0@(TASK_THREAD+THREAD_USP)
173
174	SAVE_SWITCH_STACK
175	movel	%sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */
176	movel	%a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */
177	RESTORE_SWITCH_STACK
178
179	movel	%a1@(TASK_THREAD+THREAD_USP),%a0 /* restore user stack */
180	movel	%a0,%usp
181	movew	%a1@(TASK_THREAD+THREAD_SR),%sr	/* restore thread status reg */
182	rts
183