Source-Changes-HG archive

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

[src/trunk]: src Introduce RUMP_COMPONENT. It behaves mostly like a simplified



details:   https://anonhg.NetBSD.org/src/rev/5b01210c0e9c
branches:  trunk
changeset: 752562:5b01210c0e9c
user:      pooka <pooka%NetBSD.org@localhost>
date:      Mon Mar 01 13:12:19 2010 +0000

description:
Introduce RUMP_COMPONENT.  It behaves mostly like a simplified
module which is linked into the kernel and cannot be unloaded.
The main purpose is to get the proper constructors run and create
any /dev nodes necessary for said component.  Once more of the
kernel (e.g. networking stack and device drivers) are converted to
MODULE and devfs pops up from somewhere, rump components can be
retired.

diffstat:

 lib/librumpuser/rumpuser_dl.c                      |  51 +++++++++++++++++++++-
 sys/rump/dev/lib/Makefile.inc                      |   5 +-
 sys/rump/dev/lib/libbpf/component.c                |   9 +--
 sys/rump/dev/lib/libcgd/component.c                |   9 +--
 sys/rump/dev/lib/libdm/component.c                 |   9 +--
 sys/rump/dev/lib/libnetsmb/component.c             |   8 +-
 sys/rump/dev/lib/libraidframe/component.c          |   8 +-
 sys/rump/dev/lib/librnd/component.c                |   8 +-
 sys/rump/dev/lib/libsysmon/component.c             |   8 +-
 sys/rump/dev/lib/libucom/ucom_at_usb.c             |   6 +-
 sys/rump/dev/lib/libulpt/ulpt_at_usb.c             |   6 +-
 sys/rump/dev/lib/libumass/sd_at_scsibus_at_umass.c |   6 +-
 sys/rump/dev/lib/libwscons/component.c             |   6 +-
 sys/rump/include/rump/rumpuser.h                   |   5 +-
 sys/rump/ldscript.rump                             |   9 +++-
 sys/rump/librump/rumpdev/rump_dev.c                |  30 +++---------
 sys/rump/librump/rumpdev/rump_dev_private.h        |  16 +-----
 sys/rump/librump/rumpkern/rump.c                   |  32 ++++++++++++-
 sys/rump/librump/rumpkern/rump_private.h           |  24 +++++++++-
 sys/rump/librump/rumpnet/rump_net.c                |  25 +++-------
 sys/rump/librump/rumpnet/rump_net_private.h        |   8 +--
 sys/rump/net/lib/Makefile.inc                      |   5 +-
 sys/rump/net/lib/liblocal/component.c              |  10 +--
 sys/rump/net/lib/libnet/component.c                |   8 +-
 sys/rump/net/lib/libnetinet/component.c            |  10 +--
 sys/rump/net/lib/libsockin/component.c             |  10 +--
 sys/rump/net/lib/libvirtif/component.c             |  10 +--
 27 files changed, 200 insertions(+), 141 deletions(-)

diffs (truncated from 912 to 300 lines):

diff -r 357358a99438 -r 5b01210c0e9c lib/librumpuser/rumpuser_dl.c
--- a/lib/librumpuser/rumpuser_dl.c     Mon Mar 01 13:03:30 2010 +0000
+++ b/lib/librumpuser/rumpuser_dl.c     Mon Mar 01 13:12:19 2010 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: rumpuser_dl.c,v 1.1 2010/02/26 18:54:20 pooka Exp $   */
+/*      $NetBSD: rumpuser_dl.c,v 1.2 2010/03/01 13:13:48 pooka Exp $   */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: rumpuser_dl.c,v 1.1 2010/02/26 18:54:20 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_dl.c,v 1.2 2010/03/01 13:13:48 pooka Exp $");
 
 #include <sys/types.h>
 #include <sys/time.h>
@@ -402,6 +402,46 @@
                                couldload = 1;
        } while (couldload);
 }
+
+void
+rumpuser_dl_component_init(int type, rump_component_init_fn compinit)
+{
+       struct link_map *map;
+
+       if (dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map) == -1) {
+               fprintf(stderr, "warning: rumpuser module bootstrap "
+                   "failed: %s\n", dlerror());
+               return;
+       }
+
+       for (; map->l_next; map = map->l_next)
+               continue;
+       for (; map; map = map->l_prev) {
+               if (strstr(map->l_name, "librump") != NULL) {
+                       void *handle;
+                       struct rump_component **rc, **rc_end;
+
+                       handle = dlopen(map->l_name, RTLD_LAZY);
+                       if (handle == NULL)
+                               continue;
+
+                       rc = dlsym(handle,
+                           "__start_link_set_rump_components");
+                       if (!rc)
+                               goto loop;
+                       rc_end = dlsym(handle,
+                           "__stop_link_set_rump_components");
+                       if (!rc_end)
+                               goto loop;
+
+                       for (; rc < rc_end; rc++)
+                               compinit(*rc, type);
+                       assert(rc == rc_end);
+ loop:
+                       dlclose(handle);
+               }
+       }
+}
 #else
 void
 rumpuser_dl_bootstrap(rump_modinit_fn domodinit,
@@ -410,4 +450,11 @@
 
        fprintf(stderr, "Warning, dlinfo() unsupported on host?\n");
 }
