1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)mkioconf.c 5.26 (Berkeley) 11/06/92"; 10 #endif /* not lint */ 11 12 #include <stdio.h> 13 #include "y.tab.h" 14 #include "config.h" 15 16 /* 17 * build the ioconf.c file 18 */ 19 char *qu(); 20 char *intv(); 21 char *wnum(); 22 23 #if MACHINE_VAX 24 vax_ioconf() 25 { 26 register struct device *dp, *mp, *np; 27 register int uba_n, slave; 28 FILE *fp; 29 30 fp = fopen(path("ioconf.c"), "w"); 31 if (fp == 0) { 32 perror(path("ioconf.c")); 33 exit(1); 34 } 35 fprintf(fp, "#include \"vax/include/pte.h\"\n"); 36 fprintf(fp, "#include \"sys/param.h\"\n"); 37 fprintf(fp, "#include \"sys/buf.h\"\n"); 38 fprintf(fp, "#include \"sys/map.h\"\n"); 39 fprintf(fp, "\n"); 40 fprintf(fp, "#include \"vax/mba/mbavar.h\"\n"); 41 fprintf(fp, "#include \"vax/uba/ubavar.h\"\n\n"); 42 fprintf(fp, "\n"); 43 fprintf(fp, "#define C (caddr_t)\n\n"); 44 /* 45 * First print the mba initialization structures 46 */ 47 if (seen_mba) { 48 for (dp = dtab; dp != 0; dp = dp->d_next) { 49 mp = dp->d_conn; 50 if (mp == 0 || mp == TO_NEXUS || 51 !eq(mp->d_name, "mba")) 52 continue; 53 fprintf(fp, "extern struct mba_driver %sdriver;\n", 54 dp->d_name); 55 } 56 fprintf(fp, "\nstruct mba_device mbdinit[] = {\n"); 57 fprintf(fp, "\t/* Device, Unit, Mba, Drive, Dk */\n"); 58 for (dp = dtab; dp != 0; dp = dp->d_next) { 59 mp = dp->d_conn; 60 if (dp->d_unit == QUES || mp == 0 || 61 mp == TO_NEXUS || !eq(mp->d_name, "mba")) 62 continue; 63 if (dp->d_addr) { 64 printf("can't specify csr address on mba for %s%d\n", 65 dp->d_name, dp->d_unit); 66 continue; 67 } 68 if (dp->d_vec != 0) { 69 printf("can't specify vector for %s%d on mba\n", 70 dp->d_name, dp->d_unit); 71 continue; 72 } 73 if (dp->d_drive == UNKNOWN) { 74 printf("drive not specified for %s%d\n", 75 dp->d_name, dp->d_unit); 76 continue; 77 } 78 if (dp->d_slave != UNKNOWN) { 79 printf("can't specify slave number for %s%d\n", 80 dp->d_name, dp->d_unit); 81 continue; 82 } 83 fprintf(fp, "\t{ &%sdriver, %d, %s,", 84 dp->d_name, dp->d_unit, qu(mp->d_unit)); 85 fprintf(fp, " %s, %d },\n", 86 qu(dp->d_drive), dp->d_dk); 87 } 88 fprintf(fp, "\t0\n};\n\n"); 89 /* 90 * Print the mbsinit structure 91 * Driver Controller Unit Slave 92 */ 93 fprintf(fp, "struct mba_slave mbsinit [] = {\n"); 94 fprintf(fp, "\t/* Driver, Ctlr, Unit, Slave */\n"); 95 for (dp = dtab; dp != 0; dp = dp->d_next) { 96 /* 97 * All slaves are connected to something which 98 * is connected to the massbus. 99 */ 100 if ((mp = dp->d_conn) == 0 || mp == TO_NEXUS) 101 continue; 102 np = mp->d_conn; 103 if (np == 0 || np == TO_NEXUS || 104 !eq(np->d_name, "mba")) 105 continue; 106 fprintf(fp, "\t{ &%sdriver, %s", 107 mp->d_name, qu(mp->d_unit)); 108 fprintf(fp, ", %2d, %s },\n", 109 dp->d_unit, qu(dp->d_slave)); 110 } 111 fprintf(fp, "\t0\n};\n\n"); 112 } 113 /* 114 * Now generate interrupt vectors for the unibus 115 */ 116 for (dp = dtab; dp != 0; dp = dp->d_next) { 117 if (dp->d_vec != 0) { 118 struct idlst *ip; 119 mp = dp->d_conn; 120 if (mp == 0 || mp == TO_NEXUS || 121 (!eq(mp->d_name, "uba") && !eq(mp->d_name, "bi"))) 122 continue; 123 fprintf(fp, 124 "extern struct uba_driver %sdriver;\n", 125 dp->d_name); 126 fprintf(fp, "extern "); 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, ";\n"); 136 fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, 137 dp->d_unit); 138 ip = dp->d_vec; 139 for (;;) { 140 fprintf(fp, "X%s%d", ip->id, dp->d_unit); 141 ip = ip->id_next; 142 if (ip == 0) 143 break; 144 fprintf(fp, ", "); 145 } 146 fprintf(fp, ", 0 } ;\n"); 147 } 148 } 149 fprintf(fp, "\nstruct uba_ctlr ubminit[] = {\n"); 150 fprintf(fp, "/*\t driver,\tctlr,\tubanum,\talive,\tintr,\taddr */\n"); 151 for (dp = dtab; dp != 0; dp = dp->d_next) { 152 mp = dp->d_conn; 153 if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || 154 !eq(mp->d_name, "uba")) 155 continue; 156 if (dp->d_vec == 0) { 157 printf("must specify vector for %s%d\n", 158 dp->d_name, dp->d_unit); 159 continue; 160 } 161 if (dp->d_addr == 0) { 162 printf("must specify csr address for %s%d\n", 163 dp->d_name, dp->d_unit); 164 continue; 165 } 166 if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { 167 printf("drives need their own entries; dont "); 168 printf("specify drive or slave for %s%d\n", 169 dp->d_name, dp->d_unit); 170 continue; 171 } 172 if (dp->d_flags) { 173 printf("controllers (e.g. %s%d) ", 174 dp->d_name, dp->d_unit); 175 printf("don't have flags, only devices do\n"); 176 continue; 177 } 178 fprintf(fp, 179 "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0%o },\n", 180 dp->d_name, dp->d_unit, qu(mp->d_unit), 181 dp->d_name, dp->d_unit, dp->d_addr); 182 } 183 fprintf(fp, "\t0\n};\n"); 184 /* unibus devices */ 185 fprintf(fp, "\nstruct uba_device ubdinit[] = {\n"); 186 fprintf(fp, 187 "\t/* driver, unit, ctlr, ubanum, slave, intr, addr, dk, flags*/\n"); 188 for (dp = dtab; dp != 0; dp = dp->d_next) { 189 mp = dp->d_conn; 190 if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || 191 mp == TO_NEXUS || mp->d_type == MASTER || 192 eq(mp->d_name, "mba")) 193 continue; 194 np = mp->d_conn; 195 if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) 196 continue; 197 np = 0; 198 if (eq(mp->d_name, "uba")) { 199 if (dp->d_vec == 0) { 200 printf("must specify vector for device %s%d\n", 201 dp->d_name, dp->d_unit); 202 continue; 203 } 204 if (dp->d_addr == 0) { 205 printf("must specify csr for device %s%d\n", 206 dp->d_name, dp->d_unit); 207 continue; 208 } 209 if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { 210 printf("drives/slaves can be specified "); 211 printf("only for controllers, "); 212 printf("not for device %s%d\n", 213 dp->d_name, dp->d_unit); 214 continue; 215 } 216 uba_n = mp->d_unit; 217 slave = QUES; 218 } else { 219 if ((np = mp->d_conn) == 0) { 220 printf("%s%d isn't connected to anything ", 221 mp->d_name, mp->d_unit); 222 printf(", so %s%d is unattached\n", 223 dp->d_name, dp->d_unit); 224 continue; 225 } 226 uba_n = np->d_unit; 227 if (dp->d_drive == UNKNOWN) { 228 printf("must specify ``drive number'' "); 229 printf("for %s%d\n", dp->d_name, dp->d_unit); 230 continue; 231 } 232 /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ 233 /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ 234 if (dp->d_slave != UNKNOWN) { 235 printf("slave numbers should be given only "); 236 printf("for massbus tapes, not for %s%d\n", 237 dp->d_name, dp->d_unit); 238 continue; 239 } 240 if (dp->d_vec != 0) { 241 printf("interrupt vectors should not be "); 242 printf("given for drive %s%d\n", 243 dp->d_name, dp->d_unit); 244 continue; 245 } 246 if (dp->d_addr != 0) { 247 printf("csr addresses should be given only "); 248 printf("on controllers, not on %s%d\n", 249 dp->d_name, dp->d_unit); 250 continue; 251 } 252 slave = dp->d_drive; 253 } 254 fprintf(fp, "\t{ &%sdriver, %2d, %s,", 255 eq(mp->d_name, "uba") ? dp->d_name : mp->d_name, dp->d_unit, 256 eq(mp->d_name, "uba") ? " -1" : qu(mp->d_unit)); 257 fprintf(fp, " %s, %2d, %s, C 0%-6o, %d, 0x%x },\n", 258 qu(uba_n), slave, intv(dp), dp->d_addr, dp->d_dk, 259 dp->d_flags); 260 } 261 fprintf(fp, "\t0\n};\n"); 262 (void) fclose(fp); 263 } 264 #endif 265 266 #if MACHINE_TAHOE 267 tahoe_ioconf() 268 { 269 register struct device *dp, *mp, *np; 270 register int vba_n, slave; 271 FILE *fp; 272 273 fp = fopen(path("ioconf.c"), "w"); 274 if (fp == 0) { 275 perror(path("ioconf.c")); 276 exit(1); 277 } 278 fprintf(fp, "#include \"sys/param.h\"\n"); 279 fprintf(fp, "#include \"tahoe/include/pte.h\"\n"); 280 fprintf(fp, "#include \"sys/buf.h\"\n"); 281 fprintf(fp, "#include \"sys/map.h\"\n"); 282 fprintf(fp, "\n"); 283 fprintf(fp, "#include \"tahoe/vba/vbavar.h\"\n"); 284 fprintf(fp, "\n"); 285 fprintf(fp, "#define C (caddr_t)\n\n"); 286 /* 287 * Now generate interrupt vectors for the versabus 288 */ 289 for (dp = dtab; dp != 0; dp = dp->d_next) { 290 mp = dp->d_conn; 291 if (mp == 0 || mp == TO_NEXUS || !eq(mp->d_name, "vba")) 292 continue; 293 if (dp->d_vec != 0) { 294 struct idlst *ip; 295 fprintf(fp, 296 "extern struct vba_driver %sdriver;\n", 297 dp->d_name); 298 fprintf(fp, "extern "); 299 ip = dp->d_vec; 300 for (;;) { 301 fprintf(fp, "X%s%d()", ip->id, dp->d_unit); 302 ip = ip->id_next; 303 if (ip == 0) 304 break; 305 fprintf(fp, ", "); 306 } 307 fprintf(fp, ";\n"); 308 fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, 309 dp->d_unit); 310 ip = dp->d_vec; 311 for (;;) { 312 fprintf(fp, "X%s%d", ip->id, dp->d_unit); 313 ip = ip->id_next; 314 if (ip == 0) 315 break; 316 fprintf(fp, ", "); 317 } 318 fprintf(fp, ", 0 } ;\n"); 319 } else if (dp->d_type == DRIVER) /* devices w/o interrupts */ 320 fprintf(fp, 321 "extern struct vba_driver %sdriver;\n", 322 dp->d_name); 323 } 324 fprintf(fp, "\nstruct vba_ctlr vbminit[] = {\n"); 325 fprintf(fp, "/*\t driver,\tctlr,\tvbanum,\talive,\tintr,\taddr */\n"); 326 for (dp = dtab; dp != 0; dp = dp->d_next) { 327 mp = dp->d_conn; 328 if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || 329 !eq(mp->d_name, "vba")) 330 continue; 331 if (dp->d_vec == 0) { 332 printf("must specify vector for %s%d\n", 333 dp->d_name, dp->d_unit); 334 continue; 335 } 336 if (dp->d_addr == 0) { 337 printf("must specify csr address for %s%d\n", 338 dp->d_name, dp->d_unit); 339 continue; 340 } 341 if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { 342 printf("drives need their own entries; dont "); 343 printf("specify drive or slave for %s%d\n", 344 dp->d_name, dp->d_unit); 345 continue; 346 } 347 if (dp->d_flags) { 348 printf("controllers (e.g. %s%d) ", 349 dp->d_name, dp->d_unit); 350 printf("don't have flags, only devices do\n"); 351 continue; 352 } 353 fprintf(fp, 354 "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0x%x },\n", 355 dp->d_name, dp->d_unit, qu(mp->d_unit), 356 dp->d_name, dp->d_unit, dp->d_addr); 357 } 358 fprintf(fp, "\t0\n};\n"); 359 /* versabus devices */ 360 fprintf(fp, "\nstruct vba_device vbdinit[] = {\n"); 361 fprintf(fp, 362 "\t/* driver, unit, ctlr, vbanum, slave, intr, addr, dk, flags*/\n"); 363 for (dp = dtab; dp != 0; dp = dp->d_next) { 364 mp = dp->d_conn; 365 if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || 366 mp == TO_NEXUS || mp->d_type == MASTER || 367 eq(mp->d_name, "mba")) 368 continue; 369 np = mp->d_conn; 370 if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) 371 continue; 372 np = 0; 373 if (eq(mp->d_name, "vba")) { 374 if (dp->d_vec == 0) 375 printf( 376 "Warning, no interrupt vector specified for device %s%d\n", 377 dp->d_name, dp->d_unit); 378 if (dp->d_addr == 0) { 379 printf("must specify csr for device %s%d\n", 380 dp->d_name, dp->d_unit); 381 continue; 382 } 383 if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { 384 printf("drives/slaves can be specified "); 385 printf("only for controllers, "); 386 printf("not for device %s%d\n", 387 dp->d_name, dp->d_unit); 388 continue; 389 } 390 vba_n = mp->d_unit; 391 slave = QUES; 392 } else { 393 if ((np = mp->d_conn) == 0) { 394 printf("%s%d isn't connected to anything ", 395 mp->d_name, mp->d_unit); 396 printf(", so %s%d is unattached\n", 397 dp->d_name, dp->d_unit); 398 continue; 399 } 400 vba_n = np->d_unit; 401 if (dp->d_drive == UNKNOWN) { 402 printf("must specify ``drive number'' "); 403 printf("for %s%d\n", dp->d_name, dp->d_unit); 404 continue; 405 } 406 /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */ 407 /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ 408 if (dp->d_slave != UNKNOWN) { 409 printf("slave numbers should be given only "); 410 printf("for massbus tapes, not for %s%d\n", 411 dp->d_name, dp->d_unit); 412 continue; 413 } 414 if (dp->d_vec != 0) { 415 printf("interrupt vectors should not be "); 416 printf("given for drive %s%d\n", 417 dp->d_name, dp->d_unit); 418 continue; 419 } 420 if (dp->d_addr != 0) { 421 printf("csr addresses should be given only "); 422 printf("on controllers, not on %s%d\n", 423 dp->d_name, dp->d_unit); 424 continue; 425 } 426 slave = dp->d_drive; 427 } 428 fprintf(fp, "\t{ &%sdriver, %2d, %s,", 429 eq(mp->d_name, "vba") ? dp->d_name : mp->d_name, dp->d_unit, 430 eq(mp->d_name, "vba") ? " -1" : qu(mp->d_unit)); 431 fprintf(fp, " %s, %2d, %s, C 0x%-6x, %d, 0x%x },\n", 432 qu(vba_n), slave, intv(dp), dp->d_addr, dp->d_dk, 433 dp->d_flags); 434 } 435 fprintf(fp, "\t0\n};\n"); 436 (void) fclose(fp); 437 } 438 #endif 439 440 #if MACHINE_HP300 || MACHINE_LUNA68K 441 hp300_ioconf() 442 { 443 register struct device *dp, *mp; 444 register int hpib, slave; 445 FILE *fp; 446 447 fp = fopen(path("ioconf.c"), "w"); 448 if (fp == 0) { 449 perror(path("ioconf.c")); 450 exit(1); 451 } 452 fprintf(fp, "#include \"sys/param.h\"\n"); 453 fprintf(fp, "#include \"sys/buf.h\"\n"); 454 fprintf(fp, "#include \"sys/map.h\"\n"); 455 fprintf(fp, "\n"); 456 if (machine == MACHINE_HP300) 457 fprintf(fp, "#include \"hp/dev/device.h\"\n\n"); 458 else 459 fprintf(fp, "#include \"luna68k/dev/device.h\"\n\n"); 460 fprintf(fp, "\n"); 461 fprintf(fp, "#define C (caddr_t)\n"); 462 fprintf(fp, "#define D (struct driver *)\n\n"); 463 /* 464 * First print the hpib controller initialization structures 465 */ 466 for (dp = dtab; dp != 0; dp = dp->d_next) { 467 mp = dp->d_conn; 468 if (dp->d_unit == QUES || mp == 0) 469 continue; 470 fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); 471 } 472 fprintf(fp, "\nstruct hp_ctlr hp_cinit[] = {\n"); 473 fprintf(fp, "/*\tdriver,\t\tunit,\talive,\taddr,\tflags */\n"); 474 for (dp = dtab; dp != 0; dp = dp->d_next) { 475 mp = dp->d_conn; 476 if (dp->d_unit == QUES || 477 dp->d_type != MASTER && dp->d_type != CONTROLLER) 478 continue; 479 if (mp != TO_NEXUS) { 480 printf("%s%s must be attached to an sc (nexus)\n", 481 dp->d_name, wnum(dp->d_unit)); 482 continue; 483 } 484 if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { 485 printf("can't specify drive/slave for %s%s\n", 486 dp->d_name, wnum(dp->d_unit)); 487 continue; 488 } 489 fprintf(fp, 490 "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t0x%x },\n", 491 dp->d_name, dp->d_unit, dp->d_addr, dp->d_flags); 492 } 493 fprintf(fp, "\t0\n};\n"); 494 /* devices */ 495 fprintf(fp, "\nstruct hp_device hp_dinit[] = {\n"); 496 fprintf(fp, 497 "/*driver,\tcdriver,\tunit,\tctlr,\tslave,\taddr,\tdk,\tflags*/\n"); 498 for (dp = dtab; dp != 0; dp = dp->d_next) { 499 mp = dp->d_conn; 500 if (mp == 0 || dp->d_type != DEVICE || hpbadslave(mp, dp)) 501 continue; 502 if (mp == TO_NEXUS) { 503 if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { 504 printf("can't specify drive/slave for %s%s\n", 505 dp->d_name, wnum(dp->d_unit)); 506 continue; 507 } 508 slave = QUES; 509 hpib = QUES; 510 } else { 511 if (dp->d_addr != 0) { 512 printf("can't specify sc for device %s%s\n", 513 dp->d_name, wnum(dp->d_unit)); 514 continue; 515 } 516 if (mp->d_type == CONTROLLER) { 517 if (dp->d_drive == UNKNOWN) { 518 printf("must specify drive for %s%s\n", 519 dp->d_name, wnum(dp->d_unit)); 520 continue; 521 } 522 slave = dp->d_drive; 523 } else { 524 if (dp->d_slave == UNKNOWN) { 525 printf("must specify slave for %s%s\n", 526 dp->d_name, wnum(dp->d_unit)); 527 continue; 528 } 529 slave = dp->d_slave; 530 } 531 hpib = mp->d_unit; 532 } 533 fprintf(fp, "{ &%sdriver,\t", dp->d_name); 534 if (mp == TO_NEXUS) 535 fprintf(fp, "D 0x0,\t"); 536 else 537 fprintf(fp, "&%sdriver,", mp->d_name); 538 fprintf(fp, "\t%d,\t%d,\t%d,\tC 0x%x,\t%d,\t0x%x },\n", 539 dp->d_unit, hpib, slave, 540 dp->d_addr, dp->d_dk, dp->d_flags); 541 } 542 fprintf(fp, "0\n};\n"); 543 (void) fclose(fp); 544 } 545 546 #define ishpibdev(n) (eq(n,"rd") || eq(n,"ct") || eq(n,"mt") || eq(n,"ppi")) 547 #define isscsidev(n) (eq(n,"sd") || eq(n,"st") || eq(n,"ac")) 548 549 hpbadslave(mp, dp) 550 register struct device *dp, *mp; 551 { 552 553 if (mp == TO_NEXUS && ishpibdev(dp->d_name) || 554 mp != TO_NEXUS && eq(mp->d_name, "hpib") && 555 !ishpibdev(dp->d_name)) { 556 printf("%s%s must be attached to an hpib\n", 557 dp->d_name, wnum(dp->d_unit)); 558 return (1); 559 } 560 if (mp == TO_NEXUS && isscsidev(dp->d_name) || 561 mp != TO_NEXUS && eq(mp->d_name, "scsi") && 562 !isscsidev(dp->d_name)) { 563 printf("%s%s must be attached to a scsi\n", 564 dp->d_name, wnum(dp->d_unit)); 565 return (1); 566 } 567 return (0); 568 } 569 #endif 570 571 #if MACHINE_I386 572 char *sirq(); 573 574 i386_ioconf() 575 { 576 register struct device *dp, *mp, *np; 577 register int uba_n, slave; 578 FILE *fp; 579 580 fp = fopen(path("ioconf.c"), "w"); 581 if (fp == 0) { 582 perror(path("ioconf.c")); 583 exit(1); 584 } 585 fprintf(fp, "/*\n"); 586 fprintf(fp, " * ioconf.c \n"); 587 fprintf(fp, " * Generated by config program\n"); 588 fprintf(fp, " */\n\n"); 589 fprintf(fp, "#include \"machine/pte.h\"\n"); 590 fprintf(fp, "#include \"sys/param.h\"\n"); 591 fprintf(fp, "#include \"sys/buf.h\"\n"); 592 fprintf(fp, "#include \"sys/map.h\"\n"); 593 fprintf(fp, "\n"); 594 fprintf(fp, "#define V(s) __CONCAT(V,s)\n"); 595 fprintf(fp, "#define C (caddr_t)\n\n"); 596 /* 597 * First print the isa initialization structures 598 */ 599 if (seen_isa) { 600 601 fprintf(fp, "/*\n"); 602 fprintf(fp, " * ISA devices\n"); 603 fprintf(fp, " */\n\n"); 604 fprintf(fp, "#include \"i386/isa/isa_device.h\"\n"); 605 fprintf(fp, "#include \"i386/isa/isa.h\"\n"); 606 fprintf(fp, "#include \"i386/isa/icu.h\"\n\n"); 607 608 for (dp = dtab; dp != 0; dp = dp->d_next) { 609 mp = dp->d_conn; 610 if (mp == 0 || mp == TO_NEXUS || 611 !eq(mp->d_name, "isa")) 612 continue; 613 fprintf(fp, 614 "extern struct isa_driver %sdriver; extern V(%s%d)();\n", 615 dp->d_name, dp->d_name, dp->d_unit); 616 } 617 fprintf(fp, "\nstruct isa_device isa_devtab_bio[] = {\n"); 618 fprintf(fp, "\ 619 /* driver iobase irq drq maddr msiz intr unit */\n"); 620 for (dp = dtab; dp != 0; dp = dp->d_next) { 621 mp = dp->d_conn; 622 if (dp->d_unit == QUES || mp == 0 || 623 mp == TO_NEXUS || !eq(mp->d_name, "isa")) 624 continue; 625 if (!eq(dp->d_mask, "bio")) continue; 626 if (dp->d_port) 627 fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); 628 else 629 fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); 630 fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", 631 sirq(dp->d_irq), dp->d_drq, dp->d_maddr, 632 dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); 633 } 634 fprintf(fp, "0\n};\n"); 635 636 fprintf(fp, "struct isa_device isa_devtab_tty[] = {\n"); 637 fprintf(fp, "\ 638 /* driver iobase irq drq maddr msiz intr unit */\n"); 639 for (dp = dtab; dp != 0; dp = dp->d_next) { 640 mp = dp->d_conn; 641 if (dp->d_unit == QUES || mp == 0 || 642 mp == TO_NEXUS || !eq(mp->d_name, "isa")) 643 continue; 644 if (!eq(dp->d_mask, "tty")) continue; 645 if (dp->d_port) 646 fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); 647 else 648 fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); 649 fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", 650 sirq(dp->d_irq), dp->d_drq, dp->d_maddr, 651 dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); 652 } 653 fprintf(fp, "0\n};\n\n"); 654 655 fprintf(fp, "struct isa_device isa_devtab_net[] = {\n"); 656 fprintf(fp, "\ 657 /* driver iobase irq drq maddr msiz intr unit */\n"); 658 for (dp = dtab; dp != 0; dp = dp->d_next) { 659 mp = dp->d_conn; 660 if (dp->d_unit == QUES || mp == 0 || 661 mp == TO_NEXUS || !eq(mp->d_name, "isa")) 662 continue; 663 if (!eq(dp->d_mask, "net")) continue; 664 if (dp->d_port) 665 fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); 666 else 667 fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); 668 fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", 669 sirq(dp->d_irq), dp->d_drq, dp->d_maddr, 670 dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); 671 } 672 fprintf(fp, "0\n};\n\n"); 673 674 fprintf(fp, "struct isa_device isa_devtab_null[] = {\n"); 675 fprintf(fp, "\ 676 /* driver iobase irq drq maddr msiz intr unit */\n"); 677 for (dp = dtab; dp != 0; dp = dp->d_next) { 678 mp = dp->d_conn; 679 if (dp->d_unit == QUES || mp == 0 || 680 mp == TO_NEXUS || !eq(mp->d_name, "isa")) 681 continue; 682 if (!eq(dp->d_mask, "null")) continue; 683 if (dp->d_port) 684 fprintf(fp, "{ &%sdriver, %8.8s,", dp->d_name, dp->d_port); 685 else 686 fprintf(fp, "{ &%sdriver, 0x%03x,", dp->d_name, dp->d_portn); 687 fprintf(fp, " %5.5s, %2d, C 0x%05X, %5d, V(%s%d), %2d },\n", 688 sirq(dp->d_irq), dp->d_drq, dp->d_maddr, 689 dp->d_msize, dp->d_name, dp->d_unit, dp->d_unit); 690 } 691 fprintf(fp, "0\n};\n\n"); 692 } 693 (void) fclose(fp); 694 } 695 696 char * 697 sirq(num) 698 { 699 700 if (num == -1) 701 return ("0"); 702 sprintf(errbuf, "IRQ%d", num); 703 return (errbuf); 704 } 705 #endif 706 707 #if MACHINE_PMAX 708 pmax_ioconf() 709 { 710 register struct device *dp, *mp; 711 FILE *fp; 712 713 fp = fopen(path("ioconf.c"), "w"); 714 if (fp == 0) { 715 perror(path("ioconf.c")); 716 exit(1); 717 } 718 fprintf(fp, "#include \"types.h\"\n"); 719 fprintf(fp, "#include \"pmax/dev/device.h\"\n\n"); 720 fprintf(fp, "#define C (char *)\n\n"); 721 722 /* print controller initialization structures */ 723 for (dp = dtab; dp != 0; dp = dp->d_next) { 724 if (dp->d_type == PSEUDO_DEVICE) 725 continue; 726 fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name); 727 } 728 fprintf(fp, "\nstruct pmax_ctlr pmax_cinit[] = {\n"); 729 fprintf(fp, "/*\tdriver,\t\tunit,\taddr,\t\tpri,\tflags */\n"); 730 for (dp = dtab; dp != 0; dp = dp->d_next) { 731 if (dp->d_type != CONTROLLER && dp->d_type != MASTER) 732 continue; 733 if (dp->d_conn != TO_NEXUS) { 734 printf("%s%s must be attached to a nexus (internal bus)\n", 735 dp->d_name, wnum(dp->d_unit)); 736 continue; 737 } 738 if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { 739 printf("can't specify drive/slave for %s%s\n", 740 dp->d_name, wnum(dp->d_unit)); 741 continue; 742 } 743 if (dp->d_unit == UNKNOWN || dp->d_unit == QUES) 744 dp->d_unit = 0; 745 fprintf(fp, 746 "\t{ &%sdriver,\t%d,\tC 0x%x,\t%d,\t0x%x },\n", 747 dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri, 748 dp->d_flags); 749 } 750 fprintf(fp, "\t0\n};\n"); 751 752 /* print devices connected to other controllers */ 753 fprintf(fp, "\nstruct scsi_device scsi_dinit[] = {\n"); 754 fprintf(fp, 755 "/*driver,\tcdriver,\tunit,\tctlr,\tdrive,\tslave,\tdk,\tflags*/\n"); 756 for (dp = dtab; dp != 0; dp = dp->d_next) { 757 if (dp->d_type == CONTROLLER || dp->d_type == MASTER || 758 dp->d_type == PSEUDO_DEVICE) 759 continue; 760 mp = dp->d_conn; 761 if (mp == 0 || 762 !eq(mp->d_name, "asc") && !eq(mp->d_name, "sii")) { 763 printf("%s%s: devices must be attached to a SCSI (asc or sii) controller\n", 764 dp->d_name, wnum(dp->d_unit)); 765 continue; 766 } 767 if ((unsigned)dp->d_drive > 6) { 768 printf("%s%s: SCSI drive must be in the range 0..6\n", 769 dp->d_name, wnum(dp->d_unit)); 770 continue; 771 } 772 /* may want to allow QUES later */ 773 if ((unsigned)dp->d_slave > 7) { 774 printf("%s%s: SCSI slave (LUN) must be in the range 0..7\n", 775 dp->d_name, wnum(dp->d_unit)); 776 continue; 777 } 778 fprintf(fp, "{ &%sdriver,\t&%sdriver,", dp->d_name, mp->d_name); 779 fprintf(fp, "\t%d,\t%d,\t%d,\t%d,\t%d,\t0x%x },\n", 780 dp->d_unit, mp->d_unit, dp->d_drive, dp->d_slave, 781 dp->d_dk, dp->d_flags); 782 } 783 fprintf(fp, "0\n};\n"); 784 (void) fclose(fp); 785 } 786 #endif 787 788 #if MACHINE_NEWS3400 789 int have_iop = 0; 790 int have_hb = 0; 791 int have_vme = 0; 792 793 news_ioconf() 794 { 795 register struct device *dp, *mp; 796 register int slave; 797 FILE *fp; 798 799 fp = fopen(path("ioconf.c"), "w"); 800 if (fp == 0) { 801 perror(path("ioconf.c")); 802 exit(1); 803 } 804 fprintf(fp, "#include \"param.h\"\n"); 805 fprintf(fp, "#include \"buf.h\"\n"); 806 fprintf(fp, "#include \"map.h\"\n"); 807 fprintf(fp, "#include \"vm/vm.h\"\n"); 808 fprintf(fp, "#include \"iop.h\"\n"); 809 fprintf(fp, "#include \"hb.h\"\n"); 810 fprintf(fp, "\n"); 811 fprintf(fp, "#if NIOP > 0\n"); 812 fprintf(fp, "#include \"news3400/iop/iopvar.h\"\n"); 813 fprintf(fp, "#endif\n"); 814 fprintf(fp, "#if NHB > 0\n"); 815 fprintf(fp, "#include \"news3400/hbdev/hbvar.h\"\n"); 816 fprintf(fp, "#endif\n"); 817 fprintf(fp, "\n"); 818 fprintf(fp, "#define C (caddr_t)\n\n"); 819 fprintf(fp, "\n"); 820 821 /* BEGIN HB */ 822 fprintf(fp, "#if NHB > 0\n"); 823 /* 824 * Now generate interrupt vectors for the HYPER-BUS 825 */ 826 for (dp = dtab; dp != 0; dp = dp->d_next) { 827 if (dp->d_pri >= 0) { 828 mp = dp->d_conn; 829 if (mp == 0 || mp == TO_NEXUS || 830 !eq(mp->d_name, "hb")) 831 continue; 832 fprintf(fp, "extern struct hb_driver %sdriver;\n", 833 dp->d_name); 834 have_hb++; 835 } 836 } 837 /* 838 * Now spew forth the hb_cinfo structure 839 */ 840 fprintf(fp, "\nstruct hb_ctlr hminit[] = {\n"); 841 fprintf(fp, "/*\t driver,\tctlr,\talive,\taddr,\tintpri */\n"); 842 for (dp = dtab; dp != 0; dp = dp->d_next) { 843 mp = dp->d_conn; 844 if ((dp->d_type != MASTER && dp->d_type != CONTROLLER) 845 || mp == TO_NEXUS || mp == 0 || 846 !eq(mp->d_name, "hb")) 847 continue; 848 if (dp->d_pri < 0) { 849 printf("must specify priority for %s%d\n", 850 dp->d_name, dp->d_unit); 851 continue; 852 } 853 if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { 854 printf("drives need their own entries; "); 855 printf("dont specify drive or slave for %s%d\n", 856 dp->d_name, dp->d_unit); 857 continue; 858 } 859 if (dp->d_flags) { 860 printf("controllers (e.g. %s%d) don't have flags, "); 861 printf("only devices do\n", 862 dp->d_name, dp->d_unit); 863 continue; 864 } 865 fprintf(fp, "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t%d },\n", 866 dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri); 867 } 868 fprintf(fp, "\t0\n};\n"); 869 /* 870 * Now we go for the hb_device stuff 871 */ 872 fprintf(fp, "\nstruct hb_device hdinit[] = {\n"); 873 fprintf(fp, 874 "\t/* driver, unit, ctlr, slave, addr, pri, dk, flags*/\n"); 875 for (dp = dtab; dp != 0; dp = dp->d_next) { 876 mp = dp->d_conn; 877 if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || 878 mp == TO_NEXUS || /* mp->d_type == MASTER || */ 879 eq(mp->d_name, "iop") || eq(mp->d_name, "vme")) 880 continue; 881 if (eq(mp->d_name, "hb")) { 882 if (dp->d_pri < 0) { 883 printf("must specify vector for device %s%d\n", 884 dp->d_name, dp->d_unit); 885 continue; 886 } 887 if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { 888 printf("drives/slaves can be specified only "); 889 printf("for controllers, not for device %s%d\n", 890 dp->d_name, dp->d_unit); 891 continue; 892 } 893 slave = QUES; 894 } else { 895 if (mp->d_conn == 0) { 896 printf("%s%d isn't connected to anything, ", 897 mp->d_name, mp->d_unit); 898 printf("so %s%d is unattached\n", 899 dp->d_name, dp->d_unit); 900 continue; 901 } 902 if (dp->d_drive == UNKNOWN) { 903 printf("must specify ``drive number'' for %s%d\n", 904 dp->d_name, dp->d_unit); 905 continue; 906 } 907 /* NOTE THAT ON THE IOP ``drive'' IS STORED IN */ 908 /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */ 909 if (dp->d_slave != UNKNOWN) { 910 printf("slave numbers should be given only "); 911 printf("for massbus tapes, not for %s%d\n", 912 dp->d_name, dp->d_unit); 913 continue; 914 } 915 if (dp->d_pri >= 0) { 916 printf("interrupt priority should not be "); 917 printf("given for drive %s%d\n", 918 dp->d_name, dp->d_unit); 919 continue; 920 } 921 if (dp->d_addr != 0) { 922 printf("csr addresses should be given only"); 923 printf("on controllers, not on %s%d\n", 924 dp->d_name, dp->d_unit); 925 continue; 926 } 927 slave = dp->d_drive; 928 } 929 fprintf(fp, 930 "\t{ &%sdriver, %2d, %s, %2d, C 0x%x, %d, %d, 0x%x },\n", 931 eq(mp->d_name, "hb") ? dp->d_name : mp->d_name, dp->d_unit, 932 eq(mp->d_name, "hb") ? " -1" : qu(mp->d_unit), 933 slave, dp->d_addr, dp->d_pri, dp->d_dk, dp->d_flags); 934 } 935 fprintf(fp, "\t0\n};\n\n"); 936 fprintf(fp, "#endif\n\n"); 937 /* END HB */ 938 (void) fclose(fp); 939 } 940 #endif 941 942 char * 943 intv(dev) 944 register struct device *dev; 945 { 946 static char buf[20]; 947 948 if (dev->d_vec == 0) 949 return (" 0"); 950 (void) sprintf(buf, "%sint%d", dev->d_name, dev->d_unit); 951 return (buf); 952 } 953 954 char * 955 qu(num) 956 { 957 958 if (num == QUES) 959 return ("'?'"); 960 if (num == UNKNOWN) 961 return (" -1"); 962 (void) sprintf(errbuf, "%3d", num); 963 return (errbuf); 964 } 965 966 char * 967 wnum(num) 968 { 969 970 if (num == QUES || num == UNKNOWN) 971 return ("?"); 972 (void) sprintf(errbuf, "%d", num); 973 return (errbuf); 974 } 975