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