Allow pseudo-devices to be declared with an interface attribute. For
such pseudo-devices, create cfdrivers for them which carry the appropriate attributes. This allows devices in the config file to be attached to pseudo-devices.
This commit is contained in:
parent
14757120f4
commit
a151e17b89
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: defs.h,v 1.10 2003/01/23 15:03:44 gehenna Exp $ */
|
||||
/* $NetBSD: defs.h,v 1.11 2003/01/27 05:00:54 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -365,6 +365,7 @@ struct nvlist *fsoptions; /* filesystems */
|
|||
struct nvlist *mkoptions; /* makeoptions */
|
||||
struct hashtab *devbasetab; /* devbase lookup */
|
||||
struct hashtab *devatab; /* devbase attachment lookup */
|
||||
struct hashtab *devitab; /* device instance lookup */
|
||||
struct hashtab *selecttab; /* selects things that are "optional foo" */
|
||||
struct hashtab *needcnttab; /* retains names marked "needs-count" */
|
||||
struct hashtab *opttab; /* table of configured options */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
%{
|
||||
/* $NetBSD: gram.y,v 1.40 2003/01/23 15:05:45 gehenna Exp $ */
|
||||
/* $NetBSD: gram.y,v 1.41 2003/01/27 05:00:54 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -289,7 +289,8 @@ one_def:
|
|||
{ defdevattach($5, $2, $4, $6); } |
|
||||
MAXPARTITIONS NUMBER { maxpartitions = $2; } |
|
||||
MAXUSERS NUMBER NUMBER NUMBER { setdefmaxusers($2, $3, $4); } |
|
||||
DEFPSEUDO devbase attrs_opt { defdev($2, NULL, $3, 1); } |
|
||||
DEFPSEUDO devbase interface_opt attrs_opt
|
||||
{ defdev($2, $3, $4, 1); } |
|
||||
MAJOR '{' majorlist '}';
|
||||
|
||||
atlist:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: main.c,v 1.74 2002/10/11 02:02:24 thorpej Exp $ */
|
||||
/* $NetBSD: main.c,v 1.75 2003/01/27 05:00:54 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -206,6 +206,7 @@ main(int argc, char **argv)
|
|||
ident = NULL;
|
||||
devbasetab = ht_new();
|
||||
devatab = ht_new();
|
||||
devitab = ht_new();
|
||||
selecttab = ht_new();
|
||||
needcnttab = ht_new();
|
||||
opttab = ht_new();
|
||||
|
@ -886,6 +887,29 @@ devbase_has_instances(struct devbase *dev, int unit)
|
|||
{
|
||||
struct deva *da;
|
||||
|
||||
/*
|
||||
* Pseudo-devices are a little special. We consider them
|
||||
* to have instances only if they are both:
|
||||
*
|
||||
* 1. Included in this kernel configuration.
|
||||
*
|
||||
* 2. Have one or more interface attributes.
|
||||
*/
|
||||
if (dev->d_ispseudo) {
|
||||
struct nvlist *nv;
|
||||
struct attr *a;
|
||||
|
||||
if (ht_lookup(devitab, dev->d_name) == NULL)
|
||||
return (0);
|
||||
|
||||
for (nv = dev->d_attrs; nv != NULL; nv = nv->nv_next) {
|
||||
a = nv->nv_ptr;
|
||||
if (a->a_iattr)
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
for (da = dev->d_ahead; da != NULL; da = da->d_bsame)
|
||||
if (deva_has_instances(da, unit))
|
||||
return (1);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sem.c,v 1.36 2003/01/23 15:05:46 gehenna Exp $ */
|
||||
/* $NetBSD: sem.c,v 1.37 2003/01/27 05:00:55 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -63,7 +63,7 @@ const char *s_qmark;
|
|||
const char *s_none;
|
||||
|
||||
static struct hashtab *cfhashtab; /* for config lookup */
|
||||
static struct hashtab *devitab; /* etc */
|
||||
struct hashtab *devitab; /* etc */
|
||||
|
||||
static struct attr errattr;
|
||||
static struct devbase errdev;
|
||||
|
@ -104,7 +104,6 @@ initsem(void)
|
|||
cfhashtab = ht_new();
|
||||
TAILQ_INIT(&allcf);
|
||||
|
||||
devitab = ht_new();
|
||||
TAILQ_INIT(&alldevi);
|
||||
errdev.d_name = "<internal>";
|
||||
|
||||
|
|
Loading…
Reference in New Issue