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
48 .globl resume, ret_from_exception
49 .globl ret_from_signal
50 .globl inthandler, sys_call_table
51 .globl sys_fork, sys_clone, sys_vfork
52 .globl ret_from_interrupt, bad_interrupt
58 movel %sp,%sp@- | stack frame pointer argument
61 jra ret_from_exception
66 movel %sp,%sp@- | stack frame pointer argument
69 jra ret_from_exception
71 | After a fork we jump here directly from resume,
72 | so that %d1 contains the previous task
73 | schedule_tail now used regardless of CONFIG_SMP
78 jra ret_from_exception
81 movel #-ENOSYS,%sp@(PT_D0)
82 jra ret_from_exception
85 movel #-ENOSYS,%sp@(PT_D0) | needed for strace
91 movel %sp@(PT_ORIG_D0),%d1
95 jbsr @(sys_call_table,%d1:l:4)@(0)
96 1: movel %d0,%sp@(PT_D0) | save the return value
97 subql #4,%sp | dummy return address
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 ret_from_exception
121 movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0)
123 tstb %curptr@(TASK_SYSCALL_TRACE)
125 cmpl #NR_syscalls,%d0
127 jbsr @(sys_call_table,%d0:l:4)@(0)
128 movel %d0,%sp@(PT_D0) | save the return value
131 movel %curptr@(TASK_WORK),%d0
132 jne syscall_exit_work
136 btst #5,%sp@(PT_SR) | check if returning to kernel
137 bnes 1b | if so, skip resched, signals
147 btst #5,%sp@(PT_SR) | check if returning to kernel
148 bnes 1f | if so, skip resched, signals
149 | only allow interrupts when we are really the last one on the
150 | kernel stack, otherwise stack overflow can occur during
151 | heavy interrupt load
155 movel %curptr@(TASK_WORK),%d0
162 movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0)
171 subql #4,%sp | dummy return address
173 pea %sp@(SWITCH_STACK_SIZE)
179 jbra resume_userspace
182 bclr #7,%sp@(PT_SR) | clear trace bit in SR
189 jbra resume_userspace
195 addql #1,irq_stat+CPUSTAT_LOCAL_IRQ_COUNT
199 bfextu %sp@(PT_VECTOR){#4,#12},%d0
201 addql #1,%a0@(kstat+STAT_IRQ-VECOFF(VEC_SPUR))
202 movel %a0@(autoirq_list-VECOFF(VEC_SPUR)),%a0
204 | amiga vector int handler get the req mask instead of irq vector
206 movew %a1@(C_INTREQR),%d0
207 andw %a1@(C_INTENAR),%d0
209 | prepare stack (push frame pointer, dev_id & req mask)
211 movel %a0@(IRQ_DEVID),%sp@-
213 pea %pc@(ret_from_interrupt:w)
214 jbra @(IRQ_HANDLER,%a0)@(0)
222 ** This is the main interrupt handler, responsible for calling process_int()
227 addqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+2)
228 | put exception # in d0
229 bfextu %sp@(PT_VECTOR){#4,#10},%d0
232 movel %d0,%sp@- | put vector # on stack
233 #if defined(MACH_Q40_ONLY) && defined(CONFIG_BLK_DEV_FD)
234 btstb #4,0xff000000 | Q40 floppy needs very special treatment ...
242 jbsr process_int | process the IRQ
243 3: addql #8,%sp | pop parameters off stack
246 subqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+2)
251 moveq #(~ALLOWINT>>8)&0xff,%d0
255 /* check if we need to do software interrupts */
256 tstl irq_stat+CPUSTAT_SOFTIRQ_PENDING
257 jeq ret_from_exception
258 pea ret_from_exception
262 /* Handler for uninitialized and spurious interrupts */
265 addql #1,num_spurious
270 pea %sp@(SWITCH_STACK_SIZE)
278 pea %sp@(SWITCH_STACK_SIZE)
286 pea %sp@(SWITCH_STACK_SIZE)
292 ENTRY(sys_sigsuspend)
294 pea %sp@(SWITCH_STACK_SIZE)
300 ENTRY(sys_rt_sigsuspend)
302 pea %sp@(SWITCH_STACK_SIZE)
303 jbsr do_rt_sigsuspend
314 ENTRY(sys_rt_sigreturn)
322 * Beware - when entering resume, prev (the current task) is
323 * in a0, next (the new task) is in a1,so don't change these
324 * registers until their contents are no longer needed.
328 movew %sr,%a0@(TASK_THREAD+THREAD_SR)
330 /* save fs (sfc,%dfc) (may be pointing to kernel memory) */
332 movew %d0,%a0@(TASK_THREAD+THREAD_FS)
335 /* it is better to use a movel here instead of a movew 8*) */
337 movel %d0,%a0@(TASK_THREAD+THREAD_USP)
339 /* save non-scratch registers on stack */
342 /* save current kernel stack pointer */
343 movel %sp,%a0@(TASK_THREAD+THREAD_KSP)
345 /* save floating point context */
346 #ifndef CONFIG_M68KFPU_EMU_ONLY
347 #ifdef CONFIG_M68KFPU_EMU
351 fsave %a0@(TASK_THREAD+THREAD_FPSTATE)
353 #if defined(CONFIG_M68060)
354 #if !defined(CPU_M68060_ONLY)
355 btst #3,m68k_cputype+3
358 /* The 060 FPU keeps status in bits 15-8 of the first longword */
359 tstb %a0@(TASK_THREAD+THREAD_FPSTATE+2)
361 #if !defined(CPU_M68060_ONLY)
364 #endif /* CONFIG_M68060 */
365 #if !defined(CPU_M68060_ONLY)
366 1: tstb %a0@(TASK_THREAD+THREAD_FPSTATE)
369 2: fmovemx %fp0-%fp7,%a0@(TASK_THREAD+THREAD_FPREG)
370 fmoveml %fpcr/%fpsr/%fpiar,%a0@(TASK_THREAD+THREAD_FPCNTL)
372 #endif /* CONFIG_M68KFPU_EMU_ONLY */
373 /* Return previous task in %d1 */
376 /* switch to new task (a1 contains new task) */
379 /* restore floating point context */
380 #ifndef CONFIG_M68KFPU_EMU_ONLY
381 #ifdef CONFIG_M68KFPU_EMU
385 #if defined(CONFIG_M68060)
386 #if !defined(CPU_M68060_ONLY)
387 btst #3,m68k_cputype+3
390 /* The 060 FPU keeps status in bits 15-8 of the first longword */
391 tstb %a1@(TASK_THREAD+THREAD_FPSTATE+2)
393 #if !defined(CPU_M68060_ONLY)
396 #endif /* CONFIG_M68060 */
397 #if !defined(CPU_M68060_ONLY)
398 1: tstb %a1@(TASK_THREAD+THREAD_FPSTATE)
401 2: fmovemx %a1@(TASK_THREAD+THREAD_FPREG),%fp0-%fp7
402 fmoveml %a1@(TASK_THREAD+THREAD_FPCNTL),%fpcr/%fpsr/%fpiar
403 3: frestore %a1@(TASK_THREAD+THREAD_FPSTATE)
405 #endif /* CONFIG_M68KFPU_EMU_ONLY */
407 /* restore the kernel stack pointer */
408 movel %a1@(TASK_THREAD+THREAD_KSP),%sp
410 /* restore non-scratch registers */
413 /* restore user stack pointer */
414 movel %a1@(TASK_THREAD+THREAD_USP),%a0
417 /* restore fs (sfc,%dfc) */
418 movew %a1@(TASK_THREAD+THREAD_FS),%a0
422 /* restore status register */
423 movew %a1@(TASK_THREAD+THREAD_SR),%sr
430 .long sys_ni_syscall /* 0 - old "setup()" system call*/
435 .long sys_open /* 5 */
440 .long sys_unlink /* 10 */
445 .long sys_chmod /* 15 */
447 .long sys_ni_syscall /* old break syscall holder */
450 .long sys_getpid /* 20 */
455 .long sys_stime /* 25 */
460 .long sys_utime /* 30 */
461 .long sys_ni_syscall /* old stty syscall holder */
462 .long sys_ni_syscall /* old gtty syscall holder */
465 .long sys_ni_syscall /* 35 */ /* old ftime syscall holder */
470 .long sys_rmdir /* 40 */
474 .long sys_ni_syscall /* old prof syscall holder */
475 .long sys_brk /* 45 */
480 .long sys_getegid16 /* 50 */
482 .long sys_umount /* recycled never used phys() */
483 .long sys_ni_syscall /* old lock syscall holder */
485 .long sys_fcntl /* 55 */
486 .long sys_ni_syscall /* old mpx syscall holder */
488 .long sys_ni_syscall /* old ulimit syscall holder */
490 .long sys_umask /* 60 */
495 .long sys_getpgrp /* 65 */
500 .long sys_setreuid16 /* 70 */
504 .long sys_sethostname
505 .long sys_setrlimit /* 75 */
506 .long sys_old_getrlimit
508 .long sys_gettimeofday
509 .long sys_settimeofday
510 .long sys_getgroups16 /* 80 */
511 .long sys_setgroups16
515 .long sys_readlink /* 85 */
520 .long old_mmap /* 90 */
525 .long sys_fchown16 /* 95 */
526 .long sys_getpriority
527 .long sys_setpriority
528 .long sys_ni_syscall /* old profil syscall holder */
530 .long sys_fstatfs /* 100 */
531 .long sys_ni_syscall /* ioperm for i386 */
535 .long sys_getitimer /* 105 */
540 .long sys_ni_syscall /* 110 */ /* iopl for i386 */
542 .long sys_ni_syscall /* obsolete idle() syscall */
543 .long sys_ni_syscall /* vm86old for i386 */
545 .long sys_swapoff /* 115 */
550 .long sys_clone /* 120 */
551 .long sys_setdomainname
553 .long sys_cacheflush /* modify_ldt for i386 */
555 .long sys_mprotect /* 125 */
556 .long sys_sigprocmask
557 .long sys_ni_syscall /* old "create_module" */
558 .long sys_init_module
559 .long sys_delete_module
560 .long sys_ni_syscall /* 130 - old "get_kernel_syms" */
565 .long sys_sysfs /* 135 */
566 .long sys_personality
567 .long sys_ni_syscall /* for afs_syscall */
570 .long sys_llseek /* 140 */
575 .long sys_readv /* 145 */
580 .long sys_mlock /* 150 */
584 .long sys_sched_setparam
585 .long sys_sched_getparam /* 155 */
586 .long sys_sched_setscheduler
587 .long sys_sched_getscheduler
588 .long sys_sched_yield
589 .long sys_sched_get_priority_max
590 .long sys_sched_get_priority_min /* 160 */
591 .long sys_sched_rr_get_interval
594 .long sys_setresuid16
595 .long sys_getresuid16 /* 165 */
596 .long sys_getpagesize
597 .long sys_ni_syscall /* old sys_query_module */
600 .long sys_setresgid16 /* 170 */
601 .long sys_getresgid16
603 .long sys_rt_sigreturn
604 .long sys_rt_sigaction
605 .long sys_rt_sigprocmask /* 175 */
606 .long sys_rt_sigpending
607 .long sys_rt_sigtimedwait
608 .long sys_rt_sigqueueinfo
609 .long sys_rt_sigsuspend
610 .long sys_pread64 /* 180 */
615 .long sys_capset /* 185 */
616 .long sys_sigaltstack
618 .long sys_ni_syscall /* streams1 */
619 .long sys_ni_syscall /* streams2 */
620 .long sys_vfork /* 190 */
624 .long sys_ftruncate64
625 .long sys_stat64 /* 195 */
630 .long sys_getgid /* 200 */
635 .long sys_getgroups /* 205 */
640 .long sys_setresgid /* 210 */
645 .long sys_setfsuid /* 215 */
650 .long sys_getdents64 /* 220 */
655 .long sys_fsetxattr /* 225 */
660 .long sys_llistxattr /* 230 */
662 .long sys_removexattr
663 .long sys_lremovexattr
664 .long sys_fremovexattr
665 .long sys_futex /* 235 */
670 .long sys_readahead /* 240 */
673 .long sys_io_getevents
675 .long sys_io_cancel /* 245 */
678 .long sys_lookup_dcookie
679 .long sys_epoll_create
680 .long sys_epoll_ctl /* 250 */
682 .long sys_remap_file_pages
683 .long sys_set_tid_address
684 .long sys_timer_create
685 .long sys_timer_settime /* 255 */
686 .long sys_timer_gettime
687 .long sys_timer_getoverrun
688 .long sys_timer_delete
689 .long sys_clock_settime
690 .long sys_clock_gettime /* 260 */
691 .long sys_clock_getres
692 .long sys_clock_nanosleep
695 .long sys_tgkill /* 265 */
697 .long sys_fadvise64_64
699 .long sys_get_mempolicy
700 .long sys_set_mempolicy /* 270 */
703 .long sys_mq_timedsend
704 .long sys_mq_timedreceive
705 .long sys_mq_notify /* 275 */
706 .long sys_mq_getsetattr
708 .long sys_ni_syscall /* for sys_vserver */
710 .long sys_request_key /* 280 */