+
+void
+rumpuser_dl_component_init(int type, rump_component_init_fn compinit)
+{
+
+       fprintf(stderr, "Warning, dlinfo() unsupported on host?\n");
+}
 #endif
diff -r 357358a99438 -r 5b01210c0e9c sys/rump/dev/lib/Makefile.inc
--- a/sys/rump/dev/lib/Makefile.inc     Mon Mar 01 13:03:30 2010 +0000
+++ b/sys/rump/dev/lib/Makefile.inc     Mon Mar 01 13:12:19 2010 +0000
@@ -1,7 +1,8 @@
-#      $NetBSD: Makefile.inc,v 1.2 2009/09/04 17:21:34 pooka Exp $
+#      $NetBSD: Makefile.inc,v 1.3 2010/03/01 13:12:19 pooka Exp $
 #
 
 RUMPTOP=       ${.CURDIR}/../../..
-CPPFLAGS+=     -I${RUMPTOP}/librump/rumpdev -I${RUMPTOP}/librump/rumpdev/opt
+CPPFLAGS+=     -I${RUMPTOP}/librump/rumpkern -I${RUMPTOP}/librump/rumpdev \
+               -I${RUMPTOP}/librump/rumpdev/opt
 
 .include "${RUMPTOP}/Makefile.rump"
diff -r 357358a99438 -r 5b01210c0e9c sys/rump/dev/lib/libbpf/component.c
--- a/sys/rump/dev/lib/libbpf/component.c       Mon Mar 01 13:03:30 2010 +0000
+++ b/sys/rump/dev/lib/libbpf/component.c       Mon Mar 01 13:12:19 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: component.c,v 1.2 2010/01/26 17:50:02 pooka Exp $      */
+/*     $NetBSD: component.c,v 1.3 2010/03/01 13:12:19 pooka Exp $      */
 
 /*
  * Copyright (c) 2010 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.2 2010/01/26 17:50:02 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.3 2010/03/01 13:12:19 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -36,11 +36,10 @@
 
 #include <net/bpf.h>
 
-#include "rump_dev_private.h"
+#include "rump_private.h"
 #include "rump_vfs_private.h"
 
-void
-rump_dev_bpf_init()
+RUMP_COMPONENT(RUMP_COMPONENT_DEV)
 {
         extern const struct cdevsw bpf_cdevsw;
        devmajor_t bmaj, cmaj;
diff -r 357358a99438 -r 5b01210c0e9c sys/rump/dev/lib/libcgd/component.c
--- a/sys/rump/dev/lib/libcgd/component.c       Mon Mar 01 13:03:30 2010 +0000
+++ b/sys/rump/dev/lib/libcgd/component.c       Mon Mar 01 13:12:19 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: component.c,v 1.5 2010/01/13 00:31:57 pooka Exp $      */
+/*     $NetBSD: component.c,v 1.6 2010/03/01 13:12:19 pooka Exp $      */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -26,18 +26,17 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.5 2010/01/13 00:31:57 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.6 2010/03/01 13:12:19 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
 #include <sys/device.h>
 #include <sys/stat.h>
 
-#include "rump_dev_private.h"
+#include "rump_private.h"
 #include "rump_vfs_private.h"
 
