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 $
95 static struct device cur;
96 static struct device *curp = 0;
101 struct file_list *ftab;
105 #define ns(s) strdup(s)
107 static int connect __P((char *, int));
108 static void yyerror __P((char *s));
124 Device_spec SEMICOLON
125 = { newdev(&cur); } |
126 Config_spec SEMICOLON
136 if (!strcmp($2, "i386")) {
137 machine = MACHINE_I386;
138 machinename = "i386";
139 } else if (!strcmp($2, "pc98")) {
140 machine = MACHINE_PC98;
141 machinename = "pc98";
142 } else if (!strcmp($2, "alpha")) {
143 machine = MACHINE_ALPHA;
144 machinename = "alpha";
146 yyerror("Unknown machine type");
151 (struct cputype *)malloc(sizeof (struct cputype));
152 memset(cp, 0, sizeof(*cp));
154 cp->cpu_next = cputype;
159 MAKEOPTIONS Mkopt_list
166 = { maxusers = $2; };
169 CONFIG System_id System_parameter_list
170 = { errx(1,"line %d: root/dump/swap specifications obsolete", yyline);}
178 struct opt *op = (struct opt *)malloc(sizeof (struct opt));
179 memset(op, 0, sizeof(*op));
180 op->op_name = ns("KERNEL");
184 op->op_line = yyline + 1;
188 System_parameter_list:
189 System_parameter_list ID
200 (void) snprintf(buf, sizeof(buf), "%s%d", $1, $2);
201 $$ = ns(buf); free($1);
207 (void) snprintf(buf, sizeof(buf), "%s%d%s", $1, $2, $3);
208 $$ = ns(buf); free($1);
210 | Save_id NUMBER ID NUMBER
214 (void) snprintf(buf, sizeof(buf), "%s%d%s%d",
216 $$ = ns(buf); free($1);
218 | Save_id NUMBER ID NUMBER ID
222 (void) snprintf(buf, sizeof(buf), "%s%d%s%d%s",
224 $$ = ns(buf); free($1);
229 Opt_list COMMA Option
237 struct opt *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
254 struct opt *op = (struct opt *)malloc(sizeof (struct opt));
255 memset(op, 0, sizeof(*op));
259 op->op_line = yyline + 1;
270 (void) snprintf(buf, sizeof(buf), "%d", $1);
280 Mkopt_list COMMA Mkoption
286 Save_id EQUALS Opt_value
288 struct opt *op = (struct opt *)malloc(sizeof (struct opt));
289 memset(op, 0, sizeof(*op));
291 op->op_ownfile = 0; /* for now */
294 op->op_line = yyline + 1;
305 = { cur.d_type = DEVICE; } |
308 errx(1, "line %d: Obsolete keyword 'disk' found - use 'device'", yyline);
312 errx(1, "line %d: Obsolete keyword 'tape' found - use 'device'", yyline);
316 errx(1, "line %d: Obsolete keyword 'controller' found - use 'device'", yyline);
318 PSEUDO_DEVICE Init_dev Dev
321 cur.d_type = PSEUDO_DEVICE;
323 PSEUDO_DEVICE Init_dev Dev NUMBER
326 cur.d_type = PSEUDO_DEVICE;
334 cur.d_unit = UNKNOWN;
336 Init_dev Dev NUMBER Dev_info
344 = { init_dev(&cur); };
361 cur.d_conn = "nexus";
372 BUS NUMBER /* device scbus1 at ahc0 bus 1 - twin channel */
373 = { cur.d_bus = $2; } |
375 = { cur.d_target = $2; } |
377 = { cur.d_lun = $2; } |
379 = { cur.d_drive = $2; } |
381 = { cur.d_irq = $2; } |
383 = { cur.d_drq = $2; } |
385 = { cur.d_maddr = $2; } |
387 = { cur.d_msize = $2; } |
389 = { cur.d_port = $2; } |
391 = { cur.d_portn = $2; } |
393 = { cur.d_flags = $2; } |
395 = { cur.d_disabled = 1; } |
398 errx(1, "line %d: Obsolete keyword 'conflicts' found", yyline);
408 errx(1, "line %d: %s", yyline + 1, s);
412 * add a device to the list of devices
416 register struct device *dp;
418 register struct device *np, *xp;
420 if (dp->d_unit >= 0) {
421 for (xp = dtab; xp != 0; xp = xp->d_next) {
422 if ((xp->d_unit == dp->d_unit) &&
423 eq(xp->d_name, dp->d_name)) {
424 errx(1, "line %d: already seen device %s%d",
425 yyline, xp->d_name, xp->d_unit);
429 np = (struct device *) malloc(sizeof *np);
430 memset(np, 0, sizeof(*np));
442 * find the pointer to connect to the given device and number.
443 * returns 0 if no such device and prints an error message
450 register struct device *dp;
453 for (dp = dtab; dp != 0; 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 != 0; 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);
482 register struct device *dp;
485 dp->d_name = "OHNO!!!";
490 dp->d_bus = dp->d_lun = dp->d_target = dp->d_drive = dp->d_unit = \
491 dp->d_count = UNKNOWN;
492 dp->d_port = (char *)0;