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 <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_entry_trace
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 syscall_trace_exit() call
110 call syscall_trace_exit[],0 # do_syscall_trace(regs)
115 btst _TIF_NEED_RESCHED,d2
121 # make sure we don't miss an interrupt setting need_resched or
122 # sigpending between sampling and the rti
125 # is there any work to be done other than syscall tracing?
127 btst _TIF_WORK_MASK,d2
129 btst _TIF_NEED_RESCHED,d2
132 # deal with pending signals and notify-resume requests
136 call do_notify_resume[],0
139 # perform syscall entry tracing
144 call syscall_trace_entry[],0 # returns the syscall number to actually use
155 # userspace resumption stub bypassing syscall exit tracing
156 .globl ret_from_exception, ret_from_intr
162 mov (REG_EPSW,fp),d0 # need to deliver signals before
163 # returning to userspace
165 beq resume_kernel # returning to supervisor mode
167 ENTRY(resume_userspace)
168 # make sure we don't miss an interrupt setting need_resched or
169 # sigpending between sampling and the rti
172 # is there any work to be done on int/exception return?
174 btst _TIF_WORK_MASK,d2
178 #ifdef CONFIG_PREEMPT
181 mov (TI_preempt_count,a2),d0 # non-zero preempt_count ?
186 btst _TIF_NEED_RESCHED,(TI_flags,a2)
190 cmp EPSW_IM_7,d0 # interrupts off (exception path) ?
192 call preempt_schedule_irq[],0
197 ###############################################################################
199 # IRQ handler entry point
200 # - intended to be entered at multiple priorities
202 ###############################################################################
209 mov d0,(REG_ORIG_D0,fp)
212 call do_IRQ[],0 # do_IRQ(regs)
216 ###############################################################################
218 # Monitor Signal handler entry point
220 ###############################################################################
221 ENTRY(monitor_signal)
222 movbu (0xae000001),d1
234 movm (sp),[d2,d3,a2,a3,exreg0,exreg1,exother]
239 here: jmp 0x8e000008-here+0x8e000008
241 ###############################################################################
243 # Double Fault handler entry point
244 # - note that there will not be a stack, D0/A0 will hold EPSW/PC as were
246 ###############################################################################
254 mov a0,(__df_stack-4) # PC as was
255 mov d0,(__df_stack-8) # EPSW as was
256 mn10300_set_dbfleds # display 'db-f' on the LEDs
258 mov d0,(__df_stack-12) # no ORIG_D0
259 mov sp,a0 # save corrupted SP
260 mov __df_stack-12,sp # emergency supervisor stack
262 mov a0,(REG_A0,fp) # save corrupted SP as A0 (which got
263 # clobbered by the CPU)
265 calls do_double_fault
267 bra double_fault_loop
269 ###############################################################################
271 # Bus Error handler entry point
272 # - handle external (async) bus errors separately
274 ###############################################################################
278 mov (BCBERR),d0 # what
279 btst BCBERR_BEMR_DMA,d0 # see if it was an external bus error
280 beq __common_exception_aux # it wasn't
283 mov (BCBEAR),d1 # destination of erroneous access
285 mov (REG_ORIG_D0,fp),d2
288 mov d2,(REG_ORIG_D0,fp)
291 mov fp,(12,sp) # frame pointer
292 call io_bus_error[],0
295 ###############################################################################
297 # Miscellaneous exception entry points
299 ###############################################################################
304 bra __common_exception_nonmi
306 ENTRY(__common_exception)
310 __common_exception_aux:
312 and ~EPSW_NMID,epsw # turn NMIs back on if not NMI
315 __common_exception_nonmi:
316 and 0x0000FFFF,d0 # turn the exception code into a vector
324 SAVE_ALL # build the stack frame
326 mov (REG_D0,fp),a2 # get the exception number
327 mov (REG_ORIG_D0,fp),d0
330 mov d0,(REG_ORIG_D0,fp)
332 #ifdef CONFIG_GDBSTUB
333 btst 0x01,(gdbstub_busy)
338 call gdbstub_exception[],0 # gdbstub itself caused an exception
343 mov fp,d0 # arg 0: stacked register file
344 mov a2,d1 # arg 1: exception number
347 mov (exception_table,a2),a2
349 jmp ret_from_exception
351 1: pi # BUG() equivalent
353 ###############################################################################
355 # Exception handler functions table
357 ###############################################################################
359 ENTRY(exception_table)
361 .long uninitialised_exception
365 ###############################################################################
367 # Change an entry in the exception table
368 # - D0 exception code, D1 handler
370 ###############################################################################
371 ENTRY(set_excp_vector)
373 add exception_table,d0
376 #if defined(CONFIG_MN10300_CACHE_WBACK)
377 jmp mn10300_dcache_flush_inv_range2
382 ###############################################################################
386 ###############################################################################
388 ENTRY(sys_call_table)
389 .long sys_restart_syscall /* 0 */
394 .long sys_open /* 5 */
399 .long sys_unlink /* 10 */
404 .long sys_chmod /* 15 */
406 .long sys_ni_syscall /* old break syscall holder */
409 .long sys_getpid /* 20 */
414 .long sys_stime /* 25 */
419 .long sys_utime /* 30 */
420 .long sys_ni_syscall /* old stty syscall holder */
421 .long sys_ni_syscall /* old gtty syscall holder */
424 .long sys_ni_syscall /* 35 - old ftime syscall holder */
429 .long sys_rmdir /* 40 */
433 .long sys_ni_syscall /* old prof syscall holder */
434 .long sys_brk /* 45 */
439 .long sys_getegid16 /* 50 */
441 .long sys_umount /* recycled never used phys() */
442 .long sys_ni_syscall /* old lock syscall holder */
444 .long sys_fcntl /* 55 */
445 .long sys_ni_syscall /* old mpx syscall holder */
447 .long sys_ni_syscall /* old ulimit syscall holder */
448 .long sys_ni_syscall /* old sys_olduname */
449 .long sys_umask /* 60 */
454 .long sys_getpgrp /* 65 */
459 .long sys_setreuid16 /* 70 */
463 .long sys_sethostname
464 .long sys_setrlimit /* 75 */
465 .long sys_old_getrlimit
467 .long sys_gettimeofday
468 .long sys_settimeofday
469 .long sys_getgroups16 /* 80 */
470 .long sys_setgroups16
474 .long sys_readlink /* 85 */
478 .long sys_old_readdir
479 .long old_mmap /* 90 */
484 .long sys_fchown16 /* 95 */
485 .long sys_getpriority
486 .long sys_setpriority
487 .long sys_ni_syscall /* old profil syscall holder */
489 .long sys_fstatfs /* 100 */
490 .long sys_ni_syscall /* ioperm */
494 .long sys_getitimer /* 105 */
498 .long sys_ni_syscall /* old sys_uname */
499 .long sys_ni_syscall /* 110 - iopl */
501 .long sys_ni_syscall /* old "idle" system call */
502 .long sys_ni_syscall /* vm86old */
504 .long sys_swapoff /* 115 */
509 .long sys_clone /* 120 */
510 .long sys_setdomainname
512 .long sys_ni_syscall /* modify_ldt */
514 .long sys_mprotect /* 125 */
515 .long sys_sigprocmask
516 .long sys_ni_syscall /* old "create_module" */
517 .long sys_init_module
518 .long sys_delete_module
519 .long sys_ni_syscall /* 130: old "get_kernel_syms" */
524 .long sys_sysfs /* 135 */
525 .long sys_personality
526 .long sys_ni_syscall /* reserved for afs_syscall */
529 .long sys_llseek /* 140 */
534 .long sys_readv /* 145 */
539 .long sys_mlock /* 150 */
543 .long sys_sched_setparam
544 .long sys_sched_getparam /* 155 */
545 .long sys_sched_setscheduler
546 .long sys_sched_getscheduler
547 .long sys_sched_yield
548 .long sys_sched_get_priority_max
549 .long sys_sched_get_priority_min /* 160 */
550 .long sys_sched_rr_get_interval
553 .long sys_setresuid16
554 .long sys_getresuid16 /* 165 */
555 .long sys_ni_syscall /* vm86 */
556 .long sys_ni_syscall /* Old sys_query_module */
559 .long sys_setresgid16 /* 170 */
560 .long sys_getresgid16
562 .long sys_rt_sigreturn
563 .long sys_rt_sigaction
564 .long sys_rt_sigprocmask /* 175 */
565 .long sys_rt_sigpending
566 .long sys_rt_sigtimedwait
567 .long sys_rt_sigqueueinfo
568 .long sys_rt_sigsuspend
569 .long sys_pread64 /* 180 */
574 .long sys_capset /* 185 */
575 .long sys_sigaltstack
577 .long sys_ni_syscall /* reserved for streams1 */
578 .long sys_ni_syscall /* reserved for streams2 */
579 .long sys_vfork /* 190 */
583 .long sys_ftruncate64
584 .long sys_stat64 /* 195 */
589 .long sys_getgid /* 200 */
594 .long sys_getgroups /* 205 */
599 .long sys_setresgid /* 210 */
604 .long sys_setfsuid /* 215 */
609 .long sys_getdents64 /* 220 */
611 .long sys_ni_syscall /* reserved for TUX */
614 .long sys_readahead /* 225 */
619 .long sys_lgetxattr /* 230 */
624 .long sys_removexattr /* 235 */
625 .long sys_lremovexattr
626 .long sys_fremovexattr
629 .long sys_futex /* 240 */
630 .long sys_sched_setaffinity
631 .long sys_sched_getaffinity
632 .long sys_ni_syscall /* sys_set_thread_area */
633 .long sys_ni_syscall /* sys_get_thread_area */
634 .long sys_io_setup /* 245 */
636 .long sys_io_getevents
639 .long sys_fadvise64 /* 250 */
642 .long sys_lookup_dcookie
643 .long sys_epoll_create
644 .long sys_epoll_ctl /* 255 */
646 .long sys_remap_file_pages
647 .long sys_set_tid_address
648 .long sys_timer_create
649 .long sys_timer_settime /* 260 */
650 .long sys_timer_gettime
651 .long sys_timer_getoverrun
652 .long sys_timer_delete
653 .long sys_clock_settime
654 .long sys_clock_gettime /* 265 */
655 .long sys_clock_getres
656 .long sys_clock_nanosleep
659 .long sys_tgkill /* 270 */
661 .long sys_fadvise64_64
662 .long sys_ni_syscall /* sys_vserver */
664 .long sys_get_mempolicy /* 275 */
665 .long sys_set_mempolicy
668 .long sys_mq_timedsend
669 .long sys_mq_timedreceive /* 280 */
671 .long sys_mq_getsetattr
674 .long sys_ni_syscall /* 285 */ /* available */
676 .long sys_request_key
679 .long sys_ioprio_set /* 290 */
681 .long sys_inotify_init
682 .long sys_inotify_add_watch
683 .long sys_inotify_rm_watch
684 .long sys_migrate_pages /* 295 */
689 .long sys_futimesat /* 300 */
694 .long sys_symlinkat /* 305 */
699 .long sys_ppoll /* 310 */
701 .long sys_set_robust_list
702 .long sys_get_robust_list
704 .long sys_sync_file_range /* 315 */
709 .long sys_epoll_pwait /* 320 */
712 .long sys_timerfd_create
714 .long sys_fallocate /* 325 */
715 .long sys_timerfd_settime
716 .long sys_timerfd_gettime
719 .long sys_epoll_create1 /* 330 */
722 .long sys_inotify_init1
724 .long sys_pwritev /* 335 */
725 .long sys_rt_tgsigqueueinfo
726 .long sys_perf_event_open
729 nr_syscalls=(.-sys_call_table)/4