Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/librump Create rump public interfaces from descript...



details:   https://anonhg.NetBSD.org/src/rev/8f5a9a1fe5bf
branches:  trunk
changeset: 748116:8f5a9a1fe5bf
user:      pooka <pooka%NetBSD.org@localhost>
date:      Wed Oct 14 17:17:00 2009 +0000

description:
Create rump public interfaces from description tables.  This allows
us to control and wrap all entry points from "userspace" into rump.
This in turn is necessary for the upcoming rump cpu scheduler.

For each interface "foo" a public wrapper called "rump_foo" is
created.  It calls the internal implementation "rumppriv_foo".  In
case foo is to be called from inside of rump kernel space, the
private interface "rumppriv_foo" is used -- the userspace wrapper
prototypes are not even exported into the rump kernel namespace.
Needless to say, the rump kernel internal interfaces are not exported
for users.

Now, three classes of interfaces fight for control of rump:
  + the noble local control interfaces (which this commit addresses)
  + the insidious rump system calls (which are generated from syscalls.master)
  + and the evil vnode interfaces (which are generated from vnode_if.src)

diffstat:

 sys/rump/librump/makerumpif.sh            |  204 ++++++++++++++++++++++++++++++
 sys/rump/librump/rumpkern/rumpkern.ifspec |   35 +++++
 sys/rump/librump/rumpnet/rumpnet.ifspec   |   11 +
 sys/rump/librump/rumpvfs/rumpvfs.ifspec   |   65 +++++++++
 4 files changed, 315 insertions(+), 0 deletions(-)

diffs (truncated from 331 to 300 lines):

