Commit | Line | Data |
---|---|---|
cd68466f DF |
1 | /* |
2 | * Copyright (c) 1980 Regents of the University of California. | |
86f9c1e9 KB |
3 | * All rights reserved. |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
b8c620d6 KB |
6 | * provided that the above copyright notice and this paragraph are |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
cd68466f DF |
16 | */ |
17 | ||
524aa063 | 18 | #ifndef lint |
f4b2fb14 | 19 | static char sccsid[] = "@(#)mkioconf.c 5.13 (Berkeley) %G%"; |
86f9c1e9 | 20 | #endif /* not lint */ |
5e794bde | 21 | |
b88ba334 BJ |
22 | #include <stdio.h> |
23 | #include "y.tab.h" | |
24 | #include "config.h" | |
25 | ||
26 | /* | |
5e794bde | 27 | * build the ioconf.c file |
b88ba334 | 28 | */ |
5e794bde | 29 | char *qu(); |
b312f544 | 30 | char *intv(); |
b88ba334 | 31 | |
b312f544 | 32 | #if MACHINE_VAX |
5e794bde | 33 | vax_ioconf() |
b88ba334 | 34 | { |
5e794bde BJ |
35 | register struct device *dp, *mp, *np; |
36 | register int uba_n, slave; | |
5e794bde | 37 | FILE *fp; |
b88ba334 | 38 | |
5e794bde | 39 | fp = fopen(path("ioconf.c"), "w"); |
22d68ad0 | 40 | if (fp == 0) { |
5e794bde BJ |
41 | perror(path("ioconf.c")); |
42 | exit(1); | |
b88ba334 | 43 | } |
4d8e340c | 44 | fprintf(fp, "#include \"machine/pte.h\"\n"); |
1ba95055 KM |
45 | fprintf(fp, "#include \"../sys/param.h\"\n"); |
46 | fprintf(fp, "#include \"../sys/buf.h\"\n"); | |
47 | fprintf(fp, "#include \"../sys/map.h\"\n"); | |
48 | fprintf(fp, "#include \"../sys/vm.h\"\n"); | |
5e794bde BJ |
49 | fprintf(fp, "\n"); |
50 | fprintf(fp, "#include \"../vaxmba/mbavar.h\"\n"); | |
51 | fprintf(fp, "#include \"../vaxuba/ubavar.h\"\n\n"); | |
52 | fprintf(fp, "\n"); | |
53 | fprintf(fp, "#define C (caddr_t)\n\n"); | |
54 | /* | |
55 | * First print the mba initialization structures | |
56 | */ | |
57 | if (seen_mba) { | |
22d68ad0 | 58 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
5e794bde | 59 | mp = dp->d_conn; |
22d68ad0 | 60 | if (mp == 0 || mp == TO_NEXUS || |
5e794bde BJ |
61 | !eq(mp->d_name, "mba")) |
62 | continue; | |
63 | fprintf(fp, "extern struct mba_driver %sdriver;\n", | |
64 | dp->d_name); | |
65 | } | |
66 | fprintf(fp, "\nstruct mba_device mbdinit[] = {\n"); | |
67 | fprintf(fp, "\t/* Device, Unit, Mba, Drive, Dk */\n"); | |
22d68ad0 | 68 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
5e794bde | 69 | mp = dp->d_conn; |
22d68ad0 | 70 | if (dp->d_unit == QUES || mp == 0 || |
5e794bde BJ |
71 | mp == TO_NEXUS || !eq(mp->d_name, "mba")) |
72 | continue; | |
73 | if (dp->d_addr) { | |
74 | printf("can't specify csr address on mba for %s%d\n", | |
75 | dp->d_name, dp->d_unit); | |
76 | continue; | |
77 | } | |
22d68ad0 | 78 | if (dp->d_vec != 0) { |
5e794bde BJ |
79 | printf("can't specify vector for %s%d on mba\n", |
80 | dp->d_name, dp->d_unit); | |
81 | continue; | |
82 | } | |
83 | if (dp->d_drive == UNKNOWN) { | |
84 | printf("drive not specified for %s%d\n", | |
85 | dp->d_name, dp->d_unit); | |
86 | continue; | |
87 | } | |
88 | if (dp->d_slave != UNKNOWN) { | |
89 | printf("can't specify slave number for %s%d\n", | |
90 | dp->d_name, dp->d_unit); | |
91 | continue; | |
92 | } | |
0c51914c SL |
93 | fprintf(fp, "\t{ &%sdriver, %d, %s,", |
94 | dp->d_name, dp->d_unit, qu(mp->d_unit)); | |
95 | fprintf(fp, " %s, %d },\n", | |
5e794bde BJ |
96 | qu(dp->d_drive), dp->d_dk); |
97 | } | |
98 | fprintf(fp, "\t0\n};\n\n"); | |
99 | /* | |
100 | * Print the mbsinit structure | |
101 | * Driver Controller Unit Slave | |
102 | */ | |
103 | fprintf(fp, "struct mba_slave mbsinit [] = {\n"); | |
104 | fprintf(fp, "\t/* Driver, Ctlr, Unit, Slave */\n"); | |
22d68ad0 | 105 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
5e794bde BJ |
106 | /* |
107 | * All slaves are connected to something which | |
108 | * is connected to the massbus. | |
109 | */ | |
22d68ad0 | 110 | if ((mp = dp->d_conn) == 0 || mp == TO_NEXUS) |
5e794bde BJ |
111 | continue; |
112 | np = mp->d_conn; | |
22d68ad0 | 113 | if (np == 0 || np == TO_NEXUS || |
5e794bde BJ |
114 | !eq(np->d_name, "mba")) |
115 | continue; | |
0ad2198c SL |
116 | fprintf(fp, "\t{ &%sdriver, %s", |
117 | mp->d_name, qu(mp->d_unit)); | |
118 | fprintf(fp, ", %2d, %s },\n", | |
119 | dp->d_unit, qu(dp->d_slave)); | |
5e794bde BJ |
120 | } |
121 | fprintf(fp, "\t0\n};\n\n"); | |
b88ba334 | 122 | } |
b88ba334 | 123 | /* |
5e794bde | 124 | * Now generate interrupt vectors for the unibus |
b88ba334 | 125 | */ |
22d68ad0 BJ |
126 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
127 | if (dp->d_vec != 0) { | |
5e794bde BJ |
128 | struct idlst *ip; |
129 | mp = dp->d_conn; | |
22d68ad0 | 130 | if (mp == 0 || mp == TO_NEXUS || |
67259f7b | 131 | (!eq(mp->d_name, "uba") && !eq(mp->d_name, "bi"))) |
5e794bde BJ |
132 | continue; |
133 | fprintf(fp, | |
134 | "extern struct uba_driver %sdriver;\n", | |
135 | dp->d_name); | |
136 | fprintf(fp, "extern "); | |
137 | ip = dp->d_vec; | |
138 | for (;;) { | |
139 | fprintf(fp, "X%s%d()", ip->id, dp->d_unit); | |
140 | ip = ip->id_next; | |
141 | if (ip == 0) | |
142 | break; | |
143 | fprintf(fp, ", "); | |
144 | } | |
145 | fprintf(fp, ";\n"); | |
146 | fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, | |
a0897453 | 147 | dp->d_unit); |
5e794bde BJ |
148 | ip = dp->d_vec; |
149 | for (;;) { | |
150 | fprintf(fp, "X%s%d", ip->id, dp->d_unit); | |
151 | ip = ip->id_next; | |
152 | if (ip == 0) | |
153 | break; | |
154 | fprintf(fp, ", "); | |
155 | } | |
156 | fprintf(fp, ", 0 } ;\n"); | |
157 | } | |
b88ba334 | 158 | } |
5e794bde BJ |
159 | fprintf(fp, "\nstruct uba_ctlr ubminit[] = {\n"); |
160 | fprintf(fp, "/*\t driver,\tctlr,\tubanum,\talive,\tintr,\taddr */\n"); | |
22d68ad0 | 161 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
5e794bde | 162 | mp = dp->d_conn; |
22d68ad0 | 163 | if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || |
5e794bde BJ |
164 | !eq(mp->d_name, "uba")) |
165 | continue; | |
166 | if (dp->d_vec == 0) { | |
167 | printf("must specify vector for %s%d\n", | |
168 | dp->d_name, dp->d_unit); | |
169 | continue; | |
170 | } | |
171 | if (dp->d_addr == 0) { | |
172 | printf("must specify csr address for %s%d\n", | |
173 | dp->d_name, dp->d_unit); | |
174 | continue; | |
175 | } | |
176 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
177 | printf("drives need their own entries; dont "); | |
178 | printf("specify drive or slave for %s%d\n", | |
179 | dp->d_name, dp->d_unit); | |
180 | continue; | |
181 | } | |
182 | if (dp->d_flags) { | |
183 | printf("controllers (e.g. %s%d) ", | |
184 | dp->d_name, dp->d_unit); | |
185 | printf("don't have flags, only devices do\n"); | |
186 | continue; | |
187 | } | |
188 | fprintf(fp, | |
189 | "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0%o },\n", | |
190 | dp->d_name, dp->d_unit, qu(mp->d_unit), | |
191 | dp->d_name, dp->d_unit, dp->d_addr); | |
b88ba334 | 192 | } |
5e794bde | 193 | fprintf(fp, "\t0\n};\n"); |
36e00264 | 194 | /* unibus devices */ |
5e794bde | 195 | fprintf(fp, "\nstruct uba_device ubdinit[] = {\n"); |
36e00264 BJ |
196 | fprintf(fp, |
197 | "\t/* driver, unit, ctlr, ubanum, slave, intr, addr, dk, flags*/\n"); | |
22d68ad0 | 198 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
5e794bde | 199 | mp = dp->d_conn; |
22d68ad0 | 200 | if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || |
5e794bde BJ |
201 | mp == TO_NEXUS || mp->d_type == MASTER || |
202 | eq(mp->d_name, "mba")) | |
203 | continue; | |
204 | np = mp->d_conn; | |
22d68ad0 | 205 | if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) |
5e794bde | 206 | continue; |
22d68ad0 | 207 | np = 0; |
5e794bde BJ |
208 | if (eq(mp->d_name, "uba")) { |
209 | if (dp->d_vec == 0) { | |
210 | printf("must specify vector for device %s%d\n", | |
211 | dp->d_name, dp->d_unit); | |
212 | continue; | |
213 | } | |
214 | if (dp->d_addr == 0) { | |
215 | printf("must specify csr for device %s%d\n", | |
216 | dp->d_name, dp->d_unit); | |
217 | continue; | |
218 | } | |
219 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
220 | printf("drives/slaves can be specified "); | |
221 | printf("only for controllers, "); | |
222 | printf("not for device %s%d\n", | |
223 | dp->d_name, dp->d_unit); | |
224 | continue; | |
225 | } | |
226 | uba_n = mp->d_unit; | |
227 | slave = QUES; | |
228 | } else { | |
22d68ad0 | 229 | if ((np = mp->d_conn) == 0) { |
5e794bde BJ |
230 | printf("%s%d isn't connected to anything ", |
231 | mp->d_name, mp->d_unit); | |
232 | printf(", so %s%d is unattached\n", | |
233 | dp->d_name, dp->d_unit); | |
234 | continue; | |
235 | } | |
236 | uba_n = np->d_unit; | |
237 | if (dp->d_drive == UNKNOWN) { | |
238 | printf("must specify ``drive number'' "); | |
239 | printf("for %s%d\n", dp->d_name, dp->d_unit); | |
240 | continue; | |
241 | } | |
242 | /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ | |
243 | /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ | |
244 | if (dp->d_slave != UNKNOWN) { | |
245 | printf("slave numbers should be given only "); | |
246 | printf("for massbus tapes, not for %s%d\n", | |
247 | dp->d_name, dp->d_unit); | |
248 | continue; | |
249 | } | |
250 | if (dp->d_vec != 0) { | |
251 | printf("interrupt vectors should not be "); | |
252 | printf("given for drive %s%d\n", | |
253 | dp->d_name, dp->d_unit); | |
254 | continue; | |
255 | } | |
256 | if (dp->d_addr != 0) { | |
257 | printf("csr addresses should be given only "); | |
258 | printf("on controllers, not on %s%d\n", | |
259 | dp->d_name, dp->d_unit); | |
260 | continue; | |
261 | } | |
262 | slave = dp->d_drive; | |
263 | } | |
0c51914c | 264 | fprintf(fp, "\t{ &%sdriver, %2d, %s,", |
5e794bde | 265 | eq(mp->d_name, "uba") ? dp->d_name : mp->d_name, dp->d_unit, |
0c51914c SL |
266 | eq(mp->d_name, "uba") ? " -1" : qu(mp->d_unit)); |
267 | fprintf(fp, " %s, %2d, %s, C 0%-6o, %d, 0x%x },\n", | |
268 | qu(uba_n), slave, intv(dp), dp->d_addr, dp->d_dk, | |
269 | dp->d_flags); | |
b88ba334 | 270 | } |
5e794bde | 271 | fprintf(fp, "\t0\n};\n"); |
22d68ad0 | 272 | (void) fclose(fp); |
5e794bde | 273 | } |
b312f544 | 274 | #endif |
5e794bde | 275 | |
a0105456 SL |
276 | #if MACHINE_TAHOE |
277 | tahoe_ioconf() | |
5e794bde | 278 | { |
a0105456 SL |
279 | register struct device *dp, *mp, *np; |
280 | register int vba_n, slave; | |
5e794bde BJ |
281 | FILE *fp; |
282 | ||
283 | fp = fopen(path("ioconf.c"), "w"); | |
22d68ad0 | 284 | if (fp == 0) { |
5e794bde BJ |
285 | perror(path("ioconf.c")); |
286 | exit(1); | |
b88ba334 | 287 | } |
1ba95055 | 288 | fprintf(fp, "#include \"../sys/param.h\"\n"); |
4d8e340c | 289 | fprintf(fp, "#include \"machine/pte.h\"\n"); |
1ba95055 KM |
290 | fprintf(fp, "#include \"../sys/buf.h\"\n"); |
291 | fprintf(fp, "#include \"../sys/map.h\"\n"); | |
5e794bde | 292 | fprintf(fp, "\n"); |
a0105456 | 293 | fprintf(fp, "#include \"../tahoevba/vbavar.h\"\n"); |
5e794bde BJ |
294 | fprintf(fp, "\n"); |
295 | fprintf(fp, "#define C (caddr_t)\n\n"); | |
5e794bde | 296 | /* |
a0105456 | 297 | * Now generate interrupt vectors for the versabus |
5e794bde | 298 | */ |
22d68ad0 | 299 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
dff1a390 SL |
300 | mp = dp->d_conn; |
301 | if (mp == 0 || mp == TO_NEXUS || !eq(mp->d_name, "vba")) | |
302 | continue; | |
a0105456 SL |
303 | if (dp->d_vec != 0) { |
304 | struct idlst *ip; | |
a0105456 SL |
305 | fprintf(fp, |
306 | "extern struct vba_driver %sdriver;\n", | |
5e794bde | 307 | dp->d_name); |
a0105456 SL |
308 | fprintf(fp, "extern "); |
309 | ip = dp->d_vec; | |
310 | for (;;) { | |
311 | fprintf(fp, "X%s%d()", ip->id, dp->d_unit); | |
312 | ip = ip->id_next; | |
313 | if (ip == 0) | |
314 | break; | |
315 | fprintf(fp, ", "); | |
316 | } | |
317 | fprintf(fp, ";\n"); | |
318 | fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, | |
83e6c7a7 | 319 | dp->d_unit); |
a0105456 SL |
320 | ip = dp->d_vec; |
321 | for (;;) { | |
322 | fprintf(fp, "X%s%d", ip->id, dp->d_unit); | |
323 | ip = ip->id_next; | |
324 | if (ip == 0) | |
325 | break; | |
326 | fprintf(fp, ", "); | |
327 | } | |
328 | fprintf(fp, ", 0 } ;\n"); | |
dff1a390 SL |
329 | } else if (dp->d_type == DRIVER) /* devices w/o interrupts */ |
330 | fprintf(fp, | |
331 | "extern struct vba_driver %sdriver;\n", | |
332 | dp->d_name); | |
b88ba334 | 333 | } |
a0105456 SL |
334 | fprintf(fp, "\nstruct vba_ctlr vbminit[] = {\n"); |
335 | fprintf(fp, "/*\t driver,\tctlr,\tvbanum,\talive,\tintr,\taddr */\n"); | |
22d68ad0 | 336 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
5e794bde | 337 | mp = dp->d_conn; |
22d68ad0 | 338 | if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || |
a0105456 | 339 | !eq(mp->d_name, "vba")) |
5e794bde | 340 | continue; |
a0105456 SL |
341 | if (dp->d_vec == 0) { |
342 | printf("must specify vector for %s%d\n", | |
5e794bde BJ |
343 | dp->d_name, dp->d_unit); |
344 | continue; | |
345 | } | |
346 | if (dp->d_addr == 0) { | |
347 | printf("must specify csr address for %s%d\n", | |
348 | dp->d_name, dp->d_unit); | |
349 | continue; | |
350 | } | |
351 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
a0105456 SL |
352 | printf("drives need their own entries; dont "); |
353 | printf("specify drive or slave for %s%d\n", | |
5e794bde BJ |
354 | dp->d_name, dp->d_unit); |
355 | continue; | |
356 | } | |
357 | if (dp->d_flags) { | |
a0105456 | 358 | printf("controllers (e.g. %s%d) ", |
5e794bde | 359 | dp->d_name, dp->d_unit); |
a0105456 | 360 | printf("don't have flags, only devices do\n"); |
5e794bde BJ |
361 | continue; |
362 | } | |
a0105456 SL |
363 | fprintf(fp, |
364 | "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0x%x },\n", | |
365 | dp->d_name, dp->d_unit, qu(mp->d_unit), | |
366 | dp->d_name, dp->d_unit, dp->d_addr); | |
b88ba334 | 367 | } |
5e794bde | 368 | fprintf(fp, "\t0\n};\n"); |
a0105456 SL |
369 | /* versabus devices */ |
370 | fprintf(fp, "\nstruct vba_device vbdinit[] = {\n"); | |
5e794bde | 371 | fprintf(fp, |
a0105456 | 372 | "\t/* driver, unit, ctlr, vbanum, slave, intr, addr, dk, flags*/\n"); |
22d68ad0 | 373 | for (dp = dtab; dp != 0; dp = dp->d_next) { |
5e794bde | 374 | mp = dp->d_conn; |
22d68ad0 | 375 | if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || |
5e794bde BJ |
376 | mp == TO_NEXUS || mp->d_type == MASTER || |
377 | eq(mp->d_name, "mba")) | |
378 | continue; | |
a0105456 SL |
379 | np = mp->d_conn; |
380 | if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) | |
381 | continue; | |
382 | np = 0; | |
383 | if (eq(mp->d_name, "vba")) { | |
a6df0f0e SL |
384 | if (dp->d_vec == 0) |
385 | printf( | |
386 | "Warning, no interrupt vector specified for device %s%d\n", | |
5e794bde | 387 | dp->d_name, dp->d_unit); |
5e794bde BJ |
388 | if (dp->d_addr == 0) { |
389 | printf("must specify csr for device %s%d\n", | |
390 | dp->d_name, dp->d_unit); | |
391 | continue; | |
392 | } | |
393 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
a0105456 SL |
394 | printf("drives/slaves can be specified "); |
395 | printf("only for controllers, "); | |
396 | printf("not for device %s%d\n", | |
5e794bde BJ |
397 | dp->d_name, dp->d_unit); |
398 | continue; | |
399 | } | |
a0105456 | 400 | vba_n = mp->d_unit; |
5e794bde BJ |
401 | slave = QUES; |
402 | } else { | |
a0105456 SL |
403 | if ((np = mp->d_conn) == 0) { |
404 | printf("%s%d isn't connected to anything ", | |
5e794bde | 405 | mp->d_name, mp->d_unit); |
a0105456 | 406 | printf(", so %s%d is unattached\n", |
5e794bde BJ |
407 | dp->d_name, dp->d_unit); |
408 | continue; | |
409 | } | |
a0105456 | 410 | vba_n = np->d_unit; |
5e794bde | 411 | if (dp->d_drive == UNKNOWN) { |
a0105456 SL |
412 | printf("must specify ``drive number'' "); |
413 | printf("for %s%d\n", dp->d_name, dp->d_unit); | |
5e794bde BJ |
414 | continue; |
415 | } | |
416 | /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ | |
417 | /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ | |
418 | if (dp->d_slave != UNKNOWN) { | |
419 | printf("slave numbers should be given only "); | |
420 | printf("for massbus tapes, not for %s%d\n", | |
421 | dp->d_name, dp->d_unit); | |
422 | continue; | |
423 | } | |
a0105456 SL |
424 | if (dp->d_vec != 0) { |
425 | printf("interrupt vectors should not be "); | |
5e794bde BJ |
426 | printf("given for drive %s%d\n", |
427 | dp->d_name, dp->d_unit); | |
428 | continue; | |
429 | } | |
430 | if (dp->d_addr != 0) { | |
a0105456 | 431 | printf("csr addresses should be given only "); |
5e794bde BJ |
432 | printf("on controllers, not on %s%d\n", |
433 | dp->d_name, dp->d_unit); | |
434 | continue; | |
435 | } | |
436 | slave = dp->d_drive; | |
437 | } | |
a0105456 SL |
438 | fprintf(fp, "\t{ &%sdriver, %2d, %s,", |
439 | eq(mp->d_name, "vba") ? dp->d_name : mp->d_name, dp->d_unit, | |
440 | eq(mp->d_name, "vba") ? " -1" : qu(mp->d_unit)); | |
441 | fprintf(fp, " %s, %2d, %s, C 0x%-6x, %d, 0x%x },\n", | |
442 | qu(vba_n), slave, intv(dp), dp->d_addr, dp->d_dk, | |
443 | dp->d_flags); | |
b88ba334 | 444 | } |
5e794bde | 445 | fprintf(fp, "\t0\n};\n"); |
22d68ad0 | 446 | (void) fclose(fp); |
b88ba334 | 447 | } |
b312f544 | 448 | #endif |
b88ba334 | 449 | |
f4b2fb14 KM |
450 | #if MACHINE_HP300 |
451 | hp300_ioconf() | |
452 | { | |
453 | register struct device *dp, *mp, *np; | |
454 | register int hpib, slave; | |
455 | FILE *fp; | |
456 | extern char *wnum(); | |
457 | ||
458 | fp = fopen(path("ioconf.c"), "w"); | |
459 | if (fp == 0) { | |
460 | perror(path("ioconf.c")); | |
461 | exit(1); | |
462 | } | |
463 | fprintf(fp, "#include \"machine/pte.h\"\n"); | |
464 | fprintf(fp, "#include \"../sys/param.h\"\n"); | |
465 | fprintf(fp, "#include \"../sys/buf.h\"\n"); | |
466 | fprintf(fp, "#include \"../sys/map.h\"\n"); | |
467 | fprintf(fp, "#include \"../sys/vm.h\"\n"); | |
468 | fprintf(fp, "\n"); | |
469 | fprintf(fp, "#include \"../hpdev/device.h\"\n\n"); | |
470 | fprintf(fp, "\n"); | |
471 | fprintf(fp, "#define C (caddr_t)\n"); | |
472 | fprintf(fp, "#define D (struct driver *)\n\n"); | |
473 | /* | |
474 | * First print the hpib controller initialization structures | |
475 | */ | |
476 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
477 | mp = dp->d_conn; | |
478 | if (dp->d_unit == QUES || mp == 0) | |
479 | continue; | |
480 | fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); | |
481 | } | |
482 | fprintf(fp, "\nstruct hp_ctlr hp_cinit[] = {\n"); | |
483 | fprintf(fp, "/*\tdriver,\t\tunit,\talive,\taddr,\tflags */\n"); | |
484 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
485 | mp = dp->d_conn; | |
486 | if (dp->d_unit == QUES || | |
487 | dp->d_type != MASTER && dp->d_type != CONTROLLER) | |
488 | continue; | |
489 | if (mp != TO_NEXUS) { | |
490 | printf("%s%s must be attached to an sc (nexus)\n", | |
491 | dp->d_name, wnum(dp->d_unit)); | |
492 | continue; | |
493 | } | |
494 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
495 | printf("can't specify drive/slave for %s%s\n", | |
496 | dp->d_name, wnum(dp->d_unit)); | |
497 | continue; | |
498 | } | |
499 | fprintf(fp, | |
500 | "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t0x%x },\n", | |
501 | dp->d_name, dp->d_unit, dp->d_addr, dp->d_flags); | |
502 | } | |
503 | fprintf(fp, "\t0\n};\n"); | |
504 | /* devices */ | |
505 | fprintf(fp, "\nstruct hp_device hp_dinit[] = {\n"); | |
506 | fprintf(fp, | |
507 | "/*driver,\tcdriver,\tunit,\tctlr,\tslave,\taddr,\tdk,\tflags*/\n"); | |
508 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
509 | mp = dp->d_conn; | |
510 | if (mp == 0 || dp->d_type != DEVICE || hpbadslave(mp, dp)) | |
511 | continue; | |
512 | if (mp == TO_NEXUS) { | |
513 | if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { | |
514 | printf("can't specify drive/slave for %s%s\n", | |
515 | dp->d_name, wnum(dp->d_unit)); | |
516 | continue; | |
517 | } | |
518 | slave = QUES; | |
519 | hpib = QUES; | |
520 | } else { | |
521 | if (dp->d_addr != 0) { | |
522 | printf("can't specify sc for device %s%s\n", | |
523 | dp->d_name, wnum(dp->d_unit)); | |
524 | continue; | |
525 | } | |
526 | if (mp->d_type == CONTROLLER) { | |
527 | if (dp->d_drive == UNKNOWN) { | |
528 | printf("must specify drive for %s%s\n", | |
529 | dp->d_name, wnum(dp->d_unit)); | |
530 | continue; | |
531 | } | |
532 | slave = dp->d_drive; | |
533 | } else { | |
534 | if (dp->d_slave == UNKNOWN) { | |
535 | printf("must specify slave for %s%s\n", | |
536 | dp->d_name, wnum(dp->d_unit)); | |
537 | continue; | |
538 | } | |
539 | slave = dp->d_slave; | |
540 | } | |
541 | hpib = mp->d_unit; | |
542 | } | |
543 | fprintf(fp, "{ &%sdriver,\t", dp->d_name); | |
544 | if (mp == TO_NEXUS) | |
545 | fprintf(fp, "D 0x0,\t"); | |
546 | else | |
547 | fprintf(fp, "&%sdriver,", mp->d_name); | |
548 | fprintf(fp, "\t%d,\t%d,\t%d,\tC 0x%x,\t%d,\t0x%x },\n", | |
549 | dp->d_unit, hpib, slave, | |
550 | dp->d_addr, dp->d_dk, dp->d_flags); | |
551 | } | |
552 | fprintf(fp, "0\n};\n"); | |
553 | (void) fclose(fp); | |
554 | } | |
555 | ||
556 | #define ishpibdev(n) (eq(n,"rd") || eq(n,"ct") || eq(n,"mt") || eq(n,"ppi")) | |
557 | #define isscsidev(n) (eq(n,"sd") || eq(n,"st")) | |
558 | ||
559 | hpbadslave(mp, dp) | |
560 | register struct device *dp, *mp; | |
561 | { | |
562 | extern char *wnum(); | |
563 | ||
564 | if (mp == TO_NEXUS && ishpibdev(dp->d_name) || | |
565 | mp != TO_NEXUS && eq(mp->d_name, "hpib") && | |
566 | !ishpibdev(dp->d_name)) { | |
567 | printf("%s%s must be attached to an hpib\n", | |
568 | dp->d_name, wnum(dp->d_unit)); | |
569 | return (1); | |
570 | } | |
571 | if (mp == TO_NEXUS && isscsidev(dp->d_name) || | |
572 | mp != TO_NEXUS && eq(mp->d_name, "scsi") && | |
573 | !isscsidev(dp->d_name)) { | |
574 | printf("%s%s must be attached to a scsi\n", | |
575 | dp->d_name, wnum(dp->d_unit)); | |
576 | return (1); | |
577 | } | |
578 | return (0); | |
579 | } | |
580 | ||
581 | char * | |
582 | wnum(num) | |
583 | { | |
584 | ||
585 | if (num == QUES || num == UNKNOWN) | |
586 | return ("?"); | |
587 | (void) sprintf(errbuf, "%d", num); | |
588 | return (errbuf); | |
589 | } | |
590 | #endif | |
591 | ||
a6df0f0e SL |
592 | char * |
593 | intv(dev) | |
5e794bde | 594 | register struct device *dev; |
b88ba334 BJ |
595 | { |
596 | static char buf[20]; | |
597 | ||
5e794bde BJ |
598 | if (dev->d_vec == 0) |
599 | return (" 0"); | |
9bd38ba8 KB |
600 | (void) sprintf(buf, "%sint%d", dev->d_name, dev->d_unit); |
601 | return (buf); | |
b88ba334 BJ |
602 | } |
603 | ||
604 | char * | |
605 | qu(num) | |
606 | { | |
5e794bde | 607 | |
b88ba334 | 608 | if (num == QUES) |
5e794bde | 609 | return ("'?'"); |
22d68ad0 | 610 | if (num == UNKNOWN) |
5e794bde | 611 | return (" -1"); |
9bd38ba8 KB |
612 | (void) sprintf(errbuf, "%3d", num); |
613 | return (errbuf); | |
b88ba334 | 614 | } |