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