4 struct file_list *file;
48 %type <str> device_name
53 * Copyright (c) 1988, 1993
54 * The Regents of the University of California. All rights reserved.
56 * Redistribution and use in source and binary forms, with or without
57 * modification, are permitted provided that the following conditions
59 * 1. Redistributions of source code must retain the above copyright
60 * notice, this list of conditions and the following disclaimer.
61 * 2. Redistributions in binary form must reproduce the above copyright
62 * notice, this list of conditions and the following disclaimer in the
63 * documentation and/or other materials provided with the distribution.
64 * 3. All advertising materials mentioning features or use of this software
65 * must display the following acknowledgement:
66 * This product includes software developed by the University of
67 * California, Berkeley and its contributors.
68 * 4. Neither the name of the University nor the names of its contributors
69 * may be used to endorse or promote products derived from this software
70 * without specific prior written permission.
72 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
73 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
74 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
75 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
76 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
77 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
78 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
79 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
80 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
81 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
84 * @(#)config.y 8.1 (Berkeley) 6/6/93
85 * $FreeBSD: src/usr.sbin/config/config.y,v 1.42.2.1 2001/01/23 00:09:32 peter Exp $
86 * $DragonFly: src/usr.sbin/config/config.y,v 1.7 2004/03/04 20:44:49 eirikn Exp $
96 static struct device cur;
97 static struct device *curp = 0;
102 struct file_list *ftab;
106 #define ns(s) strdup(s)
108 static int connect(char *, int);
109 static void yyerror(char *s);
125 Device_spec SEMICOLON
126 = { newdev(&cur); } |
127 Config_spec SEMICOLON
137 if (machinename != NULL) {
138 errx(1, "%d: only one machine directive is allowed",
147 cp = (struct cputype *)malloc(sizeof(struct cputype));
148 memset(cp, 0, sizeof(*cp));
150 cp->cpu_next = cputype;
155 MAKEOPTIONS Mkopt_list
162 = { maxusers = $2; };
165 CONFIG System_id System_parameter_list
166 = { errx(1,"line %d: root/dump/swap specifications obsolete", yyline);}
176 op = (struct opt *)malloc(sizeof(struct opt));
177 memset(op, 0, sizeof(*op));
178 op->op_name = ns("KERNEL");
182 op->op_line = yyline + 1;
186 System_parameter_list:
187 System_parameter_list ID
198 (void)snprintf(buf, sizeof(buf), "%s%d", $1, $2);
199 $$ = ns(buf); free($1);
205 (void)snprintf(buf, sizeof(buf), "%s%d%s", $1, $2, $3);
206 $$ = ns(buf); free($1);
208 | Save_id NUMBER ID NUMBER
212 (void)snprintf(buf, sizeof(buf), "%s%d%s%d",
214 $$ = ns(buf); free($1);
216 | Save_id NUMBER ID NUMBER ID
220 (void)snprintf(buf, sizeof(buf), "%s%d%s%d%s",
222 $$ = ns(buf); free($1);
227 Opt_list COMMA Option
238 op = (struct opt *)malloc(sizeof(struct opt));
239 memset(op, 0, sizeof(*op));
244 * op->op_line is 1-based; yyline is 0-based but is now 1
245 * larger than when `Save_id' was lexed.
247 op->op_line = yyline;
249 if ((s = strchr(op->op_name, '=')))
250 errx(1, "line %d: The `=' in options should not be quoted", yyline);
252 Save_id EQUALS Opt_value
256 op = (struct opt *)malloc(sizeof(struct opt));
257 memset(op, 0, sizeof(*op));
261 op->op_line = yyline + 1;
272 (void)snprintf(buf, sizeof(buf), "%d", $1);
282 Mkopt_list COMMA Mkoption
288 Save_id EQUALS Opt_value
292 op = (struct opt *)malloc(sizeof(struct opt));
293 memset(op, 0, sizeof(*op));
295 op->op_ownfile = 0; /* for now */
298 op->op_line = yyline + 1;
309 = { cur.d_type = DEVICE; } |
312 errx(1, "line %d: Obsolete keyword 'disk' found - use 'device'", yyline);
316 errx(1, "line %d: Obsolete keyword 'tape' found - use 'device'", yyline);
320 errx(1, "line %d: Obsolete keyword 'controller' found - use 'device'", yyline);
322 PSEUDO_DEVICE Init_dev Dev
325 cur.d_type = PSEUDO_DEVICE;
327 PSEUDO_DEVICE Init_dev Dev NUMBER
330 cur.d_type = PSEUDO_DEVICE;
338 cur.d_unit = UNKNOWN;
340 Init_dev Dev NUMBER Dev_info
348 = { init_dev(&cur); };
365 cur.d_conn = "nexus";
376 BUS NUMBER /* device scbus1 at ahc0 bus 1 - twin channel */
377 = { cur.d_bus = $2; } |
379 = { cur.d_target = $2; } |
381 = { cur.d_lun = $2; } |
383 = { cur.d_drive = $2; } |
385 = { cur.d_irq = $2; } |
387 = { cur.d_drq = $2; } |
389 = { cur.d_maddr = $2; } |
391 = { cur.d_msize = $2; } |
393 = { cur.d_port = $2; } |
395 = { cur.d_portn = $2; } |
397 = { cur.d_flags = $2; } |
399 = { cur.d_disabled = 1; } |
402 errx(1, "line %d: Obsolete keyword 'conflicts' found", yyline);
411 errx(1, "line %d: %s", yyline + 1, s);
415 * add a device to the list of devices
418 newdev(struct device *dp)
420 struct device *np, *xp;
422 if (dp->d_unit >= 0) {
423 for (xp = dtab; xp != NULL; xp = xp->d_next) {
424 if ((xp->d_unit == dp->d_unit) &&
425 eq(xp->d_name, dp->d_name)) {
426 errx(1, "line %d: already seen device %s%d",
427 yyline, xp->d_name, xp->d_unit);
431 np = (struct device *)malloc(sizeof(*np));
432 memset(np, 0, sizeof(*np));
444 * find the pointer to connect to the given device and number.
445 * returns 0 if no such device and prints an error message
448 connect(char *dev, int num)
453 for (dp = dtab; dp != NULL; dp = dp->d_next)
454 if (eq(dp->d_name, dev))
457 (void)snprintf(errbuf, sizeof(errbuf),
458 "no %s's to wildcard", dev);
464 for (dp = dtab; dp != NULL; dp = dp->d_next) {
465 if ((num != dp->d_unit) || !eq(dev, dp->d_name))
467 if (dp->d_type != DEVICE) {
468 (void)snprintf(errbuf, sizeof(errbuf),
469 "%s connected to non-device", dev);
475 (void)snprintf(errbuf, sizeof(errbuf), "%s %d not defined", dev, num);
481 init_dev(struct device *dp)
484 dp->d_name = "OHNO!!!";
489 dp->d_bus = dp->d_lun = dp->d_target = dp->d_drive = dp->d_unit = \
490 dp->d_count = UNKNOWN;