1 ###############################################################################
3 # MN10300 Exception and interrupt entry points
5 # Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd.
6 # Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
7 # Modified by David Howells (dhowells@redhat.com)
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public Licence
11 # as published by the Free Software Foundation; either version
12 # 2 of the Licence, or (at your option) any later version.
14 ###############################################################################
15 #include <linux/sys.h>
16 #include <linux/linkage.h>
18 #include <asm/irqflags.h>
19 #include <asm/thread_info.h>
20 #include <asm/intctl-regs.h>
21 #include <asm/busctl-regs.h>
22 #include <asm/timer-regs.h>
23 #include <unit/leds.h>
25 #include <asm/pgtable.h>
26 #include <asm/errno.h>
27 #include <asm/asm-offsets.h>
28 #include <asm/frame.inc>
30 #if defined(CONFIG_SMP) && defined(CONFIG_GDBSTUB)
31 #include <asm/gdb-stub.h>
32 #endif /* CONFIG_SMP && CONFIG_GDBSTUB */
35 #define preempt_stop LOCAL_IRQ_DISABLE
38 #define resume_kernel restore_all
43 ###############################################################################
45 # the return path for a forked child
46 # - on entry, D0 holds the address of the previous task to run
48 ###############################################################################
50 call schedule_tail[],0
53 # return 0 to indicate child process
58 ENTRY(ret_from_kernel_thread)
59 call schedule_tail[],0
67 ###############################################################################
71 ###############################################################################
75 mov d0,(REG_ORIG_D0,fp)
79 btst _TIF_SYSCALL_TRACE,(TI_flags,a2)
80 bne syscall_entry_trace
85 mov (sys_call_table,a1),a0
89 # make sure we don't miss an interrupt setting need_resched or
90 # sigpending between sampling and the rti
93 btst _TIF_ALLWORK_MASK,d2
98 ###############################################################################
100 # perform work that needs to be done immediately before resumption and syscall
103 ###############################################################################
108 beq resume_kernel # returning to supervisor mode
110 btst _TIF_SYSCALL_TRACE,d2
112 LOCAL_IRQ_ENABLE # could let syscall_trace_exit() call
115 call syscall_trace_exit[],0 # do_syscall_trace(regs)
120 btst _TIF_NEED_RESCHED,d2
126 # make sure we don't miss an interrupt setting need_resched or
127 # sigpending between sampling and the rti
130 # is there any work to be done other than syscall tracing?
132 btst _TIF_WORK_MASK,d2
134 btst _TIF_NEED_RESCHED,d2
137 # deal with pending signals and notify-resume requests
141 call do_notify_resume[],0
144 # perform syscall entry tracing
149 call syscall_trace_entry[],0 # returns the syscall number to actually use
160 # userspace resumption stub bypassing syscall exit tracing
161 .globl ret_from_exception, ret_from_intr
167 mov (REG_EPSW,fp),d0 # need to deliver signals before
168 # returning to userspace
170 beq resume_kernel # returning to supervisor mode
172 ENTRY(resume_userspace)
173 # make sure we don't miss an interrupt setting need_resched or
174 # sigpending between sampling and the rti
177 # is there any work to be done on int/exception return?
179 btst _TIF_WORK_MASK,d2
183 #ifdef CONFIG_PREEMPT
186 mov (TI_preempt_count,a2),d0 # non-zero preempt_count ?
191 btst _TIF_NEED_RESCHED,(TI_flags,a2)
195 cmp EPSW_IM_7,d0 # interrupts off (exception path) ?
197 call preempt_schedule_irq[],0
202 ###############################################################################
204 # IRQ handler entry point
205 # - intended to be entered at multiple priorities
207 ###############################################################################
214 mov d0,(REG_ORIG_D0,fp)
217 call do_IRQ[],0 # do_IRQ(regs)
221 ###############################################################################
223 # Double Fault handler entry point
224 # - note that there will not be a stack, D0/A0 will hold EPSW/PC as were
226 ###############################################################################
234 mov a0,(__df_stack-4) # PC as was
235 mov d0,(__df_stack-8) # EPSW as was
236 mn10300_set_dbfleds # display 'db-f' on the LEDs
238 mov d0,(__df_stack-12) # no ORIG_D0
239 mov sp,a0 # save corrupted SP
240 mov __df_stack-12,sp # emergency supervisor stack
242 mov a0,(REG_A0,fp) # save corrupted SP as A0 (which got
243 # clobbered by the CPU)
245 calls do_double_fault
247 bra double_fault_loop
249 ###############################################################################
251 # Bus Error handler entry point
252 # - handle external (async) bus errors separately
254 ###############################################################################
258 #if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
262 mov (BCBERR),d0 # what
263 btst BCBERR_BEMR_DMA,d0 # see if it was an external bus error
264 beq __common_exception_aux # it wasn't
267 mov (BCBEAR),d1 # destination of erroneous access
269 mov (REG_ORIG_D0,fp),d2
272 mov d2,(REG_ORIG_D0,fp)
275 mov fp,(12,sp) # frame pointer
276 call io_bus_error[],0
279 ###############################################################################
281 # NMI exception entry points
283 # This is used by ordinary interrupt channels that have the GxICR_NMI bit set
284 # in addition to the main NMI and Watchdog channels. SMP NMI IPIs use this
287 ###############################################################################
295 mov d0,(sp) # save d0(TBR)
299 cmp CALL_FUNCTION_NMI_IPI,d0
300 bne nmi_not_smp_callfunc # if not call function, jump
302 # function call nmi ipi
303 add 4,sp # no need to store TBR
304 mov GxICR_DETECT,d0 # clear NMI request
305 movbu d0,(GxICR(CALL_FUNCTION_NMI_IPI))
306 movhu (GxICR(CALL_FUNCTION_NMI_IPI)),d0
307 and ~EPSW_NMID,epsw # enable NMI
309 mov (sp),d0 # restore d0
311 call smp_nmi_call_function_interrupt[],0
314 nmi_not_smp_callfunc:
315 #ifdef CONFIG_KERNEL_DEBUGGER
316 cmp DEBUGGER_NMI_IPI,d0
317 bne nmi_not_debugger # if not kernel debugger NMI IPI, jump
319 # kernel debugger NMI IPI
320 add 4,sp # no need to store TBR
321 mov GxICR_DETECT,d0 # clear NMI
322 movbu d0,(GxICR(DEBUGGER_NMI_IPI))
323 movhu (GxICR(DEBUGGER_NMI_IPI)),d0
324 and ~EPSW_NMID,epsw # enable NMI
328 mov fp,d0 # arg 0: stacked register file
329 mov a2,d1 # arg 1: exception number
330 call debugger_nmi_interrupt[],0
334 #endif /* CONFIG_KERNEL_DEBUGGER */
335 mov (sp),d0 # restore TBR to d0
337 #endif /* CONFIG_SMP */
339 bra __common_exception_nonmi
341 ###############################################################################
343 # General exception entry point
345 ###############################################################################
346 ENTRY(__common_exception)
349 #if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
354 __common_exception_aux:
356 and ~EPSW_NMID,epsw # turn NMIs back on if not NMI
359 __common_exception_nonmi:
360 and 0x0000FFFF,d0 # turn the exception code into a vector
368 SAVE_ALL # build the stack frame
370 mov (REG_D0,fp),a2 # get the exception number
371 mov (REG_ORIG_D0,fp),d0
374 mov d0,(REG_ORIG_D0,fp)
376 #ifdef CONFIG_GDBSTUB
378 call gdbstub_busy_check[],0
379 and d0,d0 # check return value
381 #else /* CONFIG_SMP */
382 btst 0x01,(gdbstub_busy)
384 #endif /* CONFIG_SMP */
388 call gdbstub_exception[],0 # gdbstub itself caused an exception
391 #endif /* CONFIG_GDBSTUB */
393 mov fp,d0 # arg 0: stacked register file
394 mov a2,d1 # arg 1: exception number
397 mov (exception_table,a2),a2
399 jmp ret_from_exception
401 1: pi # BUG() equivalent
403 ###############################################################################
405 # Exception handler functions table
407 ###############################################################################
409 ENTRY(exception_table)
411 .long uninitialised_exception
415 ###############################################################################
417 # Change an entry in the exception table
418 # - D0 exception code, D1 handler
420 ###############################################################################
421 ENTRY(set_excp_vector)
423 add exception_table,d0
428 ###############################################################################
432 ###############################################################################
434 ENTRY(sys_call_table)
435 .long sys_restart_syscall /* 0 */
440 .long sys_open /* 5 */
445 .long sys_unlink /* 10 */
450 .long sys_chmod /* 15 */
452 .long sys_ni_syscall /* old break syscall holder */
455 .long sys_getpid /* 20 */
460 .long sys_stime /* 25 */
465 .long sys_utime /* 30 */
466 .long sys_ni_syscall /* old stty syscall holder */
467 .long sys_ni_syscall /* old gtty syscall holder */
470 .long sys_ni_syscall /* 35 - old ftime syscall holder */
475 .long sys_rmdir /* 40 */
479 .long sys_ni_syscall /* old prof syscall holder */
480 .long sys_brk /* 45 */
485 .long sys_getegid16 /* 50 */
487 .long sys_umount /* recycled never used phys() */
488 .long sys_ni_syscall /* old lock syscall holder */
490 .long sys_fcntl /* 55 */
491 .long sys_ni_syscall /* old mpx syscall holder */
493 .long sys_ni_syscall /* old ulimit syscall holder */
494 .long sys_ni_syscall /* old sys_olduname */
495 .long sys_umask /* 60 */
500 .long sys_getpgrp /* 65 */
505 .long sys_setreuid16 /* 70 */
509 .long sys_sethostname
510 .long sys_setrlimit /* 75 */
511 .long sys_old_getrlimit
513 .long sys_gettimeofday
514 .long sys_settimeofday
515 .long sys_getgroups16 /* 80 */
516 .long sys_setgroups16
520 .long sys_readlink /* 85 */
524 .long sys_old_readdir
525 .long old_mmap /* 90 */
530 .long sys_fchown16 /* 95 */
531 .long sys_getpriority
532 .long sys_setpriority
533 .long sys_ni_syscall /* old profil syscall holder */
535 .long sys_fstatfs /* 100 */
536 .long sys_ni_syscall /* ioperm */
540 .long sys_getitimer /* 105 */
544 .long sys_ni_syscall /* old sys_uname */
545 .long sys_ni_syscall /* 110 - iopl */
547 .long sys_ni_syscall /* old "idle" system call */
548 .long sys_ni_syscall /* vm86old */
550 .long sys_swapoff /* 115 */
555 .long sys_clone /* 120 */
556 .long sys_setdomainname
558 .long sys_ni_syscall /* modify_ldt */
560 .long sys_mprotect /* 125 */
561 .long sys_sigprocmask
562 .long sys_ni_syscall /* old "create_module" */
563 .long sys_init_module
564 .long sys_delete_module
565 .long sys_ni_syscall /* 130: old "get_kernel_syms" */
570 .long sys_sysfs /* 135 */
571 .long sys_personality
572 .long sys_ni_syscall /* reserved for afs_syscall */
575 .long sys_llseek /* 140 */
580 .long sys_readv /* 145 */
585 .long sys_mlock /* 150 */
589 .long sys_sched_setparam
590 .long sys_sched_getparam /* 155 */
591 .long sys_sched_setscheduler
592 .long sys_sched_getscheduler
593 .long sys_sched_yield
594 .long sys_sched_get_priority_max
595 .long sys_sched_get_priority_min /* 160 */
596 .long sys_sched_rr_get_interval
599 .long sys_setresuid16
600 .long sys_getresuid16 /* 165 */
601 .long sys_ni_syscall /* vm86 */
602 .long sys_ni_syscall /* Old sys_query_module */
604 .long sys_ni_syscall /* was nfsservctl */
605 .long sys_setresgid16 /* 170 */
606 .long sys_getresgid16
608 .long sys_rt_sigreturn
609 .long sys_rt_sigaction
610 .long sys_rt_sigprocmask /* 175 */
611 .long sys_rt_sigpending
612 .long sys_rt_sigtimedwait
613 .long sys_rt_sigqueueinfo
614 .long sys_rt_sigsuspend
615 .long sys_pread64 /* 180 */
620 .long sys_capset /* 185 */
621 .long sys_sigaltstack
623 .long sys_ni_syscall /* reserved for streams1 */
624 .long sys_ni_syscall /* reserved for streams2 */
625 .long sys_vfork /* 190 */
629 .long sys_ftruncate64
630 .long sys_stat64 /* 195 */
635 .long sys_getgid /* 200 */
640 .long sys_getgroups /* 205 */
645 .long sys_setresgid /* 210 */
650 .long sys_setfsuid /* 215 */
655 .long sys_getdents64 /* 220 */
657 .long sys_ni_syscall /* reserved for TUX */
660 .long sys_readahead /* 225 */
665 .long sys_lgetxattr /* 230 */
670 .long sys_removexattr /* 235 */
671 .long sys_lremovexattr
672 .long sys_fremovexattr
675 .long sys_futex /* 240 */
676 .long sys_sched_setaffinity
677 .long sys_sched_getaffinity
678 .long sys_ni_syscall /* sys_set_thread_area */
679 .long sys_ni_syscall /* sys_get_thread_area */
680 .long sys_io_setup /* 245 */
682 .long sys_io_getevents
685 .long sys_fadvise64 /* 250 */
688 .long sys_lookup_dcookie
689 .long sys_epoll_create
690 .long sys_epoll_ctl /* 255 */
692 .long sys_remap_file_pages
693 .long sys_set_tid_address
694 .long sys_timer_create
695 .long sys_timer_settime /* 260 */
696 .long sys_timer_gettime
697 .long sys_timer_getoverrun
698 .long sys_timer_delete
699 .long sys_clock_settime
700 .long sys_clock_gettime /* 265 */
701 .long sys_clock_getres
702 .long sys_clock_nanosleep
705 .long sys_tgkill /* 270 */
707 .long sys_fadvise64_64
708 .long sys_ni_syscall /* sys_vserver */
710 .long sys_get_mempolicy /* 275 */
711 .long sys_set_mempolicy
714 .long sys_mq_timedsend
715 .long sys_mq_timedreceive /* 280 */
717 .long sys_mq_getsetattr
720 .long sys_ni_syscall /* 285 */ /* available */
722 .long sys_request_key
725 .long sys_ioprio_set /* 290 */
727 .long sys_inotify_init
728 .long sys_inotify_add_watch
729 .long sys_inotify_rm_watch
730 .long sys_migrate_pages /* 295 */
735 .long sys_futimesat /* 300 */
740 .long sys_symlinkat /* 305 */
745 .long sys_ppoll /* 310 */
747 .long sys_set_robust_list
748 .long sys_get_robust_list
750 .long sys_sync_file_range /* 315 */
755 .long sys_epoll_pwait /* 320 */
758 .long sys_timerfd_create
760 .long sys_fallocate /* 325 */
761 .long sys_timerfd_settime
762 .long sys_timerfd_gettime
765 .long sys_epoll_create1 /* 330 */
768 .long sys_inotify_init1
770 .long sys_pwritev /* 335 */
771 .long sys_rt_tgsigqueueinfo
772 .long sys_perf_event_open
777 nr_syscalls=(.-sys_call_table)/4