1*3274Swnj /* ht.c 4.4 81/03/16 */ 2319Sbill 3319Sbill /* 43262Swnj * TM03/TU?? tape driver 5319Sbill */ 6319Sbill 73262Swnj #include "../h/htreg.h" 8319Sbill #include "../h/param.h" 9319Sbill #include "../h/inode.h" 10422Sbill #include "../h/pte.h" 113262Swnj #include "../h/mbareg.h" 12319Sbill #include "saio.h" 133262Swnj #include "savax.h" 14319Sbill 15319Sbill htopen(io) 163262Swnj register struct iob *io; 17319Sbill { 183262Swnj register int skip; 193262Swnj register struct htdevice *htaddr = (struct htdevice *)mbadrv(io->i_unit); 20319Sbill int i; 21319Sbill 223262Swnj mbainit(UNITTOMBA(io->i_unit)); 233262Swnj htaddr->htcs1 = HT_DCLR|HT_GO; 243262Swnj htstrategy(io, HT_REW); 25319Sbill skip = io->i_boff; 26319Sbill while (skip--) { 27319Sbill io->i_cc = -1; 283262Swnj while (htstrategy(io, HT_SFORW)) 29319Sbill ; 303262Swnj DELAY(65536); 313262Swnj htstrategy(io, HT_SENSE); 32319Sbill } 33319Sbill } 34319Sbill 35319Sbill htclose(io) 363262Swnj register struct iob *io; 37319Sbill { 383262Swnj 393262Swnj htstrategy(io, HT_REW); 40319Sbill } 41319Sbill 42319Sbill htstrategy(io, func) 433262Swnj register struct iob *io; 443262Swnj int func; 45319Sbill { 463262Swnj register int den, errcnt, ds; 47319Sbill short fc; 483262Swnj register struct htdevice *htaddr = 493262Swnj (struct htdevice *)mbadrv(io->i_unit); 50319Sbill 51319Sbill errcnt = 0; 52319Sbill retry: 533262Swnj den = HTTC_1600BPI|HTTC_PDP11; 543262Swnj htquiet(htaddr); 553262Swnj htaddr->httc = den; 563262Swnj htaddr->htfc = -io->i_cc; 573262Swnj if (func == HT_SREV) { 583262Swnj htaddr->htfc = -1; 593262Swnj htaddr->htcs1 = HT_SREV|HT_GO; 603262Swnj return (0); 61319Sbill } 62*3274Swnj if (func == READ || func == WRITE) 633262Swnj mbastart(io, func); 64319Sbill else 653262Swnj htaddr->htcs1 = func|HT_GO; 663262Swnj htquiet(htaddr); 673262Swnj ds = htaddr->htds; 683262Swnj if (ds & HTDS_TM) { 693262Swnj htaddr->htcs1 = HT_DCLR|HT_GO; 703262Swnj return (0); 71319Sbill } 723262Swnj if (ds & HTDS_ERR) { 73319Sbill if (errcnt == 0) 743262Swnj printf("tape error: ds=%x, er=%x", 753262Swnj htaddr->htds, htaddr->hter); 763262Swnj htaddr->htcs1 = HT_DCLR|HT_GO; 77319Sbill if (errcnt == 10) { 78319Sbill printf("\n"); 793262Swnj return (-1); 80319Sbill } 81319Sbill errcnt++; 823262Swnj htstrategy(io, HT_SREV); 83319Sbill goto retry; 84319Sbill } 85319Sbill if (errcnt) 86319Sbill printf(" recovered by retry\n"); 873262Swnj fc = htaddr->htfc; 883262Swnj return (io->i_cc+fc); 89319Sbill } 90319Sbill 913262Swnj htquiet(htaddr) 923262Swnj register struct htdevice *htaddr; 93319Sbill { 94319Sbill register int s; 95319Sbill 96319Sbill do 973262Swnj s = htaddr->htds; 983262Swnj while ((s & HTDS_DRY) == 0); 99319Sbill } 100