-void
-rump_dev_cgd_init()
+RUMP_COMPONENT(RUMP_COMPONENT_DEV)
 {
        extern const struct bdevsw cgd_bdevsw;
        extern const struct cdevsw cgd_cdevsw;
diff -r 357358a99438 -r 5b01210c0e9c sys/rump/dev/lib/libdm/component.c
--- a/sys/rump/dev/lib/libdm/component.c        Mon Mar 01 13:03:30 2010 +0000
+++ b/sys/rump/dev/lib/libdm/component.c        Mon Mar 01 13:12:19 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: component.c,v 1.1 2009/12/04 22:13:59 haad Exp $       */
+/*     $NetBSD: component.c,v 1.2 2010/03/01 13:12:19 pooka Exp $      */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.1 2009/12/04 22:13:59 haad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.2 2010/03/01 13:12:19 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -36,14 +36,13 @@
 
 #include <sys/vfs_syscalls.h>
 
-
+#include "rump_private.h"
 #include "rump_dev_private.h"
 #include "rump_vfs_private.h"
 
 void dmattach(int);
 
-void
-rump_dev_dm_init()
+RUMP_COMPONENT(RUMP_COMPONENT_DEV)
 {
        extern const struct bdevsw dm_bdevsw;
        extern const struct cdevsw dm_cdevsw;
diff -r 357358a99438 -r 5b01210c0e9c sys/rump/dev/lib/libnetsmb/component.c
--- a/sys/rump/dev/lib/libnetsmb/component.c    Mon Mar 01 13:03:30 2010 +0000
+++ b/sys/rump/dev/lib/libnetsmb/component.c    Mon Mar 01 13:12:19 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: component.c,v 1.3 2009/12/03 15:06:04 pooka Exp $      */
+/*     $NetBSD: component.c,v 1.4 2010/03/01 13:12:19 pooka Exp $      */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -28,20 +28,20 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.3 2009/12/03 15:06:04 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.4 2010/03/01 13:12:19 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
 #include <sys/device.h>
 #include <sys/stat.h>
 
+#include "rump_private.h"
 #include "rump_dev_private.h"
 #include "rump_vfs_private.h"
 
 void nsmbattach(int); /* XXX */
 
-void
-rump_dev_netsmb_init()
+RUMP_COMPONENT(RUMP_COMPONENT_DEV)
 {
        extern const struct cdevsw nsmb_cdevsw;
        devmajor_t bmaj, cmaj;
diff -r 357358a99438 -r 5b01210c0e9c sys/rump/dev/lib/libraidframe/component.c
--- a/sys/rump/dev/lib/libraidframe/component.c Mon Mar 01 13:03:30 2010 +0000
+++ b/sys/rump/dev/lib/libraidframe/component.c Mon Mar 01 13:12:19 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: component.c,v 1.4 2009/12/03 15:06:04 pooka Exp $      */
+/*     $NetBSD: component.c,v 1.5 2010/03/01 13:12:19 pooka Exp $      */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -26,13 +26,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.4 2009/12/03 15:06:04 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.5 2010/03/01 13:12:19 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
 #include <sys/device.h>
 #include <sys/stat.h>
 
+#include "rump_private.h"
 #include "rump_dev_private.h"
 #include "rump_vfs_private.h"
 
@@ -40,8 +41,7 @@
 
 void raidattach(int);
 
-void
-rump_dev_raidframe_init()
+RUMP_COMPONENT(RUMP_COMPONENT_DEV)
 {
        extern const struct bdevsw raid_bdevsw;
        extern const struct cdevsw raid_cdevsw;
diff -r 357358a99438 -r 5b01210c0e9c sys/rump/dev/lib/librnd/component.c
--- a/sys/rump/dev/lib/librnd/component.c       Mon Mar 01 13:03:30 2010 +0000
+++ b/sys/rump/dev/lib/librnd/component.c       Mon Mar 01 13:12:19 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: component.c,v 1.2 2009/12/03 15:06:04 pooka Exp $      */
+/*     $NetBSD: component.c,v 1.3 2010/03/01 13:12:20 pooka Exp $      */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.2 2009/12/03 15:06:04 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.3 2010/03/01 13:12:20 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -34,13 +34,13 @@
 #include <sys/rnd.h>
 #include <sys/stat.h>
 
+#include "rump_private.h"
 #include "rump_dev_private.h"
 #include "rump_vfs_private.h"
 
 void rndattach(int);
 
-void
-rump_dev_rnd_init()
+RUMP_COMPONENT(RUMP_COMPONENT_DEV)
 {
        extern const struct cdevsw rnd_cdevsw;
        devmajor_t bmaj, cmaj;
diff -r 357358a99438 -r 5b01210c0e9c sys/rump/dev/lib/libsysmon/component.c
--- a/sys/rump/dev/lib/libsysmon/component.c    Mon Mar 01 13:03:30 2010 +0000
+++ b/sys/rump/dev/lib/libsysmon/component.c    Mon Mar 01 13:12:19 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: component.c,v 1.1 2010/01/31 03:06:59 pooka Exp $      */
+/*     $NetBSD: component.c,v 1.2 2010/03/01 13:12:20 pooka Exp $      */
 
 /*
  * Copyright (c) 2010 Antti Kantee.  All Rights Reserved.



Home | Main Index | Thread Index | Old Index