|
|
1.1 ! root 1: /* ht.c 4.6 81/12/01 */ ! 2: ! 3: /* ! 4: * TM03/TU?? tape driver ! 5: */ ! 6: ! 7: #include "../h/htreg.h" ! 8: #include "../h/param.h" ! 9: #include "../h/inode.h" ! 10: #include "../h/pte.h" ! 11: #include "../h/mbareg.h" ! 12: #include "saio.h" ! 13: #include "savax.h" ! 14: ! 15: short httypes[] = ! 16: { MBDT_TM03, MBDT_TE16, MBDT_TU45, MBDT_TU77, 0 }; ! 17: ! 18: #define MASKREG(reg) ((reg)&0xffff) ! 19: ! 20: htopen(io) ! 21: register struct iob *io; ! 22: { ! 23: register int skip; ! 24: register struct htdevice *htaddr = (struct htdevice *)mbadrv(io->i_unit); ! 25: int i; ! 26: ! 27: for (i = 0; httypes[i]; i++) ! 28: if (httypes[i] == (htaddr->htdt&MBDT_TYPE)) ! 29: goto found; ! 30: _stop("not a tape\n"); ! 31: found: ! 32: mbainit(UNITTOMBA(io->i_unit)); ! 33: htaddr->htcs1 = HT_DCLR|HT_GO; ! 34: htstrategy(io, HT_REW); ! 35: skip = io->i_boff; ! 36: while (skip--) { ! 37: io->i_cc = -1; ! 38: while (htstrategy(io, HT_SFORW)) ! 39: ; ! 40: DELAY(65536); ! 41: htstrategy(io, HT_SENSE); ! 42: } ! 43: } ! 44: ! 45: htclose(io) ! 46: register struct iob *io; ! 47: { ! 48: ! 49: htstrategy(io, HT_REW); ! 50: } ! 51: ! 52: htstrategy(io, func) ! 53: register struct iob *io; ! 54: int func; ! 55: { ! 56: register int den, errcnt, ds; ! 57: int er; ! 58: short fc; ! 59: register struct htdevice *htaddr = ! 60: (struct htdevice *)mbadrv(io->i_unit); ! 61: ! 62: errcnt = 0; ! 63: retry: ! 64: den = HTTC_1600BPI|HTTC_PDP11; ! 65: htquiet(htaddr); ! 66: htaddr->htcs1 = HT_DCLR|HT_GO; ! 67: htaddr->httc = den; ! 68: htaddr->htfc = -io->i_cc; ! 69: if (func == HT_SREV) { ! 70: htaddr->htfc = -1; ! 71: htaddr->htcs1 = HT_SREV|HT_GO; ! 72: return (0); ! 73: } ! 74: if (func == READ || func == WRITE) ! 75: mbastart(io, func); ! 76: else ! 77: htaddr->htcs1 = func|HT_GO; ! 78: htquiet(htaddr); ! 79: ds = htaddr->htds; ! 80: er = htaddr->hter; ! 81: if (ds & HTDS_TM) { ! 82: htaddr->htcs1 = HT_DCLR|HT_GO; ! 83: return (0); ! 84: } ! 85: if (ds & HTDS_ERR) { ! 86: htaddr->htcs1 = HT_DCLR|HT_GO; ! 87: if ((er & HTER_CORCRC) == 0) { ! 88: printf("ht error: ds=%b, er=%b\n", ! 89: MASKREG(ds), HTDS_BITS, ! 90: MASKREG(er), HTER_BITS); ! 91: if (errcnt == 10) { ! 92: printf("ht: unrecovered error\n"); ! 93: return (-1); ! 94: } ! 95: errcnt++; ! 96: htstrategy(io, HT_SREV); ! 97: goto retry; ! 98: } ! 99: } ! 100: if (errcnt) ! 101: printf("ht: recovered by retry\n"); ! 102: fc = htaddr->htfc; ! 103: return (io->i_cc+fc); ! 104: } ! 105: ! 106: htquiet(htaddr) ! 107: register struct htdevice *htaddr; ! 108: { ! 109: register int s; ! 110: ! 111: do ! 112: s = htaddr->htds; ! 113: while ((s & HTDS_DRY) == 0); ! 114: } ! 115: ! 116:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.