Annotation of 41BSD/sys/stand/ht.c, revision 1.1.1.1

1.1       root        1: /*     ht.c    4.1     11/9/80 */
                      2: 
                      3: /*
                      4:  * TJU16 tape driver
                      5:  */
                      6: 
                      7: #include "../h/param.h"
                      8: #include "../h/inode.h"
                      9: #include "../h/pte.h"
                     10: #include "../h/mba.h"
                     11: #include "saio.h"
                     12: 
                     13: struct device
                     14: {
                     15:        int     htcs1;
                     16:        int     htds;
                     17:        int     hter;
                     18:        int     htmr;
                     19:        int     htas;
                     20:        int     htfc;
                     21:        int     htdt;
                     22:        int     htck;
                     23:        int     htsn;
                     24:        int     httc;
                     25: };
                     26: 
                     27: #define        HTMBA           PHYSMBA1
                     28: #define        HTMBANUM        1
                     29: 
                     30: #define        GO      01
                     31: #define        WCOM    060
                     32: #define        RCOM    070
                     33: #define        NOP     0
                     34: #define        WEOF    026
                     35: #define        SFORW   030
                     36: #define        SREV    032
                     37: #define        ERASE   024
                     38: #define        REW     06
                     39: #define        DCLR    010
                     40: #define P800   01700           /* 800 + pdp11 mode */
                     41: #define        P1600   02300           /* 1600 + pdp11 mode */
                     42: #define        IENABLE 0100
                     43: #define        RDY     0200
                     44: #define        TM      04
                     45: #define        DRY     0200
                     46: #define EOT    02000
                     47: #define CS     02000
                     48: #define COR    0100000
                     49: #define PES    040
                     50: #define WRL    04000
                     51: #define MOL    010000
                     52: #define ERR    040000
                     53: #define FCE    01000
                     54: #define        TRE     040000
                     55: #define HARD   064023  /* UNS|OPI|NEF|FMT|RMR|ILR|ILF */
                     56: 
                     57: #define        SIO     1
                     58: #define        SSFOR   2
                     59: #define        SSREV   3
                     60: #define SRETRY 4
                     61: #define SCOM   5
                     62: #define SOK    6
                     63: 
                     64: htopen(io)
                     65: register struct iob *io;
                     66: {
                     67:        register skip;
                     68:        int i;
                     69: 
                     70:        if ((mbaact&(1<<HTMBANUM)) == 0)
                     71:                mbainit(HTMBANUM);
                     72:        htinit();
                     73:        htstrategy(io, REW);
                     74:        skip = io->i_boff;
                     75:        while (skip--) {
                     76:                io->i_cc = -1;
                     77:                while (htstrategy(io, SFORW))
                     78:                        ;
                     79:                i = 65536;
                     80:                while (--i)
                     81:                        ;
                     82:                htstrategy(io, NOP);
                     83:        }
                     84: }
                     85: 
                     86: htclose(io)
                     87: register struct iob *io;
                     88: {
                     89:        htstrategy(io, REW);
                     90: }
                     91: 
                     92: htstrategy(io, func)
                     93: register struct iob *io;
                     94: {
                     95:        register int unit, den, errcnt, ds;
                     96:        short fc;
                     97:        register struct device *htp = mbadev(HTMBA,0);
                     98: 
                     99:        unit = io->i_unit;
                    100:        errcnt = 0;
                    101: retry:
                    102:        if(unit & 1)
                    103:                den = P1600;
                    104:        else
                    105:                den = P800;
                    106:        htquiet();
                    107:        if((htp->httc&03777) != den)
                    108:                htp->httc = den;
                    109:        htp->htfc = -io->i_cc;
                    110:        if (func == SREV) {
                    111:                htp->htfc = -1;
                    112:                htp->htcs1 = SREV | GO;
                    113:                return(0);
                    114:        }
                    115:        if (func == READ || func == WRITE)
                    116:                mbastart(io, htp, func);
                    117:        else
                    118:                htp->htcs1 = func | GO;
                    119:        htquiet();
                    120:        ds = htp->htds & TM;
                    121:        if (ds&TM) {
                    122:                htinit();
                    123:                return(0);
                    124:        }
                    125:        if (ds&ERR) {
                    126:                if (errcnt == 0)
                    127:                        printf("tape error: ds=%x, er=%x, mbasr=%x",
                    128:                            htp->htds, htp->hter,
                    129:                            HTMBA->mba_sr);
                    130:                htinit();
                    131:                if (errcnt == 10) {
                    132:                        printf("\n");
                    133:                        return(-1);
                    134:                }
                    135:                errcnt++;
                    136:                htstrategy(io, SREV);
                    137:                goto retry;
                    138:        }
                    139:        if (errcnt)
                    140:                printf(" recovered by retry\n");
                    141:        fc = htp->htfc;
                    142:        return(io->i_cc+fc);
                    143: }
                    144: 
                    145: htinit()
                    146: {
                    147: 
                    148:        mbadev(HTMBA,0)->htcs1 = DCLR|GO;
                    149: }
                    150: 
                    151: htquiet()
                    152: {
                    153:        register int s;
                    154:        register struct device *htp = mbadev(HTMBA,0);
                    155: 
                    156:        do
                    157:                s = htp->htds;
                    158:        while ((s & RDY) == 0);
                    159: }

unix.superglobalmegacorp.com

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