Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/librump/rumpdev use ioconf for mainbus



details:   https://anonhg.NetBSD.org/src/rev/26ba0e474b30
branches:  trunk
changeset: 790130:26ba0e474b30
user:      pooka <pooka%NetBSD.org@localhost>
date:      Fri Sep 20 16:49:00 2013 +0000

description:
use ioconf for mainbus

diffstat:

 sys/rump/librump/rumpdev/MAINBUS.ioconf     |   6 +++
 sys/rump/librump/rumpdev/Makefile.rumpdev   |   5 ++-
 sys/rump/librump/rumpdev/autoconf.c         |  44 +++++++++++++++++-----------
 sys/rump/librump/rumpdev/rump_dev.c         |  13 ++-----
 sys/rump/librump/rumpdev/rump_dev_private.h |   5 ++-
 5 files changed, 45 insertions(+), 28 deletions(-)

diffs (181 lines):

diff -r 2aa1ba4deaa1 -r 26ba0e474b30 sys/rump/librump/rumpdev/MAINBUS.ioconf
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/librump/rumpdev/MAINBUS.ioconf   Fri Sep 20 16:49:00 2013 +0000
@@ -0,0 +1,6 @@
+ioconf mainbus
+
+include "conf/files"
+include "rump/dev/files.rump"
+
+mainbus0 at root
diff -r 2aa1ba4deaa1 -r 26ba0e474b30 sys/rump/librump/rumpdev/Makefile.rumpdev
--- a/sys/rump/librump/rumpdev/Makefile.rumpdev Fri Sep 20 16:39:14 2013 +0000
+++ b/sys/rump/librump/rumpdev/Makefile.rumpdev Fri Sep 20 16:49:00 2013 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.rumpdev,v 1.7 2013/09/19 17:55:22 pooka Exp $
+#      $NetBSD: Makefile.rumpdev,v 1.8 2013/09/20 16:49:00 pooka Exp $
 #
 
 LIB=   rumpdev
@@ -6,6 +6,9 @@
 .PATH: ${RUMPTOP}/librump/rumpdev                              \
        ${RUMPTOP}/../kern
 
+IOCONFDIR:=    ${.PARSEDIR}
+IOCONF=                MAINBUS.ioconf
+
 SRCS=  rump_dev.c autoconf.c
 
 # sys/kern
diff -r 2aa1ba4deaa1 -r 26ba0e474b30 sys/rump/librump/rumpdev/autoconf.c
--- a/sys/rump/librump/rumpdev/autoconf.c       Fri Sep 20 16:39:14 2013 +0000
+++ b/sys/rump/librump/rumpdev/autoconf.c       Fri Sep 20 16:49:00 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.7 2012/10/27 17:18:40 chs Exp $ */
+/*     $NetBSD: autoconf.c,v 1.8 2013/09/20 16:49:00 pooka Exp $       */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.7 2012/10/27 17:18:40 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.8 2013/09/20 16:49:00 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -41,29 +41,21 @@
 };
 
 /*
- * Initial lists.  Should ingrate with config better.
+ * Initial lists as required by autoconf(9).  The data from ioconf.c
+ * is patched in by rump_mainbus_init().
  */
 const struct cfattachinit cfattachinit[] = {
        { NULL, NULL },
 };
 struct cfdata cfdata[] = {
-       { "mainbus", "mainbus", 0, FSTATE_NOTFOUND, NULL, 0, NULL},
+       { NULL, NULL, 0, FSTATE_NOTFOUND, NULL, 0, NULL}, /* replaced by init */
        { NULL, NULL, 0, FSTATE_NOTFOUND, NULL, 0, NULL},
 };
 struct cfdriver * const cfdriver_list_initial[] = {
-       NULL
+       NULL,
 };
 
