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