3 * linux/arch/m68k/kernel/entry.S
5 * Copyright (C) 1991, 1992 Linus Torvalds
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file README.legal in the main directory of this archive
11 * Linux/m68k support by Hamish Macdonald
13 * 68060 fixes by Jesper Skov
18 * entry.S contains the system-call and fault low-level handling routines.
19 * This also contains the timer-interrupt handler, as well as all interrupts
20 * and faults that can result in a task-switch.
22 * NOTE: This code handles signal-recognition, which happens every time
23 * after a timer-interrupt and after each system call.
28 * 12/03/96 Jes: Currently we only support m68k single-cpu systems, so
29 * all pointers that used to be 'current' are now entry
30 * number 0 in the 'current_set' list.
32 * 6/05/00 RZ: addedd writeback completion after return from sighandler
36 #include <linux/linkage.h>
37 #include <asm/entry.h>
38 #include <asm/errno.h>
39 #include <asm/setup.h>
40 #include <asm/segment.h>
41 #include <asm/traps.h>
42 #include <asm/unistd.h>
44 #include <asm/asm-offsets.h>
46 .globl system_call, buserr, trap, resume
48 .globl sys_fork, sys_clone, sys_vfork
49 .globl ret_from_interrupt, bad_interrupt
50 .globl auto_irqhandler_fixup
51 .globl user_irqvec_fixup, user_irqhandler_fixup
57 movel %sp,%sp@- | stack frame pointer argument
60 jra .Lret_from_exception
65 movel %sp,%sp@- | stack frame pointer argument
68 jra .Lret_from_exception
70 | After a fork we jump here directly from resume,
71 | so that %d1 contains the previous task
72 | schedule_tail now used regardless of CONFIG_SMP
77 jra .Lret_from_exception
80 movel #-ENOSYS,%sp@(PT_OFF_D0)| needed for strace
86 movel %sp@(PT_OFF_ORIG_D0),%d0
90 movel #-ENOSYS,%sp@(PT_OFF_D0)
99 jra .Lret_from_exception
101 ENTRY(ret_from_signal)
104 /* on 68040 complete pending writebacks if any */
106 bfextu %sp@(PT_OFF_FORMATVEC){#0,#4},%d0
107 subql #7,%d0 | bus error frame ?
114 jra .Lret_from_exception
121 movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0)
124 tstb %curptr@(TASK_INFO+TINFO_FLAGS+2)
126 cmpl #NR_syscalls,%d0
129 jbsr @(sys_call_table,%d0:l:4)@(0)
130 movel %d0,%sp@(PT_OFF_D0) | save the return value
133 movew %curptr@(TASK_INFO+TINFO_FLAGS+2),%d0
134 jne syscall_exit_work
138 btst #5,%sp@(PT_OFF_SR) | check if returning to kernel
139 bnes 1b | if so, skip resched, signals
149 ENTRY(ret_from_exception)
150 .Lret_from_exception:
151 btst #5,%sp@(PT_OFF_SR) | check if returning to kernel
152 bnes 1f | if so, skip resched, signals
153 | only allow interrupts when we are really the last one on the
154 | kernel stack, otherwise stack overflow can occur during
155 | heavy interrupt load
159 moveb %curptr@(TASK_INFO+TINFO_FLAGS+3),%d0
165 movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0)
174 subql #4,%sp | dummy return address
176 pea %sp@(SWITCH_STACK_SIZE)
184 | when single stepping into handler stop at the first insn
185 btst #6,%curptr@(TASK_INFO+TINFO_FLAGS+2)
189 bclr #7,%sp@(PT_OFF_SR) | clear trace bit in SR
196 jbra resume_userspace
199 /* This is the main interrupt handler for autovector interrupts */
201 ENTRY(auto_inthandler)
204 addqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
205 | put exception # in d0
206 bfextu %sp@(PT_OFF_FORMATVEC){#4,#10},%d0
210 movel %d0,%sp@- | put vector # on stack
211 auto_irqhandler_fixup = . + 2
212 jsr __m68k_handle_int | process the IRQ
213 addql #8,%sp | pop parameters off stack
216 subqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
217 jeq ret_from_last_interrupt
221 ret_from_last_interrupt:
222 moveq #(~ALLOWINT>>8)&0xff,%d0
223 andb %sp@(PT_OFF_SR),%d0
226 /* check if we need to do software interrupts */
227 tstl irq_stat+CPUSTAT_SOFTIRQ_PENDING
228 jeq .Lret_from_exception
229 pea ret_from_exception
232 /* Handler for user defined interrupt vectors */
234 ENTRY(user_inthandler)
237 addqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
238 | put exception # in d0
239 bfextu %sp@(PT_OFF_FORMATVEC){#4,#10},%d0
240 user_irqvec_fixup = . + 2
244 movel %d0,%sp@- | put vector # on stack
245 user_irqhandler_fixup = . + 2
246 jsr __m68k_handle_int | process the IRQ
247 addql #8,%sp | pop parameters off stack
249 subqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
250 jeq ret_from_last_interrupt
253 /* Handler for uninitialized and spurious interrupts */
255 ENTRY(bad_inthandler)
258 addqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
264 subqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
265 jeq ret_from_last_interrupt
271 pea %sp@(SWITCH_STACK_SIZE)
279 pea %sp@(SWITCH_STACK_SIZE)
287 pea %sp@(SWITCH_STACK_SIZE)
293 ENTRY(sys_sigsuspend)
295 pea %sp@(SWITCH_STACK_SIZE)
301 ENTRY(sys_rt_sigsuspend)
303 pea %sp@(SWITCH_STACK_SIZE)
304 jbsr do_rt_sigsuspend
315 ENTRY(sys_rt_sigreturn)
323 * Beware - when entering resume, prev (the current task) is
324 * in a0, next (the new task) is in a1,so don't change these
325 * registers until their contents are no longer needed.
329 movew %sr,%a0@(TASK_THREAD+THREAD_SR)
331 /* save fs (sfc,%dfc) (may be pointing to kernel memory) */
333 movew %d0,%a0@(TASK_THREAD+THREAD_FS)
336 /* it is better to use a movel here instead of a movew 8*) */
338 movel %d0,%a0@(TASK_THREAD+THREAD_USP)
340 /* save non-scratch registers on stack */
343 /* save current kernel stack pointer */
344 movel %sp,%a0@(TASK_THREAD+THREAD_KSP)
346 /* save floating point context */
347 #ifndef CONFIG_M68KFPU_EMU_ONLY
348 #ifdef CONFIG_M68KFPU_EMU
352 fsave %a0@(TASK_THREAD+THREAD_FPSTATE)
354 #if defined(CONFIG_M68060)
355 #if !defined(CPU_M68060_ONLY)
356 btst #3,m68k_cputype+3
359 /* The 060 FPU keeps status in bits 15-8 of the first longword */
360 tstb %a0@(TASK_THREAD+THREAD_FPSTATE+2)
362 #if !defined(CPU_M68060_ONLY)
365 #endif /* CONFIG_M68060 */
366 #if !defined(CPU_M68060_ONLY)
367 1: tstb %a0@(TASK_THREAD+THREAD_FPSTATE)
370 2: fmovemx %fp0-%fp7,%a0@(TASK_THREAD+THREAD_FPREG)
371 fmoveml %fpcr/%fpsr/%fpiar,%a0@(TASK_THREAD+THREAD_FPCNTL)
373 #endif /* CONFIG_M68KFPU_EMU_ONLY */
374 /* Return previous task in %d1 */
377 /* switch to new task (a1 contains new task) */
380 /* restore floating point context */
381 #ifndef CONFIG_M68KFPU_EMU_ONLY
382 #ifdef CONFIG_M68KFPU_EMU
386 #if defined(CONFIG_M68060)
387 #if !defined(CPU_M68060_ONLY)
388 btst #3,m68k_cputype+3
391 /* The 060 FPU keeps status in bits 15-8 of the first longword */
392 tstb %a1@(TASK_THREAD+THREAD_FPSTATE+2)
394 #if !defined(CPU_M68060_ONLY)
397 #endif /* CONFIG_M68060 */
398 #if !defined(CPU_M68060_ONLY)
399 1: tstb %a1@(TASK_THREAD+THREAD_FPSTATE)
402 2: fmovemx %a1@(TASK_THREAD+THREAD_FPREG),%fp0-%fp7
403 fmoveml %a1@(TASK_THREAD+THREAD_FPCNTL),%fpcr/%fpsr/%fpiar
404 3: frestore %a1@(TASK_THREAD+THREAD_FPSTATE)
406 #endif /* CONFIG_M68KFPU_EMU_ONLY */
408 /* restore the kernel stack pointer */
409 movel %a1@(TASK_THREAD+THREAD_KSP),%sp
411 /* restore non-scratch registers */
414 /* restore user stack pointer */
415 movel %a1@(TASK_THREAD+THREAD_USP),%a0
418 /* restore fs (sfc,%dfc) */
419 movew %a1@(TASK_THREAD+THREAD_FS),%a0
423 /* restore status register */
424 movew %a1@(TASK_THREAD+THREAD_SR),%sr
431 .long sys_restart_syscall /* 0 - old "setup()" system call, used for restarting */
436 .long sys_open /* 5 */
441 .long sys_unlink /* 10 */
446 .long sys_chmod /* 15 */
448 .long sys_ni_syscall /* old break syscall holder */
451 .long sys_getpid /* 20 */
456 .long sys_stime /* 25 */
461 .long sys_utime /* 30 */
462 .long sys_ni_syscall /* old stty syscall holder */
463 .long sys_ni_syscall /* old gtty syscall holder */
466 .long sys_ni_syscall /* 35 */ /* old ftime syscall holder */
471 .long sys_rmdir /* 40 */
475 .long sys_ni_syscall /* old prof syscall holder */
476 .long sys_brk /* 45 */
481 .long sys_getegid16 /* 50 */
483 .long sys_umount /* recycled never used phys() */
484 .long sys_ni_syscall /* old lock syscall holder */
486 .long sys_fcntl /* 55 */
487 .long sys_ni_syscall /* old mpx syscall holder */
489 .long sys_ni_syscall /* old ulimit syscall holder */
491 .long sys_umask /* 60 */
496 .long sys_getpgrp /* 65 */
501 .long sys_setreuid16 /* 70 */
505 .long sys_sethostname
506 .long sys_setrlimit /* 75 */
507 .long sys_old_getrlimit
509 .long sys_gettimeofday
510 .long sys_settimeofday
511 .long sys_getgroups16 /* 80 */
512 .long sys_setgroups16
516 .long sys_readlink /* 85 */
520 .long sys_old_readdir
521 .long old_mmap /* 90 */
526 .long sys_fchown16 /* 95 */
527 .long sys_getpriority
528 .long sys_setpriority
529 .long sys_ni_syscall /* old profil syscall holder */
531 .long sys_fstatfs /* 100 */
532 .long sys_ni_syscall /* ioperm for i386 */
536 .long sys_getitimer /* 105 */
541 .long sys_ni_syscall /* 110 */ /* iopl for i386 */
543 .long sys_ni_syscall /* obsolete idle() syscall */
544 .long sys_ni_syscall /* vm86old for i386 */
546 .long sys_swapoff /* 115 */
551 .long sys_clone /* 120 */
552 .long sys_setdomainname
554 .long sys_cacheflush /* modify_ldt for i386 */
556 .long sys_mprotect /* 125 */
557 .long sys_sigprocmask
558 .long sys_ni_syscall /* old "create_module" */
559 .long sys_init_module
560 .long sys_delete_module
561 .long sys_ni_syscall /* 130 - old "get_kernel_syms" */
566 .long sys_sysfs /* 135 */
567 .long sys_personality
568 .long sys_ni_syscall /* for afs_syscall */
571 .long sys_llseek /* 140 */
576 .long sys_readv /* 145 */
581 .long sys_mlock /* 150 */
585 .long sys_sched_setparam
586 .long sys_sched_getparam /* 155 */
587 .long sys_sched_setscheduler
588 .long sys_sched_getscheduler
589 .long sys_sched_yield
590 .long sys_sched_get_priority_max
591 .long sys_sched_get_priority_min /* 160 */
592 .long sys_sched_rr_get_interval
595 .long sys_setresuid16
596 .long sys_getresuid16 /* 165 */
597 .long sys_getpagesize
598 .long sys_ni_syscall /* old sys_query_module */
601 .long sys_setresgid16 /* 170 */
602 .long sys_getresgid16
604 .long sys_rt_sigreturn
605 .long sys_rt_sigaction
606 .long sys_rt_sigprocmask /* 175 */
607 .long sys_rt_sigpending
608 .long sys_rt_sigtimedwait
609 .long sys_rt_sigqueueinfo
610 .long sys_rt_sigsuspend
611 .long sys_pread64 /* 180 */
616 .long sys_capset /* 185 */
617 .long sys_sigaltstack
619 .long sys_ni_syscall /* streams1 */
620 .long sys_ni_syscall /* streams2 */
621 .long sys_vfork /* 190 */
625 .long sys_ftruncate64
626 .long sys_stat64 /* 195 */
631 .long sys_getgid /* 200 */
636 .long sys_getgroups /* 205 */
641 .long sys_setresgid /* 210 */
646 .long sys_setfsuid /* 215 */
651 .long sys_getdents64 /* 220 */
656 .long sys_fsetxattr /* 225 */
661 .long sys_llistxattr /* 230 */
663 .long sys_removexattr
664 .long sys_lremovexattr
665 .long sys_fremovexattr
666 .long sys_futex /* 235 */
671 .long sys_readahead /* 240 */
674 .long sys_io_getevents
676 .long sys_io_cancel /* 245 */
679 .long sys_lookup_dcookie
680 .long sys_epoll_create
681 .long sys_epoll_ctl /* 250 */
683 .long sys_remap_file_pages
684 .long sys_set_tid_address
685 .long sys_timer_create
686 .long sys_timer_settime /* 255 */
687 .long sys_timer_gettime
688 .long sys_timer_getoverrun
689 .long sys_timer_delete
690 .long sys_clock_settime
691 .long sys_clock_gettime /* 260 */
692 .long sys_clock_getres
693 .long sys_clock_nanosleep
696 .long sys_tgkill /* 265 */
698 .long sys_fadvise64_64
700 .long sys_get_mempolicy
701 .long sys_set_mempolicy /* 270 */
704 .long sys_mq_timedsend
705 .long sys_mq_timedreceive
706 .long sys_mq_notify /* 275 */
707 .long sys_mq_getsetattr
709 .long sys_ni_syscall /* for sys_vserver */
711 .long sys_request_key /* 280 */
715 .long sys_inotify_init
716 .long sys_inotify_add_watch /* 285 */
717 .long sys_inotify_rm_watch
718 .long sys_migrate_pages
721 .long sys_mknodat /* 290 */
726 .long sys_renameat /* 295 */
731 .long sys_faccessat /* 300 */
732 .long sys_ni_syscall /* Reserved for pselect6 */
733 .long sys_ni_syscall /* Reserved for ppoll */
735 .long sys_set_robust_list
736 .long sys_get_robust_list /* 305 */
738 .long sys_sync_file_range
741 .long sys_move_pages /* 310 */
742 .long sys_sched_setaffinity
743 .long sys_sched_getaffinity
746 .long sys_epoll_pwait /* 315 */
749 .long sys_timerfd_create
751 .long sys_fallocate /* 320 */
752 .long sys_timerfd_settime
753 .long sys_timerfd_gettime
756 .long sys_epoll_create1 /* 325 */
759 .long sys_inotify_init1
761 .long sys_pwritev /* 330 */
762 .long sys_rt_tgsigqueueinfo
763 .long sys_perf_event_open