Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/config Add a highly experimental pseudo-root feature...



details:   https://anonhg.NetBSD.org/src/rev/f8d3a172d69d
branches:  trunk
changeset: 752844:f8d3a172d69d
user:      pooka <pooka%NetBSD.org@localhost>
date:      Mon Mar 08 10:19:14 2010 +0000

description:
Add a highly experimental pseudo-root feature to be used in conjuction
with the also-experimental ioconf keyword.  pseudo-root allows to
specify a root at any point in the device tree without having
attachments from the actual root.

For example, instead of having a config file like this:
mainbus0 at root
bus_a? at mainbus0
bus_b? at bus_a*
device7 at bus_b?

You can have one like this:
pseudo-root bus_b*
device7 at bus_b?

This will produce the relevant ioconf.c glue for device number 7
only instead of the whole 9 yards from root.  Perhaps needless to
say, this can be used to generate snippets of config glue for
modules and, let's not deny that my main motivation for doing this,
rump components.

This is part 2/3 of my modifications to config (the last part is
autogenerating source file lists and component Makefiles).

No strong objection from cube (after a little pressuring ;), but
like he said, the implementation will most likely need some more
tweaking and may not work correctly under all pseudo-root uses yet.

diffstat:

 usr.bin/config/defs.h |   3 ++-
 usr.bin/config/gram.y |   5 +++--
 usr.bin/config/main.c |  10 ++++++++--
 usr.bin/config/pack.c |   5 +++--
 usr.bin/config/scan.l |   3 ++-
 usr.bin/config/sem.c  |  30 +++++++++++++++++++++++++++++-
 usr.bin/config/sem.h  |   3 ++-
 7 files changed, 49 insertions(+), 10 deletions(-)

diffs (174 lines):

diff -r 3d67aa1c9d23 -r f8d3a172d69d usr.bin/config/defs.h
--- a/usr.bin/config/defs.h     Mon Mar 08 09:32:18 2010 +0000
+++ b/usr.bin/config/defs.h     Mon Mar 08 10:19:14 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.32 2010/03/03 13:53:22 pooka Exp $  */
+/*     $NetBSD: defs.h,v 1.33 2010/03/08 10:19:14 pooka Exp $  */
 
 /*
  * Copyright (c) 1992, 1993
@@ -260,6 +260,7 @@
 #define        DEVI_ACTIVE     1       /* instance has an active parent */
 #define        DEVI_IGNORED    2       /* instance's parent has been removed */
 #define DEVI_BROKEN    3       /* instance is broken (syntax error) */
+       int     i_pseudoroot;   /* instance is pseudoroot */
 
        /* created during packing or ioconf.c generation */
        short   i_collapsed;    /* set => this alias no longer needed */
diff -r 3d67aa1c9d23 -r f8d3a172d69d usr.bin/config/gram.y
--- a/usr.bin/config/gram.y     Mon Mar 08 09:32:18 2010 +0000
+++ b/usr.bin/config/gram.y     Mon Mar 08 10:19:14 2010 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: gram.y,v 1.21 2010/03/03 13:53:22 pooka Exp $  */
+/*     $NetBSD: gram.y,v 1.22 2010/03/08 10:19:14 pooka Exp $  */
 
 /*
  * Copyright (c) 1992, 1993
@@ -111,7 +111,7 @@
 %token XMACHINE MAJOR MAKEOPTIONS MAXUSERS MAXPARTITIONS MINOR
 %token NEEDS_COUNT NEEDS_FLAG NO
 %token XOBJECT OBSOLETE ON OPTIONS
-%token PACKAGE PLUSEQ PREFIX PSEUDO_DEVICE
+%token PACKAGE PLUSEQ PREFIX PSEUDO_DEVICE PSEUDO_ROOT
 %token ROOT
 %token SOURCE
 %token TYPE
@@ -464,6 +464,7 @@
        NO CONFIG WORD                  { delconf($3); } |
        NO PSEUDO_DEVICE WORD           { delpseudo($3); } |
        PSEUDO_DEVICE WORD npseudo      { addpseudo($2, $3); } |
+       PSEUDO_ROOT device_instance     { addpseudoroot($2); } |
        NO device_instance AT attachment
                                        { deldevi($2, $4); } |
        NO DEVICE AT attachment         { deldeva($4); } |
diff -r 3d67aa1c9d23 -r f8d3a172d69d usr.bin/config/main.c
--- a/usr.bin/config/main.c     Mon Mar 08 09:32:18 2010 +0000
+++ b/usr.bin/config/main.c     Mon Mar 08 10:19:14 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.40 2010/03/03 13:56:29 pooka Exp $  */
+/*     $NetBSD: main.c,v 1.41 2010/03/08 10:19:14 pooka Exp $  */
 
 /*
  * Copyright (c) 1992, 1993
@@ -1026,8 +1026,14 @@
 {
        struct devi *i;
 
+       /*
+        * EHAMMERTOOBIG: we shouldn't check i_pseudoroot here.
+        * What we want by this check is them to appear non-present
+        * except for purposes of other devices being able to attach
+        * to them.
+        */
        for (i = deva->d_ihead; i != NULL; i = i->i_asame)
