added vfontinfo vwidth pac
[unix-history] / usr / src / usr.sbin / config / mkioconf.c
CommitLineData
107dc11a 1/* mkioconf.c 2.6 83/01/02 */
5e794bde 2
b88ba334
BJ
3#include <stdio.h>
4#include "y.tab.h"
5#include "config.h"
6
7/*
5e794bde 8 * build the ioconf.c file
b88ba334 9 */
5e794bde 10char *qu();
b312f544 11char *intv();
b88ba334 12
b312f544 13#if MACHINE_VAX
5e794bde 14vax_ioconf()
b88ba334 15{
5e794bde
BJ
16 register struct device *dp, *mp, *np;
17 register int uba_n, slave;
5e794bde 18 FILE *fp;
b88ba334 19
5e794bde 20 fp = fopen(path("ioconf.c"), "w");
22d68ad0 21 if (fp == 0) {
5e794bde
BJ
22 perror(path("ioconf.c"));
23 exit(1);
b88ba334 24 }
107dc11a 25 fprintf(fp, "#include \"../machine/pte.h\"\n");
5e794bde 26 fprintf(fp, "#include \"../h/param.h\"\n");
5e794bde
BJ
27 fprintf(fp, "#include \"../h/buf.h\"\n");
28 fprintf(fp, "#include \"../h/map.h\"\n");
29 fprintf(fp, "#include \"../h/vm.h\"\n");
30 fprintf(fp, "\n");
31 fprintf(fp, "#include \"../vaxmba/mbavar.h\"\n");
32 fprintf(fp, "#include \"../vaxuba/ubavar.h\"\n\n");
33 fprintf(fp, "\n");
34 fprintf(fp, "#define C (caddr_t)\n\n");
35 /*
36 * First print the mba initialization structures
37 */
38 if (seen_mba) {
22d68ad0 39 for (dp = dtab; dp != 0; dp = dp->d_next) {
5e794bde 40 mp = dp->d_conn;
22d68ad0 41 if (mp == 0 || mp == TO_NEXUS ||
5e794bde
BJ
42 !eq(mp->d_name, "mba"))
43 continue;
44 fprintf(fp, "extern struct mba_driver %sdriver;\n",
45 dp->d_name);
46 }
47 fprintf(fp, "\nstruct mba_device mbdinit[] = {\n");
48 fprintf(fp, "\t/* Device, Unit, Mba, Drive, Dk */\n");
22d68ad0 49 for (dp = dtab; dp != 0; dp = dp->d_next) {
5e794bde 50 mp = dp->d_conn;
22d68ad0 51 if (dp->d_unit == QUES || mp == 0 ||
5e794bde
BJ
52 mp == TO_NEXUS || !eq(mp->d_name, "mba"))
53 continue;
54 if (dp->d_addr) {
55 printf("can't specify csr address on mba for %s%d\n",
56 dp->d_name, dp->d_unit);
57 continue;
58 }
22d68ad0 59 if (dp->d_vec != 0) {
5e794bde
BJ
60 printf("can't specify vector for %s%d on mba\n",
61 dp->d_name, dp->d_unit);
62 continue;
63 }
64 if (dp->d_drive == UNKNOWN) {
65 printf("drive not specified for %s%d\n",
66 dp->d_name, dp->d_unit);
67 continue;
68 }
69 if (dp->d_slave != UNKNOWN) {
70 printf("can't specify slave number for %s%d\n",
71 dp->d_name, dp->d_unit);
72 continue;
73 }
74 fprintf(fp,
75 "\t{ &%sdriver, %d, %s, %s, %d },\n",
76 dp->d_name, dp->d_unit, qu(mp->d_unit),
77 qu(dp->d_drive), dp->d_dk);
78 }
79 fprintf(fp, "\t0\n};\n\n");
80 /*
81 * Print the mbsinit structure
82 * Driver Controller Unit Slave
83 */
84 fprintf(fp, "struct mba_slave mbsinit [] = {\n");
85 fprintf(fp, "\t/* Driver, Ctlr, Unit, Slave */\n");
22d68ad0 86 for (dp = dtab; dp != 0; dp = dp->d_next) {
5e794bde
BJ
87 /*
88 * All slaves are connected to something which
89 * is connected to the massbus.
90 */
22d68ad0 91 if ((mp = dp->d_conn) == 0 || mp == TO_NEXUS)
5e794bde
BJ
92 continue;
93 np = mp->d_conn;
22d68ad0 94 if (np == 0 || np == TO_NEXUS ||
5e794bde
BJ
95 !eq(np->d_name, "mba"))
96 continue;
97 fprintf(fp,
98 "\t{ &%sdriver, %s, %2d, %s },\n",
99 mp->d_name, qu(mp->d_unit), dp->d_unit,
100 qu(dp->d_slave));
101 }
102 fprintf(fp, "\t0\n};\n\n");
b88ba334 103 }
b88ba334 104 /*
5e794bde 105 * Now generate interrupt vectors for the unibus
b88ba334 106 */
22d68ad0
BJ
107 for (dp = dtab; dp != 0; dp = dp->d_next) {
108 if (dp->d_vec != 0) {
5e794bde
BJ
109 struct idlst *ip;
110 mp = dp->d_conn;
22d68ad0 111 if (mp == 0 || mp == TO_NEXUS ||
5e794bde
BJ
112 !eq(mp->d_name, "uba"))
113 continue;
114 fprintf(fp,
115 "extern struct uba_driver %sdriver;\n",
116 dp->d_name);
117 fprintf(fp, "extern ");
118 ip = dp->d_vec;
119 for (;;) {
120 fprintf(fp, "X%s%d()", ip->id, dp->d_unit);
121 ip = ip->id_next;
122 if (ip == 0)
123 break;
124 fprintf(fp, ", ");
125 }
126 fprintf(fp, ";\n");
127 fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name,
128 dp->d_unit, dp->d_unit);
129 ip = dp->d_vec;
130 for (;;) {
131 fprintf(fp, "X%s%d", ip->id, dp->d_unit);
132 ip = ip->id_next;
133 if (ip == 0)
134 break;
135 fprintf(fp, ", ");
136 }
137 fprintf(fp, ", 0 } ;\n");
138 }
b88ba334 139 }
5e794bde
BJ
140 fprintf(fp, "\nstruct uba_ctlr ubminit[] = {\n");
141 fprintf(fp, "/*\t driver,\tctlr,\tubanum,\talive,\tintr,\taddr */\n");
22d68ad0 142 for (dp = dtab; dp != 0; dp = dp->d_next) {
5e794bde 143 mp = dp->d_conn;
22d68ad0 144 if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 ||
5e794bde
BJ
145 !eq(mp->d_name, "uba"))
146 continue;
147 if (dp->d_vec == 0) {
148 printf("must specify vector for %s%d\n",
149 dp->d_name, dp->d_unit);
150 continue;
151 }
152 if (dp->d_addr == 0) {
153 printf("must specify csr address for %s%d\n",
154 dp->d_name, dp->d_unit);
155 continue;
156 }
157 if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) {
158 printf("drives need their own entries; dont ");
159 printf("specify drive or slave for %s%d\n",
160 dp->d_name, dp->d_unit);
161 continue;
162 }
163 if (dp->d_flags) {
164 printf("controllers (e.g. %s%d) ",
165 dp->d_name, dp->d_unit);
166 printf("don't have flags, only devices do\n");
167 continue;
168 }
169 fprintf(fp,
170 "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0%o },\n",
171 dp->d_name, dp->d_unit, qu(mp->d_unit),
172 dp->d_name, dp->d_unit, dp->d_addr);
b88ba334 173 }
5e794bde 174 fprintf(fp, "\t0\n};\n");
36e00264 175/* unibus devices */
5e794bde 176 fprintf(fp, "\nstruct uba_device ubdinit[] = {\n");
36e00264
BJ
177 fprintf(fp,
178"\t/* driver, unit, ctlr, ubanum, slave, intr, addr, dk, flags*/\n");
22d68ad0 179 for (dp = dtab; dp != 0; dp = dp->d_next) {
5e794bde 180 mp = dp->d_conn;
22d68ad0 181 if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 ||
5e794bde
BJ
182 mp == TO_NEXUS || mp->d_type == MASTER ||
183 eq(mp->d_name, "mba"))
184 continue;
185 np = mp->d_conn;
22d68ad0 186 if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba"))
5e794bde 187 continue;
22d68ad0 188 np = 0;
5e794bde
BJ
189 if (eq(mp->d_name, "uba")) {
190 if (dp->d_vec == 0) {
191 printf("must specify vector for device %s%d\n",
192 dp->d_name, dp->d_unit);
193 continue;
194 }
195 if (dp->d_addr == 0) {
196 printf("must specify csr for device %s%d\n",
197 dp->d_name, dp->d_unit);
198 continue;
199 }
200 if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) {
201 printf("drives/slaves can be specified ");
202 printf("only for controllers, ");
203 printf("not for device %s%d\n",
204 dp->d_name, dp->d_unit);
205 continue;
206 }
207 uba_n = mp->d_unit;
208 slave = QUES;
209 } else {
22d68ad0 210 if ((np = mp->d_conn) == 0) {
5e794bde
BJ
211 printf("%s%d isn't connected to anything ",
212 mp->d_name, mp->d_unit);
213 printf(", so %s%d is unattached\n",
214 dp->d_name, dp->d_unit);
215 continue;
216 }
217 uba_n = np->d_unit;
218 if (dp->d_drive == UNKNOWN) {
219 printf("must specify ``drive number'' ");
220 printf("for %s%d\n", dp->d_name, dp->d_unit);
221 continue;
222 }
223 /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */
224 /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */
225 if (dp->d_slave != UNKNOWN) {
226 printf("slave numbers should be given only ");
227 printf("for massbus tapes, not for %s%d\n",
228 dp->d_name, dp->d_unit);
229 continue;
230 }
231 if (dp->d_vec != 0) {
232 printf("interrupt vectors should not be ");
233 printf("given for drive %s%d\n",
234 dp->d_name, dp->d_unit);
235 continue;
236 }
237 if (dp->d_addr != 0) {
238 printf("csr addresses should be given only ");
239 printf("on controllers, not on %s%d\n",
240 dp->d_name, dp->d_unit);
241 continue;
242 }
243 slave = dp->d_drive;
244 }
245 fprintf(fp,
246"\t{ &%sdriver, %2d, %s, %s, %2d, %s, C 0%-6o, %d, 0x%x },\n",
247 eq(mp->d_name, "uba") ? dp->d_name : mp->d_name, dp->d_unit,
248 eq(mp->d_name, "uba") ? " -1" : qu(mp->d_unit), qu(uba_n),
249 slave, intv(dp), dp->d_addr, dp->d_dk, dp->d_flags);
b88ba334 250 }
5e794bde 251 fprintf(fp, "\t0\n};\n");
22d68ad0 252 (void) fclose(fp);
5e794bde 253}
b312f544 254#endif
5e794bde 255
b312f544 256#if MACHINE_SUN
5e794bde
BJ
257sun_ioconf()
258{
22d68ad0
BJ
259 register struct device *dp, *mp;
260 register int slave;
5e794bde
BJ
261 FILE *fp;
262
263 fp = fopen(path("ioconf.c"), "w");
22d68ad0 264 if (fp == 0) {
5e794bde
BJ
265 perror(path("ioconf.c"));
266 exit(1);
b88ba334 267 }
5e794bde
BJ
268 fprintf(fp, "#include \"../h/param.h\"\n");
269 fprintf(fp, "#include \"../h/buf.h\"\n");
270 fprintf(fp, "#include \"../h/map.h\"\n");
271 fprintf(fp, "#include \"../h/vm.h\"\n");
272 fprintf(fp, "\n");
107dc11a 273 fprintf(fp, "#include \"../sundev/mbvar.h\"\n");
5e794bde
BJ
274 fprintf(fp, "\n");
275 fprintf(fp, "#define C (caddr_t)\n\n");
276 fprintf(fp, "\n");
277 /*
278 * Now generate interrupt vectors for the Multibus
279 */
22d68ad0
BJ
280 for (dp = dtab; dp != 0; dp = dp->d_next) {
281 if (dp->d_pri != 0) {
5e794bde 282 mp = dp->d_conn;
22d68ad0 283 if (mp == 0 || mp == TO_NEXUS ||
5e794bde
BJ
284 !eq(mp->d_name, "mb"))
285 continue;
286 fprintf(fp, "extern struct mb_driver %sdriver;\n",
287 dp->d_name);
288 }
b88ba334 289 }
5e794bde
BJ
290 /*
291 * Now spew forth the mb_cinfo structure
292 */
293 fprintf(fp, "\nstruct mb_ctlr mbcinit[] = {\n");
294 fprintf(fp, "/*\t driver,\tctlr,\talive,\taddr,\tintpri */\n");
22d68ad0 295 for (dp = dtab; dp != 0; dp = dp->d_next) {
5e794bde 296 mp = dp->d_conn;
22d68ad0 297 if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 ||
5e794bde
BJ
298 !eq(mp->d_name, "mb"))
299 continue;
300 if (dp->d_pri == 0) {
301 printf("must specify priority for %s%d\n",
302 dp->d_name, dp->d_unit);
303 continue;
304 }
305 if (dp->d_addr == 0) {
306 printf("must specify csr address for %s%d\n",
307 dp->d_name, dp->d_unit);
308 continue;
309 }
310 if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) {
311 printf("drives need their own entries; ");
312 printf("dont specify drive or slave for %s%d\n",
313 dp->d_name, dp->d_unit);
314 continue;
315 }
316 if (dp->d_flags) {
317 printf("controllers (e.g. %s%d) don't have flags, ");
318 printf("only devices do\n",
319 dp->d_name, dp->d_unit);
320 continue;
321 }
322 fprintf(fp, "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t%d },\n",
323 dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri);
b88ba334 324 }
5e794bde
BJ
325 fprintf(fp, "\t0\n};\n");
326 /*
327 * Now we go for the mb_device stuff
328 */
329 fprintf(fp, "\nstruct mb_device mbdinit[] = {\n");
330 fprintf(fp,
331"\t/* driver, unit, ctlr, slave, addr, pri, dk, flags*/\n");
22d68ad0 332 for (dp = dtab; dp != 0; dp = dp->d_next) {
5e794bde 333 mp = dp->d_conn;
22d68ad0 334 if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 ||
5e794bde
BJ
335 mp == TO_NEXUS || mp->d_type == MASTER ||
336 eq(mp->d_name, "mba"))
337 continue;
5e794bde
BJ
338 if (eq(mp->d_name, "mb")) {
339 if (dp->d_pri == 0) {
340 printf("must specify vector for device %s%d\n",
341 dp->d_name, dp->d_unit);
342 continue;
343 }
344 if (dp->d_addr == 0) {
345 printf("must specify csr for device %s%d\n",
346 dp->d_name, dp->d_unit);
347 continue;
348 }
349 if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) {
350 printf("drives/slaves can be specified only ");
351 printf("for controllers, not for device %s%d\n",
352 dp->d_name, dp->d_unit);
353 continue;
354 }
355 slave = QUES;
356 } else {
22d68ad0 357 if (mp->d_conn == 0) {
5e794bde
BJ
358 printf("%s%d isn't connected to anything, ",
359 mp->d_name, mp->d_unit);
360 printf("so %s%d is unattached\n",
361 dp->d_name, dp->d_unit);
362 continue;
363 }
364 if (dp->d_drive == UNKNOWN) {
365 printf("must specify ``drive number'' for %s%d\n",
366 dp->d_name, dp->d_unit);
367 continue;
368 }
369 /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */
370 /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */
371 if (dp->d_slave != UNKNOWN) {
372 printf("slave numbers should be given only ");
373 printf("for massbus tapes, not for %s%d\n",
374 dp->d_name, dp->d_unit);
375 continue;
376 }
377 if (dp->d_pri != 0) {
378 printf("interrupt priority should not be ");
379 printf("given for drive %s%d\n",
380 dp->d_name, dp->d_unit);
381 continue;
382 }
383 if (dp->d_addr != 0) {
384 printf("csr addresses should be given only");
385 printf("on controllers, not on %s%d\n",
386 dp->d_name, dp->d_unit);
387 continue;
388 }
389 slave = dp->d_drive;
390 }
391 fprintf(fp,
392"\t{ &%sdriver, %2d, %s, %2d, C 0x%x, %d, %d, 0x%x },\n",
393 eq(mp->d_name, "mb") ? dp->d_name : mp->d_name, dp->d_unit,
394 eq(mp->d_name, "mb") ? " -1" : qu(mp->d_unit),
395 slave, dp->d_addr, dp->d_pri, dp->d_dk, dp->d_flags);
b88ba334 396 }
5e794bde 397 fprintf(fp, "\t0\n};\n");
22d68ad0 398 (void) fclose(fp);
b88ba334 399}
b312f544 400#endif
b88ba334 401
b88ba334 402char *intv(dev)
5e794bde 403 register struct device *dev;
b88ba334
BJ
404{
405 static char buf[20];
406
5e794bde
BJ
407 if (dev->d_vec == 0)
408 return (" 0");
22d68ad0 409 return (sprintf(buf, "%sint%d", dev->d_name, dev->d_unit));
b88ba334
BJ
410}
411
412char *
413qu(num)
414{
5e794bde 415
b88ba334 416 if (num == QUES)
5e794bde 417 return ("'?'");
22d68ad0 418 if (num == UNKNOWN)
5e794bde 419 return (" -1");
22d68ad0 420 return (sprintf(errbuf, "%3d", num));
b88ba334 421}