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.
This commit is contained in:
parent
6017724458
commit
90ac64de16
|
@ -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 @@ struct devi {
|
|||
#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 */
|
||||
|
|
|
@ -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 @@ static struct nvlist *mk_ns(const char *, struct nvlist *);
|
|||
%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 @@ config_spec:
|
|||
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); } |
|
||||
|
|
|
@ -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 @@ deva_has_instances(struct deva *deva, int unit)
|
|||
{
|
||||
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);
|
||||
|
|
|
@ -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 @@ packdevi(void)
|
|||
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 */
|
||||
|
|
|
@ -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 @@ on return ON;
|
|||
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;
|
||||
|
|
|
@ -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 @@ newdevi(const char *name, int unit, struct devbase *d)
|
|||
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);
|
||||
|
@ -1406,6 +1407,33 @@ deldev(const char *name)
|
|||
nvfreel(stack);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -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 deldeva(const char *);
|
|||
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 *);
|
||||
|
|
Loading…
Reference in New Issue