Source-Changes-HG archive

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

[src/trunk]: src Add rump_boot_etfs_register(), which can be used to specify ...



details:   https://anonhg.NetBSD.org/src/rev/7dc885862331
branches:  trunk
changeset: 329907:7dc885862331
user:      pooka <pooka%NetBSD.org@localhost>
date:      Fri Jun 13 15:45:01 2014 +0000

description:
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.

diffstat:

 lib/librumpvfs/rump_etfs.3        |  56 +++++++++++++++++++++++++++++++++++++-
 sys/rump/include/rump/rump.h      |  16 ++++++++++-
 sys/rump/librump/rumpkern/rump.c  |  21 +++++++++++++-
 sys/rump/librump/rumpvfs/rumpfs.c |  11 ++++++-
 4 files changed, 97 insertions(+), 7 deletions(-)

diffs (195 lines):

diff -r b113d9f785ce -r 7dc885862331 lib/librumpvfs/rump_etfs.3
--- a/lib/librumpvfs/rump_etfs.3        Fri Jun 13 13:54:08 2014 +0000
+++ b/lib/librumpvfs/rump_etfs.3        Fri Jun 13 15:45:01 2014 +0000
@@ -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 @@
 .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 @@
 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 .
diff -r b113d9f785ce -r 7dc885862331 sys/rump/include/rump/rump.h
--- a/sys/rump/include/rump/rump.h      Fri Jun 13 13:54:08 2014 +0000
+++ b/sys/rump/include/rump/rump.h      Fri Jun 13 15:45:01 2014 +0000
@@ -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 @@
 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);
 
diff -r b113d9f785ce -r 7dc885862331 sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c  Fri Jun 13 13:54:08 2014 +0000
+++ b/sys/rump/librump/rumpkern/rump.c  Fri Jun 13 15:45:01 2014 +0000
@@ -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 @@
        }
 }
 
+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.
diff -r b113d9f785ce -r 7dc885862331 sys/rump/librump/rumpvfs/rumpfs.c
--- a/sys/rump/librump/rumpvfs/rumpfs.c Fri Jun 13 13:54:08 2014 +0000
+++ b/sys/rump/librump/rumpvfs/rumpfs.c Fri Jun 13 15:45:01 2014 +0000
@@ -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 @@
 {
        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 @@
 
        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



Home | Main Index | Thread Index | Old Index