-               if (i->i_active == DEVI_ACTIVE &&
+               if (i->i_active == DEVI_ACTIVE && i->i_pseudoroot == 0 &&
                    (unit == WILD || unit == i->i_unit || i->i_unit == STAR))
                        return (1);
        return (0);
diff -r 3d67aa1c9d23 -r f8d3a172d69d usr.bin/config/pack.c
--- a/usr.bin/config/pack.c     Mon Mar 08 09:32:18 2010 +0000
+++ b/usr.bin/config/pack.c     Mon Mar 08 10:19:14 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pack.c,v 1.7 2010/01/21 18:06:38 pooka Exp $   */
+/*     $NetBSD: pack.c,v 1.8 2010/03/08 10:19:14 pooka Exp $   */
 
 /*
  * Copyright (c) 1992, 1993
@@ -187,7 +187,8 @@
                for (i = d->d_ihead; i != NULL; i = i->i_bsame) {
                        m = n;
                        for (l = i; l != NULL; l = l->i_alias) {
-                               if (l->i_active != DEVI_ACTIVE)
+                               if (l->i_active != DEVI_ACTIVE
+                                   || i->i_pseudoroot)
                                        continue;
                                l->i_locoff = -1;
                                /* try to find an equivalent for l */
diff -r 3d67aa1c9d23 -r f8d3a172d69d usr.bin/config/scan.l
--- a/usr.bin/config/scan.l     Mon Mar 08 09:32:18 2010 +0000
+++ b/usr.bin/config/scan.l     Mon Mar 08 10:19:14 2010 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: scan.l,v 1.14 2010/02/03 21:00:49 pooka Exp $  */
+/*     $NetBSD: scan.l,v 1.15 2010/03/08 10:19:14 pooka Exp $  */
 
 /*
  * Copyright (c) 1992, 1993
@@ -161,6 +161,7 @@
 options                return OPTIONS;
 prefix         return PREFIX;
 pseudo-device  return PSEUDO_DEVICE;
+pseudo-root    return PSEUDO_ROOT;
 root           return ROOT;
 source         return SOURCE;
 type           return TYPE;
diff -r 3d67aa1c9d23 -r f8d3a172d69d usr.bin/config/sem.c
--- a/usr.bin/config/sem.c      Mon Mar 08 09:32:18 2010 +0000
+++ b/usr.bin/config/sem.c      Mon Mar 08 10:19:14 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sem.c,v 1.33 2009/04/11 12:41:10 lukem Exp $   */
+/*     $NetBSD: sem.c,v 1.34 2010/03/08 10:19:15 pooka Exp $   */
 
 /*
  * Copyright (c) 1992, 1993
@@ -922,6 +922,7 @@
        i->i_srcfile = yyfile;
        i->i_active = DEVI_ORPHAN; /* Proper analysis comes later */
        i->i_level = devilevel;
+       i->i_pseudoroot = 0;
        if (unit >= d->d_umax)
                d->d_umax = unit + 1;
        return (i);
@@ -1407,6 +1408,33 @@
 }
 
 void
+addpseudoroot(const char *name)
+{
+       struct devi *i;
+       struct deva *iba;
+       struct devbase *ib;
+
+       fprintf(stderr, "WARNING: pseudo-root is an experimental feature\n");
+
+       i = getdevi(name);
+       if (i == NULL)
+               return;
+       ib = i->i_base;
+       iba = ib->d_ahead; /* XXX: take the first for now, revisit later */
+
+       i->i_atdeva = iba;
+       i->i_cfflags = 0;
+       i->i_locs = fixloc(name, &errattr, NULL);
+       i->i_pseudoroot = 1;
+       i->i_active = DEVI_ORPHAN; /* set active by kill_orphans() */
+
+       *iba->d_ipp = i;
+       iba->d_ipp = &i->i_asame;
+
+       ht_insert(devroottab, ib->d_name, ib);
+}
+
+void
 addpseudo(const char *name, int number)
 {
        struct devbase *d;
diff -r 3d67aa1c9d23 -r f8d3a172d69d usr.bin/config/sem.h
--- a/usr.bin/config/sem.h      Mon Mar 08 09:32:18 2010 +0000
+++ b/usr.bin/config/sem.h      Mon Mar 08 10:19:14 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sem.h,v 1.5 2006/02/11 20:15:53 cube Exp $     */
+/*     $NetBSD: sem.h,v 1.6 2010/03/08 10:19:15 pooka Exp $    */
 
 /*
  * Copyright (c) 1992, 1993
@@ -66,6 +66,7 @@
 void           deldev(const char *);
 void           addpseudo(const char *, int);
 void           delpseudo(const char *);
+void           addpseudoroot(const char *);
 void           adddevm(const char *, int, int, struct nvlist *);
 int            fixdevis(void);
 const char     *ref(const char *);



Home | Main Index | Thread Index | Old Index