2 * File: arch/blackfin/mach-common/entry.S
4 * Author: Linus Torvalds
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.
12 * Copyright 2004-2006 Analog Devices Inc.
14 * Bugs: Enter bugs at http://blackfin.uclinux.org/
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.
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.
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
32 /* NOTE: This code handles signal-recognition, which happens every time
33 * after a timer-interrupt and after each system call.
36 #include <linux/init.h>
37 #include <linux/linkage.h>
38 #include <linux/unistd.h>
39 #include <asm/blackfin.h>
40 #include <asm/errno.h>
41 #include <asm/fixed_code.h>
42 #include <asm/thread_info.h> /* TIF_NEED_RESCHED */
43 #include <asm/asm-offsets.h>
44 #include <asm/trace.h>
45 #include <asm/traps.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
54 # define EX_SCRATCH_REG CYCLES
57 #ifdef CONFIG_EXCPT_IRQ_SYSC_L1
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.
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)
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,
78 P4 = R7; /* Store EXCAUSE */
81 r7 = [p5 + PDA_LFRETX];
83 [p5 + PDA_LFRETX] = r6;
85 if !cc jump _bfin_return_from_exception;
88 R6 = VEC_CPLB_M; /* Data CPLB Miss */
90 if cc jump _ex_dcplb_miss (BP);
92 R6 = VEC_CPLB_VL; /* Data CPLB Violation */
94 if cc jump _ex_dcplb_viol (BP);
96 /* Handle Data CPLB Protection Violation
97 * and Data CPLB Multiple Hits - Linux Trap Zero
100 ENDPROC(_ex_workaround_261)
104 #define _ex_dviol _ex_dcplb_viol
106 #define _ex_dviol _ex_trap_c
108 #define _ex_dmiss _ex_dcplb_miss
109 #define _ex_dmult _ex_trap_c
113 ENTRY(_ex_dcplb_viol)
114 ENTRY(_ex_dcplb_miss)
115 ENTRY(_ex_icplb_miss)
116 (R7:6,P5:4) = [sp++];
117 /* We leave the previously pushed ASTAT on the stack. */
120 /* We must load R1 here, _before_ DEBUG_HWTRACE_SAVE, since that
121 * will change the stack pointer. */
125 DEBUG_HWTRACE_SAVE(p5, r7)
131 IF !CC JUMP _handle_bad_cplb;
133 #ifdef CONFIG_DEBUG_DOUBLEFAULT
134 /* While we were processing this, did we double fault? */
135 r7 = SEQSTAT; /* reason code is in bit 5:0 */
136 r6.l = lo(SEQSTAT_EXCAUSE);
137 r6.h = hi(SEQSTAT_EXCAUSE);
141 if CC JUMP _double_fault;
144 DEBUG_HWTRACE_RESTORE(p5, r7)
149 ENDPROC(_ex_icplb_miss)
152 raise 15; /* invoked by TRAP #0, for sys call */
153 jump.s _bfin_return_from_exception;
156 ENTRY(_ex_single_step)
157 /* If we just returned from an interrupt, the single step event is
158 for the RTI instruction. */
162 if cc jump _bfin_return_from_exception;
165 /* Don't do single step in hardware exception handler */
170 if cc jump _bfin_return_from_exception;
172 if cc jump _bfin_return_from_exception;
174 /* skip single step if current interrupt priority is higher than
175 * that of the first instruction, from which gdb starts single step */
178 .Lfind_priority_start:
180 if cc jump .Lfind_priority_done;
184 if cc jump .Lfind_priority_done;
185 jump.s .Lfind_priority_start;
186 .Lfind_priority_done:
187 p4.l = _kgdb_single_step;
188 p4.h = _kgdb_single_step;
191 if cc jump .Ldo_single_step;
197 /* If we were in user mode, do the single step normally. */
206 #ifdef CONFIG_EXACT_HWERR
207 /* Read the ILAT, and to check to see if the process we are
208 * single stepping caused a previous hardware error
209 * If so, do not single step, (which lowers to IRQ5, and makes
210 * us miss the error).
215 cc = bittst(r7, EVT_IVHW_P);
218 /* Single stepping only a single instruction, so clear the trace
221 bitclr (r7, SYSCFG_SSSTEP_P);
227 * We were in an interrupt handler. By convention, all of them save
228 * SYSCFG with their first instruction, so by checking whether our
229 * RETX points at the entry point, we can determine whether to allow
230 * a single step, or whether to clear SYSCFG.
232 * First, find out the interrupt level and the event vector for it.
242 /* What we actually do is test for the _second_ instruction in the
243 * IRQ handler. That way, if there are insns following the restore
244 * of SYSCFG after leaving the handler, we will not turn off SYSCFG
251 if !cc jump _bfin_return_from_exception;
254 bitclr (r7, SYSCFG_SSSTEP_P); /* Turn off single step */
257 /* Fall through to _bfin_return_from_exception. */
258 ENDPROC(_ex_single_step)
260 ENTRY(_bfin_return_from_exception)
268 #ifdef CONFIG_DEBUG_DOUBLEFAULT
269 /* While we were processing the current exception,
270 * did we cause another, and double fault?
272 r7 = SEQSTAT; /* reason code is in bit 5:0 */
273 r6.l = lo(SEQSTAT_EXCAUSE);
274 r6.h = hi(SEQSTAT_EXCAUSE);
278 if CC JUMP _double_fault;
281 (R7:6,P5:4) = [sp++];
285 ENDPROC(_bfin_return_from_exception)
287 ENTRY(_handle_bad_cplb)
288 DEBUG_HWTRACE_RESTORE(p5, r7)
289 /* To get here, we just tried and failed to change a CPLB
290 * so, handle things in trap_c (C code), by lowering to
291 * IRQ5, just like we normally do. Since this is not a
292 * "normal" return path, we have a do alot of stuff to
293 * the stack to get ready so, we can fall through - we
294 * need to make a CPLB exception look like a normal exception
297 /* ASTAT is still on the stack, where it is needed. */
298 [--sp] = (R7:6,P5:4);
300 ENTRY(_ex_replaceable)
304 /* The only thing that has been saved in this context is
305 * (R7:6,P5:4), ASTAT & SP - don't use anything else
310 /* Make sure we are not in a double fault */
315 if CC jump _double_fault;
316 [p5 + PDA_EXIPEND] = r7;
318 /* Call C code (trap_c) to handle the exception, which most
319 * likely involves sending a signal to the current process.
320 * To avoid double faults, lower our priority to IRQ5 first.
322 r7.h = _exception_to_level5;
323 r7.l = _exception_to_level5;
330 * Save these registers, as they are only valid in exception context
331 * (where we are now - as soon as we defer to IRQ5, they can change)
332 * DCPLB_STATUS and ICPLB_STATUS are also only valid in EVT3,
333 * but they are not very interesting, so don't save them
336 p4.l = lo(DCPLB_FAULT_ADDR);
337 p4.h = hi(DCPLB_FAULT_ADDR);
339 [p5 + PDA_DCPLB] = r7;
341 p4.l = lo(ICPLB_FAULT_ADDR);
342 p4.h = hi(ICPLB_FAULT_ADDR);
344 [p5 + PDA_ICPLB] = r6;
347 [p5 + PDA_RETX] = r6;
350 [p5 + PDA_SEQSTAT] = r6;
352 /* Save the state of single stepping */
354 [p5 + PDA_SYSCFG] = r6;
355 /* Clear it while we handle the exception in IRQ5 mode */
356 BITCLR(r6, SYSCFG_SSSTEP_P);
359 /* Save the current IMASK, since we change in order to jump to level 5 */
361 [p5 + PDA_EXIMASK] = r6;
363 p4.l = lo(SAFE_USER_INSTRUCTION);
364 p4.h = hi(SAFE_USER_INSTRUCTION);
367 /* Disable all interrupts, but make sure level 5 is enabled so
368 * we can switch to that level.
373 /* In case interrupts are disabled IPEND[4] (global interrupt disable bit)
374 * clear it (re-enabling interrupts again) by the special sequence of pushing
375 * RETI onto the stack. This way we can lower ourselves to IVG5 even if the
376 * exception was taken after the interrupt handler was called but before it
377 * got a chance to enable global interrupts itself.
383 jump.s _bfin_return_from_exception;
386 /* We just realized we got an exception, while we were processing a different
387 * exception. This is a unrecoverable event, so crash.
388 * Note: this cannot be ENTRY() as we jump here with "if cc jump" ...
391 /* Turn caches & protection off, to ensure we don't get any more
395 P4.L = LO(IMEM_CONTROL);
396 P4.H = HI(IMEM_CONTROL);
398 R5 = [P4]; /* Control Register*/
399 BITCLR(R5,ENICPLB_P);
400 CSYNC; /* Disabling of CPLBs should be proceeded by a CSYNC */
404 P4.L = LO(DMEM_CONTROL);
405 P4.H = HI(DMEM_CONTROL);
407 BITCLR(R5,ENDCPLB_P);
408 CSYNC; /* Disabling of CPLBs should be proceeded by a CSYNC */
412 /* Fix up the stack */
413 (R7:6,P5:4) = [sp++];
417 /* We should be out of the exception stack, and back down into
418 * kernel or user space stack
422 /* The dumping functions expect the return address in the RETI
427 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
429 call _double_fault_c;
431 .L_double_fault_panic:
432 JUMP .L_double_fault_panic
434 ENDPROC(_double_fault)
436 ENTRY(_exception_to_level5)
439 GET_PDA(p5, r7); /* Fetch current PDA */
440 r6 = [p5 + PDA_RETX];
443 r6 = [p5 + PDA_SYSCFG];
444 [sp + PT_SYSCFG] = r6;
446 r6 = [p5 + PDA_SEQSTAT]; /* Read back seqstat */
447 [sp + PT_SEQSTAT] = r6;
449 /* Restore the hardware error vector. */
457 #ifdef CONFIG_DEBUG_DOUBLEFAULT
458 /* Now that we have the hardware error vector programmed properly
459 * we can re-enable interrupts (IPEND[4]), so if the _trap_c causes
460 * another hardware error, we can catch it (self-nesting).
466 r7 = [p5 + PDA_EXIPEND] /* Read the IPEND from the Exception state */
467 [sp + PT_IPEND] = r7; /* Store IPEND onto the stack */
469 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
474 /* If interrupts were off during the exception (IPEND[4] = 1), turn them off
477 CC = BITTST(r7, EVT_IRPTEN_P)
479 /* this will load a random value into the reti register - but that is OK,
480 * since we do restore it to the correct value in the 'RESTORE_ALL_SYS' macro
485 /* restore the interrupt mask (IMASK) */
486 r6 = [p5 + PDA_EXIMASK];
489 call _ret_from_exception;
492 ENDPROC(_exception_to_level5)
494 ENTRY(_trap) /* Exception: 4th entry into system event table(supervisor mode)*/
495 /* Since the kernel stack can be anywhere, it's not guaranteed to be
496 * covered by a CPLB. Switch to an exception stack; use RETN as a
497 * scratch register (for want of a better option).
501 sp = [sp + PDA_EXSTACK];
502 /* Try to deal with syscalls quickly. */
504 [--sp] = (R7:6,P5:4);
506 #ifdef CONFIG_EXACT_HWERR
507 /* Make sure all pending read/writes complete. This will ensure any
508 * accesses which could cause hardware errors completes, and signal
509 * the the hardware before we do something silly, like crash the
510 * kernel. We don't need to work around anomaly 05000312, since
511 * we are already atomic
516 ANOMALY_283_315_WORKAROUND(p5, r7)
518 #ifdef CONFIG_DEBUG_DOUBLEFAULT
520 * Save these registers, as they are only valid in exception context
521 * (where we are now - as soon as we defer to IRQ5, they can change)
522 * DCPLB_STATUS and ICPLB_STATUS are also only valid in EVT3,
523 * but they are not very interesting, so don't save them
527 p4.l = lo(DCPLB_FAULT_ADDR);
528 p4.h = hi(DCPLB_FAULT_ADDR);
530 [p5 + PDA_DF_DCPLB] = r7;
532 p4.l = lo(ICPLB_FAULT_ADDR);
533 p4.h = hi(ICPLB_FAULT_ADDR);
535 [p5 + PDA_DF_ICPLB] = r7;
538 [p5 + PDA_DF_RETX] = r7;
540 r7 = SEQSTAT; /* reason code is in bit 5:0 */
541 [p5 + PDA_DF_SEQSTAT] = r7;
543 r7 = SEQSTAT; /* reason code is in bit 5:0 */
545 r6.l = lo(SEQSTAT_EXCAUSE);
546 r6.h = hi(SEQSTAT_EXCAUSE);
556 r7 = -ENOSYS; /* signextending enough */
557 [sp + PT_R0] = r7; /* return value from system call */
558 jump .Lsyscall_really_exit;
561 ENTRY(_kernel_execve)
564 r3 = SIZEOF_PTREGS / 4;
570 if !cc jump .Lclear_regs (bp);
578 if ! cc jump .Lexecve_failed;
579 /* Success. Copy our temporary pt_regs to the top of the kernel
580 * stack and do a normal exception return.
583 r0 = (-KERNEL_STACK_SIZE) (x);
587 r0 = KERNEL_STACK_SIZE - 4 (z);
593 r3 = SIZEOF_PTREGS / 4;
599 if ! cc jump .Lcopy_regs (bp);
601 r0 = (KERNEL_STACK_SIZE - SIZEOF_PTREGS) (z);
606 [SP + PT_SYSCFG] = r0;
607 [p3 + (TASK_THREAD + THREAD_KSP)] = sp;
614 ENDPROC(_kernel_execve)
622 [sp + PT_IPEND] = r0;
624 /* Store RETS for now */
626 [sp + PT_RESERVED] = r0;
627 /* Set the stack for the current process */
629 r6.l = lo(ALIGN_PAGE_MASK);
630 r6.h = hi(ALIGN_PAGE_MASK);
631 r7 = r7 & r6; /* thread_info */
635 [p2+(TASK_THREAD+THREAD_KSP)] = sp;
639 call ___ipipe_syscall_root;
642 if cc jump .Lsyscall_really_exit;
644 if cc jump .Lresume_userspace;
647 p0 = [sp + PT_ORIG_P0];
648 #endif /* CONFIG_IPIPE */
650 /* Check the System Call */
652 /* System call number is passed in P0 */
655 if ! cc jump .Lbadsys;
657 /* are we tracing syscalls?*/
659 r6.l = lo(ALIGN_PAGE_MASK);
660 r6.h = hi(ALIGN_PAGE_MASK);
664 CC = BITTST(r7,TIF_SYSCALL_TRACE);
665 if CC JUMP _sys_trace;
667 /* Execute the appropriate system call */
670 p5.l = _sys_call_table;
671 p5.h = _sys_call_table;
688 r4.l = lo(ALIGN_PAGE_MASK);
689 r4.h = hi(ALIGN_PAGE_MASK);
690 r7 = r7 & r4; /* thread_info->flags */
692 .Lresume_userspace_1:
693 /* Disable interrupts. */
697 r7 = [p5 + TI_FLAGS];
698 r4.l = lo(_TIF_WORK_MASK);
699 r4.h = hi(_TIF_WORK_MASK);
704 cc = BITTST(r7, TIF_IRQ_SYNC);
705 if !cc jump .Lsyscall_no_irqsync;
707 * Clear IPEND[4] manually to undo what resume_userspace_1 just did;
708 * we need this so that high priority domain interrupts may still
709 * preempt the current domain while the pipeline log is being played
713 SP += 4; /* don't merge with next insn to keep the pattern obvious */
715 call ___ipipe_sync_root;
717 jump .Lresume_userspace_1;
718 .Lsyscall_no_irqsync:
720 cc = BITTST(r7, TIF_NEED_RESCHED);
721 if !cc jump .Lsyscall_sigpending;
723 /* Reenable interrupts. */
731 jump .Lresume_userspace_1;
733 .Lsyscall_sigpending:
734 cc = BITTST(r7, TIF_RESTORE_SIGMASK);
735 if cc jump .Lsyscall_do_signals;
736 cc = BITTST(r7, TIF_SIGPENDING);
737 if !cc jump .Lsyscall_really_exit;
738 .Lsyscall_do_signals:
739 /* Reenable interrupts. */
748 .Lsyscall_really_exit:
749 r5 = [sp + PT_RESERVED];
752 ENDPROC(_system_call)
754 /* Do not mark as ENTRY() to avoid error in assembler ...
755 * this symbol need not be global anyways, so ...
760 /* Execute the appropriate system call */
763 p5.l = _sys_call_table;
764 p5.h = _sys_call_table;
783 jump .Lresume_userspace;
788 * Beware - when entering resume, prev (the current task) is
789 * in r0, next (the new task) is in r1.
795 [--sp] = (r7:4, p5:3);
799 [p0+(TASK_THREAD+THREAD_USP)] = p2;
801 /* save current kernel stack pointer */
802 [p0+(TASK_THREAD+THREAD_KSP)] = sp;
804 /* save program counter */
805 r1.l = _new_old_task;
806 r1.h = _new_old_task;
807 [p0+(TASK_THREAD+THREAD_PC)] = r1;
809 /* restore the kernel stack pointer */
810 sp = [p1+(TASK_THREAD+THREAD_KSP)];
812 /* restore user stack pointer */
813 p0 = [p1+(TASK_THREAD+THREAD_USP)];
817 p0 = [p1+(TASK_THREAD+THREAD_PC)];
821 * Following code actually lands up in a new (old) task.
825 (r7:4, p5:3) = [sp++];
830 * When we come out of resume, r0 carries "old" task, becuase we are
836 ENTRY(_ret_from_exception)
838 p2.l = _ipipe_percpu_domain;
839 p2.h = _ipipe_percpu_domain;
844 if !cc jump 4f; /* not on behalf of the root domain, get out */
845 #endif /* CONFIG_IPIPE */
851 [sp + PT_IPEND] = r0;
857 if !cc jump 4f; /* if not return to user mode, get out */
859 /* Make sure any pending system call or deferred exception
860 * return in ILAT for this process to get executed, otherwise
861 * in case context switch happens, system call of
862 * first process (i.e in ILAT) will be carried
863 * forward to the switched process
869 r1 = (EVT_IVG14 | EVT_IVG15) (z);
874 /* Set the stack for the current process */
876 r4.l = lo(ALIGN_PAGE_MASK);
877 r4.h = hi(ALIGN_PAGE_MASK);
878 r7 = r7 & r4; /* thread_info->flags */
880 r7 = [p5 + TI_FLAGS];
881 r4.l = lo(_TIF_WORK_MASK);
882 r4.h = hi(_TIF_WORK_MASK);
889 p1.l = _schedule_and_signal;
890 p1.h = _schedule_and_signal;
893 raise 15; /* raise evt15 to do signal or reschedule */
896 bitclr(r0, SYSCFG_SSSTEP_P); /* Turn off single step */
900 ENDPROC(_ret_from_exception)
904 _resume_kernel_from_int:
905 r0.l = ___ipipe_sync_root;
906 r0.h = ___ipipe_sync_root;
908 [--sp] = ( r7:4, p5:3 );
910 call ___ipipe_call_irqtail
912 ( r7:4, p5:3 ) = [sp++];
916 #define _resume_kernel_from_int 2f
919 ENTRY(_return_from_int)
920 /* If someone else already raised IRQ 15, do nothing. */
925 cc = bittst (r0, EVT_IVG15_P);
928 /* if not return to user mode, get out */
940 if !cc jump _resume_kernel_from_int;
942 /* Lower the interrupt level to 15. */
945 p1.l = _schedule_and_signal_from_int;
946 p1.h = _schedule_and_signal_from_int;
949 #if ANOMALY_05000281 || ANOMALY_05000461
950 r0.l = lo(SAFE_USER_INSTRUCTION);
951 r0.h = hi(SAFE_USER_INSTRUCTION);
956 raise 15; /* raise evt15 to do signal or reschedule */
960 ENDPROC(_return_from_int)
962 ENTRY(_lower_to_irq14)
963 #if ANOMALY_05000281 || ANOMALY_05000461
964 r0.l = lo(SAFE_USER_INSTRUCTION);
965 r0.h = hi(SAFE_USER_INSTRUCTION);
969 #ifdef CONFIG_DEBUG_HWERR
970 /* enable irq14 & hwerr interrupt, until we transition to _evt_evt14 */
971 r0 = (EVT_IVG14 | EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
973 /* Only enable irq14 interrupt, until we transition to _evt_evt14 */
974 r0 = (EVT_IVG14 | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
979 ENDPROC(_lower_to_irq14)
982 #ifdef CONFIG_DEBUG_HWERR
983 r0 = (EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
993 ENTRY(_schedule_and_signal_from_int)
994 /* To end up here, vector 15 was changed - so we have to change it
999 p1.l = _evt_system_call;
1000 p1.h = _evt_system_call;
1004 /* Set orig_p0 to -1 to indicate this isn't the end of a syscall. */
1006 [sp + PT_ORIG_P0] = r0;
1009 [sp + PT_RESERVED] = p1;
1012 GET_PDA(p0, r0); /* Fetch current PDA (can't migrate to other CPU here) */
1013 r0 = [p0 + PDA_IRQFLAGS];
1015 p0.l = _bfin_irq_flags;
1016 p0.h = _bfin_irq_flags;
1021 /* finish the userspace "atomic" functions for it */
1022 r1 = FIXED_CODE_END;
1025 if cc jump .Lresume_userspace (bp);
1029 call _finish_atomic_sections;
1031 jump.s .Lresume_userspace;
1032 ENDPROC(_schedule_and_signal_from_int)
1034 ENTRY(_schedule_and_signal)
1035 SAVE_CONTEXT_SYSCALL
1036 /* To end up here, vector 15 was changed - so we have to change it
1041 p1.l = _evt_system_call;
1042 p1.h = _evt_system_call;
1047 [sp + PT_RESERVED] = P0;
1048 call .Lresume_userspace;
1052 ENDPROC(_schedule_and_signal)
1054 /* We handle this 100% in exception space - to reduce overhead
1055 * Only potiential problem is if the software buffer gets swapped out of the
1056 * CPLB table - then double fault. - so we don't let this happen in other places
1058 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
1059 ENTRY(_ex_trace_buff_full)
1065 P5.L = _trace_buff_offset;
1066 P5.H = _trace_buff_offset;
1067 P3 = [P5]; /* trace_buff_offset */
1068 P5.L = lo(TBUFSTAT);
1069 P5.H = hi(TBUFSTAT);
1071 R7 <<= 1; /* double, since we need to read twice */
1073 R7 <<= 2; /* need to shift over again,
1074 * to get the number of bytes */
1077 R6 = ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN)*1024) - 1;
1084 P2.L = _trace_buff_offset;
1085 P2.H = _trace_buff_offset;
1088 P2.L = _software_trace_buff;
1089 P2.H = _software_trace_buff;
1091 LSETUP (.Lstart, .Lend) LC0;
1093 R7 = [P5]; /* read TBUF */
1107 jump _bfin_return_from_exception;
1108 ENDPROC(_ex_trace_buff_full)
1110 #if CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN == 4
1114 #endif /* CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN */
1115 ENTRY(_trace_buff_offset)
1118 ENTRY(_software_trace_buff)
1119 .rept ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN)*256);
1122 #endif /* CONFIG_DEBUG_BFIN_HWTRACE_EXPAND */
1124 #if CONFIG_EARLY_PRINTK
1128 trace_buffer_stop(p0,r0);
1130 ANOMALY_283_315_WORKAROUND(p4, r5)
1132 /* Turn caches off, to ensure we don't get double exceptions */
1134 P4.L = LO(IMEM_CONTROL);
1135 P4.H = HI(IMEM_CONTROL);
1137 R5 = [P4]; /* Control Register*/
1138 BITCLR(R5,ENICPLB_P);
1139 CSYNC; /* Disabling of CPLBs should be proceeded by a CSYNC */
1143 P4.L = LO(DMEM_CONTROL);
1144 P4.H = HI(DMEM_CONTROL);
1146 BITCLR(R5,ENDCPLB_P);
1147 CSYNC; /* Disabling of CPLBs should be proceeded by a CSYNC */
1151 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
1157 ENDPROC(_early_trap)
1159 #endif /* CONFIG_EARLY_PRINTK */
1162 * Put these in the kernel data section - that should always be covered by
1163 * a CPLB. This is needed to ensure we don't get double fault conditions
1166 #ifdef CONFIG_SYSCALL_TAB_L1
1173 /* entry for each EXCAUSE[5:0]
1174 * This table must be in sync with the table in ./kernel/traps.c
1175 * EXCPT instruction can provide 4 bits of EXCAUSE, allowing 16 to be user defined
1177 .long _ex_syscall /* 0x00 - User Defined - Linux Syscall */
1178 .long _ex_trap_c /* 0x01 - User Defined - Software breakpoint */
1180 .long _ex_trap_c /* 0x02 - User Defined - KGDB initial connection
1181 and break signal trap */
1183 .long _ex_replaceable /* 0x02 - User Defined */
1185 .long _ex_trap_c /* 0x03 - User Defined - userspace stack overflow */
1186 .long _ex_trap_c /* 0x04 - User Defined - dump trace buffer */
1187 .long _ex_replaceable /* 0x05 - User Defined */
1188 .long _ex_replaceable /* 0x06 - User Defined */
1189 .long _ex_replaceable /* 0x07 - User Defined */
1190 .long _ex_replaceable /* 0x08 - User Defined */
1191 .long _ex_replaceable /* 0x09 - User Defined */
1192 .long _ex_replaceable /* 0x0A - User Defined */
1193 .long _ex_replaceable /* 0x0B - User Defined */
1194 .long _ex_replaceable /* 0x0C - User Defined */
1195 .long _ex_replaceable /* 0x0D - User Defined */
1196 .long _ex_replaceable /* 0x0E - User Defined */
1197 .long _ex_replaceable /* 0x0F - User Defined */
1198 .long _ex_single_step /* 0x10 - HW Single step */
1199 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
1200 .long _ex_trace_buff_full /* 0x11 - Trace Buffer Full */
1202 .long _ex_trap_c /* 0x11 - Trace Buffer Full */
1204 .long _ex_trap_c /* 0x12 - Reserved */
1205 .long _ex_trap_c /* 0x13 - Reserved */
1206 .long _ex_trap_c /* 0x14 - Reserved */
1207 .long _ex_trap_c /* 0x15 - Reserved */
1208 .long _ex_trap_c /* 0x16 - Reserved */
1209 .long _ex_trap_c /* 0x17 - Reserved */
1210 .long _ex_trap_c /* 0x18 - Reserved */
1211 .long _ex_trap_c /* 0x19 - Reserved */
1212 .long _ex_trap_c /* 0x1A - Reserved */
1213 .long _ex_trap_c /* 0x1B - Reserved */
1214 .long _ex_trap_c /* 0x1C - Reserved */
1215 .long _ex_trap_c /* 0x1D - Reserved */
1216 .long _ex_trap_c /* 0x1E - Reserved */
1217 .long _ex_trap_c /* 0x1F - Reserved */
1218 .long _ex_trap_c /* 0x20 - Reserved */
1219 .long _ex_trap_c /* 0x21 - Undefined Instruction */
1220 .long _ex_trap_c /* 0x22 - Illegal Instruction Combination */
1221 .long _ex_dviol /* 0x23 - Data CPLB Protection Violation */
1222 .long _ex_trap_c /* 0x24 - Data access misaligned */
1223 .long _ex_trap_c /* 0x25 - Unrecoverable Event */
1224 .long _ex_dmiss /* 0x26 - Data CPLB Miss */
1225 .long _ex_dmult /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero */
1226 .long _ex_trap_c /* 0x28 - Emulation Watchpoint */
1227 .long _ex_trap_c /* 0x29 - Instruction fetch access error (535 only) */
1228 .long _ex_trap_c /* 0x2A - Instruction fetch misaligned */
1229 .long _ex_trap_c /* 0x2B - Instruction CPLB protection Violation */
1230 .long _ex_icplb_miss /* 0x2C - Instruction CPLB miss */
1231 .long _ex_trap_c /* 0x2D - Instruction CPLB Multiple Hits */
1232 .long _ex_trap_c /* 0x2E - Illegal use of Supervisor Resource */
1233 .long _ex_trap_c /* 0x2E - Illegal use of Supervisor Resource */
1234 .long _ex_trap_c /* 0x2F - Reserved */
1235 .long _ex_trap_c /* 0x30 - Reserved */
1236 .long _ex_trap_c /* 0x31 - Reserved */
1237 .long _ex_trap_c /* 0x32 - Reserved */
1238 .long _ex_trap_c /* 0x33 - Reserved */
1239 .long _ex_trap_c /* 0x34 - Reserved */
1240 .long _ex_trap_c /* 0x35 - Reserved */
1241 .long _ex_trap_c /* 0x36 - Reserved */
1242 .long _ex_trap_c /* 0x37 - Reserved */
1243 .long _ex_trap_c /* 0x38 - Reserved */
1244 .long _ex_trap_c /* 0x39 - Reserved */
1245 .long _ex_trap_c /* 0x3A - Reserved */
1246 .long _ex_trap_c /* 0x3B - Reserved */
1247 .long _ex_trap_c /* 0x3C - Reserved */
1248 .long _ex_trap_c /* 0x3D - Reserved */
1249 .long _ex_trap_c /* 0x3E - Reserved */
1250 .long _ex_trap_c /* 0x3F - Reserved */
1253 ENTRY(_sys_call_table)
1254 .long _sys_restart_syscall /* 0 */
1259 .long _sys_open /* 5 */
1261 .long _sys_ni_syscall /* old waitpid */
1264 .long _sys_unlink /* 10 */
1269 .long _sys_chmod /* 15 */
1270 .long _sys_chown /* chown16 */
1271 .long _sys_ni_syscall /* old break syscall holder */
1272 .long _sys_ni_syscall /* old stat */
1274 .long _sys_getpid /* 20 */
1276 .long _sys_ni_syscall /* old umount */
1279 .long _sys_stime /* 25 */
1282 .long _sys_ni_syscall /* old fstat */
1284 .long _sys_ni_syscall /* old utime */ /* 30 */
1285 .long _sys_ni_syscall /* old stty syscall holder */
1286 .long _sys_ni_syscall /* old gtty syscall holder */
1289 .long _sys_ni_syscall /* 35 */ /* old ftime syscall holder */
1294 .long _sys_rmdir /* 40 */
1298 .long _sys_ni_syscall /* old prof syscall holder */
1299 .long _sys_brk /* 45 */
1302 .long _sys_ni_syscall /* old sys_signal */
1303 .long _sys_geteuid /* geteuid16 */
1304 .long _sys_getegid /* getegid16 */ /* 50 */
1306 .long _sys_umount /* recycled never used phys() */
1307 .long _sys_ni_syscall /* old lock syscall holder */
1309 .long _sys_fcntl /* 55 */
1310 .long _sys_ni_syscall /* old mpx syscall holder */
1312 .long _sys_ni_syscall /* old ulimit syscall holder */
1313 .long _sys_ni_syscall /* old old uname */
1314 .long _sys_umask /* 60 */
1319 .long _sys_getpgrp /* 65 */
1321 .long _sys_ni_syscall /* old sys_sigaction */
1324 .long _sys_setreuid /* setreuid16 */ /* 70 */
1325 .long _sys_setregid /* setregid16 */
1326 .long _sys_ni_syscall /* old sys_sigsuspend */
1327 .long _sys_ni_syscall /* old sys_sigpending */
1328 .long _sys_sethostname
1329 .long _sys_setrlimit /* 75 */
1330 .long _sys_ni_syscall /* old getrlimit */
1331 .long _sys_getrusage
1332 .long _sys_gettimeofday
1333 .long _sys_settimeofday
1334 .long _sys_getgroups /* getgroups16 */ /* 80 */
1335 .long _sys_setgroups /* setgroups16 */
1336 .long _sys_ni_syscall /* old_select */
1338 .long _sys_ni_syscall /* old lstat */
1339 .long _sys_readlink /* 85 */
1341 .long _sys_ni_syscall /* sys_swapon */
1343 .long _sys_ni_syscall /* old_readdir */
1344 .long _sys_ni_syscall /* sys_mmap */ /* 90 */
1347 .long _sys_ftruncate
1349 .long _sys_fchown /* fchown16 */ /* 95 */
1350 .long _sys_getpriority
1351 .long _sys_setpriority
1352 .long _sys_ni_syscall /* old profil syscall holder */
1354 .long _sys_fstatfs /* 100 */
1355 .long _sys_ni_syscall
1356 .long _sys_ni_syscall /* old sys_socketcall */
1358 .long _sys_setitimer
1359 .long _sys_getitimer /* 105 */
1363 .long _sys_ni_syscall /* old uname */
1364 .long _sys_ni_syscall /* iopl for i386 */ /* 110 */
1366 .long _sys_ni_syscall /* obsolete idle() syscall */
1367 .long _sys_ni_syscall /* vm86old for i386 */
1369 .long _sys_ni_syscall /* 115 */ /* sys_swapoff */
1371 .long _sys_ni_syscall /* old sys_ipc */
1373 .long _sys_ni_syscall /* old sys_sigreturn */
1374 .long _sys_clone /* 120 */
1375 .long _sys_setdomainname
1377 .long _sys_ni_syscall /* old sys_modify_ldt */
1379 .long _sys_ni_syscall /* 125 */ /* sys_mprotect */
1380 .long _sys_ni_syscall /* old sys_sigprocmask */
1381 .long _sys_ni_syscall /* old "creat_module" */
1382 .long _sys_init_module
1383 .long _sys_delete_module
1384 .long _sys_ni_syscall /* 130: old "get_kernel_syms" */
1389 .long _sys_ni_syscall /* 135 */ /* sys_sysfs */
1390 .long _sys_personality
1391 .long _sys_ni_syscall /* for afs_syscall */
1392 .long _sys_setfsuid /* setfsuid16 */
1393 .long _sys_setfsgid /* setfsgid16 */
1394 .long _sys_llseek /* 140 */
1396 .long _sys_ni_syscall /* sys_select */
1398 .long _sys_ni_syscall /* sys_msync */
1399 .long _sys_readv /* 145 */
1402 .long _sys_fdatasync
1404 .long _sys_ni_syscall /* 150 */ /* sys_mlock */
1405 .long _sys_ni_syscall /* sys_munlock */
1406 .long _sys_ni_syscall /* sys_mlockall */
1407 .long _sys_ni_syscall /* sys_munlockall */
1408 .long _sys_sched_setparam
1409 .long _sys_sched_getparam /* 155 */
1410 .long _sys_sched_setscheduler
1411 .long _sys_sched_getscheduler
1412 .long _sys_sched_yield
1413 .long _sys_sched_get_priority_max
1414 .long _sys_sched_get_priority_min /* 160 */
1415 .long _sys_sched_rr_get_interval
1416 .long _sys_nanosleep
1418 .long _sys_setresuid /* setresuid16 */
1419 .long _sys_getresuid /* getresuid16 */ /* 165 */
1420 .long _sys_ni_syscall /* for vm86 */
1421 .long _sys_ni_syscall /* old "query_module" */
1422 .long _sys_ni_syscall /* sys_poll */
1423 .long _sys_nfsservctl
1424 .long _sys_setresgid /* setresgid16 */ /* 170 */
1425 .long _sys_getresgid /* getresgid16 */
1427 .long _sys_rt_sigreturn
1428 .long _sys_rt_sigaction
1429 .long _sys_rt_sigprocmask /* 175 */
1430 .long _sys_rt_sigpending
1431 .long _sys_rt_sigtimedwait
1432 .long _sys_rt_sigqueueinfo
1433 .long _sys_rt_sigsuspend
1434 .long _sys_pread64 /* 180 */
1436 .long _sys_lchown /* lchown16 */
1439 .long _sys_capset /* 185 */
1440 .long _sys_sigaltstack
1442 .long _sys_ni_syscall /* streams1 */
1443 .long _sys_ni_syscall /* streams2 */
1444 .long _sys_vfork /* 190 */
1445 .long _sys_getrlimit
1447 .long _sys_truncate64
1448 .long _sys_ftruncate64
1449 .long _sys_stat64 /* 195 */
1454 .long _sys_getgid /* 200 */
1459 .long _sys_getgroups /* 205 */
1460 .long _sys_setgroups
1462 .long _sys_setresuid
1463 .long _sys_getresuid
1464 .long _sys_setresgid /* 210 */
1465 .long _sys_getresgid
1469 .long _sys_setfsuid /* 215 */
1471 .long _sys_pivot_root
1472 .long _sys_ni_syscall /* sys_mincore */
1473 .long _sys_ni_syscall /* sys_madvise */
1474 .long _sys_getdents64 /* 220 */
1476 .long _sys_ni_syscall /* reserved for TUX */
1477 .long _sys_ni_syscall
1479 .long _sys_readahead /* 225 */
1481 .long _sys_lsetxattr
1482 .long _sys_fsetxattr
1484 .long _sys_lgetxattr /* 230 */
1485 .long _sys_fgetxattr
1486 .long _sys_listxattr
1487 .long _sys_llistxattr
1488 .long _sys_flistxattr
1489 .long _sys_removexattr /* 235 */
1490 .long _sys_lremovexattr
1491 .long _sys_fremovexattr
1493 .long _sys_sendfile64
1494 .long _sys_futex /* 240 */
1495 .long _sys_sched_setaffinity
1496 .long _sys_sched_getaffinity
1497 .long _sys_ni_syscall /* sys_set_thread_area */
1498 .long _sys_ni_syscall /* sys_get_thread_area */
1499 .long _sys_io_setup /* 245 */
1500 .long _sys_io_destroy
1501 .long _sys_io_getevents
1502 .long _sys_io_submit
1503 .long _sys_io_cancel
1504 .long _sys_ni_syscall /* 250 */ /* sys_alloc_hugepages */
1505 .long _sys_ni_syscall /* sys_freec_hugepages */
1506 .long _sys_exit_group
1507 .long _sys_lookup_dcookie
1508 .long _sys_bfin_spinlock
1509 .long _sys_epoll_create /* 255 */
1510 .long _sys_epoll_ctl
1511 .long _sys_epoll_wait
1512 .long _sys_ni_syscall /* remap_file_pages */
1513 .long _sys_set_tid_address
1514 .long _sys_timer_create /* 260 */
1515 .long _sys_timer_settime
1516 .long _sys_timer_gettime
1517 .long _sys_timer_getoverrun
1518 .long _sys_timer_delete
1519 .long _sys_clock_settime /* 265 */
1520 .long _sys_clock_gettime
1521 .long _sys_clock_getres
1522 .long _sys_clock_nanosleep
1524 .long _sys_fstatfs64 /* 270 */
1527 .long _sys_fadvise64_64
1528 .long _sys_ni_syscall /* vserver */
1529 .long _sys_ni_syscall /* 275, mbind */
1530 .long _sys_ni_syscall /* get_mempolicy */
1531 .long _sys_ni_syscall /* set_mempolicy */
1533 .long _sys_mq_unlink
1534 .long _sys_mq_timedsend /* 280 */
1535 .long _sys_mq_timedreceive
1536 .long _sys_mq_notify
1537 .long _sys_mq_getsetattr
1538 .long _sys_ni_syscall /* kexec_load */
1539 .long _sys_waitid /* 285 */
1541 .long _sys_request_key
1543 .long _sys_ioprio_set
1544 .long _sys_ioprio_get /* 290 */
1545 .long _sys_inotify_init
1546 .long _sys_inotify_add_watch
1547 .long _sys_inotify_rm_watch
1548 .long _sys_ni_syscall /* migrate_pages */
1549 .long _sys_openat /* 295 */
1553 .long _sys_futimesat
1554 .long _sys_fstatat64 /* 300 */
1558 .long _sys_symlinkat
1559 .long _sys_readlinkat /* 305 */
1561 .long _sys_faccessat
1564 .long _sys_unshare /* 310 */
1565 .long _sys_sram_alloc
1566 .long _sys_sram_free
1567 .long _sys_dma_memcpy
1569 .long _sys_bind /* 315 */
1571 .long _sys_getpeername
1572 .long _sys_getsockname
1573 .long _sys_getsockopt
1574 .long _sys_listen /* 320 */
1579 .long _sys_sendmsg /* 325 */
1581 .long _sys_setsockopt
1584 .long _sys_socketpair /* 330 */
1589 .long _sys_msgget /* 335 */
1594 .long _sys_shmdt /* 340 */
1597 .long _sys_sync_file_range
1599 .long _sys_vmsplice /* 345 */
1600 .long _sys_epoll_pwait
1601 .long _sys_utimensat
1603 .long _sys_timerfd_create
1604 .long _sys_eventfd /* 350 */
1607 .long _sys_fadvise64
1608 .long _sys_set_robust_list
1609 .long _sys_get_robust_list /* 355 */
1610 .long _sys_fallocate
1611 .long _sys_semtimedop
1612 .long _sys_timerfd_settime
1613 .long _sys_timerfd_gettime
1614 .long _sys_signalfd4 /* 360 */
1616 .long _sys_epoll_create1
1619 .long _sys_inotify_init1 /* 365 */
1622 .long _sys_rt_tgsigqueueinfo
1623 .long _sys_perf_event_open
1625 .rept NR_syscalls-(.-_sys_call_table)/4
1626 .long _sys_ni_syscall
1628 END(_sys_call_table)