Annotation of coherent/f/tmp/install/mkdev.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * mkdev.c
                      3:  * 06/28/93
                      4:  *
                      5:  * Allow the user to configure devices requiring loadable drivers.
                      6:  * Uses common routines in build0.c: cc -o mkdev mkdev.c build0.c
                      7:  * Usage: mkdev [ -bdv ] { scsi | at | floppytape } ...
                      8:  * Options:
                      9:  *     -b      Use special processing when invoked from /etc/build
                     10:  *     -d      Debug; echo commands without executing
                     11:  *     -v      Verbose
                     12:  *
                     13:  * Roughly, do the following for device "foo" ( at | aha154x | ss )
                     14:  *
                     15:  *     cp /drv/foo /tmp/drv/foo
                     16:  *     make necessary patches "xxx" to /tmp/drv/foo
                     17:  *     if not "at" device
                     18:  *             make nodes (mknod -f) for the device
                     19:  *     if build mode (bflag)
                     20:  *             if rootdev
                     21:  *                     append to LDKERFILE:
                     22:  *                             HD=foo.a
                     23:  *                             HDUNDEF="-u foocon_"
                     24:  *                             HDPATCH="drvl_+xx0=foocon_"
                     25:  *             /etc/drvld -r /tmp/drv/foo
                     26:  *             append to PATCHFILE:
                     27:  *                     cp /tmp/drv/foo /mnt/drv/foo
                     28:  *             if rootdev, also append to PATCHFILE:
                     29:  *                     /conf/patch /mnt/coherent xxx
                     30:  *     else - not build mode
                     31:  *             display message saying patched driver is at /tmp/drv/foo
                     32:  */
                     33: 
                     34: #define        __KERNEL__      1
                     35: 
                     36: #include <stdio.h>
                     37: #include <sys/devices.h>
                     38: #include <sys/con.h>
                     39: #include <string.h>
                     40: 
                     41: #include "build0.h"
                     42: 
                     43: #define        VERSION         "V4"            /* version number */
                     44: #define        USAGEMSG        "Usage:\t/etc/mkdev [ -bdv ] [ scsi | at | floppytape ] ...\n"
                     45: #define BUFLEN         50
                     46: #define AHA_HDS                64
                     47: #define AHA_DMA                5
                     48: #define AHA_IRQ                11
                     49: #define AHA_BASE       0x330
                     50: #define TANDY_HDS      16
                     51: 
                     52: /*
                     53:  * calculate the minor number for the specified floppy tape device:
                     54:  *     uu:     unit # (0-3)
                     55:  *     vv:     brand of drive: 0=Archive/Mountain/Summit, 1=CMS, 2&3=rsvd
                     56:  *     s:      select: 0=hard select, 1=soft select
                     57:  *     r:      rewind: 0=no rewind on close, 1=rewind on close
                     58:  */
                     59: #define        FL_TAPE_MINOR(uu,vv,s,r)   ((1<<6)|((uu)<<4)|((s)<<3)|((r)<<2)|(vv))
                     60: #define        FL_TAPE_HARD_SEL        0
                     61: #define        FL_TAPE_SOFT_SEL        1
                     62: #define        FL_TAPE_NOREW           0
                     63: #define        FL_TAPE_REW             1
                     64: 
                     65: /* Forward. */
                     66: void   scsi();
                     67: void   at();
                     68: void   floppy_tape();
                     69: 
                     70: /* Globals. */
                     71: int    bflag;                          /* Invoked from /etc/build. */
                     72: 
                     73: main(argc, argv) int argc; char *argv[];
                     74: {
                     75:        register char *s;
                     76: 
                     77:        argv0 = argv[0];
                     78:        usagemsg = USAGEMSG;
                     79:        if (argc > 1 && argv[1][0] == '-') {
                     80:                for (s = &argv[1][1]; *s; ++s) {
                     81:                        switch(*s) {
                     82:                        case 'b':       ++bflag;        break;
                     83:                        case 'd':       ++dflag;        break;
                     84:                        case 'v':       ++vflag;        break;
                     85:                        case 'V':
                     86:                                fprintf(stderr, "mkdev: %s\n", VERSION);
                     87:                                break;
                     88:                        default:        usage();        break;
                     89:                        }
                     90:                }
                     91:                --argc;
                     92:                ++argv;
                     93:        }
                     94: 
                     95:        if (argc == 1) {
                     96:                usage();
                     97:        } else {
                     98:                /* Do specified things. */
                     99:                while (--argc > 0) {
                    100:                        if (strcmp (argv [1], "scsi") == 0)
                    101:                                scsi ();
                    102:                        else if (strcmp (argv [1], "at") == 0)
                    103:                                at ();
                    104:                        else if (strcmp (argv [1], "floppytape") == 0)
                    105:                                floppy_tape ();
                    106:                        else
                    107:                                usage ();
                    108:                        ++argv;
                    109:                }
                    110:        }
                    111:        exit (0);
                    112: }
                    113: 
                    114: void
                    115: scsi()
                    116: {
                    117:        char *dev;
                    118:        int i, id, lun;
                    119:        int ss_dev = 0;
                    120:        int fut_dev = 0;
                    121:        unsigned nsdrive = 0;
                    122:        int ss_int = 5, new_int;
                    123:        unsigned int ss_base = 0xCA00, new_base;
                    124:        unsigned char ss_patch[200], buf[BUFLEN];
                    125:        FILE *fp;
                    126:        int aha_dev = 0, sd_hds = AHA_HDS, sd_dma = AHA_DMA;
                    127:        int hai_dev = 0;
                    128:        int sd_irq = AHA_IRQ, sd_base = AHA_BASE;
                    129:        int hai_tape = 0;
                    130:        int hai_disk = 0;
                    131:        int unit;
                    132:        int tape_dev;
                    133:        int choice;
                    134: 
                    135:        static int sd_irq_list[] = { 9, 10, 11, 12, 14, 15 };
                    136:        int sd_irq_ct = sizeof(sd_irq_list)/sizeof(sd_irq_list[0]);
                    137: 
                    138:        static int sd_base_list[] =
                    139:                  { 0x130, 0x134, 0x230, 0x234, 0x330, 0x334 };
                    140:        int sd_base_ct = sizeof(sd_base_list)/sizeof(sd_base_list[0]);
                    141: 
                    142:        static int sd_dma_list[] = { 0, 5, 6, 7 };
                    143:        int sd_dma_ct = sizeof(sd_dma_list)/sizeof(sd_dma_list[0]);
                    144: 
                    145:        cls(0);
                    146:        printf(
                    147: "COHERENT currently supports the following SCSI host adapters:\n"
                    148: "\n"
                    149: "(1) Adaptec AHA-154x series, no tape support\n"
                    150: "(2) Adaptec AHA-154x series, with tape support\n\n"
                    151: "(3) Seagate ST01 or ST02\n"
                    152: "(4) Future Domain TMC-845/850/860/875/885\n"
                    153: "(5) Future Domain TMC-840/841/880/881\n"
                    154: "\n"
                    155:                );
                    156: retry:
                    157:        switch(get_int(0, 5, "Enter a number from the above list or 0 to exit:")) {
                    158:        case 0:
                    159:                return;
                    160:        case 1:
                    161:                aha_dev = 1;
                    162:                break;
                    163:        case 2:
                    164:                hai_dev = 1;
                    165:                break;
                    166:        case 3:
                    167:                ss_dev = 1;
                    168:                break;
                    169:        case 4:
                    170:                ss_dev = 1;
                    171:                fut_dev = 1;
                    172:                nsdrive |= 0x8000;
                    173:                break;
                    174:        case 5:
                    175:                ss_dev = 1;
                    176:                fut_dev = 1;
                    177:                nsdrive |= 0x4000;
                    178:                break;
                    179:        default:
                    180:                goto retry;             /* should never happen */
                    181:        }
                    182: 
                    183:        /*
                    184:         * If Adaptec, allow patching host adapter variables SD_HDS
                    185:         * for Tandy variant of host BIOS.
                    186:         */
                    187:        if (aha_dev) {
                    188: printf("\nMost versions of the Adaptec BIOS use 64-head translation mode.\n");
                    189: printf("A few, including some Tandy variants, use 16-head translation mode.\n\n");
                    190:                if (!yes_no("Do you want 64-head translation mode"))
                    191:                        sd_hds = TANDY_HDS;
                    192:        }
                    193: 
                    194:        if (aha_dev || hai_dev) {
                    195:                sd_irq = get_allowed_int(sd_irq_list, sd_irq_ct, ga_dec,
                    196:                  sd_irq, ga_nonstrict,
                    197:                  "\nWhich IRQ does the host adapter use? ");
                    198:                sd_base = get_allowed_int(sd_base_list, sd_base_ct, ga_hex,
                    199:                  sd_base, ga_nonstrict,
                    200:                  "\nWhat is the hexadecimal host adapter base port address? ");
                    201:                sd_dma = get_allowed_int(sd_dma_list, sd_dma_ct, ga_hex,
                    202:                  sd_dma, ga_nonstrict,
                    203:                  "\nWhich DMA channel does the host adapter use? ");
                    204:        }
                    205: 
                    206:        /*
                    207:         * If Seagate or Future Domain, allow patching host adapter
                    208:         * variables SS_INT and SS_BASE.
                    209:         */
                    210:        if (ss_dev) {
                    211: printf("\nPlease refer to the installation guide for your host adapter.\n");
                    212: 
                    213:                /* Get value to patch for SS_INT */
                    214: printf("\nWhich IRQ number does the host adapter use [%d]? ", ss_int);
                    215:                while (1) {
                    216:                        new_int = ss_int;
                    217:                        fgets(buf, BUFLEN, stdin);
                    218:                        sscanf(buf, "%d", &new_int);
                    219:                        if (new_int < 3 || new_int > 15)
                    220: printf("Type a number between 3 and 15 or just <Enter> for the default: ");
                    221:                        else
                    222:                                break;
                    223:                } /* endwhile */
                    224:                ss_int = new_int;
                    225: 
                    226:                /* Get value to patch for SS_BASE */
                    227: printf("Your host adapter is configured for a base segment address.  Possible\n");
                    228: printf("values are: C800, CA00, CC00, CE00, DC00, and DE00.\n");
                    229: printf("What is your 4-digit hexadecimal base address [%04lx]? ", ss_base);
                    230:                while (1) {
                    231:                        new_base = ss_base;
                    232:                        fgets(buf, BUFLEN, stdin);
                    233:                        sscanf(buf, "%x", &new_base);
                    234:                        if (new_base < 0xC800 || new_base > 0xDE00)
                    235: printf("Type a number between C800 and DE00 or just <Enter> for the default: ");
                    236:                        else
                    237:                                break;
                    238:                } /* endwhile */
                    239:                ss_base = new_base;
                    240:        }
                    241:        
                    242:        /* Make device nodes. */
                    243:        cls(0);
                    244:        if (hai_dev) {
                    245:                printf(
                    246: "You must specify a SCSI-ID (0 through 7) for each SCSI hard disk or tape\n"
                    247: "device.  Each SCSI hard disk device can contain up to four partitions.\n"
                    248: "Tape devices must be configured as logical unit number (LUN) 0.  All current\n"
                    249: "SCSI tape drives with embedded SCSI controllers default to LUN 0.\n\n"
                    250:                        );
                    251:        } else {
                    252:                printf(
                    253: "You must specify a SCSI-ID (0 through 7) for each SCSI hard disk device.\n"
                    254: "Each SCSI hard disk device can contain up to four partitions.\n\n"
                    255:                        );
                    256:        }
                    257: 
                    258: for (;;) {
                    259:        tape_dev = 0;
                    260: 
                    261:        if (hai_dev) {
                    262:                printf(
                    263: "1) Enter SCSI ID for SCSI hard disk (fixed or removable media)\n"
                    264: "2) Enter SCSI ID for SCSI tape drive\n\n"
                    265: "3) End entering SCSI ID values.\n\n"
                    266:                );
                    267:                choice = get_int(1, 3, "Your choice:");
                    268:        } else {
                    269:                printf(
                    270: "1) Enter SCSI ID for SCSI hard disk (fixed or removable media)\n"
                    271: "2) End entering SCSI ID values.\n\n"
                    272:                );
                    273:                choice = get_int(1, 2, "Your choice:");
                    274:        }
                    275: 
                    276:        if (hai_dev) {
                    277:                if (choice == 2)
                    278:                        tape_dev = 1;
                    279:                if (choice == 3)
                    280:                        break;
                    281:        } else {
                    282:                if (choice == 2)
                    283:                        break;
                    284:        }
                    285: 
                    286:        if (tape_dev) {
                    287:                id = get_int(0, 7, "\nEnter the next tape device SCSI-ID:");
                    288:                hai_tape |= (1 << id);
                    289:        } else {
                    290:                id = get_int(0, 7, "\nEnter the next disk device SCSI-ID:");
                    291:                hai_disk |= (1 << id);
                    292:        }
                    293: 
                    294:        lun = 0;
                    295:        nsdrive |= (1 << id);
                    296: 
                    297:        /* Make /tmp/dev if bflag. */
                    298:        if (bflag) {
                    299:                if ((i = is_dir("/tmp/dev")) == 0)
                    300:                        sys("/bin/mkdir /tmp/dev", S_FATAL);
                    301:                else if (i == -1)
                    302:                        fatal("/tmp/dev is not a directory");
                    303:        }
                    304:        dev = (bflag) ? "/tmp/dev" : "/dev";
                    305: 
                    306:        /*
                    307:         * If we are creating a SCSI tape device (Adaptec only),
                    308:         * create special raw device nodes and generate links
                    309:         * for /dev/tape and /dev/ntape to make it easy on the user.
                    310:         */
                    311: #if !TEST
                    312:        if (tape_dev) {
                    313:                sprintf(cmd, "/etc/mknod -f %s/rst%d c %d %d",
                    314:                        dev, id, SCSI_MAJOR, SCSI_minor(1, id, lun, 3));
                    315:                sys(cmd, S_NONFATAL);
                    316:                sprintf(cmd, "/etc/mknod -f %s/rst%dn c %d %d",
                    317:                        dev, id, SCSI_MAJOR, SCSI_minor(1, id, lun, 1));
                    318:                sys(cmd, S_NONFATAL);
                    319:                sprintf(cmd, "/bin/ln -f %s/rst%d %s/tape",
                    320:                        dev, id, dev);
                    321:                sys(cmd, S_NONFATAL);
                    322:                sprintf(cmd, "/bin/ln -f %s/rst%dn %s/ntape",
                    323:                        dev, id, dev);
                    324:                sys(cmd, S_NONFATAL);
                    325: 
                    326:                /* set the device permissions. */
                    327:                sprintf(cmd, "/bin/chmog 600 sys sys %s/rst%d*", dev, id);
                    328:                sys(cmd, S_NONFATAL);
                    329:        } else {
                    330:                /*
                    331:                 * SCSI disk device:
                    332:                 * Make the cooked devices.
                    333:                 */
                    334:                for (i = 0; i < 4; i++) {
                    335:                        sprintf(cmd, "/etc/mknod -f %s/sd%d%c b %d %d",
                    336:                                dev, id, 'a'+i, SCSI_MAJOR, SCSI_minor(0, id, lun, i));
                    337:                        sys(cmd, S_NONFATAL);
                    338:                }
                    339:                sprintf(cmd, "/etc/mknod -f %s/sd%dx b %d %d",
                    340:                        dev, id, SCSI_MAJOR, SCSI_minor(1, id, lun, 0));
                    341:                sys(cmd, S_NONFATAL);
                    342:                
                    343:                /* make the raw devices. */
                    344:                for (i = 0; i < 4; i++) {
                    345:                        sprintf(cmd, "/etc/mknod -f %s/rsd%d%c c %d %d",
                    346:                                dev, id, 'a'+i, SCSI_MAJOR, SCSI_minor(0, id, lun, i));
                    347:                        sys(cmd, S_NONFATAL);
                    348:                }
                    349:                sprintf(cmd, "/etc/mknod -f %s/rsd%dx c %d %d",
                    350:                        dev, id, SCSI_MAJOR, SCSI_minor(1, id, lun, 0));
                    351:                sys(cmd, S_NONFATAL);
                    352: 
                    353:                /* set the device permissions. */
                    354:                sprintf(cmd, "/bin/chmog 600 sys sys %s/sd*[a-d] %s/rsd*[a-d]",dev,dev);
                    355:                sys(cmd, S_NONFATAL);
                    356:                sprintf(cmd, "/bin/chmog 600 root root %s/sd*x %s/rsd*x", dev, dev);
                    357:                sys(cmd, S_NONFATAL);
                    358:        } /* !(tape_dev) */
                    359:        
                    360:        /* append lines to /tmp/devices to pass device info to /etc/build. */
                    361:        if (bflag && !tape_dev) {
                    362:                for (i = 0; i < 4; i++) {
                    363:                        sprintf(cmd, "/bin/echo sd%dx sd%d%c %d %d >>/tmp/devices",
                    364:                                id, id, 'a'+i, SCSI_MAJOR, SCSI_minor(0, id, lun, i));
                    365:                        sys(cmd, S_NONFATAL);
                    366:                }
                    367:        }
                    368: #endif
                    369:        cls(0);
                    370:        printf("%s device has been installed at id %d\n\n",
                    371:          tape_dev ? "Tape" : "Disk", id);
                    372: }
                    373: 
                    374:        /* At this point all SCSI id's attached to the host are known. */
                    375: 
                    376:        /*
                    377:         * Ugly patching stuff specific to "ss" driver.
                    378:         */
                    379:        if (ss_dev) {
                    380: 
                    381:                /* "ss" device driver requires patching to work at all. */
                    382:                sprintf (ss_patch,
                    383:                         "NSDRIVE=0x%04x SS_INT=%d SS_BASE=0x%04x",
                    384:                         nsdrive, ss_int, ss_base);
                    385: 
                    386:                /* for target kernel */
                    387: 
                    388:                idenable_dev ("ss");
                    389: 
                    390:                sprintf (buf, "unsigned int\tNSDRIVE = 0x%04x;", nsdrive);
                    391:                cohtune_ent ("ss", "NSDRIVE", buf);
                    392: 
                    393:                sprintf (buf, "unsigned int\tSS_INT = %d;", ss_int);
                    394:                cohtune_ent ("ss", "SS_INT", buf);
                    395: 
                    396:                sprintf (buf, "unsigned int\tSS_BASE = %d;", ss_base);
                    397:                cohtune_ent ("ss", "SS_BASE", buf);
                    398: 
                    399:                /* for second boot kernel */
                    400:                fp = fopen(PATCHFILE,"a");
                    401: 
                    402:                fprintf (fp, "/conf/patch /mnt/coherent drvl+%d=sscon \n",
                    403:                         SCSI_MAJOR * sizeof (DRV));
                    404: 
                    405:                fprintf (fp, "/conf/patch /mnt/coherent %s\n", ss_patch);
                    406: 
                    407:                fclose (fp);
                    408: 
                    409:                /* for first boot kernel */
                    410: 
                    411:                sprintf (cmd, "/conf/kpatch -v %s", ss_patch);
                    412:                sys (cmd, S_FATAL);
                    413:                sprintf (cmd, "/conf/kpatch -v sscon:%d:in", SCSI_MAJOR);
                    414:                sys (cmd, S_FATAL);
                    415: 
                    416:                /*
                    417:                 * Allow patching of the loaded driver parameters.
                    418:                 */
                    419:                for (unit = 0; unit < 7; unit++) {
                    420:                        if (nsdrive & (1 << unit)) {
                    421:                                sprintf (cmd, "/etc/hdparms -%c%c %s/sd%dx",
                    422:                                         'r', fut_dev ? 'f' : 's', dev, unit);
                    423:                                sys (cmd, S_NONFATAL);
                    424:                        }
                    425:                }
                    426:        } /* end of "ss" stuff */
                    427: 
                    428:        /*
                    429:         * Ugly patching stuff specific to "aha154x" driver.
                    430:         * At this point all SCSI id's attached to the host are known.
                    431:         */
                    432:        if (aha_dev) {
                    433:                /*
                    434:                 * Tandy Adaptec BIOS spoofs different head count than
                    435:                 * Adaptec's Own Translation Mode.
                    436:                 */
                    437: 
                    438:                sprintf (ss_patch, "SD_HDS=%d SDDMA=%d SDIRQ=%d SDBASE=0x%x ",
                    439:                         sd_hds, sd_dma, sd_irq, sd_base);
                    440: 
                    441:                /* for target kernel */
                    442: 
                    443:                idenable_dev ("aha");
                    444: 
                    445:                sprintf (buf, "int\tSD_HDS = %d;", sd_hds);
                    446:                cohtune_ent ("aha", "SD_HDS", buf);
                    447: 
                    448:                sprintf (buf, "int\tSDDMA = %d;", sd_dma);
                    449:                cohtune_ent ("aha", "SDDMA", buf);
                    450: 
                    451:                sprintf (buf, "int\tSDIRQ = %d;", sd_irq);
                    452:                cohtune_ent ("aha", "SDIRQ", buf);
                    453: 
                    454:                sprintf (buf, "int\tSDBASE = 0x%x;", sd_base);
                    455:                cohtune_ent ("aha", "SDBASE", buf);
                    456: 
                    457:                /* for second boot kernel */
                    458:                fp = fopen (PATCHFILE,"a");
                    459: 
                    460:                fprintf (fp, "/conf/patch /mnt/coherent drvl+%d=sdcon\n",
                    461:                         SCSI_MAJOR * sizeof (DRV));
                    462: 
                    463:                fprintf (fp, "/conf/patch /mnt/coherent %s\n", ss_patch);
                    464: 
                    465:                fclose (fp);
                    466: 
                    467:                /* for first boot kernel */
                    468: 
                    469:                sprintf (cmd, "/conf/kpatch -v %s", ss_patch);
                    470:                sys (cmd, S_FATAL);
                    471:                sprintf (cmd, "/conf/kpatch -v sdcon:%d:in", SCSI_MAJOR);
                    472:                sys (cmd, S_FATAL);
                    473:        }
                    474: 
                    475:        /*
                    476:         * Ugly patching stuff specific to "hai" driver.
                    477:         * At this point all SCSI id's attached to the host are known.
                    478:         */
                    479:        if (hai_dev) {
                    480:                /*
                    481:                 * Tandy Adaptec BIOS spoofs different head count than
                    482:                 * Adaptec's Own Translation Mode.
                    483:                 */
                    484:                sprintf (ss_patch, "AHADMACHAN=%d:s AHAINTR=%d:s "
                    485:                                   "AHABASE=0x%x:s HAI_DISK=%d HAI_TAPE=%d ",
                    486:                         sd_dma, sd_irq, sd_base, hai_disk, hai_tape);
                    487: 
                    488:                /* for target kernel */
                    489: 
                    490:                idenable_dev ("hai");
                    491: 
                    492:                sprintf (buf, "int\tAHADMACHAN = %d;", sd_dma);
                    493:                cohtune_ent ("hai", "AHADMACHAN", buf);
                    494: 
                    495:                sprintf (buf, "int\tAHAINTR = %d;", sd_irq);
                    496:                cohtune_ent ("hai", "AHAINTR", buf);
                    497: 
                    498:                sprintf (buf, "int\tAHABASE = %d;", sd_base);
                    499:                cohtune_ent ("hai", "AHABASE", buf);
                    500: 
                    501:                sprintf (buf, "int\tHAI_DISK = %d;", hai_disk);
                    502:                cohtune_ent ("hai", "HAI_DISK", buf);
                    503: 
                    504:                sprintf (buf, "int\tHAI_TAPE = %d;", hai_tape);
                    505:                cohtune_ent ("hai", "HAI_TAPE", buf);
                    506: 
                    507:                /* for second boot kernel */
                    508:                fp = fopen (PATCHFILE,"a");
                    509: 
                    510:                fprintf (fp, "/conf/patch /mnt/coherent drvl+%d=scsicon \n",
                    511:                         SCSI_MAJOR * sizeof (DRV));
                    512: 
                    513:                fprintf (fp, "/conf/patch /mnt/coherent %s\n", ss_patch);
                    514: 
                    515:                fclose (fp);
                    516: 
                    517:                /* for first boot kernel */
                    518: 
                    519:                sprintf (cmd, "/conf/kpatch -v %s", ss_patch);
                    520:                sys (cmd, S_FATAL);
                    521:                sprintf (cmd, "/conf/kpatch -v scsicon:%d:in", SCSI_MAJOR);
                    522:                sys (cmd, S_FATAL);
                    523: 
                    524:        } /* end of "hai" stuff */
                    525: }
                    526: 
                    527: void
                    528: at()
                    529: {
                    530:        unsigned char at_patch[80];
                    531:        FILE *fp;
                    532:        int at_poll;
                    533:        char line[512];
                    534:        int normal_at_poll;
                    535:        int fl_dsk_ch_prob;
                    536:        int use_ps1;
                    537:        int at_drive_ct;
                    538: 
                    539:        /* Normal vs. alternate polling. */
                    540:        cls(0);
                    541:        printf(
                    542: "Most AT-compatible controllers work with NORMAL polling.\n\n"
                    543: "Perstor controllers and some IDE hard drives require ALTERNATE polling.\n\n"
                    544: "If you get \"<Watchdog Timeout>\" or \"at0:TO\" errors with normal polling,\n"
                    545: "use alternate polling.\n\n");
                    546: 
                    547:        if (normal_at_poll = yes_no ("Use NORMAL polling")) {
                    548:                strcpy (at_patch, "ATSREG=0x3F6 ");
                    549:                at_poll = 0x3F6;
                    550:        } else {
                    551:                strcpy (at_patch, "ATSREG=0x1F7 ");
                    552:                at_poll = 0x1F7;
                    553:        }
                    554:        cls(0);
                    555:        printf("%s polling will be used.\n\n",
                    556:          normal_at_poll ? "NORMAL" : "ALTERNATE");
                    557: 
                    558:        /* Normal vs. PS1 hard disk counts. */
                    559:        if (use_ps1 = yes_no(
                    560:          "Are you installing on an IBM PS1 or ValuePoint?")) {
                    561:                at_drive_ct = get_int(1, 2,
                    562:                  "Enter number of non-SCSI hard drives:");
                    563:                fl_dsk_ch_prob = 1;
                    564:        } else {
                    565:                fl_dsk_ch_prob = 0;
                    566:        }
                    567: 
                    568:        /* for target kernel */
                    569: 
                    570:        idenable_dev ("at");
                    571:        sprintf (line, "int\tATSREG = 0x%x;", at_poll);
                    572:        cohtune_ent ("at", "ATSREG", line);
                    573:        if (use_ps1)
                    574:                idtune_var("AT_DRIVE_CT", at_drive_ct);
                    575:        idtune_var("FL_DSK_CH_PROB", fl_dsk_ch_prob);
                    576: 
                    577:        /* for second boot kernel */
                    578:        fp = fopen (PATCHFILE,"a");
                    579:        fprintf (fp, "/conf/patch /mnt/coherent drvl+%d=atcon \n",
                    580:                 AT_MAJOR * sizeof (DRV));
                    581:        fprintf (fp, "/conf/patch /mnt/coherent %s\n", at_patch);
                    582:        fprintf (fp, "/conf/patch /mnt/coherent fl_dsk_ch_prob=%d\n",
                    583:          fl_dsk_ch_prob);
                    584:        if (use_ps1)
                    585:                fprintf (fp, "/conf/patch /mnt/coherent at_drive_ct=%d\n",
                    586:                  at_drive_ct);
                    587:        fclose (fp);
                    588: 
                    589:        /* for first boot kernel */
                    590: 
                    591:        sprintf (cmd, "/conf/kpatch -v %s", at_patch);
                    592:        sys (cmd, S_FATAL);
                    593:        sprintf (cmd, "/conf/kpatch -v fl_dsk_ch_prob=%d", fl_dsk_ch_prob);
                    594:        sys (cmd, S_FATAL);
                    595:        if (use_ps1) {
                    596:                sprintf (cmd, "/conf/kpatch -v at_drive_ct=%d", at_drive_ct);
                    597:                sys (cmd, S_FATAL);
                    598:        }
                    599:        /* For PS1, this step must come AFTER at_drive_ct is fixed. */
                    600:        sprintf (cmd, "/conf/kpatch -v atcon:%d:in", AT_MAJOR);
                    601:        sys (cmd, S_FATAL);
                    602: }
                    603: 
                    604: /*
                    605:  * floppy_tape:        add support for floppy tape (a really disgusting device)
                    606:  *
                    607:  *     1) give user some info regarding COH support for floppy tape
                    608:  *     2) display a list of supported drives
                    609:  *     3) query the user for type of drive
                    610:  *     4) create device nodes for specified drive
                    611:  *     5) (optional) test for which unit number the drive is seen as
                    612:  */
                    613: void
                    614: floppy_tape()
                    615: {
                    616:        int     brand;          /* which brand of drive (from menu) */
                    617:        int     i;              /* loop counter */
                    618: 
                    619:        cls(0);
                    620:        printf(
                    621: "The COHERENT system supports several brands of \"floppy tape backup\" drives,\n"
                    622: "including QIC-40 and QIC-80 models from Archive, Colorado Memory Systems (CMS),\n"
                    623: "Mountain, and Summit.\n\n"
                    624: "Please specify the brand of floppy tape drive on this computer:\n\n"
                    625: "\t0) Archive, Mountain, or Summit\n"
                    626: "\t1) Colorado Memory Systems (CMS)\n"
                    627: "\t2) Other\n\n"
                    628:        );
                    629:        brand = get_int(0, 2, "Enter drive type:");
                    630:        if (brand == 2) {
                    631:                printf(
                    632: "\nYou have specified a brand of tape drive which is currently unsupported.\n"
                    633:                );
                    634:                return;
                    635:        }
                    636:        
                    637:        /*
                    638:         * now create the following nodes for the specified drive brand:
                    639:         *       Rewind         No Rewind        Unit #
                    640:         *      --------        ---------       ---------
                    641:         *      DEV/rct0        DEV/nrct0       (unit #0)
                    642:         *      DEV/rct1        DEV/nrct1       (unit #1)
                    643:         *      DEV/rct2        DEV/nrct2       (unit #2)
                    644:         *      DEV/rct3        DEV/nrct3       (unit #3)
                    645:         *      DEV/rctss       DEV/nrctss      (soft select)
                    646:         *
                    647:         * where DEV is /mnt/dev if called from /etc/build and /dev otherwise.
                    648:         */
                    649:        for (i = 0; i <= 3; ++i) {
                    650:                sprintf(cmd, "/etc/mknod -f %s/rct%d c %d %d",
                    651:                        (bflag) ? "/mnt/dev" : "/dev", i, FL_MAJOR,
                    652:                        FL_TAPE_MINOR(i, brand, FL_TAPE_HARD_SEL, FL_TAPE_REW));
                    653:                sys(cmd, S_NONFATAL);
                    654:                sprintf(cmd, "/etc/mknod -f %s/nrct%d c %d %d",
                    655:                        (bflag) ? "/mnt/dev" : "/dev", i, FL_MAJOR,
                    656:                        FL_TAPE_MINOR(i, brand, FL_TAPE_HARD_SEL, FL_TAPE_NOREW));
                    657:                sys(cmd, S_NONFATAL);
                    658:        }
                    659:        sprintf(cmd, "/etc/mknod -f %s/rctss c %d %d",
                    660:                (bflag) ? "/mnt/dev" : "/dev", FL_MAJOR,
                    661:                FL_TAPE_MINOR(0, brand, FL_TAPE_SOFT_SEL, FL_TAPE_REW));
                    662:        sys(cmd, S_NONFATAL);
                    663:        sprintf(cmd, "/etc/mknod -f %s/nrctss c %d %d",
                    664:                (bflag) ? "/mnt/dev" : "/dev", FL_MAJOR,
                    665:                FL_TAPE_MINOR(0, brand, FL_TAPE_SOFT_SEL, FL_TAPE_NOREW));
                    666:        sys(cmd, S_NONFATAL);
                    667: }
                    668: 
                    669: /* end of mkdev.c */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.