Module Name:    src
Committed By:   pooka
Date:           Fri Jun 13 15:45:02 UTC 2014

Modified Files:
        src/lib/librumpvfs: rump_etfs.3
        src/sys/rump/include/rump: rump.h
        src/sys/rump/librump/rumpkern: rump.c
        src/sys/rump/librump/rumpvfs: rumpfs.c

Log Message:
Add rump_boot_etfs_register(), which can be used to specify etfs
nodes that will be available immediately when mountroot is done
and file systems are available.

The intended use is for example for firmware images to be available when
config_mountroot() hooks run.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/librumpvfs/rump_etfs.3
cvs rdiff -u -r1.62 -r1.63 src/sys/rump/include/rump/rump.h
cvs rdiff -u -r1.305 -r1.306 src/sys/rump/librump/rumpkern/rump.c
cvs rdiff -u -r1.128 -r1.129 src/sys/rump/librump/rumpvfs/rumpfs.c

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

Modified files:

Index: src/lib/librumpvfs/rump_etfs.3
diff -u src/lib/librumpvfs/rump_etfs.3:1.6 src/lib/librumpvfs/rump_etfs.3:1.7
--- src/lib/librumpvfs/rump_etfs.3:1.6	Thu Dec 19 15:51:39 2013
+++ src/lib/librumpvfs/rump_etfs.3	Fri Jun 13 15:45:01 2014
@@ -1,4 +1,4 @@
-.\"     $NetBSD: rump_etfs.3,v 1.6 2013/12/19 15:51:39 pooka Exp $
+.\"     $NetBSD: rump_etfs.3,v 1.7 2014/06/13 15:45:01 pooka Exp $
 .\"
 .\" Copyright (c) 2010 Antti Kantee.  All rights reserved.
 .\"
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd December 19, 2013
+.Dd June 13, 2014
 .Dt RUMP_ETFS 3
 .Os
 .Sh NAME
@@ -42,6 +42,8 @@ rump kernel (librump, \-lrump)
 .Fa "const char *key" "const char *hostpath" "enum rump_etfs_type ftype"
 .Fa "uint64_t begin" "uint64_t size"
 .Fc
+.Ft void
+.Fn rump_boot_etfs_register "struct rump_boot_etfs *eb"
 .Ft int
 .Fn rump_pub_etfs_remove "const char *key"
 .Sh DESCRIPTION
@@ -128,6 +130,56 @@ is given the special value
 the underlying file is mapped from
 .Ar begin
 to the end of the file.
+.It Fn rump_boot_etfs_register "eb"
+Unlike the above interfaces,
+.Fn rump_boot_etfs_register
+can and must be called before
+.Fn rump_init .
+It causes an etfs key to be available immediately when the root file
+system is mounted as part of
+.Fn rump_init .
+The intended use is for example for firmware images to be available
+immediately when device driver autoconfiguration is run as part of
+.Fn rump_init .
+.Pp
+To use
+.Fn rump_boot_etfs_register ,
+the client fills out
+.Fa eb .
+The layout of
+.Fa eb
+is as follows:
+.Bd -literal
+struct rump_boot_etfs {
+	/* client initializes */
+	const char *eb_key;
+	const char *eb_hostpath;
+	enum rump_etfs_type eb_type;
+	uint64_t eb_begin;
+	uint64_t eb_size;
+
+	/* rump kernel initializes */
+	struct rump_boot_etfs *_eb_next;
+	int eb_status;
+};
+.Ed
+.Pp
+All of the client fields must be initialized before the call.
+See
+.Fn rump_pub_etfs_register_withsize
+for descriptions of the fields.
+After the function has been called, the client may not touch the
+structure memory or the pathname pointers.
+After
+.Fn rump_init
+returns, the client may check the status of the registration from
+.Fa eb_status
+and free the structure.
+A value of \-1 designates that the etfs registration was not
+performed, 0 designates success and a value larger than 0 designates
+an errno.
+The client must serialize calls to
+.Fn rump_boot_etfs_register .
 .It Fn rump_pub_etfs_remove "key"
 Remove etfs mapping for
 .Fa key .

