Commit | Line | Data |
---|---|---|
cd68466f DF |
1 | /* |
2 | * Copyright (c) 1980 Regents of the University of California. | |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
5 | */ | |
6 | ||
524aa063 | 7 | #ifndef lint |
9bd38ba8 | 8 | static char sccsid[] = "@(#)mkioconf.c 5.6 (Berkeley) %G%"; |
cd68466f | 9 | #endif not lint |
5e794bde | 10 | |
b88ba334 BJ |
11 | #include <stdio.h> |
12 | #include "y.tab.h" | |
13 | #include "config.h" | |
14 | ||
15 | /* | |
5e794bde | 16 | * build the ioconf.c file |
b88ba334 | 17 | */ |
5e794bde | 18 | char *qu(); |
b312f544 | 19 | char *intv(); |
b88ba334 | 20 | |
b312f544 | 21 | #if MACHINE_VAX |
5e794bde | 22 | vax_ioconf() |
b88ba334 | 23 | { |
5e794bde BJ |
24 | register struct device *dp, *mp, *np; |
25 | register int uba_n, slave; | |
5e794bde | 26 | FILE *fp; |
b88ba334 | 27 | |
5e794bde | 28 | fp = fopen(path("ioconf.c"), "w"); |
22d68ad0 | 29 | if (fp == 0) { |
5e794bde BJ |
30 | perror(path("ioconf.c")); |
31 | exit(1); | |
b88ba334 | 32 | } |
107dc11a | 33 | fprintf(fp, "#include \"../machine/pte.h\"\n"); |
5e794bde | 34 | fprintf(fp, "#include \"../h/param.h\"\n"); |
5e794bde BJ |
35 | fprintf(fp, "#include \"../h/buf.h\"\n"); |
36 | fprintf(fp, "#include \"../h/map.h\"\n"); | |
37 | fprintf(fp, "#include \"../h/vm.h\"\n"); | |
38 | fprintf(fp, "\n"); | |
39 | fprintf(fp, "#include \"../vaxmba/mbavar.h\"\n"); | |
40 | fprintf(fp, "#include \"../vaxuba/ubavar.h\"\n\n"); | |
41 | fprintf(fp, "\n"); | |
42 | fprintf(fp, "#define C (caddr_t)\n\n"); | |
43 | /* | |
44 | * First print the mba initialization structures | |
45 | */ | |
46 | if (seen_mba) { | |
22d68ad0 | 47 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
5e794bde | 48 | mp = dp->d_conn; |
22d68ad0 | 49 | if (mp == 0 || mp == TO_NEXUS || |
5e794bde BJ |
50 | !eq(mp->d_name, "mba")) |
51 | continue; | |
52 | fprintf(fp, "extern struct mba_driver %sdriver;\n", | |
53 | dp->d_name); | |
54 | } | |
55 | fprintf(fp, "\nstruct mba_device mbdinit[] = {\n"); | |
56 | fprintf(fp, "\t/* Device, Unit, Mba, Drive, Dk */\n"); | |
22d68ad0 | 57 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
5e794bde | 58 | mp = dp->d_conn; |
22d68ad0 | 59 | if (dp->d_unit == QUES || mp == 0 || |
5e794bde BJ |
60 | mp == TO_NEXUS || !eq(mp->d_name, "mba")) |
61 | continue; | |
62 | if (dp->d_addr) { | |
63 | printf("can't specify csr address on mba for %s%d\n", | |
64 | dp->d_name, dp->d_unit); | |
65 | continue; | |
66 | } | |
22d68ad0 | 67 | if (dp->d_vec != 0) { |
5e794bde BJ |
68 | printf("can't specify vector for %s%d on mba\n", |
69 | dp->d_name, dp->d_unit); | |
70 | continue; | |
71 | } | |
72 | if (dp->d_drive == UNKNOWN) { | |
73 | printf("drive not specified for %s%d\n", | |
74 | dp->d_name, dp->d_unit); | |
75 | continue; | |
76 | } | |
77 | if (dp->d_slave != UNKNOWN) { | |
78 | printf("can't specify slave number for %s%d\n", | |
79 | dp->d_name, dp->d_unit); | |
80 | continue; | |
81 | } | |
0c51914c SL |
82 | fprintf(fp, "\t{ &%sdriver, %d, %s,", |
83 | dp->d_name, dp->d_unit, qu(mp->d_unit)); | |
84 | fprintf(fp, " %s, %d },\n", | |
5e794bde BJ |
85 | qu(dp->d_drive), dp->d_dk); |
86 | } | |
87 | fprintf(fp, "\t0\n};\n\n"); | |
88 | /* | |
89 | * Print the mbsinit structure | |
90 | * Driver Controller Unit Slave | |
91 | */ | |
92 | fprintf(fp, "struct mba_slave mbsinit [] = {\n"); | |
93 | fprintf(fp, "\t/* Driver, Ctlr, Unit, Slave */\n"); | |
22d68ad0 | 94 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
5e794bde BJ |
95 | /* |
96 | * All slaves are connected to something which | |
97 | * is connected to the massbus. | |
98 | */ | |
22d68ad0 | 99 | if ((mp = dp->d_conn) == 0 || mp == TO_NEXUS) |
5e794bde BJ |
100 | continue; |
101 | np = mp->d_conn; | |
22d68ad0 | 102 | if (np == 0 || np == TO_NEXUS || |
5e794bde BJ |
103 | !eq(np->d_name, "mba")) |
104 | continue; | |
0ad2198c SL |
105 | fprintf(fp, "\t{ &%sdriver, %s", |
106 | mp->d_name, qu(mp->d_unit)); | |
107 | fprintf(fp, ", %2d, %s },\n", | |
108 | dp->d_unit, qu(dp->d_slave)); | |
5e794bde BJ |
109 | } |
110 | fprintf(fp, "\t0\n};\n\n"); | |
b88ba334 | 111 | } |
b88ba334 | 112 | /* |
5e794bde | 113 | * Now generate interrupt vectors for the unibus |
b88ba334 | 114 | */ |
22d68ad0 BJ |
115 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
116 | if (dp->d_vec != 0) { | |
5e794bde BJ |
117 | struct idlst *ip; |
118 | mp = dp->d_conn; | |
22d68ad0 | 119 | if (mp == 0 || mp == TO_NEXUS || |
5e794bde BJ |
120 | !eq(mp->d_name, "uba")) |
121 | continue; | |
122 | fprintf(fp, | |
123 | "extern struct uba_driver %sdriver;\n", | |
124 | dp->d_name); | |
125 | fprintf(fp, "extern "); | |
126 | ip = dp->d_vec; | |
127 | for (;;) { | |
128 | fprintf(fp, "X%s%d()", ip->id, dp->d_unit); | |
129 | ip = ip->id_next; | |
130 | if (ip == 0) | |
131 | break; | |
132 | fprintf(fp, ", "); | |
133 | } | |
134 | fprintf(fp, ";\n"); | |
135 | fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, | |
a0897453 | 136 | dp->d_unit); |
5e794bde BJ |
137 | ip = dp->d_vec; |
138 | for (;;) { | |
139 | fprintf(fp, "X%s%d", ip->id, dp->d_unit); | |
140 | ip = ip->id_next; | |
141 | if (ip == 0) | |
142 | break; | |
143 | fprintf(fp, ", "); | |
144 | } | |
145 | fprintf(fp, ", 0 } ;\n"); | |
146 | } | |
b88ba334 | 147 | } |
5e794bde BJ |
148 | fprintf(fp, "\nstruct uba_ctlr ubminit[] = {\n"); |
149 | fprintf(fp, "/*\t driver,\tctlr,\tubanum,\talive,\tintr,\taddr */\n"); | |
22d68ad0 | 150 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
5e794bde | 151 | mp = dp->d_conn; |
22d68ad0 | 152 | if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || |
5e794bde BJ |
153 | !eq(mp->d_name, "uba")) |
154 | continue; | |
155 | if (dp->d_vec == 0) { | |
156 | printf("must specify vector for %s%d\n", | |
157 | dp->d_name, dp->d_unit); | |
158 | continue; | |
159 | } | |
160 | if (dp->d_addr == 0) { | |
161 | printf("must specify csr address for %s%d\n", | |
162 | dp->d_name, dp->d_unit); | |
163 | continue; | |
164 | } | |
165 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
166 | printf("drives need their own entries; dont "); | |
167 | printf("specify drive or slave for %s%d\n", | |
168 | dp->d_name, dp->d_unit); | |
169 | continue; | |
170 | } | |
171 | if (dp->d_flags) { | |
172 | printf("controllers (e.g. %s%d) ", | |
173 | dp->d_name, dp->d_unit); | |
174 | printf("don't have flags, only devices do\n"); | |
175 | continue; | |
176 | } | |
177 | fprintf(fp, | |
178 | "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0%o },\n", | |
179 | dp->d_name, dp->d_unit, qu(mp->d_unit), | |
180 | dp->d_name, dp->d_unit, dp->d_addr); | |
b88ba334 | 181 | } |
5e794bde | 182 | fprintf(fp, "\t0\n};\n"); |
36e00264 | 183 | /* unibus devices */ |
5e794bde | 184 | fprintf(fp, "\nstruct uba_device ubdinit[] = {\n"); |
36e00264 BJ |
185 | fprintf(fp, |
186 | "\t/* driver, unit, ctlr, ubanum, slave, intr, addr, dk, flags*/\n"); | |
22d68ad0 | 187 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
5e794bde | 188 | mp = dp->d_conn; |
22d68ad0 | 189 | if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || |
5e794bde BJ |
190 | mp == TO_NEXUS || mp->d_type == MASTER || |
191 | eq(mp->d_name, "mba")) | |
192 | continue; | |
193 | np = mp->d_conn; | |
22d68ad0 | 194 | if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) |
5e794bde | 195 | continue; |
22d68ad0 | 196 | np = 0; |
5e794bde BJ |
197 | if (eq(mp->d_name, "uba")) { |
198 | if (dp->d_vec == 0) { | |
199 | printf("must specify vector for device %s%d\n", | |
200 | dp->d_name, dp->d_unit); | |
201 | continue; | |
202 | } | |
203 | if (dp->d_addr == 0) { | |
204 | printf("must specify csr for device %s%d\n", | |
205 | dp->d_name, dp->d_unit); | |
206 | continue; | |
207 | } | |
208 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
209 | printf("drives/slaves can be specified "); | |
210 | printf("only for controllers, "); | |
211 | printf("not for device %s%d\n", | |
212 | dp->d_name, dp->d_unit); | |
213 | continue; | |
214 | } | |
215 | uba_n = mp->d_unit; | |
216 | slave = QUES; | |
217 | } else { | |
22d68ad0 | 218 | if ((np = mp->d_conn) == 0) { |
5e794bde BJ |
219 | printf("%s%d isn't connected to anything ", |
220 | mp->d_name, mp->d_unit); | |
221 | printf(", so %s%d is unattached\n", | |
222 | dp->d_name, dp->d_unit); | |
223 | continue; | |
224 | } | |
225 | uba_n = np->d_unit; | |
226 | if (dp->d_drive == UNKNOWN) { | |
227 | printf("must specify ``drive number'' "); | |
228 | printf("for %s%d\n", dp->d_name, dp->d_unit); | |
229 | continue; | |
230 | } | |
231 | /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ | |
232 | /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ | |
233 | if (dp->d_slave != UNKNOWN) { | |
234 | printf("slave numbers should be given only "); | |
235 | printf("for massbus tapes, not for %s%d\n", | |
236 | dp->d_name, dp->d_unit); | |
237 | continue; | |
238 | } | |
239 | if (dp->d_vec != 0) { | |
240 | printf("interrupt vectors should not be "); | |
241 | printf("given for drive %s%d\n", | |
242 | dp->d_name, dp->d_unit); | |
243 | continue; | |
244 | } | |
245 | if (dp->d_addr != 0) { | |
246 | printf("csr addresses should be given only "); | |
247 | printf("on controllers, not on %s%d\n", | |
248 | dp->d_name, dp->d_unit); | |
249 | continue; | |
250 | } | |
251 | slave = dp->d_drive; | |
252 | } | |
0c51914c | 253 | fprintf(fp, "\t{ &%sdriver, %2d, %s,", |
5e794bde | 254 | eq(mp->d_name, "uba") ? dp->d_name : mp->d_name, dp->d_unit, |
0c51914c SL |
255 | eq(mp->d_name, "uba") ? " -1" : qu(mp->d_unit)); |
256 | fprintf(fp, " %s, %2d, %s, C 0%-6o, %d, 0x%x },\n", | |
257 | qu(uba_n), slave, intv(dp), dp->d_addr, dp->d_dk, | |
258 | dp->d_flags); | |
b88ba334 | 259 | } |
5e794bde | 260 | fprintf(fp, "\t0\n};\n"); |
22d68ad0 | 261 | (void) fclose(fp); |
5e794bde | 262 | } |
b312f544 | 263 | #endif |
5e794bde | 264 | |
a0105456 SL |
265 | #if MACHINE_TAHOE |
266 | tahoe_ioconf() | |
5e794bde | 267 | { |
a0105456 SL |
268 | register struct device *dp, *mp, *np; |
269 | register int vba_n, slave; | |
5e794bde BJ |
270 | FILE *fp; |
271 | ||
272 | fp = fopen(path("ioconf.c"), "w"); | |
22d68ad0 | 273 | if (fp == 0) { |
5e794bde BJ |
274 | perror(path("ioconf.c")); |
275 | exit(1); | |
b88ba334 | 276 | } |
5e794bde | 277 | fprintf(fp, "#include \"../h/param.h\"\n"); |
a0105456 | 278 | fprintf(fp, "#include \"../machine/pte.h\"\n"); |
5e794bde BJ |
279 | fprintf(fp, "#include \"../h/buf.h\"\n"); |
280 | fprintf(fp, "#include \"../h/map.h\"\n"); | |
5e794bde | 281 | fprintf(fp, "\n"); |
a0105456 | 282 | fprintf(fp, "#include \"../tahoevba/vbavar.h\"\n"); |
5e794bde BJ |
283 | fprintf(fp, "\n"); |
284 | fprintf(fp, "#define C (caddr_t)\n\n"); | |
5e794bde | 285 | /* |
a0105456 | 286 | * Now generate interrupt vectors for the versabus |
5e794bde | 287 | */ |
22d68ad0 | 288 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
dff1a390 SL |
289 | mp = dp->d_conn; |
290 | if (mp == 0 || mp == TO_NEXUS || !eq(mp->d_name, "vba")) | |
291 | continue; | |
a0105456 SL |
292 | if (dp->d_vec != 0) { |
293 | struct idlst *ip; | |
a0105456 SL |
294 | fprintf(fp, |
295 | "extern struct vba_driver %sdriver;\n", | |
5e794bde | 296 | dp->d_name); |
a0105456 SL |
297 | fprintf(fp, "extern "); |
298 | ip = dp->d_vec; | |
299 | for (;;) { | |
300 | fprintf(fp, "X%s%d()", ip->id, dp->d_unit); | |
301 | ip = ip->id_next; | |
302 | if (ip == 0) | |
303 | break; | |
304 | fprintf(fp, ", "); | |
305 | } | |
306 | fprintf(fp, ";\n"); | |
307 | fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, | |
308 | dp->d_unit, dp->d_unit); | |
309 | ip = dp->d_vec; | |
310 | for (;;) { | |
311 | fprintf(fp, "X%s%d", ip->id, dp->d_unit); | |
312 | ip = ip->id_next; | |
313 | if (ip == 0) | |
314 | break; | |
315 | fprintf(fp, ", "); | |
316 | } | |
317 | fprintf(fp, ", 0 } ;\n"); | |
dff1a390 SL |
318 | } else if (dp->d_type == DRIVER) /* devices w/o interrupts */ |
319 | fprintf(fp, | |
320 | "extern struct vba_driver %sdriver;\n", | |
321 | dp->d_name); | |
b88ba334 | 322 | } |
a0105456 SL |
323 | fprintf(fp, "\nstruct vba_ctlr vbminit[] = {\n"); |
324 | fprintf(fp, "/*\t driver,\tctlr,\tvbanum,\talive,\tintr,\taddr */\n"); | |
22d68ad0 | 325 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
5e794bde | 326 | mp = dp->d_conn; |
22d68ad0 | 327 | if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || |
a0105456 | 328 | !eq(mp->d_name, "vba")) |
5e794bde | 329 | continue; |
a0105456 SL |
330 | if (dp->d_vec == 0) { |
331 | printf("must specify vector for %s%d\n", | |
5e794bde BJ |
332 | dp->d_name, dp->d_unit); |
333 | continue; | |
334 | } | |
335 | if (dp->d_addr == 0) { | |
336 | printf("must specify csr address for %s%d\n", | |
337 | dp->d_name, dp->d_unit); | |
338 | continue; | |
339 | } | |
340 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
a0105456 SL |
341 | printf("drives need their own entries; dont "); |
342 | printf("specify drive or slave for %s%d\n", | |
5e794bde BJ |
343 | dp->d_name, dp->d_unit); |
344 | continue; | |
345 | } | |
346 | if (dp->d_flags) { | |
a0105456 | 347 | printf("controllers (e.g. %s%d) ", |
5e794bde | 348 | dp->d_name, dp->d_unit); |
a0105456 | 349 | printf("don't have flags, only devices do\n"); |
5e794bde BJ |
350 | continue; |
351 | } | |
a0105456 SL |
352 | fprintf(fp, |
353 | "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0x%x },\n", | |
354 | dp->d_name, dp->d_unit, qu(mp->d_unit), | |
355 | dp->d_name, dp->d_unit, dp->d_addr); | |
b88ba334 | 356 | } |
5e794bde | 357 | fprintf(fp, "\t0\n};\n"); |
a0105456 SL |
358 | /* versabus devices */ |
359 | fprintf(fp, "\nstruct vba_device vbdinit[] = {\n"); | |
5e794bde | 360 | fprintf(fp, |
a0105456 | 361 | "\t/* driver, unit, ctlr, vbanum, slave, intr, addr, dk, flags*/\n"); |
22d68ad0 | 362 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
5e794bde | 363 | mp = dp->d_conn; |
22d68ad0 | 364 | if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || |
5e794bde BJ |
365 | mp == TO_NEXUS || mp->d_type == MASTER || |
366 | eq(mp->d_name, "mba")) | |
367 | continue; | |
a0105456 SL |
368 | np = mp->d_conn; |
369 | if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) | |
370 | continue; | |
371 | np = 0; | |
372 | if (eq(mp->d_name, "vba")) { | |
a6df0f0e SL |
373 | if (dp->d_vec == 0) |
374 | printf( | |
375 | "Warning, no interrupt vector specified for device %s%d\n", | |
5e794bde | 376 | dp->d_name, dp->d_unit); |
5e794bde BJ |
377 | if (dp->d_addr == 0) { |
378 | printf("must specify csr for device %s%d\n", | |
379 | dp->d_name, dp->d_unit); | |
380 | continue; | |
381 | } | |
382 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
a0105456 SL |
383 | printf("drives/slaves can be specified "); |
384 | printf("only for controllers, "); | |
385 | printf("not for device %s%d\n", | |
5e794bde BJ |
386 | dp->d_name, dp->d_unit); |
387 | continue; | |
388 | } | |
a0105456 | 389 | vba_n = mp->d_unit; |
5e794bde BJ |
390 | slave = QUES; |
391 | } else { | |
a0105456 SL |
392 | if ((np = mp->d_conn) == 0) { |
393 | printf("%s%d isn't connected to anything ", | |
5e794bde | 394 | mp->d_name, mp->d_unit); |
a0105456 | 395 | printf(", so %s%d is unattached\n", |
5e794bde BJ |
396 | dp->d_name, dp->d_unit); |
397 | continue; | |
398 | } | |
a0105456 | 399 | vba_n = np->d_unit; |
5e794bde | 400 | if (dp->d_drive == UNKNOWN) { |
a0105456 SL |
401 | printf("must specify ``drive number'' "); |
402 | printf("for %s%d\n", dp->d_name, dp->d_unit); | |
5e794bde BJ |
403 | continue; |
404 | } | |
405 | /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ | |
406 | /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ | |
407 | if (dp->d_slave != UNKNOWN) { | |
408 | printf("slave numbers should be given only "); | |
409 | printf("for massbus tapes, not for %s%d\n", | |
410 | dp->d_name, dp->d_unit); | |
411 | continue; | |
412 | } | |
a0105456 SL |
413 | if (dp->d_vec != 0) { |
414 | printf("interrupt vectors should not be "); | |
5e794bde BJ |
415 | printf("given for drive %s%d\n", |
416 | dp->d_name, dp->d_unit); | |
417 | continue; | |
418 | } | |
419 | if (dp->d_addr != 0) { | |
a0105456 | 420 | printf("csr addresses should be given only "); |
5e794bde BJ |
421 | printf("on controllers, not on %s%d\n", |
422 | dp->d_name, dp->d_unit); | |
423 | continue; | |
424 | } | |
425 | slave = dp->d_drive; | |
426 | } | |
a0105456 SL |
427 | fprintf(fp, "\t{ &%sdriver, %2d, %s,", |
428 | eq(mp->d_name, "vba") ? dp->d_name : mp->d_name, dp->d_unit, | |
429 | eq(mp->d_name, "vba") ? " -1" : qu(mp->d_unit)); | |
430 | fprintf(fp, " %s, %2d, %s, C 0x%-6x, %d, 0x%x },\n", | |
431 | qu(vba_n), slave, intv(dp), dp->d_addr, dp->d_dk, | |
432 | dp->d_flags); | |
b88ba334 | 433 | } |
5e794bde | 434 | fprintf(fp, "\t0\n};\n"); |
22d68ad0 | 435 | (void) fclose(fp); |
b88ba334 | 436 | } |
b312f544 | 437 | #endif |
b88ba334 | 438 | |
a6df0f0e SL |
439 | char * |
440 | intv(dev) | |
5e794bde | 441 | register struct device *dev; |
b88ba334 BJ |
442 | { |
443 | static char buf[20]; | |
444 | ||
5e794bde BJ |
445 | if (dev->d_vec == 0) |
446 | return (" 0"); | |
9bd38ba8 KB |
447 | (void) sprintf(buf, "%sint%d", dev->d_name, dev->d_unit); |
448 | return (buf); | |
b88ba334 BJ |
449 | } |
450 | ||
451 | char * | |
452 | qu(num) | |
453 | { | |
5e794bde | 454 | |
b88ba334 | 455 | if (num == QUES) |
5e794bde | 456 | return ("'?'"); |
22d68ad0 | 457 | if (num == UNKNOWN) |
5e794bde | 458 | return (" -1"); |
9bd38ba8 KB |
459 | (void) sprintf(errbuf, "%3d", num); |
460 | return (errbuf); | |
b88ba334 | 461 | } |