For the simple cases, augment device-major with information on how

a driver expects /dev/node -> minor mappings to go and include that
information in devsw_conv.
(no, I didn't plow through all the MD majors files)
This commit is contained in:
pooka 2010-04-30 20:47:17 +00:00
parent a6795f6ae1
commit 3da3ab250b
10 changed files with 113 additions and 44 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: majors.i386,v 1.39 2010/03/06 23:45:39 plunky Exp $
# $NetBSD: majors.i386,v 1.40 2010/04/30 20:47:17 pooka Exp $
#
# Device majors for i386
#
@ -6,7 +6,7 @@
device-major cons char 0
device-major ctty char 1
device-major mem char 2
device-major wd char 3 block 0 wd
device-major wd char 3 block 0 wd vector=8:8
device-major swap char 4 block 1 vmswap
device-major pts char 5 pty
device-major ptc char 6 pty
@ -26,7 +26,7 @@ device-major ss char 19 ss
device-major uk char 20 uk
device-major apm char 21 apm
device-major filedesc char 22
device-major bpf char 23 bpfilter
device-major bpf char 23 bpfilter vector=8,linkzero
device-major md char 24 block 17 md
device-major joy char 26 joy

View File

@ -1,7 +1,7 @@
# $NetBSD: files,v 1.988 2010/04/16 13:44:49 pooka Exp $
# $NetBSD: files,v 1.989 2010/04/30 20:47:17 pooka Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
version 20090313
version 20100430
#
# device classes

View File

@ -1,4 +1,4 @@
# $NetBSD: majors,v 1.50 2010/04/30 20:28:13 pooka Exp $
# $NetBSD: majors,v 1.51 2010/04/30 20:47:17 pooka Exp $
#
# Device majors for Machine-Independent drivers.
#
@ -9,37 +9,37 @@
#
# Majors 160-255 are used for the MI drivers.
device-major crypto char 160 crypto
device-major pf char 161 pf
device-major crypto char 160 crypto single
device-major pf char 161 pf single
#obsolete vinum char 162 vinum
device-major fss char 163 block 163 fss
device-major fss char 163 block 163 fss vector=4
device-major pps char 164 pps
device-major ptm char 165 pty
device-major atabus char 166 atabus
device-major drvctl char 167 drvctl
device-major atabus char 166 atabus vector=4
device-major drvctl char 167 drvctl single
device-major dk char 168 block 168
device-major tap char 169 tap
device-major tap char 169 tap vector=4
device-major veriexec char 170 veriexec
device-major fw char 171 ieee1394if
device-major ucycom char 172 ucycom
device-major gpio char 173 gpio
device-major utoppy char 174 utoppy
device-major bthub char 175 bthub
device-major amr char 176 amr
device-major lockstat char 177 lockstat
device-major gpio char 173 gpio vector=8,linkzero
device-major utoppy char 174 utoppy vector=2
device-major bthub char 175 bthub single
device-major amr char 176 amr vector=1
device-major lockstat char 177 lockstat single
device-major putter char 178 putter
device-major srt char 179 srt
device-major srt char 179 srt
device-major drm char 180 drmbase
device-major bio char 181 bio
device-major altmem char 182 block 182 altmem
device-major bio char 181 bio single
device-major altmem char 182 block 182 altmem
device-major twa char 187 twa
device-major cpuctl char 188
device-major pad char 189 pad
device-major cpuctl char 188 single
device-major pad char 189 pad vector=4,linkzero
device-major zfs char 190 block 190 zfs
device-major tprof char 191 tprof
device-major isv char 192 isv
device-major video char 193 video
device-major video char 193 video vector=4
device-major dm char 194 block 169 dm
device-major hdaudio char 195 hdaudio
device-major hdaudio char 195 hdaudio vector=4
device-major uhso char 196 uhso
device-major rumpblk char 197 block 197 rumpblk

View File

@ -1,4 +1,4 @@
/* $NetBSD: conf.h,v 1.136 2010/04/29 12:32:48 pooka Exp $ */
/* $NetBSD: conf.h,v 1.137 2010/04/30 20:47:17 pooka Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -228,10 +228,22 @@ int seltrue_kqfilter(dev_t, struct knote *);
#endif
#define DEV_ZERO 12 /* minor device 12 is '\0'/rathole */
enum devnode_class {
DEVNODE_DONTBOTHER,
DEVNODE_SINGLE,
DEVNODE_VECTOR
};
#define DEVNODE_FLAG_LINKZERO 0x01 /* create name -> name0 link */
struct devsw_conv {
const char *d_name;
devmajor_t d_bmajor;
devmajor_t d_cmajor;
/* information about /dev nodes related to the device */
enum devnode_class d_class;
int d_flags;
int d_vectdim[2];
};
void devsw_init(void);

View File

@ -1,4 +1,4 @@
/* $NetBSD: defs.h,v 1.34 2010/03/22 14:40:54 pooka Exp $ */
/* $NetBSD: defs.h,v 1.35 2010/04/30 20:47:18 pooka Exp $ */
/*
* Copyright (c) 1992, 1993
@ -104,7 +104,7 @@ extern const char *progname;
* The next two lines define the current version of the config(1) binary,
* and the minimum version of the configuration files it supports.
*/
#define CONFIG_VERSION 20090313
#define CONFIG_VERSION 20100430
#define CONFIG_MINVERSION 0
/*
@ -371,6 +371,7 @@ struct devm {
devmajor_t dm_cmajor; /* character major */
devmajor_t dm_bmajor; /* block major */
struct nvlist *dm_opts; /* options */
struct nvlist *dm_devnodes; /* information on /dev nodes */
};
/*

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: gram.y,v 1.23 2010/03/08 11:12:32 pooka Exp $ */
/* $NetBSD: gram.y,v 1.24 2010/04/30 20:47:18 pooka Exp $ */
/*
* Copyright (c) 1992, 1993
@ -73,6 +73,7 @@ static int adepth;
#define new_px(p, x) new0(NULL, NULL, p, 0, x)
#define new_sx(s, x) new0(NULL, s, NULL, 0, x)
#define new_nsx(n,s,x) new0(n, s, NULL, 0, x)
#define new_i(i) new0(NULL, NULL, NULL, i, NULL)
#define fx_atom(s) new0(s, NULL, NULL, FX_ATOM, NULL)
#define fx_not(e) new0(NULL, NULL, NULL, FX_NOT, e)
@ -108,14 +109,15 @@ static struct nvlist *mk_ns(const char *, struct nvlist *);
%token ENDFILE
%token XFILE FILE_SYSTEM FLAGS
%token IDENT IOCONF
%token LINKZERO
%token XMACHINE MAJOR MAKEOPTIONS MAXUSERS MAXPARTITIONS MINOR
%token NEEDS_COUNT NEEDS_FLAG NO
%token XOBJECT OBSOLETE ON OPTIONS
%token PACKAGE PLUSEQ PREFIX PSEUDO_DEVICE PSEUDO_ROOT
%token ROOT
%token SOURCE
%token SINGLE SOURCE
%token TYPE
%token VERSION
%token VECTOR VERSION
%token WITH
%token <num> NUMBER
%token <str> PATHNAME QSTRING WORD EMPTYSTRING
@ -156,6 +158,7 @@ static struct nvlist *mk_ns(const char *, struct nvlist *);
%type <list> subarches_opt subarches
%type <str> filename stringvalue locname mkvarname
%type <val> device_major_block device_major_char
%type <list> devnodes devnodetype devnodeflags devnode_dims
%%
@ -208,8 +211,8 @@ object:
XOBJECT filename fopts oflgs { addobject($2, $3, $4); };
device_major:
DEVICE_MAJOR WORD device_major_char device_major_block fopts
{ adddevm($2, $3, $4, $5); };
DEVICE_MAJOR WORD device_major_char device_major_block fopts devnodes
{ adddevm($2, $3, $4, $5, $6); };
device_major_block:
BLOCK NUMBER { $$ = $2.val; } |
@ -242,6 +245,25 @@ fflag:
NEEDS_COUNT { $$ = FI_NEEDSCOUNT; } |
NEEDS_FLAG { $$ = FI_NEEDSFLAG; };
devnodes:
devnodetype ',' devnodeflags { $$ = nvcat($1, $3); } |
devnodetype { $$ = $1; } |
/* empty */ { $$ = new_s("DEVNODE_DONTBOTHER"); };
devnodetype:
SINGLE { $$ = new_s("DEVNODE_SINGLE"); } |
VECTOR '=' devnode_dims { $$ = nvcat(new_s("DEVNODE_VECTOR"), $3); };
devnode_dims:
NUMBER ':' NUMBER { struct nvlist *__nv1, *__nv2;
__nv1 = new_i($1.val);
__nv2 = new_i($3.val);
$$ = nvcat(__nv1, __nv2); } |
NUMBER { $$ = new_i($1.val); }
devnodeflags:
LINKZERO { $$ = new_s("DEVNODE_FLAG_LINKZERO");};
oflgs:
oflgs oflag { $$ = $1 | $2; } |
/* empty */ { $$ = 0; };

