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

Defined functions

htclose defined in line 55; used 2 times
htopen defined in line 29; used 2 times
htquiet defined in line 116; used 2 times
htstrategy defined in line 62; used 7 times

Defined variables

httypes defined in line 24; used 2 times

Defined macros

MASKREG defined in line 27; used 2 times
Last modified: 1986-06-05
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 998
Valid CSS Valid XHTML 1.0 Strict