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