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