Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux...
[pandora-kernel.git] / arch / m68k / platform / 68328 / entry.S
1 /*
2  *  linux/arch/m68knommu/platform/68328/entry.S
3  *
4  *  Copyright (C) 1991, 1992  Linus Torvalds
5  *
6  * This file is subject to the terms and conditions of the GNU General Public
7  * License.  See the file README.legal in the main directory of this archive
8  * for more details.
9  *
10  * Linux/m68k support by Hamish Macdonald
11  */
12
13 #include <linux/linkage.h>
14 #include <asm/thread_info.h>
15 #include <asm/unistd.h>
16 #include <asm/errno.h>
17 #include <asm/setup.h>
18 #include <asm/segment.h>
19 #include <asm/traps.h>
20 #include <asm/asm-offsets.h>
21 #include <asm/entry.h>
22
23 .text
24
25 .globl system_call
26 .globl resume
27 .globl ret_from_exception
28 .globl ret_from_signal
29 .globl sys_call_table
30 .globl ret_from_interrupt
31 .globl bad_interrupt
32 .globl inthandler1
33 .globl inthandler2
34 .globl inthandler3
35 .globl inthandler4
36 .globl inthandler5
37 .globl inthandler6
38 .globl inthandler7
39
40 badsys:
41         movel   #-ENOSYS,%sp@(PT_OFF_D0)
42         jra     ret_from_exception
43
44 do_trace:
45         movel   #-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/
46         subql   #4,%sp
47         SAVE_SWITCH_STACK
48         jbsr    syscall_trace_enter
49         RESTORE_SWITCH_STACK
50         addql   #4,%sp
51         movel   %sp@(PT_OFF_ORIG_D0),%d1
52         movel   #-ENOSYS,%d0
53         cmpl    #NR_syscalls,%d1
54         jcc     1f
55         lsl     #2,%d1
56         lea     sys_call_table, %a0
57         jbsr    %a0@(%d1)
58
59 1:      movel   %d0,%sp@(PT_OFF_D0)     /* save the return value */
60         subql   #4,%sp                  /* dummy return address */
61         SAVE_SWITCH_STACK
62         jbsr    syscall_trace_leave
63
64 ret_from_signal:
65         RESTORE_SWITCH_STACK
66         addql   #4,%sp
67         jra     ret_from_exception
68
69 ENTRY(system_call)
70         SAVE_ALL
71
72         /* save top of frame*/
73         pea     %sp@
74         jbsr    set_esp0
75         addql   #4,%sp
76
77         movel   %sp@(PT_OFF_ORIG_D0),%d0
78
79         movel   %sp,%d1                 /* get thread_info pointer */
80         andl    #-THREAD_SIZE,%d1
81         movel   %d1,%a2
82         btst    #(TIF_SYSCALL_TRACE%8),%a2@(TINFO_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
83         jne     do_trace
84         cmpl    #NR_syscalls,%d0
85         jcc     badsys
86         lsl     #2,%d0
87         lea     sys_call_table,%a0
88         movel   %a0@(%d0), %a0
89         jbsr    %a0@
90         movel   %d0,%sp@(PT_OFF_D0)     /* save the return value*/
91
92 ret_from_exception:
93         btst    #5,%sp@(PT_OFF_SR)      /* check if returning to kernel*/
94         jeq     Luser_return            /* if so, skip resched, signals*/
95
96 Lkernel_return:
97         RESTORE_ALL
98
99 Luser_return:
100         /* only allow interrupts when we are really the last one on the*/
101         /* kernel stack, otherwise stack overflow can occur during*/
102         /* heavy interrupt load*/
103         andw    #ALLOWINT,%sr
104
105         movel   %sp,%d1                 /* get thread_info pointer */
106         andl    #-THREAD_SIZE,%d1
107         movel   %d1,%a2
108 1:
109         move    %a2@(TINFO_FLAGS),%d1   /* thread_info->flags */
110         jne     Lwork_to_do
111         RESTORE_ALL
112
113 Lwork_to_do:
114         movel   %a2@(TINFO_FLAGS),%d1   /* thread_info->flags */
115         btst    #TIF_NEED_RESCHED,%d1
116         jne     reschedule
117
118 Lsignal_return:
119         subql   #4,%sp                  /* dummy return address*/
120         SAVE_SWITCH_STACK
121         pea     %sp@(SWITCH_STACK_SIZE)
122         bsrw    do_signal
123         addql   #4,%sp
124         RESTORE_SWITCH_STACK
125         addql   #4,%sp
126         jra     1b
127
128 /*
129  * This is the main interrupt handler, responsible for calling process_int()
130  */
131 inthandler1:
132         SAVE_ALL
133         movew   %sp@(PT_OFF_FORMATVEC), %d0
134         and     #0x3ff, %d0
135
136         movel   %sp,%sp@-
137         movel   #65,%sp@-               /*  put vector # on stack*/
138         jbsr    process_int             /*  process the IRQ*/
139 3:      addql   #8,%sp                  /*  pop parameters off stack*/
140         bra     ret_from_interrupt
141
142 inthandler2:
143         SAVE_ALL
144         movew   %sp@(PT_OFF_FORMATVEC), %d0
145         and     #0x3ff, %d0
146
147         movel   %sp,%sp@-
148         movel   #66,%sp@-               /*  put vector # on stack*/
149         jbsr    process_int             /*  process the IRQ*/
150 3:      addql   #8,%sp                  /*  pop parameters off stack*/
151         bra     ret_from_interrupt
152
153 inthandler3:
154         SAVE_ALL
155         movew   %sp@(PT_OFF_FORMATVEC), %d0
156         and     #0x3ff, %d0
157
158         movel   %sp,%sp@-
159         movel   #67,%sp@-               /*  put vector # on stack*/
160         jbsr    process_int             /*  process the IRQ*/
161 3:      addql   #8,%sp                  /*  pop parameters off stack*/
162         bra     ret_from_interrupt
163
164 inthandler4:
165         SAVE_ALL
166         movew   %sp@(PT_OFF_FORMATVEC), %d0
167         and     #0x3ff, %d0
168
169         movel   %sp,%sp@-
170         movel   #68,%sp@-               /*  put vector # on stack*/
171         jbsr    process_int             /*  process the IRQ*/
172 3:      addql   #8,%sp                  /*  pop parameters off stack*/
173         bra     ret_from_interrupt
174
175 inthandler5:
176         SAVE_ALL
177         movew   %sp@(PT_OFF_FORMATVEC), %d0
178         and     #0x3ff, %d0
179
180         movel   %sp,%sp@-
181         movel   #69,%sp@-               /*  put vector # on stack*/
182         jbsr    process_int             /*  process the IRQ*/
183 3:      addql   #8,%sp                  /*  pop parameters off stack*/
184         bra     ret_from_interrupt
185
186 inthandler6:
187         SAVE_ALL
188         movew   %sp@(PT_OFF_FORMATVEC), %d0
189         and     #0x3ff, %d0
190
191         movel   %sp,%sp@-
192         movel   #70,%sp@-               /*  put vector # on stack*/
193         jbsr    process_int             /*  process the IRQ*/
194 3:      addql   #8,%sp                  /*  pop parameters off stack*/
195         bra     ret_from_interrupt
196
197 inthandler7:
198         SAVE_ALL
199         movew   %sp@(PT_OFF_FORMATVEC), %d0
200         and     #0x3ff, %d0
201
202         movel   %sp,%sp@-
203         movel   #71,%sp@-               /*  put vector # on stack*/
204         jbsr    process_int             /*  process the IRQ*/
205 3:      addql   #8,%sp                  /*  pop parameters off stack*/
206         bra     ret_from_interrupt
207
208 inthandler:
209         SAVE_ALL
210         movew   %sp@(PT_OFF_FORMATVEC), %d0
211         and     #0x3ff, %d0
212
213         movel   %sp,%sp@-
214         movel   %d0,%sp@-               /*  put vector # on stack*/
215         jbsr    process_int             /*  process the IRQ*/
216 3:      addql   #8,%sp                  /*  pop parameters off stack*/
217         bra     ret_from_interrupt
218
219 ret_from_interrupt:
220         jeq     1f
221 2:
222         RESTORE_ALL
223 1:
224         moveb   %sp@(PT_OFF_SR), %d0
225         and     #7, %d0
226         jhi     2b
227
228         /* check if we need to do software interrupts */
229         jeq     ret_from_exception
230
231         pea     ret_from_exception
232         jra     do_softirq
233
234
235 /*
236  * Handler for uninitialized and spurious interrupts.
237  */
238 ENTRY(bad_interrupt)
239         addql   #1,num_spurious
240         rte
241
242 /*
243  * Beware - when entering resume, prev (the current task) is
244  * in a0, next (the new task) is in a1,so don't change these
245  * registers until their contents are no longer needed.
246  */
247 ENTRY(resume)
248         movel   %a0,%d1                         /* save prev thread in d1 */
249         movew   %sr,%a0@(TASK_THREAD+THREAD_SR) /* save sr */
250         movel   %usp,%a2                        /* save usp */
251         movel   %a2,%a0@(TASK_THREAD+THREAD_USP)
252
253         SAVE_SWITCH_STACK
254         movel   %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */
255         movel   %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */
256         RESTORE_SWITCH_STACK
257
258         movel   %a1@(TASK_THREAD+THREAD_USP),%a0 /* restore user stack */
259         movel   %a0,%usp
260         movew   %a1@(TASK_THREAD+THREAD_SR),%sr /* restore thread status reg */
261         rts
262