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_D0) | needed for strace
86 movel %sp@(PT_ORIG_D0),%d0
90 movel #-ENOSYS,%sp@(PT_D0)
99 jra .Lret_from_exception
101 ENTRY(ret_from_signal)
104 /* on 68040 complete pending writebacks if any */
106 bfextu %sp@(PT_VECTOR){#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_D0) | save the return value
133 movew %curptr@(TASK_INFO+TINFO_FLAGS+2),%d0
134 jne syscall_exit_work
138 btst #5,%sp@(PT_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_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)
182 jbra resume_userspace
185 bclr #7,%sp@(PT_SR) | clear trace bit in SR
192 jbra resume_userspace
195 /* This is the main interrupt handler for autovector interrupts */
197 ENTRY(auto_inthandler)
200 addqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
201 | put exception # in d0
202 bfextu %sp@(PT_VECTOR){#4,#10},%d0
206 movel %d0,%sp@- | put vector # on stack
207 auto_irqhandler_fixup = . + 2
208 jsr __m68k_handle_int | process the IRQ
209 addql #8,%sp | pop parameters off stack
212 subqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
213 jeq ret_from_last_interrupt
217 ret_from_last_interrupt:
218 moveq #(~ALLOWINT>>8)&0xff,%d0
222 /* check if we need to do software interrupts */
223 tstl irq_stat+CPUSTAT_SOFTIRQ_PENDING
224 jeq .Lret_from_exception
225 pea ret_from_exception
228 /* Handler for user defined interrupt vectors */
230 ENTRY(user_inthandler)
233 addqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
234 | put exception # in d0
235 bfextu %sp@(PT_VECTOR){#4,#10},%d0
236 user_irqvec_fixup = . + 2
240 movel %d0,%sp@- | put vector # on stack
241 user_irqhandler_fixup = . + 2
242 jsr __m68k_handle_int | process the IRQ
243 addql #8,%sp | pop parameters off stack
245 subqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
246 jeq ret_from_last_interrupt
249 /* Handler for uninitialized and spurious interrupts */
251 ENTRY(bad_inthandler)
254 addqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
260 subqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
261 jeq ret_from_last_interrupt
267 pea %sp@(SWITCH_STACK_SIZE)
275 pea %sp@(SWITCH_STACK_SIZE)
283 pea %sp@(SWITCH_STACK_SIZE)
289 ENTRY(sys_sigsuspend)
291 pea %sp@(SWITCH_STACK_SIZE)
297 ENTRY(sys_rt_sigsuspend)
299 pea %sp@(SWITCH_STACK_SIZE)
300 jbsr do_rt_sigsuspend
311 ENTRY(sys_rt_sigreturn)
319 * Beware - when entering resume, prev (the current task) is
320 * in a0, next (the new task) is in a1,so don't change these
321 * registers until their contents are no longer needed.
325 movew %sr,%a0@(TASK_THREAD+THREAD_SR)
327 /* save fs (sfc,%dfc) (may be pointing to kernel memory) */
329 movew %d0,%a0@(TASK_THREAD+THREAD_FS)
332 /* it is better to use a movel here instead of a movew 8*) */
334 movel %d0,%a0@(TASK_THREAD+THREAD_USP)
336 /* save non-scratch registers on stack */
339 /* save current kernel stack pointer */
340 movel %sp,%a0@(TASK_THREAD+THREAD_KSP)
342 /* save floating point context */
343 #ifndef CONFIG_M68KFPU_EMU_ONLY
344 #ifdef CONFIG_M68KFPU_EMU
348 fsave %a0@(TASK_THREAD+THREAD_FPSTATE)
350 #if defined(CONFIG_M68060)
351 #if !defined(CPU_M68060_ONLY)
352 btst #3,m68k_cputype+3
355 /* The 060 FPU keeps status in bits 15-8 of the first longword */
356 tstb %a0@(TASK_THREAD+THREAD_FPSTATE+2)
358 #if !defined(CPU_M68060_ONLY)
361 #endif /* CONFIG_M68060 */
362 #if !defined(CPU_M68060_ONLY)
363 1: tstb %a0@(TASK_THREAD+THREAD_FPSTATE)
366 2: fmovemx %fp0-%fp7,%a0@(TASK_THREAD+THREAD_FPREG)
367 fmoveml %fpcr/%fpsr/%fpiar,%a0@(TASK_THREAD+THREAD_FPCNTL)
369 #endif /* CONFIG_M68KFPU_EMU_ONLY */
370 /* Return previous task in %d1 */
373 /* switch to new task (a1 contains new task) */
376 /* restore floating point context */
377 #ifndef CONFIG_M68KFPU_EMU_ONLY
378 #ifdef CONFIG_M68KFPU_EMU
382 #if defined(CONFIG_M68060)
383 #if !defined(CPU_M68060_ONLY)
384 btst #3,m68k_cputype+3
387 /* The 060 FPU keeps status in bits 15-8 of the first longword */
388 tstb %a1@(TASK_THREAD+THREAD_FPSTATE+2)
390 #if !defined(CPU_M68060_ONLY)
393 #endif /* CONFIG_M68060 */
394 #if !defined(CPU_M68060_ONLY)
395 1: tstb %a1@(TASK_THREAD+THREAD_FPSTATE)
398 2: fmovemx %a1@(TASK_THREAD+THREAD_FPREG),%fp0-%fp7
399 fmoveml %a1@(TASK_THREAD+THREAD_FPCNTL),%fpcr/%fpsr/%fpiar
400 3: frestore %a1@(TASK_THREAD+THREAD_FPSTATE)
402 #endif /* CONFIG_M68KFPU_EMU_ONLY */
404 /* restore the kernel stack pointer */
405 movel %a1@(TASK_THREAD+THREAD_KSP),%sp
407 /* restore non-scratch registers */
410 /* restore user stack pointer */
411 movel %a1@(TASK_THREAD+THREAD_USP),%a0
414 /* restore fs (sfc,%dfc) */
415 movew %a1@(TASK_THREAD+THREAD_FS),%a0
419 /* restore status register */
420 movew %a1@(TASK_THREAD+THREAD_SR),%sr
427 .long sys_ni_syscall /* 0 - old "setup()" system call*/
432 .long sys_open /* 5 */
437 .long sys_unlink /* 10 */
442 .long sys_chmod /* 15 */
444 .long sys_ni_syscall /* old break syscall holder */
447 .long sys_getpid /* 20 */
452 .long sys_stime /* 25 */
457 .long sys_utime /* 30 */
458 .long sys_ni_syscall /* old stty syscall holder */
459 .long sys_ni_syscall /* old gtty syscall holder */
462 .long sys_ni_syscall /* 35 */ /* old ftime syscall holder */
467 .long sys_rmdir /* 40 */
471 .long sys_ni_syscall /* old prof syscall holder */
472 .long sys_brk /* 45 */
477 .long sys_getegid16 /* 50 */
479 .long sys_umount /* recycled never used phys() */
480 .long sys_ni_syscall /* old lock syscall holder */
482 .long sys_fcntl /* 55 */
483 .long sys_ni_syscall /* old mpx syscall holder */
485 .long sys_ni_syscall /* old ulimit syscall holder */
487 .long sys_umask /* 60 */
492 .long sys_getpgrp /* 65 */
497 .long sys_setreuid16 /* 70 */
501 .long sys_sethostname
502 .long sys_setrlimit /* 75 */
503 .long sys_old_getrlimit
505 .long sys_gettimeofday
506 .long sys_settimeofday
507 .long sys_getgroups16 /* 80 */
508 .long sys_setgroups16
512 .long sys_readlink /* 85 */
517 .long old_mmap /* 90 */
522 .long sys_fchown16 /* 95 */
523 .long sys_getpriority
524 .long sys_setpriority
525 .long sys_ni_syscall /* old profil syscall holder */
527 .long sys_fstatfs /* 100 */
528 .long sys_ni_syscall /* ioperm for i386 */
532 .long sys_getitimer /* 105 */
537 .long sys_ni_syscall /* 110 */ /* iopl for i386 */
539 .long sys_ni_syscall /* obsolete idle() syscall */
540 .long sys_ni_syscall /* vm86old for i386 */
542 .long sys_swapoff /* 115 */
547 .long sys_clone /* 120 */
548 .long sys_setdomainname
550 .long sys_cacheflush /* modify_ldt for i386 */
552 .long sys_mprotect /* 125 */
553 .long sys_sigprocmask
554 .long sys_ni_syscall /* old "create_module" */
555 .long sys_init_module
556 .long sys_delete_module
557 .long sys_ni_syscall /* 130 - old "get_kernel_syms" */
562 .long sys_sysfs /* 135 */
563 .long sys_personality
564 .long sys_ni_syscall /* for afs_syscall */
567 .long sys_llseek /* 140 */
572 .long sys_readv /* 145 */
577 .long sys_mlock /* 150 */
581 .long sys_sched_setparam
582 .long sys_sched_getparam /* 155 */
583 .long sys_sched_setscheduler
584 .long sys_sched_getscheduler
585 .long sys_sched_yield
586 .long sys_sched_get_priority_max
587 .long sys_sched_get_priority_min /* 160 */
588 .long sys_sched_rr_get_interval
591 .long sys_setresuid16
592 .long sys_getresuid16 /* 165 */
593 .long sys_getpagesize
594 .long sys_ni_syscall /* old sys_query_module */
597 .long sys_setresgid16 /* 170 */
598 .long sys_getresgid16
600 .long sys_rt_sigreturn
601 .long sys_rt_sigaction
602 .long sys_rt_sigprocmask /* 175 */
603 .long sys_rt_sigpending
604 .long sys_rt_sigtimedwait
605 .long sys_rt_sigqueueinfo
606 .long sys_rt_sigsuspend
607 .long sys_pread64 /* 180 */
612 .long sys_capset /* 185 */
613 .long sys_sigaltstack
615 .long sys_ni_syscall /* streams1 */
616 .long sys_ni_syscall /* streams2 */
617 .long sys_vfork /* 190 */
621 .long sys_ftruncate64
622 .long sys_stat64 /* 195 */
627 .long sys_getgid /* 200 */
632 .long sys_getgroups /* 205 */
637 .long sys_setresgid /* 210 */
642 .long sys_setfsuid /* 215 */
647 .long sys_getdents64 /* 220 */
652 .long sys_fsetxattr /* 225 */
657 .long sys_llistxattr /* 230 */
659 .long sys_removexattr
660 .long sys_lremovexattr
661 .long sys_fremovexattr
662 .long sys_futex /* 235 */
667 .long sys_readahead /* 240 */
670 .long sys_io_getevents
672 .long sys_io_cancel /* 245 */
675 .long sys_lookup_dcookie
676 .long sys_epoll_create
677 .long sys_epoll_ctl /* 250 */
679 .long sys_remap_file_pages
680 .long sys_set_tid_address
681 .long sys_timer_create
682 .long sys_timer_settime /* 255 */
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 /* 260 */
688 .long sys_clock_getres
689 .long sys_clock_nanosleep
692 .long sys_tgkill /* 265 */
694 .long sys_fadvise64_64
696 .long sys_get_mempolicy
697 .long sys_set_mempolicy /* 270 */
700 .long sys_mq_timedsend
701 .long sys_mq_timedreceive
702 .long sys_mq_notify /* 275 */
703 .long sys_mq_getsetattr
705 .long sys_ni_syscall /* for sys_vserver */
707 .long sys_request_key /* 280 */
711 .long sys_inotify_init
712 .long sys_inotify_add_watch /* 285 */
713 .long sys_inotify_rm_watch
714 .long sys_migrate_pages
717 .long sys_mknodat /* 290 */
722 .long sys_renameat /* 295 */
727 .long sys_faccessat /* 300 */
728 .long sys_ni_syscall /* Reserved for pselect6 */
729 .long sys_ni_syscall /* Reserved for ppoll */
731 .long sys_set_robust_list
732 .long sys_get_robust_list /* 305 */
734 .long sys_sync_file_range
737 .long sys_move_pages /* 310 */
738 .long sys_sched_setaffinity
739 .long sys_sched_getaffinity
742 .long sys_epoll_pwait /* 315 */
745 .long sys_timerfd_create
747 .long sys_fallocate /* 320 */
748 .long sys_timerfd_settime
749 .long sys_timerfd_gettime