Commit | Line | Data |
---|---|---|
15637ed4 RG |
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. | |
15637ed4 RG |
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 Driver Controller Unit Slave | |
116 | */ | |
117 | fprintf(fp, "struct mba_slave mbsinit [] = {\n"); | |
118 | fprintf(fp, "\t/* Driver, Ctlr, Unit, Slave */\n"); | |
119 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
120 | /* | |
121 | * All slaves are connected to something which is | |
122 | * connected to the massbus. | |
123 | */ | |
124 | if ((mp = dp->d_conn) == 0 || mp == TO_NEXUS) | |
125 | continue; | |
126 | np = mp->d_conn; | |
127 | if (np == 0 || np == TO_NEXUS || | |
128 | !eq(np->d_name, "mba")) | |
129 | continue; | |
130 | fprintf(fp, "\t{ &%sdriver, %s", | |
131 | mp->d_name, qu(mp->d_unit)); | |
132 | fprintf(fp, ", %2d, %s },\n", | |
133 | dp->d_unit, qu(dp->d_slave)); | |
134 | } | |
135 | fprintf(fp, "\t0\n};\n\n"); | |
136 | } | |
137 | /* | |
138 | * Now generate interrupt vectors for the unibus | |
139 | */ | |
140 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
141 | if (dp->d_vec != 0) { | |
142 | struct idlst *ip; | |
143 | mp = dp->d_conn; | |
144 | if (mp == 0 || mp == TO_NEXUS || | |
145 | (!eq(mp->d_name, "uba") && !eq(mp->d_name, "bi"))) | |
146 | continue; | |
147 | fprintf(fp, | |
148 | "extern struct uba_driver %sdriver;\n", | |
149 | dp->d_name); | |
150 | fprintf(fp, "extern "); | |
151 | ip = dp->d_vec; | |
152 | for (;;) { | |
153 | fprintf(fp, "X%s%d()", ip->id, dp->d_unit); | |
154 | ip = ip->id_next; | |
155 | if (ip == 0) | |
156 | break; | |
157 | fprintf(fp, ", "); | |
158 | } | |
159 | fprintf(fp, ";\n"); | |
160 | fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, | |
161 | dp->d_unit); | |
162 | ip = dp->d_vec; | |
163 | for (;;) { | |
164 | fprintf(fp, "X%s%d", ip->id, dp->d_unit); | |
165 | ip = ip->id_next; | |
166 | if (ip == 0) | |
167 | break; | |
168 | fprintf(fp, ", "); | |
169 | } | |
170 | fprintf(fp, ", 0 } ;\n"); | |
171 | } | |
172 | } | |
173 | fprintf(fp, "\nstruct uba_ctlr ubminit[] = {\n"); | |
174 | fprintf(fp, "/*\t driver,\tctlr,\tubanum,\talive,\tintr,\taddr */\n"); | |
175 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
176 | mp = dp->d_conn; | |
177 | if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || | |
178 | !eq(mp->d_name, "uba")) | |
179 | continue; | |
180 | if (dp->d_vec == 0) { | |
181 | printf("must specify vector for %s%d\n", | |
182 | dp->d_name, dp->d_unit); | |
183 | continue; | |
184 | } | |
185 | if (dp->d_addr == 0) { | |
186 | printf("must specify csr address for %s%d\n", | |
187 | dp->d_name, dp->d_unit); | |
188 | continue; | |
189 | } | |
190 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
191 | printf("drives need their own entries; dont "); | |
192 | printf("specify drive or slave for %s%d\n", | |
193 | dp->d_name, dp->d_unit); | |
194 | continue; | |
195 | } | |
196 | if (dp->d_flags) { | |
197 | printf("controllers (e.g. %s%d) ", | |
198 | dp->d_name, dp->d_unit); | |
199 | printf("don't have flags, only devices do\n"); | |
200 | continue; | |
201 | } | |
202 | fprintf(fp, | |
203 | "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0%o },\n", | |
204 | dp->d_name, dp->d_unit, qu(mp->d_unit), | |
205 | dp->d_name, dp->d_unit, dp->d_addr); | |
206 | } | |
207 | fprintf(fp, "\t0\n};\n"); | |
208 | /* unibus devices */ | |
209 | fprintf(fp, "\nstruct uba_device ubdinit[] = {\n"); | |
210 | fprintf(fp, | |
211 | "\t/* driver, unit, ctlr, ubanum, slave, intr, addr, dk, flags*/\n"); | |
212 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
213 | mp = dp->d_conn; | |
214 | if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || | |
215 | mp == TO_NEXUS || mp->d_type == MASTER || | |
216 | eq(mp->d_name, "mba")) | |
217 | continue; | |
218 | np = mp->d_conn; | |
219 | if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) | |
220 | continue; | |
221 | np = 0; | |
222 | if (eq(mp->d_name, "uba")) { | |
223 | if (dp->d_vec == 0) { | |
224 | printf("must specify vector for device %s%d\n", | |
225 | dp->d_name, dp->d_unit); | |
226 | continue; | |
227 | } | |
228 | if (dp->d_addr == 0) { | |
229 | printf("must specify csr for device %s%d\n", | |
230 | dp->d_name, dp->d_unit); | |
231 | continue; | |
232 | } | |
233 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
234 | printf("drives/slaves can be specified "); | |
235 | printf("only for controllers, "); | |
236 | printf("not for device %s%d\n", | |
237 | dp->d_name, dp->d_unit); | |
238 | continue; | |
239 | } | |
240 | uba_n = mp->d_unit; | |
241 | slave = QUES; | |
242 | } else { | |
243 | if ((np = mp->d_conn) == 0) { | |
244 | printf("%s%d isn't connected to anything ", | |
245 | mp->d_name, mp->d_unit); | |
246 | printf(", so %s%d is unattached\n", | |
247 | dp->d_name, dp->d_unit); | |
248 | continue; | |
249 | } | |
250 | uba_n = np->d_unit; | |
251 | if (dp->d_drive == UNKNOWN) { | |
252 | printf("must specify ``drive number'' "); | |
253 | printf("for %s%d\n", dp->d_name, dp->d_unit); | |
254 | continue; | |
255 | } | |
256 | /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ | |
257 | /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ | |
258 | if (dp->d_slave != UNKNOWN) { | |
259 | printf("slave numbers should be given only "); | |
260 | printf("for massbus tapes, not for %s%d\n", | |
261 | dp->d_name, dp->d_unit); | |
262 | continue; | |
263 | } | |
264 | if (dp->d_vec != 0) { | |
265 | printf("interrupt vectors should not be "); | |
266 | printf("given for drive %s%d\n", | |
267 | dp->d_name, dp->d_unit); | |
268 | continue; | |
269 | } | |
270 | if (dp->d_addr != 0) { | |
271 | printf("csr addresses should be given only "); | |
272 | printf("on controllers, not on %s%d\n", | |
273 | dp->d_name, dp->d_unit); | |
274 | continue; | |
275 | } | |
276 | slave = dp->d_drive; | |
277 | } | |
278 | fprintf(fp, "\t{ &%sdriver, %2d, %s,", | |
279 | eq(mp->d_name, "uba") ? dp->d_name : mp->d_name, dp->d_unit, | |
280 | eq(mp->d_name, "uba") ? " -1" : qu(mp->d_unit)); | |
281 | fprintf(fp, " %s, %2d, %s, C 0%-6o, %d, 0x%x },\n", | |
282 | qu(uba_n), slave, intv(dp), dp->d_addr, dp->d_dk, | |
283 | dp->d_flags); | |
284 | } | |
285 | fprintf(fp, "\t0\n};\n"); | |
286 | (void) fclose(fp); | |
287 | } | |
288 | #endif | |
289 | ||
290 | #if MACHINE_TAHOE | |
291 | tahoe_ioconf() | |
292 | { | |
293 | register struct device *dp, *mp, *np; | |
294 | register int vba_n, slave; | |
295 | FILE *fp; | |
296 | ||
297 | fp = fopen(path("ioconf.c"), "w"); | |
298 | if (fp == 0) { | |
299 | perror(path("ioconf.c")); | |
300 | exit(1); | |
301 | } | |
302 | fprintf(fp, "#include \"sys/param.h\"\n"); | |
303 | fprintf(fp, "#include \"tahoe/include/pte.h\"\n"); | |
304 | fprintf(fp, "#include \"sys/buf.h\"\n"); | |
305 | fprintf(fp, "#include \"sys/map.h\"\n"); | |
306 | fprintf(fp, "\n"); | |
307 | fprintf(fp, "#include \"tahoe/vba/vbavar.h\"\n"); | |
308 | fprintf(fp, "\n"); | |
309 | fprintf(fp, "#define C (caddr_t)\n\n"); | |
310 | /* | |
311 | * Now generate interrupt vectors for the versabus | |
312 | */ | |
313 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
314 | mp = dp->d_conn; | |
315 | if (mp == 0 || mp == TO_NEXUS || !eq(mp->d_name, "vba")) | |
316 | continue; | |
317 | if (dp->d_vec != 0) { | |
318 | struct idlst *ip; | |
319 | fprintf(fp, | |
320 | "extern struct vba_driver %sdriver;\n", | |
321 | dp->d_name); | |
322 | fprintf(fp, "extern "); | |
323 | ip = dp->d_vec; | |
324 | for (;;) { | |
325 | fprintf(fp, "X%s%d()", ip->id, dp->d_unit); | |
326 | ip = ip->id_next; | |
327 | if (ip == 0) | |
328 | break; | |
329 | fprintf(fp, ", "); | |
330 | } | |
331 | fprintf(fp, ";\n"); | |
332 | fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, | |
333 | dp->d_unit); | |
334 | ip = dp->d_vec; | |
335 | for (;;) { | |
336 | fprintf(fp, "X%s%d", ip->id, dp->d_unit); | |
337 | ip = ip->id_next; | |
338 | if (ip == 0) | |
339 | break; | |
340 | fprintf(fp, ", "); | |
341 | } | |
342 | fprintf(fp, ", 0 } ;\n"); | |
343 | } else if (dp->d_type == DRIVER) /* devices w/o | |
344 | * 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 *shandler(); | |
607 | char *sirq(); | |
608 | ||
609 | i386_ioconf() | |
610 | { | |
611 | register struct device *dp, *mp, *np; | |
612 | register int uba_n, slave; | |
613 | FILE *fp; | |
614 | ||
615 | fp = fopen(path("ioconf.c"), "w"); | |
616 | if (fp == 0) { | |
617 | perror(path("ioconf.c")); | |
618 | exit(1); | |
619 | } | |
620 | fprintf(fp, "/*\n"); | |
621 | fprintf(fp, " * ioconf.c \n"); | |
622 | fprintf(fp, " * Generated by config program\n"); | |
623 | fprintf(fp, " */\n\n"); | |
624 | fprintf(fp, "#include \"machine/pte.h\"\n"); | |
625 | fprintf(fp, "#include \"sys/param.h\"\n"); | |
626 | fprintf(fp, "#include \"sys/buf.h\"\n"); | |
627 | fprintf(fp, "\n"); | |
78ed81a3 | 628 | fprintf(fp, "#define V(s)\t__CONCAT(V,s)\n"); |
15637ed4 RG |
629 | fprintf(fp, "#define C (caddr_t)\n\n"); |
630 | /* | |
631 | * First print the isa initialization structures | |
632 | */ | |
633 | if (seen_isa) { | |
634 | ||
635 | fprintf(fp, "/*\n"); | |
636 | fprintf(fp, " * ISA devices\n"); | |
637 | fprintf(fp, " */\n\n"); | |
638 | fprintf(fp, "#include \"i386/isa/isa_device.h\"\n"); | |
639 | fprintf(fp, "#include \"i386/isa/isa.h\"\n"); | |
640 | fprintf(fp, "#include \"i386/isa/icu.h\"\n\n"); | |
641 | ||
642 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
643 | mp = dp->d_conn; | |
644 | if (mp == 0 || mp == TO_NEXUS || | |
645 | !eq(mp->d_name, "isa")) | |
646 | continue; | |
647 | fprintf(fp, "extern struct isa_driver %3.3sdriver;", | |
648 | dp->d_name); | |
649 | if (dp->d_irq == 2) | |
650 | { | |
651 | fprintf(stderr, "remapped irq 2 to irq 9, please update your config file\n"); | |
652 | dp->d_irq = 9; | |
653 | } | |
654 | if (dp->d_irq != -1) | |
655 | fprintf(fp, " extern %s();", shandler(dp)); | |
656 | fprintf(fp, "\n"); | |
657 | } | |
658 | isa_devtab(fp, "bio"); | |
659 | isa_devtab(fp, "tty"); | |
660 | isa_devtab(fp, "net"); | |
661 | isa_devtab(fp, "null"); | |
662 | } | |
663 | (void) fclose(fp); | |
664 | } | |
665 | /* | |
666 | * Generized routine for isa bus device table, instead of repeating | |
667 | * all this 4 times, call this with the table argument. | |
668 | * | |
669 | * 4/26/93 rgrimes | |
670 | */ | |
671 | isa_devtab(fp, table) | |
672 | FILE *fp; | |
673 | char *table; | |
674 | { | |
675 | register struct device *dp, *mp; | |
676 | ||
677 | fprintf(fp, "\n\nstruct isa_device isa_devtab_%s[] = {\n", table); | |
678 | fprintf(fp, "\ | |
679 | /* driver iobase irq drq maddr msiz intr unit flags */\n"); | |
680 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
681 | mp = dp->d_conn; | |
682 | if (dp->d_unit == QUES || mp == 0 || | |
683 | mp == TO_NEXUS || !eq(mp->d_name, "isa")) | |
684 | continue; | |
685 | if (strcmp(dp->d_mask, table)) continue; | |
686 | if (dp->d_port) | |
687 | fprintf(fp, "{ &%3.3sdriver, %8.8s,", | |
688 | dp->d_name, dp->d_port); | |
689 | else | |
690 | fprintf(fp, "{ &%3.3sdriver, 0x%04x,", | |
691 | dp->d_name, dp->d_portn); | |
692 | fprintf(fp, "%6.6s, %2d, C 0x%05X, %5d, %8.8s, %2d, 0x%04X },\n", | |
693 | sirq(dp->d_irq), dp->d_drq, dp->d_maddr, | |
694 | dp->d_msize, shandler(dp), dp->d_unit, | |
695 | dp->d_flags); | |
696 | } | |
697 | fprintf(fp, "0\n};\n"); | |
698 | } | |
699 | ||
700 | /* | |
701 | * XXX - there should be a general function to print devtabs instead of these | |
702 | * little pieces of it. | |
703 | */ | |
704 | ||
705 | char * | |
706 | shandler(dp) | |
707 | register struct device *dp; | |
708 | { | |
709 | static char buf[32 + 20]; | |
710 | ||
711 | if (dp->d_irq == -1) | |
712 | return ("NULL"); | |
713 | sprintf(buf, "V(%.32s%d)", dp->d_name, dp->d_unit); | |
714 | return (buf); | |
715 | } | |
716 | ||
717 | char * | |
718 | sirq(num) | |
719 | { | |
720 | ||
721 | if (num == -1) | |
722 | return ("0"); | |
723 | sprintf(errbuf, "IRQ%d", num); | |
724 | return (errbuf); | |
725 | } | |
726 | #endif | |
727 | ||
728 | char * | |
729 | intv(dev) | |
730 | register struct device *dev; | |
731 | { | |
732 | static char buf[20]; | |
733 | ||
734 | if (dev->d_vec == 0) | |
735 | return (" 0"); | |
736 | (void) sprintf(buf, "%sint%d", dev->d_name, dev->d_unit); | |
737 | return (buf); | |
738 | } | |
739 | ||
740 | char * | |
741 | qu(num) | |
742 | { | |
743 | ||
744 | if (num == QUES) | |
745 | return ("'?'"); | |
746 | if (num == UNKNOWN) | |
747 | return (" -1"); | |
748 | (void) sprintf(errbuf, "%3d", num); | |
749 | return (errbuf); | |
750 | } |