BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.sbin / config / mkioconf.c
CommitLineData
cd68466f
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
86f9c1e9
KB
3 * All rights reserved.
4 *
af359dea
C
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.
cd68466f
DF
32 */
33
524aa063 34#ifndef lint
af359dea 35static char sccsid[] = "@(#)mkioconf.c 5.18 (Berkeley) 5/10/91";
86f9c1e9 36#endif /* not lint */
5e794bde 37
b88ba334
BJ
38#include <stdio.h>
39#include "y.tab.h"
40#include "config.h"
41
42/*
5e794bde 43 * build the ioconf.c file
b88ba334 44 */
5e794bde 45char *qu();
b312f544 46char *intv();
b88ba334 47
b312f544 48#if MACHINE_VAX
5e794bde 49vax_ioconf()
b88ba334 50{
5e794bde
BJ
51 register struct device *dp, *mp, *np;
52 register int uba_n, slave;
5e794bde 53 FILE *fp;
b88ba334 54
5e794bde 55 fp = fopen(path("ioconf.c"), "w");
22d68ad0 56 if (fp == 0) {
5e794bde
BJ
57 perror(path("ioconf.c"));
58 exit(1);
b88ba334 59 }
d0aa7457
KB
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");
5e794bde 64 fprintf(fp, "\n");
d0aa7457
KB
65 fprintf(fp, "#include \"vax/mba/mbavar.h\"\n");
66 fprintf(fp, "#include \"vax/uba/ubavar.h\"\n\n");
5e794bde
BJ
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) {
22d68ad0 73 for (dp = dtab; dp != 0; dp = dp->d_next) {
5e794bde 74 mp = dp->d_conn;
22d68ad0 75 if (mp == 0 || mp == TO_NEXUS ||
5e794bde
BJ
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");
22d68ad0 83 for (dp = dtab; dp != 0; dp = dp->d_next) {
5e794bde 84 mp = dp->d_conn;
22d68ad0 85 if (dp->d_unit == QUES || mp == 0 ||
5e794bde
BJ
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 }
22d68ad0 93 if (dp->d_vec != 0) {
5e794bde
BJ
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 }
0c51914c
SL
108 fprintf(fp, "\t{ &%sdriver, %d, %s,",
109 dp->d_name, dp->d_unit, qu(mp->d_unit));
110 fprintf(fp, " %s, %d },\n",
5e794bde
BJ
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");
22d68ad0 120 for (dp = dtab; dp != 0; dp = dp->d_next) {
5e794bde
BJ
121 /*
122 * All slaves are connected to something which
123 * is connected to the massbus.
124 */
22d68ad0 125 if ((mp = dp->d_conn) == 0 || mp == TO_NEXUS)
5e794bde
BJ
126 continue;
127 np = mp->d_conn;
22d68ad0 128 if (np == 0 || np == TO_NEXUS ||
5e794bde
BJ
129 !eq(np->d_name, "mba"))
130 continue;
0ad2198c
SL
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));
5e794bde
BJ
135 }
136 fprintf(fp, "\t0\n};\n\n");
b88ba334 137 }
b88ba334 138 /*
5e794bde 139 * Now generate interrupt vectors for the unibus
b88ba334 140 */
22d68ad0
BJ
141 for (dp = dtab; dp != 0; dp = dp->d_next) {
142 if (dp->d_vec != 0) {
5e794bde
BJ
143 struct idlst *ip;
144 mp = dp->d_conn;
22d68ad0 145 if (mp == 0 || mp == TO_NEXUS ||
67259f7b 146 (!eq(mp->d_name, "uba") && !eq(mp->d_name, "bi")))
5e794bde
BJ
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,
a0897453 162 dp->d_unit);
5e794bde
BJ
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 }
b88ba334 173 }
5e794bde
BJ
174 fprintf(fp, "\nstruct uba_ctlr ubminit[] = {\n");
175 fprintf(fp, "/*\t driver,\tctlr,\tubanum,\talive,\tintr,\taddr */\n");
22d68ad0 176 for (dp = dtab; dp != 0; dp = dp->d_next) {
5e794bde 177 mp = dp->d_conn;
22d68ad0 178 if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 ||
5e794bde
BJ
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);
b88ba334 207 }
5e794bde 208 fprintf(fp, "\t0\n};\n");
36e00264 209/* unibus devices */
5e794bde 210 fprintf(fp, "\nstruct uba_device ubdinit[] = {\n");
36e00264
BJ
211 fprintf(fp,
212"\t/* driver, unit, ctlr, ubanum, slave, intr, addr, dk, flags*/\n");
22d68ad0 213 for (dp = dtab; dp != 0; dp = dp->d_next) {
5e794bde 214 mp = dp->d_conn;
22d68ad0 215 if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 ||
5e794bde
BJ
216 mp == TO_NEXUS || mp->d_type == MASTER ||
217 eq(mp->d_name, "mba"))
218 continue;
219 np = mp->d_conn;
22d68ad0 220 if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba"))
5e794bde 221 continue;
22d68ad0 222 np = 0;
5e794bde
BJ
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 {
22d68ad0 244 if ((np = mp->d_conn) == 0) {
5e794bde
BJ
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 }
0c51914c 279 fprintf(fp, "\t{ &%sdriver, %2d, %s,",
5e794bde 280 eq(mp->d_name, "uba") ? dp->d_name : mp->d_name, dp->d_unit,
0c51914c
SL
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);
b88ba334 285 }
5e794bde 286 fprintf(fp, "\t0\n};\n");
22d68ad0 287 (void) fclose(fp);
5e794bde 288}
b312f544 289#endif
5e794bde 290
a0105456
SL
291#if MACHINE_TAHOE
292tahoe_ioconf()
5e794bde 293{
a0105456
SL
294 register struct device *dp, *mp, *np;
295 register int vba_n, slave;
5e794bde
BJ
296 FILE *fp;
297
298 fp = fopen(path("ioconf.c"), "w");
22d68ad0 299 if (fp == 0) {
5e794bde
BJ
300 perror(path("ioconf.c"));
301 exit(1);
b88ba334 302 }
d0aa7457
KB
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");
5e794bde 307 fprintf(fp, "\n");
d0aa7457 308 fprintf(fp, "#include \"tahoe/vba/vbavar.h\"\n");
5e794bde
BJ
309 fprintf(fp, "\n");
310 fprintf(fp, "#define C (caddr_t)\n\n");
5e794bde 311 /*
a0105456 312 * Now generate interrupt vectors for the versabus
5e794bde 313 */
22d68ad0 314 for (dp = dtab; dp != 0; dp = dp->d_next) {
dff1a390
SL
315 mp = dp->d_conn;
316 if (mp == 0 || mp == TO_NEXUS || !eq(mp->d_name, "vba"))
317 continue;
a0105456
SL
318 if (dp->d_vec != 0) {
319 struct idlst *ip;
a0105456
SL
320 fprintf(fp,
321 "extern struct vba_driver %sdriver;\n",
5e794bde 322 dp->d_name);
a0105456
SL
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,
83e6c7a7 334 dp->d_unit);
a0105456
SL
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");
dff1a390
SL
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);
b88ba334 348 }
a0105456
SL
349 fprintf(fp, "\nstruct vba_ctlr vbminit[] = {\n");
350 fprintf(fp, "/*\t driver,\tctlr,\tvbanum,\talive,\tintr,\taddr */\n");
22d68ad0 351 for (dp = dtab; dp != 0; dp = dp->d_next) {
5e794bde 352 mp = dp->d_conn;
22d68ad0 353 if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 ||
a0105456 354 !eq(mp->d_name, "vba"))
5e794bde 355 continue;
a0105456
SL
356 if (dp->d_vec == 0) {
357 printf("must specify vector for %s%d\n",
5e794bde
BJ
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) {
a0105456
SL
367 printf("drives need their own entries; dont ");
368 printf("specify drive or slave for %s%d\n",
5e794bde
BJ
369 dp->d_name, dp->d_unit);
370 continue;
371 }
372 if (dp->d_flags) {
a0105456 373 printf("controllers (e.g. %s%d) ",
5e794bde 374 dp->d_name, dp->d_unit);
a0105456 375 printf("don't have flags, only devices do\n");
5e794bde
BJ
376 continue;
377 }
a0105456
SL
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);
b88ba334 382 }
5e794bde 383 fprintf(fp, "\t0\n};\n");
a0105456
SL
384/* versabus devices */
385 fprintf(fp, "\nstruct vba_device vbdinit[] = {\n");
5e794bde 386 fprintf(fp,
a0105456 387"\t/* driver, unit, ctlr, vbanum, slave, intr, addr, dk, flags*/\n");
22d68ad0 388 for (dp = dtab; dp != 0; dp = dp->d_next) {
5e794bde 389 mp = dp->d_conn;
22d68ad0 390 if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 ||
5e794bde
BJ
391 mp == TO_NEXUS || mp->d_type == MASTER ||
392 eq(mp->d_name, "mba"))
393 continue;
a0105456
SL
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")) {
a6df0f0e
SL
399 if (dp->d_vec == 0)
400 printf(
401 "Warning, no interrupt vector specified for device %s%d\n",
5e794bde 402 dp->d_name, dp->d_unit);
5e794bde
BJ
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) {
a0105456
SL
409 printf("drives/slaves can be specified ");
410 printf("only for controllers, ");
411 printf("not for device %s%d\n",
5e794bde
BJ
412 dp->d_name, dp->d_unit);
413 continue;
414 }
a0105456 415 vba_n = mp->d_unit;
5e794bde
BJ
416 slave = QUES;
417 } else {
a0105456
SL
418 if ((np = mp->d_conn) == 0) {
419 printf("%s%d isn't connected to anything ",
5e794bde 420 mp->d_name, mp->d_unit);
a0105456 421 printf(", so %s%d is unattached\n",
5e794bde
BJ
422 dp->d_name, dp->d_unit);
423 continue;
424 }
a0105456 425 vba_n = np->d_unit;
5e794bde 426 if (dp->d_drive == UNKNOWN) {
a0105456
SL
427 printf("must specify ``drive number'' ");
428 printf("for %s%d\n", dp->d_name, dp->d_unit);
5e794bde
BJ
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 }
a0105456
SL
439 if (dp->d_vec != 0) {
440 printf("interrupt vectors should not be ");
5e794bde
BJ
441 printf("given for drive %s%d\n",
442 dp->d_name, dp->d_unit);
443 continue;
444 }
445 if (dp->d_addr != 0) {
a0105456 446 printf("csr addresses should be given only ");
5e794bde
BJ
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 }
a0105456
SL
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);
b88ba334 459 }
5e794bde 460 fprintf(fp, "\t0\n};\n");
22d68ad0 461 (void) fclose(fp);
b88ba334 462}
b312f544 463#endif
b88ba334 464
f4b2fb14
KM
465#if MACHINE_HP300
466hp300_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 }
d0aa7457
KB
478 fprintf(fp, "#include \"sys/param.h\"\n");
479 fprintf(fp, "#include \"sys/buf.h\"\n");
480 fprintf(fp, "#include \"sys/map.h\"\n");
f4b2fb14 481 fprintf(fp, "\n");
d0aa7457 482 fprintf(fp, "#include \"hp300/dev/device.h\"\n\n");
f4b2fb14
KM
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
572hpbadslave(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
594char *
595wnum(num)
596{
597
598 if (num == QUES || num == UNKNOWN)
599 return ("?");
600 (void) sprintf(errbuf, "%d", num);
601 return (errbuf);
602}
603#endif
604
1b6c65cb
WN
605#if MACHINE_I386
606char *sirq();
607
608i386_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, "#include \"sys/map.h\"\n");
627 fprintf(fp, "#include \"sys/vm.h\"\n");
628 fprintf(fp, "\n");
629 fprintf(fp, "#define V(s) V/**/s\n");
630 fprintf(fp, "#define C (caddr_t)\n\n");
631 /*
632 * First print the isa initialization structures
633 */
634 if (seen_isa) {
635
636 fprintf(fp, "/*\n");
637 fprintf(fp, " * ISA devices\n");
638 fprintf(fp, " */\n\n");
639 fprintf(fp, "#include \"i386/isa/isa_device.h\"\n");
640 fprintf(fp, "#include \"i386/isa/isa.h\"\n");
641 fprintf(fp, "#include \"i386/isa/icu.h\"\n\n");
642
643 for (dp = dtab; dp != 0; dp = dp->d_next) {
644 mp = dp->d_conn;
645 if (mp == 0 || mp == TO_NEXUS ||
646 !eq(mp->d_name, "isa"))
647 continue;
648 fprintf(fp,
649"extern struct isa_driver %sdriver; extern V(%s%d)();\n",
650 dp->d_name, dp->d_name, dp->d_unit);
651 }
652 fprintf(fp, "\nstruct isa_device isa_devtab_bio[] = {\n");
653 fprintf(fp, "\
654/* driver iobase irq drq maddr msiz intr unit */\n");
655 for (dp = dtab; dp != 0; dp = dp->d_next) {
656 mp = dp->d_conn;
657 if (dp->d_unit == QUES || mp == 0 ||
658 mp == TO_NEXUS || !eq(mp->d_name, "isa"))
659 continue;
660 if (!eq(dp->d_mask, "bio")) continue;
661 if (dp->d_port)
662 fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port);
663 else
664 fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn);
665 fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n",
666 sirq(dp->d_irq), dp->d_drq, dp->d_maddr,
667 dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit);
668 }
669 fprintf(fp, "0\n};\n");
670
671 fprintf(fp, "struct isa_device isa_devtab_tty[] = {\n");
672 fprintf(fp, "\
673/* driver iobase irq drq maddr msiz intr unit */\n");
674 for (dp = dtab; dp != 0; dp = dp->d_next) {
675 mp = dp->d_conn;
676 if (dp->d_unit == QUES || mp == 0 ||
677 mp == TO_NEXUS || !eq(mp->d_name, "isa"))
678 continue;
679 if (!eq(dp->d_mask, "tty")) continue;
680 if (dp->d_port)
681 fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port);
682 else
683 fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn);
684 fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n",
685 sirq(dp->d_irq), dp->d_drq, dp->d_maddr,
686 dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit);
687 }
688 fprintf(fp, "0\n};\n\n");
689
690 fprintf(fp, "struct isa_device isa_devtab_net[] = {\n");
691 fprintf(fp, "\
692/* driver iobase irq drq maddr msiz intr unit */\n");
693 for (dp = dtab; dp != 0; dp = dp->d_next) {
694 mp = dp->d_conn;
695 if (dp->d_unit == QUES || mp == 0 ||
696 mp == TO_NEXUS || !eq(mp->d_name, "isa"))
697 continue;
698 if (!eq(dp->d_mask, "net")) continue;
699 if (dp->d_port)
700 fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port);
701 else
702 fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn);
703 fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n",
704 sirq(dp->d_irq), dp->d_drq, dp->d_maddr,
705 dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit);
706 }
707 fprintf(fp, "0\n};\n\n");
708
709 fprintf(fp, "struct isa_device isa_devtab_null[] = {\n");
710 fprintf(fp, "\
711/* driver iobase irq drq maddr msiz intr unit */\n");
712 for (dp = dtab; dp != 0; dp = dp->d_next) {
713 mp = dp->d_conn;
714 if (dp->d_unit == QUES || mp == 0 ||
715 mp == TO_NEXUS || !eq(mp->d_name, "isa"))
716 continue;
717 if (!eq(dp->d_mask, "null")) continue;
718 if (dp->d_port)
719 fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port);
720 else
721 fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn);
722 fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n",
723 sirq(dp->d_irq), dp->d_drq, dp->d_maddr,
724 dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit);
725 }
726 fprintf(fp, "0\n};\n\n");
727 }
728 (void) fclose(fp);
729}
730
731char *
732sirq(num)
733{
734
735 if (num == -1)
736 return ("0");
737 sprintf(errbuf, "IRQ%d", num);
738 return (errbuf);
739}
740#endif
741
a6df0f0e
SL
742char *
743intv(dev)
5e794bde 744 register struct device *dev;
b88ba334
BJ
745{
746 static char buf[20];
747
5e794bde
BJ
748 if (dev->d_vec == 0)
749 return (" 0");
9bd38ba8
KB
750 (void) sprintf(buf, "%sint%d", dev->d_name, dev->d_unit);
751 return (buf);
b88ba334
BJ
752}
753
754char *
755qu(num)
756{
5e794bde 757
b88ba334 758 if (num == QUES)
5e794bde 759 return ("'?'");
22d68ad0 760 if (num == UNKNOWN)
5e794bde 761 return (" -1");
9bd38ba8
KB
762 (void) sprintf(errbuf, "%3d", num);
763 return (errbuf);
b88ba334 764}