diff -r b3511f846f79 -r 8f5a9a1fe5bf sys/rump/librump/makerumpif.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/librump/makerumpif.sh    Wed Oct 14 17:17:00 2009 +0000
@@ -0,0 +1,204 @@
+#!/bin/sh
+#
+#      $NetBSD: makerumpif.sh,v 1.1 2009/10/14 17:17:00 pooka Exp $
+#
+# Copyright (c) 2009 Antti Kantee.  All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+#
+# This reads a rump component interface description and creates:
+#  1: rump private prototypes for internal calls
+#  2: public prototypes for calls outside of rump
+#  3: public interface implementations which run the rump scheduler
+#     and call the private interface
+#
+
+usage ()
+{
+
+       echo "usage: $0 spec"
+       exit 1
+}
+
+boom ()
+{
+
+       echo $*
+       exit 1
+}
+
+[ $# != 1 ] && usage
+
+MYDIR=`pwd`
+while [ ! -f Makefile.rump  ]; do
+       [ `pwd` = '/' ] && boom Could not find rump topdir.
+       cd ..
+done
+RUMPTOP="`pwd`"
+cd ${MYDIR}
+
+sed -e '
+:again
+       /\\$/{
+               N
+               s/[     ]*\\\n[         ]*/ /
+               b again
+       }
+' ${1} | awk -F\| -v rumptop=${RUMPTOP} '
+function fileheaders(file, srcstr)
+{
+       printf("/*\t$NetBSD: makerumpif.sh,v 1.1 2009/10/14 17:17:00 pooka Exp $\t*/\n\n") > file
+       printf("/*\n * Automatically generated.  DO NOT EDIT.\n") > file
+       genstr = "$NetBSD: makerumpif.sh,v 1.1 2009/10/14 17:17:00 pooka Exp $"
+       gsub("\\$", "", genstr)
+       printf(" * from: %s\n", srcstr) > file
+       printf(" * by:   %s\n", genstr) > file
+       printf(" */\n") > file
+}
+
+function die(str)
+{
+
+       print str
+       exit(1)
+}
+
+NR == 1 {
+       sub(";[^\\$]*\\$", "")
+       sub("\\$", "")
+       fromstr = $0
+       next
+}
+
+$1 == "NAME"{myname = $2;next}
+$1 == "PUBHDR"{pubhdr = rumptop "/" $2;next}
+$1 == "PRIVHDR"{privhdr = rumptop "/" $2;next}
+$1 == "WRAPPERS"{gencalls = rumptop "/" $2;next}
+
+/^;/{next}
+/\\$/{sub("\\\n", "");getline nextline;$0 = $0 nextline}
+/^[ \t]*$/{next}
+{
+       if (NF != 3 && NF != 4) {
+               die("error: unexpected number of fields\n")
+       }
+       if (NF == 4) {
+               if ($4 == "WEAK")
+                       isweak = 1
+               else
+                       die("error: unexpected fourth field");
+       } else {
+               isweak = 0
+       }
+       if (!myname)
+               die("name not specified");
+       if (!pubhdr)
+               die("public header not specified");
+       if (!privhdr)
+               die("private header not specified");
+       if (!gencalls)
+               die("wrapper file not specified");
+
+       if (!once) {
+               fileheaders(pubhdr, fromstr)
+               fileheaders(privhdr, fromstr)
+               fileheaders(gencalls, fromstr)
+               once = 1
+
+               pubfile = pubhdr
+               sub(".*/", "", pubfile)
+
+               privfile = privhdr
+               sub(".*/", "", privfile)
+
+               printf("\n") > pubhdr
+               printf("\n") > privhdr
+
+               printf("\n#include <sys/cdefs.h>\n") > gencalls
+               printf("#include <sys/systm.h>\n") > gencalls
+               printf("\n#include <rump/rump.h>\n") > gencalls
+               printf("#include <rump/%s>\n\n", pubfile) > gencalls
+               printf("#include \"%s\"\n\n", privfile) > gencalls
+               printf("void __dead\nrump_%s_unavailable(void);\n",     \
+                   myname) > gencalls
+               printf("void __dead\nrump_%s_unavailable(void)\n{\n",   \
+                   myname) > gencalls
+               printf("\n\tpanic(\"%s interface unavailable\");\n}\n", \
+                   myname) > gencalls
+       }
+
+       funtype = $1
+       sub("[ \t]*$", "", funtype)
+       funname = $2
+       sub("[ \t]*$", "", funname)
+       funargs = $3
+       printf("%s rump_%s(%s);\n", funtype, funname, funargs) > pubhdr
+       printf("%s rumppriv_%s(%s);\n", funtype, funname, funargs) > privhdr
+
+       if (funtype == "void")
+               voidret = 1
+       else
+               voidret = 0
+       if (funargs == "void")
+               voidarg = 1
+       else
+               voidarg = 0
+
+       printf("\n%s\nrump_%s(", funtype, funname) > gencalls
+       if (!voidarg) {
+               narg = split(funargs, argv, ",")
+               for (i = 1; i <= narg; i++) {
+                       sub(" *", "", argv[i])
+                       if (match(argv[i], "\\*$") != 0)
+                               printf("%sarg%d", argv[i], i) > gencalls
+                       else
+                               printf("%s arg%d", argv[i], i) > gencalls
+                       if (i != narg)
+                               printf(", ") > gencalls
+               }
+       } else {
+               narg = 0
+               printf("void") > gencalls
+       }
+       printf(")\n{\n") > gencalls
+
+       if (!voidret) {
+               printf("\t%s rv;\n", $1) > gencalls
+       }
+       printf("\n\t") > gencalls
+       if (!voidret)
+               printf("rv = ") > gencalls
+       printf("rumppriv_%s(", funname) > gencalls
+       for (i = 1; i <= narg; i++) {
+               printf("arg%i", i) > gencalls
+               if (i < narg)
+                       printf(", ") > gencalls
+       }
+       printf(");\n") > gencalls
+       if (!voidret)
+               printf("\n\treturn rv;\n") > gencalls
+       printf("}\n") > gencalls
+       if (isweak)
+               printf("__weak_alias(rumppriv_%s,rump_%s_unavailable);\n", \
+                   funname, myname) > gencalls
+}'
diff -r b3511f846f79 -r 8f5a9a1fe5bf sys/rump/librump/rumpkern/rumpkern.ifspec
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/librump/rumpkern/rumpkern.ifspec Wed Oct 14 17:17:00 2009 +0000
@@ -0,0 +1,35 @@
+;      $NetBSD: rumpkern.ifspec,v 1.1 2009/10/14 17:17:00 pooka Exp $
+
+NAME|kern
+PUBHDR|include/rump/rumpkern_if_pub.h
+PRIVHDR|librump/rumpkern/rumpkern_if_priv.h
+WRAPPERS|librump/rumpkern/rumpkern_if_wrappers.c
+
+; type         | name          | args
+;
+
+void           |reboot         |int
+int            |getversion     |void
+
+int            |module_init    |struct modinfo *, prop_dictionary_t
+int            |module_fini    |struct modinfo *
+
+struct uio *   |uio_setup      |void *, size_t, off_t, enum rump_uiorw
+size_t         |uio_getresid   |struct uio *
+off_t          |uio_getoff     |struct uio *
+size_t         |uio_free       |struct uio *
+
+kauth_cred_t   |cred_create    |uid_t, gid_t, size_t, gid_t *
+kauth_cred_t   |cred_suserget  |void
+void           |cred_put       |kauth_cred_t
+
+; lwp interfaces.  these need much love
+struct lwp *   |newproc_switch |void
+struct lwp *   |setup_curlwp   |pid_t, lwpid_t, int
+struct lwp *   |get_curlwp     |void
+void           |set_curlwp     |struct lwp *
+void           |clear_curlwp   |void
+
+int            |sysproxy_set                   |rump_sysproxy_t, void *
+int            |sysproxy_socket_setup_client   |int
+int            |sysproxy_socket_setup_server   |int
diff -r b3511f846f79 -r 8f5a9a1fe5bf sys/rump/librump/rumpnet/rumpnet.ifspec
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/librump/rumpnet/rumpnet.ifspec   Wed Oct 14 17:17:00 2009 +0000
@@ -0,0 +1,11 @@
+;       $NetBSD: rumpnet.ifspec,v 1.1 2009/10/14 17:17:00 pooka Exp $
+
+NAME|net
+PUBHDR|include/rump/rumpnet_if_pub.h
+PRIVHDR|librump/rumpnet/rumpnet_if_priv.h
+WRAPPERS|librump/rumpnet/rumpnet_if_wrappers.c
+
+; type          | name          | args         | attrs
+;
+
+int            |virtif_create  |int            |WEAK
diff -r b3511f846f79 -r 8f5a9a1fe5bf sys/rump/librump/rumpvfs/rumpvfs.ifspec
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/librump/rumpvfs/rumpvfs.ifspec   Wed Oct 14 17:17:00 2009 +0000
@@ -0,0 +1,65 @@
+;       $NetBSD: rumpvfs.ifspec,v 1.1 2009/10/14 17:17:00 pooka Exp $
+
+NAME|vfs
+PUBHDR|include/rump/rumpvfs_if_pub.h
+PRIVHDR|librump/rumpvfs/rumpvfs_if_priv.h
+WRAPPERS|librump/rumpvfs/rumpvfs_if_wrappers.c
+
+; type          | name          | args         | attrs
+;
+
+void           |getvninfo      |struct vnode *, enum vtype *, off_t *, dev_t *
+
+
+struct vfsops *        |vfslist_iterate|struct vfsops *
+struct vfsops *        |vfs_getopsbyname|const char *
+
+struct vattr * |vattr_init     |void
+void           |vattr_settype  |struct vattr *, enum vtype
+void           |vattr_setmode  |struct vattr *, mode_t
+void           |vattr_setrdev  |struct vattr *, dev_t
+void           |vattr_free     |struct vattr *
+
+void           |vp_incref      |struct vnode *
+int            |vp_getref      |struct vnode *
+void           |vp_rele        |struct vnode *
+
+void           |vp_interlock   |struct vnode *
+
+int            |etfs_register  |const char *, const char *, enum rump_etfs_type
+int            |etfs_register_withsize |const char *, const char *,    \
+                                        enum rump_etfs_type, uint64_t, \
+                                        uint64_t
+int            |etfs_remove    |const char *
+



Home | Main Index | Thread Index | Old Index