summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorpooka <pooka@NetBSD.org>2010-04-30 20:47:17 +0000
committerpooka <pooka@NetBSD.org>2010-04-30 20:47:17 +0000
commit3da3ab250bef7eb52cfb4e1afebb64108725bb15 (patch)
treea3c4febdbe39bc92b6b5667acda181190a178f9d /usr.bin
parenta6795f6ae1eb93ca46de19cb735a8fd07c78e940 (diff)
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)
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/config/defs.h5
-rw-r--r--usr.bin/config/gram.y32
-rw-r--r--usr.bin/config/mkdevsw.c32
-rw-r--r--usr.bin/config/scan.l5
-rw-r--r--usr.bin/config/sem.c16
-rw-r--r--usr.bin/config/sem.h5
6 files changed, 76 insertions, 19 deletions
diff --git a/usr.bin/config/defs.h b/usr.bin/config/defs.h
index cfe1197a93b..ef9e1e53b90 100644
--- a/usr.bin/config/defs.h
+++ b/usr.bin/config/defs.h
@@ -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 */
};
/*
diff --git a/usr.bin/config/gram.y b/usr.bin/config/gram.y
index fb13dbf3a45..4736dccdaaa 100644
--- a/usr.bin/config/gram.y
+++ b/usr.bin/config/gram.y
@@ -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; };
diff --git a/usr.bin/config/mkdevsw.c b/usr.bin/config/mkdevsw.c
index 0eb8e49cc68..598266d508f 100644
--- a/usr.bin/config/mkdevsw.c
+++ b/usr.bin/config/mkdevsw.c
@@ -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"
diff --git a/usr.bin/config/scan.l b/usr.bin/config/scan.l
index bdb394d198e..6198b5eaffb 100644
--- a/usr.bin/config/scan.l
+++ b/usr.bin/config/scan.l
@@ -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;
diff --git a/usr.bin/config/sem.c b/usr.bin/config/sem.c
index 48d9354f5d3..6aa82c1c5d4 100644
--- a/usr.bin/config/sem.c
+++ b/usr.bin/config/sem.c
@@ -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);
diff --git a/usr.bin/config/sem.h b/usr.bin/config/sem.h
index b9064b6f1c3..4c973926375 100644
--- a/usr.bin/config/sem.h
+++ b/usr.bin/config/sem.h
@@ -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 *);