Annotation of researchv9/sys/boot/stand/xt.c, revision 1.1.1.1

1.1       root        1: #ifndef XTBOOT
                      2: #ifndef lint
                      3: static char sccsid[] = "@(#)xt.c       1.1 86/02/03    Copyr 1985 Sun Micro";
                      4: #endif
                      5: #endif
                      6: 
                      7: /*
                      8:  * Copyright (c) 1985 by Sun Microsystems, Inc.
                      9:  */
                     10: 
                     11: /*
                     12:  * Standalone driver for Xylogics 472 Tape Controller
                     13:  */
                     14: 
                     15: #include "saio.h"
                     16: #include "../sundev/xycreg.h"
                     17: #include "../sundev/xtreg.h"
                     18: 
                     19: 
                     20: #define NXTADDR        2
                     21: unsigned long xtaddrs[] = { 0xEE60, 0xEE68 };
                     22: 
                     23: #define MAXXTREC       (20*1024)       /* max size tape rec allowed */
                     24: 
                     25: struct xtdma {
                     26:        struct xtiopb   xtiopb;
                     27:        char            xtblock[MAXXTREC];
                     28: };
                     29: 
                     30: /* Define resources needed by this driver */
                     31: struct devinfo xtinfo = {
                     32:        sizeof(struct xydevice), sizeof (struct xtdma), 0,
                     33:        NXTADDR, xtaddrs, MAP_MBIO,
                     34:        MAXXTREC,
                     35: };
                     36: 
                     37: int    xtstrategy(), xtopen(), xtclose();
                     38: extern int     nullsys(), ttboot();
                     39: 
                     40: struct boottab xtdriver = {
                     41:        "xt",   nullsys, ttboot, xtopen, xtclose, xtstrategy,
                     42:        "xt: Xylogics 472 tape",        &xtinfo,
                     43: };
                     44: 
                     45: xtopen(sip)
                     46:        register struct saioreq *sip;
                     47: {
                     48:        register skip;
                     49:        register struct xydevice *xyaddr;
                     50: 
                     51:        xyaddr = (struct xydevice *) sip->si_devaddr;
                     52:        if (pokec((char *)xyaddr, 0))
                     53:                return (-1);
                     54:        skip = xyaddr->xy_resupd;       /* controller reset */
                     55:        xtcmd(sip, XT_SEEK, XT_REW);
                     56:        skip = sip->si_boff;
                     57:        while (skip--) {
                     58:                sip->si_cc = 0;
                     59:                xtcmd(sip, XT_SEEK, XT_FILE);
                     60:        }
                     61:        return (0);
                     62: }
                     63: 
                     64: xtclose(sip)
                     65:        register struct saioreq *sip;
                     66: {
                     67: 
                     68:        xtcmd(sip, XT_SEEK, XT_REW);
                     69: }
                     70: 
                     71: xtstrategy(sip, rw)
                     72:        struct saioreq *sip;
                     73:        int rw;
                     74: {
                     75:        int func = (rw == WRITE) ? XT_WRITE : XT_READ;
                     76: 
                     77:        return xtcmd(sip, func, 0);
                     78: }
                     79: 
                     80: xtcmd(sip, func, subfunc)
                     81:        register struct saioreq *sip;
                     82: {
                     83:        register struct xtiopb *xt = &((struct xtdma *)sip->si_dmaaddr)->xtiopb;
                     84:        register struct xydevice *xyaddr = (struct xydevice *)sip->si_devaddr;
                     85:        char *xtbuf = ((struct xtdma *)sip->si_dmaaddr)->xtblock;
                     86:        int err, t;
                     87: 
                     88:        bzero((char *)xt, sizeof (struct xtiopb));
                     89:        xt->xt_reloc = 1;
                     90:        xt->xt_autoup = 1;
                     91:        xt->xt_cmd = func;
                     92:        xt->xt_subfunc = subfunc;
                     93:        xt->xt_unit = sip->si_unit & 3;
                     94:        xt->xt_throttle = 5;
                     95:        switch (func) {
                     96: 
                     97:        case XT_READ:
                     98:                xt->xt_cnt = sip->si_cc;
                     99:                xt->xt_swab = 1;
                    100:                xt->xt_retry = 1;
                    101:                break;
                    102: 
                    103:        case XT_WRITE:
                    104:                xt->xt_cnt = sip->si_cc;
                    105:                bcopy((char *)sip->si_ma, xtbuf, xt->xt_cnt);
                    106:                xt->xt_swab = 1;
                    107:                xt->xt_retry = 1;
                    108:                break;
                    109: 
                    110:        default:
                    111:                xt->xt_cnt = 1;
                    112:                break;
                    113:        }
                    114:        xt->xt_bufoff = XYOFF(xtbuf);
                    115:        xt->xt_bufrel = XYREL(xyaddr, xtbuf);
                    116: 
                    117:        t = XYREL(xyaddr, (char *)xt);
                    118:        xyaddr->xy_iopbrel[0] = t >> 8;
                    119:        xyaddr->xy_iopbrel[1] = t;
                    120:        xyaddr->xy_iopboff[0] = ((int)xt) >> 8;
                    121:        xyaddr->xy_iopboff[1] = (int)xt;
                    122:        xyaddr->xy_csr = XY_GO;
                    123: 
                    124:        do {
                    125:                DELAY(30);
                    126:        } while (xyaddr->xy_csr & XY_BUSY);
                    127:        err = xt->xt_errno;
                    128: 
                    129:        if (err != XTE_NOERROR && err != XTE_SHORTREC && err != XTE_LONGREC) {
                    130:                if (err == XTE_EOF || err == XTE_EOT)
                    131:                        return (0);
                    132:                /* Note: controller does retries for us */
                    133:                printf("xt hard err %x\n", err);
                    134:                return (-1);
                    135:        }
                    136:        if (func == XT_READ)
                    137:                bcopy(xtbuf, (char *)sip->si_ma, xt->xt_acnt);
                    138:        return (xt->xt_acnt);
                    139: }

unix.superglobalmegacorp.com

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