-static const struct cfiattrdata mainbuscf_iattrdata = {
-       "mainbus", 0, {
-               { NULL, NULL, 0 },
-       }
-};
-static const struct cfiattrdata * const mainbus_attrs[] = {
-       &mainbuscf_iattrdata,
-       NULL
-};
-CFDRIVER_DECL(mainbus, DV_DULL, mainbus_attrs);
+#include "ioconf.c"
 
 CFATTACH_DECL_NEW(mainbus, sizeof(struct mainbus_softc),
        mainbus_match, mainbus_attach, NULL, NULL);
@@ -102,14 +94,14 @@
        rump_pdev_add(NULL, 0);
 }
 
-int
+static int
 mainbus_match(device_t parent, cfdata_t match, void *aux)
 {
 
        return 1;
 }
 
-void
+static void
 mainbus_attach(device_t parent, device_t self, void *aux)
 {
 
@@ -128,3 +120,21 @@
 
        return 0;
 }
+
+void
+rump_mainbus_init(void)
+{
+
+       /* replace cfdata[0] to a state expected by autoconf(9) */
+       memcpy(&cfdata[0], &cfdata_ioconf_mainbus[0], sizeof(cfdata[0]));
+}
+
+void
+rump_mainbus_attach(void)
+{
+       const struct cfattachinit *cfai = &cfattach_ioconf_mainbus[0];
+
+       config_cfdata_attach(cfdata, 0);
+       config_cfdriver_attach(cfdriver_ioconf_mainbus[0]);
+       config_cfattach_attach(cfai->cfai_name, cfai->cfai_list[0]);
+}
diff -r 2aa1ba4deaa1 -r 26ba0e474b30 sys/rump/librump/rumpdev/rump_dev.c
--- a/sys/rump/librump/rumpdev/rump_dev.c       Fri Sep 20 16:39:14 2013 +0000
+++ b/sys/rump/librump/rumpdev/rump_dev.c       Fri Sep 20 16:49:00 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump_dev.c,v 1.23 2013/09/17 23:55:16 pooka Exp $      */
+/*     $NetBSD: rump_dev.c,v 1.24 2013/09/20 16:49:00 pooka Exp $      */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump_dev.c,v 1.23 2013/09/17 23:55:16 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump_dev.c,v 1.24 2013/09/20 16:49:00 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -48,6 +48,7 @@
 
        KERNEL_LOCK(1, curlwp);
 
+       rump_mainbus_init();
        config_init_mi();
 
        rump_component_init(RUMP_COMPONENT_DEV);
@@ -62,13 +63,7 @@
         */
        if (rump_component_count(RUMP_COMPONENT_DEV) > 0
            || rump_component_count(RUMP_COMPONENT_DEV_AFTERMAINBUS) > 0) {
-               extern struct cfdriver mainbus_cd;
-               extern struct cfattach mainbus_ca;
-               extern struct cfdata cfdata[];
-
-               config_cfdata_attach(cfdata, 0);
-               config_cfdriver_attach(&mainbus_cd);
-               config_cfattach_attach("mainbus", &mainbus_ca);
+               rump_mainbus_attach();
                if (config_rootfound("mainbus", NULL) == NULL)
                        panic("no mainbus");
 
diff -r 2aa1ba4deaa1 -r 26ba0e474b30 sys/rump/librump/rumpdev/rump_dev_private.h
--- a/sys/rump/librump/rumpdev/rump_dev_private.h       Fri Sep 20 16:39:14 2013 +0000
+++ b/sys/rump/librump/rumpdev/rump_dev_private.h       Fri Sep 20 16:49:00 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump_dev_private.h,v 1.12 2010/06/13 16:49:01 pooka Exp $      */
+/*     $NetBSD: rump_dev_private.h,v 1.13 2013/09/20 16:49:00 pooka Exp $      */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -35,6 +35,9 @@
 void   rump_pdev_add(void (*fn)(int), int);
 void   rump_pdev_finalize(void);
 
+void   rump_mainbus_init(void);
+void   rump_mainbus_attach(void);
+
 struct mainbus_attach_args {
        int maa_unit;
 };



Home | Main Index | Thread Index | Old Index