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 ###############################################################################
62 ###############################################################################
66 mov d0,(REG_ORIG_D0,fp)
70 btst _TIF_SYSCALL_TRACE,(TI_flags,a2)
71 bne syscall_entry_trace
76 mov (sys_call_table,a1),a0
80 # make sure we don't miss an interrupt setting need_resched or
81 # sigpending between sampling and the rti
84 btst _TIF_ALLWORK_MASK,d2
89 ###############################################################################
91 # perform work that needs to be done immediately before resumption and syscall
94 ###############################################################################
97 btst _TIF_SYSCALL_TRACE,d2
99 LOCAL_IRQ_ENABLE # could let syscall_trace_exit() call
102 call syscall_trace_exit[],0 # do_syscall_trace(regs)
107 btst _TIF_NEED_RESCHED,d2
113 # make sure we don't miss an interrupt setting need_resched or
114 # sigpending between sampling and the rti
117 # is there any work to be done other than syscall tracing?
119 btst _TIF_WORK_MASK,d2
121 btst _TIF_NEED_RESCHED,d2
124 # deal with pending signals and notify-resume requests
128 call do_notify_resume[],0
131 # perform syscall entry tracing
136 call syscall_trace_entry[],0 # returns the syscall number to actually use
147 # userspace resumption stub bypassing syscall exit tracing
148 .globl ret_from_exception, ret_from_intr
154 mov (REG_EPSW,fp),d0 # need to deliver signals before
155 # returning to userspace
157 beq resume_kernel # returning to supervisor mode
159 ENTRY(resume_userspace)
160 # make sure we don't miss an interrupt setting need_resched or
161 # sigpending between sampling and the rti
164 # is there any work to be done on int/exception return?
166 btst _TIF_WORK_MASK,d2
170 #ifdef CONFIG_PREEMPT
173 mov (TI_preempt_count,a2),d0 # non-zero preempt_count ?
178 btst _TIF_NEED_RESCHED,(TI_flags,a2)
182 cmp EPSW_IM_7,d0 # interrupts off (exception path) ?
184 call preempt_schedule_irq[],0
189 ###############################################################################
191 # IRQ handler entry point
192 # - intended to be entered at multiple priorities
194 ###############################################################################
201 mov d0,(REG_ORIG_D0,fp)
204 call do_IRQ[],0 # do_IRQ(regs)
208 ###############################################################################
210 # Double Fault handler entry point
211 # - note that there will not be a stack, D0/A0 will hold EPSW/PC as were
213 ###############################################################################
221 mov a0,(__df_stack-4) # PC as was
222 mov d0,(__df_stack-8) # EPSW as was
223 mn10300_set_dbfleds # display 'db-f' on the LEDs
225 mov d0,(__df_stack-12) # no ORIG_D0
226 mov sp,a0 # save corrupted SP
227 mov __df_stack-12,sp # emergency supervisor stack
229 mov a0,(REG_A0,fp) # save corrupted SP as A0 (which got
230 # clobbered by the CPU)
232 calls do_double_fault
234 bra double_fault_loop
236 ###############################################################################
238 # Bus Error handler entry point
239 # - handle external (async) bus errors separately
241 ###############################################################################
245 #if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
249 mov (BCBERR),d0 # what
250 btst BCBERR_BEMR_DMA,d0 # see if it was an external bus error
251 beq __common_exception_aux # it wasn't
254 mov (BCBEAR),d1 # destination of erroneous access
256 mov (REG_ORIG_D0,fp),d2
259 mov d2,(REG_ORIG_D0,fp)
262 mov fp,(12,sp) # frame pointer
263 call io_bus_error[],0
266 ###############################################################################
268 # NMI exception entry points
270 # This is used by ordinary interrupt channels that have the GxICR_NMI bit set
271 # in addition to the main NMI and Watchdog channels. SMP NMI IPIs use this
274 ###############################################################################
282 mov d0,(sp) # save d0(TBR)
286 cmp CALL_FUNCTION_NMI_IPI,d0
287 bne nmi_not_smp_callfunc # if not call function, jump
289 # function call nmi ipi
290 add 4,sp # no need to store TBR
291 mov GxICR_DETECT,d0 # clear NMI request
292 movbu d0,(GxICR(CALL_FUNCTION_NMI_IPI))
293 movhu (GxICR(CALL_FUNCTION_NMI_IPI)),d0
294 and ~EPSW_NMID,epsw # enable NMI
296 mov (sp),d0 # restore d0
298 call smp_nmi_call_function_interrupt[],0
301 nmi_not_smp_callfunc:
302 #ifdef CONFIG_KERNEL_DEBUGGER
303 cmp DEBUGGER_NMI_IPI,d0
304 bne nmi_not_debugger # if not kernel debugger NMI IPI, jump
306 # kernel debugger NMI IPI
307 add 4,sp # no need to store TBR
308 mov GxICR_DETECT,d0 # clear NMI
309 movbu d0,(GxICR(DEBUGGER_NMI_IPI))
310 movhu (GxICR(DEBUGGER_NMI_IPI)),d0
311 and ~EPSW_NMID,epsw # enable NMI
315 mov fp,d0 # arg 0: stacked register file
316 mov a2,d1 # arg 1: exception number
317 call debugger_nmi_interrupt[],0
321 #endif /* CONFIG_KERNEL_DEBUGGER */
322 mov (sp),d0 # restore TBR to d0
324 #endif /* CONFIG_SMP */
326 bra __common_exception_nonmi
328 ###############################################################################
330 # General exception entry point
332 ###############################################################################
333 ENTRY(__common_exception)
336 #if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
341 __common_exception_aux:
343 and ~EPSW_NMID,epsw # turn NMIs back on if not NMI
346 __common_exception_nonmi:
347 and 0x0000FFFF,d0 # turn the exception code into a vector
355 SAVE_ALL # build the stack frame
357 mov (REG_D0,fp),a2 # get the exception number
358 mov (REG_ORIG_D0,fp),d0
361 mov d0,(REG_ORIG_D0,fp)
363 #ifdef CONFIG_GDBSTUB
365 call gdbstub_busy_check[],0
366 and d0,d0 # check return value
368 #else /* CONFIG_SMP */
369 btst 0x01,(gdbstub_busy)
371 #endif /* CONFIG_SMP */
375 call gdbstub_exception[],0 # gdbstub itself caused an exception
378 #endif /* CONFIG_GDBSTUB */
380 mov fp,d0 # arg 0: stacked register file
381 mov a2,d1 # arg 1: exception number
384 mov (exception_table,a2),a2
386 jmp ret_from_exception
388 1: pi # BUG() equivalent
390 ###############################################################################
392 # Exception handler functions table
394 ###############################################################################
396 ENTRY(exception_table)
398 .long uninitialised_exception
402 ###############################################################################
404 # Change an entry in the exception table
405 # - D0 exception code, D1 handler
407 ###############################################################################
408 ENTRY(set_excp_vector)
410 add exception_table,d0
415 ###############################################################################
419 ###############################################################################
421 ENTRY(sys_call_table)
422 .long sys_restart_syscall /* 0 */
427 .long sys_open /* 5 */
432 .long sys_unlink /* 10 */
437 .long sys_chmod /* 15 */
439 .long sys_ni_syscall /* old break syscall holder */
442 .long sys_getpid /* 20 */
447 .long sys_stime /* 25 */
452 .long sys_utime /* 30 */
453 .long sys_ni_syscall /* old stty syscall holder */
454 .long sys_ni_syscall /* old gtty syscall holder */
457 .long sys_ni_syscall /* 35 - old ftime syscall holder */
462 .long sys_rmdir /* 40 */
466 .long sys_ni_syscall /* old prof syscall holder */
467 .long sys_brk /* 45 */
472 .long sys_getegid16 /* 50 */
474 .long sys_umount /* recycled never used phys() */
475 .long sys_ni_syscall /* old lock syscall holder */
477 .long sys_fcntl /* 55 */
478 .long sys_ni_syscall /* old mpx syscall holder */
480 .long sys_ni_syscall /* old ulimit syscall holder */
481 .long sys_ni_syscall /* old sys_olduname */
482 .long sys_umask /* 60 */
487 .long sys_getpgrp /* 65 */
492 .long sys_setreuid16 /* 70 */
496 .long sys_sethostname
497 .long sys_setrlimit /* 75 */
498 .long sys_old_getrlimit
500 .long sys_gettimeofday
501 .long sys_settimeofday
502 .long sys_getgroups16 /* 80 */
503 .long sys_setgroups16
507 .long sys_readlink /* 85 */
511 .long sys_old_readdir
512 .long old_mmap /* 90 */
517 .long sys_fchown16 /* 95 */
518 .long sys_getpriority
519 .long sys_setpriority
520 .long sys_ni_syscall /* old profil syscall holder */
522 .long sys_fstatfs /* 100 */
523 .long sys_ni_syscall /* ioperm */
527 .long sys_getitimer /* 105 */
531 .long sys_ni_syscall /* old sys_uname */
532 .long sys_ni_syscall /* 110 - iopl */
534 .long sys_ni_syscall /* old "idle" system call */
535 .long sys_ni_syscall /* vm86old */
537 .long sys_swapoff /* 115 */
542 .long sys_clone /* 120 */
543 .long sys_setdomainname
545 .long sys_ni_syscall /* modify_ldt */
547 .long sys_mprotect /* 125 */
548 .long sys_sigprocmask
549 .long sys_ni_syscall /* old "create_module" */
550 .long sys_init_module
551 .long sys_delete_module
552 .long sys_ni_syscall /* 130: old "get_kernel_syms" */
557 .long sys_sysfs /* 135 */
558 .long sys_personality
559 .long sys_ni_syscall /* reserved for afs_syscall */
562 .long sys_llseek /* 140 */
567 .long sys_readv /* 145 */
572 .long sys_mlock /* 150 */
576 .long sys_sched_setparam
577 .long sys_sched_getparam /* 155 */
578 .long sys_sched_setscheduler
579 .long sys_sched_getscheduler
580 .long sys_sched_yield
581 .long sys_sched_get_priority_max
582 .long sys_sched_get_priority_min /* 160 */
583 .long sys_sched_rr_get_interval
586 .long sys_setresuid16
587 .long sys_getresuid16 /* 165 */
588 .long sys_ni_syscall /* vm86 */
589 .long sys_ni_syscall /* Old sys_query_module */
591 .long sys_ni_syscall /* was nfsservctl */
592 .long sys_setresgid16 /* 170 */
593 .long sys_getresgid16
595 .long sys_rt_sigreturn
596 .long sys_rt_sigaction
597 .long sys_rt_sigprocmask /* 175 */
598 .long sys_rt_sigpending
599 .long sys_rt_sigtimedwait
600 .long sys_rt_sigqueueinfo
601 .long sys_rt_sigsuspend
602 .long sys_pread64 /* 180 */
607 .long sys_capset /* 185 */
608 .long sys_sigaltstack
610 .long sys_ni_syscall /* reserved for streams1 */
611 .long sys_ni_syscall /* reserved for streams2 */
612 .long sys_vfork /* 190 */
616 .long sys_ftruncate64
617 .long sys_stat64 /* 195 */
622 .long sys_getgid /* 200 */
627 .long sys_getgroups /* 205 */
632 .long sys_setresgid /* 210 */
637 .long sys_setfsuid /* 215 */
642 .long sys_getdents64 /* 220 */
644 .long sys_ni_syscall /* reserved for TUX */
647 .long sys_readahead /* 225 */
652 .long sys_lgetxattr /* 230 */
657 .long sys_removexattr /* 235 */
658 .long sys_lremovexattr
659 .long sys_fremovexattr
662 .long sys_futex /* 240 */
663 .long sys_sched_setaffinity
664 .long sys_sched_getaffinity
665 .long sys_ni_syscall /* sys_set_thread_area */
666 .long sys_ni_syscall /* sys_get_thread_area */
667 .long sys_io_setup /* 245 */
669 .long sys_io_getevents
672 .long sys_fadvise64 /* 250 */
675 .long sys_lookup_dcookie
676 .long sys_epoll_create
677 .long sys_epoll_ctl /* 255 */
679 .long sys_remap_file_pages
680 .long sys_set_tid_address
681 .long sys_timer_create
682 .long sys_timer_settime /* 260 */
683 .long sys_timer_gettime
684 .long sys_timer_getoverrun
685 .long sys_timer_delete
686 .long sys_clock_settime
687 .long sys_clock_gettime /* 265 */
688 .long sys_clock_getres
689 .long sys_clock_nanosleep
692 .long sys_tgkill /* 270 */
694 .long sys_fadvise64_64
695 .long sys_ni_syscall /* sys_vserver */
697 .long sys_get_mempolicy /* 275 */
698 .long sys_set_mempolicy
701 .long sys_mq_timedsend
702 .long sys_mq_timedreceive /* 280 */
704 .long sys_mq_getsetattr
707 .long sys_ni_syscall /* 285 */ /* available */
709 .long sys_request_key
712 .long sys_ioprio_set /* 290 */
714 .long sys_inotify_init
715 .long sys_inotify_add_watch
716 .long sys_inotify_rm_watch
717 .long sys_migrate_pages /* 295 */
722 .long sys_futimesat /* 300 */
727 .long sys_symlinkat /* 305 */
732 .long sys_ppoll /* 310 */
734 .long sys_set_robust_list
735 .long sys_get_robust_list
737 .long sys_sync_file_range /* 315 */
742 .long sys_epoll_pwait /* 320 */
745 .long sys_timerfd_create
747 .long sys_fallocate /* 325 */
748 .long sys_timerfd_settime
749 .long sys_timerfd_gettime
752 .long sys_epoll_create1 /* 330 */
755 .long sys_inotify_init1
757 .long sys_pwritev /* 335 */
758 .long sys_rt_tgsigqueueinfo
759 .long sys_perf_event_open
764 nr_syscalls=(.-sys_call_table)/4