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.
33 #include <linux/sys.h>
34 #include <linux/config.h>
35 #include <linux/linkage.h>
36 #include <asm/entry.h>
37 #include <asm/errno.h>
38 #include <asm/setup.h>
39 #include <asm/segment.h>
40 #include <asm/traps.h>
42 #include "m68k_defs.h"
44 .globl SYMBOL_NAME(system_call), SYMBOL_NAME(buserr), SYMBOL_NAME(trap)
45 .globl SYMBOL_NAME(resume), SYMBOL_NAME(ret_from_exception)
46 .globl SYMBOL_NAME(ret_from_signal)
47 .globl SYMBOL_NAME(inthandler), SYMBOL_NAME(sys_call_table)
48 .globl SYMBOL_NAME(sys_fork), SYMBOL_NAME(sys_clone), SYMBOL_NAME(sys_vfork)
49 .globl SYMBOL_NAME(ret_from_interrupt), SYMBOL_NAME(bad_interrupt)
55 movel %sp,%sp@- | stack frame pointer argument
56 bsrl SYMBOL_NAME(buserr_c)
58 jra SYMBOL_NAME(ret_from_exception)
63 movel %sp,%sp@- | stack frame pointer argument
64 bsrl SYMBOL_NAME(trap_c)
66 jra SYMBOL_NAME(ret_from_exception)
70 movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0)
72 pea SYMBOL_NAME(ret_from_exception)
73 jmp SYMBOL_NAME(schedule)
75 | After a fork we jump here directly from resume,
76 | so that %d1 contains the previous task
77 | Theoretically only needed on SMP, but let's watch
78 | what happens in schedule_tail() in future...
81 jsr SYMBOL_NAME(schedule_tail)
83 jra SYMBOL_NAME(ret_from_exception)
86 movel #-ENOSYS,PT_D0(%sp)
87 jra SYMBOL_NAME(ret_from_exception)
90 movel #-ENOSYS,PT_D0(%sp) | needed for strace
93 jbsr SYMBOL_NAME(syscall_trace)
96 jbsr @(SYMBOL_NAME(sys_call_table),%d2:l:4)@(0)
97 movel %d0,%sp@(PT_D0) | save the return value
98 subql #4,%sp | dummy return address
100 jbsr SYMBOL_NAME(syscall_trace)
102 SYMBOL_NAME_LABEL(ret_from_signal)
105 jra SYMBOL_NAME(ret_from_exception)
113 movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0)
115 cmpl #NR_syscalls,%d2
117 btst #PF_TRACESYS_BIT,%curptr@(TASK_FLAGS+PF_TRACESYS_OFF)
119 jbsr @(SYMBOL_NAME(sys_call_table),%d2:l:4)@(0)
120 movel %d0,%sp@(PT_D0) | save the return value
122 SYMBOL_NAME_LABEL(ret_from_exception)
123 btst #5,%sp@(PT_SR) | check if returning to kernel
124 bnes 2f | if so, skip resched, signals
125 | only allow interrupts when we are really the last one on the
126 | kernel stack, otherwise stack overflow can occur during
127 | heavy interupt load
129 tstl %curptr@(TASK_NEEDRESCHED)
130 jne SYMBOL_NAME(reschedule)
132 cmpl #SYMBOL_NAME(task),%curptr | task[0] cannot have signals
135 | check for delayed trace
136 bclr #PF_DTRACE_BIT,%curptr@(TASK_FLAGS+PF_DTRACE_OFF)
139 tstl %curptr@(TASK_STATE) | state
140 jne SYMBOL_NAME(reschedule)
142 tstl %curptr@(TASK_SIGPENDING)
147 subql #4,%sp | dummy return address
149 pea %sp@(SWITCH_STACK_SIZE)
151 bsrl SYMBOL_NAME(do_signal)
158 bclr #7,%sp@(PT_SR) | clear trace bit in SR
162 jbsr SYMBOL_NAME(send_sig)
170 SYMBOL_NAME_LABEL(ami_inthandler)
171 addql #1,SYMBOL_NAME(local_irq_count)
175 bfextu %sp@(PT_VECTOR){#4,#12},%d0
177 addql #1,%a0@(SYMBOL_NAME(kstat)+STAT_IRQ-VECOFF(VEC_SPUR))
178 movel %a0@(SYMBOL_NAME(autoirq_list)-VECOFF(VEC_SPUR)),%a0
180 | amiga vector int handler get the req mask instead of irq vector
182 movew %a1@(C_INTREQR),%d0
183 andw %a1@(C_INTENAR),%d0
185 | prepare stack (push frame pointer, dev_id & req mask)
187 movel %a0@(IRQ_DEVID),%sp@-
189 pea %pc@(SYMBOL_NAME(ret_from_interrupt):w)
190 jbra @(IRQ_HANDLER,%a0)@(0)
198 ** This is the main interrupt handler, responsible for calling process_int()
200 SYMBOL_NAME_LABEL(inthandler)
203 addql #1,SYMBOL_NAME(local_irq_count)
204 | put exception # in d0
205 bfextu %sp@(PT_VECTOR){#4,#10},%d0
208 movel %d0,%sp@- | put vector # on stack
209 #if defined(MACH_Q40_ONLY) && defined(CONFIG_BLK_DEV_FD)
210 btstb #4,0xff000000 | Q40 floppy needs very special treatment ...
214 jbsr SYMBOL_NAME(floppy_hardint)
218 jbsr SYMBOL_NAME(process_int)| process the IRQ
219 3: addql #8,%sp | pop parameters off stack
221 SYMBOL_NAME_LABEL(ret_from_interrupt)
222 subql #1,SYMBOL_NAME(local_irq_count)
228 bfextu %sp@(PT_SR){#5,#3},%d0 | Check for nested interrupt.
229 #if MAX_NOINT_IPL > 0
230 cmpiw #MAX_NOINT_IPL,%d0
234 /* check if we need to do software interrupts */
236 movel SYMBOL_NAME(bh_active),%d0
237 andl SYMBOL_NAME(bh_mask),%d0
238 jeq SYMBOL_NAME(ret_from_exception)
240 pea SYMBOL_NAME(ret_from_exception)
241 jra SYMBOL_NAME(do_bottom_half)
244 /* Handler for uninitialized and spurious interrupts */
246 SYMBOL_NAME_LABEL(bad_interrupt)
247 addql #1,SYMBOL_NAME(num_spurious)
252 pea %sp@(SWITCH_STACK_SIZE)
253 jbsr SYMBOL_NAME(m68k_fork)
260 pea %sp@(SWITCH_STACK_SIZE)
261 jbsr SYMBOL_NAME(m68k_clone)
268 pea %sp@(SWITCH_STACK_SIZE)
269 jbsr SYMBOL_NAME(m68k_vfork)
274 ENTRY(sys_sigsuspend)
276 pea %sp@(SWITCH_STACK_SIZE)
277 jbsr SYMBOL_NAME(do_sigsuspend)
282 ENTRY(sys_rt_sigsuspend)
284 pea %sp@(SWITCH_STACK_SIZE)
285 jbsr SYMBOL_NAME(do_rt_sigsuspend)
292 jbsr SYMBOL_NAME(do_sigreturn)
296 ENTRY(sys_rt_sigreturn)
298 jbsr SYMBOL_NAME(do_rt_sigreturn)
302 SYMBOL_NAME_LABEL(resume)
304 * Beware - when entering resume, prev (the current task) is
305 * in a0, next (the new task) is in a1,so don't change these
306 * registers until their contents are no longer needed.
310 movew %sr,%a0@(TASK_THREAD+THREAD_SR)
312 /* save fs (sfc,%dfc) (may be pointing to kernel memory) */
314 movew %d0,%a0@(TASK_THREAD+THREAD_FS)
317 /* it is better to use a movel here instead of a movew 8*) */
319 movel %d0,%a0@(TASK_THREAD+THREAD_USP)
321 /* save non-scratch registers on stack */
324 /* save current kernel stack pointer */
325 movel %sp,%a0@(TASK_THREAD+THREAD_KSP)
327 /* save floating point context */
328 #ifndef CONFIG_M68KFPU_EMU_ONLY
329 #ifdef CONFIG_M68KFPU_EMU
330 tstl SYMBOL_NAME(m68k_fputype)
333 fsave %a0@(TASK_THREAD+THREAD_FPSTATE)
335 #if defined(CONFIG_M68060)
336 #if !defined(CPU_M68060_ONLY)
337 btst #3,SYMBOL_NAME(m68k_cputype)+3
340 /* The 060 FPU keeps status in bits 15-8 of the first longword */
341 tstb %a0@(TASK_THREAD+THREAD_FPSTATE+2)
343 #if !defined(CPU_M68060_ONLY)
346 #endif /* CONFIG_M68060 */
347 #if !defined(CPU_M68060_ONLY)
348 1: tstb %a0@(TASK_THREAD+THREAD_FPSTATE)
351 2: fmovemx %fp0-%fp7,%a0@(TASK_THREAD+THREAD_FPREG)
352 fmoveml %fpcr/%fpsr/%fpiar,%a0@(TASK_THREAD+THREAD_FPCNTL)
354 #endif /* CONFIG_M68KFPU_EMU_ONLY */
355 /* Return previous task in %d1 */
358 /* switch to new task (a1 contains new task) */
361 /* restore floating point context */
362 #ifndef CONFIG_M68KFPU_EMU_ONLY
363 #ifdef CONFIG_M68KFPU_EMU
364 tstl SYMBOL_NAME(m68k_fputype)
367 #if defined(CONFIG_M68060)
368 #if !defined(CPU_M68060_ONLY)
369 btst #3,SYMBOL_NAME(m68k_cputype)+3
372 /* The 060 FPU keeps status in bits 15-8 of the first longword */
373 tstb %a1@(TASK_THREAD+THREAD_FPSTATE+2)
375 #if !defined(CPU_M68060_ONLY)
378 #endif /* CONFIG_M68060 */
379 #if !defined(CPU_M68060_ONLY)
380 1: tstb %a1@(TASK_THREAD+THREAD_FPSTATE)
383 2: fmovemx %a1@(TASK_THREAD+THREAD_FPREG),%fp0-%fp7
384 fmoveml %a1@(TASK_THREAD+THREAD_FPCNTL),%fpcr/%fpsr/%fpiar
385 3: frestore %a1@(TASK_THREAD+THREAD_FPSTATE)
387 #endif /* CONFIG_M68KFPU_EMU_ONLY */
389 /* restore the kernel stack pointer */
390 movel %a1@(TASK_THREAD+THREAD_KSP),%sp
392 /* restore non-scratch registers */
395 /* restore user stack pointer */
396 movel %a1@(TASK_THREAD+THREAD_USP),%a0
399 /* restore fs (sfc,%dfc) */
400 movew %a1@(TASK_THREAD+THREAD_FS),%a0
404 /* restore status register */
405 movew %a1@(TASK_THREAD+THREAD_SR),%sr
411 SYMBOL_NAME_LABEL(sys_call_table)
412 .long SYMBOL_NAME(sys_ni_syscall) /* 0 - old "setup()" system call*/
413 .long SYMBOL_NAME(sys_exit)
414 .long SYMBOL_NAME(sys_fork)
415 .long SYMBOL_NAME(sys_read)
416 .long SYMBOL_NAME(sys_write)
417 .long SYMBOL_NAME(sys_open) /* 5 */
418 .long SYMBOL_NAME(sys_close)
419 .long SYMBOL_NAME(sys_waitpid)
420 .long SYMBOL_NAME(sys_creat)
421 .long SYMBOL_NAME(sys_link)
422 .long SYMBOL_NAME(sys_unlink) /* 10 */
423 .long SYMBOL_NAME(sys_execve)
424 .long SYMBOL_NAME(sys_chdir)
425 .long SYMBOL_NAME(sys_time)
426 .long SYMBOL_NAME(sys_mknod)
427 .long SYMBOL_NAME(sys_chmod) /* 15 */
428 .long SYMBOL_NAME(sys_chown)
429 .long SYMBOL_NAME(sys_ni_syscall) /* old break syscall holder */
430 .long SYMBOL_NAME(sys_stat)
431 .long SYMBOL_NAME(sys_lseek)
432 .long SYMBOL_NAME(sys_getpid) /* 20 */
433 .long SYMBOL_NAME(sys_mount)
434 .long SYMBOL_NAME(sys_oldumount)
435 .long SYMBOL_NAME(sys_setuid)
436 .long SYMBOL_NAME(sys_getuid)
437 .long SYMBOL_NAME(sys_stime) /* 25 */
438 .long SYMBOL_NAME(sys_ptrace)
439 .long SYMBOL_NAME(sys_alarm)
440 .long SYMBOL_NAME(sys_fstat)
441 .long SYMBOL_NAME(sys_pause)
442 .long SYMBOL_NAME(sys_utime) /* 30 */
443 .long SYMBOL_NAME(sys_ni_syscall) /* old stty syscall holder */
444 .long SYMBOL_NAME(sys_ni_syscall) /* old gtty syscall holder */
445 .long SYMBOL_NAME(sys_access)
446 .long SYMBOL_NAME(sys_nice)
447 .long SYMBOL_NAME(sys_ni_syscall) /* 35 */ /* old ftime syscall holder */
448 .long SYMBOL_NAME(sys_sync)
449 .long SYMBOL_NAME(sys_kill)
450 .long SYMBOL_NAME(sys_rename)
451 .long SYMBOL_NAME(sys_mkdir)
452 .long SYMBOL_NAME(sys_rmdir) /* 40 */
453 .long SYMBOL_NAME(sys_dup)
454 .long SYMBOL_NAME(sys_pipe)
455 .long SYMBOL_NAME(sys_times)
456 .long SYMBOL_NAME(sys_ni_syscall) /* old prof syscall holder */
457 .long SYMBOL_NAME(sys_brk) /* 45 */
458 .long SYMBOL_NAME(sys_setgid)
459 .long SYMBOL_NAME(sys_getgid)
460 .long SYMBOL_NAME(sys_signal)
461 .long SYMBOL_NAME(sys_geteuid)
462 .long SYMBOL_NAME(sys_getegid) /* 50 */
463 .long SYMBOL_NAME(sys_acct)
464 .long SYMBOL_NAME(sys_umount) /* recycled never used phys() */
465 .long SYMBOL_NAME(sys_ni_syscall) /* old lock syscall holder */
466 .long SYMBOL_NAME(sys_ioctl)
467 .long SYMBOL_NAME(sys_fcntl) /* 55 */
468 .long SYMBOL_NAME(sys_ni_syscall) /* old mpx syscall holder */
469 .long SYMBOL_NAME(sys_setpgid)
470 .long SYMBOL_NAME(sys_ni_syscall) /* old ulimit syscall holder */
471 .long SYMBOL_NAME(sys_ni_syscall)
472 .long SYMBOL_NAME(sys_umask) /* 60 */
473 .long SYMBOL_NAME(sys_chroot)
474 .long SYMBOL_NAME(sys_ustat)
475 .long SYMBOL_NAME(sys_dup2)
476 .long SYMBOL_NAME(sys_getppid)
477 .long SYMBOL_NAME(sys_getpgrp) /* 65 */
478 .long SYMBOL_NAME(sys_setsid)
479 .long SYMBOL_NAME(sys_sigaction)
480 .long SYMBOL_NAME(sys_sgetmask)
481 .long SYMBOL_NAME(sys_ssetmask)
482 .long SYMBOL_NAME(sys_setreuid) /* 70 */
483 .long SYMBOL_NAME(sys_setregid)
484 .long SYMBOL_NAME(sys_sigsuspend)
485 .long SYMBOL_NAME(sys_sigpending)
486 .long SYMBOL_NAME(sys_sethostname)
487 .long SYMBOL_NAME(sys_setrlimit) /* 75 */
488 .long SYMBOL_NAME(sys_getrlimit)
489 .long SYMBOL_NAME(sys_getrusage)
490 .long SYMBOL_NAME(sys_gettimeofday)
491 .long SYMBOL_NAME(sys_settimeofday)
492 .long SYMBOL_NAME(sys_getgroups) /* 80 */
493 .long SYMBOL_NAME(sys_setgroups)
494 .long SYMBOL_NAME(old_select)
495 .long SYMBOL_NAME(sys_symlink)
496 .long SYMBOL_NAME(sys_lstat)
497 .long SYMBOL_NAME(sys_readlink) /* 85 */
498 .long SYMBOL_NAME(sys_uselib)
499 .long SYMBOL_NAME(sys_swapon)
500 .long SYMBOL_NAME(sys_reboot)
501 .long SYMBOL_NAME(old_readdir)
502 .long SYMBOL_NAME(old_mmap) /* 90 */
503 .long SYMBOL_NAME(sys_munmap)
504 .long SYMBOL_NAME(sys_truncate)
505 .long SYMBOL_NAME(sys_ftruncate)
506 .long SYMBOL_NAME(sys_fchmod)
507 .long SYMBOL_NAME(sys_fchown) /* 95 */
508 .long SYMBOL_NAME(sys_getpriority)
509 .long SYMBOL_NAME(sys_setpriority)
510 .long SYMBOL_NAME(sys_ni_syscall) /* old profil syscall holder */
511 .long SYMBOL_NAME(sys_statfs)
512 .long SYMBOL_NAME(sys_fstatfs) /* 100 */
513 .long SYMBOL_NAME(sys_ioperm)
514 .long SYMBOL_NAME(sys_socketcall)
515 .long SYMBOL_NAME(sys_syslog)
516 .long SYMBOL_NAME(sys_setitimer)
517 .long SYMBOL_NAME(sys_getitimer) /* 105 */
518 .long SYMBOL_NAME(sys_newstat)
519 .long SYMBOL_NAME(sys_newlstat)
520 .long SYMBOL_NAME(sys_newfstat)
521 .long SYMBOL_NAME(sys_ni_syscall)
522 .long SYMBOL_NAME(sys_ni_syscall) /* iopl for i386 */ /* 110 */
523 .long SYMBOL_NAME(sys_vhangup)
524 .long SYMBOL_NAME(sys_ni_syscall) /* obsolete idle() syscall */
525 .long SYMBOL_NAME(sys_ni_syscall) /* vm86old for i386 */
526 .long SYMBOL_NAME(sys_wait4)
527 .long SYMBOL_NAME(sys_swapoff) /* 115 */
528 .long SYMBOL_NAME(sys_sysinfo)
529 .long SYMBOL_NAME(sys_ipc)
530 .long SYMBOL_NAME(sys_fsync)
531 .long SYMBOL_NAME(sys_sigreturn)
532 .long SYMBOL_NAME(sys_clone) /* 120 */
533 .long SYMBOL_NAME(sys_setdomainname)
534 .long SYMBOL_NAME(sys_newuname)
535 .long SYMBOL_NAME(sys_cacheflush) /* modify_ldt for i386 */
536 .long SYMBOL_NAME(sys_adjtimex)
537 .long SYMBOL_NAME(sys_mprotect) /* 125 */
538 .long SYMBOL_NAME(sys_sigprocmask)
539 .long SYMBOL_NAME(sys_create_module)
540 .long SYMBOL_NAME(sys_init_module)
541 .long SYMBOL_NAME(sys_delete_module)
542 .long SYMBOL_NAME(sys_get_kernel_syms) /* 130 */
543 .long SYMBOL_NAME(sys_quotactl)
544 .long SYMBOL_NAME(sys_getpgid)
545 .long SYMBOL_NAME(sys_fchdir)
546 .long SYMBOL_NAME(sys_bdflush)
547 .long SYMBOL_NAME(sys_sysfs) /* 135 */
548 .long SYMBOL_NAME(sys_personality)
549 .long SYMBOL_NAME(sys_ni_syscall) /* for afs_syscall */
550 .long SYMBOL_NAME(sys_setfsuid)
551 .long SYMBOL_NAME(sys_setfsgid)
552 .long SYMBOL_NAME(sys_llseek) /* 140 */
553 .long SYMBOL_NAME(sys_getdents)
554 .long SYMBOL_NAME(sys_select)
555 .long SYMBOL_NAME(sys_flock)
556 .long SYMBOL_NAME(sys_msync)
557 .long SYMBOL_NAME(sys_readv) /* 145 */
558 .long SYMBOL_NAME(sys_writev)
559 .long SYMBOL_NAME(sys_getsid)
560 .long SYMBOL_NAME(sys_fdatasync)
561 .long SYMBOL_NAME(sys_sysctl)
562 .long SYMBOL_NAME(sys_mlock) /* 150 */
563 .long SYMBOL_NAME(sys_munlock)
564 .long SYMBOL_NAME(sys_mlockall)
565 .long SYMBOL_NAME(sys_munlockall)
566 .long SYMBOL_NAME(sys_sched_setparam)
567 .long SYMBOL_NAME(sys_sched_getparam) /* 155 */
568 .long SYMBOL_NAME(sys_sched_setscheduler)
569 .long SYMBOL_NAME(sys_sched_getscheduler)
570 .long SYMBOL_NAME(sys_sched_yield)
571 .long SYMBOL_NAME(sys_sched_get_priority_max)
572 .long SYMBOL_NAME(sys_sched_get_priority_min) /* 160 */
573 .long SYMBOL_NAME(sys_sched_rr_get_interval)
574 .long SYMBOL_NAME(sys_nanosleep)
575 .long SYMBOL_NAME(sys_mremap)
576 .long SYMBOL_NAME(sys_setresuid)
577 .long SYMBOL_NAME(sys_getresuid) /* 165 */
578 .long SYMBOL_NAME(sys_ni_syscall) /* for vm86 */
579 .long SYMBOL_NAME(sys_query_module)
580 .long SYMBOL_NAME(sys_poll)
581 .long SYMBOL_NAME(sys_nfsservctl)
582 .long SYMBOL_NAME(sys_setresgid) /* 170 */
583 .long SYMBOL_NAME(sys_getresgid)
584 .long SYMBOL_NAME(sys_prctl)
585 .long SYMBOL_NAME(sys_rt_sigreturn)
586 .long SYMBOL_NAME(sys_rt_sigaction)
587 .long SYMBOL_NAME(sys_rt_sigprocmask) /* 175 */
588 .long SYMBOL_NAME(sys_rt_sigpending)
589 .long SYMBOL_NAME(sys_rt_sigtimedwait)
590 .long SYMBOL_NAME(sys_rt_sigqueueinfo)
591 .long SYMBOL_NAME(sys_rt_sigsuspend)
592 .long SYMBOL_NAME(sys_pread) /* 180 */
593 .long SYMBOL_NAME(sys_pwrite)
594 .long SYMBOL_NAME(sys_lchown);
595 .long SYMBOL_NAME(sys_getcwd)
596 .long SYMBOL_NAME(sys_capget)
597 .long SYMBOL_NAME(sys_capset) /* 185 */
598 .long SYMBOL_NAME(sys_sigaltstack)
599 .long SYMBOL_NAME(sys_sendfile)
600 .long SYMBOL_NAME(sys_ni_syscall) /* streams1 */
601 .long SYMBOL_NAME(sys_ni_syscall) /* streams2 */
602 .long SYMBOL_NAME(sys_vfork) /* 190 */
604 .rept NR_syscalls-(.-SYMBOL_NAME(sys_call_table))/4
605 .long SYMBOL_NAME(sys_ni_syscall)