Index: src/sys/rump/include/rump/rump.h
diff -u src/sys/rump/include/rump/rump.h:1.62 src/sys/rump/include/rump/rump.h:1.63
--- src/sys/rump/include/rump/rump.h:1.62	Wed Apr  2 17:09:23 2014
+++ src/sys/rump/include/rump/rump.h	Fri Jun 13 15:45:02 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rump.h,v 1.62 2014/04/02 17:09:23 justin Exp $	*/
+/*	$NetBSD: rump.h,v 1.63 2014/06/13 15:45:02 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -108,6 +108,20 @@ int	rump_boot_gethowto(void);
 void	rump_boot_sethowto(int);
 void	rump_boot_setsigmodel(enum rump_sigmodel);
 
+struct rump_boot_etfs {
+	/* client initializes */
+	const char *eb_key;
+	const char *eb_hostpath;
+	enum rump_etfs_type eb_type;
+	uint64_t eb_begin;
+	uint64_t eb_size;
+
+	/* rump kernel initializes */
+	struct rump_boot_etfs *_eb_next;
+	int eb_status;
+};
+void	rump_boot_etfs_register(struct rump_boot_etfs *);
+
 void	rump_schedule(void);
 void	rump_unschedule(void);
 

Index: src/sys/rump/librump/rumpkern/rump.c
diff -u src/sys/rump/librump/rumpkern/rump.c:1.305 src/sys/rump/librump/rumpkern/rump.c:1.306
--- src/sys/rump/librump/rumpkern/rump.c:1.305	Sun May 25 16:31:51 2014
+++ src/sys/rump/librump/rumpkern/rump.c	Fri Jun 13 15:45:02 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rump.c,v 1.305 2014/05/25 16:31:51 pooka Exp $	*/
+/*	$NetBSD: rump.c,v 1.306 2014/06/13 15:45:02 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.305 2014/05/25 16:31:51 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.306 2014/06/13 15:45:02 pooka Exp $");
 
 #include <sys/systm.h>
 #define ELFSIZE ARCH_ELFSIZE
@@ -885,6 +885,23 @@ rump_syscall_boot_establish(const struct
 	}
 }
 
+struct rump_boot_etfs *ebstart;
+void
+rump_boot_etfs_register(struct rump_boot_etfs *eb)
+{
+
+	/*
+	 * Could use atomics, but, since caller would need to synchronize
+	 * against calling rump_init() anyway, easier to just specify the
+	 * interface as "caller serializes".  This solve-by-specification
+	 * approach avoids the grey area of using atomics before rump_init()
+	 * runs.
+	 */
+	eb->_eb_next = ebstart;
+	eb->eb_status = -1;
+	ebstart = eb;
+}
+
 /*
  * Temporary notification that rumpkern_time is obsolete.  This is to
  * be removed along with obsoleting rumpkern_time in a few months.

Index: src/sys/rump/librump/rumpvfs/rumpfs.c
diff -u src/sys/rump/librump/rumpvfs/rumpfs.c:1.128 src/sys/rump/librump/rumpvfs/rumpfs.c:1.129
--- src/sys/rump/librump/rumpvfs/rumpfs.c:1.128	Wed May 28 20:57:22 2014
+++ src/sys/rump/librump/rumpvfs/rumpfs.c	Fri Jun 13 15:45:02 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfs.c,v 1.128 2014/05/28 20:57:22 justin Exp $	*/
+/*	$NetBSD: rumpfs.c,v 1.129 2014/06/13 15:45:02 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009, 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.128 2014/05/28 20:57:22 justin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.129 2014/06/13 15:45:02 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -1817,6 +1817,8 @@ rumpfs_init()
 {
 	extern rump_etfs_register_withsize_fn rump__etfs_register;
 	extern rump_etfs_remove_fn rump__etfs_remove;
+	extern struct rump_boot_etfs *ebstart;
+	struct rump_boot_etfs *eb;
 
 	CTASSERT(RUMP_ETFS_SIZE_ENDOFF == RUMPBLK_SIZENOTSET);
 
@@ -1825,6 +1827,11 @@ rumpfs_init()
 
 	rump__etfs_register = etfsregister;
 	rump__etfs_remove = etfsremove;
+
+	for (eb = ebstart; eb; eb = eb->_eb_next) {
+		eb->eb_status = etfsregister(eb->eb_key, eb->eb_hostpath,
+		    eb->eb_type, eb->eb_begin, eb->eb_size);
+	}
 }
 
 void

Reply via email to