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