Blackfin: use generic name for EVT14 handler
[safe/jmp/linux-2.6] / arch / blackfin / mach-common / entry.S
1 /*
2  * File:         arch/blackfin/mach-common/entry.S
3  * Based on:
4  * Author:       Linus Torvalds
5  *
6  * Created:      ?
7  * Description:  contains the system-call and fault low-level handling routines.
8  *               This also contains the timer-interrupt handler, as well as all
9  *               interrupts and faults that can result in a task-switch.
10  *
11  * Modified:
12  *               Copyright 2004-2006 Analog Devices Inc.
13  *
14  * Bugs:         Enter bugs at http://blackfin.uclinux.org/
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 2 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, see the file COPYING, or write
28  * to the Free Software Foundation, Inc.,
29  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
30  */
31
32 /* NOTE: This code handles signal-recognition, which happens every time
33  * after a timer-interrupt and after each system call.
34  */
35
36 #include <linux/init.h>
37 #include <linux/linkage.h>
38 #include <linux/unistd.h>
39 #include <asm/blackfin.h>
40 #include <asm/errno.h>
41 #include <asm/fixed_code.h>
42 #include <asm/thread_info.h>  /* TIF_NEED_RESCHED */
43 #include <asm/asm-offsets.h>
44 #include <asm/trace.h>
45 #include <asm/traps.h>
46
47 #include <asm/context.S>
48
49 #if defined(CONFIG_BFIN_SCRATCH_REG_RETN)
50 # define EX_SCRATCH_REG RETN
51 #elif defined(CONFIG_BFIN_SCRATCH_REG_RETE)
52 # define EX_SCRATCH_REG RETE
53 #else
54 # define EX_SCRATCH_REG CYCLES
55 #endif
56
57 #ifdef CONFIG_EXCPT_IRQ_SYSC_L1
58 .section .l1.text
59 #else
60 .text
61 #endif
62
63 /* Slightly simplified and streamlined entry point for CPLB misses.
64  * This one does not lower the level to IRQ5, and thus can be used to
65  * patch up CPLB misses on the kernel stack.
66  */
67 #if ANOMALY_05000261
68 #define _ex_dviol _ex_workaround_261
69 #define _ex_dmiss _ex_workaround_261
70 #define _ex_dmult _ex_workaround_261
71
72 ENTRY(_ex_workaround_261)
73         /*
74          * Work around an anomaly: if we see a new DCPLB fault, return
75          * without doing anything.  Then, if we get the same fault again,
76          * handle it.
77          */
78         P4 = R7;        /* Store EXCAUSE */
79
80         GET_PDA(p5, r7);
81         r7 = [p5 + PDA_LFRETX];
82         r6 = retx;
83         [p5 + PDA_LFRETX] = r6;
84         cc = r6 == r7;
85         if !cc jump _bfin_return_from_exception;
86         /* fall through */
87         R7 = P4;
88         R6 = VEC_CPLB_M;        /* Data CPLB Miss */
89         cc = R6 == R7;
90         if cc jump _ex_dcplb_miss (BP);
91 #ifdef CONFIG_MPU
92         R6 = VEC_CPLB_VL;       /* Data CPLB Violation */
93         cc = R6 == R7;
94         if cc jump _ex_dcplb_viol (BP);
95 #endif
96         /* Handle Data CPLB Protection Violation
97          * and Data CPLB Multiple Hits - Linux Trap Zero
98          */
99         jump _ex_trap_c;
100 ENDPROC(_ex_workaround_261)
101
102 #else
103 #ifdef CONFIG_MPU
104 #define _ex_dviol _ex_dcplb_viol
105 #else
106 #define _ex_dviol _ex_trap_c
107 #endif
108 #define _ex_dmiss _ex_dcplb_miss
109 #define _ex_dmult _ex_trap_c
110 #endif
111
112
113 ENTRY(_ex_dcplb_viol)
114 ENTRY(_ex_dcplb_miss)
115 ENTRY(_ex_icplb_miss)
116         (R7:6,P5:4) = [sp++];
117         /* We leave the previously pushed ASTAT on the stack.  */
118         SAVE_CONTEXT_CPLB
119
120         /* We must load R1 here, _before_ DEBUG_HWTRACE_SAVE, since that
121          * will change the stack pointer.  */
122         R0 = SEQSTAT;
123         R1 = SP;
124
125         DEBUG_HWTRACE_SAVE(p5, r7)
126
127         sp += -12;
128         call _cplb_hdr;
129         sp += 12;
130         CC = R0 == 0;
131         IF !CC JUMP _handle_bad_cplb;
132
133 #ifdef CONFIG_DEBUG_DOUBLEFAULT
134         /* While we were processing this, did we double fault? */
135         r7 = SEQSTAT;           /* reason code is in bit 5:0 */
136         r6.l = lo(SEQSTAT_EXCAUSE);
137         r6.h = hi(SEQSTAT_EXCAUSE);
138         r7 = r7 & r6;
139         r6 = 0x25;
140         CC = R7 == R6;
141         if CC JUMP _double_fault;
142 #endif
143
144         DEBUG_HWTRACE_RESTORE(p5, r7)
145         RESTORE_CONTEXT_CPLB
146         ASTAT = [SP++];
147         SP = EX_SCRATCH_REG;
148         rtx;
149 ENDPROC(_ex_icplb_miss)
150
151 ENTRY(_ex_syscall)
152         raise 15;               /* invoked by TRAP #0, for sys call */
153         jump.s _bfin_return_from_exception;
154 ENDPROC(_ex_syscall)
155
156 ENTRY(_ex_single_step)
157         /* If we just returned from an interrupt, the single step event is
158            for the RTI instruction.  */
159         r7 = retx;
160         r6 = reti;
161         cc = r7 == r6;
162         if cc jump _bfin_return_from_exception;
163
164 #ifdef CONFIG_KGDB
165         /* Don't do single step in hardware exception handler */
166         p5.l = lo(IPEND);
167         p5.h = hi(IPEND);
168         r6 = [p5];
169         cc = bittst(r6, 4);
170         if cc jump _bfin_return_from_exception;
171         cc = bittst(r6, 5);
172         if cc jump _bfin_return_from_exception;
173
174         /* skip single step if current interrupt priority is higher than
175          * that of the first instruction, from which gdb starts single step */
176         r6 >>= 6;
177         r7 = 10;
178 .Lfind_priority_start:
179         cc = bittst(r6, 0);
180         if cc jump .Lfind_priority_done;
181         r6 >>= 1;
182         r7 += -1;
183         cc = r7 == 0;
184         if cc jump .Lfind_priority_done;
185         jump.s .Lfind_priority_start;
186 .Lfind_priority_done:
187         p4.l = _kgdb_single_step;
188         p4.h = _kgdb_single_step;
189         r6 = [p4];
190         cc = r6 == 0;
191         if cc jump .Ldo_single_step;
192         r6 += -1;
193         cc = r6 < r7;
194         if cc jump 1f;
195 .Ldo_single_step:
196 #else
197         /* If we were in user mode, do the single step normally.  */
198         p5.l = lo(IPEND);
199         p5.h = hi(IPEND);
200         r6 = [p5];
201         r7 = 0xffe0 (z);
202         r7 = r7 & r6;
203         cc = r7 == 0;
204         if !cc jump 1f;
205 #endif
206 #ifdef CONFIG_EXACT_HWERR
207         /* Read the ILAT, and to check to see if the process we are
208          * single stepping caused a previous hardware error
209          * If so, do not single step, (which lowers to IRQ5, and makes
210          * us miss the error).
211          */
212         p5.l = lo(ILAT);
213         p5.h = hi(ILAT);
214         r7 = [p5];
215         cc = bittst(r7, EVT_IVHW_P);
216         if cc jump 1f;
217 #endif
218         /* Single stepping only a single instruction, so clear the trace
219          * bit here.  */
220         r7 = syscfg;
221         bitclr (r7, SYSCFG_SSSTEP_P);
222         syscfg = R7;
223         jump _ex_trap_c;
224
225 1:
226         /*
227          * We were in an interrupt handler.  By convention, all of them save
228          * SYSCFG with their first instruction, so by checking whether our
229          * RETX points at the entry point, we can determine whether to allow
230          * a single step, or whether to clear SYSCFG.
231          *
232          * First, find out the interrupt level and the event vector for it.
233          */
234         p5.l = lo(EVT0);
235         p5.h = hi(EVT0);
236         p5 += -4;
237 2:
238         r7 = rot r7 by -1;
239         p5 += 4;
240         if !cc jump 2b;
241
242         /* What we actually do is test for the _second_ instruction in the
243          * IRQ handler.  That way, if there are insns following the restore
244          * of SYSCFG after leaving the handler, we will not turn off SYSCFG
245          * for them.  */
246
247         r7 = [p5];
248         r7 += 2;
249         r6 = RETX;
250         cc = R7 == R6;
251         if !cc jump _bfin_return_from_exception;
252
253         r7 = syscfg;
254         bitclr (r7, SYSCFG_SSSTEP_P);   /* Turn off single step */
255         syscfg = R7;
256
257         /* Fall through to _bfin_return_from_exception.  */
258 ENDPROC(_ex_single_step)
259
260 ENTRY(_bfin_return_from_exception)
261 #if ANOMALY_05000257
262         R7=LC0;
263         LC0=R7;
264         R7=LC1;
265         LC1=R7;
266 #endif
267
268 #ifdef CONFIG_DEBUG_DOUBLEFAULT
269         /* While we were processing the current exception,
270          * did we cause another, and double fault?
271          */
272         r7 = SEQSTAT;           /* reason code is in bit 5:0 */
273         r6.l = lo(SEQSTAT_EXCAUSE);
274         r6.h = hi(SEQSTAT_EXCAUSE);
275         r7 = r7 & r6;
276         r6 = VEC_UNCOV;
277         CC = R7 == R6;
278         if CC JUMP _double_fault;
279 #endif
280
281         (R7:6,P5:4) = [sp++];
282         ASTAT = [sp++];
283         sp = EX_SCRATCH_REG;
284         rtx;
285 ENDPROC(_bfin_return_from_exception)
286
287 ENTRY(_handle_bad_cplb)
288         DEBUG_HWTRACE_RESTORE(p5, r7)
289         /* To get here, we just tried and failed to change a CPLB
290          * so, handle things in trap_c (C code), by lowering to
291          * IRQ5, just like we normally do. Since this is not a
292          * "normal" return path, we have a do alot of stuff to
293          * the stack to get ready so, we can fall through - we
294          * need to make a CPLB exception look like a normal exception
295          */
296         RESTORE_CONTEXT_CPLB
297         /* ASTAT is still on the stack, where it is needed.  */
298         [--sp] = (R7:6,P5:4);
299
300 ENTRY(_ex_replaceable)
301         nop;
302
303 ENTRY(_ex_trap_c)
304         /* The only thing that has been saved in this context is
305          * (R7:6,P5:4), ASTAT & SP - don't use anything else
306          */
307
308         GET_PDA(p5, r6);
309
310         /* Make sure we are not in a double fault */
311         p4.l = lo(IPEND);
312         p4.h = hi(IPEND);
313         r7 = [p4];
314         CC = BITTST (r7, 5);
315         if CC jump _double_fault;
316         [p5 + PDA_EXIPEND] = r7;
317
318         /* Call C code (trap_c) to handle the exception, which most
319          * likely involves sending a signal to the current process.
320          * To avoid double faults, lower our priority to IRQ5 first.
321          */
322         r7.h = _exception_to_level5;
323         r7.l = _exception_to_level5;
324         p4.l = lo(EVT5);
325         p4.h = hi(EVT5);
326         [p4] = r7;
327         csync;
328
329 #ifndef CONFIG_DEBUG_DOUBLEFAULT
330
331         /*
332          * Save these registers, as they are only valid in exception context
333          *  (where we are now - as soon as we defer to IRQ5, they can change)
334          * DCPLB_STATUS and ICPLB_STATUS are also only valid in EVT3,
335          * but they are not very interesting, so don't save them
336          */
337
338         p4.l = lo(DCPLB_FAULT_ADDR);
339         p4.h = hi(DCPLB_FAULT_ADDR);
340         r7 = [p4];
341         [p5 + PDA_DCPLB] = r7;
342
343         p4.l = lo(ICPLB_FAULT_ADDR);
344         p4.h = hi(ICPLB_FAULT_ADDR);
345         r6 = [p4];
346         [p5 + PDA_ICPLB] = r6;
347
348         r6 = retx;
349         [p5 + PDA_RETX] = r6;
350 #endif
351         /* Save the state of single stepping */
352         r6 = SYSCFG;
353         [p5 + PDA_SYSCFG] = r6;
354         /* Clear it while we handle the exception in IRQ5 mode */
355         BITCLR(r6, SYSCFG_SSSTEP_P);
356         SYSCFG = r6;
357
358         /* Save the current IMASK, since we change in order to jump to level 5 */
359         cli r6;
360         [p5 + PDA_EXIMASK] = r6;
361
362         p4.l = lo(SAFE_USER_INSTRUCTION);
363         p4.h = hi(SAFE_USER_INSTRUCTION);
364         retx = p4;
365
366         /* Disable all interrupts, but make sure level 5 is enabled so
367          * we can switch to that level.
368          */
369         r6 = 0x3f;
370         sti r6;
371
372         /* In case interrupts are disabled IPEND[4] (global interrupt disable bit)
373          * clear it (re-enabling interrupts again) by the special sequence of pushing
374          * RETI onto the stack.  This way we can lower ourselves to IVG5 even if the
375          * exception was taken after the interrupt handler was called but before it
376          * got a chance to enable global interrupts itself.
377          */
378         [--sp] = reti;
379         sp += 4;
380
381         raise 5;
382         jump.s _bfin_return_from_exception;
383 ENDPROC(_ex_trap_c)
384
385 /* We just realized we got an exception, while we were processing a different
386  * exception. This is a unrecoverable event, so crash.
387  * Note: this cannot be ENTRY() as we jump here with "if cc jump" ...
388  */
389 ENTRY(_double_fault)
390         /* Turn caches & protection off, to ensure we don't get any more
391          * double exceptions
392          */
393
394         P4.L = LO(IMEM_CONTROL);
395         P4.H = HI(IMEM_CONTROL);
396
397         R5 = [P4];              /* Control Register*/
398         BITCLR(R5,ENICPLB_P);
399         SSYNC;          /* SSYNC required before writing to IMEM_CONTROL. */
400         .align 8;
401         [P4] = R5;
402         SSYNC;
403
404         P4.L = LO(DMEM_CONTROL);
405         P4.H = HI(DMEM_CONTROL);
406         R5 = [P4];
407         BITCLR(R5,ENDCPLB_P);
408         SSYNC;          /* SSYNC required before writing to DMEM_CONTROL. */
409         .align 8;
410         [P4] = R5;
411         SSYNC;
412
413         /* Fix up the stack */
414         (R7:6,P5:4) = [sp++];
415         ASTAT = [sp++];
416         SP = EX_SCRATCH_REG;
417
418         /* We should be out of the exception stack, and back down into
419          * kernel or user space stack
420          */
421         SAVE_ALL_SYS
422
423         /* The dumping functions expect the return address in the RETI
424          * slot.  */
425         r6 = retx;
426         [sp + PT_PC] = r6;
427
428         r0 = sp;        /* stack frame pt_regs pointer argument ==> r0 */
429         SP += -12;
430         call _double_fault_c;
431         SP += 12;
432 .L_double_fault_panic:
433         JUMP .L_double_fault_panic
434
435 ENDPROC(_double_fault)
436
437 ENTRY(_exception_to_level5)
438         SAVE_ALL_SYS
439
440         GET_PDA(p5, r7);        /* Fetch current PDA */
441         r6 = [p5 + PDA_RETX];
442         [sp + PT_PC] = r6;
443
444         r6 = [p5 + PDA_SYSCFG];
445         [sp + PT_SYSCFG] = r6;
446
447         /* Restore the hardware error vector.  */
448         r7.h = _evt_ivhw;
449         r7.l = _evt_ivhw;
450         p4.l = lo(EVT5);
451         p4.h = hi(EVT5);
452         [p4] = r7;
453         csync;
454
455 #ifdef CONFIG_DEBUG_DOUBLEFAULT
456         /* Now that we have the hardware error vector programmed properly
457          * we can re-enable interrupts (IPEND[4]), so if the _trap_c causes
458          * another hardware error, we can catch it (self-nesting).
459          */
460         [--sp] = reti;
461         sp += 4;
462 #endif
463
464         r7 = [p5 + PDA_EXIPEND] /* Read the IPEND from the Exception state */
465         [sp + PT_IPEND] = r7;   /* Store IPEND onto the stack */
466
467         r0 = sp;        /* stack frame pt_regs pointer argument ==> r0 */
468         SP += -12;
469         call _trap_c;
470         SP += 12;
471
472         /* If interrupts were off during the exception (IPEND[4] = 1), turn them off
473          * before we return.
474          */
475         CC = BITTST(r7, EVT_IRPTEN_P)
476         if !CC jump 1f;
477         /* this will load a random value into the reti register - but that is OK,
478          * since we do restore it to the correct value in the 'RESTORE_ALL_SYS' macro
479          */
480         sp += -4;
481         reti = [sp++];
482 1:
483         /* restore the interrupt mask (IMASK) */
484         r6 = [p5 + PDA_EXIMASK];
485         sti r6;
486
487         call _ret_from_exception;
488         RESTORE_ALL_SYS
489         rti;
490 ENDPROC(_exception_to_level5)
491
492 ENTRY(_trap) /* Exception: 4th entry into system event table(supervisor mode)*/
493         /* Since the kernel stack can be anywhere, it's not guaranteed to be
494          * covered by a CPLB.  Switch to an exception stack; use RETN as a
495          * scratch register (for want of a better option).
496          */
497         EX_SCRATCH_REG = sp;
498         GET_PDA_SAFE(sp);
499         sp = [sp + PDA_EXSTACK]
500         /* Try to deal with syscalls quickly.  */
501         [--sp] = ASTAT;
502         [--sp] = (R7:6,P5:4);
503
504 #ifdef CONFIG_EXACT_HWERR
505         /* Make sure all pending read/writes complete. This will ensure any
506          * accesses which could cause hardware errors completes, and signal
507          * the the hardware before we do something silly, like crash the
508          * kernel. We don't need to work around anomaly 05000312, since
509          * we are already atomic
510          */
511         ssync;
512 #endif
513
514 #if ANOMALY_05000283 || ANOMALY_05000315
515         cc = r7 == r7;
516         p5.h = HI(CHIPID);
517         p5.l = LO(CHIPID);
518         if cc jump 1f;
519         r7.l = W[p5];
520 1:
521 #endif
522
523 #ifdef CONFIG_DEBUG_DOUBLEFAULT
524         /*
525          * Save these registers, as they are only valid in exception context
526          * (where we are now - as soon as we defer to IRQ5, they can change)
527          * DCPLB_STATUS and ICPLB_STATUS are also only valid in EVT3,
528          * but they are not very interesting, so don't save them
529          */
530
531         GET_PDA(p5, r7);
532         p4.l = lo(DCPLB_FAULT_ADDR);
533         p4.h = hi(DCPLB_FAULT_ADDR);
534         r7 = [p4];
535         [p5 + PDA_DCPLB] = r7;
536
537         p4.l = lo(ICPLB_FAULT_ADDR);
538         p4.h = hi(ICPLB_FAULT_ADDR);
539         r7 = [p4];
540         [p5 + PDA_ICPLB] = r7;
541
542         r6 = retx;
543         [p5 + PDA_RETX] = r6;
544
545         r7 = SEQSTAT;           /* reason code is in bit 5:0 */
546         [p5 + PDA_SEQSTAT] = r7;
547 #else
548         r7 = SEQSTAT;           /* reason code is in bit 5:0 */
549 #endif
550         r6.l = lo(SEQSTAT_EXCAUSE);
551         r6.h = hi(SEQSTAT_EXCAUSE);
552         r7 = r7 & r6;
553         p5.h = _ex_table;
554         p5.l = _ex_table;
555         p4 = r7;
556         p5 = p5 + (p4 << 2);
557         p4 = [p5];
558         jump (p4);
559
560 .Lbadsys:
561         r7 = -ENOSYS;           /* signextending enough */
562         [sp + PT_R0] = r7;      /* return value from system call */
563         jump .Lsyscall_really_exit;
564 ENDPROC(_trap)
565
566 ENTRY(_kernel_execve)
567         link SIZEOF_PTREGS;
568         p0 = sp;
569         r3 = SIZEOF_PTREGS / 4;
570         r4 = 0(x);
571 .Lclear_regs:
572         [p0++] = r4;
573         r3 += -1;
574         cc = r3 == 0;
575         if !cc jump .Lclear_regs (bp);
576
577         p0 = sp;
578         sp += -16;
579         [sp + 12] = p0;
580         call _do_execve;
581         SP += 16;
582         cc = r0 == 0;
583         if ! cc jump .Lexecve_failed;
584         /* Success.  Copy our temporary pt_regs to the top of the kernel
585          * stack and do a normal exception return.
586          */
587         r1 = sp;
588         r0 = (-KERNEL_STACK_SIZE) (x);
589         r1 = r1 & r0;
590         p2 = r1;
591         p3 = [p2];
592         r0 = KERNEL_STACK_SIZE - 4 (z);
593         p1 = r0;
594         p1 = p1 + p2;
595
596         p0 = fp;
597         r4 = [p0--];
598         r3 = SIZEOF_PTREGS / 4;
599 .Lcopy_regs:
600         r4 = [p0--];
601         [p1--] = r4;
602         r3 += -1;
603         cc = r3 == 0;
604         if ! cc jump .Lcopy_regs (bp);
605
606         r0 = (KERNEL_STACK_SIZE - SIZEOF_PTREGS) (z);
607         p1 = r0;
608         p1 = p1 + p2;
609         sp = p1;
610         r0 = syscfg;
611         [SP + PT_SYSCFG] = r0;
612         [p3 + (TASK_THREAD + THREAD_KSP)] = sp;
613
614         RESTORE_CONTEXT;
615         rti;
616 .Lexecve_failed:
617         unlink;
618         rts;
619 ENDPROC(_kernel_execve)
620
621 ENTRY(_system_call)
622         /* Store IPEND */
623         p2.l = lo(IPEND);
624         p2.h = hi(IPEND);
625         csync;
626         r0 = [p2];
627         [sp + PT_IPEND] = r0;
628
629         /* Store RETS for now */
630         r0 = rets;
631         [sp + PT_RESERVED] = r0;
632         /* Set the stack for the current process */
633         r7 = sp;
634         r6.l = lo(ALIGN_PAGE_MASK);
635         r6.h = hi(ALIGN_PAGE_MASK);
636         r7 = r7 & r6;           /* thread_info */
637         p2 = r7;
638         p2 = [p2];
639
640         [p2+(TASK_THREAD+THREAD_KSP)] = sp;
641 #ifdef CONFIG_IPIPE
642         r0 = sp;
643         SP += -12;
644         call ___ipipe_syscall_root;
645         SP += 12;
646         cc = r0 == 1;
647         if cc jump .Lsyscall_really_exit;
648         cc = r0 == -1;
649         if cc jump .Lresume_userspace;
650         r3 = [sp + PT_R3];
651         r4 = [sp + PT_R4];
652         p0 = [sp + PT_ORIG_P0];
653 #endif /* CONFIG_IPIPE */
654
655         /* Check the System Call */
656         r7 = __NR_syscall;
657         /* System call number is passed in P0 */
658         r6 = p0;
659         cc = r6 < r7;
660         if ! cc jump .Lbadsys;
661
662         /* are we tracing syscalls?*/
663         r7 = sp;
664         r6.l = lo(ALIGN_PAGE_MASK);
665         r6.h = hi(ALIGN_PAGE_MASK);
666         r7 = r7 & r6;
667         p2 = r7;
668         r7 = [p2+TI_FLAGS];
669         CC = BITTST(r7,TIF_SYSCALL_TRACE);
670         if CC JUMP _sys_trace;
671
672         /* Execute the appropriate system call */
673
674         p4 = p0;
675         p5.l = _sys_call_table;
676         p5.h = _sys_call_table;
677         p5 = p5 + (p4 << 2);
678         r0 = [sp + PT_R0];
679         r1 = [sp + PT_R1];
680         r2 = [sp + PT_R2];
681         p5 = [p5];
682
683         [--sp] = r5;
684         [--sp] = r4;
685         [--sp] = r3;
686         SP += -12;
687         call (p5);
688         SP += 24;
689         [sp + PT_R0] = r0;
690
691 .Lresume_userspace:
692         r7 = sp;
693         r4.l = lo(ALIGN_PAGE_MASK);
694         r4.h = hi(ALIGN_PAGE_MASK);
695         r7 = r7 & r4;           /* thread_info->flags */
696         p5 = r7;
697 .Lresume_userspace_1:
698         /* Disable interrupts.  */
699         [--sp] = reti;
700         reti = [sp++];
701
702         r7 = [p5 + TI_FLAGS];
703         r4.l = lo(_TIF_WORK_MASK);
704         r4.h = hi(_TIF_WORK_MASK);
705         r7 =  r7 & r4;
706
707 .Lsyscall_resched:
708 #ifdef CONFIG_IPIPE
709         cc = BITTST(r7, TIF_IRQ_SYNC);
710         if !cc jump .Lsyscall_no_irqsync;
711         [--sp] = reti;
712         r0 = [sp++];
713         SP += -12;
714         call ___ipipe_sync_root;
715         SP += 12;
716         jump .Lresume_userspace_1;
717 .Lsyscall_no_irqsync:
718 #endif
719         cc = BITTST(r7, TIF_NEED_RESCHED);
720         if !cc jump .Lsyscall_sigpending;
721
722         /* Reenable interrupts.  */
723         [--sp] = reti;
724         r0 = [sp++];
725
726         SP += -12;
727         call _schedule;
728         SP += 12;
729
730         jump .Lresume_userspace_1;
731
732 .Lsyscall_sigpending:
733         cc = BITTST(r7, TIF_RESTORE_SIGMASK);
734         if cc jump .Lsyscall_do_signals;
735         cc = BITTST(r7, TIF_SIGPENDING);
736         if !cc jump .Lsyscall_really_exit;
737 .Lsyscall_do_signals:
738         /* Reenable interrupts.  */
739         [--sp] = reti;
740         r0 = [sp++];
741
742         r0 = sp;
743         SP += -12;
744         call _do_signal;
745         SP += 12;
746
747 .Lsyscall_really_exit:
748         r5 = [sp + PT_RESERVED];
749         rets = r5;
750 #ifdef CONFIG_IPIPE
751         [--sp] = reti;
752         r5 = [sp++];
753 #endif /* CONFIG_IPIPE */
754         rts;
755 ENDPROC(_system_call)
756
757 /* Do not mark as ENTRY() to avoid error in assembler ...
758  * this symbol need not be global anyways, so ...
759  */
760 _sys_trace:
761         call _syscall_trace;
762
763         /* Execute the appropriate system call */
764
765         p4 = [SP + PT_P0];
766         p5.l = _sys_call_table;
767         p5.h = _sys_call_table;
768         p5 = p5 + (p4 << 2);
769         r0 = [sp + PT_R0];
770         r1 = [sp + PT_R1];
771         r2 = [sp + PT_R2];
772         r3 = [sp + PT_R3];
773         r4 = [sp + PT_R4];
774         r5 = [sp + PT_R5];
775         p5 = [p5];
776
777         [--sp] = r5;
778         [--sp] = r4;
779         [--sp] = r3;
780         SP += -12;
781         call (p5);
782         SP += 24;
783         [sp + PT_R0] = r0;
784
785         call _syscall_trace;
786         jump .Lresume_userspace;
787 ENDPROC(_sys_trace)
788
789 ENTRY(_resume)
790         /*
791          * Beware - when entering resume, prev (the current task) is
792          * in r0, next (the new task) is in r1.
793          */
794         p0 = r0;
795         p1 = r1;
796         [--sp] = rets;
797         [--sp] = fp;
798         [--sp] = (r7:4, p5:3);
799
800         /* save usp */
801         p2 = usp;
802         [p0+(TASK_THREAD+THREAD_USP)] = p2;
803
804         /* save current kernel stack pointer */
805         [p0+(TASK_THREAD+THREAD_KSP)] = sp;
806
807         /* save program counter */
808         r1.l = _new_old_task;
809         r1.h = _new_old_task;
810         [p0+(TASK_THREAD+THREAD_PC)] = r1;
811
812         /* restore the kernel stack pointer */
813         sp = [p1+(TASK_THREAD+THREAD_KSP)];
814
815         /* restore user stack pointer */
816         p0 = [p1+(TASK_THREAD+THREAD_USP)];
817         usp = p0;
818
819         /* restore pc */
820         p0 = [p1+(TASK_THREAD+THREAD_PC)];
821         jump (p0);
822
823         /*
824          * Following code actually lands up in a new (old) task.
825          */
826
827 _new_old_task:
828         (r7:4, p5:3) = [sp++];
829         fp = [sp++];
830         rets = [sp++];
831
832         /*
833          * When we come out of resume, r0 carries "old" task, becuase we are
834          * in "new" task.
835          */
836         rts;
837 ENDPROC(_resume)
838
839 ENTRY(_ret_from_exception)
840 #ifdef CONFIG_IPIPE
841         [--sp] = rets;
842         SP += -12;
843         call ___ipipe_check_root
844         SP += 12
845         rets = [sp++];
846         cc = r0 == 0;
847         if cc jump 4f;                /* not on behalf of Linux, get out */
848 #endif /* CONFIG_IPIPE */
849         p2.l = lo(IPEND);
850         p2.h = hi(IPEND);
851
852         csync;
853         r0 = [p2];
854         [sp + PT_IPEND] = r0;
855
856 1:
857         r2 = LO(~0x37) (Z);
858         r0 = r2 & r0;
859         cc = r0 == 0;
860         if !cc jump 4f; /* if not return to user mode, get out */
861
862         /* Make sure any pending system call or deferred exception
863          * return in ILAT for this process to get executed, otherwise
864          * in case context switch happens, system call of
865          * first process (i.e in ILAT) will be carried
866          * forward to the switched process
867          */
868
869         p2.l = lo(ILAT);
870         p2.h = hi(ILAT);
871         r0 = [p2];
872         r1 = (EVT_IVG14 | EVT_IVG15) (z);
873         r0 = r0 & r1;
874         cc = r0 == 0;
875         if !cc jump 5f;
876
877         /* Set the stack for the current process */
878         r7 = sp;
879         r4.l = lo(ALIGN_PAGE_MASK);
880         r4.h = hi(ALIGN_PAGE_MASK);
881         r7 = r7 & r4;           /* thread_info->flags */
882         p5 = r7;
883         r7 = [p5 + TI_FLAGS];
884         r4.l = lo(_TIF_WORK_MASK);
885         r4.h = hi(_TIF_WORK_MASK);
886         r7 =  r7 & r4;
887         cc = r7 == 0;
888         if cc jump 4f;
889
890         p0.l = lo(EVT15);
891         p0.h = hi(EVT15);
892         p1.l = _schedule_and_signal;
893         p1.h = _schedule_and_signal;
894         [p0] = p1;
895         csync;
896         raise 15;               /* raise evt15 to do signal or reschedule */
897 4:
898         r0 = syscfg;
899         bitclr(r0, SYSCFG_SSSTEP_P);            /* Turn off single step */
900         syscfg = r0;
901 5:
902         rts;
903 ENDPROC(_ret_from_exception)
904
905 #ifdef CONFIG_IPIPE
906
907 _sync_root_irqs:
908         [--sp] = reti;          /* Reenable interrupts */
909         r0 = [sp++];
910         jump.l ___ipipe_sync_root
911
912 _resume_kernel_from_int:
913         r0.l = _sync_root_irqs
914         r0.h = _sync_root_irqs
915         [--sp] = rets;
916         [--sp] = ( r7:4, p5:3 );
917         SP += -12;
918         call ___ipipe_call_irqtail
919         SP += 12;
920         ( r7:4, p5:3 ) = [sp++];
921         rets = [sp++];
922         rts
923 #else
924 #define _resume_kernel_from_int  2f
925 #endif
926
927 ENTRY(_return_from_int)
928         /* If someone else already raised IRQ 15, do nothing.  */
929         csync;
930         p2.l = lo(ILAT);
931         p2.h = hi(ILAT);
932         r0 = [p2];
933         cc = bittst (r0, EVT_IVG15_P);
934         if cc jump 2f;
935
936         /* if not return to user mode, get out */
937         p2.l = lo(IPEND);
938         p2.h = hi(IPEND);
939         r0 = [p2];
940         r1 = 0x17(Z);
941         r2 = ~r1;
942         r2.h = 0;
943         r0 = r2 & r0;
944         r1 = 1;
945         r1 = r0 - r1;
946         r2 = r0 & r1;
947         cc = r2 == 0;
948         if !cc jump _resume_kernel_from_int;
949
950         /* Lower the interrupt level to 15.  */
951         p0.l = lo(EVT15);
952         p0.h = hi(EVT15);
953         p1.l = _schedule_and_signal_from_int;
954         p1.h = _schedule_and_signal_from_int;
955         [p0] = p1;
956         csync;
957 #if ANOMALY_05000281 || ANOMALY_05000461
958         r0.l = lo(SAFE_USER_INSTRUCTION);
959         r0.h = hi(SAFE_USER_INSTRUCTION);
960         reti = r0;
961 #endif
962         r0 = 0x801f (z);
963         STI r0;
964         raise 15;       /* raise evt15 to do signal or reschedule */
965         rti;
966 2:
967         rts;
968 ENDPROC(_return_from_int)
969
970 ENTRY(_lower_to_irq14)
971 #if ANOMALY_05000281 || ANOMALY_05000461
972         r0.l = lo(SAFE_USER_INSTRUCTION);
973         r0.h = hi(SAFE_USER_INSTRUCTION);
974         reti = r0;
975 #endif
976
977 #ifdef CONFIG_DEBUG_HWERR
978         /* enable irq14 & hwerr interrupt, until we transition to _evt_evt14 */
979         r0 = (EVT_IVG14 | EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
980 #else
981         /* Only enable irq14 interrupt, until we transition to _evt_evt14 */
982         r0 = (EVT_IVG14 | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
983 #endif
984         sti r0;
985         raise 14;
986         rti;
987 ENDPROC(_lower_to_irq14)
988
989 ENTRY(_evt_evt14)
990 #ifdef CONFIG_DEBUG_HWERR
991         r0 = (EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
992         sti r0;
993 #else
994         cli r0;
995 #endif
996         [--sp] = RETI;
997         SP += 4;
998         rts;
999 ENDPROC(_evt_evt14)
1000
1001 ENTRY(_schedule_and_signal_from_int)
1002         /* To end up here, vector 15 was changed - so we have to change it
1003          * back.
1004          */
1005         p0.l = lo(EVT15);
1006         p0.h = hi(EVT15);
1007         p1.l = _evt_system_call;
1008         p1.h = _evt_system_call;
1009         [p0] = p1;
1010         csync;
1011
1012         /* Set orig_p0 to -1 to indicate this isn't the end of a syscall.  */
1013         r0 = -1 (x);
1014         [sp + PT_ORIG_P0] = r0;
1015
1016         p1 = rets;
1017         [sp + PT_RESERVED] = p1;
1018
1019 #ifdef CONFIG_SMP
1020         GET_PDA(p0, r0);        /* Fetch current PDA (can't migrate to other CPU here) */
1021         r0 = [p0 + PDA_IRQFLAGS];
1022 #else
1023         p0.l = _bfin_irq_flags;
1024         p0.h = _bfin_irq_flags;
1025         r0 = [p0];
1026 #endif
1027         sti r0;
1028
1029         r0 = sp;
1030         sp += -12;
1031         call _finish_atomic_sections;
1032         sp += 12;
1033         jump.s .Lresume_userspace;
1034 ENDPROC(_schedule_and_signal_from_int)
1035
1036 ENTRY(_schedule_and_signal)
1037         SAVE_CONTEXT_SYSCALL
1038         /* To end up here, vector 15 was changed - so we have to change it
1039          * back.
1040          */
1041         p0.l = lo(EVT15);
1042         p0.h = hi(EVT15);
1043         p1.l = _evt_system_call;
1044         p1.h = _evt_system_call;
1045         [p0] = p1;
1046         csync;
1047         p0.l = 1f;
1048         p0.h = 1f;
1049         [sp + PT_RESERVED] = P0;
1050         call .Lresume_userspace;
1051 1:
1052         RESTORE_CONTEXT
1053         rti;
1054 ENDPROC(_schedule_and_signal)
1055
1056 /* We handle this 100% in exception space - to reduce overhead
1057  * Only potiential problem is if the software buffer gets swapped out of the
1058  * CPLB table - then double fault. - so we don't let this happen in other places
1059  */
1060 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
1061 ENTRY(_ex_trace_buff_full)
1062         [--sp] = P3;
1063         [--sp] = P2;
1064         [--sp] = LC0;
1065         [--sp] = LT0;
1066         [--sp] = LB0;
1067         P5.L = _trace_buff_offset;
1068         P5.H = _trace_buff_offset;
1069         P3 = [P5];              /* trace_buff_offset */
1070         P5.L = lo(TBUFSTAT);
1071         P5.H = hi(TBUFSTAT);
1072         R7 = [P5];
1073         R7 <<= 1;               /* double, since we need to read twice */
1074         LC0 = R7;
1075         R7 <<= 2;               /* need to shift over again,
1076                                  * to get the number of bytes */
1077         P5.L = lo(TBUF);
1078         P5.H = hi(TBUF);
1079         R6 = ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN)*1024) - 1;
1080
1081         P2 = R7;
1082         P3 = P3 + P2;
1083         R7 = P3;
1084         R7 = R7 & R6;
1085         P3 = R7;
1086         P2.L = _trace_buff_offset;
1087         P2.H = _trace_buff_offset;
1088         [P2] = P3;
1089
1090         P2.L = _software_trace_buff;
1091         P2.H = _software_trace_buff;
1092
1093         LSETUP (.Lstart, .Lend) LC0;
1094 .Lstart:
1095         R7 = [P5];      /* read TBUF */
1096         P4 = P3 + P2;
1097         [P4] = R7;
1098         P3 += -4;
1099         R7 = P3;
1100         R7 = R7 & R6;
1101 .Lend:
1102         P3 = R7;
1103
1104         LB0 = [sp++];
1105         LT0 = [sp++];
1106         LC0 = [sp++];
1107         P2 = [sp++];
1108         P3 = [sp++];
1109         jump _bfin_return_from_exception;
1110 ENDPROC(_ex_trace_buff_full)
1111
1112 #if CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN == 4
1113 .data
1114 #else
1115 .section .l1.data.B
1116 #endif /* CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN */
1117 ENTRY(_trace_buff_offset)
1118         .long 0;
1119 ALIGN
1120 ENTRY(_software_trace_buff)
1121         .rept ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN)*256);
1122         .long 0
1123         .endr
1124 #endif /* CONFIG_DEBUG_BFIN_HWTRACE_EXPAND */
1125
1126 #if CONFIG_EARLY_PRINTK
1127 __INIT
1128 ENTRY(_early_trap)
1129         SAVE_ALL_SYS
1130         trace_buffer_stop(p0,r0);
1131
1132 #if ANOMALY_05000283 || ANOMALY_05000315
1133         cc = r5 == r5;
1134         p4.h = HI(CHIPID);
1135         p4.l = LO(CHIPID);
1136         if cc jump 1f;
1137         r5.l = W[p4];
1138 1:
1139 #endif
1140
1141         /* Turn caches off, to ensure we don't get double exceptions */
1142
1143         P4.L = LO(IMEM_CONTROL);
1144         P4.H = HI(IMEM_CONTROL);
1145
1146         R5 = [P4];              /* Control Register*/
1147         BITCLR(R5,ENICPLB_P);
1148         CLI R1;
1149         SSYNC;          /* SSYNC required before writing to IMEM_CONTROL. */
1150         .align 8;
1151         [P4] = R5;
1152         SSYNC;
1153
1154         P4.L = LO(DMEM_CONTROL);
1155         P4.H = HI(DMEM_CONTROL);
1156         R5 = [P4];
1157         BITCLR(R5,ENDCPLB_P);
1158         SSYNC;          /* SSYNC required before writing to DMEM_CONTROL. */
1159         .align 8;
1160         [P4] = R5;
1161         SSYNC;
1162         STI R1;
1163
1164         r0 = sp;        /* stack frame pt_regs pointer argument ==> r0 */
1165         r1 = RETX;
1166
1167         SP += -12;
1168         call _early_trap_c;
1169         SP += 12;
1170 ENDPROC(_early_trap)
1171 __FINIT
1172 #endif /* CONFIG_EARLY_PRINTK */
1173
1174 /*
1175  * Put these in the kernel data section - that should always be covered by
1176  * a CPLB. This is needed to ensure we don't get double fault conditions
1177  */
1178
1179 #ifdef CONFIG_SYSCALL_TAB_L1
1180 .section .l1.data
1181 #else
1182 .data
1183 #endif
1184
1185 ENTRY(_ex_table)
1186         /* entry for each EXCAUSE[5:0]
1187          * This table must be in sync with the table in ./kernel/traps.c
1188          * EXCPT instruction can provide 4 bits of EXCAUSE, allowing 16 to be user defined
1189          */
1190         .long _ex_syscall       /* 0x00 - User Defined - Linux Syscall */
1191         .long _ex_trap_c        /* 0x01 - User Defined - Software breakpoint */
1192 #ifdef  CONFIG_KGDB
1193         .long _ex_trap_c        /* 0x02 - User Defined - KGDB initial connection
1194                                                          and break signal trap */
1195 #else
1196         .long _ex_replaceable   /* 0x02 - User Defined */
1197 #endif
1198         .long _ex_trap_c        /* 0x03 - User Defined - userspace stack overflow */
1199         .long _ex_trap_c        /* 0x04 - User Defined - dump trace buffer */
1200         .long _ex_replaceable   /* 0x05 - User Defined */
1201         .long _ex_replaceable   /* 0x06 - User Defined */
1202         .long _ex_replaceable   /* 0x07 - User Defined */
1203         .long _ex_replaceable   /* 0x08 - User Defined */
1204         .long _ex_replaceable   /* 0x09 - User Defined */
1205         .long _ex_replaceable   /* 0x0A - User Defined */
1206         .long _ex_replaceable   /* 0x0B - User Defined */
1207         .long _ex_replaceable   /* 0x0C - User Defined */
1208         .long _ex_replaceable   /* 0x0D - User Defined */
1209         .long _ex_replaceable   /* 0x0E - User Defined */
1210         .long _ex_replaceable   /* 0x0F - User Defined */
1211         .long _ex_single_step   /* 0x10 - HW Single step */
1212 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
1213         .long _ex_trace_buff_full /* 0x11 - Trace Buffer Full */
1214 #else
1215         .long _ex_trap_c        /* 0x11 - Trace Buffer Full */
1216 #endif
1217         .long _ex_trap_c        /* 0x12 - Reserved */
1218         .long _ex_trap_c        /* 0x13 - Reserved */
1219         .long _ex_trap_c        /* 0x14 - Reserved */
1220         .long _ex_trap_c        /* 0x15 - Reserved */
1221         .long _ex_trap_c        /* 0x16 - Reserved */
1222         .long _ex_trap_c        /* 0x17 - Reserved */
1223         .long _ex_trap_c        /* 0x18 - Reserved */
1224         .long _ex_trap_c        /* 0x19 - Reserved */
1225         .long _ex_trap_c        /* 0x1A - Reserved */
1226         .long _ex_trap_c        /* 0x1B - Reserved */
1227         .long _ex_trap_c        /* 0x1C - Reserved */
1228         .long _ex_trap_c        /* 0x1D - Reserved */
1229         .long _ex_trap_c        /* 0x1E - Reserved */
1230         .long _ex_trap_c        /* 0x1F - Reserved */
1231         .long _ex_trap_c        /* 0x20 - Reserved */
1232         .long _ex_trap_c        /* 0x21 - Undefined Instruction */
1233         .long _ex_trap_c        /* 0x22 - Illegal Instruction Combination */
1234         .long _ex_dviol         /* 0x23 - Data CPLB Protection Violation */
1235         .long _ex_trap_c        /* 0x24 - Data access misaligned */
1236         .long _ex_trap_c        /* 0x25 - Unrecoverable Event */
1237         .long _ex_dmiss         /* 0x26 - Data CPLB Miss */
1238         .long _ex_dmult         /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero */
1239         .long _ex_trap_c        /* 0x28 - Emulation Watchpoint */
1240         .long _ex_trap_c        /* 0x29 - Instruction fetch access error (535 only) */
1241         .long _ex_trap_c        /* 0x2A - Instruction fetch misaligned */
1242         .long _ex_trap_c        /* 0x2B - Instruction CPLB protection Violation */
1243         .long _ex_icplb_miss    /* 0x2C - Instruction CPLB miss */
1244         .long _ex_trap_c        /* 0x2D - Instruction CPLB Multiple Hits */
1245         .long _ex_trap_c        /* 0x2E - Illegal use of Supervisor Resource */
1246         .long _ex_trap_c        /* 0x2E - Illegal use of Supervisor Resource */
1247         .long _ex_trap_c        /* 0x2F - Reserved */
1248         .long _ex_trap_c        /* 0x30 - Reserved */
1249         .long _ex_trap_c        /* 0x31 - Reserved */
1250         .long _ex_trap_c        /* 0x32 - Reserved */
1251         .long _ex_trap_c        /* 0x33 - Reserved */
1252         .long _ex_trap_c        /* 0x34 - Reserved */
1253         .long _ex_trap_c        /* 0x35 - Reserved */
1254         .long _ex_trap_c        /* 0x36 - Reserved */
1255         .long _ex_trap_c        /* 0x37 - Reserved */
1256         .long _ex_trap_c        /* 0x38 - Reserved */
1257         .long _ex_trap_c        /* 0x39 - Reserved */
1258         .long _ex_trap_c        /* 0x3A - Reserved */
1259         .long _ex_trap_c        /* 0x3B - Reserved */
1260         .long _ex_trap_c        /* 0x3C - Reserved */
1261         .long _ex_trap_c        /* 0x3D - Reserved */
1262         .long _ex_trap_c        /* 0x3E - Reserved */
1263         .long _ex_trap_c        /* 0x3F - Reserved */
1264 END(_ex_table)
1265
1266 ENTRY(_sys_call_table)
1267         .long _sys_restart_syscall      /* 0 */
1268         .long _sys_exit
1269         .long _sys_fork
1270         .long _sys_read
1271         .long _sys_write
1272         .long _sys_open         /* 5 */
1273         .long _sys_close
1274         .long _sys_ni_syscall   /* old waitpid */
1275         .long _sys_creat
1276         .long _sys_link
1277         .long _sys_unlink       /* 10 */
1278         .long _sys_execve
1279         .long _sys_chdir
1280         .long _sys_time
1281         .long _sys_mknod
1282         .long _sys_chmod                /* 15 */
1283         .long _sys_chown        /* chown16 */
1284         .long _sys_ni_syscall   /* old break syscall holder */
1285         .long _sys_ni_syscall   /* old stat */
1286         .long _sys_lseek
1287         .long _sys_getpid       /* 20 */
1288         .long _sys_mount
1289         .long _sys_ni_syscall   /* old umount */
1290         .long _sys_setuid
1291         .long _sys_getuid
1292         .long _sys_stime                /* 25 */
1293         .long _sys_ptrace
1294         .long _sys_alarm
1295         .long _sys_ni_syscall   /* old fstat */
1296         .long _sys_pause
1297         .long _sys_ni_syscall   /* old utime */ /* 30 */
1298         .long _sys_ni_syscall   /* old stty syscall holder */
1299         .long _sys_ni_syscall   /* old gtty syscall holder */
1300         .long _sys_access
1301         .long _sys_nice
1302         .long _sys_ni_syscall   /* 35 */ /* old ftime syscall holder */
1303         .long _sys_sync
1304         .long _sys_kill
1305         .long _sys_rename
1306         .long _sys_mkdir
1307         .long _sys_rmdir                /* 40 */
1308         .long _sys_dup
1309         .long _sys_pipe
1310         .long _sys_times
1311         .long _sys_ni_syscall   /* old prof syscall holder */
1312         .long _sys_brk          /* 45 */
1313         .long _sys_setgid
1314         .long _sys_getgid
1315         .long _sys_ni_syscall   /* old sys_signal */
1316         .long _sys_geteuid      /* geteuid16 */
1317         .long _sys_getegid      /* getegid16 */ /* 50 */
1318         .long _sys_acct
1319         .long _sys_umount       /* recycled never used phys() */
1320         .long _sys_ni_syscall   /* old lock syscall holder */
1321         .long _sys_ioctl
1322         .long _sys_fcntl                /* 55 */
1323         .long _sys_ni_syscall   /* old mpx syscall holder */
1324         .long _sys_setpgid
1325         .long _sys_ni_syscall   /* old ulimit syscall holder */
1326         .long _sys_ni_syscall   /* old old uname */
1327         .long _sys_umask                /* 60 */
1328         .long _sys_chroot
1329         .long _sys_ustat
1330         .long _sys_dup2
1331         .long _sys_getppid
1332         .long _sys_getpgrp      /* 65 */
1333         .long _sys_setsid
1334         .long _sys_ni_syscall   /* old sys_sigaction */
1335         .long _sys_sgetmask
1336         .long _sys_ssetmask
1337         .long _sys_setreuid     /* setreuid16 */        /* 70 */
1338         .long _sys_setregid     /* setregid16 */
1339         .long _sys_ni_syscall   /* old sys_sigsuspend */
1340         .long _sys_ni_syscall   /* old sys_sigpending */
1341         .long _sys_sethostname
1342         .long _sys_setrlimit    /* 75 */
1343         .long _sys_ni_syscall   /* old getrlimit */
1344         .long _sys_getrusage
1345         .long _sys_gettimeofday
1346         .long _sys_settimeofday
1347         .long _sys_getgroups    /* getgroups16 */       /* 80 */
1348         .long _sys_setgroups    /* setgroups16 */
1349         .long _sys_ni_syscall   /* old_select */
1350         .long _sys_symlink
1351         .long _sys_ni_syscall   /* old lstat */
1352         .long _sys_readlink     /* 85 */
1353         .long _sys_uselib
1354         .long _sys_ni_syscall   /* sys_swapon */
1355         .long _sys_reboot
1356         .long _sys_ni_syscall   /* old_readdir */
1357         .long _sys_ni_syscall   /* sys_mmap */  /* 90 */
1358         .long _sys_munmap
1359         .long _sys_truncate
1360         .long _sys_ftruncate
1361         .long _sys_fchmod
1362         .long _sys_fchown       /* fchown16 */  /* 95 */
1363         .long _sys_getpriority
1364         .long _sys_setpriority
1365         .long _sys_ni_syscall   /* old profil syscall holder */
1366         .long _sys_statfs
1367         .long _sys_fstatfs      /* 100 */
1368         .long _sys_ni_syscall
1369         .long _sys_ni_syscall   /* old sys_socketcall */
1370         .long _sys_syslog
1371         .long _sys_setitimer
1372         .long _sys_getitimer    /* 105 */
1373         .long _sys_newstat
1374         .long _sys_newlstat
1375         .long _sys_newfstat
1376         .long _sys_ni_syscall   /* old uname */
1377         .long _sys_ni_syscall   /* iopl for i386 */ /* 110 */
1378         .long _sys_vhangup
1379         .long _sys_ni_syscall   /* obsolete idle() syscall */
1380         .long _sys_ni_syscall   /* vm86old for i386 */
1381         .long _sys_wait4
1382         .long _sys_ni_syscall   /* 115 */ /* sys_swapoff */
1383         .long _sys_sysinfo
1384         .long _sys_ni_syscall   /* old sys_ipc */
1385         .long _sys_fsync
1386         .long _sys_ni_syscall   /* old sys_sigreturn */
1387         .long _sys_clone                /* 120 */
1388         .long _sys_setdomainname
1389         .long _sys_newuname
1390         .long _sys_ni_syscall   /* old sys_modify_ldt */
1391         .long _sys_adjtimex
1392         .long _sys_ni_syscall   /* 125 */ /* sys_mprotect */
1393         .long _sys_ni_syscall   /* old sys_sigprocmask */
1394         .long _sys_ni_syscall   /* old "creat_module" */
1395         .long _sys_init_module
1396         .long _sys_delete_module
1397         .long _sys_ni_syscall   /* 130: old "get_kernel_syms" */
1398         .long _sys_quotactl
1399         .long _sys_getpgid
1400         .long _sys_fchdir
1401         .long _sys_bdflush
1402         .long _sys_ni_syscall   /* 135 */ /* sys_sysfs */
1403         .long _sys_personality
1404         .long _sys_ni_syscall   /* for afs_syscall */
1405         .long _sys_setfsuid     /* setfsuid16 */
1406         .long _sys_setfsgid     /* setfsgid16 */
1407         .long _sys_llseek       /* 140 */
1408         .long _sys_getdents
1409         .long _sys_ni_syscall   /* sys_select */
1410         .long _sys_flock
1411         .long _sys_ni_syscall   /* sys_msync */
1412         .long _sys_readv                /* 145 */
1413         .long _sys_writev
1414         .long _sys_getsid
1415         .long _sys_fdatasync
1416         .long _sys_sysctl
1417         .long _sys_ni_syscall   /* 150 */ /* sys_mlock */
1418         .long _sys_ni_syscall   /* sys_munlock */
1419         .long _sys_ni_syscall   /* sys_mlockall */
1420         .long _sys_ni_syscall   /* sys_munlockall */
1421         .long _sys_sched_setparam
1422         .long _sys_sched_getparam /* 155 */
1423         .long _sys_sched_setscheduler
1424         .long _sys_sched_getscheduler
1425         .long _sys_sched_yield
1426         .long _sys_sched_get_priority_max
1427         .long _sys_sched_get_priority_min  /* 160 */
1428         .long _sys_sched_rr_get_interval
1429         .long _sys_nanosleep
1430         .long _sys_mremap
1431         .long _sys_setresuid    /* setresuid16 */
1432         .long _sys_getresuid    /* getresuid16 */       /* 165 */
1433         .long _sys_ni_syscall   /* for vm86 */
1434         .long _sys_ni_syscall   /* old "query_module" */
1435         .long _sys_ni_syscall   /* sys_poll */
1436         .long _sys_nfsservctl
1437         .long _sys_setresgid    /* setresgid16 */       /* 170 */
1438         .long _sys_getresgid    /* getresgid16 */
1439         .long _sys_prctl
1440         .long _sys_rt_sigreturn
1441         .long _sys_rt_sigaction
1442         .long _sys_rt_sigprocmask /* 175 */
1443         .long _sys_rt_sigpending
1444         .long _sys_rt_sigtimedwait
1445         .long _sys_rt_sigqueueinfo
1446         .long _sys_rt_sigsuspend
1447         .long _sys_pread64      /* 180 */
1448         .long _sys_pwrite64
1449         .long _sys_lchown       /* lchown16 */
1450         .long _sys_getcwd
1451         .long _sys_capget
1452         .long _sys_capset       /* 185 */
1453         .long _sys_sigaltstack
1454         .long _sys_sendfile
1455         .long _sys_ni_syscall   /* streams1 */
1456         .long _sys_ni_syscall   /* streams2 */
1457         .long _sys_vfork                /* 190 */
1458         .long _sys_getrlimit
1459         .long _sys_mmap2
1460         .long _sys_truncate64
1461         .long _sys_ftruncate64
1462         .long _sys_stat64       /* 195 */
1463         .long _sys_lstat64
1464         .long _sys_fstat64
1465         .long _sys_chown
1466         .long _sys_getuid
1467         .long _sys_getgid       /* 200 */
1468         .long _sys_geteuid
1469         .long _sys_getegid
1470         .long _sys_setreuid
1471         .long _sys_setregid
1472         .long _sys_getgroups    /* 205 */
1473         .long _sys_setgroups
1474         .long _sys_fchown
1475         .long _sys_setresuid
1476         .long _sys_getresuid
1477         .long _sys_setresgid    /* 210 */
1478         .long _sys_getresgid
1479         .long _sys_lchown
1480         .long _sys_setuid
1481         .long _sys_setgid
1482         .long _sys_setfsuid     /* 215 */
1483         .long _sys_setfsgid
1484         .long _sys_pivot_root
1485         .long _sys_ni_syscall   /* sys_mincore */
1486         .long _sys_ni_syscall   /* sys_madvise */
1487         .long _sys_getdents64   /* 220 */
1488         .long _sys_fcntl64
1489         .long _sys_ni_syscall   /* reserved for TUX */
1490         .long _sys_ni_syscall
1491         .long _sys_gettid
1492         .long _sys_readahead    /* 225 */
1493         .long _sys_setxattr
1494         .long _sys_lsetxattr
1495         .long _sys_fsetxattr
1496         .long _sys_getxattr
1497         .long _sys_lgetxattr    /* 230 */
1498         .long _sys_fgetxattr
1499         .long _sys_listxattr
1500         .long _sys_llistxattr
1501         .long _sys_flistxattr
1502         .long _sys_removexattr  /* 235 */
1503         .long _sys_lremovexattr
1504         .long _sys_fremovexattr
1505         .long _sys_tkill
1506         .long _sys_sendfile64
1507         .long _sys_futex                /* 240 */
1508         .long _sys_sched_setaffinity
1509         .long _sys_sched_getaffinity
1510         .long _sys_ni_syscall   /* sys_set_thread_area */
1511         .long _sys_ni_syscall   /* sys_get_thread_area */
1512         .long _sys_io_setup     /* 245 */
1513         .long _sys_io_destroy
1514         .long _sys_io_getevents
1515         .long _sys_io_submit
1516         .long _sys_io_cancel
1517         .long _sys_ni_syscall   /* 250 */ /* sys_alloc_hugepages */
1518         .long _sys_ni_syscall   /* sys_freec_hugepages */
1519         .long _sys_exit_group
1520         .long _sys_lookup_dcookie
1521         .long _sys_bfin_spinlock
1522         .long _sys_epoll_create /* 255 */
1523         .long _sys_epoll_ctl
1524         .long _sys_epoll_wait
1525         .long _sys_ni_syscall /* remap_file_pages */
1526         .long _sys_set_tid_address
1527         .long _sys_timer_create /* 260 */
1528         .long _sys_timer_settime
1529         .long _sys_timer_gettime
1530         .long _sys_timer_getoverrun
1531         .long _sys_timer_delete
1532         .long _sys_clock_settime /* 265 */
1533         .long _sys_clock_gettime
1534         .long _sys_clock_getres
1535         .long _sys_clock_nanosleep
1536         .long _sys_statfs64
1537         .long _sys_fstatfs64    /* 270 */
1538         .long _sys_tgkill
1539         .long _sys_utimes
1540         .long _sys_fadvise64_64
1541         .long _sys_ni_syscall /* vserver */
1542         .long _sys_ni_syscall /* 275, mbind */
1543         .long _sys_ni_syscall /* get_mempolicy */
1544         .long _sys_ni_syscall /* set_mempolicy */
1545         .long _sys_mq_open
1546         .long _sys_mq_unlink
1547         .long _sys_mq_timedsend /* 280 */
1548         .long _sys_mq_timedreceive
1549         .long _sys_mq_notify
1550         .long _sys_mq_getsetattr
1551         .long _sys_ni_syscall /* kexec_load */
1552         .long _sys_waitid       /* 285 */
1553         .long _sys_add_key
1554         .long _sys_request_key
1555         .long _sys_keyctl
1556         .long _sys_ioprio_set
1557         .long _sys_ioprio_get   /* 290 */
1558         .long _sys_inotify_init
1559         .long _sys_inotify_add_watch
1560         .long _sys_inotify_rm_watch
1561         .long _sys_ni_syscall /* migrate_pages */
1562         .long _sys_openat       /* 295 */
1563         .long _sys_mkdirat
1564         .long _sys_mknodat
1565         .long _sys_fchownat
1566         .long _sys_futimesat
1567         .long _sys_fstatat64    /* 300 */
1568         .long _sys_unlinkat
1569         .long _sys_renameat
1570         .long _sys_linkat
1571         .long _sys_symlinkat
1572         .long _sys_readlinkat   /* 305 */
1573         .long _sys_fchmodat
1574         .long _sys_faccessat
1575         .long _sys_pselect6
1576         .long _sys_ppoll
1577         .long _sys_unshare      /* 310 */
1578         .long _sys_sram_alloc
1579         .long _sys_sram_free
1580         .long _sys_dma_memcpy
1581         .long _sys_accept
1582         .long _sys_bind         /* 315 */
1583         .long _sys_connect
1584         .long _sys_getpeername
1585         .long _sys_getsockname
1586         .long _sys_getsockopt
1587         .long _sys_listen       /* 320 */
1588         .long _sys_recv
1589         .long _sys_recvfrom
1590         .long _sys_recvmsg
1591         .long _sys_send
1592         .long _sys_sendmsg      /* 325 */
1593         .long _sys_sendto
1594         .long _sys_setsockopt
1595         .long _sys_shutdown
1596         .long _sys_socket
1597         .long _sys_socketpair   /* 330 */
1598         .long _sys_semctl
1599         .long _sys_semget
1600         .long _sys_semop
1601         .long _sys_msgctl
1602         .long _sys_msgget       /* 335 */
1603         .long _sys_msgrcv
1604         .long _sys_msgsnd
1605         .long _sys_shmat
1606         .long _sys_shmctl
1607         .long _sys_shmdt        /* 340 */
1608         .long _sys_shmget
1609         .long _sys_splice
1610         .long _sys_sync_file_range
1611         .long _sys_tee
1612         .long _sys_vmsplice     /* 345 */
1613         .long _sys_epoll_pwait
1614         .long _sys_utimensat
1615         .long _sys_signalfd
1616         .long _sys_timerfd_create
1617         .long _sys_eventfd      /* 350 */
1618         .long _sys_pread64
1619         .long _sys_pwrite64
1620         .long _sys_fadvise64
1621         .long _sys_set_robust_list
1622         .long _sys_get_robust_list      /* 355 */
1623         .long _sys_fallocate
1624         .long _sys_semtimedop
1625         .long _sys_timerfd_settime
1626         .long _sys_timerfd_gettime
1627         .long _sys_signalfd4            /* 360 */
1628         .long _sys_eventfd2
1629         .long _sys_epoll_create1
1630         .long _sys_dup3
1631         .long _sys_pipe2
1632         .long _sys_inotify_init1        /* 365 */
1633         .long _sys_preadv
1634         .long _sys_pwritev
1635         .long _sys_rt_tgsigqueueinfo
1636         .long _sys_perf_counter_open
1637
1638         .rept NR_syscalls-(.-_sys_call_table)/4
1639         .long _sys_ni_syscall
1640         .endr
1641 END(_sys_call_table)