| @@ -1,775 +1,908 @@ | | | @@ -1,775 +1,908 @@ |
1 | %{ | | 1 | %{ |
2 | /* $NetBSD: gram.y,v 1.24 2010/04/30 20:47:18 pooka Exp $ */ | | 2 | /* $NetBSD: gram.y,v 1.25 2012/03/11 00:14:20 dholland Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (c) 1992, 1993 | | 5 | * Copyright (c) 1992, 1993 |
6 | * The Regents of the University of California. All rights reserved. | | 6 | * The Regents of the University of California. All rights reserved. |
7 | * | | 7 | * |
8 | * This software was developed by the Computer Systems Engineering group | | 8 | * This software was developed by the Computer Systems Engineering group |
9 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | | 9 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and |
10 | * contributed to Berkeley. | | 10 | * contributed to Berkeley. |
11 | * | | 11 | * |
12 | * All advertising materials mentioning features or use of this software | | 12 | * All advertising materials mentioning features or use of this software |
13 | * must display the following acknowledgement: | | 13 | * must display the following acknowledgement: |
14 | * This product includes software developed by the University of | | 14 | * This product includes software developed by the University of |
15 | * California, Lawrence Berkeley Laboratories. | | 15 | * California, Lawrence Berkeley Laboratories. |
16 | * | | 16 | * |
17 | * Redistribution and use in source and binary forms, with or without | | 17 | * Redistribution and use in source and binary forms, with or without |
18 | * modification, are permitted provided that the following conditions | | 18 | * modification, are permitted provided that the following conditions |
19 | * are met: | | 19 | * are met: |
20 | * 1. Redistributions of source code must retain the above copyright | | 20 | * 1. Redistributions of source code must retain the above copyright |
21 | * notice, this list of conditions and the following disclaimer. | | 21 | * notice, this list of conditions and the following disclaimer. |
22 | * 2. Redistributions in binary form must reproduce the above copyright | | 22 | * 2. Redistributions in binary form must reproduce the above copyright |
23 | * notice, this list of conditions and the following disclaimer in the | | 23 | * notice, this list of conditions and the following disclaimer in the |
24 | * documentation and/or other materials provided with the distribution. | | 24 | * documentation and/or other materials provided with the distribution. |
25 | * 3. Neither the name of the University nor the names of its contributors | | 25 | * 3. Neither the name of the University nor the names of its contributors |
26 | * may be used to endorse or promote products derived from this software | | 26 | * may be used to endorse or promote products derived from this software |
27 | * without specific prior written permission. | | 27 | * without specific prior written permission. |
28 | * | | 28 | * |
29 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 29 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
30 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 30 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
31 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 31 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
33 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 33 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
34 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 34 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
35 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 35 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
36 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 36 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
37 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 37 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
38 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 38 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
39 | * SUCH DAMAGE. | | 39 | * SUCH DAMAGE. |
40 | * | | 40 | * |
41 | * from: @(#)gram.y 8.1 (Berkeley) 6/6/93 | | 41 | * from: @(#)gram.y 8.1 (Berkeley) 6/6/93 |
42 | */ | | 42 | */ |
43 | | | 43 | |
44 | #include <sys/types.h> | | 44 | #include <sys/types.h> |
45 | #include <sys/param.h> | | 45 | #include <sys/param.h> |
46 | #include <ctype.h> | | 46 | #include <ctype.h> |
47 | #include <stdio.h> | | 47 | #include <stdio.h> |
48 | #include <stdlib.h> | | 48 | #include <stdlib.h> |
49 | #include <string.h> | | 49 | #include <string.h> |
50 | #include <errno.h> | | 50 | #include <errno.h> |
51 | #include "defs.h" | | 51 | #include "defs.h" |
52 | #include "sem.h" | | 52 | #include "sem.h" |
53 | | | 53 | |
54 | #define FORMAT(n) (((n).fmt == 8 && (n).val != 0) ? "0%llo" : \ | | 54 | #define FORMAT(n) (((n).fmt == 8 && (n).val != 0) ? "0%llo" : \ |
55 | ((n).fmt == 16) ? "0x%llx" : "%lld") | | 55 | ((n).fmt == 16) ? "0x%llx" : "%lld") |
56 | | | 56 | |
57 | #define stop(s) cfgerror(s), exit(1) | | 57 | #define stop(s) cfgerror(s), exit(1) |
58 | | | 58 | |
59 | static struct config conf; /* at most one active at a time */ | | 59 | static struct config conf; /* at most one active at a time */ |
60 | | | 60 | |
61 | /* the following is used to recover nvlist space after errors */ | | 61 | /* the following is used to recover nvlist space after errors */ |
62 | static struct nvlist *alloc[1000]; | | 62 | static struct nvlist *alloc[1000]; |
63 | static int adepth; | | 63 | static int adepth; |
64 | #define new0(n,s,p,i,x) (alloc[adepth++] = newnv(n, s, p, i, x)) | | 64 | #define new0(n,s,p,i,x) (alloc[adepth++] = newnv(n, s, p, i, x)) |
65 | #define new_n(n) new0(n, NULL, NULL, 0, NULL) | | 65 | #define new_n(n) new0(n, NULL, NULL, 0, NULL) |
66 | #define new_nx(n, x) new0(n, NULL, NULL, 0, x) | | 66 | #define new_nx(n, x) new0(n, NULL, NULL, 0, x) |
67 | #define new_ns(n, s) new0(n, s, NULL, 0, NULL) | | 67 | #define new_ns(n, s) new0(n, s, NULL, 0, NULL) |
68 | #define new_si(s, i) new0(NULL, s, NULL, i, NULL) | | 68 | #define new_si(s, i) new0(NULL, s, NULL, i, NULL) |
69 | #define new_nsi(n,s,i) new0(n, s, NULL, i, NULL) | | 69 | #define new_nsi(n,s,i) new0(n, s, NULL, i, NULL) |
70 | #define new_np(n, p) new0(n, NULL, p, 0, NULL) | | 70 | #define new_np(n, p) new0(n, NULL, p, 0, NULL) |
71 | #define new_s(s) new0(NULL, s, NULL, 0, NULL) | | 71 | #define new_s(s) new0(NULL, s, NULL, 0, NULL) |
72 | #define new_p(p) new0(NULL, NULL, p, 0, NULL) | | 72 | #define new_p(p) new0(NULL, NULL, p, 0, NULL) |
73 | #define new_px(p, x) new0(NULL, NULL, p, 0, x) | | 73 | #define new_px(p, x) new0(NULL, NULL, p, 0, x) |
74 | #define new_sx(s, x) new0(NULL, s, NULL, 0, x) | | 74 | #define new_sx(s, x) new0(NULL, s, NULL, 0, x) |
75 | #define new_nsx(n,s,x) new0(n, s, NULL, 0, x) | | 75 | #define new_nsx(n,s,x) new0(n, s, NULL, 0, x) |
76 | #define new_i(i) new0(NULL, NULL, NULL, i, NULL) | | 76 | #define new_i(i) new0(NULL, NULL, NULL, i, NULL) |
77 | | | 77 | |
78 | #define fx_atom(s) new0(s, NULL, NULL, FX_ATOM, NULL) | | 78 | #define fx_atom(s) new0(s, NULL, NULL, FX_ATOM, NULL) |
79 | #define fx_not(e) new0(NULL, NULL, NULL, FX_NOT, e) | | 79 | #define fx_not(e) new0(NULL, NULL, NULL, FX_NOT, e) |
80 | #define fx_and(e1, e2) new0(NULL, NULL, e1, FX_AND, e2) | | 80 | #define fx_and(e1, e2) new0(NULL, NULL, e1, FX_AND, e2) |
81 | #define fx_or(e1, e2) new0(NULL, NULL, e1, FX_OR, e2) | | 81 | #define fx_or(e1, e2) new0(NULL, NULL, e1, FX_OR, e2) |
82 | | | 82 | |
83 | static void cleanup(void); | | 83 | static void cleanup(void); |
84 | static void setmachine(const char *, const char *, struct nvlist *, int); | | 84 | static void setmachine(const char *, const char *, struct nvlist *, int); |
85 | static void check_maxpart(void); | | 85 | static void check_maxpart(void); |
86 | | | 86 | |
87 | static void app(struct nvlist *, struct nvlist *); | | 87 | static void app(struct nvlist *, struct nvlist *); |
88 | | | 88 | |
89 | static struct nvlist *mk_nsis(const char *, int, struct nvlist *, int); | | 89 | static struct nvlist *mk_nsis(const char *, int, struct nvlist *, int); |
90 | static struct nvlist *mk_ns(const char *, struct nvlist *); | | 90 | static struct nvlist *mk_ns(const char *, struct nvlist *); |
91 | | | 91 | |
92 | %} | | 92 | %} |
93 | | | 93 | |
94 | %union { | | 94 | %union { |
95 | struct attr *attr; | | 95 | struct attr *attr; |
96 | struct devbase *devb; | | 96 | struct devbase *devb; |
97 | struct deva *deva; | | 97 | struct deva *deva; |
98 | struct nvlist *list; | | 98 | struct nvlist *list; |
99 | const char *str; | | 99 | const char *str; |
100 | struct numconst num; | | 100 | struct numconst num; |
101 | int64_t val; | | 101 | int64_t val; |
102 | } | | 102 | } |
103 | | | 103 | |
104 | %token AND AT ATTACH | | 104 | %token AND AT ATTACH |
105 | %token BLOCK BUILD | | 105 | %token BLOCK BUILD |
106 | %token CHAR COLONEQ COMPILE_WITH CONFIG | | 106 | %token CHAR COLONEQ COMPILE_WITH CONFIG |
107 | %token DEFFS DEFINE DEFOPT DEFPARAM DEFFLAG DEFPSEUDO DEFPSEUDODEV | | 107 | %token DEFFS DEFINE DEFOPT DEFPARAM DEFFLAG DEFPSEUDO DEFPSEUDODEV |
108 | %token DEVICE DEVCLASS DUMPS DEVICE_MAJOR | | 108 | %token DEVICE DEVCLASS DUMPS DEVICE_MAJOR |
109 | %token ENDFILE | | 109 | %token ENDFILE |
110 | %token XFILE FILE_SYSTEM FLAGS | | 110 | %token XFILE FILE_SYSTEM FLAGS |
111 | %token IDENT IOCONF | | 111 | %token IDENT IOCONF |
112 | %token LINKZERO | | 112 | %token LINKZERO |
113 | %token XMACHINE MAJOR MAKEOPTIONS MAXUSERS MAXPARTITIONS MINOR | | 113 | %token XMACHINE MAJOR MAKEOPTIONS MAXUSERS MAXPARTITIONS MINOR |
114 | %token NEEDS_COUNT NEEDS_FLAG NO | | 114 | %token NEEDS_COUNT NEEDS_FLAG NO |
115 | %token XOBJECT OBSOLETE ON OPTIONS | | 115 | %token XOBJECT OBSOLETE ON OPTIONS |
116 | %token PACKAGE PLUSEQ PREFIX PSEUDO_DEVICE PSEUDO_ROOT | | 116 | %token PACKAGE PLUSEQ PREFIX PSEUDO_DEVICE PSEUDO_ROOT |
117 | %token ROOT | | 117 | %token ROOT |
118 | %token SINGLE SOURCE | | 118 | %token SINGLE SOURCE |
119 | %token TYPE | | 119 | %token TYPE |
120 | %token VECTOR VERSION | | 120 | %token VECTOR VERSION |
121 | %token WITH | | 121 | %token WITH |
122 | %token <num> NUMBER | | 122 | %token <num> NUMBER |
123 | %token <str> PATHNAME QSTRING WORD EMPTYSTRING | | 123 | %token <str> PATHNAME QSTRING WORD EMPTYSTRING |
124 | %token ENDDEFS | | 124 | %token ENDDEFS |
125 | | | 125 | |
126 | %left '|' | | 126 | %left '|' |
127 | %left '&' | | 127 | %left '&' |
128 | | | 128 | |
129 | %type <list> fopts fexpr fatom | | 129 | %type <list> fopts fexpr fatom |
130 | %type <str> fs_spec | | 130 | %type <str> fs_spec |
131 | %type <val> fflgs fflag oflgs oflag | | 131 | %type <val> fflgs fflag oflgs oflag |
132 | %type <str> rule | | 132 | %type <str> rule |
133 | %type <attr> attr | | 133 | %type <attr> attr |
134 | %type <devb> devbase | | 134 | %type <devb> devbase |
135 | %type <deva> devattach_opt | | 135 | %type <deva> devattach_opt |
136 | %type <list> atlist interface_opt | | 136 | %type <list> atlist interface_opt |
137 | %type <str> atname | | 137 | %type <str> atname |
138 | %type <list> loclist_opt loclist locdef | | 138 | %type <list> loclist_opt loclist locdef |
139 | %type <str> locdefault | | 139 | %type <str> locdefault |
140 | %type <list> values locdefaults | | 140 | %type <list> values locdefaults |
141 | %type <list> attrs_opt attrs | | 141 | %type <list> attrs_opt attrs |
142 | %type <list> locators locator | | 142 | %type <list> locators locator |
143 | %type <list> dev_spec | | 143 | %type <list> dev_spec |
144 | %type <str> device_instance | | 144 | %type <str> device_instance |
145 | %type <str> attachment | | 145 | %type <str> attachment |
146 | %type <str> value | | 146 | %type <str> value |
147 | %type <val> major_minor npseudo | | 147 | %type <val> major_minor npseudo |
148 | %type <num> signed_number | | 148 | %type <num> signed_number |
149 | %type <val> flags_opt | | 149 | %type <val> flags_opt |
150 | %type <str> deffs | | 150 | %type <str> deffs |
151 | %type <list> deffses | | 151 | %type <list> deffses |
152 | %type <list> defopt | | 152 | %type <list> defopt |
153 | %type <list> defopts | | 153 | %type <list> defopts |
154 | %type <str> optdep | | 154 | %type <str> optdep |
155 | %type <list> optdeps | | 155 | %type <list> optdeps |
156 | %type <list> defoptdeps | | 156 | %type <list> defoptdeps |
157 | %type <str> optfile_opt | | 157 | %type <str> optfile_opt |
158 | %type <list> subarches_opt subarches | | 158 | %type <list> subarches_opt subarches |
159 | %type <str> filename stringvalue locname mkvarname | | 159 | %type <str> filename stringvalue locname mkvarname |
160 | %type <val> device_major_block device_major_char | | 160 | %type <val> device_major_block device_major_char |
161 | %type <list> devnodes devnodetype devnodeflags devnode_dims | | 161 | %type <list> devnodes devnodetype devnodeflags devnode_dims |
162 | | | 162 | |
163 | %% | | 163 | %% |
164 | | | 164 | |
165 | /* | | 165 | /* |
166 | * A configuration consists of a machine type, followed by the machine | | 166 | * A complete configuration consists of both the configuration part (a |
167 | * definition files (via the include() mechanism), followed by the | | 167 | * kernel config such as GENERIC or SKYNET, plus also the various |
168 | * configuration specification(s) proper. In effect, this is two | | 168 | * std.* files), which selects the material to be in the kernel, and |
169 | * separate grammars, with some shared terminals and nonterminals. | | 169 | * also the definition part (files, files.*, etc.) that declares what |
170 | * Note that we do not have sufficient keywords to enforce any order | | 170 | * material is available to be placed in kernels. |
171 | * between elements of "topthings" without introducing shift/reduce | | 171 | * |
172 | * conflicts. Instead, check order requirements in the C code. | | 172 | * The two parts have almost entirely separate syntaxes. This grammar |
| | | 173 | * covers both of them. When config is run on a kernel configuration |
| | | 174 | * file, the std.* file for the port is included explicitly. The |
| | | 175 | * files.* files are included implicitly when the std.* file declares |
| | | 176 | * the machine type. |
| | | 177 | * |
| | | 178 | * The machine spec, which brings in the definition part, must appear |
| | | 179 | * before all configuration material except for the "topthings"; these |
| | | 180 | * are the "source" and "build" declarations that tell config where |
| | | 181 | * things are. These are not used by default. |
| | | 182 | * |
| | | 183 | * A previous version of this comment contained the following text: |
| | | 184 | * |
| | | 185 | * Note that we do not have sufficient keywords to enforce any |
| | | 186 | * order between elements of "topthings" without introducing |
| | | 187 | * shift/reduce conflicts. Instead, check order requirements in |
| | | 188 | * the C code. |
| | | 189 | * |
| | | 190 | * As of March 2012 this comment makes no sense, as there are only two |
| | | 191 | * topthings and no reason for them to be forcibly ordered. |
| | | 192 | * Furthermore, the statement about conflicts is false. |
173 | */ | | 193 | */ |
| | | 194 | |
| | | 195 | /* Complete configuration. */ |
174 | Configuration: | | 196 | Configuration: |
175 | topthings /* dirspecs, include "std.arch" */ | | 197 | topthings |
176 | machine_spec /* "machine foo" from machine descr. */ | | 198 | machine_spec |
177 | dev_defs ENDDEFS /* all machine definition files */ | | 199 | dev_defs ENDDEFS |
178 | { check_maxpart(); check_version(); } | | 200 | { check_maxpart(); check_version(); } |
179 | specs; /* rest of machine description */ | | 201 | specs; |
180 | | | 202 | |
| | | 203 | /* Sequence of zero or more topthings. */ |
181 | topthings: | | 204 | topthings: |
182 | topthings topthing | | | 205 | topthings topthing | |
183 | /* empty */; | | 206 | /* empty */; |
184 | | | 207 | |
| | | 208 | /* Directory specification. */ |
185 | topthing: | | 209 | topthing: |
186 | SOURCE filename '\n' { if (!srcdir) srcdir = $2; } | | | 210 | SOURCE filename '\n' { if (!srcdir) srcdir = $2; } | |
187 | BUILD filename '\n' { if (!builddir) builddir = $2; } | | | 211 | BUILD filename '\n' { if (!builddir) builddir = $2; } | |
188 | '\n'; | | 212 | '\n'; |
189 | | | 213 | |
| | | 214 | /* "machine foo" from std.whatever */ |
190 | machine_spec: | | 215 | machine_spec: |
191 | XMACHINE WORD '\n' { setmachine($2,NULL,NULL,0); } | | | 216 | XMACHINE WORD '\n' { setmachine($2,NULL,NULL,0); } | |
192 | XMACHINE WORD WORD subarches_opt '\n' { setmachine($2,$3,$4,0); } | | | 217 | XMACHINE WORD WORD subarches_opt '\n' { setmachine($2,$3,$4,0); } | |
193 | IOCONF WORD '\n' { setmachine($2,NULL,NULL,1); } | | | 218 | IOCONF WORD '\n' { setmachine($2,NULL,NULL,1); } | |
194 | error { stop("cannot proceed without machine or ioconf specifier"); }; | | 219 | error { stop("cannot proceed without machine or ioconf specifier"); }; |
195 | | | 220 | |
| | | 221 | /* Optional subarches. */ |
196 | subarches_opt: | | 222 | subarches_opt: |
197 | subarches | | | 223 | subarches | |
198 | /* empty */ { $$ = NULL; }; | | 224 | /* empty */ { $$ = NULL; }; |
199 | | | 225 | |
| | | 226 | /* Subarches declaration. */ |
200 | subarches: | | 227 | subarches: |
201 | subarches WORD { $$ = new_nx($2, $1); } | | | 228 | subarches WORD { $$ = new_nx($2, $1); } | |
202 | WORD { $$ = new_n($1); }; | | 229 | WORD { $$ = new_n($1); }; |
203 | | | 230 | |
| | | 231 | /************************************************************/ |
| | | 232 | |
204 | /* | | 233 | /* |
205 | * Various nonterminals shared between the grammars. | | 234 | * Various nonterminals shared between the grammars. |
| | | 235 | * (Note: that's a lie, pending some reorg) |
206 | */ | | 236 | */ |
| | | 237 | |
| | | 238 | /* source file: file foo/bar.c bar|baz needs-flag compile-with blah */ |
207 | file: | | 239 | file: |
208 | XFILE filename fopts fflgs rule { addfile($2, $3, $4, $5); }; | | 240 | XFILE filename fopts fflgs rule { addfile($2, $3, $4, $5); }; |
209 | | | 241 | |
| | | 242 | /* object file: object zot.o foo|zot needs-flag */ |
210 | object: | | 243 | object: |
211 | XOBJECT filename fopts oflgs { addobject($2, $3, $4); }; | | 244 | XOBJECT filename fopts oflgs { addobject($2, $3, $4); }; |
212 | | | 245 | |
| | | 246 | /* device major declaration */ |
213 | device_major: | | 247 | device_major: |
214 | DEVICE_MAJOR WORD device_major_char device_major_block fopts devnodes | | 248 | DEVICE_MAJOR WORD device_major_char device_major_block fopts devnodes |
215 | { adddevm($2, $3, $4, $5, $6); }; | | 249 | { adddevm($2, $3, $4, $5, $6); }; |
216 | | | 250 | /* block 33 */ |
217 | device_major_block: | | 251 | device_major_block: |
218 | BLOCK NUMBER { $$ = $2.val; } | | | 252 | BLOCK NUMBER { $$ = $2.val; } | |
219 | /* empty */ { $$ = -1; }; | | 253 | /* empty */ { $$ = -1; }; |
220 | | | 254 | |
| | | 255 | /* char 55 */ |
221 | device_major_char: | | 256 | device_major_char: |
222 | CHAR NUMBER { $$ = $2.val; } | | | 257 | CHAR NUMBER { $$ = $2.val; } | |
223 | /* empty */ { $$ = -1; }; | | 258 | /* empty */ { $$ = -1; }; |
224 | | | 259 | |
225 | /* order of options is important, must use right recursion */ | | 260 | /* |
| | | 261 | * order of options is important, must use right recursion |
| | | 262 | * |
| | | 263 | * dholland 20120310: wut? |
| | | 264 | */ |
| | | 265 | |
| | | 266 | /* file options: optional expression of config elements */ |
226 | fopts: | | 267 | fopts: |
227 | fexpr { $$ = $1; } | | | 268 | fexpr { $$ = $1; } | |
228 | /* empty */ { $$ = NULL; }; | | 269 | /* empty */ { $$ = NULL; }; |
229 | | | 270 | |
| | | 271 | /* expression of config elements */ |
| | | 272 | /* XXX this should use a real expression grammar */ |
230 | fexpr: | | 273 | fexpr: |
231 | fatom { $$ = $1; } | | | 274 | fatom { $$ = $1; } | |
232 | '!' fatom { $$ = fx_not($2); } | | | 275 | '!' fatom { $$ = fx_not($2); } | |
233 | fexpr '&' fexpr { $$ = fx_and($1, $3); } | | | 276 | fexpr '&' fexpr { $$ = fx_and($1, $3); } | |
234 | fexpr '|' fexpr { $$ = fx_or($1, $3); } | | | 277 | fexpr '|' fexpr { $$ = fx_or($1, $3); } | |
235 | '(' fexpr ')' { $$ = $2; }; | | 278 | '(' fexpr ')' { $$ = $2; }; |
236 | | | 279 | |
| | | 280 | /* basic element of config element expression: a config element */ |
237 | fatom: | | 281 | fatom: |
238 | WORD { $$ = fx_atom($1); }; | | 282 | WORD { $$ = fx_atom($1); }; |
239 | | | 283 | |
| | | 284 | /* zero or more flags for a file */ |
240 | fflgs: | | 285 | fflgs: |
241 | fflgs fflag { $$ = $1 | $2; } | | | 286 | fflgs fflag { $$ = $1 | $2; } | |
242 | /* empty */ { $$ = 0; }; | | 287 | /* empty */ { $$ = 0; }; |
243 | | | 288 | |
| | | 289 | /* one flag for a file */ |
244 | fflag: | | 290 | fflag: |
245 | NEEDS_COUNT { $$ = FI_NEEDSCOUNT; } | | | 291 | NEEDS_COUNT { $$ = FI_NEEDSCOUNT; } | |
246 | NEEDS_FLAG { $$ = FI_NEEDSFLAG; }; | | 292 | NEEDS_FLAG { $$ = FI_NEEDSFLAG; }; |
247 | | | 293 | |
| | | 294 | /* device node specification */ |
248 | devnodes: | | 295 | devnodes: |
249 | devnodetype ',' devnodeflags { $$ = nvcat($1, $3); } | | | 296 | devnodetype ',' devnodeflags { $$ = nvcat($1, $3); } | |
250 | devnodetype { $$ = $1; } | | | 297 | devnodetype { $$ = $1; } | |
251 | /* empty */ { $$ = new_s("DEVNODE_DONTBOTHER"); }; | | 298 | /* empty */ { $$ = new_s("DEVNODE_DONTBOTHER"); }; |
252 | | | 299 | |
| | | 300 | /* device nodes without flags */ |
253 | devnodetype: | | 301 | devnodetype: |
254 | SINGLE { $$ = new_s("DEVNODE_SINGLE"); } | | | 302 | SINGLE { $$ = new_s("DEVNODE_SINGLE"); } | |
255 | VECTOR '=' devnode_dims { $$ = nvcat(new_s("DEVNODE_VECTOR"), $3); }; | | 303 | VECTOR '=' devnode_dims { $$ = nvcat(new_s("DEVNODE_VECTOR"), $3); }; |
256 | | | 304 | |
| | | 305 | /* dimensions (?) */ |
257 | devnode_dims: | | 306 | devnode_dims: |
258 | NUMBER ':' NUMBER { struct nvlist *__nv1, *__nv2; | | 307 | NUMBER ':' NUMBER { struct nvlist *__nv1, *__nv2; |
259 | __nv1 = new_i($1.val); | | 308 | __nv1 = new_i($1.val); |
260 | __nv2 = new_i($3.val); | | 309 | __nv2 = new_i($3.val); |
261 | $$ = nvcat(__nv1, __nv2); } | | | 310 | $$ = nvcat(__nv1, __nv2); } | |
262 | NUMBER { $$ = new_i($1.val); } | | 311 | NUMBER { $$ = new_i($1.val); } |
263 | | | 312 | |
| | | 313 | /* flags for device nodes */ |
264 | devnodeflags: | | 314 | devnodeflags: |
265 | LINKZERO { $$ = new_s("DEVNODE_FLAG_LINKZERO");}; | | 315 | LINKZERO { $$ = new_s("DEVNODE_FLAG_LINKZERO");}; |
266 | | | 316 | |
| | | 317 | /* zero or more flags for an object file */ |
267 | oflgs: | | 318 | oflgs: |
268 | oflgs oflag { $$ = $1 | $2; } | | | 319 | oflgs oflag { $$ = $1 | $2; } | |
269 | /* empty */ { $$ = 0; }; | | 320 | /* empty */ { $$ = 0; }; |
270 | | | 321 | |
| | | 322 | /* a single flag for an object file */ |
271 | oflag: | | 323 | oflag: |
272 | NEEDS_FLAG { $$ = OI_NEEDSFLAG; }; | | 324 | NEEDS_FLAG { $$ = OI_NEEDSFLAG; }; |
273 | | | 325 | |
| | | 326 | /* extra compile directive for a source file */ |
274 | rule: | | 327 | rule: |
275 | COMPILE_WITH stringvalue { $$ = $2; } | | | 328 | COMPILE_WITH stringvalue { $$ = $2; } | |
276 | /* empty */ { $$ = NULL; }; | | 329 | /* empty */ { $$ = NULL; }; |
277 | | | 330 | |
| | | 331 | /* prefix delimiter */ |
278 | prefix: | | 332 | prefix: |
279 | PREFIX filename { prefix_push($2); } | | | 333 | PREFIX filename { prefix_push($2); } | |
280 | PREFIX { prefix_pop(); }; | | 334 | PREFIX { prefix_pop(); }; |
281 | | | 335 | |
| | | 336 | /************************************************************/ |
| | | 337 | |
282 | /* | | 338 | /* |
283 | * The machine definitions grammar. | | 339 | * The machine definitions grammar. |
284 | */ | | 340 | */ |
| | | 341 | |
| | | 342 | /* Complete definition part: the contents of all files.* files. */ |
285 | dev_defs: | | 343 | dev_defs: |
286 | dev_defs dev_def | | | 344 | dev_defs dev_def | |
287 | dev_defs ENDFILE { enddefs(); checkfiles(); } | | | 345 | dev_defs ENDFILE { enddefs(); checkfiles(); } | |
288 | /* empty */; | | 346 | /* empty */; |
289 | | | 347 | |
| | | 348 | /* A single definition, or a blank line. Trap errors. */ |
290 | dev_def: | | 349 | dev_def: |
291 | one_def '\n' { adepth = 0; } | | | 350 | one_def '\n' { adepth = 0; } | |
292 | '\n' | | | 351 | '\n' | |
293 | error '\n' { cleanup(); }; | | 352 | error '\n' { cleanup(); }; |
294 | | | 353 | |
| | | 354 | /* A single definition. */ |
295 | one_def: | | 355 | one_def: |
296 | file | | | 356 | file | |
297 | object | | | 357 | object | |
298 | device_major { do_devsw = 1; } | | | 358 | device_major { do_devsw = 1; } | |
299 | prefix | | | 359 | prefix | |
300 | DEVCLASS WORD { (void)defattr($2, NULL, NULL, 1); } | | | 360 | DEVCLASS WORD { (void)defattr($2, NULL, NULL, 1); } | |
301 | DEFFS deffses defoptdeps { deffilesystem($2, $3); } | | | 361 | DEFFS deffses defoptdeps { deffilesystem($2, $3); } | |
302 | DEFINE WORD interface_opt attrs_opt | | 362 | DEFINE WORD interface_opt attrs_opt |
303 | { (void)defattr($2, $3, $4, 0); } | | | 363 | { (void)defattr($2, $3, $4, 0); } | |
304 | DEFOPT optfile_opt defopts defoptdeps | | 364 | DEFOPT optfile_opt defopts defoptdeps |
305 | { defoption($2, $3, $4); } | | | 365 | { defoption($2, $3, $4); } | |
306 | DEFFLAG optfile_opt defopts defoptdeps | | 366 | DEFFLAG optfile_opt defopts defoptdeps |
307 | { defflag($2, $3, $4, 0); } | | | 367 | { defflag($2, $3, $4, 0); } | |
308 | OBSOLETE DEFFLAG optfile_opt defopts | | 368 | OBSOLETE DEFFLAG optfile_opt defopts |
309 | { defflag($3, $4, NULL, 1); } | | | 369 | { defflag($3, $4, NULL, 1); } | |
310 | DEFPARAM optfile_opt defopts defoptdeps | | 370 | DEFPARAM optfile_opt defopts defoptdeps |
311 | { defparam($2, $3, $4, 0); } | | | 371 | { defparam($2, $3, $4, 0); } | |
312 | OBSOLETE DEFPARAM optfile_opt defopts | | 372 | OBSOLETE DEFPARAM optfile_opt defopts |
313 | { defparam($3, $4, NULL, 1); } | | | 373 | { defparam($3, $4, NULL, 1); } | |
314 | DEVICE devbase interface_opt attrs_opt | | 374 | DEVICE devbase interface_opt attrs_opt |
315 | { defdev($2, $3, $4, 0); } | | | 375 | { defdev($2, $3, $4, 0); } | |
316 | ATTACH devbase AT atlist devattach_opt attrs_opt | | 376 | ATTACH devbase AT atlist devattach_opt attrs_opt |
317 | { defdevattach($5, $2, $4, $6); } | | | 377 | { defdevattach($5, $2, $4, $6); } | |
318 | MAXPARTITIONS NUMBER { maxpartitions = $2.val; } | | | 378 | MAXPARTITIONS NUMBER { maxpartitions = $2.val; } | |
319 | MAXUSERS NUMBER NUMBER NUMBER { setdefmaxusers($2.val, $3.val, $4.val); } | | | 379 | MAXUSERS NUMBER NUMBER NUMBER { setdefmaxusers($2.val, $3.val, $4.val); } | |
320 | MAKEOPTIONS condmkopt_list | | | 380 | MAKEOPTIONS condmkopt_list | |
321 | /* interface_opt in DEFPSEUDO is for backwards compatibility */ | | 381 | /* interface_opt in DEFPSEUDO is for backwards compatibility */ |
322 | DEFPSEUDO devbase interface_opt attrs_opt | | 382 | DEFPSEUDO devbase interface_opt attrs_opt |
323 | { defdev($2, $3, $4, 1); } | | | 383 | { defdev($2, $3, $4, 1); } | |
324 | DEFPSEUDODEV devbase interface_opt attrs_opt | | 384 | DEFPSEUDODEV devbase interface_opt attrs_opt |
325 | { defdev($2, $3, $4, 2); } | | | 385 | { defdev($2, $3, $4, 2); } | |
326 | MAJOR '{' majorlist '}' | | | 386 | MAJOR '{' majorlist '}' | |
327 | VERSION NUMBER { setversion($2.val); }; | | 387 | VERSION NUMBER { setversion($2.val); }; |
328 | | | 388 | |
| | | 389 | /* list of places to attach: attach blah at ... */ |
329 | atlist: | | 390 | atlist: |
330 | atlist ',' atname { $$ = new_nx($3, $1); } | | | 391 | atlist ',' atname { $$ = new_nx($3, $1); } | |
331 | atname { $$ = new_n($1); }; | | 392 | atname { $$ = new_n($1); }; |
332 | | | 393 | |
| | | 394 | /* a place to attach a device */ |
333 | atname: | | 395 | atname: |
334 | WORD { $$ = $1; } | | | 396 | WORD { $$ = $1; } | |
335 | ROOT { $$ = NULL; }; | | 397 | ROOT { $$ = NULL; }; |
336 | | | 398 | |
| | | 399 | /* one or more file system names */ |
337 | deffses: | | 400 | deffses: |
338 | deffses deffs { $$ = new_nx($2, $1); } | | | 401 | deffses deffs { $$ = new_nx($2, $1); } | |
339 | deffs { $$ = new_n($1); }; | | 402 | deffs { $$ = new_n($1); }; |
340 | | | 403 | |
| | | 404 | /* a single file system name */ |
341 | deffs: | | 405 | deffs: |
342 | WORD { $$ = $1; }; | | 406 | WORD { $$ = $1; }; |
343 | | | 407 | |
| | | 408 | /* option dependencies (read as "defopt deps") which are optional */ |
344 | defoptdeps: | | 409 | defoptdeps: |
345 | ':' optdeps { $$ = $2; } | | | 410 | ':' optdeps { $$ = $2; } | |
346 | /* empty */ { $$ = NULL; }; | | 411 | /* empty */ { $$ = NULL; }; |
347 | | | 412 | |
| | | 413 | /* a list of option dependencies */ |
348 | optdeps: | | 414 | optdeps: |
349 | optdeps ',' optdep { $$ = new_nx($3, $1); } | | | 415 | optdeps ',' optdep { $$ = new_nx($3, $1); } | |
350 | optdep { $$ = new_n($1); }; | | 416 | optdep { $$ = new_n($1); }; |
351 | | | 417 | |
| | | 418 | /* one option dependence */ |
352 | optdep: | | 419 | optdep: |
353 | WORD { $$ = $1; }; | | 420 | WORD { $$ = $1; }; |
354 | | | 421 | |
| | | 422 | /* one or more defined options */ |
355 | defopts: | | 423 | defopts: |
356 | defopts defopt { $$ = nvcat($2, $1); } | | | 424 | defopts defopt { $$ = nvcat($2, $1); } | |
357 | defopt { $$ = $1; }; | | 425 | defopt { $$ = $1; }; |
358 | | | 426 | |
| | | 427 | /* one defined option */ |
359 | defopt: | | 428 | defopt: |
360 | WORD { $$ = new_n($1); } | | | 429 | WORD { $$ = new_n($1); } | |
361 | WORD '=' value { $$ = new_ns($1, $3); } | | | 430 | WORD '=' value { $$ = new_ns($1, $3); } | |
362 | WORD COLONEQ value { | | 431 | WORD COLONEQ value { |
363 | struct nvlist *__nv = | | 432 | struct nvlist *__nv = |
364 | new_n($1); | | 433 | new_n($1); |
365 | $$ = new_nsx("", $3, __nv); | | 434 | $$ = new_nsx("", $3, __nv); |
366 | } | | | 435 | } | |
367 | WORD '=' value COLONEQ value { | | 436 | WORD '=' value COLONEQ value { |
368 | struct nvlist *__nv = | | 437 | struct nvlist *__nv = |
369 | new_n($1); | | 438 | new_n($1); |
370 | $$ = new_nsx("", $5, __nv); | | 439 | $$ = new_nsx("", $5, __nv); |
371 | }; | | 440 | }; |
372 | | | 441 | |
| | | 442 | /* device name */ |
373 | devbase: | | 443 | devbase: |
374 | WORD { $$ = getdevbase($1); }; | | 444 | WORD { $$ = getdevbase($1); }; |
375 | | | 445 | |
| | | 446 | /* optional attachment: with foo */ |
376 | devattach_opt: | | 447 | devattach_opt: |
377 | WITH WORD { $$ = getdevattach($2); } | | | 448 | WITH WORD { $$ = getdevattach($2); } | |
378 | /* empty */ { $$ = NULL; }; | | 449 | /* empty */ { $$ = NULL; }; |
379 | | | 450 | |
| | | 451 | /* optional locator specification in braces */ |
380 | interface_opt: | | 452 | interface_opt: |
381 | '{' loclist_opt '}' { $$ = new_nx("", $2); } | | | 453 | '{' loclist_opt '}' { $$ = new_nx("", $2); } | |
382 | /* empty */ { $$ = NULL; }; | | 454 | /* empty */ { $$ = NULL; }; |
383 | | | 455 | |
| | | 456 | /* optional locator specification without braces */ |
384 | loclist_opt: | | 457 | loclist_opt: |
385 | loclist { $$ = $1; } | | | 458 | loclist { $$ = $1; } | |
386 | /* empty */ { $$ = NULL; }; | | 459 | /* empty */ { $$ = NULL; }; |
387 | | | 460 | |
388 | /* loclist order matters, must use right recursion */ | | 461 | /* |
| | | 462 | * loclist order matters, must use right recursion |
| | | 463 | * XXX wot? |
| | | 464 | */ |
| | | 465 | |
| | | 466 | /* list of locator definitions */ |
389 | loclist: | | 467 | loclist: |
390 | locdef ',' loclist { $$ = $1; app($1, $3); } | | | 468 | locdef ',' loclist { $$ = $1; app($1, $3); } | |
391 | locdef { $$ = $1; }; | | 469 | locdef { $$ = $1; }; |
392 | | | 470 | |
393 | /* "[ WORD locdefault ]" syntax may be unnecessary... */ | | 471 | /* |
| | | 472 | * "[ WORD locdefault ]" syntax may be unnecessary... |
| | | 473 | */ |
| | | 474 | |
| | | 475 | /* one locator definition */ |
394 | locdef: | | 476 | locdef: |
395 | locname locdefault { $$ = new_nsi($1, $2, 0); } | | | 477 | locname locdefault { $$ = new_nsi($1, $2, 0); } | |
396 | locname { $$ = new_nsi($1, NULL, 0); } | | | 478 | locname { $$ = new_nsi($1, NULL, 0); } | |
397 | '[' locname locdefault ']' { $$ = new_nsi($2, $3, 1); } | | | 479 | '[' locname locdefault ']' { $$ = new_nsi($2, $3, 1); } | |
398 | locname '[' NUMBER ']' { $$ = mk_nsis($1, $3.val, NULL, 0); } | | | 480 | locname '[' NUMBER ']' { $$ = mk_nsis($1, $3.val, NULL, 0); } | |
399 | locname '[' NUMBER ']' locdefaults | | 481 | locname '[' NUMBER ']' locdefaults |
400 | { $$ = mk_nsis($1, $3.val, $5, 0); } | | | 482 | { $$ = mk_nsis($1, $3.val, $5, 0); } | |
401 | '[' locname '[' NUMBER ']' locdefaults ']' | | 483 | '[' locname '[' NUMBER ']' locdefaults ']' |
402 | { $$ = mk_nsis($2, $4.val, $6, 1); }; | | 484 | { $$ = mk_nsis($2, $4.val, $6, 1); }; |
403 | | | 485 | |
| | | 486 | /* locator name */ |
404 | locname: | | 487 | locname: |
405 | WORD { $$ = $1; } | | | 488 | WORD { $$ = $1; } | |
406 | QSTRING { $$ = $1; }; | | 489 | QSTRING { $$ = $1; }; |
407 | | | 490 | |
| | | 491 | /* locator default value */ |
408 | locdefault: | | 492 | locdefault: |
409 | '=' value { $$ = $2; }; | | 493 | '=' value { $$ = $2; }; |
410 | | | 494 | |
| | | 495 | /* multiple locator default values */ |
411 | locdefaults: | | 496 | locdefaults: |
412 | '=' '{' values '}' { $$ = $3; }; | | 497 | '=' '{' values '}' { $$ = $3; }; |
413 | | | 498 | |
| | | 499 | /* optional file for an option */ |
414 | optfile_opt: | | 500 | optfile_opt: |
415 | filename { $$ = $1; } | | | 501 | filename { $$ = $1; } | |
416 | /* empty */ { $$ = NULL; }; | | 502 | /* empty */ { $$ = NULL; }; |
417 | | | 503 | |
| | | 504 | /* filename. */ |
418 | filename: | | 505 | filename: |
419 | QSTRING { $$ = $1; } | | | 506 | QSTRING { $$ = $1; } | |
420 | PATHNAME { $$ = $1; }; | | 507 | PATHNAME { $$ = $1; }; |
421 | | | 508 | |
| | | 509 | /* constant value */ |
422 | value: | | 510 | value: |
423 | QSTRING { $$ = $1; } | | | 511 | QSTRING { $$ = $1; } | |
424 | WORD { $$ = $1; } | | | 512 | WORD { $$ = $1; } | |
425 | EMPTYSTRING { $$ = $1; } | | | 513 | EMPTYSTRING { $$ = $1; } | |
426 | signed_number { char bf[40]; | | 514 | signed_number { char bf[40]; |
427 | (void)snprintf(bf, sizeof(bf), | | 515 | (void)snprintf(bf, sizeof(bf), |
428 | FORMAT($1), (long long)$1.val); | | 516 | FORMAT($1), (long long)$1.val); |
429 | $$ = intern(bf); }; | | 517 | $$ = intern(bf); }; |
430 | | | 518 | |
| | | 519 | /* constant value that is a string */ |
431 | stringvalue: | | 520 | stringvalue: |
432 | QSTRING { $$ = $1; } | | | 521 | QSTRING { $$ = $1; } | |
433 | WORD { $$ = $1; }; | | 522 | WORD { $$ = $1; }; |
434 | | | 523 | |
| | | 524 | /* comma-separated list of values */ |
435 | values: | | 525 | values: |
436 | value ',' values { $$ = new_sx($1, $3); } | | | 526 | value ',' values { $$ = new_sx($1, $3); } | |
437 | value { $$ = new_s($1); }; | | 527 | value { $$ = new_s($1); }; |
438 | | | 528 | |
| | | 529 | /* possibly negative number */ |
439 | signed_number: | | 530 | signed_number: |
440 | NUMBER { $$ = $1; } | | | 531 | NUMBER { $$ = $1; } | |
441 | '-' NUMBER { $$.fmt = $2.fmt; $$.val = -$2.val; }; | | 532 | '-' NUMBER { $$.fmt = $2.fmt; $$.val = -$2.val; }; |
442 | | | 533 | |
| | | 534 | /* optional attributes */ |
443 | attrs_opt: | | 535 | attrs_opt: |
444 | ':' attrs { $$ = $2; } | | | 536 | ':' attrs { $$ = $2; } | |
445 | /* empty */ { $$ = NULL; }; | | 537 | /* empty */ { $$ = NULL; }; |
446 | | | 538 | |
| | | 539 | /* one or more attributes */ |
447 | attrs: | | 540 | attrs: |
448 | attrs ',' attr { $$ = new_px($3, $1); } | | | 541 | attrs ',' attr { $$ = new_px($3, $1); } | |
449 | attr { $$ = new_p($1); }; | | 542 | attr { $$ = new_p($1); }; |
450 | | | 543 | |
| | | 544 | /* one attribute */ |
451 | attr: | | 545 | attr: |
452 | WORD { $$ = getattr($1); }; | | 546 | WORD { $$ = getattr($1); }; |
453 | | | 547 | |
| | | 548 | /* list of major numbers */ |
| | | 549 | /* XXX why is this right-recursive? */ |
454 | majorlist: | | 550 | majorlist: |
455 | majorlist ',' majordef | | | 551 | majorlist ',' majordef | |
456 | majordef; | | 552 | majordef; |
457 | | | 553 | |
| | | 554 | /* one major number */ |
458 | majordef: | | 555 | majordef: |
459 | devbase '=' NUMBER { setmajor($1, $3.val); }; | | 556 | devbase '=' NUMBER { setmajor($1, $3.val); }; |
460 | | | 557 | |
| | | 558 | /************************************************************/ |
461 | | | 559 | |
462 | /* | | 560 | /* |
463 | * The configuration grammar. | | 561 | * The configuration grammar. |
464 | */ | | 562 | */ |
| | | 563 | |
| | | 564 | /* Complete configuration part: all std.* files plus selected config. */ |
465 | specs: | | 565 | specs: |
466 | specs spec | | | 566 | specs spec | |
467 | /* empty */; | | 567 | /* empty */; |
468 | | | 568 | |
| | | 569 | /* One config item, or a blank line. Trap errors. */ |
469 | spec: | | 570 | spec: |
470 | config_spec '\n' { adepth = 0; } | | | 571 | config_spec '\n' { adepth = 0; } | |
471 | '\n' | | | 572 | '\n' | |
472 | error '\n' { cleanup(); }; | | 573 | error '\n' { cleanup(); }; |
473 | | | 574 | |
| | | 575 | /* One config item. */ |
474 | config_spec: | | 576 | config_spec: |
475 | one_def | | | 577 | one_def | |
476 | NO FILE_SYSTEM no_fs_list | | | 578 | NO FILE_SYSTEM no_fs_list | |
477 | FILE_SYSTEM fs_list | | | 579 | FILE_SYSTEM fs_list | |
478 | NO MAKEOPTIONS no_mkopt_list | | | 580 | NO MAKEOPTIONS no_mkopt_list | |
479 | MAKEOPTIONS mkopt_list | | | 581 | MAKEOPTIONS mkopt_list | |
480 | NO OPTIONS no_opt_list | | | 582 | NO OPTIONS no_opt_list | |
481 | OPTIONS opt_list | | | 583 | OPTIONS opt_list | |
482 | MAXUSERS NUMBER { setmaxusers($2.val); } | | | 584 | MAXUSERS NUMBER { setmaxusers($2.val); } | |
483 | IDENT stringvalue { setident($2); } | | | 585 | IDENT stringvalue { setident($2); } | |
484 | CONFIG conf root_spec sysparam_list | | 586 | CONFIG conf root_spec sysparam_list |
485 | { addconf(&conf); } | | | 587 | { addconf(&conf); } | |
486 | NO CONFIG WORD { delconf($3); } | | | 588 | NO CONFIG WORD { delconf($3); } | |
487 | NO PSEUDO_DEVICE WORD { delpseudo($3); } | | | 589 | NO PSEUDO_DEVICE WORD { delpseudo($3); } | |
488 | PSEUDO_DEVICE WORD npseudo { addpseudo($2, $3); } | | | 590 | PSEUDO_DEVICE WORD npseudo { addpseudo($2, $3); } | |
489 | PSEUDO_ROOT device_instance { addpseudoroot($2); } | | | 591 | PSEUDO_ROOT device_instance { addpseudoroot($2); } | |
490 | NO device_instance AT attachment | | 592 | NO device_instance AT attachment |
491 | { deldevi($2, $4); } | | | 593 | { deldevi($2, $4); } | |
492 | NO DEVICE AT attachment { deldeva($4); } | | | 594 | NO DEVICE AT attachment { deldeva($4); } | |
493 | NO device_instance { deldev($2); } | | | 595 | NO device_instance { deldev($2); } | |
494 | device_instance AT attachment locators flags_opt | | 596 | device_instance AT attachment locators flags_opt |
495 | { adddev($1, $3, $4, $5); }; | | 597 | { adddev($1, $3, $4, $5); }; |
496 | | | 598 | |
| | | 599 | /* list of filesystems */ |
497 | fs_list: | | 600 | fs_list: |
498 | fs_list ',' fsoption | | | 601 | fs_list ',' fsoption | |
499 | fsoption; | | 602 | fsoption; |
500 | | | 603 | |
| | | 604 | /* one filesystem */ |
501 | fsoption: | | 605 | fsoption: |
502 | WORD { addfsoption($1); }; | | 606 | WORD { addfsoption($1); }; |
503 | | | 607 | |
| | | 608 | /* list of filesystems that had NO in front */ |
504 | no_fs_list: | | 609 | no_fs_list: |
505 | no_fs_list ',' no_fsoption | | | 610 | no_fs_list ',' no_fsoption | |
506 | no_fsoption; | | 611 | no_fsoption; |
507 | | | 612 | |
| | | 613 | /* one filesystem that had NO in front */ |
508 | no_fsoption: | | 614 | no_fsoption: |
509 | WORD { delfsoption($1); }; | | 615 | WORD { delfsoption($1); }; |
510 | | | 616 | |
| | | 617 | /* list of make options */ |
| | | 618 | /* XXX why is this right-recursive? */ |
511 | mkopt_list: | | 619 | mkopt_list: |
512 | mkopt_list ',' mkoption | | | 620 | mkopt_list ',' mkoption | |
513 | mkoption; | | 621 | mkoption; |
514 | | | 622 | |
| | | 623 | /* variable name for make option */ |
515 | mkvarname: | | 624 | mkvarname: |
516 | QSTRING { $$ = $1; } | | | 625 | QSTRING { $$ = $1; } | |
517 | WORD { $$ = $1; }; | | 626 | WORD { $$ = $1; }; |
518 | | | 627 | |
| | | 628 | /* one make option */ |
519 | mkoption: | | 629 | mkoption: |
520 | mkvarname '=' value { addmkoption($1, $3); } | | | 630 | mkvarname '=' value { addmkoption($1, $3); } | |
521 | mkvarname PLUSEQ value { appendmkoption($1, $3); }; | | 631 | mkvarname PLUSEQ value { appendmkoption($1, $3); }; |
522 | | | 632 | |
| | | 633 | /* list of conditional makeoptions */ |
523 | condmkopt_list: | | 634 | condmkopt_list: |
524 | condmkopt_list ',' condmkoption | | | 635 | condmkopt_list ',' condmkoption | |
525 | condmkoption; | | 636 | condmkoption; |
526 | | | 637 | |
| | | 638 | /* one conditional make option */ |
527 | condmkoption: | | 639 | condmkoption: |
528 | fexpr mkvarname PLUSEQ value { appendcondmkoption($1, $2, $4); }; | | 640 | fexpr mkvarname PLUSEQ value { appendcondmkoption($1, $2, $4); }; |
529 | | | 641 | |
| | | 642 | /* list of make options that had NO in front */ |
530 | no_mkopt_list: | | 643 | no_mkopt_list: |
531 | no_mkopt_list ',' no_mkoption | | | 644 | no_mkopt_list ',' no_mkoption | |
532 | no_mkoption; | | 645 | no_mkoption; |
533 | | | 646 | |
| | | 647 | /* one make option that had NO in front */ |
534 | no_mkoption: | | 648 | no_mkoption: |
535 | WORD { delmkoption($1); } | | 649 | WORD { delmkoption($1); } |
536 | | | 650 | |
| | | 651 | /* list of options */ |
537 | opt_list: | | 652 | opt_list: |
538 | opt_list ',' option | | | 653 | opt_list ',' option | |
539 | option; | | 654 | option; |
540 | | | 655 | |
| | | 656 | /* one option */ |
541 | option: | | 657 | option: |
542 | WORD { addoption($1, NULL); } | | | 658 | WORD { addoption($1, NULL); } | |
543 | WORD '=' value { addoption($1, $3); }; | | 659 | WORD '=' value { addoption($1, $3); }; |
544 | | | 660 | |
| | | 661 | /* list of options that had NO in front */ |
545 | no_opt_list: | | 662 | no_opt_list: |
546 | no_opt_list ',' no_option | | | 663 | no_opt_list ',' no_option | |
547 | no_option; | | 664 | no_option; |
548 | | | 665 | |
| | | 666 | /* one option that had NO in front */ |
549 | no_option: | | 667 | no_option: |
550 | WORD { deloption($1); }; | | 668 | WORD { deloption($1); }; |
551 | | | 669 | |
| | | 670 | /* the name in "config name root on ..." */ |
552 | conf: | | 671 | conf: |
553 | WORD { conf.cf_name = $1; | | 672 | WORD { conf.cf_name = $1; |
554 | conf.cf_lineno = currentline(); | | 673 | conf.cf_lineno = currentline(); |
555 | conf.cf_fstype = NULL; | | 674 | conf.cf_fstype = NULL; |
556 | conf.cf_root = NULL; | | 675 | conf.cf_root = NULL; |
557 | conf.cf_dump = NULL; }; | | 676 | conf.cf_dump = NULL; }; |
558 | | | 677 | |
| | | 678 | /* root fs specification */ |
559 | root_spec: | | 679 | root_spec: |
560 | ROOT on_opt dev_spec fs_spec_opt | | 680 | ROOT on_opt dev_spec fs_spec_opt |
561 | { setconf(&conf.cf_root, "root", $3); }; | | 681 | { setconf(&conf.cf_root, "root", $3); }; |
562 | | | 682 | |
| | | 683 | /* filesystem type for root fs specification */ |
563 | fs_spec_opt: | | 684 | fs_spec_opt: |
564 | TYPE fs_spec { setfstype(&conf.cf_fstype, $2); } | | | 685 | TYPE fs_spec { setfstype(&conf.cf_fstype, $2); } | |
565 | /* empty */; | | 686 | /* empty */; |
566 | | | 687 | |
| | | 688 | /* filesystem name for root fs specification */ |
567 | fs_spec: | | 689 | fs_spec: |
568 | '?' { $$ = intern("?"); } | | | 690 | '?' { $$ = intern("?"); } | |
569 | WORD { $$ = $1; }; | | 691 | WORD { $$ = $1; }; |
570 | | | 692 | |
| | | 693 | /* zero or more additional system parameters */ |
571 | sysparam_list: | | 694 | sysparam_list: |
572 | sysparam_list sysparam | | | 695 | sysparam_list sysparam | |
573 | /* empty */; | | 696 | /* empty */; |
574 | | | 697 | |
| | | 698 | /* one additional system parameter (there's only one: dumps) */ |
575 | sysparam: | | 699 | sysparam: |
576 | DUMPS on_opt dev_spec { setconf(&conf.cf_dump, "dumps", $3); }; | | 700 | DUMPS on_opt dev_spec { setconf(&conf.cf_dump, "dumps", $3); }; |
577 | | | 701 | |
| | | 702 | /* device for root fs or dump */ |
578 | dev_spec: | | 703 | dev_spec: |
579 | '?' { $$ = new_si(intern("?"), NODEV); } | | | 704 | '?' { $$ = new_si(intern("?"), NODEV); } | |
580 | WORD { $$ = new_si($1, NODEV); } | | | 705 | WORD { $$ = new_si($1, NODEV); } | |
581 | major_minor { $$ = new_si(NULL, $1); }; | | 706 | major_minor { $$ = new_si(NULL, $1); }; |
582 | | | 707 | |
| | | 708 | /* major and minor device number */ |
583 | major_minor: | | 709 | major_minor: |
584 | MAJOR NUMBER MINOR NUMBER { $$ = makedev($2.val, $4.val); }; | | 710 | MAJOR NUMBER MINOR NUMBER { $$ = makedev($2.val, $4.val); }; |
585 | | | 711 | |
| | | 712 | /* optional ON keyword */ |
586 | on_opt: | | 713 | on_opt: |
587 | ON | /* empty */; | | 714 | ON | /* empty */; |
588 | | | 715 | |
| | | 716 | /* number of pseudo devices to configure (which is optional) */ |
589 | npseudo: | | 717 | npseudo: |
590 | NUMBER { $$ = $1.val; } | | | 718 | NUMBER { $$ = $1.val; } | |
591 | /* empty */ { $$ = 1; }; | | 719 | /* empty */ { $$ = 1; }; |
592 | | | 720 | |
| | | 721 | /* name of a device to configure */ |
593 | device_instance: | | 722 | device_instance: |
594 | WORD '*' { $$ = starref($1); } | | | 723 | WORD '*' { $$ = starref($1); } | |
595 | WORD { $$ = $1; }; | | 724 | WORD { $$ = $1; }; |
596 | | | 725 | |
| | | 726 | /* name of a device to configure an attachment to */ |
597 | attachment: | | 727 | attachment: |
598 | ROOT { $$ = NULL; } | | | 728 | ROOT { $$ = NULL; } | |
599 | WORD '?' { $$ = wildref($1); } | | | 729 | WORD '?' { $$ = wildref($1); } | |
600 | WORD { $$ = $1; }; | | 730 | WORD { $$ = $1; }; |
601 | | | 731 | |
| | | 732 | /* zero or more locators */ |
602 | locators: | | 733 | locators: |
603 | locators locator { $$ = $2; app($2, $1); } | | | 734 | locators locator { $$ = $2; app($2, $1); } | |
604 | /* empty */ { $$ = NULL; }; | | 735 | /* empty */ { $$ = NULL; }; |
605 | | | 736 | |
| | | 737 | /* one locator */ |
606 | locator: | | 738 | locator: |
607 | WORD values { $$ = mk_ns($1, $2); } | | | 739 | WORD values { $$ = mk_ns($1, $2); } | |
608 | WORD '?' { $$ = new_ns($1, NULL); }; | | 740 | WORD '?' { $$ = new_ns($1, NULL); }; |
609 | | | 741 | |
| | | 742 | /* optional device flags */ |
610 | flags_opt: | | 743 | flags_opt: |
611 | FLAGS NUMBER { $$ = $2.val; } | | | 744 | FLAGS NUMBER { $$ = $2.val; } | |
612 | /* empty */ { $$ = 0; }; | | 745 | /* empty */ { $$ = 0; }; |
613 | | | 746 | |
614 | %% | | 747 | %% |
615 | | | 748 | |
616 | void | | 749 | void |
617 | yyerror(const char *s) | | 750 | yyerror(const char *s) |
618 | { | | 751 | { |
619 | | | 752 | |
620 | cfgerror("%s", s); | | 753 | cfgerror("%s", s); |
621 | } | | 754 | } |
622 | | | 755 | |
623 | /* | | 756 | /* |
624 | * Cleanup procedure after syntax error: release any nvlists | | 757 | * Cleanup procedure after syntax error: release any nvlists |
625 | * allocated during parsing the current line. | | 758 | * allocated during parsing the current line. |
626 | */ | | 759 | */ |
627 | static void | | 760 | static void |
628 | cleanup(void) | | 761 | cleanup(void) |
629 | { | | 762 | { |
630 | struct nvlist **np; | | 763 | struct nvlist **np; |
631 | int i; | | 764 | int i; |
632 | | | 765 | |
633 | for (np = alloc, i = adepth; --i >= 0; np++) | | 766 | for (np = alloc, i = adepth; --i >= 0; np++) |
634 | nvfree(*np); | | 767 | nvfree(*np); |
635 | adepth = 0; | | 768 | adepth = 0; |
636 | } | | 769 | } |
637 | | | 770 | |
638 | static void | | 771 | static void |
639 | setmachine(const char *mch, const char *mcharch, struct nvlist *mchsubarches, | | 772 | setmachine(const char *mch, const char *mcharch, struct nvlist *mchsubarches, |
640 | int isioconf) | | 773 | int isioconf) |
641 | { | | 774 | { |
642 | char buf[MAXPATHLEN]; | | 775 | char buf[MAXPATHLEN]; |
643 | struct nvlist *nv; | | 776 | struct nvlist *nv; |
644 | | | 777 | |
645 | if (isioconf) { | | 778 | if (isioconf) { |
646 | fprintf(stderr, "WARNING: ioconf is an experimental feature\n"); | | 779 | fprintf(stderr, "WARNING: ioconf is an experimental feature\n"); |
647 | if (include(_PATH_DEVNULL, ENDDEFS, 0, 0) != 0) | | 780 | if (include(_PATH_DEVNULL, ENDDEFS, 0, 0) != 0) |
648 | exit(1); | | 781 | exit(1); |
649 | ioconfname = mch; | | 782 | ioconfname = mch; |
650 | return; | | 783 | return; |
651 | } | | 784 | } |
652 | | | 785 | |
653 | machine = mch; | | 786 | machine = mch; |
654 | machinearch = mcharch; | | 787 | machinearch = mcharch; |
655 | machinesubarches = mchsubarches; | | 788 | machinesubarches = mchsubarches; |
656 | | | 789 | |
657 | /* | | 790 | /* |
658 | * Define attributes for all the given names | | 791 | * Define attributes for all the given names |
659 | */ | | 792 | */ |
660 | if (defattr(machine, NULL, NULL, 0) != 0 || | | 793 | if (defattr(machine, NULL, NULL, 0) != 0 || |
661 | (machinearch != NULL && | | 794 | (machinearch != NULL && |
662 | defattr(machinearch, NULL, NULL, 0) != 0)) | | 795 | defattr(machinearch, NULL, NULL, 0) != 0)) |
663 | exit(1); | | 796 | exit(1); |
664 | for (nv = machinesubarches; nv != NULL; nv = nv->nv_next) { | | 797 | for (nv = machinesubarches; nv != NULL; nv = nv->nv_next) { |
665 | if (defattr(nv->nv_name, NULL, NULL, 0) != 0) | | 798 | if (defattr(nv->nv_name, NULL, NULL, 0) != 0) |
666 | exit(1); | | 799 | exit(1); |
667 | } | | 800 | } |
668 | | | 801 | |
669 | /* | | 802 | /* |
670 | * Set up the file inclusion stack. This empty include tells | | 803 | * Set up the file inclusion stack. This empty include tells |
671 | * the parser there are no more device definitions coming. | | 804 | * the parser there are no more device definitions coming. |
672 | */ | | 805 | */ |
673 | if (include(_PATH_DEVNULL, ENDDEFS, 0, 0) != 0) | | 806 | if (include(_PATH_DEVNULL, ENDDEFS, 0, 0) != 0) |
674 | exit(1); | | 807 | exit(1); |
675 | | | 808 | |
676 | /* Include arch/${MACHINE}/conf/files.${MACHINE} */ | | 809 | /* Include arch/${MACHINE}/conf/files.${MACHINE} */ |
677 | (void)snprintf(buf, sizeof(buf), "arch/%s/conf/files.%s", | | 810 | (void)snprintf(buf, sizeof(buf), "arch/%s/conf/files.%s", |
678 | machine, machine); | | 811 | machine, machine); |
679 | if (include(buf, ENDFILE, 0, 0) != 0) | | 812 | if (include(buf, ENDFILE, 0, 0) != 0) |
680 | exit(1); | | 813 | exit(1); |
681 | | | 814 | |
682 | /* Include any arch/${MACHINE_SUBARCH}/conf/files.${MACHINE_SUBARCH} */ | | 815 | /* Include any arch/${MACHINE_SUBARCH}/conf/files.${MACHINE_SUBARCH} */ |
683 | for (nv = machinesubarches; nv != NULL; nv = nv->nv_next) { | | 816 | for (nv = machinesubarches; nv != NULL; nv = nv->nv_next) { |
684 | (void)snprintf(buf, sizeof(buf), "arch/%s/conf/files.%s", | | 817 | (void)snprintf(buf, sizeof(buf), "arch/%s/conf/files.%s", |
685 | nv->nv_name, nv->nv_name); | | 818 | nv->nv_name, nv->nv_name); |
686 | if (include(buf, ENDFILE, 0, 0) != 0) | | 819 | if (include(buf, ENDFILE, 0, 0) != 0) |
687 | exit(1); | | 820 | exit(1); |
688 | } | | 821 | } |
689 | | | 822 | |
690 | /* Include any arch/${MACHINE_ARCH}/conf/files.${MACHINE_ARCH} */ | | 823 | /* Include any arch/${MACHINE_ARCH}/conf/files.${MACHINE_ARCH} */ |
691 | if (machinearch != NULL) | | 824 | if (machinearch != NULL) |
692 | (void)snprintf(buf, sizeof(buf), "arch/%s/conf/files.%s", | | 825 | (void)snprintf(buf, sizeof(buf), "arch/%s/conf/files.%s", |
693 | machinearch, machinearch); | | 826 | machinearch, machinearch); |
694 | else | | 827 | else |
695 | strlcpy(buf, _PATH_DEVNULL, sizeof(buf)); | | 828 | strlcpy(buf, _PATH_DEVNULL, sizeof(buf)); |
696 | if (include(buf, ENDFILE, 0, 0) != 0) | | 829 | if (include(buf, ENDFILE, 0, 0) != 0) |
697 | exit(1); | | 830 | exit(1); |
698 | | | 831 | |
699 | /* | | 832 | /* |
700 | * Include the global conf/files. As the last thing | | 833 | * Include the global conf/files. As the last thing |
701 | * pushed on the stack, it will be processed first. | | 834 | * pushed on the stack, it will be processed first. |
702 | */ | | 835 | */ |
703 | if (include("conf/files", ENDFILE, 0, 0) != 0) | | 836 | if (include("conf/files", ENDFILE, 0, 0) != 0) |
704 | exit(1); | | 837 | exit(1); |
705 | | | 838 | |
706 | oktopackage = 1; | | 839 | oktopackage = 1; |
707 | } | | 840 | } |
708 | | | 841 | |
709 | static void | | 842 | static void |
710 | check_maxpart(void) | | 843 | check_maxpart(void) |
711 | { | | 844 | { |
712 | | | 845 | |
713 | if (maxpartitions <= 0 && ioconfname == NULL) { | | 846 | if (maxpartitions <= 0 && ioconfname == NULL) { |
714 | stop("cannot proceed without maxpartitions specifier"); | | 847 | stop("cannot proceed without maxpartitions specifier"); |
715 | } | | 848 | } |
716 | } | | 849 | } |
717 | | | 850 | |
718 | static void | | 851 | static void |
719 | check_version(void) | | 852 | check_version(void) |
720 | { | | 853 | { |
721 | /* | | 854 | /* |
722 | * In essence, version is 0 and is not supported anymore | | 855 | * In essence, version is 0 and is not supported anymore |
723 | */ | | 856 | */ |
724 | if (version < CONFIG_MINVERSION) | | 857 | if (version < CONFIG_MINVERSION) |
725 | stop("your sources are out of date -- please update."); | | 858 | stop("your sources are out of date -- please update."); |
726 | } | | 859 | } |
727 | | | 860 | |
728 | static void | | 861 | static void |
729 | app(struct nvlist *p, struct nvlist *q) | | 862 | app(struct nvlist *p, struct nvlist *q) |
730 | { | | 863 | { |
731 | while (p->nv_next) | | 864 | while (p->nv_next) |
732 | p = p->nv_next; | | 865 | p = p->nv_next; |
733 | p->nv_next = q; | | 866 | p->nv_next = q; |
734 | } | | 867 | } |
735 | | | 868 | |
736 | static struct nvlist * | | 869 | static struct nvlist * |
737 | mk_nsis(const char *name, int count, struct nvlist *adefs, int opt) | | 870 | mk_nsis(const char *name, int count, struct nvlist *adefs, int opt) |
738 | { | | 871 | { |
739 | struct nvlist *defs = adefs; | | 872 | struct nvlist *defs = adefs; |
740 | struct nvlist **p; | | 873 | struct nvlist **p; |
741 | char buf[200]; | | 874 | char buf[200]; |
742 | int i; | | 875 | int i; |
743 | | | 876 | |
744 | if (count <= 0) { | | 877 | if (count <= 0) { |
745 | fprintf(stderr, "config: array with <= 0 size: %s\n", name); | | 878 | fprintf(stderr, "config: array with <= 0 size: %s\n", name); |
746 | exit(1); | | 879 | exit(1); |
747 | } | | 880 | } |
748 | p = &defs; | | 881 | p = &defs; |
749 | for(i = 0; i < count; i++) { | | 882 | for(i = 0; i < count; i++) { |
750 | if (*p == NULL) | | 883 | if (*p == NULL) |
751 | *p = new_s("0"); | | 884 | *p = new_s("0"); |
752 | snprintf(buf, sizeof(buf), "%s%c%d", name, ARRCHR, i); | | 885 | snprintf(buf, sizeof(buf), "%s%c%d", name, ARRCHR, i); |
753 | (*p)->nv_name = i == 0 ? name : intern(buf); | | 886 | (*p)->nv_name = i == 0 ? name : intern(buf); |
754 | (*p)->nv_num = i > 0 || opt; | | 887 | (*p)->nv_num = i > 0 || opt; |
755 | p = &(*p)->nv_next; | | 888 | p = &(*p)->nv_next; |
756 | } | | 889 | } |
757 | *p = 0; | | 890 | *p = 0; |
758 | return defs; | | 891 | return defs; |
759 | } | | 892 | } |
760 | | | 893 | |
761 | | | 894 | |
762 | static struct nvlist * | | 895 | static struct nvlist * |
763 | mk_ns(const char *name, struct nvlist *vals) | | 896 | mk_ns(const char *name, struct nvlist *vals) |
764 | { | | 897 | { |
765 | struct nvlist *p; | | 898 | struct nvlist *p; |
766 | char buf[200]; | | 899 | char buf[200]; |
767 | int i; | | 900 | int i; |
768 | | | 901 | |
769 | for(i = 0, p = vals; p; i++, p = p->nv_next) { | | 902 | for(i = 0, p = vals; p; i++, p = p->nv_next) { |
770 | snprintf(buf, sizeof(buf), "%s%c%d", name, ARRCHR, i); | | 903 | snprintf(buf, sizeof(buf), "%s%c%d", name, ARRCHR, i); |
771 | p->nv_name = i == 0 ? name : intern(buf); | | 904 | p->nv_name = i == 0 ? name : intern(buf); |
772 | } | | 905 | } |
773 | return vals; | | 906 | return vals; |
774 | } | | 907 | } |
775 | | | 908 | |