4 struct file_list *file;
13 %token CONFIG_MACHINE_ARCH
14 %token CONFIG_PLATFORM
50 %type <str> device_name
55 * Copyright (c) 1988, 1993
56 * The Regents of the University of California. All rights reserved.
58 * Redistribution and use in source and binary forms, with or without
59 * modification, are permitted provided that the following conditions
61 * 1. Redistributions of source code must retain the above copyright
62 * notice, this list of conditions and the following disclaimer.
63 * 2. Redistributions in binary form must reproduce the above copyright
64 * notice, this list of conditions and the following disclaimer in the
65 * documentation and/or other materials provided with the distribution.
66 * 3. All advertising materials mentioning features or use of this software
67 * must display the following acknowledgement:
68 * This product includes software developed by the University of
69 * California, Berkeley and its contributors.
70 * 4. Neither the name of the University nor the names of its contributors
71 * may be used to endorse or promote products derived from this software
72 * without specific prior written permission.
74 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
75 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
76 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
77 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
78 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
79 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
80 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
81 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
82 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
83 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
86 * @(#)config.y 8.1 (Berkeley) 6/6/93
87 * $FreeBSD: src/usr.sbin/config/config.y,v 1.42.2.1 2001/01/23 00:09:32 peter Exp $
88 * $DragonFly: src/usr.sbin/config/config.y,v 1.14 2007/01/19 07:23:43 dillon Exp $
98 static struct device cur;
99 static struct device *curp = 0;
104 struct file_list *ftab;
108 static int connect(char *, int);
109 static void yyerror(const char *s);
125 Device_spec SEMICOLON
126 = { newdev(&cur); } |
127 Config_spec SEMICOLON
135 CONFIG_PLATFORM Save_id
137 if (platformname != NULL) {
138 errx(1, "%d: only one platform directive is allowed",
143 CONFIG_MACHINE Save_id
145 if (machinename != NULL) {
146 errx(1, "%d: only one machine directive is allowed",
151 CONFIG_MACHINE_ARCH Save_id
153 if (machinearchname != NULL) {
154 errx(1, "%d: only one machine_arch directive is allowed",
157 machinearchname = $2;
163 cp = malloc(sizeof(struct cputype));
164 bzero(cp, sizeof(*cp));
166 cp->cpu_next = cputype;
171 MAKEOPTIONS Mkopt_list
178 = { maxusers = $2; };
181 CONFIG System_id System_parameter_list
182 = { errx(1,"line %d: root/dump/swap specifications obsolete", yyline);}
192 op = malloc(sizeof(struct opt));
193 bzero(op, sizeof(*op));
194 op->op_name = strdup("KERNEL");
198 op->op_line = yyline + 1;
202 System_parameter_list:
203 System_parameter_list ID
214 snprintf(buf, sizeof(buf), "%s%d", $1, $2);
222 snprintf(buf, sizeof(buf), "%s%d%s", $1, $2, $3);
226 | Save_id NUMBER ID NUMBER
230 snprintf(buf, sizeof(buf), "%s%d%s%d",
235 | Save_id NUMBER ID NUMBER ID
239 snprintf(buf, sizeof(buf), "%s%d%s%d%s",
247 Opt_list COMMA Option
257 op = malloc(sizeof(struct opt));
258 bzero(op, sizeof(*op));
263 * op->op_line is 1-based; yyline is 0-based but is now 1
264 * larger than when `Save_id' was lexed.
266 op->op_line = yyline;
268 if (strchr(op->op_name, '=') != NULL)
269 errx(1, "line %d: The `=' in options should not be quoted", yyline);
271 Save_id EQUALS Opt_value
275 op = malloc(sizeof(struct opt));
276 bzero(op, sizeof(*op));
280 op->op_line = yyline + 1;
291 snprintf(buf, sizeof(buf), "%d", $1);
301 Mkopt_list COMMA Mkoption
307 Save_id EQUALS Opt_value
311 op = malloc(sizeof(struct opt));
312 bzero(op, sizeof(*op));
314 op->op_ownfile = 0; /* for now */
317 op->op_line = yyline + 1;
328 = { cur.d_type = DEVICE; } |
331 errx(1, "line %d: Obsolete keyword 'disk' found - use 'device'", yyline);
335 errx(1, "line %d: Obsolete keyword 'tape' found - use 'device'", yyline);
339 errx(1, "line %d: Obsolete keyword 'controller' found - use 'device'", yyline);
341 PSEUDO_DEVICE Init_dev Dev
344 cur.d_type = PSEUDO_DEVICE;
346 PSEUDO_DEVICE Init_dev Dev NUMBER
349 cur.d_type = PSEUDO_DEVICE;
357 cur.d_unit = UNKNOWN;
359 Init_dev Dev NUMBER Dev_info
367 = { init_dev(&cur); };
384 cur.d_conn = "nexus";
395 BUS NUMBER /* device scbus1 at ahc0 bus 1 - twin channel */
396 = { cur.d_bus = $2; } |
398 = { cur.d_target = $2; } |
400 = { cur.d_lun = $2; } |
402 = { cur.d_drive = $2; } |
404 = { cur.d_irq = $2; } |
406 = { cur.d_drq = $2; } |
408 = { cur.d_maddr = $2; } |
410 = { cur.d_msize = $2; } |
412 = { cur.d_port = $2; } |
414 = { cur.d_portn = $2; } |
416 = { cur.d_flags = $2; } |
418 = { cur.d_disabled = 1; } |
421 errx(1, "line %d: Obsolete keyword 'conflicts' found", yyline);
427 yyerror(const char *s)
430 errx(1, "line %d: %s", yyline + 1, s);
434 * add a device to the list of devices
437 newdev(struct device *dp)
439 struct device *np, *xp;
441 if (dp->d_unit >= 0) {
442 for (xp = dtab; xp != NULL; xp = xp->d_next) {
443 if ((xp->d_unit == dp->d_unit) &&
444 !strcmp(xp->d_name, dp->d_name)) {
445 errx(1, "line %d: already seen device %s%d",
446 yyline, xp->d_name, xp->d_unit);
450 np = malloc(sizeof(*np));
451 bzero(np, sizeof(*np));
463 * find the pointer to connect to the given device and number.
464 * returns 0 if no such device and prints an error message
467 connect(char *dev, int num)
472 for (dp = dtab; dp != NULL; dp = dp->d_next)
473 if (!strcmp(dp->d_name, dev))
476 snprintf(errbuf, sizeof(errbuf),
477 "no %s's to wildcard", dev);
483 for (dp = dtab; dp != NULL; dp = dp->d_next) {
484 if ((num != dp->d_unit) || strcmp(dev, dp->d_name))
486 if (dp->d_type != DEVICE) {
487 snprintf(errbuf, sizeof(errbuf),
488 "%s connected to non-device", dev);
494 snprintf(errbuf, sizeof(errbuf), "%s %d not defined", dev, num);
500 init_dev(struct device *dp)
503 dp->d_name = "OHNO!!!";
508 dp->d_bus = dp->d_lun = dp->d_target = dp->d_drive = dp->d_unit =
509 dp->d_count = UNKNOWN;