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