|
|
1.1 ! root 1: #ifndef lint ! 2: static char sccsid[] = "@(#)mkioconf.c 2.9 (Berkeley) 8/11/83"; ! 3: #endif ! 4: ! 5: #include <stdio.h> ! 6: #include "y.tab.h" ! 7: #include "config.h" ! 8: ! 9: /* ! 10: * build the ioconf.c file ! 11: */ ! 12: char *qu(); ! 13: char *intv(); ! 14: ! 15: #if MACHINE_TAHOE ! 16: tahoe_ioconf() ! 17: { ! 18: register struct device *dp, *mp, *np; ! 19: register int vba_n, slave; ! 20: FILE *fp; ! 21: ! 22: fp = fopen(path("ioconf.c"), "w"); ! 23: if (fp == 0) { ! 24: perror(path("ioconf.c")); ! 25: exit(1); ! 26: } ! 27: fprintf(fp, "#include \"../h/param.h\"\n"); ! 28: fprintf(fp, "#include \"../machine/pte.h\"\n"); ! 29: fprintf(fp, "#include \"../h/buf.h\"\n"); ! 30: fprintf(fp, "#include \"../h/map.h\"\n"); ! 31: fprintf(fp, "\n"); ! 32: fprintf(fp, "#include \"../vba/vbavar.h\"\n"); ! 33: fprintf(fp, "\n"); ! 34: fprintf(fp, "#define C (caddr_t)\n\n"); ! 35: /* ! 36: * Now generate interrupt vectors for the versabus ! 37: */ ! 38: for (dp = dtab; dp != 0; dp = dp->d_next) { ! 39: if (dp->d_vec != 0) { ! 40: struct idlst *ip; ! 41: mp = dp->d_conn; ! 42: if (mp == 0 || mp == TO_NEXUS || ! 43: !eq(mp->d_name, "vba")) ! 44: continue; ! 45: fprintf(fp, ! 46: "extern struct vba_driver %sdriver;\n", ! 47: dp->d_name); ! 48: fprintf(fp, "extern "); ! 49: ip = dp->d_vec; ! 50: for (;;) { ! 51: fprintf(fp, "X%s%d()", ip->id, dp->d_unit); ! 52: ip = ip->id_next; ! 53: if (ip == 0) ! 54: break; ! 55: fprintf(fp, ", "); ! 56: } ! 57: fprintf(fp, ";\n"); ! 58: fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, ! 59: dp->d_unit, dp->d_unit); ! 60: ip = dp->d_vec; ! 61: for (;;) { ! 62: fprintf(fp, "X%s%d", ip->id, dp->d_unit); ! 63: ip = ip->id_next; ! 64: if (ip == 0) ! 65: break; ! 66: fprintf(fp, ", "); ! 67: } ! 68: fprintf(fp, ", 0 } ;\n"); ! 69: } ! 70: } ! 71: fprintf(fp, "\nstruct vba_ctlr vbminit[] = {\n"); ! 72: fprintf(fp, "/*\t driver,\tctlr,\tvbanum,\talive,\tintr,\taddr */\n"); ! 73: for (dp = dtab; dp != 0; dp = dp->d_next) { ! 74: mp = dp->d_conn; ! 75: if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || ! 76: !eq(mp->d_name, "vba")) ! 77: continue; ! 78: if (dp->d_vec == 0) { ! 79: printf("must specify vector for %s%d\n", ! 80: dp->d_name, dp->d_unit); ! 81: continue; ! 82: } ! 83: if (dp->d_addr == 0) { ! 84: printf("must specify csr address for %s%d\n", ! 85: dp->d_name, dp->d_unit); ! 86: continue; ! 87: } ! 88: if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { ! 89: printf("drives need their own entries; dont "); ! 90: printf("specify drive or slave for %s%d\n", ! 91: dp->d_name, dp->d_unit); ! 92: continue; ! 93: } ! 94: if (dp->d_flags) { ! 95: printf("controllers (e.g. %s%d) ", ! 96: dp->d_name, dp->d_unit); ! 97: printf("don't have flags, only devices do\n"); ! 98: continue; ! 99: } ! 100: fprintf(fp, ! 101: "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0x%x },\n", ! 102: dp->d_name, dp->d_unit, qu(mp->d_unit), ! 103: dp->d_name, dp->d_unit, dp->d_addr); ! 104: } ! 105: fprintf(fp, "\t0\n};\n"); ! 106: /* versabus devices */ ! 107: fprintf(fp, "\nstruct vba_device vbdinit[] = {\n"); ! 108: fprintf(fp, ! 109: "\t/* driver, unit, ctlr, vbanum, slave, intr, addr, dk, flags*/\n"); ! 110: for (dp = dtab; dp != 0; dp = dp->d_next) { ! 111: mp = dp->d_conn; ! 112: if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || ! 113: mp == TO_NEXUS || mp->d_type == MASTER || ! 114: eq(mp->d_name, "mba")) ! 115: continue; ! 116: np = mp->d_conn; ! 117: if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) ! 118: continue; ! 119: np = 0; ! 120: if (eq(mp->d_name, "vba")) { ! 121: if (dp->d_vec == 0) { ! 122: printf("must specify vector for device %s%d\n", ! 123: dp->d_name, dp->d_unit); ! 124: continue; ! 125: } ! 126: if (dp->d_addr == 0) { ! 127: printf("must specify csr for device %s%d\n", ! 128: dp->d_name, dp->d_unit); ! 129: continue; ! 130: } ! 131: if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { ! 132: printf("drives/slaves can be specified "); ! 133: printf("only for controllers, "); ! 134: printf("not for device %s%d\n", ! 135: dp->d_name, dp->d_unit); ! 136: continue; ! 137: } ! 138: vba_n = mp->d_unit; ! 139: slave = QUES; ! 140: } else { ! 141: if ((np = mp->d_conn) == 0) { ! 142: printf("%s%d isn't connected to anything ", ! 143: mp->d_name, mp->d_unit); ! 144: printf(", so %s%d is unattached\n", ! 145: dp->d_name, dp->d_unit); ! 146: continue; ! 147: } ! 148: vba_n = np->d_unit; ! 149: if (dp->d_drive == UNKNOWN) { ! 150: printf("must specify ``drive number'' "); ! 151: printf("for %s%d\n", dp->d_name, dp->d_unit); ! 152: continue; ! 153: } ! 154: /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ ! 155: /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ ! 156: if (dp->d_slave != UNKNOWN) { ! 157: printf("slave numbers should be given only "); ! 158: printf("for massbus tapes, not for %s%d\n", ! 159: dp->d_name, dp->d_unit); ! 160: continue; ! 161: } ! 162: if (dp->d_vec != 0) { ! 163: printf("interrupt vectors should not be "); ! 164: printf("given for drive %s%d\n", ! 165: dp->d_name, dp->d_unit); ! 166: continue; ! 167: } ! 168: if (dp->d_addr != 0) { ! 169: printf("csr addresses should be given only "); ! 170: printf("on controllers, not on %s%d\n", ! 171: dp->d_name, dp->d_unit); ! 172: continue; ! 173: } ! 174: slave = dp->d_drive; ! 175: } ! 176: fprintf(fp, "\t{ &%sdriver, %2d, %s,", ! 177: eq(mp->d_name, "vba") ? dp->d_name : mp->d_name, dp->d_unit, ! 178: eq(mp->d_name, "vba") ? " -1" : qu(mp->d_unit)); ! 179: fprintf(fp, " %s, %2d, %s, C 0x%-6x, %d, 0x%x },\n", ! 180: qu(vba_n), slave, intv(dp), dp->d_addr, dp->d_dk, ! 181: dp->d_flags); ! 182: } ! 183: fprintf(fp, "\t0\n};\n"); ! 184: (void) fclose(fp); ! 185: } ! 186: #endif ! 187: ! 188: #if MACHINE_VAX ! 189: vax_ioconf() ! 190: { ! 191: } ! 192: #endif ! 193: ! 194: #if MACHINE_SUN ! 195: sun_ioconf() ! 196: { ! 197: register struct device *dp, *mp; ! 198: register int slave; ! 199: FILE *fp; ! 200: ! 201: fp = fopen(path("ioconf.c"), "w"); ! 202: if (fp == 0) { ! 203: perror(path("ioconf.c")); ! 204: exit(1); ! 205: } ! 206: fprintf(fp, "#include \"../h/param.h\"\n"); ! 207: fprintf(fp, "#include \"../h/buf.h\"\n"); ! 208: fprintf(fp, "#include \"../h/map.h\"\n"); ! 209: fprintf(fp, "#include \"../h/vm.h\"\n"); ! 210: fprintf(fp, "\n"); ! 211: fprintf(fp, "#include \"../sundev/mbvar.h\"\n"); ! 212: fprintf(fp, "\n"); ! 213: fprintf(fp, "#define C (caddr_t)\n\n"); ! 214: fprintf(fp, "\n"); ! 215: /* ! 216: * Now generate interrupt vectors for the Multibus ! 217: */ ! 218: for (dp = dtab; dp != 0; dp = dp->d_next) { ! 219: if (dp->d_pri != 0) { ! 220: mp = dp->d_conn; ! 221: if (mp == 0 || mp == TO_NEXUS || ! 222: !eq(mp->d_name, "mb")) ! 223: continue; ! 224: fprintf(fp, "extern struct mb_driver %sdriver;\n", ! 225: dp->d_name); ! 226: } ! 227: } ! 228: /* ! 229: * Now spew forth the mb_cinfo structure ! 230: */ ! 231: fprintf(fp, "\nstruct mb_ctlr mbcinit[] = {\n"); ! 232: fprintf(fp, "/*\t driver,\tctlr,\talive,\taddr,\tintpri */\n"); ! 233: for (dp = dtab; dp != 0; dp = dp->d_next) { ! 234: mp = dp->d_conn; ! 235: if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || ! 236: !eq(mp->d_name, "mb")) ! 237: continue; ! 238: if (dp->d_pri == 0) { ! 239: printf("must specify priority for %s%d\n", ! 240: dp->d_name, dp->d_unit); ! 241: continue; ! 242: } ! 243: if (dp->d_addr == 0) { ! 244: printf("must specify csr address for %s%d\n", ! 245: dp->d_name, dp->d_unit); ! 246: continue; ! 247: } ! 248: if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { ! 249: printf("drives need their own entries; "); ! 250: printf("dont specify drive or slave for %s%d\n", ! 251: dp->d_name, dp->d_unit); ! 252: continue; ! 253: } ! 254: if (dp->d_flags) { ! 255: printf("controllers (e.g. %s%d) don't have flags, "); ! 256: printf("only devices do\n", ! 257: dp->d_name, dp->d_unit); ! 258: continue; ! 259: } ! 260: fprintf(fp, "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t%d },\n", ! 261: dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri); ! 262: } ! 263: fprintf(fp, "\t0\n};\n"); ! 264: /* ! 265: * Now we go for the mb_device stuff ! 266: */ ! 267: fprintf(fp, "\nstruct mb_device mbdinit[] = {\n"); ! 268: fprintf(fp, ! 269: "\t/* driver, unit, ctlr, slave, addr, pri, dk, flags*/\n"); ! 270: for (dp = dtab; dp != 0; dp = dp->d_next) { ! 271: mp = dp->d_conn; ! 272: if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || ! 273: mp == TO_NEXUS || mp->d_type == MASTER || ! 274: eq(mp->d_name, "vba")) ! 275: continue; ! 276: if (eq(mp->d_name, "mb")) { ! 277: if (dp->d_pri == 0) { ! 278: printf("must specify vector for device %s%d\n", ! 279: dp->d_name, dp->d_unit); ! 280: continue; ! 281: } ! 282: if (dp->d_addr == 0) { ! 283: printf("must specify csr for device %s%d\n", ! 284: dp->d_name, dp->d_unit); ! 285: continue; ! 286: } ! 287: if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { ! 288: printf("drives/slaves can be specified only "); ! 289: printf("for controllers, not for device %s%d\n", ! 290: dp->d_name, dp->d_unit); ! 291: continue; ! 292: } ! 293: slave = QUES; ! 294: } else { ! 295: if (mp->d_conn == 0) { ! 296: printf("%s%d isn't connected to anything, ", ! 297: mp->d_name, mp->d_unit); ! 298: printf("so %s%d is unattached\n", ! 299: dp->d_name, dp->d_unit); ! 300: continue; ! 301: } ! 302: if (dp->d_drive == UNKNOWN) { ! 303: printf("must specify ``drive number'' for %s%d\n", ! 304: dp->d_name, dp->d_unit); ! 305: continue; ! 306: } ! 307: /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ ! 308: /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ ! 309: if (dp->d_slave != UNKNOWN) { ! 310: printf("slave numbers should be given only "); ! 311: printf("for massbus tapes, not for %s%d\n", ! 312: dp->d_name, dp->d_unit); ! 313: continue; ! 314: } ! 315: if (dp->d_pri != 0) { ! 316: printf("interrupt priority should not be "); ! 317: printf("given for drive %s%d\n", ! 318: dp->d_name, dp->d_unit); ! 319: continue; ! 320: } ! 321: if (dp->d_addr != 0) { ! 322: printf("csr addresses should be given only"); ! 323: printf("on controllers, not on %s%d\n", ! 324: dp->d_name, dp->d_unit); ! 325: continue; ! 326: } ! 327: slave = dp->d_drive; ! 328: } ! 329: fprintf(fp, ! 330: "\t{ &%sdriver, %2d, %s, %2d, C 0x%x, %d, %d, 0x%x },\n", ! 331: eq(mp->d_name, "mb") ? dp->d_name : mp->d_name, dp->d_unit, ! 332: eq(mp->d_name, "mb") ? " -1" : qu(mp->d_unit), ! 333: slave, dp->d_addr, dp->d_pri, dp->d_dk, dp->d_flags); ! 334: } ! 335: fprintf(fp, "\t0\n};\n"); ! 336: (void) fclose(fp); ! 337: } ! 338: #endif ! 339: ! 340: char *intv(dev) ! 341: register struct device *dev; ! 342: { ! 343: static char buf[20]; ! 344: ! 345: if (dev->d_vec == 0) ! 346: return (" 0"); ! 347: return (sprintf(buf, "%sint%d", dev->d_name, dev->d_unit)); ! 348: } ! 349: ! 350: char * ! 351: qu(num) ! 352: { ! 353: ! 354: if (num == QUES) ! 355: return ("'?'"); ! 356: if (num == UNKNOWN) ! 357: return (" -1"); ! 358: return (sprintf(errbuf, "%3d", num)); ! 359: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.