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/config.h>
37 #include <linux/linkage.h>
38 #include <asm/entry.h>
39 #include <asm/errno.h>
40 #include <asm/setup.h>
41 #include <asm/segment.h>
42 #include <asm/traps.h>
43 #include <asm/unistd.h>
45 #include <asm/asm-offsets.h>
47 .globl system_call, buserr, trap, resume
49 .globl sys_fork, sys_clone, sys_vfork
50 .globl ret_from_interrupt, bad_interrupt
56 movel %sp,%sp@- | stack frame pointer argument
59 jra .Lret_from_exception
64 movel %sp,%sp@- | stack frame pointer argument
67 jra .Lret_from_exception
69 | After a fork we jump here directly from resume,
70 | so that %d1 contains the previous task
71 | schedule_tail now used regardless of CONFIG_SMP
76 jra .Lret_from_exception
79 movel #-ENOSYS,%sp@(PT_D0) | needed for strace
85 movel %sp@(PT_ORIG_D0),%d0
89 movel #-ENOSYS,%sp@(PT_D0)
98 jra .Lret_from_exception
100 ENTRY(ret_from_signal)
103 /* on 68040 complete pending writebacks if any */
105 bfextu %sp@(PT_VECTOR){#0,#4},%d0
106 subql #7,%d0 | bus error frame ?
113 jra .Lret_from_exception
120 movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0)
123 tstb %curptr@(TASK_INFO+TINFO_FLAGS+2)
125 cmpl #NR_syscalls,%d0
128 jbsr @(sys_call_table,%d0:l:4)@(0)
129 movel %d0,%sp@(PT_D0) | save the return value
132 movew %curptr@(TASK_INFO+TINFO_FLAGS+2),%d0
133 jne syscall_exit_work
137 btst #5,%sp@(PT_SR) | check if returning to kernel
138 bnes 1b | if so, skip resched, signals
148 ENTRY(ret_from_exception)
149 .Lret_from_exception:
150 btst #5,%sp@(PT_SR) | check if returning to kernel
151 bnes 1f | if so, skip resched, signals
152 | only allow interrupts when we are really the last one on the
153 | kernel stack, otherwise stack overflow can occur during
154 | heavy interrupt load
158 moveb %curptr@(TASK_INFO+TINFO_FLAGS+3),%d0
164 movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0)
173 subql #4,%sp | dummy return address
175 pea %sp@(SWITCH_STACK_SIZE)
181 jbra resume_userspace
184 bclr #7,%sp@(PT_SR) | clear trace bit in SR
191 jbra resume_userspace
194 /* This is the main interrupt handler for autovector interrupts */
196 ENTRY(auto_inthandler)
199 addqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
200 | put exception # in d0
201 bfextu %sp@(PT_VECTOR){#4,#10},%d0
205 movel %d0,%sp@- | put vector # on stack
206 #if defined(MACH_Q40_ONLY) && defined(CONFIG_BLK_DEV_FD)
207 btstb #4,0xff000000 | Q40 floppy needs very special treatment ...
215 jsr m68k_handle_int | process the IRQ
216 3: addql #8,%sp | pop parameters off stack
219 subqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
220 jeq ret_from_last_interrupt
224 ret_from_last_interrupt:
225 moveq #(~ALLOWINT>>8)&0xff,%d0
229 /* check if we need to do software interrupts */
230 tstl irq_stat+CPUSTAT_SOFTIRQ_PENDING
231 jeq .Lret_from_exception
232 pea ret_from_exception
235 /* Handler for user defined interrupt vectors */
237 ENTRY(mach_inthandler)
240 addqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
241 | put exception # in d0
242 bfextu %sp@(PT_VECTOR){#4,#10},%d0
245 movel %d0,%sp@- | put vector # on stack
246 movel mach_process_int,%a0
247 jsr %a0@ | process the IRQ
248 addql #8,%sp | pop parameters off stack
250 subqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
251 jeq ret_from_last_interrupt
254 /* Handler for uninitialized and spurious interrupts */
256 ENTRY(bad_inthandler)
259 addqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
265 subqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1)
266 jeq ret_from_last_interrupt
272 pea %sp@(SWITCH_STACK_SIZE)
280 pea %sp@(SWITCH_STACK_SIZE)
288 pea %sp@(SWITCH_STACK_SIZE)
294 ENTRY(sys_sigsuspend)
296 pea %sp@(SWITCH_STACK_SIZE)
302 ENTRY(sys_rt_sigsuspend)
304 pea %sp@(SWITCH_STACK_SIZE)
305 jbsr do_rt_sigsuspend
316 ENTRY(sys_rt_sigreturn)
324 * Beware - when entering resume, prev (the current task) is
325 * in a0, next (the new task) is in a1,so don't change these
326 * registers until their contents are no longer needed.
330 movew %sr,%a0@(TASK_THREAD+THREAD_SR)
332 /* save fs (sfc,%dfc) (may be pointing to kernel memory) */
334 movew %d0,%a0@(TASK_THREAD+THREAD_FS)
337 /* it is better to use a movel here instead of a movew 8*) */
339 movel %d0,%a0@(TASK_THREAD+THREAD_USP)
341 /* save non-scratch registers on stack */
344 /* save current kernel stack pointer */
345 movel %sp,%a0@(TASK_THREAD+THREAD_KSP)
347 /* save floating point context */
348 #ifndef CONFIG_M68KFPU_EMU_ONLY
349 #ifdef CONFIG_M68KFPU_EMU
353 fsave %a0@(TASK_THREAD+THREAD_FPSTATE)
355 #if defined(CONFIG_M68060)
356 #if !defined(CPU_M68060_ONLY)
357 btst #3,m68k_cputype+3
360 /* The 060 FPU keeps status in bits 15-8 of the first longword */
361 tstb %a0@(TASK_THREAD+THREAD_FPSTATE+2)
363 #if !defined(CPU_M68060_ONLY)
366 #endif /* CONFIG_M68060 */
367 #if !defined(CPU_M68060_ONLY)
368 1: tstb %a0@(TASK_THREAD+THREAD_FPSTATE)
371 2: fmovemx %fp0-%fp7,%a0@(TASK_THREAD+THREAD_FPREG)
372 fmoveml %fpcr/%fpsr/%fpiar,%a0@(TASK_THREAD+THREAD_FPCNTL)
374 #endif /* CONFIG_M68KFPU_EMU_ONLY */
375 /* Return previous task in %d1 */
378 /* switch to new task (a1 contains new task) */
381 /* restore floating point context */
382 #ifndef CONFIG_M68KFPU_EMU_ONLY
383 #ifdef CONFIG_M68KFPU_EMU
387 #if defined(CONFIG_M68060)
388 #if !defined(CPU_M68060_ONLY)
389 btst #3,m68k_cputype+3
392 /* The 060 FPU keeps status in bits 15-8 of the first longword */
393 tstb %a1@(TASK_THREAD+THREAD_FPSTATE+2)
395 #if !defined(CPU_M68060_ONLY)
398 #endif /* CONFIG_M68060 */
399 #if !defined(CPU_M68060_ONLY)
400 1: tstb %a1@(TASK_THREAD+THREAD_FPSTATE)
403 2: fmovemx %a1@(TASK_THREAD+THREAD_FPREG),%fp0-%fp7
404 fmoveml %a1@(TASK_THREAD+THREAD_FPCNTL),%fpcr/%fpsr/%fpiar
405 3: frestore %a1@(TASK_THREAD+THREAD_FPSTATE)
407 #endif /* CONFIG_M68KFPU_EMU_ONLY */
409 /* restore the kernel stack pointer */
410 movel %a1@(TASK_THREAD+THREAD_KSP),%sp
412 /* restore non-scratch registers */
415 /* restore user stack pointer */
416 movel %a1@(TASK_THREAD+THREAD_USP),%a0
419 /* restore fs (sfc,%dfc) */
420 movew %a1@(TASK_THREAD+THREAD_FS),%a0
424 /* restore status register */
425 movew %a1@(TASK_THREAD+THREAD_SR),%sr
432 .long sys_ni_syscall /* 0 - old "setup()" system call*/
437 .long sys_open /* 5 */
442 .long sys_unlink /* 10 */
447 .long sys_chmod /* 15 */
449 .long sys_ni_syscall /* old break syscall holder */
452 .long sys_getpid /* 20 */
457 .long sys_stime /* 25 */
462 .long sys_utime /* 30 */
463 .long sys_ni_syscall /* old stty syscall holder */
464 .long sys_ni_syscall /* old gtty syscall holder */
467 .long sys_ni_syscall /* 35 */ /* old ftime syscall holder */
472 .long sys_rmdir /* 40 */
476 .long sys_ni_syscall /* old prof syscall holder */
477 .long sys_brk /* 45 */
482 .long sys_getegid16 /* 50 */
484 .long sys_umount /* recycled never used phys() */
485 .long sys_ni_syscall /* old lock syscall holder */
487 .long sys_fcntl /* 55 */
488 .long sys_ni_syscall /* old mpx syscall holder */
490 .long sys_ni_syscall /* old ulimit syscall holder */
492 .long sys_umask /* 60 */
497 .long sys_getpgrp /* 65 */
502 .long sys_setreuid16 /* 70 */
506 .long sys_sethostname
507 .long sys_setrlimit /* 75 */
508 .long sys_old_getrlimit
510 .long sys_gettimeofday
511 .long sys_settimeofday
512 .long sys_getgroups16 /* 80 */
513 .long sys_setgroups16
517 .long sys_readlink /* 85 */
522 .long old_mmap /* 90 */
527 .long sys_fchown16 /* 95 */
528 .long sys_getpriority
529 .long sys_setpriority
530 .long sys_ni_syscall /* old profil syscall holder */
532 .long sys_fstatfs /* 100 */
533 .long sys_ni_syscall /* ioperm for i386 */
537 .long sys_getitimer /* 105 */
542 .long sys_ni_syscall /* 110 */ /* iopl for i386 */
544 .long sys_ni_syscall /* obsolete idle() syscall */
545 .long sys_ni_syscall /* vm86old for i386 */
547 .long sys_swapoff /* 115 */
552 .long sys_clone /* 120 */
553 .long sys_setdomainname
555 .long sys_cacheflush /* modify_ldt for i386 */
557 .long sys_mprotect /* 125 */
558 .long sys_sigprocmask
559 .long sys_ni_syscall /* old "create_module" */
560 .long sys_init_module
561 .long sys_delete_module
562 .long sys_ni_syscall /* 130 - old "get_kernel_syms" */
567 .long sys_sysfs /* 135 */
568 .long sys_personality
569 .long sys_ni_syscall /* for afs_syscall */
572 .long sys_llseek /* 140 */
577 .long sys_readv /* 145 */
582 .long sys_mlock /* 150 */
586 .long sys_sched_setparam
587 .long sys_sched_getparam /* 155 */
588 .long sys_sched_setscheduler
589 .long sys_sched_getscheduler
590 .long sys_sched_yield
591 .long sys_sched_get_priority_max
592 .long sys_sched_get_priority_min /* 160 */
593 .long sys_sched_rr_get_interval
596 .long sys_setresuid16
597 .long sys_getresuid16 /* 165 */
598 .long sys_getpagesize
599 .long sys_ni_syscall /* old sys_query_module */
602 .long sys_setresgid16 /* 170 */
603 .long sys_getresgid16
605 .long sys_rt_sigreturn
606 .long sys_rt_sigaction
607 .long sys_rt_sigprocmask /* 175 */
608 .long sys_rt_sigpending
609 .long sys_rt_sigtimedwait
610 .long sys_rt_sigqueueinfo
611 .long sys_rt_sigsuspend
612 .long sys_pread64 /* 180 */
617 .long sys_capset /* 185 */
618 .long sys_sigaltstack
620 .long sys_ni_syscall /* streams1 */
621 .long sys_ni_syscall /* streams2 */
622 .long sys_vfork /* 190 */
626 .long sys_ftruncate64
627 .long sys_stat64 /* 195 */
632 .long sys_getgid /* 200 */
637 .long sys_getgroups /* 205 */
642 .long sys_setresgid /* 210 */
647 .long sys_setfsuid /* 215 */
652 .long sys_getdents64 /* 220 */
657 .long sys_fsetxattr /* 225 */
662 .long sys_llistxattr /* 230 */
664 .long sys_removexattr
665 .long sys_lremovexattr
666 .long sys_fremovexattr
667 .long sys_futex /* 235 */
672 .long sys_readahead /* 240 */
675 .long sys_io_getevents
677 .long sys_io_cancel /* 245 */
680 .long sys_lookup_dcookie
681 .long sys_epoll_create
682 .long sys_epoll_ctl /* 250 */
684 .long sys_remap_file_pages
685 .long sys_set_tid_address
686 .long sys_timer_create
687 .long sys_timer_settime /* 255 */
688 .long sys_timer_gettime
689 .long sys_timer_getoverrun
690 .long sys_timer_delete
691 .long sys_clock_settime
692 .long sys_clock_gettime /* 260 */
693 .long sys_clock_getres
694 .long sys_clock_nanosleep
697 .long sys_tgkill /* 265 */
699 .long sys_fadvise64_64
701 .long sys_get_mempolicy
702 .long sys_set_mempolicy /* 270 */
705 .long sys_mq_timedsend
706 .long sys_mq_timedreceive
707 .long sys_mq_notify /* 275 */
708 .long sys_mq_getsetattr
710 .long sys_ni_syscall /* for sys_vserver */
712 .long sys_request_key /* 280 */