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