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. All advertising materials mentioning features or use of this software
63 * must display the following acknowledgement:
64 * This product includes software developed by the University of
65 * California, Berkeley and its contributors.
66 * 4. Neither the name of the University nor the names of its contributors
67 * may be used to endorse or promote products derived from this software
68 * without specific prior written permission.
70 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
71 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
72 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
73 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
74 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
75 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
76 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
77 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
78 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
79 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
82 * @(#)config.y 8.1 (Berkeley) 6/6/93
83 * $FreeBSD: src/usr.sbin/config/config.y,v 1.42.2.1 2001/01/23 00:09:32 peter Exp $
84 * $DragonFly: src/usr.sbin/config/config.y,v 1.15 2008/05/01 09:24:42 swildner Exp $
94 static struct device cur
;
95 static struct device
*curp
= 0;
100 struct file_list
*ftab
;
104 static int connect
(char *, int);
105 static void yyerror(const char *s
);
121 Device_spec SEMICOLON
122 = { newdev
(&cur
); } |
123 Config_spec SEMICOLON
131 CONFIG_PLATFORM Save_id
133 if
(platformname
!= NULL
) {
134 errx
(1, "%d: only one platform directive is allowed",
139 CONFIG_MACHINE Save_id
141 if
(machinename
!= NULL
) {
142 errx
(1, "%d: only one machine directive is allowed",
147 CONFIG_MACHINE_ARCH Save_id
149 if
(machinearchname
!= NULL
) {
150 errx
(1, "%d: only one machine_arch directive is allowed",
153 machinearchname
= $2;
159 cp
= malloc
(sizeof
(struct cputype
));
160 bzero
(cp
, sizeof
(*cp
));
162 cp
->cpu_next
= cputype
;
167 MAKEOPTIONS Mkopt_list
174 = { maxusers
= $2; };
177 CONFIG System_id System_parameter_list
178 = { errx
(1,"line %d: root/dump/swap specifications obsolete", yyline
);}
188 op
= malloc
(sizeof
(struct opt
));
189 bzero
(op
, sizeof
(*op
));
190 op
->op_name
= strdup
("KERNEL");
194 op
->op_line
= yyline
+ 1;
198 System_parameter_list:
199 System_parameter_list ID
210 snprintf
(buf
, sizeof
(buf
), "%s%d", $1, $2);
218 snprintf
(buf
, sizeof
(buf
), "%s%d%s", $1, $2, $3);
222 | Save_id NUMBER ID NUMBER
226 snprintf
(buf
, sizeof
(buf
), "%s%d%s%d",
231 | Save_id NUMBER ID NUMBER ID
235 snprintf
(buf
, sizeof
(buf
), "%s%d%s%d%s",
243 Opt_list COMMA Option
253 op
= malloc
(sizeof
(struct opt
));
254 bzero
(op
, sizeof
(*op
));
259 * op->op_line is 1-based; yyline is 0-based but is now 1
260 * larger than when `Save_id' was lexed.
262 op
->op_line
= yyline
;
264 if
(strchr
(op
->op_name
, '=') != NULL
)
265 errx
(1, "line %d: The `=' in options should not be quoted", yyline
);
267 Save_id EQUALS Opt_value
271 op
= malloc
(sizeof
(struct opt
));
272 bzero
(op
, sizeof
(*op
));
276 op
->op_line
= yyline
+ 1;
287 snprintf
(buf
, sizeof
(buf
), "%d", $1);
297 Mkopt_list COMMA Mkoption
303 Save_id EQUALS Opt_value
307 op
= malloc
(sizeof
(struct opt
));
308 bzero
(op
, sizeof
(*op
));
310 op
->op_ownfile
= 0; /* for now */
313 op
->op_line
= yyline
+ 1;
324 = { cur.d_type
= DEVICE
; } |
325 PSEUDO_DEVICE Init_dev Dev
328 cur.d_type
= PSEUDO_DEVICE
;
330 PSEUDO_DEVICE Init_dev Dev NUMBER
333 cur.d_type
= PSEUDO_DEVICE
;
341 cur.d_unit
= UNKNOWN
;
343 Init_dev Dev NUMBER Dev_info
351 = { init_dev
(&cur
); };
368 cur.d_conn
= "nexus";
379 BUS NUMBER
/* device scbus1 at ahc0 bus 1 - twin channel */
380 = { cur.d_bus
= $2; } |
382 = { cur.d_target
= $2; } |
384 = { cur.d_lun
= $2; } |
386 = { cur.d_drive
= $2; } |
388 = { cur.d_irq
= $2; } |
390 = { cur.d_drq
= $2; } |
392 = { cur.d_maddr
= $2; } |
394 = { cur.d_msize
= $2; } |
396 = { cur.d_port
= $2; } |
398 = { cur.d_portn
= $2; } |
400 = { cur.d_flags
= $2; } |
402 = { cur.d_disabled
= 1; }
407 yyerror(const char *s
)
410 errx
(1, "line %d: %s", yyline
+ 1, s
);
414 * add a device to the list of devices
417 newdev
(struct device
*dp
)
419 struct device
*np
, *xp
;
421 if
(dp
->d_unit
>= 0) {
422 for
(xp
= dtab
; xp
!= NULL
; xp
= xp
->d_next
) {
423 if
((xp
->d_unit
== dp
->d_unit
) &&
424 !strcmp
(xp
->d_name
, dp
->d_name
)) {
425 errx
(1, "line %d: already seen device %s%d",
426 yyline
, xp
->d_name
, xp
->d_unit
);
430 np
= malloc
(sizeof
(*np
));
431 bzero
(np
, sizeof
(*np
));
443 * find the pointer to connect to the given device and number.
444 * returns 0 if no such device and prints an error message
447 connect
(char *dev
, int num
)
452 for
(dp
= dtab
; dp
!= NULL
; dp
= dp
->d_next
)
453 if
(!strcmp
(dp
->d_name
, dev
))
456 snprintf
(errbuf
, sizeof
(errbuf
),
457 "no %s's to wildcard", dev
);
463 for
(dp
= dtab
; dp
!= NULL
; dp
= dp
->d_next
) {
464 if
((num
!= dp
->d_unit
) || strcmp
(dev
, dp
->d_name
))
466 if
(dp
->d_type
!= DEVICE
) {
467 snprintf
(errbuf
, sizeof
(errbuf
),
468 "%s connected to non-device", dev
);
474 snprintf
(errbuf
, sizeof
(errbuf
), "%s %d not defined", dev
, num
);
480 init_dev
(struct device
*dp
)
483 dp
->d_name
= "OHNO!!!";
488 dp
->d_bus
= dp
->d_lun
= dp
->d_target
= dp
->d_drive
= dp
->d_unit
=
489 dp
->d_count
= UNKNOWN
;