Module Name: src Committed By: pooka Date: Fri Mar 5 18:41:46 UTC 2010
Modified Files: src/sys/rump/librump/rumpkern: rump.c rumpkern.ifspec src/sys/rump/librump/rumpvfs: rump_vfs.c Log Message: Use improved kernel module interfaces: instead of adding + loading modules in bootstrap, just add them. Load them later the same way as the kernel does: module_init_class(). Change the signature of rump_module_init() to take a vector instead of just one module. All modules in a DSO should be init'd at the same time because they might depend on each other, and code outside the rump kernel cannot know which way. (binary kernel modules are still loaded with rump_sys_modctl() the usual way). To generate a diff of this commit: cvs rdiff -u -r1.154 -r1.155 src/sys/rump/librump/rumpkern/rump.c cvs rdiff -u -r1.3 -r1.4 src/sys/rump/librump/rumpkern/rumpkern.ifspec cvs rdiff -u -r1.42 -r1.43 src/sys/rump/librump/rumpvfs/rump_vfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/rump/librump/rumpkern/rump.c diff -u src/sys/rump/librump/rumpkern/rump.c:1.154 src/sys/rump/librump/rumpkern/rump.c:1.155 --- src/sys/rump/librump/rumpkern/rump.c:1.154 Mon Mar 1 13:12:20 2010 +++ src/sys/rump/librump/rumpkern/rump.c Fri Mar 5 18:41:46 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: rump.c,v 1.154 2010/03/01 13:12:20 pooka Exp $ */ +/* $NetBSD: rump.c,v 1.155 2010/03/05 18:41:46 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.154 2010/03/01 13:12:20 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.155 2010/03/05 18:41:46 pooka Exp $"); #include <sys/param.h> #include <sys/atomic.h> @@ -145,6 +145,8 @@ rump_proc_vfs_init_fn rump_proc_vfs_init; rump_proc_vfs_release_fn rump_proc_vfs_release; +static void add_linkedin_modules(const struct modinfo *const *, size_t); + static void __noinline messthestack(void) { @@ -284,6 +286,8 @@ devsw_init(); pipe_init(); + rumpuser_dl_bootstrap(add_linkedin_modules, rump_kernelfsym_load); + /* these do nothing if not present */ rump_vfs_init(); rump_net_init(); @@ -299,7 +303,7 @@ sysctl_finalize(); - rumpuser_dl_bootstrap(rump_module_init, rump_kernelfsym_load); + module_init_class(MODULE_CLASS_ANY); rumpuser_gethostname(hostname, MAXHOSTNAMELEN, &error); hostnamelen = strlen(hostname); @@ -612,48 +616,37 @@ rumpuser_dl_component_init(type, rump_component_init_cb); } -#define ERROUT(err) do { rv = err; goto out; } while (/*CONSTCOND*/0) +/* + * Initialize a module which has already been loaded and linked + * with dlopen(). This is fundamentally the same as a builtin module. + */ int -rump_module_init(struct modinfo *mi, prop_dictionary_t props) +rump_module_init(const struct modinfo * const *mip, size_t nmodinfo) { - struct module *mod; - int rv; - /* module_dummy */ - if (mi->mi_name == NULL) - return EINVAL; - - mutex_enter(&module_lock); - if (module_lookup(mi->mi_name)) - ERROUT(EEXIST); - - if (!module_compatible(mi->mi_version, __NetBSD_Version__)) - ERROUT(EPROGMISMATCH); - - rv = mi->mi_modcmd(MODULE_CMD_INIT, props); - if (rv == 0) { - mod = kmem_zalloc(sizeof(*mod), KM_SLEEP); - mod->mod_info = mi; - module_enqueue(mod); - if (mi->mi_class == MODULE_CLASS_SECMODEL) - secmodel_register(); - } - - out: - mutex_exit(&module_lock); - return rv; + return module_builtin_add(mip, nmodinfo, true); } +/* + * Finish module (flawless victory, fatality!). + */ int -rump_module_fini(struct modinfo *mi) +rump_module_fini(const struct modinfo *mi) { - int rv; - rv = mi->mi_modcmd(MODULE_CMD_FINI, NULL); - if (rv == 0 && mi->mi_class == MODULE_CLASS_SECMODEL) - secmodel_deregister(); + return module_builtin_remove(mi, true); +} - return rv; +/* + * Add loaded and linked module to the builtin list. It will + * later be initialized with module_init_class(). + */ + +static void +add_linkedin_modules(const struct modinfo * const *mip, size_t nmodinfo) +{ + + module_builtin_add(mip, nmodinfo, false); } int Index: src/sys/rump/librump/rumpkern/rumpkern.ifspec diff -u src/sys/rump/librump/rumpkern/rumpkern.ifspec:1.3 src/sys/rump/librump/rumpkern/rumpkern.ifspec:1.4 --- src/sys/rump/librump/rumpkern/rumpkern.ifspec:1.3 Thu Nov 26 09:20:07 2009 +++ src/sys/rump/librump/rumpkern/rumpkern.ifspec Fri Mar 5 18:41:46 2010 @@ -1,4 +1,4 @@ -; $NetBSD: rumpkern.ifspec,v 1.3 2009/11/26 09:20:07 pooka Exp $ +; $NetBSD: rumpkern.ifspec,v 1.4 2010/03/05 18:41:46 pooka Exp $ NAME|kern PUBHDR|include/rump/rumpkern_if_pub.h @@ -11,8 +11,8 @@ void |reboot |int int |getversion |void -int |module_init |struct modinfo *, prop_dictionary_t -int |module_fini |struct modinfo * +int |module_init |const struct modinfo * const *, size_t +int |module_fini |const struct modinfo * int |kernelfsym_load|void *, uint64_t, char *, uint64_t struct uio * |uio_setup |void *, size_t, off_t, enum rump_uiorw Index: src/sys/rump/librump/rumpvfs/rump_vfs.c diff -u src/sys/rump/librump/rumpvfs/rump_vfs.c:1.42 src/sys/rump/librump/rumpvfs/rump_vfs.c:1.43 --- src/sys/rump/librump/rumpvfs/rump_vfs.c:1.42 Thu Dec 17 00:29:46 2009 +++ src/sys/rump/librump/rumpvfs/rump_vfs.c Fri Mar 5 18:41:46 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: rump_vfs.c,v 1.42 2009/12/17 00:29:46 pooka Exp $ */ +/* $NetBSD: rump_vfs.c,v 1.43 2010/03/05 18:41:46 pooka Exp $ */ /* * Copyright (c) 2008 Antti Kantee. All Rights Reserved. @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.42 2009/12/17 00:29:46 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.43 2010/03/05 18:41:46 pooka Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -133,6 +133,8 @@ } else { syncdelay = 0; } + + module_init_class(MODULE_CLASS_VFS); } void