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/system.h>
19 #include <asm/irqflags.h>
20 #include <asm/thread_info.h>
21 #include <asm/intctl-regs.h>
22 #include <asm/busctl-regs.h>
23 #include <asm/timer-regs.h>
24 #include <unit/leds.h>
26 #include <asm/pgtable.h>
27 #include <asm/errno.h>
28 #include <asm/asm-offsets.h>
29 #include <asm/frame.inc>
31 #if defined(CONFIG_SMP) && defined(CONFIG_GDBSTUB)
32 #include <asm/gdb-stub.h>
33 #endif /* CONFIG_SMP && CONFIG_GDBSTUB */
36 #define preempt_stop LOCAL_IRQ_DISABLE
39 #define resume_kernel restore_all
44 ###############################################################################
46 # the return path for a forked child
47 # - on entry, D0 holds the address of the previous task to run
49 ###############################################################################
51 call schedule_tail[],0
54 # return 0 to indicate child process
59 ###############################################################################
63 ###############################################################################
67 mov d0,(REG_ORIG_D0,fp)
71 btst _TIF_SYSCALL_TRACE,(TI_flags,a2)
72 bne syscall_entry_trace
77 mov (sys_call_table,a1),a0
81 # make sure we don't miss an interrupt setting need_resched or
82 # sigpending between sampling and the rti
85 btst _TIF_ALLWORK_MASK,d2
90 ###############################################################################
92 # perform work that needs to be done immediately before resumption and syscall
95 ###############################################################################
98 btst _TIF_SYSCALL_TRACE,d2
100 LOCAL_IRQ_ENABLE # could let syscall_trace_exit() call
103 call syscall_trace_exit[],0 # do_syscall_trace(regs)
108 btst _TIF_NEED_RESCHED,d2
114 # make sure we don't miss an interrupt setting need_resched or
115 # sigpending between sampling and the rti
118 # is there any work to be done other than syscall tracing?
120 btst _TIF_WORK_MASK,d2
122 btst _TIF_NEED_RESCHED,d2
125 # deal with pending signals and notify-resume requests
129 call do_notify_resume[],0
132 # perform syscall entry tracing
137 call syscall_trace_entry[],0 # returns the syscall number to actually use
148 # userspace resumption stub bypassing syscall exit tracing
149 .globl ret_from_exception, ret_from_intr
155 mov (REG_EPSW,fp),d0 # need to deliver signals before
156 # returning to userspace
158 beq resume_kernel # returning to supervisor mode
160 ENTRY(resume_userspace)
161 # make sure we don't miss an interrupt setting need_resched or
162 # sigpending between sampling and the rti
165 # is there any work to be done on int/exception return?
167 btst _TIF_WORK_MASK,d2
171 #ifdef CONFIG_PREEMPT
174 mov (TI_preempt_count,a2),d0 # non-zero preempt_count ?
179 btst _TIF_NEED_RESCHED,(TI_flags,a2)
183 cmp EPSW_IM_7,d0 # interrupts off (exception path) ?
185 call preempt_schedule_irq[],0
190 ###############################################################################
192 # IRQ handler entry point
193 # - intended to be entered at multiple priorities
195 ###############################################################################
202 mov d0,(REG_ORIG_D0,fp)
205 call do_IRQ[],0 # do_IRQ(regs)
209 ###############################################################################
211 # Double Fault handler entry point
212 # - note that there will not be a stack, D0/A0 will hold EPSW/PC as were
214 ###############################################################################
222 mov a0,(__df_stack-4) # PC as was
223 mov d0,(__df_stack-8) # EPSW as was
224 mn10300_set_dbfleds # display 'db-f' on the LEDs
226 mov d0,(__df_stack-12) # no ORIG_D0
227 mov sp,a0 # save corrupted SP
228 mov __df_stack-12,sp # emergency supervisor stack
230 mov a0,(REG_A0,fp) # save corrupted SP as A0 (which got
231 # clobbered by the CPU)
233 calls do_double_fault
235 bra double_fault_loop
237 ###############################################################################
239 # Bus Error handler entry point
240 # - handle external (async) bus errors separately
242 ###############################################################################
246 #if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
250 mov (BCBERR),d0 # what
251 btst BCBERR_BEMR_DMA,d0 # see if it was an external bus error
252 beq __common_exception_aux # it wasn't
255 mov (BCBEAR),d1 # destination of erroneous access
257 mov (REG_ORIG_D0,fp),d2
260 mov d2,(REG_ORIG_D0,fp)
263 mov fp,(12,sp) # frame pointer
264 call io_bus_error[],0
267 ###############################################################################
269 # NMI exception entry points
271 # This is used by ordinary interrupt channels that have the GxICR_NMI bit set
272 # in addition to the main NMI and Watchdog channels. SMP NMI IPIs use this
275 ###############################################################################
283 mov d0,(sp) # save d0(TBR)
287 cmp CALL_FUNCTION_NMI_IPI,d0
288 bne nmi_not_smp_callfunc # if not call function, jump
290 # function call nmi ipi
291 add 4,sp # no need to store TBR
292 mov GxICR_DETECT,d0 # clear NMI request
293 movbu d0,(GxICR(CALL_FUNCTION_NMI_IPI))
294 movhu (GxICR(CALL_FUNCTION_NMI_IPI)),d0
295 and ~EPSW_NMID,epsw # enable NMI
297 mov (sp),d0 # restore d0
299 call smp_nmi_call_function_interrupt[],0
302 nmi_not_smp_callfunc:
303 #ifdef CONFIG_KERNEL_DEBUGGER
304 cmp DEBUGGER_NMI_IPI,d0
305 bne nmi_not_debugger # if not kernel debugger NMI IPI, jump
307 # kernel debugger NMI IPI
308 add 4,sp # no need to store TBR
309 mov GxICR_DETECT,d0 # clear NMI
310 movbu d0,(GxICR(DEBUGGER_NMI_IPI))
311 movhu (GxICR(DEBUGGER_NMI_IPI)),d0
312 and ~EPSW_NMID,epsw # enable NMI
316 mov fp,d0 # arg 0: stacked register file
317 mov a2,d1 # arg 1: exception number
318 call debugger_nmi_interrupt[],0
322 #endif /* CONFIG_KERNEL_DEBUGGER */
323 mov (sp),d0 # restore TBR to d0
325 #endif /* CONFIG_SMP */
327 bra __common_exception_nonmi
329 ###############################################################################
331 # General exception entry point
333 ###############################################################################
334 ENTRY(__common_exception)
337 #if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
342 __common_exception_aux:
344 and ~EPSW_NMID,epsw # turn NMIs back on if not NMI
347 __common_exception_nonmi:
348 and 0x0000FFFF,d0 # turn the exception code into a vector
356 SAVE_ALL # build the stack frame
358 mov (REG_D0,fp),a2 # get the exception number
359 mov (REG_ORIG_D0,fp),d0
362 mov d0,(REG_ORIG_D0,fp)
364 #ifdef CONFIG_GDBSTUB
366 call gdbstub_busy_check[],0
367 and d0,d0 # check return value
369 #else /* CONFIG_SMP */
370 btst 0x01,(gdbstub_busy)
372 #endif /* CONFIG_SMP */
376 call gdbstub_exception[],0 # gdbstub itself caused an exception
379 #endif /* CONFIG_GDBSTUB */
381 mov fp,d0 # arg 0: stacked register file
382 mov a2,d1 # arg 1: exception number
385 mov (exception_table,a2),a2
387 jmp ret_from_exception
389 1: pi # BUG() equivalent
391 ###############################################################################
393 # Exception handler functions table
395 ###############################################################################
397 ENTRY(exception_table)
399 .long uninitialised_exception
403 ###############################################################################
405 # Change an entry in the exception table
406 # - D0 exception code, D1 handler
408 ###############################################################################
409 ENTRY(set_excp_vector)
411 add exception_table,d0
416 ###############################################################################
420 ###############################################################################
422 ENTRY(sys_call_table)
423 .long sys_restart_syscall /* 0 */
428 .long sys_open /* 5 */
433 .long sys_unlink /* 10 */
438 .long sys_chmod /* 15 */
440 .long sys_ni_syscall /* old break syscall holder */
443 .long sys_getpid /* 20 */
448 .long sys_stime /* 25 */
453 .long sys_utime /* 30 */
454 .long sys_ni_syscall /* old stty syscall holder */
455 .long sys_ni_syscall /* old gtty syscall holder */
458 .long sys_ni_syscall /* 35 - old ftime syscall holder */
463 .long sys_rmdir /* 40 */
467 .long sys_ni_syscall /* old prof syscall holder */
468 .long sys_brk /* 45 */
473 .long sys_getegid16 /* 50 */
475 .long sys_umount /* recycled never used phys() */
476 .long sys_ni_syscall /* old lock syscall holder */
478 .long sys_fcntl /* 55 */
479 .long sys_ni_syscall /* old mpx syscall holder */
481 .long sys_ni_syscall /* old ulimit syscall holder */
482 .long sys_ni_syscall /* old sys_olduname */
483 .long sys_umask /* 60 */
488 .long sys_getpgrp /* 65 */
493 .long sys_setreuid16 /* 70 */
497 .long sys_sethostname
498 .long sys_setrlimit /* 75 */
499 .long sys_old_getrlimit
501 .long sys_gettimeofday
502 .long sys_settimeofday
503 .long sys_getgroups16 /* 80 */
504 .long sys_setgroups16
508 .long sys_readlink /* 85 */
512 .long sys_old_readdir
513 .long old_mmap /* 90 */
518 .long sys_fchown16 /* 95 */
519 .long sys_getpriority
520 .long sys_setpriority
521 .long sys_ni_syscall /* old profil syscall holder */
523 .long sys_fstatfs /* 100 */
524 .long sys_ni_syscall /* ioperm */
528 .long sys_getitimer /* 105 */
532 .long sys_ni_syscall /* old sys_uname */
533 .long sys_ni_syscall /* 110 - iopl */
535 .long sys_ni_syscall /* old "idle" system call */
536 .long sys_ni_syscall /* vm86old */
538 .long sys_swapoff /* 115 */
543 .long sys_clone /* 120 */
544 .long sys_setdomainname
546 .long sys_ni_syscall /* modify_ldt */
548 .long sys_mprotect /* 125 */
549 .long sys_sigprocmask
550 .long sys_ni_syscall /* old "create_module" */
551 .long sys_init_module
552 .long sys_delete_module
553 .long sys_ni_syscall /* 130: old "get_kernel_syms" */
558 .long sys_sysfs /* 135 */
559 .long sys_personality
560 .long sys_ni_syscall /* reserved for afs_syscall */
563 .long sys_llseek /* 140 */
568 .long sys_readv /* 145 */
573 .long sys_mlock /* 150 */
577 .long sys_sched_setparam
578 .long sys_sched_getparam /* 155 */
579 .long sys_sched_setscheduler
580 .long sys_sched_getscheduler
581 .long sys_sched_yield
582 .long sys_sched_get_priority_max
583 .long sys_sched_get_priority_min /* 160 */
584 .long sys_sched_rr_get_interval
587 .long sys_setresuid16
588 .long sys_getresuid16 /* 165 */
589 .long sys_ni_syscall /* vm86 */
590 .long sys_ni_syscall /* Old sys_query_module */
592 .long sys_ni_syscall /* was nfsservctl */
593 .long sys_setresgid16 /* 170 */
594 .long sys_getresgid16
596 .long sys_rt_sigreturn
597 .long sys_rt_sigaction
598 .long sys_rt_sigprocmask /* 175 */
599 .long sys_rt_sigpending
600 .long sys_rt_sigtimedwait
601 .long sys_rt_sigqueueinfo
602 .long sys_rt_sigsuspend
603 .long sys_pread64 /* 180 */
608 .long sys_capset /* 185 */
609 .long sys_sigaltstack
611 .long sys_ni_syscall /* reserved for streams1 */
612 .long sys_ni_syscall /* reserved for streams2 */
613 .long sys_vfork /* 190 */
617 .long sys_ftruncate64
618 .long sys_stat64 /* 195 */
623 .long sys_getgid /* 200 */
628 .long sys_getgroups /* 205 */
633 .long sys_setresgid /* 210 */
638 .long sys_setfsuid /* 215 */
643 .long sys_getdents64 /* 220 */
645 .long sys_ni_syscall /* reserved for TUX */
648 .long sys_readahead /* 225 */
653 .long sys_lgetxattr /* 230 */
658 .long sys_removexattr /* 235 */
659 .long sys_lremovexattr
660 .long sys_fremovexattr
663 .long sys_futex /* 240 */
664 .long sys_sched_setaffinity
665 .long sys_sched_getaffinity
666 .long sys_ni_syscall /* sys_set_thread_area */
667 .long sys_ni_syscall /* sys_get_thread_area */
668 .long sys_io_setup /* 245 */
670 .long sys_io_getevents
673 .long sys_fadvise64 /* 250 */
676 .long sys_lookup_dcookie
677 .long sys_epoll_create
678 .long sys_epoll_ctl /* 255 */
680 .long sys_remap_file_pages
681 .long sys_set_tid_address
682 .long sys_timer_create
683 .long sys_timer_settime /* 260 */
684 .long sys_timer_gettime
685 .long sys_timer_getoverrun
686 .long sys_timer_delete
687 .long sys_clock_settime
688 .long sys_clock_gettime /* 265 */
689 .long sys_clock_getres
690 .long sys_clock_nanosleep
693 .long sys_tgkill /* 270 */
695 .long sys_fadvise64_64
696 .long sys_ni_syscall /* sys_vserver */
698 .long sys_get_mempolicy /* 275 */
699 .long sys_set_mempolicy
702 .long sys_mq_timedsend
703 .long sys_mq_timedreceive /* 280 */
705 .long sys_mq_getsetattr
708 .long sys_ni_syscall /* 285 */ /* available */
710 .long sys_request_key
713 .long sys_ioprio_set /* 290 */
715 .long sys_inotify_init
716 .long sys_inotify_add_watch
717 .long sys_inotify_rm_watch
718 .long sys_migrate_pages /* 295 */
723 .long sys_futimesat /* 300 */
728 .long sys_symlinkat /* 305 */
733 .long sys_ppoll /* 310 */
735 .long sys_set_robust_list
736 .long sys_get_robust_list
738 .long sys_sync_file_range /* 315 */
743 .long sys_epoll_pwait /* 320 */
746 .long sys_timerfd_create
748 .long sys_fallocate /* 325 */
749 .long sys_timerfd_settime
750 .long sys_timerfd_gettime
753 .long sys_epoll_create1 /* 330 */
756 .long sys_inotify_init1
758 .long sys_pwritev /* 335 */
759 .long sys_rt_tgsigqueueinfo
760 .long sys_perf_event_open
765 nr_syscalls=(.-sys_call_table)/4