7 #include <linux/config.h>
8 #include <asm/system.h>
13 #define NR_SYSCALLS 377
16 * These offsets must match with alpha_mv in <asm/machvec.h>.
26 #define SWITCH_STACK_SIZE 320
29 * task structure offsets
33 #define TASK_SIGPENDING 16
34 #define TASK_ADDR_LIMIT 24
35 #define TASK_EXEC_DOMAIN 32
36 #define TASK_NEED_RESCHED 40
37 #define TASK_PTRACE 48
38 #define TASK_PROCESSOR 100
41 * task flags (must match include/linux/sched.h):
43 #define PT_PTRACED 0x00000001
45 #define CLONE_VM 0x00000100
48 * This defines the normal kernel pt-regs layout.
50 * regs 9-15 preserved by C code
51 * regs 16-18 saved by PAL-code
52 * regs 29-30 saved and set up by PAL-code
53 * JRP - Save regs 16-18 in a special area of the stack, so that
54 * the palcode-provided values are available to the signal handler.
73 ldq $2,HAE_CACHE($2); \
92 ldq $20,HAE_CACHE($19); \
100 ldq $20,HAE_REG($19); \
102 call_pal PAL_swpipl; \
103 stq $21,HAE_CACHE($19); \
106 call_pal PAL_swpipl; \
124 #if defined(__linux__) && !defined(__ELF__)
134 lda $26,ret_from_sys_call
144 /* save $9 - $15 so the inline exception code can manipulate them. */
154 /* handle the fault */
157 jsr $26,do_page_fault
158 /* reload the registers after the exception code played. */
167 /* finish up the syscall as normal. */
177 lda $26,ret_from_sys_call
188 lda $26,ret_from_sys_call
199 lda $26,ret_from_sys_call
206 * Fork() is one of the special system calls: it needs to
207 * save the callee-saved regs so that the regs can be found
208 * for the new process.. We save them in the "context switch"
209 * stack format (see arch/alpha/kernel/process.c).
211 * Also, for the kernel fork, we need to fake the system call
212 * stack buildup, as we can't do system calls from kernel space.
226 bis $31,2,$0 /* Register v0: syscall nr for fork() */
234 * kernel_thread(fn, arg, clone_flags)
240 ldgp $29,0($27) /* we can be called from a module */
248 mov $16,$9 /* save fn */
249 mov $17,$10 /* save arg */
250 or $18,$0,$16 /* shuffle flags to front; add CLONE_VM. */
252 bne $20,1f /* $20 is non-zero in child */
258 /* this is in child: look out as we don't have any stack here.. */
259 1: mov $9,$27 /* get fn */
261 mov $10,$16 /* get arg */
262 bic $30,$8,$8 /* get current */
271 * __kernel_execve(path, argv, envp, regs)
274 .globl __kernel_execve
277 ldgp $29,0($27) /* we can be called from modules. */
284 bne $0,1f /* error! */
286 br $31,ret_from_sys_call
295 lda $30,-SWITCH_STACK_SIZE($30)
332 mf_fpcr $f0 # get fpcr
336 stt $f0,312($30) # save fpcr in slot of $f31
337 ldt $f0,64($30) # dont let "do_switch_stack" change fp state.
342 .ent undo_switch_stack
352 ldt $f30,312($30) # get saved fpcr
357 mt_fpcr $f30 # install saved fpcr
385 lda $30,SWITCH_STACK_SIZE($30)
387 .end undo_switch_stack
395 ldq $0,256($30) /* get PS */
399 and $0,8,$0 /* user mode? */
401 bne $0,entUnaUser /* yup -> do user-level unaligned fault */
413 /* 16-18 PAL-saved */
445 /* 16-18 PAL-saved */
464 ldq $0,0($30) /* restore original $0 */
465 lda $30,256($30) /* pop entUna's stack frame */
466 SAVE_ALL /* setup normal kernel stack */
478 jsr $26,do_entUnaUser
491 * A fork is the same as clone(SIGCHLD, 0);
497 bsr $1,do_switch_stack
502 bsr $1,undo_switch_stack
510 bsr $1,do_switch_stack
511 /* arg1 and arg2 come from the user */
514 bsr $1,undo_switch_stack
522 bsr $1,do_switch_stack
525 bsr $1,undo_switch_stack
530 .globl alpha_switch_to
534 bsr $1,do_switch_stack
537 bsr $1,undo_switch_stack
543 * Oh, well.. Disassembling OSF/1 binaries to find out how the
544 * system calls work isn't much fun.
546 * entSys is special in that the PAL-code doesn't save a0-a2, so
547 * we start off by doing that by hand.
551 .globl ret_from_sys_call
557 lda $4,NR_SYSCALLS($31)
558 stq $16,SP_OFF+24($30)
559 lda $5,sys_call_table
560 lda $27,sys_ni_syscall
562 ldq $3,TASK_PTRACE($8)
563 stq $17,SP_OFF+32($30)
566 stq $18,SP_OFF+40($30)
570 1: jsr $26,($27),alpha_ni_syscall
572 blt $0,syscall_error /* the call failed */
574 stq $31,72($30) /* a3=0 => no error */
578 cmovne $26,0,$19 /* $19 = 0 => non-restartable */
579 ldl $3,TASK_PROCESSOR($8)
580 lda $4,irq_stat /* softirq_active */
581 sll $3,L1_CACHE_SHIFT,$3
583 ldq $4,0($4) /* softirq_active[32] + softirq_mask[32] */
586 bne $4,handle_softirq
592 ldq $2,TASK_NEED_RESCHED($8)
593 lda $4,init_task_union
596 ldl $5,TASK_SIGPENDING($8)
604 /* PTRACE syscall handler */
607 /* set up signal stack, call syscall_trace */
608 bsr $1,do_switch_stack
609 jsr $26,syscall_trace
610 bsr $1,undo_switch_stack
612 /* get the system call number and the arguments back.. */
614 ldq $16,SP_OFF+24($30)
615 ldq $17,SP_OFF+32($30)
616 ldq $18,SP_OFF+40($30)
621 /* get the system call pointer.. */
622 lda $1,NR_SYSCALLS($31)
623 lda $2,sys_call_table
624 lda $27,alpha_ni_syscall
629 1: jsr $26,($27),sys_gettimeofday
633 blt $0,strace_error /* the call failed */
634 stq $31,72($30) /* a3=0 => no error */
636 stq $0,0($30) /* save return value */
638 bsr $1,do_switch_stack
639 jsr $26,syscall_trace
640 bsr $1,undo_switch_stack
641 br $31,ret_from_sys_call
645 ldq $19,0($30) /* old syscall nr (zero if success) */
646 beq $19,strace_success
647 ldq $20,72($30) /* .. and this a3 */
649 subq $31,$0,$0 /* with error in v0 */
650 addq $31,1,$1 /* set a3 for errno return */
652 stq $1,72($30) /* a3 for return */
654 bsr $1,do_switch_stack
655 mov $19,$9 /* save old syscall number */
656 mov $20,$10 /* save old a3 */
657 jsr $26,syscall_trace
660 bsr $1,undo_switch_stack
662 mov $31,$26 /* tell "ret_from_sys_call" we can restart */
668 stq $19,0($30) /* save syscall nr */
669 stq $20,8($30) /* and error indication (a3) */
679 * Some system calls (e.g., ptrace) can return arbitrary
680 * values which might normally be mistaken as error numbers.
681 * Those functions must zero $0 (v0) directly in the stack
682 * frame to indicate that a negative return value wasn't an
685 ldq $19,0($30) /* old syscall nr (zero if success) */
688 ldq $20,72($30) /* .. and this a3 */
689 subq $31,$0,$0 /* with error in v0 */
690 addq $31,1,$1 /* set a3 for errno return */
692 mov $31,$26 /* tell "ret_from_sys_call" we can restart */
693 stq $1,72($30) /* a3 for return */
698 stq $31,72($30) /* a3=0 => no error */
704 br $1,do_switch_stack
708 bsr $1,undo_switch_stack
713 .globl ret_from_smp_fork
715 .ent ret_from_smp_fork
717 lda $26,ret_from_sys_call
719 jsr $31,schedule_tail
720 .end ret_from_smp_fork
721 #endif /* CONFIG_SMP */
727 stq $19,0($30) /* save syscall nr */
728 stq $20,8($30) /* and error indication (a3) */
733 br ret_from_reschedule
740 lda $18,-SWITCH_STACK_SIZE($30)
741 lda $30,-SWITCH_STACK_SIZE($30)
743 br $1,undo_switch_stack
748 .ent sys_rt_sigreturn
751 lda $18,-SWITCH_STACK_SIZE($30)
752 lda $30,-SWITCH_STACK_SIZE($30)
753 jsr $26,do_rt_sigreturn
754 br $1,undo_switch_stack
756 .end sys_rt_sigreturn
762 br $1,do_switch_stack
764 jsr $26,do_sigsuspend
765 lda $30,SWITCH_STACK_SIZE($30)
770 .ent sys_rt_sigsuspend
773 br $1,do_switch_stack
775 jsr $26,do_rt_sigsuspend
776 lda $30,SWITCH_STACK_SIZE($30)
778 .end sys_rt_sigsuspend
782 .globl sys_call_table
784 .quad alpha_ni_syscall /* 0 */
789 .quad alpha_ni_syscall /* 5 */
792 .quad alpha_ni_syscall
794 .quad sys_unlink /* 10 */
795 .quad alpha_ni_syscall
799 .quad sys_chmod /* 15 */
802 .quad alpha_ni_syscall
804 .quad sys_getxpid /* 20 */
809 .quad alpha_ni_syscall /* 25 */
811 .quad alpha_ni_syscall
812 .quad alpha_ni_syscall
813 .quad alpha_ni_syscall
814 .quad alpha_ni_syscall /* 30 */
815 .quad alpha_ni_syscall
816 .quad alpha_ni_syscall
818 .quad alpha_ni_syscall
819 .quad alpha_ni_syscall /* 35 */
822 .quad alpha_ni_syscall
824 .quad alpha_ni_syscall /* 40 */
827 .quad osf_set_program_attributes
828 .quad alpha_ni_syscall
829 .quad sys_open /* 45 */
830 .quad alpha_ni_syscall
832 .quad osf_sigprocmask
833 .quad alpha_ni_syscall
834 .quad alpha_ni_syscall /* 50 */
837 .quad alpha_ni_syscall
839 .quad alpha_ni_syscall /* 55 */
840 .quad alpha_ni_syscall
844 .quad sys_umask /* 60 */
846 .quad alpha_ni_syscall
848 .quad sys_getpagesize
849 .quad alpha_ni_syscall /* 65 */
853 .quad alpha_ni_syscall
854 .quad alpha_ni_syscall /* 70 */
856 .quad alpha_ni_syscall
859 .quad sys_madvise /* 75 */
861 .quad alpha_ni_syscall
862 .quad alpha_ni_syscall
864 /* map BSD's setpgrp to sys_setpgid for binary compatibility: */
865 .quad sys_setgroups /* 80 */
866 .quad alpha_ni_syscall
869 .quad alpha_ni_syscall
870 .quad alpha_ni_syscall /* 85 */
872 .quad sys_gethostname
873 .quad sys_sethostname
874 .quad sys_getdtablesize
875 .quad sys_dup2 /* 90 */
880 .quad sys_fsync /* 95 */
881 .quad sys_setpriority
885 .quad osf_getpriority /* 100 */
890 .quad sys_setsockopt /* 105 */
892 .quad alpha_ni_syscall
893 .quad alpha_ni_syscall
894 .quad alpha_ni_syscall
895 .quad alpha_ni_syscall /* 110 */
900 .quad alpha_ni_syscall /* 115 */
901 .quad osf_gettimeofday
904 .quad alpha_ni_syscall
905 .quad sys_readv /* 120 */
907 .quad osf_settimeofday
910 .quad sys_recvfrom /* 125 */
915 .quad sys_ftruncate /* 130 */
920 .quad sys_socketpair /* 135 */
924 .quad alpha_ni_syscall
925 .quad alpha_ni_syscall /* 140 */
926 .quad sys_getpeername
927 .quad alpha_ni_syscall
928 .quad alpha_ni_syscall
930 .quad sys_setrlimit /* 145 */
931 .quad alpha_ni_syscall
934 .quad alpha_ni_syscall
935 .quad sys_getsockname /* 150 */
936 .quad alpha_ni_syscall
937 .quad alpha_ni_syscall
938 .quad alpha_ni_syscall
939 .quad alpha_ni_syscall
940 .quad alpha_ni_syscall /* 155 */
942 .quad alpha_ni_syscall
943 .quad alpha_ni_syscall
944 .quad osf_getdirentries
945 .quad osf_statfs /* 160 */
947 .quad alpha_ni_syscall
948 .quad alpha_ni_syscall
949 .quad alpha_ni_syscall
950 .quad osf_getdomainname /* 165 */
951 .quad sys_setdomainname
952 .quad alpha_ni_syscall
953 .quad alpha_ni_syscall
954 .quad alpha_ni_syscall
955 .quad alpha_ni_syscall /* 170 */
956 .quad alpha_ni_syscall
957 .quad alpha_ni_syscall
958 .quad alpha_ni_syscall
959 .quad alpha_ni_syscall
960 .quad alpha_ni_syscall /* 175 */
961 .quad alpha_ni_syscall
962 .quad alpha_ni_syscall
963 .quad alpha_ni_syscall
964 .quad alpha_ni_syscall
965 .quad alpha_ni_syscall /* 180 */
966 .quad alpha_ni_syscall
967 .quad alpha_ni_syscall
968 .quad alpha_ni_syscall
969 .quad alpha_ni_syscall
970 .quad alpha_ni_syscall /* 185 */
971 .quad alpha_ni_syscall
972 .quad alpha_ni_syscall
973 .quad alpha_ni_syscall
974 .quad alpha_ni_syscall
975 .quad alpha_ni_syscall /* 190 */
976 .quad alpha_ni_syscall
977 .quad alpha_ni_syscall
978 .quad alpha_ni_syscall
979 .quad alpha_ni_syscall
980 .quad alpha_ni_syscall /* 195 */
981 .quad alpha_ni_syscall
982 .quad alpha_ni_syscall
983 .quad alpha_ni_syscall
985 .quad sys_msgctl /* 200 */
990 .quad sys_semget /* 205 */
995 .quad sys_shmctl /* 210 */
998 .quad alpha_ni_syscall
999 .quad alpha_ni_syscall
1000 .quad alpha_ni_syscall /* 215 */
1001 .quad alpha_ni_syscall
1003 .quad alpha_ni_syscall
1004 .quad alpha_ni_syscall
1005 .quad alpha_ni_syscall /* 220 */
1006 .quad alpha_ni_syscall
1007 .quad alpha_ni_syscall
1008 .quad alpha_ni_syscall
1009 .quad alpha_ni_syscall
1010 .quad alpha_ni_syscall /* 225 */
1011 .quad alpha_ni_syscall
1012 .quad alpha_ni_syscall
1013 .quad alpha_ni_syscall
1014 .quad alpha_ni_syscall
1015 .quad alpha_ni_syscall /* 230 */
1016 .quad alpha_ni_syscall
1017 .quad alpha_ni_syscall
1020 .quad sys_sigaltstack /* 235 */
1021 .quad alpha_ni_syscall
1022 .quad alpha_ni_syscall
1023 .quad alpha_ni_syscall
1024 .quad alpha_ni_syscall
1025 .quad alpha_ni_syscall /* 240 */
1027 .quad alpha_ni_syscall
1028 .quad alpha_ni_syscall
1029 .quad osf_proplist_syscall
1030 .quad alpha_ni_syscall /* 245 */
1031 .quad alpha_ni_syscall
1032 .quad alpha_ni_syscall
1033 .quad alpha_ni_syscall
1034 .quad alpha_ni_syscall
1035 .quad alpha_ni_syscall /* 250 */
1036 .quad osf_usleep_thread
1037 .quad alpha_ni_syscall
1038 .quad alpha_ni_syscall
1040 .quad alpha_ni_syscall /* 255 */
1041 .quad osf_getsysinfo
1042 .quad osf_setsysinfo
1043 .quad alpha_ni_syscall
1044 .quad alpha_ni_syscall
1045 .quad alpha_ni_syscall /* 260 */
1046 .quad alpha_ni_syscall
1047 .quad alpha_ni_syscall
1048 .quad alpha_ni_syscall
1049 .quad alpha_ni_syscall
1050 .quad alpha_ni_syscall /* 265 */
1051 .quad alpha_ni_syscall
1052 .quad alpha_ni_syscall
1053 .quad alpha_ni_syscall
1054 .quad alpha_ni_syscall
1055 .quad alpha_ni_syscall /* 270 */
1056 .quad alpha_ni_syscall
1057 .quad alpha_ni_syscall
1058 .quad alpha_ni_syscall
1059 .quad alpha_ni_syscall
1060 .quad alpha_ni_syscall /* 275 */
1061 .quad alpha_ni_syscall
1062 .quad alpha_ni_syscall
1063 .quad alpha_ni_syscall
1064 .quad alpha_ni_syscall
1065 .quad alpha_ni_syscall /* 280 */
1066 .quad alpha_ni_syscall
1067 .quad alpha_ni_syscall
1068 .quad alpha_ni_syscall
1069 .quad alpha_ni_syscall
1070 .quad alpha_ni_syscall /* 285 */
1071 .quad alpha_ni_syscall
1072 .quad alpha_ni_syscall
1073 .quad alpha_ni_syscall
1074 .quad alpha_ni_syscall
1075 .quad alpha_ni_syscall /* 290 */
1076 .quad alpha_ni_syscall
1077 .quad alpha_ni_syscall
1078 .quad alpha_ni_syscall
1079 .quad alpha_ni_syscall
1080 .quad alpha_ni_syscall /* 295 */
1081 .quad alpha_ni_syscall
1082 .quad alpha_ni_syscall
1083 .quad alpha_ni_syscall
1084 .quad alpha_ni_syscall
1085 /* linux-specific system calls start at 300 */
1086 .quad sys_bdflush /* 300 */
1089 .quad sys_old_adjtimex
1091 .quad sys_getdents /* 305 */
1092 .quad alpha_create_module
1093 .quad sys_init_module
1094 .quad sys_delete_module
1095 .quad sys_get_kernel_syms
1096 .quad sys_syslog /* 310 */
1101 .quad sys_munlock /* 315 */
1103 .quad sys_munlockall
1106 .quad sys_ni_syscall /* 320 */
1110 .quad sys_personality
1111 .quad sys_setfsuid /* 325 */
1116 .quad sys_sched_setparam /* 330 */
1117 .quad sys_sched_getparam
1118 .quad sys_sched_setscheduler
1119 .quad sys_sched_getscheduler
1120 .quad sys_sched_yield
1121 .quad sys_sched_get_priority_max /* 335 */
1122 .quad sys_sched_get_priority_min
1123 .quad sys_sched_rr_get_interval
1124 .quad sys_ni_syscall /* sys_afs_syscall */
1126 .quad sys_nanosleep /* 340 */
1128 .quad sys_nfsservctl
1131 .quad sys_pciconfig_read /* 345 */
1132 .quad sys_pciconfig_write
1133 .quad sys_query_module
1136 .quad sys_pwrite /* 350 */
1137 .quad sys_rt_sigreturn
1138 .quad sys_rt_sigaction
1139 .quad sys_rt_sigprocmask
1140 .quad sys_rt_sigpending
1141 .quad sys_rt_sigtimedwait /* 355 */
1142 .quad sys_rt_sigqueueinfo
1143 .quad sys_rt_sigsuspend
1145 .quad sys_gettimeofday
1146 .quad sys_settimeofday /* 360 */
1151 .quad sys_wait4 /* 365 */
1156 .quad sys_sendfile /* 370 */
1159 .quad sys_ni_syscall /* sys_dipc */
1160 .quad sys_pivot_root
1161 .quad sys_mincore /* 375 */
1162 .quad sys_pciconfig_iobase
1163 .quad sys_getdents64