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