From: NIIBE Y. <gn...@ch...> - 2000-09-29 13:36:57
|
Support "syscall" syscall and assembler change. The register name in the input/output/clobber list, no "$" would be correct. 2000-09-29 NIIBE Yutaka <gn...@m1...> * arch/sh/kernel/sys_sh.c (sys_syscall): New function. * arch/sh/kernel/entry.S (sys_call_table:0): Assign sys_syscall. * include/asm-sh/unistd.h (__NR_syscall): New macro. (setup): Removed. 2000-09-28 NIIBE Yutaka <gn...@m1...> * include/asm-sh/system.h (switch_to): Add T-flag to the clobber list of asm statements. * arch/sh/kernel/entry.S (sys_fcntl64): Added. * include/asm/unistd.h (__NR_fcntl64): Added. 2000-09-27 NIIBE Yutaka <gn...@m1...> * include/asm/unistd.h (_syscall0, _syscall1, _syscall2, _syscall3, _syscall4, _syscall5): Don't put "$" prefix for register name. * include/asm-sh/system.h (switch_to): Likewise. * arch/sh/kernel/sh_bios.c (sh_bios_call): Likewise. * arch/sh/kernel/process.c (kernel_thread): Likewise. Use __sc0 and __sc3. Index: arch/sh/kernel/entry.S =================================================================== RCS file: /cvsroot/linuxsh/kernel/arch/sh/kernel/entry.S,v retrieving revision 1.25 diff -u -r1.25 entry.S --- arch/sh/kernel/entry.S 2000/09/09 01:45:20 1.25 +++ arch/sh/kernel/entry.S 2000/09/29 13:26:05 @@ -937,7 +937,7 @@ #endif ENTRY(sys_call_table) - .long SYMBOL_NAME(sys_ni_syscall) /* 0 - old "setup()" system call*/ + .long SYMBOL_NAME(sys_syscall) /* 0 */ .long SYMBOL_NAME(sys_exit) .long SYMBOL_NAME(sys_fork) .long SYMBOL_NAME(sys_read) @@ -1158,6 +1158,7 @@ .long SYMBOL_NAME(sys_mincore) .long SYMBOL_NAME(sys_madvise) .long SYMBOL_NAME(sys_getdents64) /* 220 */ + .long SYMBOL_NAME(sys_fcntl64) /* * NOTE!! This doesn't have to be exact - we just have @@ -1165,7 +1166,7 @@ * entries. Don't panic if you notice that this hasn't * been shrunk every time we add a new system call. */ - .rept NR_syscalls-220 + .rept NR_syscalls-221 .long SYMBOL_NAME(sys_ni_syscall) .endr Index: arch/sh/kernel/process.c =================================================================== RCS file: /cvsroot/linuxsh/kernel/arch/sh/kernel/process.c,v retrieving revision 1.13 diff -u -r1.13 process.c --- arch/sh/kernel/process.c 2000/09/06 00:22:10 1.13 +++ arch/sh/kernel/process.c 2000/09/29 13:26:05 @@ -136,11 +136,12 @@ */ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) { /* Don't use this in BL=1(cli). Or else, CPU resets! */ - register unsigned long __sc0 __asm__ ("$r3") = __NR_clone; - register unsigned long __sc4 __asm__ ("$r4") = (long) flags | CLONE_VM; - register unsigned long __sc5 __asm__ ("$r5") = 0; - register unsigned long __sc8 __asm__ ("$r8") = (long) arg; - register unsigned long __sc9 __asm__ ("$r9") = (long) fn; + register unsigned long __sc0 __asm__ ("r0"); + register unsigned long __sc3 __asm__ ("r3") = __NR_clone; + register unsigned long __sc4 __asm__ ("r4") = (long) flags | CLONE_VM; + register unsigned long __sc5 __asm__ ("r5") = 0; + register unsigned long __sc8 __asm__ ("r8") = (long) arg; + register unsigned long __sc9 __asm__ ("r9") = (long) fn; __asm__("trapa #0x12\n\t" /* Linux/SH system call */ "tst #0xff, $r0\n\t" /* child or parent? */ @@ -148,13 +149,13 @@ "jsr @$r9\n\t" /* call fn */ " mov $r8, $r4\n\t" /* push argument */ "mov $r0, $r4\n\t" /* return value to arg of exit */ - "mov %2, $r3\n\t" /* exit */ + "mov %1, $r3\n\t" /* exit */ "trapa #0x11\n" "1:" : "=z" (__sc0) - : "0" (__sc0), "i" (__NR_exit), - "r" (__sc4), "r" (__sc5), "r" (__sc8), "r" (__sc9) - : "memory"); + : "i" (__NR_exit), "r" (__sc3), "r" (__sc4), "r" (__sc5), + "r" (__sc8), "r" (__sc9) + : "memory", "t"); return __sc0; } Index: arch/sh/kernel/sh_bios.c =================================================================== RCS file: /cvsroot/linuxsh/kernel/arch/sh/kernel/sh_bios.c,v retrieving revision 1.2 diff -u -r1.2 sh_bios.c --- arch/sh/kernel/sh_bios.c 2000/07/26 04:37:32 1.2 +++ arch/sh/kernel/sh_bios.c 2000/09/29 13:26:05 @@ -20,11 +20,11 @@ static __inline__ long sh_bios_call(long func, long arg0, long arg1, long arg2, long arg3) { - register long r0 __asm__("$r0") = func; - register long r4 __asm__("$r4") = arg0; - register long r5 __asm__("$r5") = arg1; - register long r6 __asm__("$r6") = arg2; - register long r7 __asm__("$r7") = arg3; + register long r0 __asm__("r0") = func; + register long r4 __asm__("r4") = arg0; + register long r5 __asm__("r5") = arg1; + register long r6 __asm__("r6") = arg2; + register long r7 __asm__("r7") = arg3; __asm__ __volatile__("trapa #0x3f" : "=z" (r0) : "0" (r0), "r" (r4), "r" (r5), "r" (r6), "r" (r7) Index: arch/sh/kernel/sys_sh.c =================================================================== RCS file: /cvsroot/linuxsh/kernel/arch/sh/kernel/sys_sh.c,v retrieving revision 1.4 diff -u -r1.4 sys_sh.c --- arch/sh/kernel/sys_sh.c 2000/07/06 03:58:37 1.4 +++ arch/sh/kernel/sys_sh.c 2000/09/29 13:26:05 @@ -8,6 +8,7 @@ * Taken from i386 version. */ +#include <linux/sys.h> #include <linux/errno.h> #include <linux/sched.h> #include <linux/mm.h> @@ -20,6 +21,7 @@ #include <linux/mman.h> #include <linux/file.h> #include <linux/utsname.h> +#include <linux/unistd.h> #include <asm/uaccess.h> #include <asm/ipc.h> @@ -194,4 +196,43 @@ current->state = TASK_INTERRUPTIBLE; schedule(); return -ERESTARTNOHAND; +} + +typedef asmlinkage int (*syscall_t)(void *a0,...); + +/* + * Do the indirect syscall syscall. + * Only support less than three arguments. + * + * XXX: Should check the compiler's output: There shoule be no use of stack. + */ +asmlinkage int sys_syscall(unsigned long nr, unsigned long r5, + unsigned long r6, unsigned long r7) +{ + extern syscall_t *sys_call_table; + syscall_t syscall; + + if (nr > NR_syscalls) + return -ENOSYS; + + if (nr == __NR_syscall) + return -EINVAL; + + syscall = sys_call_table[nr]; + if (syscall == NULL) + return -ENOSYS; + + { + register long __r3 __asm__ ("r3") = nr; + register long __r4 __asm__ ("r4") = r5; + register long __r5 __asm__ ("r5") = r6; + register long __r6 __asm__ ("r6") = r7; + + asm volatile("jmp @%0; nop" + : : "z" (syscall), + "r" (__r3), "r" (__r4), + "r" (__r5), "r" (__r6)); + } + /* NEVER reached */ + return 0; } Index: include/asm-sh/system.h =================================================================== RCS file: /cvsroot/linuxsh/kernel/include/asm-sh/system.h,v retrieving revision 1.9 diff -u -r1.9 system.h --- include/asm-sh/system.h 2000/09/26 01:32:31 1.9 +++ include/asm-sh/system.h 2000/09/29 13:26:12 @@ -21,12 +21,12 @@ #define prepare_to_switch() do { } while(0) #define switch_to(prev,next,last) do { \ register struct task_struct *__last; \ - register unsigned long *__ts1 __asm__ ("$r1") = &prev->thread.sp; \ - register unsigned long *__ts2 __asm__ ("$r2") = &prev->thread.pc; \ - register unsigned long *__ts4 __asm__ ("$r4") = (unsigned long *)prev; \ - register unsigned long *__ts5 __asm__ ("$r5") = (unsigned long *)next; \ - register unsigned long *__ts6 __asm__ ("$r6") = &next->thread.sp; \ - register unsigned long __ts7 __asm__ ("$r7") = next->thread.pc; \ + register unsigned long *__ts1 __asm__ ("r1") = &prev->thread.sp; \ + register unsigned long *__ts2 __asm__ ("r2") = &prev->thread.pc; \ + register unsigned long *__ts4 __asm__ ("r4") = (unsigned long *)prev; \ + register unsigned long *__ts5 __asm__ ("r5") = (unsigned long *)next; \ + register unsigned long *__ts6 __asm__ ("r6") = &next->thread.sp; \ + register unsigned long __ts7 __asm__ ("r7") = next->thread.pc; \ __asm__ __volatile__ (".balign 4\n\t" \ "stc.l $gbr, @-$r15\n\t" \ "sts.l $pr, @-$r15\n\t" \ @@ -63,7 +63,7 @@ :"0" (prev), \ "r" (__ts1), "r" (__ts2), \ "r" (__ts4), "r" (__ts5), "r" (__ts6), "r" (__ts7) \ - :"r3"); \ + :"r3", "t"); \ last = __last; \ } while (0) #endif Index: include/asm-sh/unistd.h =================================================================== RCS file: /cvsroot/linuxsh/kernel/include/asm-sh/unistd.h,v retrieving revision 1.6 diff -u -r1.6 unistd.h --- include/asm-sh/unistd.h 2000/08/23 01:37:38 1.6 +++ include/asm-sh/unistd.h 2000/09/29 13:26:12 @@ -9,7 +9,7 @@ * This file contains the system call numbers. */ -#define __NR_setup 0 /* used only by init, to get system going */ +#define __NR_syscall 0 #define __NR_exit 1 #define __NR_fork 2 #define __NR_read 3 @@ -85,7 +85,7 @@ #define __NR_sigpending 73 #define __NR_sethostname 74 #define __NR_setrlimit 75 -#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */ +#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */ #define __NR_getrusage 77 #define __NR_gettimeofday 78 #define __NR_settimeofday 79 @@ -230,6 +230,7 @@ #define __NR_mincore 218 #define __NR_madvise 219 #define __NR_getdents64 220 +#define __NR_fcntl64 221 /* user-visible error numbers are in the range -1 - -125: see <asm-sh/errno.h> */ @@ -249,7 +250,7 @@ #define _syscall0(type,name) \ type name(void) \ { \ -register long __sc0 __asm__ ("$r3") = __NR_##name; \ +register long __sc0 __asm__ ("r3") = __NR_##name; \ __asm__ __volatile__ ("trapa #0x10" \ : "=z" (__sc0) \ : "0" (__sc0) \ @@ -260,8 +261,8 @@ #define _syscall1(type,name,type1,arg1) \ type name(type1 arg1) \ { \ -register long __sc0 __asm__ ("$r3") = __NR_##name; \ -register long __sc4 __asm__ ("$r4") = (long) arg1; \ +register long __sc0 __asm__ ("r3") = __NR_##name; \ +register long __sc4 __asm__ ("r4") = (long) arg1; \ __asm__ __volatile__ ("trapa #0x11" \ : "=z" (__sc0) \ : "0" (__sc0), "r" (__sc4) \ @@ -272,9 +273,9 @@ #define _syscall2(type,name,type1,arg1,type2,arg2) \ type name(type1 arg1,type2 arg2) \ { \ -register long __sc0 __asm__ ("$r3") = __NR_##name; \ -register long __sc4 __asm__ ("$r4") = (long) arg1; \ -register long __sc5 __asm__ ("$r5") = (long) arg2; \ +register long __sc0 __asm__ ("r3") = __NR_##name; \ +register long __sc4 __asm__ ("r4") = (long) arg1; \ +register long __sc5 __asm__ ("r5") = (long) arg2; \ __asm__ __volatile__ ("trapa #0x12" \ : "=z" (__sc0) \ : "0" (__sc0), "r" (__sc4), "r" (__sc5) \ @@ -285,10 +286,10 @@ #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ type name(type1 arg1,type2 arg2,type3 arg3) \ { \ -register long __sc0 __asm__ ("$r3") = __NR_##name; \ -register long __sc4 __asm__ ("$r4") = (long) arg1; \ -register long __sc5 __asm__ ("$r5") = (long) arg2; \ -register long __sc6 __asm__ ("$r6") = (long) arg3; \ +register long __sc0 __asm__ ("r3") = __NR_##name; \ +register long __sc4 __asm__ ("r4") = (long) arg1; \ +register long __sc5 __asm__ ("r5") = (long) arg2; \ +register long __sc6 __asm__ ("r6") = (long) arg3; \ __asm__ __volatile__ ("trapa #0x13" \ : "=z" (__sc0) \ : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6) \ @@ -299,11 +300,11 @@ #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ { \ -register long __sc0 __asm__ ("$r3") = __NR_##name; \ -register long __sc4 __asm__ ("$r4") = (long) arg1; \ -register long __sc5 __asm__ ("$r5") = (long) arg2; \ -register long __sc6 __asm__ ("$r6") = (long) arg3; \ -register long __sc7 __asm__ ("$r7") = (long) arg4; \ +register long __sc0 __asm__ ("r3") = __NR_##name; \ +register long __sc4 __asm__ ("r4") = (long) arg1; \ +register long __sc5 __asm__ ("r5") = (long) arg2; \ +register long __sc6 __asm__ ("r6") = (long) arg3; \ +register long __sc7 __asm__ ("r7") = (long) arg4; \ __asm__ __volatile__ ("trapa #0x14" \ : "=z" (__sc0) \ : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), \ @@ -315,12 +316,12 @@ #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \ type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ { \ -register long __sc3 __asm__ ("$r3") = __NR_##name; \ -register long __sc4 __asm__ ("$r4") = (long) arg1; \ -register long __sc5 __asm__ ("$r5") = (long) arg2; \ -register long __sc6 __asm__ ("$r6") = (long) arg3; \ -register long __sc7 __asm__ ("$r7") = (long) arg4; \ -register long __sc0 __asm__ ("$r0") = (long) arg5; \ +register long __sc3 __asm__ ("r3") = __NR_##name; \ +register long __sc4 __asm__ ("r4") = (long) arg1; \ +register long __sc5 __asm__ ("r5") = (long) arg2; \ +register long __sc6 __asm__ ("r6") = (long) arg3; \ +register long __sc7 __asm__ ("r7") = (long) arg4; \ +register long __sc0 __asm__ ("r0") = (long) arg5; \ __asm__ __volatile__ ("trapa #0x15" \ : "=z" (__sc0) \ : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \ @@ -345,7 +346,6 @@ */ #define __NR__exit __NR_exit static __inline__ _syscall0(int,pause) -static __inline__ _syscall1(int,setup,int,magic) static __inline__ _syscall0(int,sync) static __inline__ _syscall0(pid_t,setsid) static __inline__ _syscall3(int,write,int,fd,const char *,buf,off_t,count) |