View File

@ -1,4 +1,4 @@
/* $NetBSD: mkdevsw.c,v 1.8 2010/04/15 12:35:57 pooka Exp $ */
/* $NetBSD: mkdevsw.c,v 1.9 2010/04/30 20:47:18 pooka Exp $ */
/*
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -162,8 +162,34 @@ emitconv(FILE *fp)
fputs("\n/* device conversion table */\n"
"struct devsw_conv devsw_conv0[] = {\n", fp);
TAILQ_FOREACH(dm, &alldevms, dm_next) {
fprintf(fp, "\t{ \"%s\", %d, %d },\n", dm->dm_name,
dm->dm_bmajor, dm->dm_cmajor);
struct nvlist *nv;
const char *d_class, *d_flags = "0";
int d_vec[2] = { 0, 0 };
int i = 0;
/*
* "parse" info. currently the rules are simple:
* 1) first entry defines class
* 2) next ones without n_str are d_vectdim
* 3) next one with n_str is d_flags
* 4) EOL
*/
nv = dm->dm_devnodes;
d_class = nv->nv_str;
while ((nv = nv->nv_next) != NULL) {
if (i > 2)
panic("invalid devnode definition");
if (nv->nv_str) {
d_flags = nv->nv_str;
break;
}
d_vec[i++] = nv->nv_num;
}
fprintf(fp, "\t{ \"%s\", %d, %d, %s, %s, { %d, %d }},\n",
dm->dm_name, dm->dm_bmajor, dm->dm_cmajor,
d_class, d_flags, d_vec[0], d_vec[1]);
}
fputs("};\n\n"
"struct devsw_conv *devsw_conv = devsw_conv0;\n"

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: scan.l,v 1.15 2010/03/08 10:19:14 pooka Exp $ */
/* $NetBSD: scan.l,v 1.16 2010/04/30 20:47:18 pooka Exp $ */
/*
* Copyright (c) 1992, 1993
@ -146,6 +146,7 @@ file-system return FILE_SYSTEM;
flags return FLAGS;
ident return IDENT;
ioconf return IOCONF;
linkzero return LINKZERO;
machine return XMACHINE;
major return MAJOR;
makeoptions return MAKEOPTIONS;
@ -163,8 +164,10 @@ prefix return PREFIX;
pseudo-device return PSEUDO_DEVICE;
pseudo-root return PSEUDO_ROOT;
root return ROOT;
single return SINGLE;
source return SOURCE;
type return TYPE;
vector return VECTOR;
version return VERSION;
with return WITH;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sem.c,v 1.34 2010/03/08 10:19:15 pooka Exp $ */
/* $NetBSD: sem.c,v 1.35 2010/04/30 20:47:18 pooka Exp $ */
/*
* Copyright (c) 1992, 1993
@ -1492,24 +1492,27 @@ delpseudo(const char *name)
void
adddevm(const char *name, devmajor_t cmajor, devmajor_t bmajor,
struct nvlist *nv)
struct nvlist *nv_opts, struct nvlist *nv_nodes)
{
struct devm *dm;
if (cmajor != NODEVMAJOR && (cmajor < 0 || cmajor >= 4096)) {
cfgerror("character major %d is invalid", cmajor);
nvfreel(nv);
nvfreel(nv_opts);
nvfreel(nv_nodes);
return;
}
if (bmajor != NODEVMAJOR && (bmajor < 0 || bmajor >= 4096)) {
cfgerror("block major %d is invalid", bmajor);
nvfreel(nv);
nvfreel(nv_opts);
nvfreel(nv_nodes);
return;
}
if (cmajor == NODEVMAJOR && bmajor == NODEVMAJOR) {
cfgerror("both character/block majors are not specified");
nvfreel(nv);
nvfreel(nv_opts);
nvfreel(nv_nodes);
return;
}
@ -1519,7 +1522,8 @@ adddevm(const char *name, devmajor_t cmajor, devmajor_t bmajor,
dm->dm_name = name;
dm->dm_cmajor = cmajor;
dm->dm_bmajor = bmajor;
dm->dm_opts = nv;
dm->dm_opts = nv_opts;
dm->dm_devnodes = nv_nodes;
TAILQ_INSERT_TAIL(&alldevms, dm, dm_next);

View File

@ -1,4 +1,4 @@
/* $NetBSD: sem.h,v 1.6 2010/03/08 10:19:15 pooka Exp $ */
/* $NetBSD: sem.h,v 1.7 2010/04/30 20:47:18 pooka Exp $ */
/*
* Copyright (c) 1992, 1993
@ -67,7 +67,8 @@ 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 *);
void adddevm(const char *, int, int,
struct nvlist *, struct nvlist *);
int fixdevis(void);
const char *ref(const char *);
const char *starref(const char *);