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