7 #include <asm/system.h>
11 #define NR_SYSCALLS 371
14 * These offsets must match with alpha_mv in <asm/machvec.h>.
24 #define SWITCH_STACK_SIZE 320
27 * task structure offsets
31 #define TASK_SIGPENDING 16
32 #define TASK_ADDR_LIMIT 24
33 #define TASK_EXEC_DOMAIN 32
34 #define TASK_NEED_RESCHED 40
37 * task flags (must match include/linux/sched.h):
39 #define PF_PTRACED 0x00000010
42 * This defines the normal kernel pt-regs layout.
44 * regs 9-15 preserved by C code
45 * regs 16-18 saved by PAL-code
46 * regs 29-30 saved and set up by PAL-code
47 * JRP - Save regs 16-18 in a special area of the stack, so that
48 * the palcode-provided values are available to the signal handler.
67 ldq $2,HAE_CACHE($2); \
86 ldq $21,HAE_CACHE($19); \
94 ldq $20,HAE_REG($19); \
96 call_pal PAL_swpipl; \
97 stq $21,HAE_CACHE($19); \
100 call_pal PAL_swpipl; \
118 #if defined(__linux__) && !defined(__ELF__)
128 lda $26,ret_from_sys_call
138 /* save $9 - $15 so the inline exception code can manipulate them. */
148 /* handle the fault */
151 jsr $26,do_page_fault
152 /* reload the registers after the exception code played. */
161 /* finish up the syscall as normal. */
171 lda $26,ret_from_sys_call
182 lda $26,ret_from_sys_call
193 lda $26,ret_from_sys_call
200 * Fork() is one of the special system calls: it needs to
201 * save the callee-saved regs so that the regs can be found
202 * for the new process.. We save them in the "context switch"
203 * stack format (see arch/alpha/kernel/process.c).
205 * Also, for the kernel fork, we need to fake the system call
206 * stack buildup, as we can't do system calls from kernel space.
220 bis $31,2,$0 /* Register v0: syscall nr for fork() */
228 * __kernel_thread(clone_flags, fn, arg)
231 .globl __kernel_thread
234 ldgp $29,0($27) /* we can be called from a module */
241 mov $17,$9 /* save fn */
242 mov $18,$10 /* save arg */
244 bne $20,1f /* $20 is non-zero in child */
250 /* this is in child: look out as we don't have any stack here.. */
251 1: mov $9,$27 /* get fn */
253 mov $10,$16 /* get arg */
254 bic $30,$8,$8 /* get current */
263 * __kernel_execve(path, argv, envp, regs)
266 .globl __kernel_execve
269 ldgp $29,0($27) /* we can be called from modules. */
276 bne $0,1f /* error! */
278 br $31,ret_from_sys_call
287 lda $30,-SWITCH_STACK_SIZE($30)
324 mf_fpcr $f0 # get fpcr
328 stt $f0,312($30) # save fpcr in slot of $f31
329 ldt $f0,64($30) # dont let "do_switch_stack" change fp state.
334 .ent undo_switch_stack
344 ldt $f30,312($30) # get saved fpcr
349 mt_fpcr $f30 # install saved fpcr
377 lda $30,SWITCH_STACK_SIZE($30)
379 .end undo_switch_stack
387 ldq $0,256($30) /* get PS */
391 and $0,8,$0 /* user mode? */
393 bne $0,entUnaUser /* yup -> do user-level unaligned fault */
405 /* 16-18 PAL-saved */
437 /* 16-18 PAL-saved */
456 ldq $0,0($30) /* restore original $0 */
457 lda $30,256($30) /* pop entUna's stack frame */
458 SAVE_ALL /* setup normal kernel stack */
470 jsr $26,do_entUnaUser
483 * A fork is the same as clone(SIGCHLD, 0);
489 bsr $1,do_switch_stack
494 bsr $1,undo_switch_stack
502 bsr $1,do_switch_stack
503 /* arg1 and arg2 come from the user */
506 bsr $1,undo_switch_stack
514 bsr $1,do_switch_stack
517 bsr $1,undo_switch_stack
522 .globl alpha_switch_to
526 bsr $1,do_switch_stack
529 bsr $1,undo_switch_stack
535 * Oh, well.. Disassembling OSF/1 binaries to find out how the
536 * system calls work isn't much fun.
538 * entSys is special in that the PAL-code doesn't save a0-a2, so
539 * we start off by doing that by hand.
543 .globl ret_from_sys_call
549 lda $4,NR_SYSCALLS($31)
550 stq $16,SP_OFF+24($30)
551 lda $5,sys_call_table
552 lda $27,sys_ni_syscall
554 ldq $3,TASK_FLAGS($8)
555 stq $17,SP_OFF+32($30)
558 stq $18,SP_OFF+40($30)
562 1: jsr $26,($27),alpha_ni_syscall
564 blt $0,syscall_error /* the call failed */
566 stq $31,72($30) /* a3=0 => no error */
570 cmovne $26,0,$19 /* $19 = 0 => non-restartable */
571 /* check bottom half interrupts */
575 bne $2,handle_bottom_half
581 ldq $2,TASK_NEED_RESCHED($8)
582 lda $4,init_task_union
585 ldl $5,TASK_SIGPENDING($8)
593 /* PTRACE syscall handler */
596 /* set up signal stack, call syscall_trace */
597 bsr $1,do_switch_stack
598 jsr $26,syscall_trace
599 bsr $1,undo_switch_stack
601 /* get the system call number and the arguments back.. */
603 ldq $16,SP_OFF+24($30)
604 ldq $17,SP_OFF+32($30)
605 ldq $18,SP_OFF+40($30)
610 /* get the system call pointer.. */
611 lda $1,NR_SYSCALLS($31)
612 lda $2,sys_call_table
613 lda $27,alpha_ni_syscall
618 1: jsr $26,($27),sys_gettimeofday
622 blt $0,strace_error /* the call failed */
623 stq $31,72($30) /* a3=0 => no error */
625 stq $0,0($30) /* save return value */
627 bsr $1,do_switch_stack
628 jsr $26,syscall_trace
629 bsr $1,undo_switch_stack
630 br $31,ret_from_sys_call
634 ldq $19,0($30) /* old syscall nr (zero if success) */
635 beq $19,strace_success
636 ldq $20,72($30) /* .. and this a3 */
638 subq $31,$0,$0 /* with error in v0 */
639 addq $31,1,$1 /* set a3 for errno return */
641 stq $1,72($30) /* a3 for return */
643 bsr $1,do_switch_stack
644 mov $19,$9 /* save old syscall number */
645 mov $20,$10 /* save old a3 */
646 jsr $26,syscall_trace
649 bsr $1,undo_switch_stack
651 mov $31,$26 /* tell "ret_from_sys_call" we can restart */
657 stq $19,0($30) /* save syscall nr */
658 stq $20,8($30) /* and error indication (a3) */
659 jsr $26,do_bottom_half
663 br ret_from_handle_bh
668 * Some system calls (e.g., ptrace) can return arbitrary
669 * values which might normally be mistaken as error numbers.
670 * Those functions must zero $0 (v0) directly in the stack
671 * frame to indicate that a negative return value wasn't an
674 ldq $19,0($30) /* old syscall nr (zero if success) */
677 ldq $20,72($30) /* .. and this a3 */
678 subq $31,$0,$0 /* with error in v0 */
679 addq $31,1,$1 /* set a3 for errno return */
681 mov $31,$26 /* tell "ret_from_sys_call" we can restart */
682 stq $1,72($30) /* a3 for return */
687 stq $31,72($30) /* a3=0 => no error */
693 br $1,do_switch_stack
697 bsr $1,undo_switch_stack
702 .globl ret_from_smp_fork
704 .ent ret_from_smp_fork
706 lda $26,ret_from_sys_call
708 jsr $31,schedule_tail
709 .end ret_from_smp_fork
716 stq $19,0($30) /* save syscall nr */
717 stq $20,8($30) /* and error indication (a3) */
722 br ret_from_reschedule
729 lda $18,-SWITCH_STACK_SIZE($30)
730 lda $30,-SWITCH_STACK_SIZE($30)
732 br $1,undo_switch_stack
737 .ent sys_rt_sigreturn
740 lda $18,-SWITCH_STACK_SIZE($30)
741 lda $30,-SWITCH_STACK_SIZE($30)
742 jsr $26,do_rt_sigreturn
743 br $1,undo_switch_stack
745 .end sys_rt_sigreturn
751 br $1,do_switch_stack
753 jsr $26,do_sigsuspend
754 lda $30,SWITCH_STACK_SIZE($30)
759 .ent sys_rt_sigsuspend
762 br $1,do_switch_stack
764 jsr $26,do_rt_sigsuspend
765 lda $30,SWITCH_STACK_SIZE($30)
767 .end sys_rt_sigsuspend
771 .globl sys_call_table
773 .quad alpha_ni_syscall /* 0 */
778 .quad alpha_ni_syscall /* 5 */
781 .quad alpha_ni_syscall
783 .quad sys_unlink /* 10 */
784 .quad alpha_ni_syscall
788 .quad sys_chmod /* 15 */
791 .quad alpha_ni_syscall
793 .quad sys_getxpid /* 20 */
798 .quad alpha_ni_syscall /* 25 */
800 .quad alpha_ni_syscall
801 .quad alpha_ni_syscall
802 .quad alpha_ni_syscall
803 .quad alpha_ni_syscall /* 30 */
804 .quad alpha_ni_syscall
805 .quad alpha_ni_syscall
807 .quad alpha_ni_syscall
808 .quad alpha_ni_syscall /* 35 */
811 .quad alpha_ni_syscall
813 .quad alpha_ni_syscall /* 40 */
816 .quad osf_set_program_attributes
817 .quad alpha_ni_syscall
818 .quad sys_open /* 45 */
819 .quad alpha_ni_syscall
821 .quad osf_sigprocmask
822 .quad alpha_ni_syscall
823 .quad alpha_ni_syscall /* 50 */
826 .quad alpha_ni_syscall
828 .quad alpha_ni_syscall /* 55 */
829 .quad alpha_ni_syscall
833 .quad sys_umask /* 60 */
835 .quad alpha_ni_syscall
837 .quad sys_getpagesize
838 .quad alpha_ni_syscall /* 65 */
842 .quad alpha_ni_syscall
843 .quad alpha_ni_syscall /* 70 */
845 .quad alpha_ni_syscall
848 .quad sys_madvise /* 75 */
850 .quad alpha_ni_syscall
851 .quad alpha_ni_syscall
853 /* map BSD's setpgrp to sys_setpgid for binary compatibility: */
854 .quad sys_setgroups /* 80 */
855 .quad alpha_ni_syscall
858 .quad alpha_ni_syscall
859 .quad alpha_ni_syscall /* 85 */
861 .quad sys_gethostname
862 .quad sys_sethostname
863 .quad sys_getdtablesize
864 .quad sys_dup2 /* 90 */
869 .quad sys_fsync /* 95 */
870 .quad sys_setpriority
874 .quad osf_getpriority /* 100 */
879 .quad sys_setsockopt /* 105 */
881 .quad alpha_ni_syscall
882 .quad alpha_ni_syscall
883 .quad alpha_ni_syscall
884 .quad alpha_ni_syscall /* 110 */
889 .quad alpha_ni_syscall /* 115 */
890 .quad osf_gettimeofday
893 .quad alpha_ni_syscall
894 .quad sys_readv /* 120 */
896 .quad osf_settimeofday
899 .quad sys_recvfrom /* 125 */
904 .quad sys_ftruncate /* 130 */
909 .quad sys_socketpair /* 135 */
913 .quad alpha_ni_syscall
914 .quad alpha_ni_syscall /* 140 */
915 .quad sys_getpeername
916 .quad alpha_ni_syscall
917 .quad alpha_ni_syscall
919 .quad sys_setrlimit /* 145 */
920 .quad alpha_ni_syscall
923 .quad alpha_ni_syscall
924 .quad sys_getsockname /* 150 */
925 .quad alpha_ni_syscall
926 .quad alpha_ni_syscall
927 .quad alpha_ni_syscall
928 .quad alpha_ni_syscall
929 .quad alpha_ni_syscall /* 155 */
931 .quad alpha_ni_syscall
932 .quad alpha_ni_syscall
933 .quad osf_getdirentries
934 .quad osf_statfs /* 160 */
936 .quad alpha_ni_syscall
937 .quad alpha_ni_syscall
938 .quad alpha_ni_syscall
939 .quad osf_getdomainname /* 165 */
940 .quad sys_setdomainname
941 .quad alpha_ni_syscall
942 .quad alpha_ni_syscall
943 .quad alpha_ni_syscall
944 .quad alpha_ni_syscall /* 170 */
945 .quad alpha_ni_syscall
946 .quad alpha_ni_syscall
947 .quad alpha_ni_syscall
948 .quad alpha_ni_syscall
949 .quad alpha_ni_syscall /* 175 */
950 .quad alpha_ni_syscall
951 .quad alpha_ni_syscall
952 .quad alpha_ni_syscall
953 .quad alpha_ni_syscall
954 .quad alpha_ni_syscall /* 180 */
955 .quad alpha_ni_syscall
956 .quad alpha_ni_syscall
957 .quad alpha_ni_syscall
958 .quad alpha_ni_syscall
959 .quad alpha_ni_syscall /* 185 */
960 .quad alpha_ni_syscall
961 .quad alpha_ni_syscall
962 .quad alpha_ni_syscall
963 .quad alpha_ni_syscall
964 .quad alpha_ni_syscall /* 190 */
965 .quad alpha_ni_syscall
966 .quad alpha_ni_syscall
967 .quad alpha_ni_syscall
968 .quad alpha_ni_syscall
969 .quad alpha_ni_syscall /* 195 */
970 .quad alpha_ni_syscall
971 .quad alpha_ni_syscall
972 .quad alpha_ni_syscall
974 .quad sys_msgctl /* 200 */
979 .quad sys_semget /* 205 */
984 .quad sys_shmctl /* 210 */
987 .quad alpha_ni_syscall
988 .quad alpha_ni_syscall
989 .quad alpha_ni_syscall /* 215 */
990 .quad alpha_ni_syscall
992 .quad alpha_ni_syscall
993 .quad alpha_ni_syscall
994 .quad alpha_ni_syscall /* 220 */
995 .quad alpha_ni_syscall
996 .quad alpha_ni_syscall
997 .quad alpha_ni_syscall
998 .quad alpha_ni_syscall
999 .quad alpha_ni_syscall /* 225 */
1000 .quad alpha_ni_syscall
1001 .quad alpha_ni_syscall
1002 .quad alpha_ni_syscall
1003 .quad alpha_ni_syscall
1004 .quad alpha_ni_syscall /* 230 */
1005 .quad alpha_ni_syscall
1006 .quad alpha_ni_syscall
1009 .quad sys_sigaltstack /* 235 */
1010 .quad alpha_ni_syscall
1011 .quad alpha_ni_syscall
1012 .quad alpha_ni_syscall
1013 .quad alpha_ni_syscall
1014 .quad alpha_ni_syscall /* 240 */
1016 .quad alpha_ni_syscall
1017 .quad alpha_ni_syscall
1018 .quad osf_proplist_syscall
1019 .quad alpha_ni_syscall /* 245 */
1020 .quad alpha_ni_syscall
1021 .quad alpha_ni_syscall
1022 .quad alpha_ni_syscall
1023 .quad alpha_ni_syscall
1024 .quad alpha_ni_syscall /* 250 */
1025 .quad osf_usleep_thread
1026 .quad alpha_ni_syscall
1027 .quad alpha_ni_syscall
1029 .quad alpha_ni_syscall /* 255 */
1030 .quad osf_getsysinfo
1031 .quad osf_setsysinfo
1032 .quad alpha_ni_syscall
1033 .quad alpha_ni_syscall
1034 .quad alpha_ni_syscall /* 260 */
1035 .quad alpha_ni_syscall
1036 .quad alpha_ni_syscall
1037 .quad alpha_ni_syscall
1038 .quad alpha_ni_syscall
1039 .quad alpha_ni_syscall /* 265 */
1040 .quad alpha_ni_syscall
1041 .quad alpha_ni_syscall
1042 .quad alpha_ni_syscall
1043 .quad alpha_ni_syscall
1044 .quad alpha_ni_syscall /* 270 */
1045 .quad alpha_ni_syscall
1046 .quad alpha_ni_syscall
1047 .quad alpha_ni_syscall
1048 .quad alpha_ni_syscall
1049 .quad alpha_ni_syscall /* 275 */
1050 .quad alpha_ni_syscall
1051 .quad alpha_ni_syscall
1052 .quad alpha_ni_syscall
1053 .quad alpha_ni_syscall
1054 .quad alpha_ni_syscall /* 280 */
1055 .quad alpha_ni_syscall
1056 .quad alpha_ni_syscall
1057 .quad alpha_ni_syscall
1058 .quad alpha_ni_syscall
1059 .quad alpha_ni_syscall /* 285 */
1060 .quad alpha_ni_syscall
1061 .quad alpha_ni_syscall
1062 .quad alpha_ni_syscall
1063 .quad alpha_ni_syscall
1064 .quad alpha_ni_syscall /* 290 */
1065 .quad alpha_ni_syscall
1066 .quad alpha_ni_syscall
1067 .quad alpha_ni_syscall
1068 .quad alpha_ni_syscall
1069 .quad alpha_ni_syscall /* 295 */
1070 .quad alpha_ni_syscall
1071 .quad alpha_ni_syscall
1072 .quad alpha_ni_syscall
1073 .quad alpha_ni_syscall
1074 /* linux-specific system calls start at 300 */
1075 .quad sys_bdflush /* 300 */
1078 .quad sys_old_adjtimex
1080 .quad sys_getdents /* 305 */
1081 .quad alpha_create_module
1082 .quad sys_init_module
1083 .quad sys_delete_module
1084 .quad sys_get_kernel_syms
1085 .quad sys_syslog /* 310 */
1090 .quad sys_munlock /* 315 */
1092 .quad sys_munlockall
1095 .quad sys_idle /* 320 */
1099 .quad sys_personality
1100 .quad sys_setfsuid /* 325 */
1105 .quad sys_sched_setparam /* 330 */
1106 .quad sys_sched_getparam
1107 .quad sys_sched_setscheduler
1108 .quad sys_sched_getscheduler
1109 .quad sys_sched_yield
1110 .quad sys_sched_get_priority_max /* 335 */
1111 .quad sys_sched_get_priority_min
1112 .quad sys_sched_rr_get_interval
1113 .quad sys_ni_syscall /* sys_afs_syscall */
1115 .quad sys_nanosleep /* 340 */
1117 .quad sys_nfsservctl
1120 .quad sys_pciconfig_read /* 345 */
1121 .quad sys_pciconfig_write
1122 .quad sys_query_module
1125 .quad sys_pwrite /* 350 */
1126 .quad sys_rt_sigreturn
1127 .quad sys_rt_sigaction
1128 .quad sys_rt_sigprocmask
1129 .quad sys_rt_sigpending
1130 .quad sys_rt_sigtimedwait /* 355 */
1131 .quad sys_rt_sigqueueinfo
1132 .quad sys_rt_sigsuspend
1134 .quad sys_gettimeofday
1135 .quad sys_settimeofday /* 360 */
1140 .quad sys_wait4 /* 365 */
1145 .quad sys_sendfile /* 370 */
1146 .quad sys_timer_create
1147 .quad sys_timer_settime
1148 .quad sys_timer_gettime
1149 .quad sys_timer_setoverrun
1150 .quad sys_timer_delete /* 375 */
1151 .quad sys_clock_gettime
1152 .quad sys_clock_settime
1153 .quad sys_clock_getres /* 378 */