Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Teach makesyscalls.sh how to auto-generate the list...



details:   https://anonhg.NetBSD.org/src/rev/f2a4c6efa4be
branches:  trunk
changeset: 338017:f2a4c6efa4be
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sat May 09 05:51:26 2015 +0000

description:
Teach makesyscalls.sh how to auto-generate the list of syscalls that
can be resolved by module auto-load.

Update syscalls.master to identify the specific module that contains
the auto-loadable code for each syscall.

diffstat:

 sys/kern/makesyscalls.sh |   48 +++++-
 sys/kern/syscalls.master |  386 ++++++++++++++++++++++++++++------------------
 2 files changed, 276 insertions(+), 158 deletions(-)

diffs (truncated from 904 to 300 lines):

diff -r 4d017f6f11e5 -r f2a4c6efa4be sys/kern/makesyscalls.sh
--- a/sys/kern/makesyscalls.sh  Sat May 09 02:12:29 2015 +0000
+++ b/sys/kern/makesyscalls.sh  Sat May 09 05:51:26 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: makesyscalls.sh,v 1.151 2015/03/08 20:31:53 christos Exp $
+#      $NetBSD: makesyscalls.sh,v 1.152 2015/05/09 05:51:26 pgoyette Exp $
 #
 # Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou
 # All rights reserved.
@@ -45,6 +45,7 @@
 #      sysnames        the syscall names file
 #      sysnumhdr       the syscall numbers file
 #      syssw           the syscall switch file
+#      sysautoload     the syscall autoload definitions file
 #      sysarghdr       the syscall argument struct definitions
 #      compatopts      those syscall types that are for 'compat' syscalls
 #      switchname      the name for the 'struct sysent' we define
@@ -140,6 +141,7 @@
 
        # to allow nested #if/#else/#endif sets
        savedepth = 0
+       auto_skip = 0
        # to track already processed syscalls
 
        sysnames = \"$sysnames\"
@@ -150,6 +152,7 @@
        systrace = \"$systrace\"
        systracetmp = \"$systracetmp\"
        systraceret = \"$systraceret\"
+       sysautoload = \"$sysautoload\"
        rumpcalls = \"$rumpcalls\"
        rumpcallshdr = \"$rumpcallshdr\"
        rumpsysent = \"$rumpsysent\"
@@ -220,6 +223,10 @@
        printf "/*\n * System call argument lists.\n *\n" > sysarghdr
        printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysarghdr
 
+       printf "/* %s */\n\n", tag > sysautoload
+       printf "/*\n * System call autoload table.\n *\n" > sysautoload
+       printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysautoload
+
        printf "/* %s */\n\n", tag > rumpcalls
        printf "/*\n * System call vector and marshalling for rump.\n *\n" > rumpcalls
        printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcalls
@@ -240,6 +247,13 @@
        printf " * created from%s\n */\n\n", $0 > sysnames
        printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysnames
 
+       printf " * created from%s\n */\n\n", $0 > sysautoload
+       printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysautoload
+       printf("static struct {\n")                     > sysautoload
+       printf("\tu_int\t\tal_code;\n")                 > sysautoload
+       printf("\tconst char\t*al_module;\n")           > sysautoload
+       printf("} const syscalls_autoload[] = {\n")     > sysautoload
+
        printf " * created from%s\n */\n\n", $0 > rumpcalls
        printf "#ifdef RUMP_CLIENT\n" > rumpcalls
        printf "#include <rump/rumpuser_port.h>\n" > rumpcalls
@@ -385,6 +399,19 @@
        if ($1 ~ /^#[   ]*if/) {
                savedepth++
                savesyscall[savedepth] = syscall
+               skip_auto[savedepth] = auto_skip
+               auto_skip = 0
+
+               # Special handling for sysautoload conditionals
+               #
+               # We ignore all conditions other than those for
+               # !defined(_LP64) which are used for SYSV* syscalls
+               # only
+
+               if ($0 ~ /!defined\(_LP64\)/) {
+                       printf("#if !defined(_LP64)\n") > sysautoload
+                       auto_skip = savedepth
+               }
        }
        if ($1 ~ /^#[   ]*else/) {
                if (savedepth <= 0) {
@@ -392,6 +419,9 @@
                            infile, NR)
                        exit 1
                }
