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

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

unix.superglobalmegacorp.com

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