Module Name: src
Committed By: pooka
Date: Mon Jul 20 18:04:14 UTC 2009
Added Files:
src/sys/rump/librump/rumpdev: Makefile Makefile.rumpdev autoconf.c
devnodes.c rump_dev.c rump_dev_private.h
Log Message:
device subroutines and autoconfig support for rump. work in progress.
To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/rump/librump/rumpdev/Makefile \
src/sys/rump/librump/rumpdev/Makefile.rumpdev \
src/sys/rump/librump/rumpdev/autoconf.c \
src/sys/rump/librump/rumpdev/devnodes.c \
src/sys/rump/librump/rumpdev/rump_dev.c \
src/sys/rump/librump/rumpdev/rump_dev_private.h
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/rumpdev/Makefile
diff -u /dev/null src/sys/rump/librump/rumpdev/Makefile:1.1
--- /dev/null Mon Jul 20 18:04:14 2009
+++ src/sys/rump/librump/rumpdev/Makefile Mon Jul 20 18:04:13 2009
@@ -0,0 +1,5 @@
+# $NetBSD: Makefile,v 1.1 2009/07/20 18:04:13 pooka Exp $
+#
+
+RUMPTOP=${.CURDIR}/../..
+.include "${RUMPTOP}/librump/rumpdev/Makefile.rumpdev"
Index: src/sys/rump/librump/rumpdev/Makefile.rumpdev
diff -u /dev/null src/sys/rump/librump/rumpdev/Makefile.rumpdev:1.1
--- /dev/null Mon Jul 20 18:04:14 2009
+++ src/sys/rump/librump/rumpdev/Makefile.rumpdev Mon Jul 20 18:04:13 2009
@@ -0,0 +1,24 @@
+# $NetBSD: Makefile.rumpdev,v 1.1 2009/07/20 18:04:13 pooka Exp $
+#
+
+.include "${RUMPTOP}/Makefile.rump"
+
+LIB= rumpdev
+
+.PATH: ${RUMPTOP}/librump/rumpdev \
+ ${RUMPTOP}/../kern
+
+SRCS= rump_dev.c autoconf.c devnodes.c
+
+# sys/kern
+SRCS+= subr_autoconf.c
+
+# automatically in sync src/lib
+SHLIB_MAJOR= 0
+SHLIB_MINOR= 0
+
+CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern
+CPPFLAGS+= -Wno-pointer-sign
+
+.include <bsd.lib.mk>
+.include <bsd.klinks.mk>
Index: src/sys/rump/librump/rumpdev/autoconf.c
diff -u /dev/null src/sys/rump/librump/rumpdev/autoconf.c:1.1
--- /dev/null Mon Jul 20 18:04:14 2009
+++ src/sys/rump/librump/rumpdev/autoconf.c Mon Jul 20 18:04:13 2009
@@ -0,0 +1,69 @@
+/* $NetBSD: autoconf.c,v 1.1 2009/07/20 18:04:13 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 OR CONTRIBUTORS 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.1 2009/07/20 18:04:13 pooka Exp $");
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+
+/* random stubs since we don't run config on rump yet */
+struct cfdata *cfdata;
+const short *cfroots;
+struct cfdriver * const *cfdriver_list_initial;
+struct cfattachinit *cfattachinit;
+
+/* actually used */
+#define MAXPDEVS 256
+struct pdevinit pdevinit[MAXPDEVS] = {{NULL,0}, }; /* XXX: static limit */
+static int pdev_total = 0;
+
+#include "rump_dev_private.h"
+
+void
+rump_pdev_add(void (*pdev_attach)(int), int pdev_count)
+{
+ struct pdevinit *pdev_new;
+
+ KASSERT(cold);
+
+ pdev_new = &pdevinit[pdev_total];
+ pdev_new->pdev_attach = pdev_attach;
+ pdev_new->pdev_count = pdev_count;
+
+ pdev_total++;
+ KASSERT(pdev_total < MAXPDEVS);
+}
+
+void
+rump_pdev_finalize()
+{
+
+ rump_pdev_add(NULL, 0);
+}
Index: src/sys/rump/librump/rumpdev/devnodes.c
diff -u /dev/null src/sys/rump/librump/rumpdev/devnodes.c:1.1
--- /dev/null Mon Jul 20 18:04:14 2009
+++ src/sys/rump/librump/rumpdev/devnodes.c Mon Jul 20 18:04:13 2009
@@ -0,0 +1,71 @@
+/* $NetBSD: devnodes.c,v 1.1 2009/07/20 18:04:13 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 OR CONTRIBUTORS 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: devnodes.c,v 1.1 2009/07/20 18:04:13 pooka Exp $");
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/kmem.h>
+#include <sys/stat.h>
+#include <sys/vfs_syscalls.h>
+
+#include "rump_dev_private.h"
+
+/* realqvik(tm) "devfs" */
+int
+rump_dev_makenodes(dev_t devtype, const char *basename, char minchar,
+ devmajor_t maj, devminor_t minnum, int nnodes)
+{
+ int error;
+ char *devname, *p;
+ size_t devlen;
+ register_t retval;
+
+ error = do_sys_mkdir("/dev", 0777);
+ if (error != 0 && error != EEXIST)
+ return error;
+
+ devlen = strlen("/dev/") + strlen(basename) + 1 + 1; /* +letter +0 */
+ devname = kmem_zalloc(devlen, KM_SLEEP);
+ strlcpy(devname, "/dev/", devlen);
+ strlcat(devname, basename, devlen);
+ p = devname + devlen-2;
+
+ for (; nnodes > 0; nnodes--, minchar++, minnum++) {
+ KASSERT(minchar <= 'z');
+ *p = minchar;
+
+ if ((error = do_sys_mknod(curlwp, devname, 0666 | devtype,
+ makedev(maj, minnum), &retval)))
+ goto out;
+ }
+
+ out:
+ kmem_free(devname, devlen);
+ return error;
+}
Index: src/sys/rump/librump/rumpdev/rump_dev.c
diff -u /dev/null src/sys/rump/librump/rumpdev/rump_dev.c:1.1
--- /dev/null Mon Jul 20 18:04:14 2009
+++ src/sys/rump/librump/rumpdev/rump_dev.c Mon Jul 20 18:04:14 2009
@@ -0,0 +1,62 @@
+/* $NetBSD: rump_dev.c,v 1.1 2009/07/20 18:04:14 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 OR CONTRIBUTORS 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: rump_dev.c,v 1.1 2009/07/20 18:04:14 pooka Exp $");
+
+#include <sys/param.h>
+#include <sys/device.h>
+
+#include "rump_dev_private.h"
+
+void nocomponent(void);
+void nocomponent() {}
+__weak_alias(rump_dev_cgd_init,nocomponent);
+__weak_alias(rump_dev_raidframe_init,nocomponent);
+
+void
+rump_dev_init(void)
+{
+
+ config_init();
+
+ rump_dev_cgd_init();
+ rump_dev_raidframe_init();
+
+ rump_pdev_finalize();
+
+ config_finalize();
+}
+
+#ifdef __HAVE_DEVICE_REGISTER
+void
+device_register(struct device *dev, void *v)
+{
+
+ /* nada */
+}
+#endif
Index: src/sys/rump/librump/rumpdev/rump_dev_private.h
diff -u /dev/null src/sys/rump/librump/rumpdev/rump_dev_private.h:1.1
--- /dev/null Mon Jul 20 18:04:14 2009
+++ src/sys/rump/librump/rumpdev/rump_dev_private.h Mon Jul 20 18:04:14 2009
@@ -0,0 +1,43 @@
+/* $NetBSD: rump_dev_private.h,v 1.1 2009/07/20 18:04:14 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 OR CONTRIBUTORS 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.
+ */
+
+#ifndef _SYS_RUMP_DEV_PRIVATE_H_
+#define _SYS_RUMP_DEV_PRIVATE_H_
+
+void rump_dev_init(void);
+
+void rump_pdev_add(void (*fn)(int), int);
+void rump_pdev_finalize(void);
+
+int rump_dev_makenodes(dev_t, const char *, char,
+ devmajor_t, devminor_t, int);
+
+
+void rump_dev_cgd_init(void);
+void rump_dev_raidframe_init(void);
+
+#endif /* _SYS_RUMP_DEV_PRIVATE_H_ */