Commit | Line | Data |
---|---|---|
0f8c65ff WJ |
1 | /* |
2 | * Copyright (c) 1980 Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * 3. All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | |
15 | * This product includes software developed by the University of | |
16 | * California, Berkeley and its contributors. | |
17 | * 4. Neither the name of the University nor the names of its contributors | |
18 | * may be used to endorse or promote products derived from this software | |
19 | * without specific prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
31 | * SUCH DAMAGE. | |
32 | */ | |
33 | ||
34 | #ifndef lint | |
35 | static char sccsid[] = "@(#)mkioconf.c 5.18 (Berkeley) 5/10/91"; | |
36 | #endif /* not lint */ | |
37 | ||
38 | #include <stdio.h> | |
39 | #include "y.tab.h" | |
40 | #include "config.h" | |
41 | ||
42 | /* | |
43 | * build the ioconf.c file | |
44 | */ | |
45 | char *qu(); | |
46 | char *intv(); | |
47 | ||
48 | #if MACHINE_VAX | |
49 | vax_ioconf() | |
50 | { | |
51 | register struct device *dp, *mp, *np; | |
52 | register int uba_n, slave; | |
53 | FILE *fp; | |
54 | ||
55 | fp = fopen(path("ioconf.c"), "w"); | |
56 | if (fp == 0) { | |
57 | perror(path("ioconf.c")); | |
58 | exit(1); | |
59 | } | |
60 | fprintf(fp, "#include \"vax/include/pte.h\"\n"); | |
61 | fprintf(fp, "#include \"sys/param.h\"\n"); | |
62 | fprintf(fp, "#include \"sys/buf.h\"\n"); | |
63 | fprintf(fp, "#include \"sys/map.h\"\n"); | |
64 | fprintf(fp, "\n"); | |
65 | fprintf(fp, "#include \"vax/mba/mbavar.h\"\n"); | |
66 | fprintf(fp, "#include \"vax/uba/ubavar.h\"\n\n"); | |
67 | fprintf(fp, "\n"); | |
68 | fprintf(fp, "#define C (caddr_t)\n\n"); | |
69 | /* | |
70 | * First print the mba initialization structures | |
71 | */ | |
72 | if (seen_mba) { | |
73 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
74 | mp = dp->d_conn; | |
75 | if (mp == 0 || mp == TO_NEXUS || | |
76 | !eq(mp->d_name, "mba")) | |
77 | continue; | |
78 | fprintf(fp, "extern struct mba_driver %sdriver;\n", | |
79 | dp->d_name); | |
80 | } | |
81 | fprintf(fp, "\nstruct mba_device mbdinit[] = {\n"); | |
82 | fprintf(fp, "\t/* Device, Unit, Mba, Drive, Dk */\n"); | |
83 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
84 | mp = dp->d_conn; | |
85 | if (dp->d_unit == QUES || mp == 0 || | |
86 | mp == TO_NEXUS || !eq(mp->d_name, "mba")) | |
87 | continue; | |
88 | if (dp->d_addr) { | |
89 | printf("can't specify csr address on mba for %s%d\n", | |
90 | dp->d_name, dp->d_unit); | |
91 | continue; | |
92 | } | |
93 | if (dp->d_vec != 0) { | |
94 | printf("can't specify vector for %s%d on mba\n", | |
95 | dp->d_name, dp->d_unit); | |
96 | continue; | |
97 | } | |
98 | if (dp->d_drive == UNKNOWN) { | |
99 | printf("drive not specified for %s%d\n", | |
100 | dp->d_name, dp->d_unit); | |
101 | continue; | |
102 | } | |
103 | if (dp->d_slave != UNKNOWN) { | |
104 | printf("can't specify slave number for %s%d\n", | |
105 | dp->d_name, dp->d_unit); | |
106 | continue; | |
107 | } | |
108 | fprintf(fp, "\t{ &%sdriver, %d, %s,", | |
109 | dp->d_name, dp->d_unit, qu(mp->d_unit)); | |
110 | fprintf(fp, " %s, %d },\n", | |
111 | qu(dp->d_drive), dp->d_dk); | |
112 | } | |
113 | fprintf(fp, "\t0\n};\n\n"); | |
114 | /* | |
115 | * Print the mbsinit structure | |
116 | * Driver Controller Unit Slave | |
117 | */ | |
118 | fprintf(fp, "struct mba_slave mbsinit [] = {\n"); | |
119 | fprintf(fp, "\t/* Driver, Ctlr, Unit, Slave */\n"); | |
120 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
121 | /* | |
122 | * All slaves are connected to something which | |
123 | * is connected to the massbus. | |
124 | */ | |
125 | if ((mp = dp->d_conn) == 0 || mp == TO_NEXUS) | |
126 | continue; | |
127 | np = mp->d_conn; | |
128 | if (np == 0 || np == TO_NEXUS || | |
129 | !eq(np->d_name, "mba")) | |
130 | continue; | |
131 | fprintf(fp, "\t{ &%sdriver, %s", | |
132 | mp->d_name, qu(mp->d_unit)); | |
133 | fprintf(fp, ", %2d, %s },\n", | |
134 | dp->d_unit, qu(dp->d_slave)); | |
135 | } | |
136 | fprintf(fp, "\t0\n};\n\n"); | |
137 | } | |
138 | /* | |
139 | * Now generate interrupt vectors for the unibus | |
140 | */ | |
141 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
142 | if (dp->d_vec != 0) { | |
143 | struct idlst *ip; | |
144 | mp = dp->d_conn; | |
145 | if (mp == 0 || mp == TO_NEXUS || | |
146 | (!eq(mp->d_name, "uba") && !eq(mp->d_name, "bi"))) | |
147 | continue; | |
148 | fprintf(fp, | |
149 | "extern struct uba_driver %sdriver;\n", | |
150 | dp->d_name); | |
151 | fprintf(fp, "extern "); | |
152 | ip = dp->d_vec; | |
153 | for (;;) { | |
154 | fprintf(fp, "X%s%d()", ip->id, dp->d_unit); | |
155 | ip = ip->id_next; | |
156 | if (ip == 0) | |
157 | break; | |
158 | fprintf(fp, ", "); | |
159 | } | |
160 | fprintf(fp, ";\n"); | |
161 | fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, | |
162 | dp->d_unit); | |
163 | ip = dp->d_vec; | |
164 | for (;;) { | |
165 | fprintf(fp, "X%s%d", ip->id, dp->d_unit); | |
166 | ip = ip->id_next; | |
167 | if (ip == 0) | |
168 | break; | |
169 | fprintf(fp, ", "); | |
170 | } | |
171 | fprintf(fp, ", 0 } ;\n"); | |
172 | } | |
173 | } | |
174 | fprintf(fp, "\nstruct uba_ctlr ubminit[] = {\n"); | |
175 | fprintf(fp, "/*\t driver,\tctlr,\tubanum,\talive,\tintr,\taddr */\n"); | |
176 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
177 | mp = dp->d_conn; | |
178 | if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || | |
179 | !eq(mp->d_name, "uba")) | |
180 | continue; | |
181 | if (dp->d_vec == 0) { | |
182 | printf("must specify vector for %s%d\n", | |
183 | dp->d_name, dp->d_unit); | |
184 | continue; | |
185 | } | |
186 | if (dp->d_addr == 0) { | |
187 | printf("must specify csr address for %s%d\n", | |
188 | dp->d_name, dp->d_unit); | |
189 | continue; | |
190 | } | |
191 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
192 | printf("drives need their own entries; dont "); | |
193 | printf("specify drive or slave for %s%d\n", | |
194 | dp->d_name, dp->d_unit); | |
195 | continue; | |
196 | } | |
197 | if (dp->d_flags) { | |
198 | printf("controllers (e.g. %s%d) ", | |
199 | dp->d_name, dp->d_unit); | |
200 | printf("don't have flags, only devices do\n"); | |
201 | continue; | |
202 | } | |
203 | fprintf(fp, | |
204 | "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0%o },\n", | |
205 | dp->d_name, dp->d_unit, qu(mp->d_unit), | |
206 | dp->d_name, dp->d_unit, dp->d_addr); | |
207 | } | |
208 | fprintf(fp, "\t0\n};\n"); | |
209 | /* unibus devices */ | |
210 | fprintf(fp, "\nstruct uba_device ubdinit[] = {\n"); | |
211 | fprintf(fp, | |
212 | "\t/* driver, unit, ctlr, ubanum, slave, intr, addr, dk, flags*/\n"); | |
213 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
214 | mp = dp->d_conn; | |
215 | if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || | |
216 | mp == TO_NEXUS || mp->d_type == MASTER || | |
217 | eq(mp->d_name, "mba")) | |
218 | continue; | |
219 | np = mp->d_conn; | |
220 | if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) | |
221 | continue; | |
222 | np = 0; | |
223 | if (eq(mp->d_name, "uba")) { | |
224 | if (dp->d_vec == 0) { | |
225 | printf("must specify vector for device %s%d\n", | |
226 | dp->d_name, dp->d_unit); | |
227 | continue; | |
228 | } | |
229 | if (dp->d_addr == 0) { | |
230 | printf("must specify csr for device %s%d\n", | |
231 | dp->d_name, dp->d_unit); | |
232 | continue; | |
233 | } | |
234 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
235 | printf("drives/slaves can be specified "); | |
236 | printf("only for controllers, "); | |
237 | printf("not for device %s%d\n", | |
238 | dp->d_name, dp->d_unit); | |
239 | continue; | |
240 | } | |
241 | uba_n = mp->d_unit; | |
242 | slave = QUES; | |
243 | } else { | |
244 | if ((np = mp->d_conn) == 0) { | |
245 | printf("%s%d isn't connected to anything ", | |
246 | mp->d_name, mp->d_unit); | |
247 | printf(", so %s%d is unattached\n", | |
248 | dp->d_name, dp->d_unit); | |
249 | continue; | |
250 | } | |
251 | uba_n = np->d_unit; | |
252 | if (dp->d_drive == UNKNOWN) { | |
253 | printf("must specify ``drive number'' "); | |
254 | printf("for %s%d\n", dp->d_name, dp->d_unit); | |
255 | continue; | |
256 | } | |
257 | /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ | |
258 | /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ | |
259 | if (dp->d_slave != UNKNOWN) { | |
260 | printf("slave numbers should be given only "); | |
261 | printf("for massbus tapes, not for %s%d\n", | |
262 | dp->d_name, dp->d_unit); | |
263 | continue; | |
264 | } | |
265 | if (dp->d_vec != 0) { | |
266 | printf("interrupt vectors should not be "); | |
267 | printf("given for drive %s%d\n", | |
268 | dp->d_name, dp->d_unit); | |
269 | continue; | |
270 | } | |
271 | if (dp->d_addr != 0) { | |
272 | printf("csr addresses should be given only "); | |
273 | printf("on controllers, not on %s%d\n", | |
274 | dp->d_name, dp->d_unit); | |
275 | continue; | |
276 | } | |
277 | slave = dp->d_drive; | |
278 | } | |
279 | fprintf(fp, "\t{ &%sdriver, %2d, %s,", | |
280 | eq(mp->d_name, "uba") ? dp->d_name : mp->d_name, dp->d_unit, | |
281 | eq(mp->d_name, "uba") ? " -1" : qu(mp->d_unit)); | |
282 | fprintf(fp, " %s, %2d, %s, C 0%-6o, %d, 0x%x },\n", | |
283 | qu(uba_n), slave, intv(dp), dp->d_addr, dp->d_dk, | |
284 | dp->d_flags); | |
285 | } | |
286 | fprintf(fp, "\t0\n};\n"); | |
287 | (void) fclose(fp); | |
288 | } | |
289 | #endif | |
290 | ||
291 | #if MACHINE_TAHOE | |
292 | tahoe_ioconf() | |
293 | { | |
294 | register struct device *dp, *mp, *np; | |
295 | register int vba_n, slave; | |
296 | FILE *fp; | |
297 | ||
298 | fp = fopen(path("ioconf.c"), "w"); | |
299 | if (fp == 0) { | |
300 | perror(path("ioconf.c")); | |
301 | exit(1); | |
302 | } | |
303 | fprintf(fp, "#include \"sys/param.h\"\n"); | |
304 | fprintf(fp, "#include \"tahoe/include/pte.h\"\n"); | |
305 | fprintf(fp, "#include \"sys/buf.h\"\n"); | |
306 | fprintf(fp, "#include \"sys/map.h\"\n"); | |
307 | fprintf(fp, "\n"); | |
308 | fprintf(fp, "#include \"tahoe/vba/vbavar.h\"\n"); | |
309 | fprintf(fp, "\n"); | |
310 | fprintf(fp, "#define C (caddr_t)\n\n"); | |
311 | /* | |
312 | * Now generate interrupt vectors for the versabus | |
313 | */ | |
314 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
315 | mp = dp->d_conn; | |
316 | if (mp == 0 || mp == TO_NEXUS || !eq(mp->d_name, "vba")) | |
317 | continue; | |
318 | if (dp->d_vec != 0) { | |
319 | struct idlst *ip; | |
320 | fprintf(fp, | |
321 | "extern struct vba_driver %sdriver;\n", | |
322 | dp->d_name); | |
323 | fprintf(fp, "extern "); | |
324 | ip = dp->d_vec; | |
325 | for (;;) { | |
326 | fprintf(fp, "X%s%d()", ip->id, dp->d_unit); | |
327 | ip = ip->id_next; | |
328 | if (ip == 0) | |
329 | break; | |
330 | fprintf(fp, ", "); | |
331 | } | |
332 | fprintf(fp, ";\n"); | |
333 | fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, | |
334 | dp->d_unit); | |
335 | ip = dp->d_vec; | |
336 | for (;;) { | |
337 | fprintf(fp, "X%s%d", ip->id, dp->d_unit); | |
338 | ip = ip->id_next; | |
339 | if (ip == 0) | |
340 | break; | |
341 | fprintf(fp, ", "); | |
342 | } | |
343 | fprintf(fp, ", 0 } ;\n"); | |
344 | } else if (dp->d_type == DRIVER) /* devices w/o interrupts */ | |
345 | fprintf(fp, | |
346 | "extern struct vba_driver %sdriver;\n", | |
347 | dp->d_name); | |
348 | } | |
349 | fprintf(fp, "\nstruct vba_ctlr vbminit[] = {\n"); | |
350 | fprintf(fp, "/*\t driver,\tctlr,\tvbanum,\talive,\tintr,\taddr */\n"); | |
351 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
352 | mp = dp->d_conn; | |
353 | if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || | |
354 | !eq(mp->d_name, "vba")) | |
355 | continue; | |
356 | if (dp->d_vec == 0) { | |
357 | printf("must specify vector for %s%d\n", | |
358 | dp->d_name, dp->d_unit); | |
359 | continue; | |
360 | } | |
361 | if (dp->d_addr == 0) { | |
362 | printf("must specify csr address for %s%d\n", | |
363 | dp->d_name, dp->d_unit); | |
364 | continue; | |
365 | } | |
366 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
367 | printf("drives need their own entries; dont "); | |
368 | printf("specify drive or slave for %s%d\n", | |
369 | dp->d_name, dp->d_unit); | |
370 | continue; | |
371 | } | |
372 | if (dp->d_flags) { | |
373 | printf("controllers (e.g. %s%d) ", | |
374 | dp->d_name, dp->d_unit); | |
375 | printf("don't have flags, only devices do\n"); | |
376 | continue; | |
377 | } | |
378 | fprintf(fp, | |
379 | "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0x%x },\n", | |
380 | dp->d_name, dp->d_unit, qu(mp->d_unit), | |
381 | dp->d_name, dp->d_unit, dp->d_addr); | |
382 | } | |
383 | fprintf(fp, "\t0\n};\n"); | |
384 | /* versabus devices */ | |
385 | fprintf(fp, "\nstruct vba_device vbdinit[] = {\n"); | |
386 | fprintf(fp, | |
387 | "\t/* driver, unit, ctlr, vbanum, slave, intr, addr, dk, flags*/\n"); | |
388 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
389 | mp = dp->d_conn; | |
390 | if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || | |
391 | mp == TO_NEXUS || mp->d_type == MASTER || | |
392 | eq(mp->d_name, "mba")) | |
393 | continue; | |
394 | np = mp->d_conn; | |
395 | if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) | |
396 | continue; | |
397 | np = 0; | |
398 | if (eq(mp->d_name, "vba")) { | |
399 | if (dp->d_vec == 0) | |
400 | printf( | |
401 | "Warning, no interrupt vector specified for device %s%d\n", | |
402 | dp->d_name, dp->d_unit); | |
403 | if (dp->d_addr == 0) { | |
404 | printf("must specify csr for device %s%d\n", | |
405 | dp->d_name, dp->d_unit); | |
406 | continue; | |
407 | } | |
408 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
409 | printf("drives/slaves can be specified "); | |
410 | printf("only for controllers, "); | |
411 | printf("not for device %s%d\n", | |
412 | dp->d_name, dp->d_unit); | |
413 | continue; | |
414 | } | |
415 | vba_n = mp->d_unit; | |
416 | slave = QUES; | |
417 | } else { | |
418 | if ((np = mp->d_conn) == 0) { | |
419 | printf("%s%d isn't connected to anything ", | |
420 | mp->d_name, mp->d_unit); | |
421 | printf(", so %s%d is unattached\n", | |
422 | dp->d_name, dp->d_unit); | |
423 | continue; | |
424 | } | |
425 | vba_n = np->d_unit; | |
426 | if (dp->d_drive == UNKNOWN) { | |
427 | printf("must specify ``drive number'' "); | |
428 | printf("for %s%d\n", dp->d_name, dp->d_unit); | |
429 | continue; | |
430 | } | |
431 | /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ | |
432 | /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ | |
433 | if (dp->d_slave != UNKNOWN) { | |
434 | printf("slave numbers should be given only "); | |
435 | printf("for massbus tapes, not for %s%d\n", | |
436 | dp->d_name, dp->d_unit); | |
437 | continue; | |
438 | } | |
439 | if (dp->d_vec != 0) { | |
440 | printf("interrupt vectors should not be "); | |
441 | printf("given for drive %s%d\n", | |
442 | dp->d_name, dp->d_unit); | |
443 | continue; | |
444 | } | |
445 | if (dp->d_addr != 0) { | |
446 | printf("csr addresses should be given only "); | |
447 | printf("on controllers, not on %s%d\n", | |
448 | dp->d_name, dp->d_unit); | |
449 | continue; | |
450 | } | |
451 | slave = dp->d_drive; | |
452 | } | |
453 | fprintf(fp, "\t{ &%sdriver, %2d, %s,", | |
454 | eq(mp->d_name, "vba") ? dp->d_name : mp->d_name, dp->d_unit, | |
455 | eq(mp->d_name, "vba") ? " -1" : qu(mp->d_unit)); | |
456 | fprintf(fp, " %s, %2d, %s, C 0x%-6x, %d, 0x%x },\n", | |
457 | qu(vba_n), slave, intv(dp), dp->d_addr, dp->d_dk, | |
458 | dp->d_flags); | |
459 | } | |
460 | fprintf(fp, "\t0\n};\n"); | |
461 | (void) fclose(fp); | |
462 | } | |
463 | #endif | |
464 | ||
465 | #if MACHINE_HP300 | |
466 | hp300_ioconf() | |
467 | { | |
468 | register struct device *dp, *mp, *np; | |
469 | register int hpib, slave; | |
470 | FILE *fp; | |
471 | extern char *wnum(); | |
472 | ||
473 | fp = fopen(path("ioconf.c"), "w"); | |
474 | if (fp == 0) { | |
475 | perror(path("ioconf.c")); | |
476 | exit(1); | |
477 | } | |
478 | fprintf(fp, "#include \"sys/param.h\"\n"); | |
479 | fprintf(fp, "#include \"sys/buf.h\"\n"); | |
480 | fprintf(fp, "#include \"sys/map.h\"\n"); | |
481 | fprintf(fp, "\n"); | |
482 | fprintf(fp, "#include \"hp300/dev/device.h\"\n\n"); | |
483 | fprintf(fp, "\n"); | |
484 | fprintf(fp, "#define C (caddr_t)\n"); | |
485 | fprintf(fp, "#define D (struct driver *)\n\n"); | |
486 | /* | |
487 | * First print the hpib controller initialization structures | |
488 | */ | |
489 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
490 | mp = dp->d_conn; | |
491 | if (dp->d_unit == QUES || mp == 0) | |
492 | continue; | |
493 | fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); | |
494 | } | |
495 | fprintf(fp, "\nstruct hp_ctlr hp_cinit[] = {\n"); | |
496 | fprintf(fp, "/*\tdriver,\t\tunit,\talive,\taddr,\tflags */\n"); | |
497 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
498 | mp = dp->d_conn; | |
499 | if (dp->d_unit == QUES || | |
500 | dp->d_type != MASTER && dp->d_type != CONTROLLER) | |
501 | continue; | |
502 | if (mp != TO_NEXUS) { | |
503 | printf("%s%s must be attached to an sc (nexus)\n", | |
504 | dp->d_name, wnum(dp->d_unit)); | |
505 | continue; | |
506 | } | |
507 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
508 | printf("can't specify drive/slave for %s%s\n", | |
509 | dp->d_name, wnum(dp->d_unit)); | |
510 | continue; | |
511 | } | |
512 | fprintf(fp, | |
513 | "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t0x%x },\n", | |
514 | dp->d_name, dp->d_unit, dp->d_addr, dp->d_flags); | |
515 | } | |
516 | fprintf(fp, "\t0\n};\n"); | |
517 | /* devices */ | |
518 | fprintf(fp, "\nstruct hp_device hp_dinit[] = {\n"); | |
519 | fprintf(fp, | |
520 | "/*driver,\tcdriver,\tunit,\tctlr,\tslave,\taddr,\tdk,\tflags*/\n"); | |
521 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
522 | mp = dp->d_conn; | |
523 | if (mp == 0 || dp->d_type != DEVICE || hpbadslave(mp, dp)) | |
524 | continue; | |
525 | if (mp == TO_NEXUS) { | |
526 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
527 | printf("can't specify drive/slave for %s%s\n", | |
528 | dp->d_name, wnum(dp->d_unit)); | |
529 | continue; | |
530 | } | |
531 | slave = QUES; | |
532 | hpib = QUES; | |
533 | } else { | |
534 | if (dp->d_addr != 0) { | |
535 | printf("can't specify sc for device %s%s\n", | |
536 | dp->d_name, wnum(dp->d_unit)); | |
537 | continue; | |
538 | } | |
539 | if (mp->d_type == CONTROLLER) { | |
540 | if (dp->d_drive == UNKNOWN) { | |
541 | printf("must specify drive for %s%s\n", | |
542 | dp->d_name, wnum(dp->d_unit)); | |
543 | continue; | |
544 | } | |
545 | slave = dp->d_drive; | |
546 | } else { | |
547 | if (dp->d_slave == UNKNOWN) { | |
548 | printf("must specify slave for %s%s\n", | |
549 | dp->d_name, wnum(dp->d_unit)); | |
550 | continue; | |
551 | } | |
552 | slave = dp->d_slave; | |
553 | } | |
554 | hpib = mp->d_unit; | |
555 | } | |
556 | fprintf(fp, "{ &%sdriver,\t", dp->d_name); | |
557 | if (mp == TO_NEXUS) | |
558 | fprintf(fp, "D 0x0,\t"); | |
559 | else | |
560 | fprintf(fp, "&%sdriver,", mp->d_name); | |
561 | fprintf(fp, "\t%d,\t%d,\t%d,\tC 0x%x,\t%d,\t0x%x },\n", | |
562 | dp->d_unit, hpib, slave, | |
563 | dp->d_addr, dp->d_dk, dp->d_flags); | |
564 | } | |
565 | fprintf(fp, "0\n};\n"); | |
566 | (void) fclose(fp); | |
567 | } | |
568 | ||
569 | #define ishpibdev(n) (eq(n,"rd") || eq(n,"ct") || eq(n,"mt") || eq(n,"ppi")) | |
570 | #define isscsidev(n) (eq(n,"sd") || eq(n,"st")) | |
571 | ||
572 | hpbadslave(mp, dp) | |
573 | register struct device *dp, *mp; | |
574 | { | |
575 | extern char *wnum(); | |
576 | ||
577 | if (mp == TO_NEXUS && ishpibdev(dp->d_name) || | |
578 | mp != TO_NEXUS && eq(mp->d_name, "hpib") && | |
579 | !ishpibdev(dp->d_name)) { | |
580 | printf("%s%s must be attached to an hpib\n", | |
581 | dp->d_name, wnum(dp->d_unit)); | |
582 | return (1); | |
583 | } | |
584 | if (mp == TO_NEXUS && isscsidev(dp->d_name) || | |
585 | mp != TO_NEXUS && eq(mp->d_name, "scsi") && | |
586 | !isscsidev(dp->d_name)) { | |
587 | printf("%s%s must be attached to a scsi\n", | |
588 | dp->d_name, wnum(dp->d_unit)); | |
589 | return (1); | |
590 | } | |
591 | return (0); | |
592 | } | |
593 | ||
594 | char * | |
595 | wnum(num) | |
596 | { | |
597 | ||
598 | if (num == QUES || num == UNKNOWN) | |
599 | return ("?"); | |
600 | (void) sprintf(errbuf, "%d", num); | |
601 | return (errbuf); | |
602 | } | |
603 | #endif | |
604 | ||
605 | #if MACHINE_I386 | |
606 | char *sirq(); | |
607 | ||
608 | i386_ioconf() | |
609 | { | |
610 | register struct device *dp, *mp, *np; | |
611 | register int uba_n, slave; | |
612 | FILE *fp; | |
613 | ||
614 | fp = fopen(path("ioconf.c"), "w"); | |
615 | if (fp == 0) { | |
616 | perror(path("ioconf.c")); | |
617 | exit(1); | |
618 | } | |
619 | fprintf(fp, "/*\n"); | |
620 | fprintf(fp, " * ioconf.c \n"); | |
621 | fprintf(fp, " * Generated by config program\n"); | |
622 | fprintf(fp, " */\n\n"); | |
623 | fprintf(fp, "#include \"machine/pte.h\"\n"); | |
624 | fprintf(fp, "#include \"sys/param.h\"\n"); | |
625 | fprintf(fp, "#include \"sys/buf.h\"\n"); | |
626 | fprintf(fp, "\n"); | |
627 | fprintf(fp, "#define V(s) V##s\n"); | |
628 | fprintf(fp, "#define C (caddr_t)\n\n"); | |
629 | /* | |
630 | * First print the isa initialization structures | |
631 | */ | |
632 | if (seen_isa) { | |
633 | ||
634 | fprintf(fp, "/*\n"); | |
635 | fprintf(fp, " * ISA devices\n"); | |
636 | fprintf(fp, " */\n\n"); | |
637 | fprintf(fp, "#include \"i386/isa/isa_device.h\"\n"); | |
638 | fprintf(fp, "#include \"i386/isa/isa.h\"\n"); | |
639 | fprintf(fp, "#include \"i386/isa/icu.h\"\n\n"); | |
640 | ||
641 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
642 | mp = dp->d_conn; | |
643 | if (mp == 0 || mp == TO_NEXUS || | |
644 | !eq(mp->d_name, "isa")) | |
645 | continue; | |
646 | fprintf(fp, | |
647 | "extern struct isa_driver %sdriver; extern V(%s%d)();\n", | |
648 | dp->d_name, dp->d_name, dp->d_unit); | |
649 | } | |
650 | fprintf(fp, "\nstruct isa_device isa_devtab_bio[] = {\n"); | |
651 | fprintf(fp, "\ | |
652 | /* driver iobase irq drq maddr msiz intr unit */\n"); | |
653 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
654 | mp = dp->d_conn; | |
655 | if (dp->d_unit == QUES || mp == 0 || | |
656 | mp == TO_NEXUS || !eq(mp->d_name, "isa")) | |
657 | continue; | |
658 | if (!eq(dp->d_mask, "bio")) continue; | |
659 | if (dp->d_port) | |
660 | fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); | |
661 | else | |
662 | fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); | |
663 | fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", | |
664 | sirq(dp->d_irq), dp->d_drq, dp->d_maddr, | |
665 | dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); | |
666 | } | |
667 | fprintf(fp, "0\n};\n"); | |
668 | ||
669 | fprintf(fp, "struct isa_device isa_devtab_tty[] = {\n"); | |
670 | fprintf(fp, "\ | |
671 | /* driver iobase irq drq maddr msiz intr unit */\n"); | |
672 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
673 | mp = dp->d_conn; | |
674 | if (dp->d_unit == QUES || mp == 0 || | |
675 | mp == TO_NEXUS || !eq(mp->d_name, "isa")) | |
676 | continue; | |
677 | if (!eq(dp->d_mask, "tty")) continue; | |
678 | if (dp->d_port) | |
679 | fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); | |
680 | else | |
681 | fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); | |
682 | fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", | |
683 | sirq(dp->d_irq), dp->d_drq, dp->d_maddr, | |
684 | dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); | |
685 | } | |
686 | fprintf(fp, "0\n};\n\n"); | |
687 | ||
688 | fprintf(fp, "struct isa_device isa_devtab_net[] = {\n"); | |
689 | fprintf(fp, "\ | |
690 | /* driver iobase irq drq maddr msiz intr unit */\n"); | |
691 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
692 | mp = dp->d_conn; | |
693 | if (dp->d_unit == QUES || mp == 0 || | |
694 | mp == TO_NEXUS || !eq(mp->d_name, "isa")) | |
695 | continue; | |
696 | if (!eq(dp->d_mask, "net")) continue; | |
697 | if (dp->d_port) | |
698 | fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); | |
699 | else | |
700 | fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); | |
701 | fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", | |
702 | sirq(dp->d_irq), dp->d_drq, dp->d_maddr, | |
703 | dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); | |
704 | } | |
705 | fprintf(fp, "0\n};\n\n"); | |
706 | ||
707 | fprintf(fp, "struct isa_device isa_devtab_null[] = {\n"); | |
708 | fprintf(fp, "\ | |
709 | /* driver iobase irq drq maddr msiz intr unit */\n"); | |
710 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
711 | mp = dp->d_conn; | |
712 | if (dp->d_unit == QUES || mp == 0 || | |
713 | mp == TO_NEXUS || !eq(mp->d_name, "isa")) | |
714 | continue; | |
715 | if (!eq(dp->d_mask, "null")) continue; | |
716 | if (dp->d_port) | |
717 | fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); | |
718 | else | |
719 | fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); | |
720 | fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", | |
721 | sirq(dp->d_irq), dp->d_drq, dp->d_maddr, | |
722 | dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); | |
723 | } | |
724 | fprintf(fp, "0\n};\n\n"); | |
725 | } | |
726 | (void) fclose(fp); | |
727 | } | |
728 | ||
729 | char * | |
730 | sirq(num) | |
731 | { | |
732 | ||
733 | if (num == -1) | |
734 | return ("0"); | |
735 | sprintf(errbuf, "IRQ%d", num); | |
736 | return (errbuf); | |
737 | } | |
738 | #endif | |
739 | ||
740 | char * | |
741 | intv(dev) | |
742 | register struct device *dev; | |
743 | { | |
744 | static char buf[20]; | |
745 | ||
746 | if (dev->d_vec == 0) | |
747 | return (" 0"); | |
748 | (void) sprintf(buf, "%sint%d", dev->d_name, dev->d_unit); | |
749 | return (buf); | |
750 | } | |
751 | ||
752 | char * | |
753 | qu(num) | |
754 | { | |
755 | ||
756 | if (num == QUES) | |
757 | return ("'?'"); | |
758 | if (num == UNKNOWN) | |
759 | return (" -1"); | |
760 | (void) sprintf(errbuf, "%3d", num); | |
761 | return (errbuf); | |
762 | } |