Salvage pre-devsw config support so that one can config such as other

branch's kernel.
This commit is contained in:
enami 2002-09-11 06:20:09 +00:00
parent 822449ac65
commit 78948a7123
5 changed files with 82 additions and 23 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: defs.h,v 1.5 2002/09/06 13:18:43 gehenna Exp $ */
/* $NetBSD: defs.h,v 1.6 2002/09/11 06:20:09 enami Exp $ */
/*
* Copyright (c) 1992, 1993
@ -378,6 +378,7 @@ TAILQ_HEAD(, devm) alldevms; /* list of all device-majors */
int ndevi; /* number of devi's (before packing) */
int maxbdevm; /* max number of block major */
int maxcdevm; /* max number of character major */
int do_devsw; /* 0 if pre-devsw config */
TAILQ_HEAD(, files) allfiles; /* list of all kernel source files */
TAILQ_HEAD(, objects) allobjects; /* list of all kernel object and

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: gram.y,v 1.35 2002/09/06 13:18:43 gehenna Exp $ */
/* $NetBSD: gram.y,v 1.36 2002/09/11 06:20:09 enami Exp $ */
/*
* Copyright (c) 1992, 1993
@ -263,7 +263,7 @@ dev_def:
one_def:
file |
object |
device_major |
device_major { do_devsw = 1; } |
include |
prefix |
DEVCLASS WORD { (void)defattr($2, NULL, 1); } |

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.69 2002/09/06 13:18:43 gehenna Exp $ */
/* $NetBSD: main.c,v 1.70 2002/09/11 06:20:09 enami Exp $ */
/*
* Copyright (c) 1992, 1993
@ -311,7 +311,7 @@ main(int argc, char **argv)
* Ready to go. Build all the various files.
*/
if (mksymlinks() || mkmakefile() || mkheaders() || mkswap() ||
mkioconf() || mkdevsw() || mkident())
mkioconf() || (do_devsw ? mkdevsw() : 0) || mkident())
stop();
(void)printf("Don't forget to run \"make depend\"\n");
exit(0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: mkioconf.c,v 1.60 2002/09/06 13:18:43 gehenna Exp $ */
/* $NetBSD: mkioconf.c,v 1.61 2002/09/11 06:20:09 enami Exp $ */
/*
* Copyright (c) 1992, 1993
@ -65,6 +65,7 @@ static int emitpseudo(FILE *);
static int emitpv(FILE *);
static int emitroots(FILE *);
static int emitvfslist(FILE *);
static int emitname2blk(FILE *);
#define SEP(pos, max) (((u_int)(pos) % (max)) == 0 ? "\n\t" : " ")
@ -91,7 +92,7 @@ mkioconf(void)
v = emithdr(fp);
if (v != 0 || emitcfdrivers(fp) || emitexterns(fp) || emitloc(fp) ||
emitpv(fp) || emitcfdata(fp) || emitroots(fp) || emitpseudo(fp) ||
emitvfslist(fp)) {
emitvfslist(fp) || (do_devsw ? 0 : emitname2blk(fp))) {
if (v >= 0)
(void)fprintf(stderr,
"config: error writing ioconf.c: %s\n",
@ -444,3 +445,31 @@ emitvfslist(FILE *fp)
return (0);
}
/*
* Emit name to major block number table.
*/
int
emitname2blk(FILE *fp)
{
struct devbase *dev;
if (fputs("\n/* device name to major block number */\n", fp) < 0)
return (1);
if (fprintf(fp, "struct devnametobdevmaj dev_name2blk[] = {\n") < 0)
return (1);
TAILQ_FOREACH(dev, &allbases, d_next) {
if (dev->d_major == NODEV)
continue;
if (fprintf(fp, "\t{ \"%s\", %d },\n",
dev->d_name, dev->d_major) < 0)
return (1);
}
if (fprintf(fp, "\t{ NULL, 0 }\n};\n") < 0)
return (1);
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sem.c,v 1.31 2002/09/06 13:18:43 gehenna Exp $ */
/* $NetBSD: sem.c,v 1.32 2002/09/11 06:20:10 enami Exp $ */
/*
* Copyright (c) 1992, 1993
@ -82,6 +82,8 @@ static void selectbase(struct devbase *, struct deva *);
static int onlist(struct nvlist *, void *);
static const char **fixloc(const char *, struct attr *, struct nvlist *);
static const char *makedevstr(int, int);
static const char *major2name(int);
static int dev2major(struct devbase *);
extern const char *yyfile;
@ -549,23 +551,55 @@ setmajor(struct devbase *d, int n)
d->d_major = n;
}
const char *
major2name(int maj)
{
struct devbase *dev;
struct devm *dm;
if (!do_devsw) {
TAILQ_FOREACH(dev, &allbases, d_next) {
if (dev->d_major == maj)
return (dev->d_name);
}
} else {
TAILQ_FOREACH(dm, &alldevms, dm_next) {
if (dm->dm_bmajor == maj)
return (dm->dm_name);
}
}
return (NULL);
}
int
dev2major(struct devbase *dev)
{
struct devm *dm;
if (!do_devsw)
return (dev->d_major);
TAILQ_FOREACH(dm, &alldevms, dm_next) {
if (strcmp(dm->dm_name, dev->d_name) == 0)
return (dm->dm_bmajor);
}
return (NODEV);
}
/*
* Make a string description of the device at maj/min.
*/
static const char *
makedevstr(int maj, int min)
{
struct devm *dm;
const char *devname;
char buf[32];
TAILQ_FOREACH(dm, &alldevms, dm_next) {
if (dm->dm_bmajor == maj)
break;
}
if (dm == NULL)
devname = major2name(maj);
if (devname == NULL)
(void)sprintf(buf, "<%d/%d>", maj, min);
else
(void)sprintf(buf, "%s%d%c", dm->dm_name,
(void)sprintf(buf, "%s%d%c", devname,
min / maxpartitions, (min % maxpartitions) + 'a');
return (intern(buf));
@ -582,7 +616,6 @@ resolve(struct nvlist **nvp, const char *name, const char *what,
{
struct nvlist *nv;
struct devbase *dev;
struct devm *dm;
const char *cp;
int maj, min, i, l;
int unit;
@ -654,17 +687,13 @@ resolve(struct nvlist **nvp, const char *name, const char *what,
nv->nv_int = NODEV;
nv->nv_ifunit = unit; /* XXX XXX XXX */
} else {
TAILQ_FOREACH(dm, &alldevms, dm_next) {
if (strcmp(dm->dm_name, dev->d_name) == 0)
break;
}
if (dm == NULL) {
maj = dev2major(dev);
if (maj == NODEV) {
error("%s: can't make %s device from `%s'",
name, what, nv->nv_str);
return (1);
}
nv->nv_int =
makedev(dm->dm_bmajor, unit * maxpartitions + part);
nv->nv_int = makedev(maj, unit * maxpartitions + part);
}
nv->nv_name = dev->d_name;