]>
Commit | Line | Data |
---|---|---|
72af70cf | 1 | /* |
1da177e4 LT |
2 | * linux/arch/cris/entry.S |
3 | * | |
4 | * Copyright (C) 2000, 2001, 2002 Axis Communications AB | |
5 | * | |
6 | * Authors: Bjorn Wesen (bjornw@axis.com) | |
1da177e4 LT |
7 | */ |
8 | ||
9 | /* | |
10 | * entry.S contains the system-call and fault low-level handling routines. | |
11 | * | |
12 | * NOTE: This code handles signal-recognition, which happens every time | |
13 | * after a timer-interrupt and after each system call. | |
14 | * | |
15 | * Stack layout in 'ret_from_system_call': | |
16 | * ptrace needs to have all regs on the stack. | |
17 | * if the order here is changed, it needs to be | |
18 | * updated in fork.c:copy_process, signal.c:do_signal, | |
19 | * ptrace.c and ptrace.h | |
20 | * | |
21 | */ | |
22 | ||
1da177e4 LT |
23 | #include <linux/linkage.h> |
24 | #include <linux/sys.h> | |
25 | #include <asm/unistd.h> | |
556dcee7 | 26 | #include <arch/sv_addr_ag.h> |
1da177e4 LT |
27 | #include <asm/errno.h> |
28 | #include <asm/thread_info.h> | |
5a077369 | 29 | #include <asm/asm-offsets.h> |
1da177e4 LT |
30 | #include <asm/page.h> |
31 | #include <asm/pgtable.h> | |
32 | ||
33 | ;; functions exported from this file | |
34 | ||
35 | .globl system_call | |
36 | .globl ret_from_intr | |
37 | .globl ret_from_fork | |
38 | .globl resume | |
39 | .globl multiple_interrupt | |
40 | .globl hwbreakpoint | |
41 | .globl IRQ1_interrupt | |
42 | .globl spurious_interrupt | |
43 | .globl hw_bp_trigs | |
44 | .globl mmu_bus_fault | |
45 | .globl do_sigtrap | |
46 | .globl gdb_handle_breakpoint | |
47 | .globl sys_call_table | |
48 | ||
49 | ;; below are various parts of system_call which are not in the fast-path | |
50 | ||
51 | #ifdef CONFIG_PREEMPT | |
52 | ; Check if preemptive kernel scheduling should be done | |
53 | _resume_kernel: | |
7cf32cad | 54 | di |
1da177e4 LT |
55 | ; Load current task struct |
56 | movs.w -8192, $r0 ; THREAD_SIZE = 8192 | |
57 | and.d $sp, $r0 | |
58 | move.d [$r0+TI_preempt_count], $r10 ; Preemption disabled? | |
59 | bne _Rexit | |
60 | nop | |
61 | _need_resched: | |
62 | move.d [$r0+TI_flags], $r10 | |
63 | btstq TIF_NEED_RESCHED, $r10 ; Check if need_resched is set | |
64 | bpl _Rexit | |
65 | nop | |
66 | ; Ok, lets's do some preemptive kernel scheduling | |
7cf32cad | 67 | jsr preempt_schedule_irq |
1da177e4 LT |
68 | ; Load new task struct |
69 | movs.w -8192, $r0 ; THREAD_SIZE = 8192 | |
70 | and.d $sp, $r0 | |
71 | ; One more time (with new task) | |
72 | ba _need_resched | |
73 | nop | |
74 | #else | |
75 | #define _resume_kernel _Rexit | |
76 | #endif | |
77 | ||
78 | ; Called at exit from fork. schedule_tail must be called to drop | |
79 | ; spinlock if CONFIG_PREEMPT | |
80 | ret_from_fork: | |
81 | jsr schedule_tail | |
82 | ba ret_from_sys_call | |
83 | nop | |
84 | ||
85 | ret_from_intr: | |
86 | ;; check for resched if preemptive kernel or if we're going back to user-mode | |
87 | ;; this test matches the user_regs(regs) macro | |
88 | ;; we cannot simply test $dccr, because that does not necessarily | |
89 | ;; reflect what mode we'll return into. | |
90 | ||
91 | move.d [$sp + PT_dccr], $r0; regs->dccr | |
92 | btstq 8, $r0 ; U-flag | |
93 | bpl _resume_kernel | |
94 | ; Note that di below is in delay slot | |
95 | ||
96 | _resume_userspace: | |
97 | di ; so need_resched and sigpending don't change | |
98 | ||
99 | movs.w -8192, $r0 ; THREAD_SIZE == 8192 | |
100 | and.d $sp, $r0 | |
101 | ||
102 | move.d [$r0+TI_flags], $r10 ; current->work | |
103 | and.d _TIF_WORK_MASK, $r10 ; is there any work to be done on return | |
104 | bne _work_pending | |
105 | nop | |
106 | ba _Rexit | |
107 | nop | |
108 | ||
109 | ;; The system_call is called by a BREAK instruction, which works like | |
110 | ;; an interrupt call but it stores the return PC in BRP instead of IRP. | |
111 | ;; Since we dont really want to have two epilogues (one for system calls | |
112 | ;; and one for interrupts) we push the contents of BRP instead of IRP in the | |
113 | ;; system call prologue, to make it look like an ordinary interrupt on the | |
114 | ;; stackframe. | |
115 | ;; | |
116 | ;; Since we can't have system calls inside interrupts, it should not matter | |
117 | ;; that we don't stack IRP. | |
118 | ;; | |
119 | ;; In r9 we have the wanted syscall number. Arguments come in r10,r11,r12,r13,mof,srp | |
120 | ;; | |
121 | ;; This function looks on the _surface_ like spaghetti programming, but it's | |
122 | ;; really designed so that the fast-path does not force cache-loading of non-used | |
123 | ;; instructions. Only the non-common cases cause the outlined code to run.. | |
124 | ||
125 | system_call: | |
126 | ;; stack-frame similar to the irq heads, which is reversed in ret_from_sys_call | |
127 | move $brp,[$sp=$sp-16]; instruction pointer and room for a fake SBFS frame | |
128 | push $srp | |
129 | push $dccr | |
130 | push $mof | |
131 | subq 14*4, $sp ; make room for r0-r13 | |
132 | movem $r13, [$sp] ; push r0-r13 | |
133 | push $r10 ; push orig_r10 | |
134 | clear.d [$sp=$sp-4] ; frametype == 0, normal stackframe | |
135 | ||
136 | movs.w -ENOSYS, $r0 | |
137 | move.d $r0, [$sp+PT_r10] ; put the default return value in r10 in the frame | |
138 | ||
139 | ;; check if this process is syscall-traced | |
140 | ||
141 | movs.w -8192, $r0 ; THREAD_SIZE == 8192 | |
142 | and.d $sp, $r0 | |
143 | ||
144 | move.d [$r0+TI_flags], $r0 | |
145 | btstq TIF_SYSCALL_TRACE, $r0 | |
146 | bmi _syscall_trace_entry | |
147 | nop | |
148 | ||
149 | _syscall_traced: | |
150 | ||
151 | ;; check for sanity in the requested syscall number | |
152 | ||
153 | cmpu.w NR_syscalls, $r9 | |
154 | bcc ret_from_sys_call | |
155 | lslq 2, $r9 ; multiply by 4, in the delay slot | |
156 | ||
157 | ;; as a bonus 7th parameter, we give the location on the stack | |
158 | ;; of the register structure itself. some syscalls need this. | |
159 | ||
160 | push $sp | |
161 | ||
162 | ;; the parameter carrying registers r10, r11, r12 and 13 are intact. | |
163 | ;; the fifth and sixth parameters (if any) was in mof and srp | |
164 | ;; respectively, and we need to put them on the stack. | |
165 | ||
166 | push $srp | |
167 | push $mof | |
168 | ||
169 | jsr [$r9+sys_call_table] ; actually do the system call | |
170 | addq 3*4, $sp ; pop the mof, srp and regs parameters | |
171 | move.d $r10, [$sp+PT_r10] ; save the return value | |
172 | ||
173 | moveq 1, $r9 ; "parameter" to ret_from_sys_call to show it was a sys call | |
174 | ||
175 | ;; fall through into ret_from_sys_call to return | |
176 | ||
177 | ret_from_sys_call: | |
178 | ;; r9 is a parameter - if >=1 we came from a syscall, if 0, from an irq | |
179 | ||
180 | ;; get the current task-struct pointer (see top for defs) | |
181 | ||
182 | movs.w -8192, $r0 ; THREAD_SIZE == 8192 | |
183 | and.d $sp, $r0 | |
184 | ||
185 | di ; make sure need_resched and sigpending don't change | |
186 | move.d [$r0+TI_flags],$r1 | |
187 | and.d _TIF_ALLWORK_MASK, $r1 | |
188 | bne _syscall_exit_work | |
189 | nop | |
190 | ||
191 | _Rexit: | |
192 | ;; this epilogue MUST match the prologues in multiple_interrupt, irq.h and ptregs.h | |
193 | pop $r10 ; frametype | |
194 | bne _RBFexit ; was not CRIS_FRAME_NORMAL, handle otherwise | |
195 | addq 4, $sp ; skip orig_r10, in delayslot | |
196 | movem [$sp+], $r13 ; registers r0-r13 | |
197 | pop $mof ; multiply overflow register | |
198 | pop $dccr ; condition codes | |
199 | pop $srp ; subroutine return pointer | |
200 | ;; now we have a 4-word SBFS frame which we do not want to restore | |
201 | ;; using RBF since it was not stacked with SBFS. instead we would like to | |
202 | ;; just get the PC value to restart it with, and skip the rest of | |
203 | ;; the frame. | |
204 | ;; Also notice that it's important to use instructions here that | |
205 | ;; keep the interrupts disabled (since we've already popped DCCR) | |
206 | move [$sp=$sp+16], $p8; pop the SBFS frame from the sp | |
207 | jmpu [$sp-16] ; return through the irp field in the sbfs frame | |
208 | ||
209 | _RBFexit: | |
210 | movem [$sp+], $r13 ; registers r0-r13, in delay slot | |
211 | pop $mof ; multiply overflow register | |
212 | pop $dccr ; condition codes | |
213 | pop $srp ; subroutine return pointer | |
214 | rbf [$sp+] ; return by popping the CPU status | |
215 | ||
216 | ;; We get here after doing a syscall if extra work might need to be done | |
217 | ;; perform syscall exit tracing if needed | |
218 | ||
219 | _syscall_exit_work: | |
220 | ;; $r0 contains current at this point and irq's are disabled | |
221 | ||
222 | move.d [$r0+TI_flags], $r1 | |
223 | btstq TIF_SYSCALL_TRACE, $r1 | |
224 | bpl _work_pending | |
225 | nop | |
226 | ||
227 | ei | |
228 | ||
229 | move.d $r9, $r1 ; preserve r9 | |
230 | jsr do_syscall_trace | |
231 | move.d $r1, $r9 | |
232 | ||
233 | ba _resume_userspace | |
234 | nop | |
235 | ||
236 | _work_pending: | |
237 | move.d [$r0+TI_flags], $r1 | |
238 | btstq TIF_NEED_RESCHED, $r1 | |
239 | bpl _work_notifysig ; was neither trace nor sched, must be signal/notify | |
240 | nop | |
241 | ||
242 | _work_resched: | |
243 | move.d $r9, $r1 ; preserve r9 | |
244 | jsr schedule | |
245 | move.d $r1, $r9 | |
246 | di | |
247 | ||
248 | move.d [$r0+TI_flags], $r1 | |
249 | and.d _TIF_WORK_MASK, $r1; ignore the syscall trace counter | |
250 | beq _Rexit | |
251 | nop | |
252 | btstq TIF_NEED_RESCHED, $r1 | |
253 | bmi _work_resched ; current->work.need_resched | |
254 | nop | |
255 | ||
256 | _work_notifysig: | |
257 | ;; deal with pending signals and notify-resume requests | |
258 | ||
259 | move.d $r9, $r10 ; do_notify_resume syscall/irq param | |
7b275523 JN |
260 | move.d $sp, $r11 ; the regs param |
261 | move.d $r1, $r12 ; the thread_info_flags parameter | |
1da177e4 LT |
262 | jsr do_notify_resume |
263 | ||
264 | ba _Rexit | |
265 | nop | |
266 | ||
267 | ;; We get here as a sidetrack when we've entered a syscall with the | |
268 | ;; trace-bit set. We need to call do_syscall_trace and then continue | |
269 | ;; with the call. | |
270 | ||
271 | _syscall_trace_entry: | |
272 | ;; PT_r10 in the frame contains -ENOSYS as required, at this point | |
273 | ||
274 | jsr do_syscall_trace | |
275 | ||
276 | ;; now re-enter the syscall code to do the syscall itself | |
277 | ;; we need to restore $r9 here to contain the wanted syscall, and | |
278 | ;; the other parameter-bearing registers | |
279 | ||
280 | move.d [$sp+PT_r9], $r9 | |
281 | move.d [$sp+PT_orig_r10], $r10 ; PT_r10 is already filled with -ENOSYS. | |
282 | move.d [$sp+PT_r11], $r11 | |
283 | move.d [$sp+PT_r12], $r12 | |
284 | move.d [$sp+PT_r13], $r13 | |
285 | move [$sp+PT_mof], $mof | |
286 | move [$sp+PT_srp], $srp | |
287 | ||
288 | ba _syscall_traced | |
289 | nop | |
290 | ||
291 | ;; resume performs the actual task-switching, by switching stack pointers | |
292 | ;; input arguments: r10 = prev, r11 = next, r12 = thread offset in task struct | |
293 | ;; returns old current in r10 | |
294 | ;; | |
295 | ;; TODO: see the i386 version. The switch_to which calls resume in our version | |
296 | ;; could really be an inline asm of this. | |
297 | ||
298 | resume: | |
299 | push $srp ; we keep the old/new PC on the stack | |
300 | add.d $r12, $r10 ; r10 = current tasks tss | |
301 | move $dccr, [$r10+THREAD_dccr]; save irq enable state | |
302 | di | |
303 | ||
304 | move $usp, [$r10+ THREAD_usp] ; save user-mode stackpointer | |
305 | ||
306 | ;; See copy_thread for the reason why register R9 is saved. | |
307 | subq 10*4, $sp | |
308 | movem $r9, [$sp] ; save non-scratch registers and R9. | |
309 | ||
310 | move.d $sp, [$r10+THREAD_ksp] ; save the kernel stack pointer for the old task | |
311 | move.d $sp, $r10 ; return last running task in r10 | |
312 | and.d -8192, $r10 ; get thread_info from stackpointer | |
313 | move.d [$r10+TI_task], $r10 ; get task | |
314 | add.d $r12, $r11 ; find the new tasks tss | |
315 | move.d [$r11+THREAD_ksp], $sp ; switch into the new stackframe by restoring kernel sp | |
316 | ||
317 | movem [$sp+], $r9 ; restore non-scratch registers and R9. | |
318 | ||
319 | move [$r11+THREAD_usp], $usp ; restore user-mode stackpointer | |
320 | ||
321 | move [$r11+THREAD_dccr], $dccr ; restore irq enable status | |
322 | jump [$sp+] ; restore PC | |
323 | ||
324 | ;; This is the MMU bus fault handler. | |
325 | ;; It needs to stack the CPU status and overall is different | |
326 | ;; from the other interrupt handlers. | |
327 | ||
328 | mmu_bus_fault: | |
329 | ;; For refills we try to do a quick page table lookup. If it is | |
330 | ;; a real fault we let the mm subsystem handle it. | |
331 | ||
332 | ;; the first longword in the sbfs frame was the interrupted PC | |
333 | ;; which fits nicely with the "IRP" slot in pt_regs normally used to | |
334 | ;; contain the return address. used by Oops to print kernel errors. | |
335 | sbfs [$sp=$sp-16] ; push the internal CPU status | |
336 | push $dccr | |
337 | di | |
338 | subq 2*4, $sp | |
339 | movem $r1, [$sp] | |
340 | move.d [R_MMU_CAUSE], $r1 | |
341 | ;; ETRAX 100LX TR89 bugfix: if the second half of an unaligned | |
342 | ;; write causes a MMU-fault, it will not be restarted correctly. | |
343 | ;; This could happen if a write crosses a page-boundary and the | |
344 | ;; second page is not yet COW'ed or even loaded. The workaround | |
345 | ;; is to clear the unaligned bit in the CPU status record, so | |
346 | ;; that the CPU will rerun both the first and second halves of | |
347 | ;; the instruction. This will not have any sideeffects unless | |
348 | ;; the first half goes to any device or memory that can't be | |
349 | ;; written twice, and which is mapped through the MMU. | |
350 | ;; | |
351 | ;; We only need to do this for writes. | |
352 | btstq 8, $r1 ; Write access? | |
353 | bpl 1f | |
354 | nop | |
355 | move.d [$sp+16], $r0 ; Clear unaligned bit in csrinstr | |
356 | and.d ~(1<<5), $r0 | |
357 | move.d $r0, [$sp+16] | |
358 | 1: btstq 12, $r1 ; Refill? | |
359 | bpl 2f | |
7cf32cad MS |
360 | lsrq 24, $r1 ; Get PGD index (bit 24-31) |
361 | move.d [per_cpu__current_pgd], $r0 ; PGD for the current process | |
1da177e4 LT |
362 | move.d [$r0+$r1.d], $r0 ; Get PMD |
363 | beq 2f | |
364 | nop | |
365 | and.w PAGE_MASK, $r0 ; Remove PMD flags | |
366 | move.d [R_MMU_CAUSE], $r1 | |
367 | lsrq PAGE_SHIFT, $r1 | |
7cf32cad | 368 | and.d 0x7ff, $r1 ; Get PTE index into PGD (bit 13-23) |
1da177e4 LT |
369 | move.d [$r0+$r1.d], $r1 ; Get PTE |
370 | beq 2f | |
371 | nop | |
372 | ;; Store in TLB | |
373 | move.d $r1, [R_TLB_LO] | |
374 | ;; Return | |
375 | movem [$sp+], $r1 | |
376 | pop $dccr | |
377 | rbf [$sp+] ; return by popping the CPU status | |
378 | ||
379 | 2: ; PMD or PTE missing, let the mm subsystem fix it up. | |
380 | movem [$sp+], $r1 | |
381 | pop $dccr | |
382 | ||
383 | ; Ok, not that easy, pass it on to the mm subsystem | |
384 | ; The MMU status record is now on the stack | |
385 | push $srp ; make a stackframe similar to pt_regs | |
386 | push $dccr | |
387 | push $mof | |
388 | di | |
389 | subq 14*4, $sp | |
390 | movem $r13, [$sp] | |
391 | push $r10 ; dummy orig_r10 | |
392 | moveq 1, $r10 | |
393 | push $r10 ; frametype == 1, BUSFAULT frame type | |
394 | ||
395 | move.d $sp, $r10 ; pt_regs argument to handle_mmu_bus_fault | |
396 | ||
397 | jsr handle_mmu_bus_fault ; in arch/cris/arch-v10/mm/fault.c | |
398 | ||
399 | ;; now we need to return through the normal path, we cannot just | |
400 | ;; do the RBFexit since we might have killed off the running | |
401 | ;; process due to a SEGV, scheduled due to a page blocking or | |
402 | ;; whatever. | |
403 | ||
404 | moveq 0, $r9 ; busfault is equivalent to an irq | |
405 | ||
406 | ba ret_from_intr | |
407 | nop | |
408 | ||
409 | ;; special handlers for breakpoint and NMI | |
410 | hwbreakpoint: | |
411 | push $dccr | |
412 | di | |
413 | push $r10 | |
414 | push $r11 | |
415 | move.d [hw_bp_trig_ptr],$r10 | |
416 | move $brp,$r11 | |
417 | move.d $r11,[$r10+] | |
418 | move.d $r10,[hw_bp_trig_ptr] | |
419 | 1: pop $r11 | |
420 | pop $r10 | |
421 | pop $dccr | |
422 | retb | |
423 | nop | |
424 | ||
425 | IRQ1_interrupt: | |
1da177e4 LT |
426 | ;; this prologue MUST match the one in irq.h and the struct in ptregs.h!!! |
427 | move $brp,[$sp=$sp-16]; instruction pointer and room for a fake SBFS frame | |
428 | push $srp | |
429 | push $dccr | |
430 | push $mof | |
431 | di | |
432 | subq 14*4, $sp | |
433 | movem $r13, [$sp] | |
434 | push $r10 ; push orig_r10 | |
435 | clear.d [$sp=$sp-4] ; frametype == 0, normal frame | |
436 | ||
7b275523 JN |
437 | ;; If there is a glitch on the NMI pin shorter than ~100ns |
438 | ;; (i.e. non-active by the time we get here) then the nmi_pin bit | |
439 | ;; in R_IRQ_MASK0_RD will already be cleared. The watchdog_nmi bit | |
440 | ;; is cleared by us however (when feeding the watchdog), which is why | |
441 | ;; we use that bit to determine what brought us here. | |
442 | ||
7cf32cad | 443 | move.d [R_IRQ_MASK0_RD], $r1 ; External NMI or watchdog? |
7b275523 JN |
444 | and.d (1<<30), $r1 |
445 | bne wdog | |
7cf32cad MS |
446 | move.d $sp, $r10 |
447 | jsr handle_nmi | |
448 | setf m ; Enable NMI again | |
7b275523 | 449 | ba _Rexit ; Return the standard way |
7cf32cad MS |
450 | nop |
451 | wdog: | |
452 | #if defined(CONFIG_ETRAX_WATCHDOG) && !defined(CONFIG_SVINTO_SIM) | |
1da177e4 LT |
453 | ;; Check if we're waiting for reset to happen, as signalled by |
454 | ;; hard_reset_now setting cause_of_death to a magic value. If so, just | |
455 | ;; get stuck until reset happens. | |
456 | .comm cause_of_death, 4 ;; Don't declare this anywhere. | |
457 | move.d [cause_of_death], $r10 | |
458 | cmp.d 0xbedead, $r10 | |
459 | _killed_by_death: | |
460 | beq _killed_by_death | |
461 | nop | |
462 | ||
463 | ;; We'll see this in ksymoops dumps. | |
464 | Watchdog_bite: | |
465 | ||
466 | #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY | |
467 | ;; We just restart the watchdog here to be sure we dont get | |
468 | ;; hit while printing the watchdogmsg below | |
469 | ;; This restart is compatible with the rest of the C-code, so | |
470 | ;; the C-code can keep restarting the watchdog after this point. | |
471 | ;; The non-NICE_DOGGY code below though, disables the possibility | |
472 | ;; to restart since it changes the watchdog key, to avoid any | |
473 | ;; buggy loops etc. keeping the watchdog alive after this. | |
474 | jsr reset_watchdog | |
475 | #else | |
476 | ||
477 | ;; We need to extend the 3.3ms after the NMI at watchdog bite, so we have | |
478 | ;; time for an oops-dump over a 115k2 serial wire. Another 100ms should do. | |
479 | ||
480 | ;; Change the watchdog key to an arbitrary 3-bit value and restart the | |
481 | ;; watchdog. | |
482 | #define WD_INIT 2 | |
483 | moveq IO_FIELD (R_WATCHDOG, key, WD_INIT), $r10 | |
484 | move.d R_WATCHDOG, $r11 | |
485 | ||
486 | move.d $r10, [$r11] | |
487 | moveq IO_FIELD (R_WATCHDOG, key, \ | |
488 | IO_EXTRACT (R_WATCHDOG, key, \ | |
489 | IO_MASK (R_WATCHDOG, key)) \ | |
490 | ^ WD_INIT) \ | |
491 | | IO_STATE (R_WATCHDOG, enable, start), $r10 | |
492 | move.d $r10, [$r11] | |
493 | ||
494 | #endif | |
495 | ||
496 | ;; Note that we don't do "setf m" here (or after two necessary NOPs), | |
497 | ;; since *not* doing that saves us from re-entrancy checks. We don't want | |
498 | ;; to get here again due to possible subsequent NMIs; we want the watchdog | |
499 | ;; to reset us. | |
500 | ||
501 | move.d _watchdogmsg,$r10 | |
502 | jsr printk | |
503 | ||
504 | move.d $sp, $r10 | |
505 | jsr watchdog_bite_hook | |
506 | ||
507 | ;; This nop is here so we see the "Watchdog_bite" label in ksymoops dumps | |
508 | ;; rather than "spurious_interrupt". | |
509 | nop | |
510 | ;; At this point we drop down into spurious_interrupt, which will do a | |
511 | ;; hard reset. | |
512 | ||
513 | .section .rodata,"a" | |
514 | _watchdogmsg: | |
515 | .ascii "Oops: bitten by watchdog\n\0" | |
516 | .previous | |
517 | ||
518 | #endif /* CONFIG_ETRAX_WATCHDOG and not CONFIG_SVINTO_SIM */ | |
519 | ||
520 | spurious_interrupt: | |
521 | di | |
522 | jump hard_reset_now | |
523 | ||
524 | ;; this handles the case when multiple interrupts arrive at the same time | |
525 | ;; we jump to the first set interrupt bit in a priority fashion | |
526 | ;; the hardware will call the unserved interrupts after the handler finishes | |
527 | ||
528 | multiple_interrupt: | |
529 | ;; this prologue MUST match the one in irq.h and the struct in ptregs.h!!! | |
530 | move $irp,[$sp=$sp-16]; instruction pointer and room for a fake SBFS frame | |
531 | push $srp | |
532 | push $dccr | |
533 | push $mof | |
534 | di | |
535 | subq 14*4, $sp | |
536 | movem $r13, [$sp] | |
537 | push $r10 ; push orig_r10 | |
538 | clear.d [$sp=$sp-4] ; frametype == 0, normal frame | |
6d3d4be4 | 539 | |
7b275523 JN |
540 | move.d $sp, $r10 |
541 | jsr do_multiple_IRQ | |
6d3d4be4 | 542 | |
1da177e4 LT |
543 | jump ret_from_intr |
544 | ||
545 | do_sigtrap: | |
546 | ;; | |
547 | ;; SIGTRAP the process that executed the break instruction. | |
548 | ;; Make a frame that Rexit in entry.S expects. | |
549 | ;; | |
550 | move $brp, [$sp=$sp-16] ; Push BRP while faking a cpu status record. | |
551 | push $srp ; Push subroutine return pointer. | |
552 | push $dccr ; Push condition codes. | |
553 | push $mof ; Push multiply overflow reg. | |
554 | di ; Need to disable irq's at this point. | |
555 | subq 14*4, $sp ; Make room for r0-r13. | |
556 | movem $r13, [$sp] ; Push the r0-r13 registers. | |
557 | push $r10 ; Push orig_r10. | |
558 | clear.d [$sp=$sp-4] ; Frametype - this is a normal stackframe. | |
559 | ||
560 | movs.w -8192,$r9 ; THREAD_SIZE == 8192 | |
561 | and.d $sp, $r9 | |
562 | move.d [$r9+TI_task], $r10 | |
563 | move.d [$r10+TASK_pid], $r10 ; current->pid as arg1. | |
564 | moveq 5, $r11 ; SIGTRAP as arg2. | |
565 | jsr sys_kill | |
566 | jump ret_from_intr ; Use the return routine for interrupts. | |
567 | ||
568 | gdb_handle_breakpoint: | |
569 | push $dccr | |
570 | push $r0 | |
571 | #ifdef CONFIG_ETRAX_KGDB | |
572 | move $dccr, $r0 ; U-flag not affected by previous insns. | |
573 | btstq 8, $r0 ; Test the U-flag. | |
574 | bmi _ugdb_handle_breakpoint ; Go to user mode debugging. | |
575 | nop ; Empty delay slot (cannot pop r0 here). | |
576 | pop $r0 ; Restore r0. | |
577 | ba kgdb_handle_breakpoint ; Go to kernel debugging. | |
578 | pop $dccr ; Restore dccr in delay slot. | |
579 | #endif | |
580 | ||
581 | _ugdb_handle_breakpoint: | |
582 | move $brp, $r0 ; Use r0 temporarily for calculation. | |
583 | subq 2, $r0 ; Set to address of previous instruction. | |
584 | move $r0, $brp | |
585 | pop $r0 ; Restore r0. | |
586 | ba do_sigtrap ; SIGTRAP the offending process. | |
587 | pop $dccr ; Restore dccr in delay slot. | |
6d3d4be4 | 588 | |
7b275523 JN |
589 | .global kernel_execve |
590 | kernel_execve: | |
591 | move.d __NR_execve, $r9 | |
592 | break 13 | |
593 | ret | |
594 | nop | |
595 | ||
1da177e4 LT |
596 | .data |
597 | ||
598 | hw_bp_trigs: | |
599 | .space 64*4 | |
600 | hw_bp_trig_ptr: | |
601 | .dword hw_bp_trigs | |
602 | ||
603 | .section .rodata,"a" | |
604 | sys_call_table: | |
605 | .long sys_restart_syscall /* 0 - old "setup()" system call, used for restarting */ | |
606 | .long sys_exit | |
607 | .long sys_fork | |
608 | .long sys_read | |
609 | .long sys_write | |
610 | .long sys_open /* 5 */ | |
611 | .long sys_close | |
612 | .long sys_waitpid | |
613 | .long sys_creat | |
614 | .long sys_link | |
615 | .long sys_unlink /* 10 */ | |
616 | .long sys_execve | |
617 | .long sys_chdir | |
618 | .long sys_time | |
619 | .long sys_mknod | |
620 | .long sys_chmod /* 15 */ | |
621 | .long sys_lchown16 | |
622 | .long sys_ni_syscall /* old break syscall holder */ | |
623 | .long sys_stat | |
624 | .long sys_lseek | |
625 | .long sys_getpid /* 20 */ | |
626 | .long sys_mount | |
627 | .long sys_oldumount | |
628 | .long sys_setuid16 | |
629 | .long sys_getuid16 | |
630 | .long sys_stime /* 25 */ | |
631 | .long sys_ptrace | |
632 | .long sys_alarm | |
633 | .long sys_fstat | |
634 | .long sys_pause | |
635 | .long sys_utime /* 30 */ | |
636 | .long sys_ni_syscall /* old stty syscall holder */ | |
637 | .long sys_ni_syscall /* old gtty syscall holder */ | |
638 | .long sys_access | |
639 | .long sys_nice | |
640 | .long sys_ni_syscall /* 35 old ftime syscall holder */ | |
641 | .long sys_sync | |
642 | .long sys_kill | |
643 | .long sys_rename | |
644 | .long sys_mkdir | |
645 | .long sys_rmdir /* 40 */ | |
646 | .long sys_dup | |
647 | .long sys_pipe | |
648 | .long sys_times | |
649 | .long sys_ni_syscall /* old prof syscall holder */ | |
650 | .long sys_brk /* 45 */ | |
651 | .long sys_setgid16 | |
652 | .long sys_getgid16 | |
653 | .long sys_signal | |
654 | .long sys_geteuid16 | |
655 | .long sys_getegid16 /* 50 */ | |
656 | .long sys_acct | |
657 | .long sys_umount /* recycled never used phys( */ | |
658 | .long sys_ni_syscall /* old lock syscall holder */ | |
659 | .long sys_ioctl | |
660 | .long sys_fcntl /* 55 */ | |
661 | .long sys_ni_syscall /* old mpx syscall holder */ | |
662 | .long sys_setpgid | |
663 | .long sys_ni_syscall /* old ulimit syscall holder */ | |
664 | .long sys_ni_syscall /* old sys_olduname holder */ | |
665 | .long sys_umask /* 60 */ | |
666 | .long sys_chroot | |
667 | .long sys_ustat | |
668 | .long sys_dup2 | |
669 | .long sys_getppid | |
670 | .long sys_getpgrp /* 65 */ | |
671 | .long sys_setsid | |
672 | .long sys_sigaction | |
673 | .long sys_sgetmask | |
674 | .long sys_ssetmask | |
675 | .long sys_setreuid16 /* 70 */ | |
676 | .long sys_setregid16 | |
677 | .long sys_sigsuspend | |
678 | .long sys_sigpending | |
679 | .long sys_sethostname | |
680 | .long sys_setrlimit /* 75 */ | |
681 | .long sys_old_getrlimit | |
682 | .long sys_getrusage | |
683 | .long sys_gettimeofday | |
684 | .long sys_settimeofday | |
685 | .long sys_getgroups16 /* 80 */ | |
686 | .long sys_setgroups16 | |
687 | .long sys_select /* was old_select in Linux/E100 */ | |
688 | .long sys_symlink | |
689 | .long sys_lstat | |
690 | .long sys_readlink /* 85 */ | |
691 | .long sys_uselib | |
692 | .long sys_swapon | |
693 | .long sys_reboot | |
e55380ed | 694 | .long sys_old_readdir |
1da177e4 LT |
695 | .long old_mmap /* 90 */ |
696 | .long sys_munmap | |
697 | .long sys_truncate | |
698 | .long sys_ftruncate | |
699 | .long sys_fchmod | |
700 | .long sys_fchown16 /* 95 */ | |
701 | .long sys_getpriority | |
702 | .long sys_setpriority | |
703 | .long sys_ni_syscall /* old profil syscall holder */ | |
704 | .long sys_statfs | |
705 | .long sys_fstatfs /* 100 */ | |
706 | .long sys_ni_syscall /* sys_ioperm in i386 */ | |
707 | .long sys_socketcall | |
708 | .long sys_syslog | |
709 | .long sys_setitimer | |
710 | .long sys_getitimer /* 105 */ | |
711 | .long sys_newstat | |
712 | .long sys_newlstat | |
713 | .long sys_newfstat | |
714 | .long sys_ni_syscall /* old sys_uname holder */ | |
715 | .long sys_ni_syscall /* sys_iopl in i386 */ | |
716 | .long sys_vhangup | |
717 | .long sys_ni_syscall /* old "idle" system call */ | |
718 | .long sys_ni_syscall /* vm86old in i386 */ | |
719 | .long sys_wait4 | |
720 | .long sys_swapoff /* 115 */ | |
721 | .long sys_sysinfo | |
722 | .long sys_ipc | |
723 | .long sys_fsync | |
724 | .long sys_sigreturn | |
725 | .long sys_clone /* 120 */ | |
726 | .long sys_setdomainname | |
727 | .long sys_newuname | |
728 | .long sys_ni_syscall /* sys_modify_ldt */ | |
729 | .long sys_adjtimex | |
730 | .long sys_mprotect /* 125 */ | |
731 | .long sys_sigprocmask | |
732 | .long sys_ni_syscall /* old "create_module" */ | |
733 | .long sys_init_module | |
734 | .long sys_delete_module | |
735 | .long sys_ni_syscall /* 130: old "get_kernel_syms" */ | |
736 | .long sys_quotactl | |
737 | .long sys_getpgid | |
738 | .long sys_fchdir | |
739 | .long sys_bdflush | |
740 | .long sys_sysfs /* 135 */ | |
741 | .long sys_personality | |
742 | .long sys_ni_syscall /* for afs_syscall */ | |
743 | .long sys_setfsuid16 | |
744 | .long sys_setfsgid16 | |
745 | .long sys_llseek /* 140 */ | |
746 | .long sys_getdents | |
747 | .long sys_select | |
748 | .long sys_flock | |
749 | .long sys_msync | |
750 | .long sys_readv /* 145 */ | |
751 | .long sys_writev | |
752 | .long sys_getsid | |
753 | .long sys_fdatasync | |
754 | .long sys_sysctl | |
755 | .long sys_mlock /* 150 */ | |
756 | .long sys_munlock | |
757 | .long sys_mlockall | |
758 | .long sys_munlockall | |
759 | .long sys_sched_setparam | |
760 | .long sys_sched_getparam /* 155 */ | |
761 | .long sys_sched_setscheduler | |
762 | .long sys_sched_getscheduler | |
763 | .long sys_sched_yield | |
764 | .long sys_sched_get_priority_max | |
765 | .long sys_sched_get_priority_min /* 160 */ | |
766 | .long sys_sched_rr_get_interval | |
767 | .long sys_nanosleep | |
768 | .long sys_mremap | |
769 | .long sys_setresuid16 | |
770 | .long sys_getresuid16 /* 165 */ | |
771 | .long sys_ni_syscall /* sys_vm86 */ | |
772 | .long sys_ni_syscall /* Old sys_query_module */ | |
773 | .long sys_poll | |
774 | .long sys_nfsservctl | |
775 | .long sys_setresgid16 /* 170 */ | |
776 | .long sys_getresgid16 | |
777 | .long sys_prctl | |
778 | .long sys_rt_sigreturn | |
779 | .long sys_rt_sigaction | |
780 | .long sys_rt_sigprocmask /* 175 */ | |
781 | .long sys_rt_sigpending | |
782 | .long sys_rt_sigtimedwait | |
783 | .long sys_rt_sigqueueinfo | |
784 | .long sys_rt_sigsuspend | |
785 | .long sys_pread64 /* 180 */ | |
786 | .long sys_pwrite64 | |
787 | .long sys_chown16 | |
788 | .long sys_getcwd | |
789 | .long sys_capget | |
790 | .long sys_capset /* 185 */ | |
791 | .long sys_sigaltstack | |
792 | .long sys_sendfile | |
793 | .long sys_ni_syscall /* streams1 */ | |
794 | .long sys_ni_syscall /* streams2 */ | |
795 | .long sys_vfork /* 190 */ | |
796 | .long sys_getrlimit | |
797 | .long sys_mmap2 | |
798 | .long sys_truncate64 | |
799 | .long sys_ftruncate64 | |
800 | .long sys_stat64 /* 195 */ | |
801 | .long sys_lstat64 | |
802 | .long sys_fstat64 | |
803 | .long sys_lchown | |
804 | .long sys_getuid | |
805 | .long sys_getgid /* 200 */ | |
806 | .long sys_geteuid | |
807 | .long sys_getegid | |
808 | .long sys_setreuid | |
809 | .long sys_setregid | |
810 | .long sys_getgroups /* 205 */ | |
811 | .long sys_setgroups | |
812 | .long sys_fchown | |
813 | .long sys_setresuid | |
814 | .long sys_getresuid | |
815 | .long sys_setresgid /* 210 */ | |
816 | .long sys_getresgid | |
817 | .long sys_chown | |
818 | .long sys_setuid | |
819 | .long sys_setgid | |
820 | .long sys_setfsuid /* 215 */ | |
821 | .long sys_setfsgid | |
822 | .long sys_pivot_root | |
823 | .long sys_mincore | |
824 | .long sys_madvise | |
825 | .long sys_getdents64 /* 220 */ | |
826 | .long sys_fcntl64 | |
827 | .long sys_ni_syscall /* reserved for TUX */ | |
828 | .long sys_ni_syscall | |
829 | .long sys_gettid | |
830 | .long sys_readahead /* 225 */ | |
831 | .long sys_setxattr | |
832 | .long sys_lsetxattr | |
833 | .long sys_fsetxattr | |
834 | .long sys_getxattr | |
835 | .long sys_lgetxattr /* 230 */ | |
836 | .long sys_fgetxattr | |
837 | .long sys_listxattr | |
838 | .long sys_llistxattr | |
839 | .long sys_flistxattr | |
840 | .long sys_removexattr /* 235 */ | |
841 | .long sys_lremovexattr | |
842 | .long sys_fremovexattr | |
843 | .long sys_tkill | |
844 | .long sys_sendfile64 | |
845 | .long sys_futex /* 240 */ | |
846 | .long sys_sched_setaffinity | |
847 | .long sys_sched_getaffinity | |
848 | .long sys_ni_syscall /* sys_set_thread_area */ | |
849 | .long sys_ni_syscall /* sys_get_thread_area */ | |
850 | .long sys_io_setup /* 245 */ | |
851 | .long sys_io_destroy | |
852 | .long sys_io_getevents | |
853 | .long sys_io_submit | |
854 | .long sys_io_cancel | |
855 | .long sys_fadvise64 /* 250 */ | |
856 | .long sys_ni_syscall | |
857 | .long sys_exit_group | |
858 | .long sys_lookup_dcookie | |
859 | .long sys_epoll_create | |
860 | .long sys_epoll_ctl /* 255 */ | |
861 | .long sys_epoll_wait | |
862 | .long sys_remap_file_pages | |
863 | .long sys_set_tid_address | |
864 | .long sys_timer_create | |
865 | .long sys_timer_settime /* 260 */ | |
866 | .long sys_timer_gettime | |
867 | .long sys_timer_getoverrun | |
868 | .long sys_timer_delete | |
869 | .long sys_clock_settime | |
870 | .long sys_clock_gettime /* 265 */ | |
871 | .long sys_clock_getres | |
872 | .long sys_clock_nanosleep | |
873 | .long sys_statfs64 | |
874 | .long sys_fstatfs64 | |
875 | .long sys_tgkill /* 270 */ | |
876 | .long sys_utimes | |
877 | .long sys_fadvise64_64 | |
878 | .long sys_ni_syscall /* sys_vserver */ | |
879 | .long sys_ni_syscall /* sys_mbind */ | |
880 | .long sys_ni_syscall /* 275 sys_get_mempolicy */ | |
881 | .long sys_ni_syscall /* sys_set_mempolicy */ | |
882 | .long sys_mq_open | |
883 | .long sys_mq_unlink | |
884 | .long sys_mq_timedsend | |
885 | .long sys_mq_timedreceive /* 280 */ | |
886 | .long sys_mq_notify | |
887 | .long sys_mq_getsetattr | |
888 | .long sys_ni_syscall /* reserved for kexec */ | |
889 | .long sys_waitid | |
7cf32cad MS |
890 | .long sys_ni_syscall /* 285 */ /* available */ |
891 | .long sys_add_key | |
892 | .long sys_request_key | |
893 | .long sys_keyctl | |
0c3537ff JN |
894 | .long sys_ioprio_set |
895 | .long sys_ioprio_get /* 290 */ | |
896 | .long sys_inotify_init | |
897 | .long sys_inotify_add_watch | |
898 | .long sys_inotify_rm_watch | |
899 | .long sys_migrate_pages | |
900 | .long sys_openat /* 295 */ | |
901 | .long sys_mkdirat | |
902 | .long sys_mknodat | |
903 | .long sys_fchownat | |
904 | .long sys_futimesat | |
905 | .long sys_fstatat64 /* 300 */ | |
906 | .long sys_unlinkat | |
907 | .long sys_renameat | |
908 | .long sys_linkat | |
909 | .long sys_symlinkat | |
910 | .long sys_readlinkat /* 305 */ | |
911 | .long sys_fchmodat | |
912 | .long sys_faccessat | |
913 | .long sys_pselect6 | |
914 | .long sys_ppoll | |
915 | .long sys_unshare /* 310 */ | |
916 | .long sys_set_robust_list | |
917 | .long sys_get_robust_list | |
918 | .long sys_splice | |
919 | .long sys_sync_file_range | |
920 | .long sys_tee /* 315 */ | |
921 | .long sys_vmsplice | |
922 | .long sys_move_pages | |
923 | .long sys_getcpu | |
924 | .long sys_epoll_pwait | |
925 | .long sys_utimensat /* 320 */ | |
926 | .long sys_signalfd | |
7800029d | 927 | .long sys_timerfd_create |
0c3537ff JN |
928 | .long sys_eventfd |
929 | .long sys_fallocate | |
7800029d JN |
930 | .long sys_timerfd_settime /* 325 */ |
931 | .long sys_timerfd_gettime | |
6d3d4be4 JN |
932 | .long sys_signalfd4 |
933 | .long sys_eventfd2 | |
934 | .long sys_epoll_create1 | |
935 | .long sys_dup3 /* 330 */ | |
936 | .long sys_pipe2 | |
937 | .long sys_inotify_init1 | |
938 | .long sys_preadv | |
939 | .long sys_pwritev | |
1da177e4 LT |
940 | |
941 | /* | |
942 | * NOTE!! This doesn't have to be exact - we just have | |
943 | * to make sure we have _enough_ of the "sys_ni_syscall" | |
944 | * entries. Don't panic if you notice that this hasn't | |
945 | * been shrunk every time we add a new system call. | |
946 | */ | |
947 | ||
948 | .rept NR_syscalls-(.-sys_call_table)/4 | |
949 | .long sys_ni_syscall | |
950 | .endr | |
951 |