Commit | Line | Data |
---|---|---|
22d68ad0 BJ |
1 | %union { |
2 | char *str; | |
3 | int val; | |
36edb824 | 4 | struct file_list *file; |
22d68ad0 BJ |
5 | struct idlst *lst; |
6 | } | |
7 | ||
36edb824 SL |
8 | %token AND |
9 | %token ANY | |
10 | %token ARGS | |
11 | %token AT | |
12 | %token COMMA | |
13 | %token CONFIG | |
14 | %token CONTROLLER | |
15 | %token CPU | |
16 | %token CSR | |
17 | %token DEVICE | |
18 | %token DISK | |
19 | %token DRIVE | |
20 | %token DST | |
21 | %token DUMPS | |
22 | %token EQUALS | |
23 | %token FLAGS | |
24 | %token HZ | |
25 | %token IDENT | |
f025f13d | 26 | %token MACHINE |
36edb824 SL |
27 | %token MAJOR |
28 | %token MASTER | |
29 | %token MAXUSERS | |
30 | %token MBA | |
31 | %token MINOR | |
32 | %token MINUS | |
33 | %token NEXUS | |
34 | %token ON | |
35 | %token OPTIONS | |
36 | %token PRIORITY | |
37 | %token PSEUDO_DEVICE | |
38 | %token ROOT | |
39 | %token SEMICOLON | |
40 | %token SIZE | |
41 | %token SLAVE | |
42 | %token SWAP | |
43 | %token TIMEZONE | |
44 | %token TRACE | |
45 | %token UBA | |
46 | %token VECTOR | |
22d68ad0 BJ |
47 | |
48 | %token <str> ID | |
49 | %token <val> NUMBER | |
50 | %token <val> FPNUMBER | |
51 | ||
52 | %type <str> Save_id | |
53 | %type <str> Opt_value | |
54 | %type <str> Dev | |
55 | %type <lst> Id_list | |
36edb824 SL |
56 | %type <val> optional_size |
57 | %type <str> device_name | |
58 | %type <val> major_minor | |
59 | %type <val> arg_device_spec | |
60 | %type <val> root_device_spec | |
61 | %type <val> dump_device_spec | |
62 | %type <file> swap_device_spec | |
22d68ad0 | 63 | |
2f47f1cc | 64 | %{ |
0bf41cfc | 65 | |
cd68466f DF |
66 | /* |
67 | * Copyright (c) 1980 Regents of the University of California. | |
68 | * All rights reserved. The Berkeley software License Agreement | |
69 | * specifies the terms and conditions for redistribution. | |
70 | * | |
71 | * @(#)config.y 5.1 (Berkeley) %G% | |
72 | */ | |
0bf41cfc | 73 | |
2f47f1cc | 74 | #include "config.h" |
36edb824 | 75 | #include <ctype.h> |
2f47f1cc | 76 | #include <stdio.h> |
f025f13d BJ |
77 | |
78 | struct device cur; | |
79 | struct device *curp = 0; | |
80 | char *temp_id; | |
81 | char *val_id; | |
22d68ad0 | 82 | char *malloc(); |
f025f13d | 83 | |
2f47f1cc MT |
84 | %} |
85 | %% | |
86 | Configuration: | |
87 | Many_specs | |
36edb824 | 88 | = { verifysystemspecs(); } |
22d68ad0 | 89 | ; |
2f47f1cc MT |
90 | |
91 | Many_specs: | |
92 | Many_specs Spec | |
22d68ad0 BJ |
93 | | |
94 | /* lambda */ | |
95 | ; | |
2f47f1cc MT |
96 | |
97 | Spec: | |
22d68ad0 BJ |
98 | Device_spec SEMICOLON |
99 | = { newdev(&cur); } | | |
100 | Config_spec SEMICOLON | |
101 | | | |
102 | TRACE SEMICOLON | |
103 | = { do_trace = !do_trace; } | | |
104 | SEMICOLON | |
105 | | | |
2f47f1cc | 106 | error SEMICOLON |
22d68ad0 | 107 | ; |
2f47f1cc MT |
108 | |
109 | Config_spec: | |
22d68ad0 BJ |
110 | MACHINE Save_id |
111 | = { | |
0bf41cfc BJ |
112 | if (!strcmp($2, "vax")) { |
113 | machine = MACHINE_VAX; | |
114 | machinename = "vax"; | |
115 | } else if (!strcmp($2, "sun")) { | |
116 | machine = MACHINE_SUN; | |
117 | machinename = "sun"; | |
118 | } else | |
119 | yyerror("Unknown machine type"); | |
22d68ad0 BJ |
120 | } | |
121 | CPU Save_id | |
122 | = { | |
123 | struct cputype *cp = | |
124 | (struct cputype *)malloc(sizeof (struct cputype)); | |
125 | cp->cpu_name = ns($2); | |
126 | cp->cpu_next = cputype; | |
127 | cputype = cp; | |
128 | free(temp_id); | |
129 | } | | |
130 | OPTIONS Opt_list | |
131 | | | |
132 | IDENT ID | |
133 | = { ident = ns($2); } | | |
36edb824 SL |
134 | System_spec |
135 | | | |
22d68ad0 BJ |
136 | HZ NUMBER |
137 | = { yyerror("HZ specification obsolete; delete"); } | | |
138 | TIMEZONE NUMBER | |
139 | = { timezone = 60 * $2; check_tz(); } | | |
c00c470f SL |
140 | TIMEZONE NUMBER DST NUMBER |
141 | = { timezone = 60 * $2; dst = $4; check_tz(); } | | |
22d68ad0 BJ |
142 | TIMEZONE NUMBER DST |
143 | = { timezone = 60 * $2; dst = 1; check_tz(); } | | |
144 | TIMEZONE FPNUMBER | |
145 | = { timezone = $2; check_tz(); } | | |
c00c470f SL |
146 | TIMEZONE FPNUMBER DST NUMBER |
147 | = { timezone = $2; dst = $4; check_tz(); } | | |
22d68ad0 BJ |
148 | TIMEZONE FPNUMBER DST |
149 | = { timezone = $2; dst = 1; check_tz(); } | | |
150 | TIMEZONE MINUS NUMBER | |
151 | = { timezone = -60 * $3; check_tz(); } | | |
c00c470f SL |
152 | TIMEZONE MINUS NUMBER DST NUMBER |
153 | = { timezone = -60 * $3; dst = $5; check_tz(); } | | |
22d68ad0 BJ |
154 | TIMEZONE MINUS NUMBER DST |
155 | = { timezone = -60 * $3; dst = 1; check_tz(); } | | |
156 | TIMEZONE MINUS FPNUMBER | |
157 | = { timezone = -$3; check_tz(); } | | |
c00c470f SL |
158 | TIMEZONE MINUS FPNUMBER DST NUMBER |
159 | = { timezone = -$3; dst = $5; check_tz(); } | | |
22d68ad0 BJ |
160 | TIMEZONE MINUS FPNUMBER DST |
161 | = { timezone = -$3; dst = 1; check_tz(); } | | |
162 | MAXUSERS NUMBER | |
163 | = { maxusers = $2; }; | |
2f47f1cc | 164 | |
36edb824 SL |
165 | System_spec: |
166 | System_id System_parameter_list | |
167 | = { checksystemspec(*confp); } | |
168 | ; | |
169 | ||
170 | System_id: | |
171 | CONFIG Save_id | |
172 | = { mkconf($2); } | |
173 | ; | |
174 | ||
175 | System_parameter_list: | |
176 | System_parameter_list System_parameter | |
177 | | System_parameter | |
178 | ; | |
179 | ||
180 | System_parameter: | |
181 | swap_spec | |
182 | | root_spec | |
183 | | dump_spec | |
184 | | arg_spec | |
185 | ; | |
186 | ||
187 | swap_spec: | |
188 | SWAP optional_on swap_device_list | |
189 | ; | |
190 | ||
191 | swap_device_list: | |
192 | swap_device_list AND swap_device | |
193 | | swap_device | |
194 | ; | |
195 | ||
196 | swap_device: | |
197 | swap_device_spec optional_size | |
198 | = { mkswap(*confp, $1, $2); } | |
199 | ; | |
200 | ||
201 | swap_device_spec: | |
202 | device_name | |
203 | = { | |
204 | struct file_list *fl = newswap(); | |
205 | ||
206 | if (eq($1, "generic")) | |
207 | fl->f_fn = $1; | |
208 | else { | |
209 | fl->f_swapdev = nametodev($1, 0, 'b'); | |
210 | fl->f_fn = devtoname(fl->f_swapdev); | |
211 | } | |
212 | $$ = fl; | |
213 | } | |
214 | | major_minor | |
215 | = { | |
216 | struct file_list *fl = newswap(); | |
217 | ||
218 | fl->f_swapdev = $1; | |
219 | fl->f_fn = devtoname($1); | |
220 | $$ = fl; | |
221 | } | |
222 | ; | |
223 | ||
224 | root_spec: | |
225 | ROOT optional_on root_device_spec | |
226 | = { | |
227 | struct file_list *fl = *confp; | |
228 | ||
229 | if (fl && fl->f_rootdev != NODEV) | |
230 | yyerror("extraneous root device specification"); | |
231 | else | |
232 | fl->f_rootdev = $3; | |
233 | } | |
234 | ; | |
235 | ||
236 | root_device_spec: | |
237 | device_name | |
238 | = { $$ = nametodev($1, 0, 'a'); } | |
239 | | major_minor | |
240 | ; | |
241 | ||
242 | dump_spec: | |
243 | DUMPS optional_on dump_device_spec | |
244 | = { | |
245 | struct file_list *fl = *confp; | |
246 | ||
247 | if (fl && fl->f_dumpdev != NODEV) | |
248 | yyerror("extraneous dump device specification"); | |
249 | else | |
250 | fl->f_dumpdev = $3; | |
251 | } | |
252 | ||
253 | ; | |
254 | ||
255 | dump_device_spec: | |
256 | device_name | |
257 | = { $$ = nametodev($1, 0, 'b'); } | |
258 | | major_minor | |
259 | ; | |
260 | ||
261 | arg_spec: | |
262 | ARGS optional_on arg_device_spec | |
263 | = { | |
264 | struct file_list *fl = *confp; | |
265 | ||
266 | if (fl && fl->f_argdev != NODEV) | |
267 | yyerror("extraneous arg device specification"); | |
268 | else | |
269 | fl->f_argdev = $3; | |
270 | } | |
271 | ; | |
272 | ||
273 | arg_device_spec: | |
274 | device_name | |
275 | = { $$ = nametodev($1, 0, 'b'); } | |
276 | | major_minor | |
277 | ; | |
278 | ||
279 | major_minor: | |
280 | MAJOR NUMBER MINOR NUMBER | |
281 | = { $$ = makedev($2, $4); } | |
282 | ; | |
283 | ||
284 | optional_on: | |
285 | ON | |
286 | | /* empty */ | |
287 | ; | |
288 | ||
289 | optional_size: | |
290 | SIZE NUMBER | |
291 | = { $$ = $2; } | |
292 | | /* empty */ | |
293 | = { $$ = 0; } | |
294 | ; | |
295 | ||
296 | device_name: | |
297 | Save_id | |
298 | = { $$ = $1; } | |
299 | | Save_id NUMBER | |
300 | = { | |
301 | char buf[80]; | |
302 | ||
303 | (void) sprintf(buf, "%s%d", $1, $2); | |
304 | $$ = ns(buf); free($1); | |
305 | } | |
306 | | Save_id NUMBER ID | |
307 | = { | |
308 | char buf[80]; | |
309 | ||
310 | (void) sprintf(buf, "%s%d%s", $1, $2, $3); | |
311 | $$ = ns(buf); free($1); | |
312 | } | |
313 | ; | |
314 | ||
b1e602f2 | 315 | Opt_list: |
22d68ad0 BJ |
316 | Opt_list COMMA Option |
317 | | | |
b1e602f2 | 318 | Option |
22d68ad0 | 319 | ; |
b1e602f2 MT |
320 | |
321 | Option: | |
22d68ad0 BJ |
322 | Save_id |
323 | = { | |
324 | struct opt *op = (struct opt *)malloc(sizeof (struct opt)); | |
325 | op->op_name = ns($1); | |
326 | op->op_next = opt; | |
327 | op->op_value = 0; | |
328 | opt = op; | |
329 | free(temp_id); | |
330 | } | | |
331 | Save_id EQUALS Opt_value | |
332 | = { | |
333 | struct opt *op = (struct opt *)malloc(sizeof (struct opt)); | |
334 | op->op_name = ns($1); | |
335 | op->op_next = opt; | |
336 | op->op_value = ns($3); | |
337 | opt = op; | |
338 | free(temp_id); | |
339 | free(val_id); | |
340 | } ; | |
b1e602f2 | 341 | |
841254c0 | 342 | Opt_value: |
22d68ad0 BJ |
343 | ID |
344 | = { $$ = val_id = ns($1); } | | |
345 | NUMBER | |
346 | = { char nb[16]; $$ = val_id = ns(sprintf(nb, "%d", $1)); }; | |
841254c0 RE |
347 | |
348 | ||
2f47f1cc | 349 | Save_id: |
22d68ad0 BJ |
350 | ID |
351 | = { $$ = temp_id = ns($1); } | |
2f47f1cc MT |
352 | ; |
353 | ||
354 | Dev: | |
22d68ad0 BJ |
355 | UBA |
356 | = { $$ = ns("uba"); } | | |
357 | MBA | |
358 | = { $$ = ns("mba"); } | | |
359 | ID | |
360 | = { $$ = ns($1); } | |
2f47f1cc MT |
361 | ; |
362 | ||
363 | Device_spec: | |
22d68ad0 BJ |
364 | DEVICE Dev_name Dev_info Int_spec |
365 | = { cur.d_type = DEVICE; } | | |
366 | MASTER Dev_name Dev_info Int_spec | |
367 | = { cur.d_type = MASTER; } | | |
368 | DISK Dev_name Dev_info Int_spec | |
369 | = { cur.d_dk = 1; cur.d_type = DEVICE; } | | |
370 | CONTROLLER Dev_name Dev_info Int_spec | |
371 | = { cur.d_type = CONTROLLER; } | | |
372 | PSEUDO_DEVICE Init_dev Dev | |
373 | = { | |
374 | cur.d_name = $3; | |
375 | cur.d_type = PSEUDO_DEVICE; | |
376 | } | | |
377 | PSEUDO_DEVICE Init_dev Dev NUMBER | |
378 | = { | |
379 | cur.d_name = $3; | |
380 | cur.d_type = PSEUDO_DEVICE; | |
381 | cur.d_slave = $4; | |
382 | }; | |
2f47f1cc MT |
383 | |
384 | Dev_name: | |
22d68ad0 BJ |
385 | Init_dev Dev NUMBER |
386 | = { | |
387 | cur.d_name = $2; | |
388 | if (eq($2, "mba")) | |
389 | seen_mba = 1; | |
390 | else if (eq($2, "uba")) | |
391 | seen_uba = 1; | |
392 | cur.d_unit = $3; | |
393 | }; | |
2f47f1cc MT |
394 | |
395 | Init_dev: | |
22d68ad0 BJ |
396 | /* lambda */ |
397 | = { init_dev(&cur); }; | |
2f47f1cc MT |
398 | |
399 | Dev_info: | |
400 | Con_info Info_list | |
22d68ad0 BJ |
401 | | |
402 | /* lambda */ | |
403 | ; | |
2f47f1cc MT |
404 | |
405 | Con_info: | |
22d68ad0 BJ |
406 | AT Dev NUMBER |
407 | = { | |
b1e602f2 MT |
408 | if (eq(cur.d_name, "mba") || eq(cur.d_name, "uba")) |
409 | yyerror(sprintf(errbuf, | |
22d68ad0 | 410 | "%s must be connected to a nexus", cur.d_name)); |
b1e602f2 | 411 | cur.d_conn = connect($2, $3); |
22d68ad0 BJ |
412 | } | |
413 | AT NEXUS NUMBER | |
414 | = { check_nexus(&cur, $3); cur.d_conn = TO_NEXUS; }; | |
2f47f1cc MT |
415 | |
416 | Info_list: | |
417 | Info_list Info | |
22d68ad0 BJ |
418 | | |
419 | /* lambda */ | |
420 | ; | |
2f47f1cc MT |
421 | |
422 | Info: | |
22d68ad0 BJ |
423 | CSR NUMBER |
424 | = { cur.d_addr = $2; } | | |
425 | DRIVE NUMBER | |
426 | = { cur.d_drive = $2; } | | |
427 | SLAVE NUMBER | |
428 | = { | |
429 | if (cur.d_conn != 0 && cur.d_conn != TO_NEXUS && | |
430 | cur.d_conn->d_type == MASTER) | |
b1e602f2 MT |
431 | cur.d_slave = $2; |
432 | else | |
433 | yyerror("can't specify slave--not to master"); | |
22d68ad0 BJ |
434 | } | |
435 | FLAGS NUMBER | |
436 | = { cur.d_flags = $2; }; | |
2f47f1cc MT |
437 | |
438 | Int_spec: | |
22d68ad0 BJ |
439 | VECTOR Id_list |
440 | = { cur.d_vec = $2; } | | |
441 | PRIORITY NUMBER | |
442 | = { cur.d_pri = $2; } | | |
443 | /* lambda */ | |
444 | ; | |
08f9a943 BJ |
445 | |
446 | Id_list: | |
22d68ad0 BJ |
447 | Save_id |
448 | = { | |
449 | struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst)); | |
450 | a->id = $1; a->id_next = 0; $$ = a; | |
451 | } | | |
08f9a943 | 452 | Save_id Id_list = |
22d68ad0 BJ |
453 | { |
454 | struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst)); | |
455 | a->id = $1; a->id_next = $2; $$ = a; | |
456 | }; | |
457 | ||
2f47f1cc MT |
458 | %% |
459 | ||
460 | yyerror(s) | |
f025f13d | 461 | char *s; |
2f47f1cc | 462 | { |
f025f13d | 463 | |
36edb824 | 464 | fprintf(stderr, "config: line %d: %s\n", yyline, s); |
2f47f1cc MT |
465 | } |
466 | ||
467 | /* | |
f025f13d | 468 | * return the passed string in a new space |
2f47f1cc | 469 | */ |
2f47f1cc MT |
470 | char * |
471 | ns(str) | |
f025f13d | 472 | register char *str; |
2f47f1cc MT |
473 | { |
474 | register char *cp; | |
475 | ||
22d68ad0 BJ |
476 | cp = malloc((unsigned)(strlen(str)+1)); |
477 | (void) strcpy(cp, str); | |
478 | return (cp); | |
2f47f1cc MT |
479 | } |
480 | ||
481 | /* | |
f025f13d | 482 | * add a device to the list of devices |
2f47f1cc | 483 | */ |
2f47f1cc | 484 | newdev(dp) |
f025f13d | 485 | register struct device *dp; |
2f47f1cc MT |
486 | { |
487 | register struct device *np; | |
488 | ||
489 | np = (struct device *) malloc(sizeof *np); | |
490 | *np = *dp; | |
f025f13d | 491 | if (curp == 0) |
b1e602f2 MT |
492 | dtab = np; |
493 | else | |
494 | curp->d_next = np; | |
495 | curp = np; | |
2f47f1cc MT |
496 | } |
497 | ||
498 | /* | |
f025f13d | 499 | * note that a configuration should be made |
2f47f1cc | 500 | */ |
36edb824 SL |
501 | mkconf(sysname) |
502 | char *sysname; | |
2f47f1cc | 503 | { |
36edb824 | 504 | register struct file_list *fl, **flp; |
2f47f1cc MT |
505 | |
506 | fl = (struct file_list *) malloc(sizeof *fl); | |
36edb824 SL |
507 | fl->f_type = SYSTEMSPEC; |
508 | fl->f_needs = sysname; | |
509 | fl->f_rootdev = NODEV; | |
510 | fl->f_argdev = NODEV; | |
511 | fl->f_dumpdev = NODEV; | |
512 | fl->f_fn = 0; | |
513 | fl->f_next = 0; | |
514 | for (flp = confp; *flp; flp = &(*flp)->f_next) | |
515 | ; | |
516 | *flp = fl; | |
517 | confp = flp; | |
518 | } | |
519 | ||
520 | struct file_list * | |
521 | newswap() | |
522 | { | |
523 | struct file_list *fl = (struct file_list *)malloc(sizeof (*fl)); | |
524 | ||
525 | fl->f_type = SWAPSPEC; | |
526 | fl->f_next = 0; | |
527 | fl->f_swapdev = NODEV; | |
528 | fl->f_swapsize = 0; | |
529 | fl->f_needs = 0; | |
530 | fl->f_fn = 0; | |
531 | return (fl); | |
532 | } | |
533 | ||
534 | /* | |
535 | * Add a swap device to the system's configuration | |
536 | */ | |
537 | mkswap(system, fl, size) | |
538 | struct file_list *system, *fl; | |
539 | int size; | |
540 | { | |
541 | register struct file_list **flp; | |
542 | char *cp, name[80]; | |
543 | ||
544 | if (system == 0 || system->f_type != SYSTEMSPEC) { | |
545 | yyerror("\"swap\" spec precedes \"config\" specification"); | |
546 | return; | |
547 | } | |
548 | if (size < 0) { | |
549 | yyerror("illegal swap partition size"); | |
550 | return; | |
551 | } | |
552 | /* | |
553 | * Append swap description to the end of the list. | |
554 | */ | |
555 | flp = &system->f_next; | |
556 | for (; *flp && (*flp)->f_type == SWAPSPEC; flp = &(*flp)->f_next) | |
557 | ; | |
558 | fl->f_next = *flp; | |
559 | *flp = fl; | |
8df5b824 | 560 | fl->f_swapsize = size; |
36edb824 SL |
561 | /* |
562 | * If first swap device for this system, | |
563 | * set up f_fn field to insure swap | |
564 | * files are created with unique names. | |
565 | */ | |
566 | if (system->f_fn) | |
567 | return; | |
568 | if (eq(fl->f_fn, "generic")) | |
569 | system->f_fn = ns(fl->f_fn); | |
2f47f1cc | 570 | else |
36edb824 | 571 | system->f_fn = ns(system->f_needs); |
2f47f1cc MT |
572 | } |
573 | ||
574 | /* | |
f025f13d BJ |
575 | * find the pointer to connect to the given device and number. |
576 | * returns 0 if no such device and prints an error message | |
2f47f1cc | 577 | */ |
f025f13d BJ |
578 | struct device * |
579 | connect(dev, num) | |
580 | register char *dev; | |
581 | register int num; | |
2f47f1cc MT |
582 | { |
583 | register struct device *dp; | |
f6f4af06 | 584 | struct device *huhcon(); |
2f47f1cc | 585 | |
a5e18d6b | 586 | if (num == QUES) |
f025f13d BJ |
587 | return (huhcon(dev)); |
588 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
589 | if ((num != dp->d_unit) || !eq(dev, dp->d_name)) | |
590 | continue; | |
591 | if (dp->d_type != CONTROLLER && dp->d_type != MASTER) { | |
a5e18d6b MT |
592 | yyerror(sprintf(errbuf, |
593 | "%s connected to non-controller", dev)); | |
f025f13d BJ |
594 | return (0); |
595 | } | |
596 | return (dp); | |
597 | } | |
2f47f1cc | 598 | yyerror(sprintf(errbuf, "%s %d not defined", dev, num)); |
f025f13d | 599 | return (0); |
2f47f1cc | 600 | } |
f6f4af06 MT |
601 | |
602 | /* | |
f025f13d | 603 | * connect to an unspecific thing |
f6f4af06 | 604 | */ |
f025f13d BJ |
605 | struct device * |
606 | huhcon(dev) | |
607 | register char *dev; | |
f6f4af06 | 608 | { |
f025f13d BJ |
609 | register struct device *dp, *dcp; |
610 | struct device rdev; | |
611 | int oldtype; | |
612 | ||
f6f4af06 | 613 | /* |
f025f13d | 614 | * First make certain that there are some of these to wildcard on |
f6f4af06 | 615 | */ |
f025f13d BJ |
616 | for (dp = dtab; dp != 0; dp = dp->d_next) |
617 | if (eq(dp->d_name, dev)) | |
618 | break; | |
619 | if (dp == 0) { | |
620 | yyerror(sprintf(errbuf, "no %s's to wildcard", dev)); | |
621 | return (0); | |
622 | } | |
623 | oldtype = dp->d_type; | |
624 | dcp = dp->d_conn; | |
625 | /* | |
626 | * Now see if there is already a wildcard entry for this device | |
627 | * (e.g. Search for a "uba ?") | |
628 | */ | |
629 | for (; dp != 0; dp = dp->d_next) | |
630 | if (eq(dev, dp->d_name) && dp->d_unit == -1) | |
631 | break; | |
632 | /* | |
633 | * If there isn't, make one because everything needs to be connected | |
634 | * to something. | |
635 | */ | |
636 | if (dp == 0) { | |
637 | dp = &rdev; | |
638 | init_dev(dp); | |
639 | dp->d_unit = QUES; | |
640 | dp->d_name = ns(dev); | |
641 | dp->d_type = oldtype; | |
642 | newdev(dp); | |
643 | dp = curp; | |
644 | /* | |
645 | * Connect it to the same thing that other similar things are | |
646 | * connected to, but make sure it is a wildcard unit | |
647 | * (e.g. up connected to sc ?, here we make connect sc? to a | |
648 | * uba?). If other things like this are on the NEXUS or | |
649 | * if they aren't connected to anything, then make the same | |
650 | * connection, else call ourself to connect to another | |
651 | * unspecific device. | |
652 | */ | |
653 | if (dcp == TO_NEXUS || dcp == 0) | |
654 | dp->d_conn = dcp; | |
655 | else | |
656 | dp->d_conn = connect(dcp->d_name, QUES); | |
657 | } | |
658 | return (dp); | |
f6f4af06 MT |
659 | } |
660 | ||
661 | init_dev(dp) | |
f025f13d | 662 | register struct device *dp; |
f6f4af06 | 663 | { |
f025f13d BJ |
664 | |
665 | dp->d_name = "OHNO!!!"; | |
666 | dp->d_type = DEVICE; | |
667 | dp->d_conn = 0; | |
668 | dp->d_vec = 0; | |
669 | dp->d_addr = dp->d_pri = dp->d_flags = dp->d_dk = 0; | |
670 | dp->d_slave = dp->d_drive = dp->d_unit = UNKNOWN; | |
a5e18d6b MT |
671 | } |
672 | ||
673 | /* | |
f025f13d | 674 | * make certain that this is a reasonable type of thing to connect to a nexus |
a5e18d6b | 675 | */ |
a5e18d6b | 676 | check_nexus(dev, num) |
f025f13d BJ |
677 | register struct device *dev; |
678 | int num; | |
a5e18d6b | 679 | { |
f025f13d | 680 | |
0bf41cfc | 681 | switch (machine) { |
f025f13d | 682 | |
0bf41cfc BJ |
683 | case MACHINE_VAX: |
684 | if (!eq(dev->d_name, "uba") && !eq(dev->d_name, "mba")) | |
685 | yyerror("only uba's and mba's should be connected to the nexus"); | |
686 | if (num != QUES) | |
687 | yyerror("can't give specific nexus numbers"); | |
688 | break; | |
689 | ||
690 | case MACHINE_SUN: | |
691 | if (!eq(dev->d_name, "mb")) | |
692 | yyerror("only mb's should be connected to the nexus"); | |
693 | break; | |
694 | } | |
f6f4af06 | 695 | } |
b1e602f2 MT |
696 | |
697 | /* | |
698 | * Check the timezone to make certain it is sensible | |
699 | */ | |
700 | ||
701 | check_tz() | |
702 | { | |
841254c0 | 703 | if (abs(timezone) > 12 * 60) |
b1e602f2 MT |
704 | yyerror("timezone is unreasonable"); |
705 | else | |
f025f13d | 706 | hadtz = 1; |
b1e602f2 | 707 | } |
36edb824 SL |
708 | |
709 | /* | |
710 | * Check system specification and apply defaulting | |
711 | * rules on root, argument, dump, and swap devices. | |
712 | */ | |
713 | checksystemspec(fl) | |
714 | register struct file_list *fl; | |
715 | { | |
716 | char buf[BUFSIZ]; | |
717 | register struct file_list *swap; | |
718 | int generic; | |
719 | ||
720 | if (fl == 0 || fl->f_type != SYSTEMSPEC) { | |
721 | yyerror("internal error, bad system specification"); | |
722 | exit(1); | |
723 | } | |
724 | swap = fl->f_next; | |
725 | generic = swap && swap->f_type == SWAPSPEC && eq(swap->f_fn, "generic"); | |
726 | if (fl->f_rootdev == NODEV && !generic) { | |
727 | yyerror("no root device specified"); | |
728 | exit(1); | |
729 | } | |
730 | /* | |
731 | * Default swap area to be in 'b' partition of root's | |
732 | * device. If root specified to be other than on 'a' | |
733 | * partition, give warning, something probably amiss. | |
734 | */ | |
735 | if (swap == 0 || swap->f_type != SWAPSPEC) { | |
736 | dev_t dev; | |
737 | ||
738 | swap = newswap(); | |
739 | dev = fl->f_rootdev; | |
740 | if (minor(dev) & 07) { | |
741 | sprintf(buf, | |
742 | "Warning, swap defaulted to 'b' partition with root on '%c' partition", | |
743 | (minor(dev) & 07) + 'a'); | |
744 | yyerror(buf); | |
745 | } | |
746 | swap->f_swapdev = | |
747 | makedev(major(dev), (minor(dev) &~ 07) | ('b' - 'a')); | |
748 | swap->f_fn = devtoname(swap->f_swapdev); | |
749 | mkswap(fl, swap, 0); | |
750 | } | |
751 | /* | |
752 | * Make sure a generic swap isn't specified, along with | |
753 | * other stuff (user must really be confused). | |
754 | */ | |
755 | if (generic) { | |
756 | if (fl->f_rootdev != NODEV) | |
757 | yyerror("root device specified with generic swap"); | |
758 | if (fl->f_argdev != NODEV) | |
759 | yyerror("arg device specified with generic swap"); | |
760 | if (fl->f_dumpdev != NODEV) | |
761 | yyerror("dump device specified with generic swap"); | |
762 | return; | |
763 | } | |
764 | /* | |
765 | * Default argument device and check for oddball arrangements. | |
766 | */ | |
767 | if (fl->f_argdev == NODEV) | |
768 | fl->f_argdev = swap->f_swapdev; | |
769 | if (fl->f_argdev != swap->f_swapdev) | |
770 | yyerror("Warning, arg device different than primary swap"); | |
771 | /* | |
772 | * Default dump device and warn if place is not a | |
773 | * swap area or the argument device partition. | |
774 | */ | |
775 | if (fl->f_dumpdev == NODEV) | |
776 | fl->f_dumpdev = swap->f_swapdev; | |
777 | if (fl->f_dumpdev != swap->f_swapdev && fl->f_dumpdev != fl->f_argdev) { | |
778 | struct file_list *p = swap->f_next; | |
779 | ||
780 | for (; p && p->f_type == SWAPSPEC; p = p->f_next) | |
781 | if (fl->f_dumpdev == p->f_swapdev) | |
782 | return; | |
783 | sprintf(buf, "Warning, orphaned dump device, %s", | |
784 | "do you know what you're doing"); | |
785 | yyerror(buf); | |
786 | } | |
787 | } | |
788 | ||
789 | /* | |
790 | * Verify all devices specified in the system specification | |
791 | * are present in the device specifications. | |
792 | */ | |
793 | verifysystemspecs() | |
794 | { | |
795 | register struct file_list *fl; | |
796 | dev_t checked[50], *verifyswap(); | |
797 | register dev_t *pchecked = checked; | |
798 | ||
799 | for (fl = conf_list; fl; fl = fl->f_next) { | |
800 | if (fl->f_type != SYSTEMSPEC) | |
801 | continue; | |
802 | if (!finddev(fl->f_rootdev)) | |
803 | deverror(fl->f_needs, "root"); | |
804 | *pchecked++ = fl->f_rootdev; | |
805 | pchecked = verifyswap(fl->f_next, checked, pchecked); | |
806 | #define samedev(dev1, dev2) \ | |
807 | ((minor(dev1) &~ 07) != (minor(dev2) &~ 07)) | |
808 | if (!alreadychecked(fl->f_dumpdev, checked, pchecked)) { | |
809 | if (!finddev(fl->f_dumpdev)) | |
810 | deverror(fl->f_needs, "dump"); | |
811 | *pchecked++ = fl->f_dumpdev; | |
812 | } | |
813 | if (!alreadychecked(fl->f_argdev, checked, pchecked)) { | |
814 | if (!finddev(fl->f_argdev)) | |
815 | deverror(fl->f_needs, "arg"); | |
816 | *pchecked++ = fl->f_argdev; | |
817 | } | |
818 | } | |
819 | } | |
820 | ||
821 | /* | |
822 | * Do as above, but for swap devices. | |
823 | */ | |
824 | dev_t * | |
825 | verifyswap(fl, checked, pchecked) | |
826 | register struct file_list *fl; | |
827 | dev_t checked[]; | |
828 | register dev_t *pchecked; | |
829 | { | |
830 | ||
831 | for (;fl && fl->f_type == SWAPSPEC; fl = fl->f_next) { | |
832 | if (eq(fl->f_fn, "generic")) | |
833 | continue; | |
834 | if (alreadychecked(fl->f_swapdev, checked, pchecked)) | |
835 | continue; | |
836 | if (!finddev(fl->f_swapdev)) | |
837 | fprintf(stderr, | |
838 | "config: swap device %s not configured", fl->f_fn); | |
839 | *pchecked++ = fl->f_swapdev; | |
840 | } | |
841 | return (pchecked); | |
842 | } | |
843 | ||
844 | /* | |
845 | * Has a device already been checked | |
846 | * for it's existence in the configuration? | |
847 | */ | |
848 | alreadychecked(dev, list, last) | |
849 | dev_t dev, list[]; | |
850 | register dev_t *last; | |
851 | { | |
852 | register dev_t *p; | |
853 | ||
854 | for (p = list; p < last; p++) | |
855 | if (samedev(*p, dev)) | |
856 | return (1); | |
857 | return (0); | |
858 | } | |
859 | ||
860 | deverror(systemname, devtype) | |
861 | char *systemname, *devtype; | |
862 | { | |
863 | ||
864 | fprintf(stderr, "config: %s: %s device not configured\n", | |
865 | systemname, devtype); | |
866 | } | |
867 | ||
868 | /* | |
869 | * Look for the device in the list of | |
870 | * configured hardware devices. Must | |
871 | * take into account stuff wildcarded. | |
872 | */ | |
873 | finddev(dev) | |
874 | dev_t dev; | |
875 | { | |
876 | ||
877 | /* punt on this right now */ | |
878 | return (1); | |
879 | } |