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