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