Module Name:    src
Committed By:   pooka
Date:           Wed Oct 14 17:17:00 UTC 2009

Added Files:
        src/sys/rump/librump: makerumpif.sh
        src/sys/rump/librump/rumpkern: rumpkern.ifspec
        src/sys/rump/librump/rumpnet: rumpnet.ifspec
        src/sys/rump/librump/rumpvfs: rumpvfs.ifspec

Log Message:
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)


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/rump/librump/makerumpif.sh
cvs rdiff -u -r0 -r1.1 src/sys/rump/librump/rumpkern/rumpkern.ifspec
cvs rdiff -u -r0 -r1.1 src/sys/rump/librump/rumpnet/rumpnet.ifspec
cvs rdiff -u -r0 -r1.1 src/sys/rump/librump/rumpvfs/rumpvfs.ifspec

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/sys/rump/librump/makerumpif.sh
diff -u /dev/null src/sys/rump/librump/makerumpif.sh:1.1
--- /dev/null	Wed Oct 14 17:17:00 2009
+++ src/sys/rump/librump/makerumpif.sh	Wed Oct 14 17:17:00 2009
@@ -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
+}'

Index: src/sys/rump/librump/rumpkern/rumpkern.ifspec
diff -u /dev/null src/sys/rump/librump/rumpkern/rumpkern.ifspec:1.1
--- /dev/null	Wed Oct 14 17:17:00 2009
+++ src/sys/rump/librump/rumpkern/rumpkern.ifspec	Wed Oct 14 17:17:00 2009
@@ -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

Index: src/sys/rump/librump/rumpnet/rumpnet.ifspec
diff -u /dev/null src/sys/rump/librump/rumpnet/rumpnet.ifspec:1.1
--- /dev/null	Wed Oct 14 17:17:00 2009
+++ src/sys/rump/librump/rumpnet/rumpnet.ifspec	Wed Oct 14 17:17:00 2009
@@ -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

Index: src/sys/rump/librump/rumpvfs/rumpvfs.ifspec
diff -u /dev/null src/sys/rump/librump/rumpvfs/rumpvfs.ifspec:1.1
--- /dev/null	Wed Oct 14 17:17:00 2009
+++ src/sys/rump/librump/rumpvfs/rumpvfs.ifspec	Wed Oct 14 17:17:00 2009
@@ -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 *
+
+void		|freecn		|struct componentname *, int
+int		|checksavecn	|struct componentname *
+int		|namei		|uint32_t, uint32_t, const char *,	\
+				 struct vnode **, struct vnode **,	\
+				 struct componentname **
+struct componentname *|makecn	|u_long, u_long, const char *, size_t,	\
+				 kauth_cred_t, struct lwp *
+
+int		|vfs_unmount	|struct mount *, int
+int		|vfs_root	|struct mount *, struct vnode **, int
+int		|vfs_statvfs	|struct mount *, struct statvfs *
+int		|vfs_sync	|struct mount *, int, kauth_cred_t
+int		|vfs_fhtovp	|struct mount *, struct fid *, struct vnode **
+int		|vfs_vptofh	|struct vnode *, struct fid *, size_t *
+void		|vfs_syncwait	|struct mount *
+int		|vfs_getmp	|const char *, struct mount **
+
+void		|rcvp_set	|struct vnode *, struct vnode *
+struct vnode *	|cdir_get	|void
+
+; I picked the wrong header to stop sniffin' glue
+int		|syspuffs_glueinit	|int, int *	|WEAK
+
+; compat syscalls.  these are currently hand-"generated"
+int		|sys___stat30		|const char *, struct stat *
+int		|sys___lstat30		|const char *, struct stat *
+
+; Other compat glue (for sniffing purposes)
+; XXX: (lack of) types
+void		|vattr50_to_vattr	|const struct vattr *, struct vattr *
+void		|vattr_to_vattr50	|const struct vattr *, struct vattr *

Reply via email to