2 * Contains the system-call and fault low-level handling routines.
3 * This also contains the timer-interrupt handler, as well as all
4 * interrupts and faults that can result in a task-switch.
6 * Copyright 2005-2009 Analog Devices Inc.
8 * Licensed under the GPL-2 or later.
11 /* NOTE: This code handles signal-recognition, which happens every time
12 * after a timer-interrupt and after each system call.
15 #include <linux/init.h>
16 #include <linux/linkage.h>
17 #include <linux/unistd.h>
18 #include <asm/blackfin.h>
19 #include <asm/errno.h>
20 #include <asm/fixed_code.h>
21 #include <asm/thread_info.h> /* TIF_NEED_RESCHED */
22 #include <asm/asm-offsets.h>
23 #include <asm/trace.h>
24 #include <asm/traps.h>
26 #include <asm/context.S>
29 #ifdef CONFIG_EXCPT_IRQ_SYSC_L1
35 /* Slightly simplified and streamlined entry point for CPLB misses.
36 * This one does not lower the level to IRQ5, and thus can be used to
37 * patch up CPLB misses on the kernel stack.
40 #define _ex_dviol _ex_workaround_261
41 #define _ex_dmiss _ex_workaround_261
42 #define _ex_dmult _ex_workaround_261
44 ENTRY(_ex_workaround_261)
46 * Work around an anomaly: if we see a new DCPLB fault, return
47 * without doing anything. Then, if we get the same fault again,
50 P4 = R7; /* Store EXCAUSE */
53 r7 = [p5 + PDA_LFRETX];
55 [p5 + PDA_LFRETX] = r6;
57 if !cc jump _bfin_return_from_exception;
60 R6 = VEC_CPLB_M; /* Data CPLB Miss */
62 if cc jump _ex_dcplb_miss (BP);
64 R6 = VEC_CPLB_VL; /* Data CPLB Violation */
66 if cc jump _ex_dcplb_viol (BP);
68 /* Handle Data CPLB Protection Violation
69 * and Data CPLB Multiple Hits - Linux Trap Zero
72 ENDPROC(_ex_workaround_261)
76 #define _ex_dviol _ex_dcplb_viol
78 #define _ex_dviol _ex_trap_c
80 #define _ex_dmiss _ex_dcplb_miss
81 #define _ex_dmult _ex_trap_c
89 /* We leave the previously pushed ASTAT on the stack. */
92 /* We must load R1 here, _before_ DEBUG_HWTRACE_SAVE, since that
93 * will change the stack pointer. */
97 DEBUG_HWTRACE_SAVE(p5, r7)
103 IF !CC JUMP _handle_bad_cplb;
105 #ifdef CONFIG_DEBUG_DOUBLEFAULT
106 /* While we were processing this, did we double fault? */
107 r7 = SEQSTAT; /* reason code is in bit 5:0 */
108 r6.l = lo(SEQSTAT_EXCAUSE);
109 r6.h = hi(SEQSTAT_EXCAUSE);
113 if CC JUMP _double_fault;
116 DEBUG_HWTRACE_RESTORE(p5, r7)
121 ENDPROC(_ex_icplb_miss)
124 raise 15; /* invoked by TRAP #0, for sys call */
125 jump.s _bfin_return_from_exception;
128 ENTRY(_ex_single_step)
129 /* If we just returned from an interrupt, the single step event is
130 for the RTI instruction. */
134 if cc jump _bfin_return_from_exception;
137 /* Don't do single step in hardware exception handler */
142 if cc jump _bfin_return_from_exception;
144 if cc jump _bfin_return_from_exception;
146 /* skip single step if current interrupt priority is higher than
147 * that of the first instruction, from which gdb starts single step */
150 .Lfind_priority_start:
152 if cc jump .Lfind_priority_done;
156 if cc jump .Lfind_priority_done;
157 jump.s .Lfind_priority_start;
158 .Lfind_priority_done:
159 p4.l = _kgdb_single_step;
160 p4.h = _kgdb_single_step;
163 if cc jump .Ldo_single_step;
169 /* If we were in user mode, do the single step normally. */
178 #ifdef CONFIG_EXACT_HWERR
179 /* Read the ILAT, and to check to see if the process we are
180 * single stepping caused a previous hardware error
181 * If so, do not single step, (which lowers to IRQ5, and makes
182 * us miss the error).
187 cc = bittst(r7, EVT_IVHW_P);
190 /* Single stepping only a single instruction, so clear the trace
193 bitclr (r7, SYSCFG_SSSTEP_P);
199 * We were in an interrupt handler. By convention, all of them save
200 * SYSCFG with their first instruction, so by checking whether our
201 * RETX points at the entry point, we can determine whether to allow
202 * a single step, or whether to clear SYSCFG.
204 * First, find out the interrupt level and the event vector for it.
214 /* What we actually do is test for the _second_ instruction in the
215 * IRQ handler. That way, if there are insns following the restore
216 * of SYSCFG after leaving the handler, we will not turn off SYSCFG
223 if !cc jump _bfin_return_from_exception;
226 bitclr (r7, SYSCFG_SSSTEP_P); /* Turn off single step */
229 /* Fall through to _bfin_return_from_exception. */
230 ENDPROC(_ex_single_step)
232 ENTRY(_bfin_return_from_exception)
240 #ifdef CONFIG_DEBUG_DOUBLEFAULT
241 /* While we were processing the current exception,
242 * did we cause another, and double fault?
244 r7 = SEQSTAT; /* reason code is in bit 5:0 */
245 r6.l = lo(SEQSTAT_EXCAUSE);
246 r6.h = hi(SEQSTAT_EXCAUSE);
250 if CC JUMP _double_fault;
253 (R7:6,P5:4) = [sp++];
257 ENDPROC(_bfin_return_from_exception)
259 ENTRY(_handle_bad_cplb)
260 DEBUG_HWTRACE_RESTORE(p5, r7)
261 /* To get here, we just tried and failed to change a CPLB
262 * so, handle things in trap_c (C code), by lowering to
263 * IRQ5, just like we normally do. Since this is not a
264 * "normal" return path, we have a do a lot of stuff to
265 * the stack to get ready so, we can fall through - we
266 * need to make a CPLB exception look like a normal exception
269 /* ASTAT is still on the stack, where it is needed. */
270 [--sp] = (R7:6,P5:4);
272 ENTRY(_ex_replaceable)
276 /* The only thing that has been saved in this context is
277 * (R7:6,P5:4), ASTAT & SP - don't use anything else
282 /* Make sure we are not in a double fault */
287 if CC jump _double_fault;
288 [p5 + PDA_EXIPEND] = r7;
290 /* Call C code (trap_c) to handle the exception, which most
291 * likely involves sending a signal to the current process.
292 * To avoid double faults, lower our priority to IRQ5 first.
294 r7.h = _exception_to_level5;
295 r7.l = _exception_to_level5;
302 * Save these registers, as they are only valid in exception context
303 * (where we are now - as soon as we defer to IRQ5, they can change)
304 * DCPLB_STATUS and ICPLB_STATUS are also only valid in EVT3,
305 * but they are not very interesting, so don't save them
308 p4.l = lo(DCPLB_FAULT_ADDR);
309 p4.h = hi(DCPLB_FAULT_ADDR);
311 [p5 + PDA_DCPLB] = r7;
313 p4.l = lo(ICPLB_FAULT_ADDR);
314 p4.h = hi(ICPLB_FAULT_ADDR);
316 [p5 + PDA_ICPLB] = r6;
319 [p5 + PDA_RETX] = r6;
322 [p5 + PDA_SEQSTAT] = r6;
324 /* Save the state of single stepping */
326 [p5 + PDA_SYSCFG] = r6;
327 /* Clear it while we handle the exception in IRQ5 mode */
328 BITCLR(r6, SYSCFG_SSSTEP_P);
331 /* Save the current IMASK, since we change in order to jump to level 5 */
333 [p5 + PDA_EXIMASK] = r6;
335 p4.l = lo(SAFE_USER_INSTRUCTION);
336 p4.h = hi(SAFE_USER_INSTRUCTION);
339 /* Disable all interrupts, but make sure level 5 is enabled so
340 * we can switch to that level.
345 /* In case interrupts are disabled IPEND[4] (global interrupt disable bit)
346 * clear it (re-enabling interrupts again) by the special sequence of pushing
347 * RETI onto the stack. This way we can lower ourselves to IVG5 even if the
348 * exception was taken after the interrupt handler was called but before it
349 * got a chance to enable global interrupts itself.
355 jump.s _bfin_return_from_exception;
358 /* We just realized we got an exception, while we were processing a different
359 * exception. This is a unrecoverable event, so crash.
360 * Note: this cannot be ENTRY() as we jump here with "if cc jump" ...
363 /* Turn caches & protection off, to ensure we don't get any more
367 P4.L = LO(IMEM_CONTROL);
368 P4.H = HI(IMEM_CONTROL);
370 R5 = [P4]; /* Control Register*/
371 BITCLR(R5,ENICPLB_P);
372 CSYNC; /* Disabling of CPLBs should be proceeded by a CSYNC */
376 P4.L = LO(DMEM_CONTROL);
377 P4.H = HI(DMEM_CONTROL);
379 BITCLR(R5,ENDCPLB_P);
380 CSYNC; /* Disabling of CPLBs should be proceeded by a CSYNC */
384 /* Fix up the stack */
385 (R7:6,P5:4) = [sp++];
389 /* We should be out of the exception stack, and back down into
390 * kernel or user space stack
394 /* The dumping functions expect the return address in the RETI
399 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
401 pseudo_long_call _double_fault_c, p5;
403 .L_double_fault_panic:
404 JUMP .L_double_fault_panic
406 ENDPROC(_double_fault)
408 ENTRY(_exception_to_level5)
411 GET_PDA(p5, r7); /* Fetch current PDA */
412 r6 = [p5 + PDA_RETX];
415 r6 = [p5 + PDA_SYSCFG];
416 [sp + PT_SYSCFG] = r6;
418 r6 = [p5 + PDA_SEQSTAT]; /* Read back seqstat */
419 [sp + PT_SEQSTAT] = r6;
421 /* Restore the hardware error vector. */
429 #ifdef CONFIG_DEBUG_DOUBLEFAULT
430 /* Now that we have the hardware error vector programmed properly
431 * we can re-enable interrupts (IPEND[4]), so if the _trap_c causes
432 * another hardware error, we can catch it (self-nesting).
438 r7 = [p5 + PDA_EXIPEND] /* Read the IPEND from the Exception state */
439 [sp + PT_IPEND] = r7; /* Store IPEND onto the stack */
441 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
443 pseudo_long_call _trap_c, p4;
446 /* If interrupts were off during the exception (IPEND[4] = 1), turn them off
449 CC = BITTST(r7, EVT_IRPTEN_P)
451 /* this will load a random value into the reti register - but that is OK,
452 * since we do restore it to the correct value in the 'RESTORE_ALL_SYS' macro
457 /* restore the interrupt mask (IMASK) */
458 r6 = [p5 + PDA_EXIMASK];
461 call _ret_from_exception;
464 ENDPROC(_exception_to_level5)
466 ENTRY(_trap) /* Exception: 4th entry into system event table(supervisor mode)*/
467 /* Since the kernel stack can be anywhere, it's not guaranteed to be
468 * covered by a CPLB. Switch to an exception stack; use RETN as a
469 * scratch register (for want of a better option).
473 sp = [sp + PDA_EXSTACK];
474 /* Try to deal with syscalls quickly. */
476 [--sp] = (R7:6,P5:4);
478 ANOMALY_283_315_WORKAROUND(p5, r7)
480 #ifdef CONFIG_EXACT_HWERR
481 /* Make sure all pending read/writes complete. This will ensure any
482 * accesses which could cause hardware errors completes, and signal
483 * the the hardware before we do something silly, like crash the
484 * kernel. We don't need to work around anomaly 05000312, since
485 * we are already atomic
490 #ifdef CONFIG_DEBUG_DOUBLEFAULT
492 * Save these registers, as they are only valid in exception context
493 * (where we are now - as soon as we defer to IRQ5, they can change)
494 * DCPLB_STATUS and ICPLB_STATUS are also only valid in EVT3,
495 * but they are not very interesting, so don't save them
499 p4.l = lo(DCPLB_FAULT_ADDR);
500 p4.h = hi(DCPLB_FAULT_ADDR);
502 [p5 + PDA_DF_DCPLB] = r7;
504 p4.l = lo(ICPLB_FAULT_ADDR);
505 p4.h = hi(ICPLB_FAULT_ADDR);
507 [p5 + PDA_DF_ICPLB] = r7;
510 [p5 + PDA_DF_RETX] = r7;
512 r7 = SEQSTAT; /* reason code is in bit 5:0 */
513 [p5 + PDA_DF_SEQSTAT] = r7;
515 r7 = SEQSTAT; /* reason code is in bit 5:0 */
517 r6.l = lo(SEQSTAT_EXCAUSE);
518 r6.h = hi(SEQSTAT_EXCAUSE);
528 r7 = -ENOSYS; /* signextending enough */
529 [sp + PT_R0] = r7; /* return value from system call */
530 jump .Lsyscall_really_exit;
533 ENTRY(_kernel_execve)
536 r3 = SIZEOF_PTREGS / 4;
542 if !cc jump .Lclear_regs (bp);
547 pseudo_long_call _do_execve, p5;
550 if ! cc jump .Lexecve_failed;
551 /* Success. Copy our temporary pt_regs to the top of the kernel
552 * stack and do a normal exception return.
555 r0 = (-KERNEL_STACK_SIZE) (x);
559 r0 = KERNEL_STACK_SIZE - 4 (z);
565 r3 = SIZEOF_PTREGS / 4;
571 if ! cc jump .Lcopy_regs (bp);
573 r0 = (KERNEL_STACK_SIZE - SIZEOF_PTREGS) (z);
578 [SP + PT_SYSCFG] = r0;
579 [p3 + (TASK_THREAD + THREAD_KSP)] = sp;
586 ENDPROC(_kernel_execve)
594 [sp + PT_IPEND] = r0;
596 /* Store RETS for now */
598 [sp + PT_RESERVED] = r0;
599 /* Set the stack for the current process */
601 r6.l = lo(ALIGN_PAGE_MASK);
602 r6.h = hi(ALIGN_PAGE_MASK);
603 r7 = r7 & r6; /* thread_info */
607 [p2+(TASK_THREAD+THREAD_KSP)] = sp;
611 pseudo_long_call ___ipipe_syscall_root, p0;
614 if cc jump .Lsyscall_really_exit;
616 if cc jump .Lresume_userspace;
619 p0 = [sp + PT_ORIG_P0];
620 #endif /* CONFIG_IPIPE */
622 /* are we tracing syscalls?*/
624 r6.l = lo(ALIGN_PAGE_MASK);
625 r6.h = hi(ALIGN_PAGE_MASK);
629 CC = BITTST(r7,TIF_SYSCALL_TRACE);
630 if CC JUMP _sys_trace;
631 CC = BITTST(r7,TIF_SINGLESTEP);
632 if CC JUMP _sys_trace;
634 /* Make sure the system call # is valid */
636 /* System call number is passed in P0 */
640 /* Execute the appropriate system call */
643 p5.l = _sys_call_table;
644 p5.h = _sys_call_table;
661 r4.l = lo(ALIGN_PAGE_MASK);
662 r4.h = hi(ALIGN_PAGE_MASK);
663 r7 = r7 & r4; /* thread_info->flags */
665 .Lresume_userspace_1:
666 /* Disable interrupts. */
670 r7 = [p5 + TI_FLAGS];
671 r4.l = lo(_TIF_WORK_MASK);
672 r4.h = hi(_TIF_WORK_MASK);
677 cc = BITTST(r7, TIF_IRQ_SYNC);
678 if !cc jump .Lsyscall_no_irqsync;
680 * Clear IPEND[4] manually to undo what resume_userspace_1 just did;
681 * we need this so that high priority domain interrupts may still
682 * preempt the current domain while the pipeline log is being played
686 SP += 4; /* don't merge with next insn to keep the pattern obvious */
688 pseudo_long_call ___ipipe_sync_root, p4;
690 jump .Lresume_userspace_1;
691 .Lsyscall_no_irqsync:
693 cc = BITTST(r7, TIF_NEED_RESCHED);
694 if !cc jump .Lsyscall_sigpending;
696 /* Reenable interrupts. */
701 pseudo_long_call _schedule, p4;
704 jump .Lresume_userspace_1;
706 .Lsyscall_sigpending:
707 cc = BITTST(r7, TIF_SIGPENDING);
708 if cc jump .Lsyscall_do_signals;
709 cc = BITTST(r7, TIF_NOTIFY_RESUME);
710 if !cc jump .Lsyscall_really_exit;
711 .Lsyscall_do_signals:
712 /* Reenable interrupts. */
718 pseudo_long_call _do_notify_resume, p5;
721 .Lsyscall_really_exit:
722 r5 = [sp + PT_RESERVED];
725 ENDPROC(_system_call)
727 /* Do not mark as ENTRY() to avoid error in assembler ...
728 * this symbol need not be global anyways, so ...
732 pseudo_long_call _syscall_trace_enter, p5;
734 /* Make sure the system call # is valid */
739 if cc jump .Lsys_trace_badsys;
741 /* Execute the appropriate system call */
742 p5.l = _sys_call_table;
743 p5.h = _sys_call_table;
763 pseudo_long_call _syscall_trace_leave, p5;
764 jump .Lresume_userspace;
769 * Beware - when entering resume, prev (the current task) is
770 * in r0, next (the new task) is in r1.
776 [--sp] = (r7:4, p5:3);
780 [p0+(TASK_THREAD+THREAD_USP)] = p2;
782 /* save current kernel stack pointer */
783 [p0+(TASK_THREAD+THREAD_KSP)] = sp;
785 /* save program counter */
786 r1.l = _new_old_task;
787 r1.h = _new_old_task;
788 [p0+(TASK_THREAD+THREAD_PC)] = r1;
790 /* restore the kernel stack pointer */
791 sp = [p1+(TASK_THREAD+THREAD_KSP)];
793 /* restore user stack pointer */
794 p0 = [p1+(TASK_THREAD+THREAD_USP)];
798 p0 = [p1+(TASK_THREAD+THREAD_PC)];
802 * Following code actually lands up in a new (old) task.
806 (r7:4, p5:3) = [sp++];
811 * When we come out of resume, r0 carries "old" task, because we are
817 ENTRY(_ret_from_exception)
819 p2.l = _ipipe_percpu_domain;
820 p2.h = _ipipe_percpu_domain;
825 if !cc jump 4f; /* not on behalf of the root domain, get out */
826 #endif /* CONFIG_IPIPE */
832 [sp + PT_IPEND] = r0;
838 if !cc jump 4f; /* if not return to user mode, get out */
840 /* Make sure any pending system call or deferred exception
841 * return in ILAT for this process to get executed, otherwise
842 * in case context switch happens, system call of
843 * first process (i.e in ILAT) will be carried
844 * forward to the switched process
850 r1 = (EVT_IVG14 | EVT_IVG15) (z);
855 /* Set the stack for the current process */
857 r4.l = lo(ALIGN_PAGE_MASK);
858 r4.h = hi(ALIGN_PAGE_MASK);
859 r7 = r7 & r4; /* thread_info->flags */
861 r7 = [p5 + TI_FLAGS];
862 r4.l = lo(_TIF_WORK_MASK);
863 r4.h = hi(_TIF_WORK_MASK);
870 p1.l = _schedule_and_signal;
871 p1.h = _schedule_and_signal;
874 raise 15; /* raise evt15 to do signal or reschedule */
877 bitclr(r0, SYSCFG_SSSTEP_P); /* Turn off single step */
881 ENDPROC(_ret_from_exception)
883 #if defined(CONFIG_PREEMPT)
886 #if ANOMALY_05000281 || ANOMALY_05000461
887 r0.l = lo(SAFE_USER_INSTRUCTION);
888 r0.h = hi(SAFE_USER_INSTRUCTION);
892 #ifdef CONFIG_DEBUG_HWERR
893 /* enable irq14 & hwerr interrupt, until we transition to _evt_evt14 */
894 r0 = (EVT_IVG14 | EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
896 /* Only enable irq14 interrupt, until we transition to _evt_evt14 */
897 r0 = (EVT_IVG14 | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
903 p1.l = _evt_up_evt14;
904 p1.h = _evt_up_evt14;
911 ENDPROC(_up_to_irq14)
914 #ifdef CONFIG_DEBUG_HWERR
915 r0 = (EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
920 #ifdef CONFIG_TRACE_IRQFLAGS
923 call _trace_hardirqs_off;
930 /* restore normal evt14 */
939 ENDPROC(_evt_up_evt14)
945 _resume_kernel_from_int:
946 r1 = LO(~0x8000) (Z);
952 /* Sync the root stage only from the outer interrupt level. */
953 if !cc jump .Lnosync;
954 r0.l = ___ipipe_sync_root;
955 r0.h = ___ipipe_sync_root;
958 [--sp] = ( r7:4, p5:3 );
960 call ___ipipe_call_irqtail
962 ( r7:4, p5:3 ) = [sp++];
967 #elif defined(CONFIG_PREEMPT)
969 _resume_kernel_from_int:
970 /* check preempt_count */
972 r4.l = lo(ALIGN_PAGE_MASK);
973 r4.h = hi(ALIGN_PAGE_MASK);
976 r7 = [p5 + TI_PREEMPT];
978 if !cc jump .Lreturn_to_kernel;
980 r7 = [p5 + TI_FLAGS];
981 r4.l = lo(_TIF_WORK_MASK);
982 r4.h = hi(_TIF_WORK_MASK);
984 cc = BITTST(r7, TIF_NEED_RESCHED);
985 if !cc jump .Lreturn_to_kernel;
987 * let schedule done at level 15, otherwise sheduled process will run
988 * at high level and block low level interrupt
990 r6 = reti; /* save reti */
991 r5.l = .Lkernel_schedule;
992 r5.h = .Lkernel_schedule;
998 pseudo_long_call _preempt_schedule_irq, p4;
1004 /* up to irq14 so that reti after restore_all can return to irq15(kernel) */
1005 pseudo_long_call _up_to_irq14, p4;
1009 reti = r6; /* restore reti so that origin process can return to interrupted point */
1011 jump .Lneed_schedule;
1014 #define _resume_kernel_from_int .Lreturn_to_kernel
1017 ENTRY(_return_from_int)
1018 /* If someone else already raised IRQ 15, do nothing. */
1023 cc = bittst (r0, EVT_IVG15_P);
1024 if cc jump .Lreturn_to_kernel;
1026 /* if not return to user mode, get out */
1038 if !cc jump _resume_kernel_from_int;
1040 /* Lower the interrupt level to 15. */
1043 p1.l = _schedule_and_signal_from_int;
1044 p1.h = _schedule_and_signal_from_int;
1047 #if ANOMALY_05000281 || ANOMALY_05000461
1048 r0.l = lo(SAFE_USER_INSTRUCTION);
1049 r0.h = hi(SAFE_USER_INSTRUCTION);
1054 raise 15; /* raise evt15 to do signal or reschedule */
1058 ENDPROC(_return_from_int)
1060 ENTRY(_lower_to_irq14)
1061 #if ANOMALY_05000281 || ANOMALY_05000461
1062 r0.l = lo(SAFE_USER_INSTRUCTION);
1063 r0.h = hi(SAFE_USER_INSTRUCTION);
1067 #ifdef CONFIG_DEBUG_HWERR
1068 /* enable irq14 & hwerr interrupt, until we transition to _evt_evt14 */
1069 r0 = (EVT_IVG14 | EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
1071 /* Only enable irq14 interrupt, until we transition to _evt_evt14 */
1072 r0 = (EVT_IVG14 | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
1077 ENDPROC(_lower_to_irq14)
1080 #ifdef CONFIG_DEBUG_HWERR
1081 r0 = (EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
1086 #ifdef CONFIG_TRACE_IRQFLAGS
1089 call _trace_hardirqs_off;
1098 ENTRY(_schedule_and_signal_from_int)
1099 /* To end up here, vector 15 was changed - so we have to change it
1104 p1.l = _evt_system_call;
1105 p1.h = _evt_system_call;
1109 /* Set orig_p0 to -1 to indicate this isn't the end of a syscall. */
1111 [sp + PT_ORIG_P0] = r0;
1114 [sp + PT_RESERVED] = p1;
1116 #ifdef CONFIG_TRACE_IRQFLAGS
1117 /* trace_hardirqs_on() checks if all irqs are disabled. But here IRQ 15
1118 * is turned on, so disable all irqs. */
1121 call _trace_hardirqs_on;
1125 GET_PDA(p0, r0); /* Fetch current PDA (can't migrate to other CPU here) */
1126 r0 = [p0 + PDA_IRQFLAGS];
1128 p0.l = _bfin_irq_flags;
1129 p0.h = _bfin_irq_flags;
1134 /* finish the userspace "atomic" functions for it */
1135 r1.l = lo(FIXED_CODE_END);
1136 r1.h = hi(FIXED_CODE_END);
1139 if cc jump .Lresume_userspace (bp);
1144 pseudo_long_call _finish_atomic_sections, p5;
1146 jump.s .Lresume_userspace;
1147 ENDPROC(_schedule_and_signal_from_int)
1149 ENTRY(_schedule_and_signal)
1150 SAVE_CONTEXT_SYSCALL
1151 /* To end up here, vector 15 was changed - so we have to change it
1156 p1.l = _evt_system_call;
1157 p1.h = _evt_system_call;
1162 [sp + PT_RESERVED] = P0;
1163 call .Lresume_userspace;
1167 ENDPROC(_schedule_and_signal)
1169 /* We handle this 100% in exception space - to reduce overhead
1170 * Only potiential problem is if the software buffer gets swapped out of the
1171 * CPLB table - then double fault. - so we don't let this happen in other places
1173 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
1174 ENTRY(_ex_trace_buff_full)
1180 P5.L = _trace_buff_offset;
1181 P5.H = _trace_buff_offset;
1182 P3 = [P5]; /* trace_buff_offset */
1183 P5.L = lo(TBUFSTAT);
1184 P5.H = hi(TBUFSTAT);
1186 R7 <<= 1; /* double, since we need to read twice */
1188 R7 <<= 2; /* need to shift over again,
1189 * to get the number of bytes */
1192 R6 = ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN)*1024) - 1;
1199 P2.L = _trace_buff_offset;
1200 P2.H = _trace_buff_offset;
1203 P2.L = _software_trace_buff;
1204 P2.H = _software_trace_buff;
1206 LSETUP (.Lstart, .Lend) LC0;
1208 R7 = [P5]; /* read TBUF */
1222 jump _bfin_return_from_exception;
1223 ENDPROC(_ex_trace_buff_full)
1225 #if CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN == 4
1229 #endif /* CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN */
1230 ENTRY(_trace_buff_offset)
1233 ENTRY(_software_trace_buff)
1234 .rept ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN)*256);
1237 #endif /* CONFIG_DEBUG_BFIN_HWTRACE_EXPAND */
1239 #ifdef CONFIG_EARLY_PRINTK
1243 trace_buffer_stop(p0,r0);
1245 ANOMALY_283_315_WORKAROUND(p4, r5)
1247 /* Turn caches off, to ensure we don't get double exceptions */
1249 P4.L = LO(IMEM_CONTROL);
1250 P4.H = HI(IMEM_CONTROL);
1252 R5 = [P4]; /* Control Register*/
1253 BITCLR(R5,ENICPLB_P);
1254 CSYNC; /* Disabling of CPLBs should be proceeded by a CSYNC */
1258 P4.L = LO(DMEM_CONTROL);
1259 P4.H = HI(DMEM_CONTROL);
1261 BITCLR(R5,ENDCPLB_P);
1262 CSYNC; /* Disabling of CPLBs should be proceeded by a CSYNC */
1266 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
1272 ENDPROC(_early_trap)
1274 #endif /* CONFIG_EARLY_PRINTK */
1277 * Put these in the kernel data section - that should always be covered by
1278 * a CPLB. This is needed to ensure we don't get double fault conditions
1281 #ifdef CONFIG_SYSCALL_TAB_L1
1288 /* entry for each EXCAUSE[5:0]
1289 * This table must be in sync with the table in ./kernel/traps.c
1290 * EXCPT instruction can provide 4 bits of EXCAUSE, allowing 16 to be user defined
1292 .long _ex_syscall /* 0x00 - User Defined - Linux Syscall */
1293 .long _ex_trap_c /* 0x01 - User Defined - Software breakpoint */
1295 .long _ex_trap_c /* 0x02 - User Defined - KGDB initial connection
1296 and break signal trap */
1298 .long _ex_replaceable /* 0x02 - User Defined */
1300 .long _ex_trap_c /* 0x03 - User Defined - userspace stack overflow */
1301 .long _ex_trap_c /* 0x04 - User Defined - dump trace buffer */
1302 .long _ex_replaceable /* 0x05 - User Defined */
1303 .long _ex_replaceable /* 0x06 - User Defined */
1304 .long _ex_replaceable /* 0x07 - User Defined */
1305 .long _ex_replaceable /* 0x08 - User Defined */
1306 .long _ex_replaceable /* 0x09 - User Defined */
1307 .long _ex_replaceable /* 0x0A - User Defined */
1308 .long _ex_replaceable /* 0x0B - User Defined */
1309 .long _ex_replaceable /* 0x0C - User Defined */
1310 .long _ex_replaceable /* 0x0D - User Defined */
1311 .long _ex_replaceable /* 0x0E - User Defined */
1312 .long _ex_replaceable /* 0x0F - User Defined */
1313 .long _ex_single_step /* 0x10 - HW Single step */
1314 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
1315 .long _ex_trace_buff_full /* 0x11 - Trace Buffer Full */
1317 .long _ex_trap_c /* 0x11 - Trace Buffer Full */
1319 .long _ex_trap_c /* 0x12 - Reserved */
1320 .long _ex_trap_c /* 0x13 - Reserved */
1321 .long _ex_trap_c /* 0x14 - Reserved */
1322 .long _ex_trap_c /* 0x15 - Reserved */
1323 .long _ex_trap_c /* 0x16 - Reserved */
1324 .long _ex_trap_c /* 0x17 - Reserved */
1325 .long _ex_trap_c /* 0x18 - Reserved */
1326 .long _ex_trap_c /* 0x19 - Reserved */
1327 .long _ex_trap_c /* 0x1A - Reserved */
1328 .long _ex_trap_c /* 0x1B - Reserved */
1329 .long _ex_trap_c /* 0x1C - Reserved */
1330 .long _ex_trap_c /* 0x1D - Reserved */
1331 .long _ex_trap_c /* 0x1E - Reserved */
1332 .long _ex_trap_c /* 0x1F - Reserved */
1333 .long _ex_trap_c /* 0x20 - Reserved */
1334 .long _ex_trap_c /* 0x21 - Undefined Instruction */
1335 .long _ex_trap_c /* 0x22 - Illegal Instruction Combination */
1336 .long _ex_dviol /* 0x23 - Data CPLB Protection Violation */
1337 .long _ex_trap_c /* 0x24 - Data access misaligned */
1338 .long _ex_trap_c /* 0x25 - Unrecoverable Event */
1339 .long _ex_dmiss /* 0x26 - Data CPLB Miss */
1340 .long _ex_dmult /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero */
1341 .long _ex_trap_c /* 0x28 - Emulation Watchpoint */
1342 .long _ex_trap_c /* 0x29 - Instruction fetch access error (535 only) */
1343 .long _ex_trap_c /* 0x2A - Instruction fetch misaligned */
1344 .long _ex_trap_c /* 0x2B - Instruction CPLB protection Violation */
1345 .long _ex_icplb_miss /* 0x2C - Instruction CPLB miss */
1346 .long _ex_trap_c /* 0x2D - Instruction CPLB Multiple Hits */
1347 .long _ex_trap_c /* 0x2E - Illegal use of Supervisor Resource */
1348 .long _ex_trap_c /* 0x2E - Illegal use of Supervisor Resource */
1349 .long _ex_trap_c /* 0x2F - Reserved */
1350 .long _ex_trap_c /* 0x30 - Reserved */
1351 .long _ex_trap_c /* 0x31 - Reserved */
1352 .long _ex_trap_c /* 0x32 - Reserved */
1353 .long _ex_trap_c /* 0x33 - Reserved */
1354 .long _ex_trap_c /* 0x34 - Reserved */
1355 .long _ex_trap_c /* 0x35 - Reserved */
1356 .long _ex_trap_c /* 0x36 - Reserved */
1357 .long _ex_trap_c /* 0x37 - Reserved */
1358 .long _ex_trap_c /* 0x38 - Reserved */
1359 .long _ex_trap_c /* 0x39 - Reserved */
1360 .long _ex_trap_c /* 0x3A - Reserved */
1361 .long _ex_trap_c /* 0x3B - Reserved */
1362 .long _ex_trap_c /* 0x3C - Reserved */
1363 .long _ex_trap_c /* 0x3D - Reserved */
1364 .long _ex_trap_c /* 0x3E - Reserved */
1365 .long _ex_trap_c /* 0x3F - Reserved */
1368 ENTRY(_sys_call_table)
1369 .long _sys_restart_syscall /* 0 */
1371 .long _sys_ni_syscall /* fork */
1374 .long _sys_open /* 5 */
1376 .long _sys_ni_syscall /* old waitpid */
1379 .long _sys_unlink /* 10 */
1384 .long _sys_chmod /* 15 */
1385 .long _sys_chown /* chown16 */
1386 .long _sys_ni_syscall /* old break syscall holder */
1387 .long _sys_ni_syscall /* old stat */
1389 .long _sys_getpid /* 20 */
1391 .long _sys_ni_syscall /* old umount */
1394 .long _sys_stime /* 25 */
1397 .long _sys_ni_syscall /* old fstat */
1399 .long _sys_ni_syscall /* old utime */ /* 30 */
1400 .long _sys_ni_syscall /* old stty syscall holder */
1401 .long _sys_ni_syscall /* old gtty syscall holder */
1404 .long _sys_ni_syscall /* 35 */ /* old ftime syscall holder */
1409 .long _sys_rmdir /* 40 */
1413 .long _sys_ni_syscall /* old prof syscall holder */
1414 .long _sys_brk /* 45 */
1417 .long _sys_ni_syscall /* old sys_signal */
1418 .long _sys_geteuid /* geteuid16 */
1419 .long _sys_getegid /* getegid16 */ /* 50 */
1421 .long _sys_umount /* recycled never used phys() */
1422 .long _sys_ni_syscall /* old lock syscall holder */
1424 .long _sys_fcntl /* 55 */
1425 .long _sys_ni_syscall /* old mpx syscall holder */
1427 .long _sys_ni_syscall /* old ulimit syscall holder */
1428 .long _sys_ni_syscall /* old old uname */
1429 .long _sys_umask /* 60 */
1434 .long _sys_getpgrp /* 65 */
1436 .long _sys_ni_syscall /* old sys_sigaction */
1439 .long _sys_setreuid /* setreuid16 */ /* 70 */
1440 .long _sys_setregid /* setregid16 */
1441 .long _sys_ni_syscall /* old sys_sigsuspend */
1442 .long _sys_ni_syscall /* old sys_sigpending */
1443 .long _sys_sethostname
1444 .long _sys_setrlimit /* 75 */
1445 .long _sys_ni_syscall /* old getrlimit */
1446 .long _sys_getrusage
1447 .long _sys_gettimeofday
1448 .long _sys_settimeofday
1449 .long _sys_getgroups /* getgroups16 */ /* 80 */
1450 .long _sys_setgroups /* setgroups16 */
1451 .long _sys_ni_syscall /* old_select */
1453 .long _sys_ni_syscall /* old lstat */
1454 .long _sys_readlink /* 85 */
1456 .long _sys_ni_syscall /* sys_swapon */
1458 .long _sys_ni_syscall /* old_readdir */
1459 .long _sys_ni_syscall /* sys_mmap */ /* 90 */
1462 .long _sys_ftruncate
1464 .long _sys_fchown /* fchown16 */ /* 95 */
1465 .long _sys_getpriority
1466 .long _sys_setpriority
1467 .long _sys_ni_syscall /* old profil syscall holder */
1469 .long _sys_fstatfs /* 100 */
1470 .long _sys_ni_syscall
1471 .long _sys_ni_syscall /* old sys_socketcall */
1473 .long _sys_setitimer
1474 .long _sys_getitimer /* 105 */
1478 .long _sys_ni_syscall /* old uname */
1479 .long _sys_ni_syscall /* iopl for i386 */ /* 110 */
1481 .long _sys_ni_syscall /* obsolete idle() syscall */
1482 .long _sys_ni_syscall /* vm86old for i386 */
1484 .long _sys_ni_syscall /* 115 */ /* sys_swapoff */
1486 .long _sys_ni_syscall /* old sys_ipc */
1488 .long _sys_ni_syscall /* old sys_sigreturn */
1489 .long _sys_clone /* 120 */
1490 .long _sys_setdomainname
1492 .long _sys_ni_syscall /* old sys_modify_ldt */
1494 .long _sys_mprotect /* 125 */
1495 .long _sys_ni_syscall /* old sys_sigprocmask */
1496 .long _sys_ni_syscall /* old "creat_module" */
1497 .long _sys_init_module
1498 .long _sys_delete_module
1499 .long _sys_ni_syscall /* 130: old "get_kernel_syms" */
1504 .long _sys_ni_syscall /* 135 */ /* sys_sysfs */
1505 .long _sys_personality
1506 .long _sys_ni_syscall /* for afs_syscall */
1507 .long _sys_setfsuid /* setfsuid16 */
1508 .long _sys_setfsgid /* setfsgid16 */
1509 .long _sys_llseek /* 140 */
1511 .long _sys_ni_syscall /* sys_select */
1514 .long _sys_readv /* 145 */
1517 .long _sys_fdatasync
1519 .long _sys_mlock /* 150 */
1522 .long _sys_munlockall
1523 .long _sys_sched_setparam
1524 .long _sys_sched_getparam /* 155 */
1525 .long _sys_sched_setscheduler
1526 .long _sys_sched_getscheduler
1527 .long _sys_sched_yield
1528 .long _sys_sched_get_priority_max
1529 .long _sys_sched_get_priority_min /* 160 */
1530 .long _sys_sched_rr_get_interval
1531 .long _sys_nanosleep
1533 .long _sys_setresuid /* setresuid16 */
1534 .long _sys_getresuid /* getresuid16 */ /* 165 */
1535 .long _sys_ni_syscall /* for vm86 */
1536 .long _sys_ni_syscall /* old "query_module" */
1537 .long _sys_ni_syscall /* sys_poll */
1538 .long _sys_ni_syscall /* old nfsservctl */
1539 .long _sys_setresgid /* setresgid16 */ /* 170 */
1540 .long _sys_getresgid /* getresgid16 */
1542 .long _sys_rt_sigreturn
1543 .long _sys_rt_sigaction
1544 .long _sys_rt_sigprocmask /* 175 */
1545 .long _sys_rt_sigpending
1546 .long _sys_rt_sigtimedwait
1547 .long _sys_rt_sigqueueinfo
1548 .long _sys_rt_sigsuspend
1549 .long _sys_pread64 /* 180 */
1551 .long _sys_lchown /* lchown16 */
1554 .long _sys_capset /* 185 */
1555 .long _sys_sigaltstack
1557 .long _sys_ni_syscall /* streams1 */
1558 .long _sys_ni_syscall /* streams2 */
1559 .long _sys_vfork /* 190 */
1560 .long _sys_getrlimit
1561 .long _sys_mmap_pgoff
1562 .long _sys_truncate64
1563 .long _sys_ftruncate64
1564 .long _sys_stat64 /* 195 */
1569 .long _sys_getgid /* 200 */
1574 .long _sys_getgroups /* 205 */
1575 .long _sys_setgroups
1577 .long _sys_setresuid
1578 .long _sys_getresuid
1579 .long _sys_setresgid /* 210 */
1580 .long _sys_getresgid
1584 .long _sys_setfsuid /* 215 */
1586 .long _sys_pivot_root
1589 .long _sys_getdents64 /* 220 */
1591 .long _sys_ni_syscall /* reserved for TUX */
1592 .long _sys_ni_syscall
1594 .long _sys_readahead /* 225 */
1596 .long _sys_lsetxattr
1597 .long _sys_fsetxattr
1599 .long _sys_lgetxattr /* 230 */
1600 .long _sys_fgetxattr
1601 .long _sys_listxattr
1602 .long _sys_llistxattr
1603 .long _sys_flistxattr
1604 .long _sys_removexattr /* 235 */
1605 .long _sys_lremovexattr
1606 .long _sys_fremovexattr
1608 .long _sys_sendfile64
1609 .long _sys_futex /* 240 */
1610 .long _sys_sched_setaffinity
1611 .long _sys_sched_getaffinity
1612 .long _sys_ni_syscall /* sys_set_thread_area */
1613 .long _sys_ni_syscall /* sys_get_thread_area */
1614 .long _sys_io_setup /* 245 */
1615 .long _sys_io_destroy
1616 .long _sys_io_getevents
1617 .long _sys_io_submit
1618 .long _sys_io_cancel
1619 .long _sys_ni_syscall /* 250 */ /* sys_alloc_hugepages */
1620 .long _sys_ni_syscall /* sys_freec_hugepages */
1621 .long _sys_exit_group
1622 .long _sys_lookup_dcookie
1623 .long _sys_bfin_spinlock
1624 .long _sys_epoll_create /* 255 */
1625 .long _sys_epoll_ctl
1626 .long _sys_epoll_wait
1627 .long _sys_ni_syscall /* remap_file_pages */
1628 .long _sys_set_tid_address
1629 .long _sys_timer_create /* 260 */
1630 .long _sys_timer_settime
1631 .long _sys_timer_gettime
1632 .long _sys_timer_getoverrun
1633 .long _sys_timer_delete
1634 .long _sys_clock_settime /* 265 */
1635 .long _sys_clock_gettime
1636 .long _sys_clock_getres
1637 .long _sys_clock_nanosleep
1639 .long _sys_fstatfs64 /* 270 */
1642 .long _sys_fadvise64_64
1643 .long _sys_ni_syscall /* vserver */
1644 .long _sys_mbind /* 275 */
1645 .long _sys_ni_syscall /* get_mempolicy */
1646 .long _sys_ni_syscall /* set_mempolicy */
1648 .long _sys_mq_unlink
1649 .long _sys_mq_timedsend /* 280 */
1650 .long _sys_mq_timedreceive
1651 .long _sys_mq_notify
1652 .long _sys_mq_getsetattr
1653 .long _sys_ni_syscall /* kexec_load */
1654 .long _sys_waitid /* 285 */
1656 .long _sys_request_key
1658 .long _sys_ioprio_set
1659 .long _sys_ioprio_get /* 290 */
1660 .long _sys_inotify_init
1661 .long _sys_inotify_add_watch
1662 .long _sys_inotify_rm_watch
1663 .long _sys_ni_syscall /* migrate_pages */
1664 .long _sys_openat /* 295 */
1668 .long _sys_futimesat
1669 .long _sys_fstatat64 /* 300 */
1673 .long _sys_symlinkat
1674 .long _sys_readlinkat /* 305 */
1676 .long _sys_faccessat
1679 .long _sys_unshare /* 310 */
1680 .long _sys_sram_alloc
1681 .long _sys_sram_free
1682 .long _sys_dma_memcpy
1684 .long _sys_bind /* 315 */
1686 .long _sys_getpeername
1687 .long _sys_getsockname
1688 .long _sys_getsockopt
1689 .long _sys_listen /* 320 */
1694 .long _sys_sendmsg /* 325 */
1696 .long _sys_setsockopt
1699 .long _sys_socketpair /* 330 */
1704 .long _sys_msgget /* 335 */
1709 .long _sys_shmdt /* 340 */
1712 .long _sys_sync_file_range
1714 .long _sys_vmsplice /* 345 */
1715 .long _sys_epoll_pwait
1716 .long _sys_utimensat
1718 .long _sys_timerfd_create
1719 .long _sys_eventfd /* 350 */
1722 .long _sys_fadvise64
1723 .long _sys_set_robust_list
1724 .long _sys_get_robust_list /* 355 */
1725 .long _sys_fallocate
1726 .long _sys_semtimedop
1727 .long _sys_timerfd_settime
1728 .long _sys_timerfd_gettime
1729 .long _sys_signalfd4 /* 360 */
1731 .long _sys_epoll_create1
1734 .long _sys_inotify_init1 /* 365 */
1737 .long _sys_rt_tgsigqueueinfo
1738 .long _sys_perf_event_open
1739 .long _sys_recvmmsg /* 370 */
1740 .long _sys_fanotify_init
1741 .long _sys_fanotify_mark
1742 .long _sys_prlimit64
1743 .long _sys_cacheflush
1744 .long _sys_name_to_handle_at /* 375 */
1745 .long _sys_open_by_handle_at
1746 .long _sys_clock_adjtime
1749 .long _sys_sendmmsg /* 380 */
1750 .long _sys_process_vm_readv
1751 .long _sys_process_vm_writev
1753 .rept NR_syscalls-(.-_sys_call_table)/4
1754 .long _sys_ni_syscall
1756 END(_sys_call_table)