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.11 2005/01/12 00:26:03 cpressey Exp $
96 static struct device cur;
97 static struct device *curp = 0;
102 struct file_list *ftab;
106 static int connect(char *, int);
107 static void yyerror(const char *s);
123 Device_spec SEMICOLON
124 = { newdev(&cur); } |
125 Config_spec SEMICOLON
135 if (machinename != NULL) {
136 errx(1, "%d: only one machine directive is allowed",
145 cp = malloc(sizeof(struct cputype));
146 bzero(cp, sizeof(*cp));
148 cp->cpu_next = cputype;
153 MAKEOPTIONS Mkopt_list
160 = { maxusers = $2; };
163 CONFIG System_id System_parameter_list
164 = { errx(1,"line %d: root/dump/swap specifications obsolete", yyline);}
174 op = malloc(sizeof(struct opt));
175 bzero(op, sizeof(*op));
176 op->op_name = strdup("KERNEL");
180 op->op_line = yyline + 1;
184 System_parameter_list:
185 System_parameter_list ID
196 snprintf(buf, sizeof(buf), "%s%d", $1, $2);
204 snprintf(buf, sizeof(buf), "%s%d%s", $1, $2, $3);
208 | Save_id NUMBER ID NUMBER
212 snprintf(buf, sizeof(buf), "%s%d%s%d",
217 | Save_id NUMBER ID NUMBER ID
221 snprintf(buf, sizeof(buf), "%s%d%s%d%s",
229 Opt_list COMMA Option
239 op = malloc(sizeof(struct opt));
240 bzero(op, sizeof(*op));
245 * op->op_line is 1-based; yyline is 0-based but is now 1
246 * larger than when `Save_id' was lexed.
248 op->op_line = yyline;
250 if (strchr(op->op_name, '=') != NULL)
251 errx(1, "line %d: The `=' in options should not be quoted", yyline);
253 Save_id EQUALS Opt_value
257 op = malloc(sizeof(struct opt));
258 bzero(op, sizeof(*op));
262 op->op_line = yyline + 1;
273 snprintf(buf, sizeof(buf), "%d", $1);
283 Mkopt_list COMMA Mkoption
289 Save_id EQUALS Opt_value
293 op = malloc(sizeof(struct opt));
294 bzero(op, sizeof(*op));
296 op->op_ownfile = 0; /* for now */
299 op->op_line = yyline + 1;
310 = { cur.d_type = DEVICE; } |
313 errx(1, "line %d: Obsolete keyword 'disk' found - use 'device'", yyline);
317 errx(1, "line %d: Obsolete keyword 'tape' found - use 'device'", yyline);
321 errx(1, "line %d: Obsolete keyword 'controller' found - use 'device'", yyline);
323 PSEUDO_DEVICE Init_dev Dev
326 cur.d_type = PSEUDO_DEVICE;
328 PSEUDO_DEVICE Init_dev Dev NUMBER
331 cur.d_type = PSEUDO_DEVICE;
339 cur.d_unit = UNKNOWN;
341 Init_dev Dev NUMBER Dev_info
349 = { init_dev(&cur); };
366 cur.d_conn = "nexus";
377 BUS NUMBER /* device scbus1 at ahc0 bus 1 - twin channel */
378 = { cur.d_bus = $2; } |
380 = { cur.d_target = $2; } |
382 = { cur.d_lun = $2; } |
384 = { cur.d_drive = $2; } |
386 = { cur.d_irq = $2; } |
388 = { cur.d_drq = $2; } |
390 = { cur.d_maddr = $2; } |
392 = { cur.d_msize = $2; } |
394 = { cur.d_port = $2; } |
396 = { cur.d_portn = $2; } |
398 = { cur.d_flags = $2; } |
400 = { cur.d_disabled = 1; } |
403 errx(1, "line %d: Obsolete keyword 'conflicts' found", yyline);
409 yyerror(const char *s)
412 errx(1, "line %d: %s", yyline + 1, s);
416 * add a device to the list of devices
419 newdev(struct device *dp)
421 struct device *np, *xp;
423 if (dp->d_unit >= 0) {
424 for (xp = dtab; xp != NULL; xp = xp->d_next) {
425 if ((xp->d_unit == dp->d_unit) &&
426 !strcmp(xp->d_name, dp->d_name)) {
427 errx(1, "line %d: already seen device %s%d",
428 yyline, xp->d_name, xp->d_unit);
432 np = malloc(sizeof(*np));
433 bzero(np, sizeof(*np));
445 * find the pointer to connect to the given device and number.
446 * returns 0 if no such device and prints an error message
449 connect(char *dev, int num)
454 for (dp = dtab; dp != NULL; dp = dp->d_next)
455 if (!strcmp(dp->d_name, dev))
458 snprintf(errbuf, sizeof(errbuf),
459 "no %s's to wildcard", dev);
465 for (dp = dtab; dp != NULL; dp = dp->d_next) {
466 if ((num != dp->d_unit) || strcmp(dev, dp->d_name))
468 if (dp->d_type != DEVICE) {
469 snprintf(errbuf, sizeof(errbuf),
470 "%s connected to non-device", dev);
476 snprintf(errbuf, sizeof(errbuf), "%s %d not defined", dev, num);
482 init_dev(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;