4 struct file_list
*file
;
13 %token CONFIG_MACHINE_ARCH
49 %type
<str
> device_name
54 * Copyright (c) 1988, 1993
55 * The Regents of the University of California. All rights reserved.
57 * Redistribution and use in source and binary forms, with or without
58 * modification, are permitted provided that the following conditions
60 * 1. Redistributions of source code must retain the above copyright
61 * notice, this list of conditions and the following disclaimer.
62 * 2. Redistributions in binary form must reproduce the above copyright
63 * notice, this list of conditions and the following disclaimer in the
64 * documentation and/or other materials provided with the distribution.
65 * 3. All advertising materials mentioning features or use of this software
66 * must display the following acknowledgement:
67 * This product includes software developed by the University of
68 * California, Berkeley and its contributors.
69 * 4. Neither the name of the University nor the names of its contributors
70 * may be used to endorse or promote products derived from this software
71 * without specific prior written permission.
73 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
74 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
75 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
76 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
77 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
78 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
79 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
80 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
81 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
82 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
85 * @(#)config.y 8.1 (Berkeley) 6/6/93
86 * $FreeBSD: src/usr.sbin/config/config.y,v 1.42.2.1 2001/01/23 00:09:32 peter Exp $
87 * $DragonFly: src/usr.sbin/config/config.y,v 1.13 2006/11/07 06:57:02 dillon Exp $
97 static struct device cur
;
98 static struct device
*curp
= 0;
103 struct file_list
*ftab
;
107 static int connect
(char *, int);
108 static void yyerror(const char *s
);
124 Device_spec SEMICOLON
125 = { newdev
(&cur
); } |
126 Config_spec SEMICOLON
134 CONFIG_MACHINE Save_id
136 if
(machinename
!= NULL
) {
137 errx
(1, "%d: only one machine directive is allowed",
142 CONFIG_MACHINE_ARCH Save_id
144 if
(machinearchname
!= NULL
) {
145 errx
(1, "%d: only one machine_arch directive is allowed",
148 machinearchname
= $2;
154 cp
= malloc
(sizeof
(struct cputype
));
155 bzero
(cp
, sizeof
(*cp
));
157 cp
->cpu_next
= cputype
;
162 MAKEOPTIONS Mkopt_list
169 = { maxusers
= $2; };
172 CONFIG System_id System_parameter_list
173 = { errx
(1,"line %d: root/dump/swap specifications obsolete", yyline
);}
183 op
= malloc
(sizeof
(struct opt
));
184 bzero
(op
, sizeof
(*op
));
185 op
->op_name
= strdup
("KERNEL");
189 op
->op_line
= yyline
+ 1;
193 System_parameter_list:
194 System_parameter_list ID
205 snprintf
(buf
, sizeof
(buf
), "%s%d", $1, $2);
213 snprintf
(buf
, sizeof
(buf
), "%s%d%s", $1, $2, $3);
217 | Save_id NUMBER ID NUMBER
221 snprintf
(buf
, sizeof
(buf
), "%s%d%s%d",
226 | Save_id NUMBER ID NUMBER ID
230 snprintf
(buf
, sizeof
(buf
), "%s%d%s%d%s",
238 Opt_list COMMA Option
248 op
= malloc
(sizeof
(struct opt
));
249 bzero
(op
, sizeof
(*op
));
254 * op->op_line is 1-based; yyline is 0-based but is now 1
255 * larger than when `Save_id' was lexed.
257 op
->op_line
= yyline
;
259 if
(strchr
(op
->op_name
, '=') != NULL
)
260 errx
(1, "line %d: The `=' in options should not be quoted", yyline
);
262 Save_id EQUALS Opt_value
266 op
= malloc
(sizeof
(struct opt
));
267 bzero
(op
, sizeof
(*op
));
271 op
->op_line
= yyline
+ 1;
282 snprintf
(buf
, sizeof
(buf
), "%d", $1);
292 Mkopt_list COMMA Mkoption
298 Save_id EQUALS Opt_value
302 op
= malloc
(sizeof
(struct opt
));
303 bzero
(op
, sizeof
(*op
));
305 op
->op_ownfile
= 0; /* for now */
308 op
->op_line
= yyline
+ 1;
319 = { cur.d_type
= DEVICE
; } |
322 errx
(1, "line %d: Obsolete keyword 'disk' found - use 'device'", yyline
);
326 errx
(1, "line %d: Obsolete keyword 'tape' found - use 'device'", yyline
);
330 errx
(1, "line %d: Obsolete keyword 'controller' found - use 'device'", yyline
);
332 PSEUDO_DEVICE Init_dev Dev
335 cur.d_type
= PSEUDO_DEVICE
;
337 PSEUDO_DEVICE Init_dev Dev NUMBER
340 cur.d_type
= PSEUDO_DEVICE
;
348 cur.d_unit
= UNKNOWN
;
350 Init_dev Dev NUMBER Dev_info
358 = { init_dev
(&cur
); };
375 cur.d_conn
= "nexus";
386 BUS NUMBER
/* device scbus1 at ahc0 bus 1 - twin channel */
387 = { cur.d_bus
= $2; } |
389 = { cur.d_target
= $2; } |
391 = { cur.d_lun
= $2; } |
393 = { cur.d_drive
= $2; } |
395 = { cur.d_irq
= $2; } |
397 = { cur.d_drq
= $2; } |
399 = { cur.d_maddr
= $2; } |
401 = { cur.d_msize
= $2; } |
403 = { cur.d_port
= $2; } |
405 = { cur.d_portn
= $2; } |
407 = { cur.d_flags
= $2; } |
409 = { cur.d_disabled
= 1; } |
412 errx
(1, "line %d: Obsolete keyword 'conflicts' found", yyline
);
418 yyerror(const char *s
)
421 errx
(1, "line %d: %s", yyline
+ 1, s
);
425 * add a device to the list of devices
428 newdev
(struct device
*dp
)
430 struct device
*np
, *xp
;
432 if
(dp
->d_unit
>= 0) {
433 for
(xp
= dtab
; xp
!= NULL
; xp
= xp
->d_next
) {
434 if
((xp
->d_unit
== dp
->d_unit
) &&
435 !strcmp
(xp
->d_name
, dp
->d_name
)) {
436 errx
(1, "line %d: already seen device %s%d",
437 yyline
, xp
->d_name
, xp
->d_unit
);
441 np
= malloc
(sizeof
(*np
));
442 bzero
(np
, sizeof
(*np
));
454 * find the pointer to connect to the given device and number.
455 * returns 0 if no such device and prints an error message
458 connect
(char *dev
, int num
)
463 for
(dp
= dtab
; dp
!= NULL
; dp
= dp
->d_next
)
464 if
(!strcmp
(dp
->d_name
, dev
))
467 snprintf
(errbuf
, sizeof
(errbuf
),
468 "no %s's to wildcard", dev
);
474 for
(dp
= dtab
; dp
!= NULL
; dp
= dp
->d_next
) {
475 if
((num
!= dp
->d_unit
) || strcmp
(dev
, dp
->d_name
))
477 if
(dp
->d_type
!= DEVICE
) {
478 snprintf
(errbuf
, sizeof
(errbuf
),
479 "%s connected to non-device", dev
);
485 snprintf
(errbuf
, sizeof
(errbuf
), "%s %d not defined", dev
, num
);
491 init_dev
(struct device
*dp
)
494 dp
->d_name
= "OHNO!!!";
499 dp
->d_bus
= dp
->d_lun
= dp
->d_target
= dp
->d_drive
= dp
->d_unit
=
500 dp
->d_count
= UNKNOWN
;