+               if (auto_skip == savedepth) {
+                       print > sysautoload
+               }
                syscall = savesyscall[savedepth]
        }
        if ($1 ~ /^#[       ]*endif/) {
@@ -400,6 +430,10 @@
                            infile, NR)
                        exit 1
                }
+               if (auto_skip == savedepth) {
+                       print > sysautoload
+               }
+               auto_skip = skip_auto[savedepth];
                savedepth--
        }
        print > sysent
@@ -455,6 +489,8 @@
        if ($f == "MODULAR") {          # registered at runtime
                modular = 1
                f++
+               modname = $f
+               f++
        } else {
                modular =  0;
        }
@@ -637,6 +673,13 @@
        printf("#define\t%s%s%s\t%d\n\n", constprefix, wrap, funcalias,
            syscall) > sysnumhdr
 
+       # output entry for syscall autoload table, if modular
+       if (modular ) {
+               printf("\t    { %s%s%s, \"%s\" },\n", constprefix, wrap,
+                   funcalias, modname) > sysautoload
+       }
+
+
        # rumpalooza
        if (!rumpable)
                return
@@ -1084,6 +1127,7 @@
 cat $sysprotos >> $sysarghdr
 echo "#endif /* _${constprefix}SYSCALL_H_ */" >> $sysnumhdr
 echo "#endif /* _${constprefix}SYSCALLARGS_H_ */" >> $sysarghdr
+echo "};" >> $sysautoload
 printf "\n#endif /* _RUMP_RUMP_SYSCALLS_H_ */\n" >> $rumpprotos
 cat $sysdcl $sysent > $syssw
 cat $sysnamesbottom >> $sysnames
@@ -1100,4 +1144,4 @@
 cat $systraceret >> $systrace
 
 echo Generated following files:
