4 struct file_list
*file
;
13 %token CONFIG_MACHINE_ARCH
14 %token CONFIG_PLATFORM
46 %type
<str
> device_name
51 * Copyright (c) 1988, 1993
52 * The Regents of the University of California. All rights reserved.
54 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions
57 * 1. Redistributions of source code must retain the above copyright
58 * notice, this list of conditions and the following disclaimer.
59 * 2. Redistributions in binary form must reproduce the above copyright
60 * notice, this list of conditions and the following disclaimer in the
61 * documentation and/or other materials provided with the distribution.
62 * 3. Neither the name of the University nor the names of its contributors
63 * may be used to endorse or promote products derived from this software
64 * without specific prior written permission.
66 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
67 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
68 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
69 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
70 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
71 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
72 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
73 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
74 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
75 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
78 * @(#)config.y 8.1 (Berkeley) 6/6/93
79 * $FreeBSD: src/usr.sbin/config/config.y,v 1.42.2.1 2001/01/23 00:09:32 peter Exp $
89 static struct device cur
;
90 static struct device
*curp
= 0;
95 struct file_list
*ftab
;
99 static int connect
(char *, int);
100 static void yyerror(const char *s
);
102 #if YYPATCH < 20180510
119 Device_spec SEMICOLON
{ newdev
(&cur
); }
121 Config_spec SEMICOLON
129 CONFIG_PLATFORM Save_id
{
130 if
(platformname
!= NULL
) {
131 errx
(1, "%d: only one platform directive is allowed",
136 CONFIG_MACHINE Save_id
{
137 if
(machinename
!= NULL
) {
138 errx
(1, "%d: only one machine directive is allowed",
143 CONFIG_MACHINE_ARCH Save_id
{
144 if
(machinearchname
!= NULL
) {
145 errx
(1, "%d: only one machine_arch directive is allowed",
148 machinearchname
= $2;
153 cp
= malloc
(sizeof
(struct cputype
));
154 bzero
(cp
, sizeof
(*cp
));
156 cp
->cpu_next
= cputype
;
161 MAKEOPTIONS Mkopt_list
163 IDENT ID
{ ident
= $2; }
167 MAXUSERS NUMBER
{ maxusers
= $2; };
170 CONFIG System_id System_parameter_list
{
171 errx
(1,"line %d: root/dump/swap specifications obsolete",
181 op
= malloc
(sizeof
(struct opt
));
182 bzero
(op
, sizeof
(*op
));
183 op
->op_name
= strdup
("KERNEL");
187 op
->op_line
= yyline
+ 1;
191 System_parameter_list:
192 System_parameter_list ID
201 snprintf
(buf
, sizeof
(buf
), "%s%d", $1, $2);
205 | Save_id NUMBER ID
{
208 snprintf
(buf
, sizeof
(buf
), "%s%d%s", $1, $2, $3);
212 | Save_id NUMBER ID NUMBER
{
215 snprintf
(buf
, sizeof
(buf
), "%s%d%s%d",
220 | Save_id NUMBER ID NUMBER ID
{
223 snprintf
(buf
, sizeof
(buf
), "%s%d%s%d%s",
231 Opt_list COMMA Option
240 op
= malloc
(sizeof
(struct opt
));
241 bzero
(op
, sizeof
(*op
));
246 * op->op_line is 1-based; yyline is 0-based but is now 1
247 * larger than when `Save_id' was lexed.
249 op
->op_line
= yyline
;
251 if
(strchr
(op
->op_name
, '=') != NULL
)
252 errx
(1, "line %d: The `=' in options should not be quoted", yyline
);
254 Save_id EQUALS Opt_value
{
257 op
= malloc
(sizeof
(struct opt
));
258 bzero
(op
, sizeof
(*op
));
262 op
->op_line
= yyline
+ 1;
271 snprintf
(buf
, sizeof
(buf
), "%d", $1);
280 Mkopt_list COMMA Mkoption
286 Save_id EQUALS Opt_value
{
289 op
= malloc
(sizeof
(struct opt
));
290 bzero
(op
, sizeof
(*op
));
292 op
->op_ownfile
= 0; /* for now */
295 op
->op_line
= yyline
+ 1;
304 DEVICE Dev_spec
{ cur.d_type
= DEVICE
; }
306 PSEUDO_DEVICE Init_dev Dev
{
308 cur.d_type
= PSEUDO_DEVICE
;
310 PSEUDO_DEVICE Init_dev Dev NUMBER
{
312 cur.d_type
= PSEUDO_DEVICE
;
319 cur.d_unit
= UNKNOWN
;
321 Init_dev Dev NUMBER Dev_info
{
327 /* lambda */ { init_dev
(&cur
); };
342 cur.d_conn
= "nexus";
353 BUS NUMBER
{ cur.d_bus
= $2; }
355 TARGET NUMBER
{ cur.d_target
= $2; }
357 UNIT NUMBER
{ cur.d_lun
= $2; }
359 DRIVE NUMBER
{ cur.d_drive
= $2; }
361 IRQ NUMBER
{ cur.d_irq
= $2; }
363 DRQ NUMBER
{ cur.d_drq
= $2; }
365 IOMEM NUMBER
{ cur.d_maddr
= $2; }
367 IOSIZ NUMBER
{ cur.d_msize
= $2; }
369 PORT device_name
{ cur.d_port
= $2; }
371 PORT NUMBER
{ cur.d_portn
= $2; }
373 FLAGS NUMBER
{ cur.d_flags
= $2; }
375 DISABLE
{ cur.d_disabled
= 1; }
380 yyerror(const char *s
)
383 errx
(1, "line %d: %s", yyline
+ 1, s
);
387 * add a device to the list of devices
390 newdev
(struct device
*dp
)
392 struct device
*np
, *xp
;
394 if
(dp
->d_unit
>= 0) {
395 for
(xp
= dtab
; xp
!= NULL
; xp
= xp
->d_next
) {
396 if
((xp
->d_unit
== dp
->d_unit
) &&
397 !strcmp
(xp
->d_name
, dp
->d_name
)) {
398 errx
(1, "line %d: already seen device %s%d",
399 yyline
, xp
->d_name
, xp
->d_unit
);
403 np
= malloc
(sizeof
(*np
));
404 bzero
(np
, sizeof
(*np
));
416 * find the pointer to connect to the given device and number.
417 * returns 0 if no such device and prints an error message
420 connect
(char *dev
, int num
)
425 for
(dp
= dtab
; dp
!= NULL
; dp
= dp
->d_next
)
426 if
(!strcmp
(dp
->d_name
, dev
))
429 snprintf
(errbuf
, sizeof
(errbuf
),
430 "no %s's to wildcard", dev
);
436 for
(dp
= dtab
; dp
!= NULL
; dp
= dp
->d_next
) {
437 if
((num
!= dp
->d_unit
) || strcmp
(dev
, dp
->d_name
))
439 if
(dp
->d_type
!= DEVICE
) {
440 snprintf
(errbuf
, sizeof
(errbuf
),
441 "%s connected to non-device", dev
);
447 snprintf
(errbuf
, sizeof
(errbuf
), "%s %d not defined", dev
, num
);
453 init_dev
(struct device
*dp
)
456 dp
->d_name
= "OHNO!!!";
461 dp
->d_bus
= dp
->d_lun
= dp
->d_target
= dp
->d_drive
= dp
->d_unit
=
462 dp
->d_count
= UNKNOWN
;