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/thread_info.h>
20 #include <asm/intctl-regs.h>
21 #include <asm/busctl-regs.h>
22 #include <asm/timer-regs.h>
23 #include <asm/unit/leds.h>
25 #include <asm/pgtable.h>
26 #include <asm/errno.h>
27 #include <asm/asm-offsets.h>
28 #include <asm/frame.inc>
31 #define preempt_stop __cli
34 #define resume_kernel restore_all
39 or EPSW_IE|MN10300_CLI_LEVEL,epsw
45 or EPSW_IE|EPSW_IM_7,epsw
51 ###############################################################################
53 # the return path for a forked child
54 # - on entry, D0 holds the address of the previous task to run
56 ###############################################################################
58 call schedule_tail[],0
61 # return 0 to indicate child process
66 ###############################################################################
70 ###############################################################################
74 mov d0,(REG_ORIG_D0,fp)
78 btst _TIF_SYSCALL_TRACE,(TI_flags,a2)
79 bne syscall_trace_entry
84 mov (sys_call_table,a1),a0
88 # make sure we don't miss an interrupt setting need_resched or
89 # sigpending between sampling and the rti
92 btst _TIF_ALLWORK_MASK,d2
97 ###############################################################################
99 # perform work that needs to be done immediately before resumption and syscall
102 ###############################################################################
105 btst _TIF_SYSCALL_TRACE,d2
107 __sti # could let do_syscall_trace() call
111 call do_syscall_trace[],0 # do_syscall_trace(regs,entryexit)
116 btst _TIF_NEED_RESCHED,d2
122 # make sure we don't miss an interrupt setting need_resched or
123 # sigpending between sampling and the rti
126 # is there any work to be done other than syscall tracing?
128 btst _TIF_WORK_MASK,d2
130 btst _TIF_NEED_RESCHED,d2
133 # deal with pending signals and notify-resume requests
137 call do_notify_resume[],0
140 # perform syscall entry tracing
146 call do_syscall_trace[],0
147 mov (REG_ORIG_D0,fp),d0
158 # userspace resumption stub bypassing syscall exit tracing
159 .globl ret_from_exception, ret_from_intr
165 mov (REG_EPSW,fp),d0 # need to deliver signals before
166 # returning to userspace
168 beq resume_kernel # returning to supervisor mode
170 ENTRY(resume_userspace)
171 # make sure we don't miss an interrupt setting need_resched or
172 # sigpending between sampling and the rti
175 # is there any work to be done on int/exception return?
177 btst _TIF_WORK_MASK,d2
181 #ifdef CONFIG_PREEMPT
183 mov (TI_preempt_count,a2),d0 # non-zero preempt_count ?
188 btst _TIF_NEED_RESCHED,(TI_flags,a2)
192 cmp EPSW_IM_7,d0 # interrupts off (exception path) ?
194 call preempt_schedule_irq[],0
199 ###############################################################################
201 # IRQ handler entry point
202 # - intended to be entered at multiple priorities
204 ###############################################################################
211 mov d0,(REG_ORIG_D0,fp)
214 call do_IRQ[],0 # do_IRQ(regs)
218 ###############################################################################
220 # Monitor Signal handler entry point
222 ###############################################################################
223 ENTRY(monitor_signal)
224 movbu (0xae000001),d1
236 movm (sp),[d2,d3,a2,a3,exreg0,exreg1,exother]
241 here: jmp 0x8e000008-here+0x8e000008
243 ###############################################################################
245 # Double Fault handler entry point
246 # - note that there will not be a stack, D0/A0 will hold EPSW/PC as were
248 ###############################################################################
256 mov a0,(__df_stack-4) # PC as was
257 mov d0,(__df_stack-8) # EPSW as was
258 mn10300_set_dbfleds # display 'db-f' on the LEDs
260 mov d0,(__df_stack-12) # no ORIG_D0
261 mov sp,a0 # save corrupted SP
262 mov __df_stack-12,sp # emergency supervisor stack
264 mov a0,(REG_A0,fp) # save corrupted SP as A0 (which got
265 # clobbered by the CPU)
267 calls do_double_fault
269 bra double_fault_loop
271 ###############################################################################
273 # Bus Error handler entry point
274 # - handle external (async) bus errors separately
276 ###############################################################################
280 mov (BCBERR),d0 # what
281 btst BCBERR_BEMR_DMA,d0 # see if it was an external bus error
282 beq __common_exception_aux # it wasn't
285 mov (BCBEAR),d1 # destination of erroneous access
287 mov (REG_ORIG_D0,fp),d2
290 mov d2,(REG_ORIG_D0,fp)
293 mov fp,(12,sp) # frame pointer
294 call io_bus_error[],0
297 ###############################################################################
299 # Miscellaneous exception entry points
301 ###############################################################################
306 bra __common_exception_nonmi
308 ENTRY(__common_exception)
312 __common_exception_aux:
314 and ~EPSW_NMID,epsw # turn NMIs back on if not NMI
317 __common_exception_nonmi:
318 and 0x0000FFFF,d0 # turn the exception code into a vector
326 SAVE_ALL # build the stack frame
328 mov (REG_D0,fp),a2 # get the exception number
329 mov (REG_ORIG_D0,fp),d0
332 mov d0,(REG_ORIG_D0,fp)
334 #ifdef CONFIG_GDBSTUB
335 btst 0x01,(gdbstub_busy)
340 call gdbstub_exception[],0 # gdbstub itself caused an exception
345 mov fp,d0 # arg 0: stacked register file
346 mov a2,d1 # arg 1: exception number
349 mov (exception_table,a2),a2
351 jmp ret_from_exception
353 1: pi # BUG() equivalent
355 ###############################################################################
357 # Exception handler functions table
359 ###############################################################################
361 ENTRY(exception_table)
363 .long uninitialised_exception
367 ###############################################################################
369 # Change an entry in the exception table
370 # - D0 exception code, D1 handler
372 ###############################################################################
373 ENTRY(set_excp_vector)
375 add exception_table,d0
378 #if defined(CONFIG_MN10300_CACHE_WBACK)
379 jmp mn10300_dcache_flush_inv_range2
384 ###############################################################################
388 ###############################################################################
390 ENTRY(sys_call_table)
391 .long sys_restart_syscall /* 0 */
396 .long sys_open /* 5 */
401 .long sys_unlink /* 10 */
406 .long sys_chmod /* 15 */
408 .long sys_ni_syscall /* old break syscall holder */
411 .long sys_getpid /* 20 */
416 .long sys_stime /* 25 */
421 .long sys_utime /* 30 */
422 .long sys_ni_syscall /* old stty syscall holder */
423 .long sys_ni_syscall /* old gtty syscall holder */
426 .long sys_ni_syscall /* 35 - old ftime syscall holder */
431 .long sys_rmdir /* 40 */
435 .long sys_ni_syscall /* old prof syscall holder */
436 .long sys_brk /* 45 */
441 .long sys_getegid16 /* 50 */
443 .long sys_umount /* recycled never used phys() */
444 .long sys_ni_syscall /* old lock syscall holder */
446 .long sys_fcntl /* 55 */
447 .long sys_ni_syscall /* old mpx syscall holder */
449 .long sys_ni_syscall /* old ulimit syscall holder */
450 .long sys_ni_syscall /* old sys_olduname */
451 .long sys_umask /* 60 */
456 .long sys_getpgrp /* 65 */
461 .long sys_setreuid16 /* 70 */
465 .long sys_sethostname
466 .long sys_setrlimit /* 75 */
467 .long sys_old_getrlimit
469 .long sys_gettimeofday
470 .long sys_settimeofday
471 .long sys_getgroups16 /* 80 */
472 .long sys_setgroups16
476 .long sys_readlink /* 85 */
481 .long old_mmap /* 90 */
486 .long sys_fchown16 /* 95 */
487 .long sys_getpriority
488 .long sys_setpriority
489 .long sys_ni_syscall /* old profil syscall holder */
491 .long sys_fstatfs /* 100 */
492 .long sys_ni_syscall /* ioperm */
496 .long sys_getitimer /* 105 */
500 .long sys_ni_syscall /* old sys_uname */
501 .long sys_ni_syscall /* 110 - iopl */
503 .long sys_ni_syscall /* old "idle" system call */
504 .long sys_ni_syscall /* vm86old */
506 .long sys_swapoff /* 115 */
511 .long sys_clone /* 120 */
512 .long sys_setdomainname
514 .long sys_ni_syscall /* modify_ldt */
516 .long sys_mprotect /* 125 */
517 .long sys_sigprocmask
518 .long sys_ni_syscall /* old "create_module" */
519 .long sys_init_module
520 .long sys_delete_module
521 .long sys_ni_syscall /* 130: old "get_kernel_syms" */
526 .long sys_sysfs /* 135 */
527 .long sys_personality
528 .long sys_ni_syscall /* reserved for afs_syscall */
531 .long sys_llseek /* 140 */
536 .long sys_readv /* 145 */
541 .long sys_mlock /* 150 */
545 .long sys_sched_setparam
546 .long sys_sched_getparam /* 155 */
547 .long sys_sched_setscheduler
548 .long sys_sched_getscheduler
549 .long sys_sched_yield
550 .long sys_sched_get_priority_max
551 .long sys_sched_get_priority_min /* 160 */
552 .long sys_sched_rr_get_interval
555 .long sys_setresuid16
556 .long sys_getresuid16 /* 165 */
557 .long sys_ni_syscall /* vm86 */
558 .long sys_ni_syscall /* Old sys_query_module */
561 .long sys_setresgid16 /* 170 */
562 .long sys_getresgid16
564 .long sys_rt_sigreturn
565 .long sys_rt_sigaction
566 .long sys_rt_sigprocmask /* 175 */
567 .long sys_rt_sigpending
568 .long sys_rt_sigtimedwait
569 .long sys_rt_sigqueueinfo
570 .long sys_rt_sigsuspend
571 .long sys_pread64 /* 180 */
576 .long sys_capset /* 185 */
577 .long sys_sigaltstack
579 .long sys_ni_syscall /* reserved for streams1 */
580 .long sys_ni_syscall /* reserved for streams2 */
581 .long sys_vfork /* 190 */
585 .long sys_ftruncate64
586 .long sys_stat64 /* 195 */
591 .long sys_getgid /* 200 */
596 .long sys_getgroups /* 205 */
601 .long sys_setresgid /* 210 */
606 .long sys_setfsuid /* 215 */
611 .long sys_getdents64 /* 220 */
613 .long sys_ni_syscall /* reserved for TUX */
616 .long sys_readahead /* 225 */
621 .long sys_lgetxattr /* 230 */
626 .long sys_removexattr /* 235 */
627 .long sys_lremovexattr
628 .long sys_fremovexattr
631 .long sys_futex /* 240 */
632 .long sys_sched_setaffinity
633 .long sys_sched_getaffinity
634 .long sys_ni_syscall /* sys_set_thread_area */
635 .long sys_ni_syscall /* sys_get_thread_area */
636 .long sys_io_setup /* 245 */
638 .long sys_io_getevents
641 .long sys_fadvise64 /* 250 */
644 .long sys_lookup_dcookie
645 .long sys_epoll_create
646 .long sys_epoll_ctl /* 255 */
648 .long sys_remap_file_pages
649 .long sys_set_tid_address
650 .long sys_timer_create
651 .long sys_timer_settime /* 260 */
652 .long sys_timer_gettime
653 .long sys_timer_getoverrun
654 .long sys_timer_delete
655 .long sys_clock_settime
656 .long sys_clock_gettime /* 265 */
657 .long sys_clock_getres
658 .long sys_clock_nanosleep
661 .long sys_tgkill /* 270 */
663 .long sys_fadvise64_64
664 .long sys_ni_syscall /* sys_vserver */
666 .long sys_get_mempolicy /* 275 */
667 .long sys_set_mempolicy
670 .long sys_mq_timedsend
671 .long sys_mq_timedreceive /* 280 */
673 .long sys_mq_getsetattr
676 .long sys_ni_syscall /* 285 */ /* available */
678 .long sys_request_key
681 .long sys_ioprio_set /* 290 */
683 .long sys_inotify_init
684 .long sys_inotify_add_watch
685 .long sys_inotify_rm_watch
686 .long sys_migrate_pages /* 295 */
691 .long sys_futimesat /* 300 */
696 .long sys_symlinkat /* 305 */
701 .long sys_ppoll /* 310 */
703 .long sys_set_robust_list
704 .long sys_get_robust_list
706 .long sys_sync_file_range /* 315 */
711 .long sys_epoll_pwait /* 320 */
714 .long sys_timerfd_create
716 .long sys_fallocate /* 325 */
717 .long sys_timerfd_settime
718 .long sys_timerfd_gettime
721 nr_syscalls=(.-sys_call_table)/4