1*3262Swnj /* ht.c 4.3 81/03/15 */ 2319Sbill 3319Sbill /* 4*3262Swnj * TM03/TU?? tape driver 5319Sbill */ 6319Sbill 7*3262Swnj #include "../h/htreg.h" 8319Sbill #include "../h/param.h" 9319Sbill #include "../h/inode.h" 10422Sbill #include "../h/pte.h" 11*3262Swnj #include "../h/mbareg.h" 12319Sbill #include "saio.h" 13*3262Swnj #include "savax.h" 14319Sbill 15319Sbill htopen(io) 16*3262Swnj register struct iob *io; 17319Sbill { 18*3262Swnj register int skip; 19*3262Swnj register struct htdevice *htaddr = (struct htdevice *)mbadrv(io->i_unit); 20319Sbill int i; 21319Sbill 22*3262Swnj mbainit(UNITTOMBA(io->i_unit)); 23*3262Swnj htaddr->htcs1 = HT_DCLR|HT_GO; 24*3262Swnj htstrategy(io, HT_REW); 25319Sbill skip = io->i_boff; 26319Sbill while (skip--) { 27319Sbill io->i_cc = -1; 28*3262Swnj while (htstrategy(io, HT_SFORW)) 29319Sbill ; 30*3262Swnj DELAY(65536); 31*3262Swnj htstrategy(io, HT_SENSE); 32319Sbill } 33319Sbill } 34319Sbill 35319Sbill htclose(io) 36*3262Swnj register struct iob *io; 37319Sbill { 38*3262Swnj 39*3262Swnj htstrategy(io, HT_REW); 40319Sbill } 41319Sbill 42319Sbill htstrategy(io, func) 43*3262Swnj register struct iob *io; 44*3262Swnj int func; 45319Sbill { 46*3262Swnj register int den, errcnt, ds; 47319Sbill short fc; 48*3262Swnj register struct htdevice *htaddr = 49*3262Swnj (struct htdevice *)mbadrv(io->i_unit); 50319Sbill 51319Sbill errcnt = 0; 52319Sbill retry: 53*3262Swnj den = HTTC_1600BPI|HTTC_PDP11; 54*3262Swnj htquiet(htaddr); 55*3262Swnj htaddr->httc = den; 56*3262Swnj htaddr->htfc = -io->i_cc; 57*3262Swnj if (func == HT_SREV) { 58*3262Swnj htaddr->htfc = -1; 59*3262Swnj htaddr->htcs1 = HT_SREV|HT_GO; 60*3262Swnj return (0); 61319Sbill } 62*3262Swnj if (func == HT_RCOM || func == HT_WCOM) 63*3262Swnj mbastart(io, func); 64319Sbill else 65*3262Swnj htaddr->htcs1 = func|HT_GO; 66*3262Swnj htquiet(htaddr); 67*3262Swnj ds = htaddr->htds; 68*3262Swnj if (ds & HTDS_TM) { 69*3262Swnj htaddr->htcs1 = HT_DCLR|HT_GO; 70*3262Swnj return (0); 71319Sbill } 72*3262Swnj if (ds & HTDS_ERR) { 73319Sbill if (errcnt == 0) 74*3262Swnj printf("tape error: ds=%x, er=%x", 75*3262Swnj htaddr->htds, htaddr->hter); 76*3262Swnj htaddr->htcs1 = HT_DCLR|HT_GO; 77319Sbill if (errcnt == 10) { 78319Sbill printf("\n"); 79*3262Swnj return (-1); 80319Sbill } 81319Sbill errcnt++; 82*3262Swnj htstrategy(io, HT_SREV); 83319Sbill goto retry; 84319Sbill } 85319Sbill if (errcnt) 86319Sbill printf(" recovered by retry\n"); 87*3262Swnj fc = htaddr->htfc; 88*3262Swnj return (io->i_cc+fc); 89319Sbill } 90319Sbill 91*3262Swnj htquiet(htaddr) 92*3262Swnj register struct htdevice *htaddr; 93319Sbill { 94319Sbill register int s; 95319Sbill 96319Sbill do 97*3262Swnj s = htaddr->htds; 98*3262Swnj while ((s & HTDS_DRY) == 0); 99319Sbill } 100