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