-echo $sysarghdr $sysnumhdr $syssw $sysnames $systrace $rumpcalls $rumpcallshdr $rumpsysmap
+echo $sysarghdr $sysnumhdr $syssw $sysnames $sysautoload $systrace $rumpcalls $rumpcallshdr $rumpsysmap
diff -r 4d017f6f11e5 -r f2a4c6efa4be sys/kern/syscalls.master
--- a/sys/kern/syscalls.master  Sat May 09 02:12:29 2015 +0000
+++ b/sys/kern/syscalls.master  Sat May 09 05:51:26 2015 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.273 2015/04/08 13:24:25 justin Exp $
+       compat $NetBSD: syscalls.master,v 1.274 2015/05/09 05:51:26 pgoyette Exp $
 
 ;      @(#)syscalls.master     8.2 (Berkeley) 1/13/94
 
@@ -12,7 +12,7 @@
 ;
 ; Optional fields are specified after the type field
 ; (NOTE! they *must* be specified in this order):
-;      MODULAR:attempt to autoload system call if not present
+;      MODULAR modname :attempt to autoload system call module if not present
 ;      RUMP:   generate rump syscall entry point
 ;
 ; types:
@@ -75,26 +75,29 @@
 5      STD      RUMP   { int|sys||open(const char *path, \
                            int flags, ... mode_t mode); }
 6      STD      RUMP   { int|sys||close(int fd); }
-7      COMPAT_50 MODULAR { int|sys||wait4(pid_t pid, int *status, \
+7      COMPAT_50 MODULAR compat { int|sys||wait4(pid_t pid, int *status, \
                            int options, struct rusage50 *rusage); }
-8      COMPAT_43 MODULAR { int|sys||creat(const char *path, mode_t mode); } ocreat
+8      COMPAT_43 MODULAR compat        \
+               { int|sys||creat(const char *path, mode_t mode); } ocreat
 9      STD      RUMP   { int|sys||link(const char *path, const char *link); }
 10     STD      RUMP   { int|sys||unlink(const char *path); }
 11     OBSOL           execv
 12     STD      RUMP   { int|sys||chdir(const char *path); }
 13     STD      RUMP   { int|sys||fchdir(int fd); }
-14     COMPAT_50 MODULAR RUMP { int|sys||mknod(const char *path, mode_t mode, \
-                           uint32_t dev); }
+14     COMPAT_50 MODULAR compat RUMP   \
+               { int|sys||mknod(const char *path, mode_t mode, uint32_t dev); }
 15     STD      RUMP   { int|sys||chmod(const char *path, mode_t mode); }
 16     STD      RUMP   { int|sys||chown(const char *path, uid_t uid, \
                            gid_t gid); }
 17     STD             { int|sys||obreak(char *nsize); } break
-18     COMPAT_20 MODULAR { int|sys||getfsstat(struct statfs12 *buf, \
+18     COMPAT_20 MODULAR compat { int|sys||getfsstat(struct statfs12 *buf, \
                            long bufsize, int flags); }
-19     COMPAT_43 MODULAR { long|sys||lseek(int fd, long offset, int whence); }\
+19     COMPAT_43 MODULAR compat        \
+               { long|sys||lseek(int fd, long offset, int whence); }\
                            olseek
 20     NOERR   RUMP    { pid_t|sys||getpid_with_ppid(void); } getpid
-21     COMPAT_40 MODULAR { int|sys||mount(const char *type, const char *path, \
+21     COMPAT_40 MODULAR compat        \
+               { int|sys||mount(const char *type, const char *path, \
                            int flags, void *data); }
 22     STD      RUMP   { int|sys||unmount(const char *path, int flags); }
 23     STD     RUMP    { int|sys||setuid(uid_t uid); }
@@ -120,10 +123,11 @@
 35     STD     RUMP    { int|sys||fchflags(int fd, u_long flags); }
 36     NOERR    RUMP   { void|sys||sync(void); }
 37     STD             { int|sys||kill(pid_t pid, int signum); }
-38     COMPAT_43 MODULAR { int|sys||stat(const char *path, struct stat43 *ub); } \
-                           stat43
+38     COMPAT_43 MODULAR compat        \
+               { int|sys||stat(const char *path, struct stat43 *ub); } stat43
 39     NOERR   RUMP    { pid_t|sys||getppid(void); }
-40     COMPAT_43 MODULAR { int|sys||lstat(const char *path, \
+40     COMPAT_43 MODULAR compat        \
+               { int|sys||lstat(const char *path, \
                            struct stat43 *ub); } lstat43
 41     STD     RUMP    { int|sys||dup(int fd); }
 42     STD     RUMP    { int|sys||pipe(void); }
@@ -132,22 +136,22 @@
                            u_long offset, u_int scale); }
 45     STD     RUMP    { int|sys||ktrace(const char *fname, int ops, \
                            int facs, pid_t pid); }
-46     COMPAT_13 MODULAR { int|sys||sigaction(int signum, \
+46     COMPAT_13 MODULAR compat { int|sys||sigaction(int signum, \
                            const struct sigaction13 *nsa, \
                            struct sigaction13 *osa); } sigaction13
 47     NOERR   RUMP    { gid_t|sys||getgid_with_egid(void); } getgid
-48     COMPAT_13 MODULAR { int|sys||sigprocmask(int how, \
+48     COMPAT_13 MODULAR compat { int|sys||sigprocmask(int how, \
                            int mask); } sigprocmask13
 49     STD     RUMP    { int|sys||__getlogin(char *namebuf, size_t namelen); }
 50     STD     RUMP    { int|sys||__setlogin(const char *namebuf); }
 51     STD             { int|sys||acct(const char *path); }
-52     COMPAT_13 MODULAR { int|sys||sigpending(void); } sigpending13
-53     COMPAT_13 MODULAR { int|sys||sigaltstack( \
+52     COMPAT_13 MODULAR compat { int|sys||sigpending(void); } sigpending13
+53     COMPAT_13 MODULAR compat { int|sys||sigaltstack( \
                            const struct sigaltstack13 *nss, \
                            struct sigaltstack13 *oss); } sigaltstack13
 54     STD     RUMP    { int|sys||ioctl(int fd, \
                            u_long com, ... void *data); }
-55     COMPAT_12 MODULAR { int|sys||reboot(int opt); } oreboot
+55     COMPAT_12 MODULAR compat { int|sys||reboot(int opt); } oreboot
 56     STD      RUMP   { int|sys||revoke(const char *path); }
 57     STD      RUMP   { int|sys||symlink(const char *path, \
                            const char *link); }
@@ -157,18 +161,22 @@
                            char * const *argp, char * const *envp); }
 60     STD      RUMP   { mode_t|sys||umask(mode_t newmask); }
 61     STD      RUMP   { int|sys||chroot(const char *path); }
-62     COMPAT_43 MODULAR { int|sys||fstat(int fd, struct stat43 *sb); } fstat43
-63     COMPAT_43 MODULAR { int|sys||getkerninfo(int op, char *where, int *size, \
+62     COMPAT_43 MODULAR compat        \
+               { int|sys||fstat(int fd, struct stat43 *sb); } fstat43
+63     COMPAT_43 MODULAR compat        \
+               { int|sys||getkerninfo(int op, char *where, int *size, \
                            int arg); } ogetkerninfo
-64     COMPAT_43 MODULAR { int|sys||getpagesize(void); } ogetpagesize
-65     COMPAT_12 MODULAR { int|sys||msync(void *addr, size_t len); }
+64     COMPAT_43 MODULAR compat        \
+               { int|sys||getpagesize(void); } ogetpagesize
+65     COMPAT_12 MODULAR compat { int|sys||msync(void *addr, size_t len); }
 ; XXX COMPAT_??? for 4.4BSD-compatible vfork(2)?
 66     STD             { int|sys||vfork(void); }
 67     OBSOL           vread
 68     OBSOL           vwrite
 69     STD             { int|sys||sbrk(intptr_t incr); }
 70     STD             { int|sys||sstk(int incr); }
-71     COMPAT_43 MODULAR { int|sys||mmap(void *addr, size_t len, int prot, \
+71     COMPAT_43 MODULAR compat        \
+               { int|sys||mmap(void *addr, size_t len, int prot, \
                            int flags, int fd, long pos); } ommap
 72     STD             { int|sys||ovadvise(int anom); } vadvise
 73     STD             { int|sys||munmap(void *addr, size_t len); }
@@ -186,37 +194,44 @@
                            const gid_t *gidset); }
 81     STD     RUMP    { int|sys||getpgrp(void); }
 82     STD     RUMP    { int|sys||setpgid(pid_t pid, pid_t pgid); }
-83     COMPAT_50 MODULAR { int|sys||setitimer(int which, \
+83     COMPAT_50 MODULAR compat { int|sys||setitimer(int which, \
                            const struct itimerval50 *itv, \
                            struct itimerval50 *oitv); }
-84     COMPAT_43 MODULAR { int|sys||wait(void); } owait
-85     COMPAT_12 MODULAR { int|sys||swapon(const char *name); } oswapon
-86     COMPAT_50 MODULAR { int|sys||getitimer(int which, \
+84     COMPAT_43 MODULAR compat { int|sys||wait(void); } owait
+85     COMPAT_12 MODULAR compat { int|sys||swapon(const char *name); } oswapon
+86     COMPAT_50 MODULAR compat { int|sys||getitimer(int which, \
                            struct itimerval50 *itv); }
-87     COMPAT_43 MODULAR { int|sys||gethostname(char *hostname, u_int len); } \
+87     COMPAT_43 MODULAR compat        \
+               { int|sys||gethostname(char *hostname, u_int len); } \
                            ogethostname
-88     COMPAT_43 MODULAR { int|sys||sethostname(char *hostname, u_int len); } \
+88     COMPAT_43 MODULAR compat        \
+               { int|sys||sethostname(char *hostname, u_int len); } \
                            osethostname
-89     COMPAT_43 MODULAR { int|sys||getdtablesize(void); } ogetdtablesize
+89     COMPAT_43 MODULAR compat        \
+               { int|sys||getdtablesize(void); } ogetdtablesize
 90     STD      RUMP   { int|sys||dup2(int from, int to); }
 91     UNIMPL          getdopt
 92     STD     RUMP    { int|sys||fcntl(int fd, int cmd, ... void *arg); }
-93     COMPAT_50 MODULAR RUMP  { int|sys||select(int nd, fd_set *in, fd_set *ou, \
+93     COMPAT_50 MODULAR compat RUMP   \
+               { int|sys||select(int nd, fd_set *in, fd_set *ou, \
                            fd_set *ex, struct timeval50 *tv); }
 94     UNIMPL          setdopt
 95     STD     RUMP    { int|sys||fsync(int fd); }
 96     STD             { int|sys||setpriority(int which, id_t who, int prio); }
-97     COMPAT_30 MODULAR { int|sys||socket(int domain, int type, int protocol); }
+97     COMPAT_30 MODULAR compat        \



Home | Main Index | Thread Index | Old Index