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