1: /*
   2:  * Copyright (c) 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	2.4 (2.11BSD) 1997/1/20
   7:  */
   8: 
   9: /*
  10:  * TM02/3 - TU16/TE16/TU77 standalone tape driver
  11:  */
  12: 
  13: #include "../h/param.h"
  14: #include "../pdpuba/htreg.h"
  15: #include "saio.h"
  16: 
  17: #define NHT     2
  18: #define H_NOREWIND  004     /* not used in stand alone driver */
  19: #define H_1600BPI   010
  20: 
  21:     struct  htdevice *HTcsr[NHT + 1] =
  22:         {
  23:         (struct htdevice *)0172440,
  24:         (struct htdevice *)0,
  25:         (struct htdevice *)-1
  26:         };
  27: extern int tapemark;    /* flag to indicate tapemark encountered
  28: 			   (see sys.c as to how it's used) */
  29: 
  30: htopen(io)
  31:     register struct iob *io;
  32: {
  33:     register skip;
  34:     register int ctlr = io->i_ctlr;
  35: 
  36:     if (genopen(NHT, io) < 0)
  37:         return(-1);
  38:     io->i_flgs |= F_TAPE;
  39:     htstrategy(io, HT_REW);
  40:     skip = io->i_part;
  41:     while (skip--) {
  42:         io->i_cc = 0;
  43:         while (htstrategy(io, HT_SFORW))
  44:             continue;
  45:         delay(30000);
  46:         htstrategy(io, HT_SENSE);
  47:     }
  48:     return(0);
  49: }
  50: 
  51: htclose(io)
  52:     struct iob *io;
  53: {
  54:     htstrategy(io, HT_REW);
  55: }
  56: 
  57: /*
  58:  * Copy the space logic from the open routine but add the check for spacing
  59:  * backwards.
  60: */
  61: 
  62: htseek(io, space)
  63:     struct  iob *io;
  64:     register int    space;
  65:     {
  66:     register int    fnc;
  67: 
  68:     if  (space < 0)
  69:         {
  70:         space = -space;
  71:         fnc = HT_SREV;
  72:         }
  73:     else
  74:         fnc = HT_SFORW;
  75:     io->i_cc = space;
  76:     htstrategy(io, fnc);
  77:     delay(30000);
  78:     htstrategy(io, HT_SENSE);
  79:     }
  80: 
  81: /*
  82:  * Returns 0 (and sets 'tapemark') if tape mark was seen.  Returns -1 on fatal
  83:  * error.  Otherwise the length of data tranferred is returned.
  84: */
  85: 
  86: htstrategy(io, func)
  87:     register struct iob *io;
  88: {
  89:     int unit, com;
  90:     int errcnt, ctlr, bae, lo16, fnc;
  91:     register struct htdevice *htaddr;
  92: 
  93:     unit = io->i_unit;
  94:     ctlr = io->i_ctlr;
  95:     htaddr = HTcsr[ctlr];
  96:     errcnt = 0;
  97: retry:
  98:     while ((htaddr->htcs1 & HT_RDY) == 0)
  99:         continue;
 100:     while (htaddr->htfs & HTFS_PIP)
 101:         continue;
 102: 
 103:     iomapadr(io->i_ma, &bae, &lo16);
 104:     htaddr->httc =
 105:         ((io->i_unit&H_1600BPI) ? HTTC_1600BPI : HTTC_800BPI)
 106:         | HTTC_PDP11 | unit;
 107:     htaddr->htba = (caddr_t) lo16;
 108:     htaddr->htfc = -io->i_cc;
 109:     htaddr->htwc = -(io->i_cc >> 1);
 110:     com = (bae << 8) | HT_GO;
 111:     switch  (func)
 112:         {
 113:         case    READ:
 114:             fnc = HT_RCOM;
 115:             break;
 116:         case    WRITE:
 117:             fnc = HT_WCOM;
 118:             break;
 119:         default:
 120:             fnc = func;
 121:             break;
 122:         }
 123:     com |= fnc;
 124:     htaddr->htcs1 = com;
 125:     while ((htaddr->htcs1 & HT_RDY) == 0)
 126:         continue;
 127:     if (htaddr->htfs & HTFS_TM) {
 128:         tapemark = 1;
 129:         htinit(htaddr);
 130:         return(0);
 131:     }
 132:     if (htaddr->htcs1 & HT_TRE) {
 133:         if (errcnt == 0)
 134:             printf("\n%s err: cs2=%o, er=%o",
 135:                 devname(io), htaddr->htcs2, htaddr->hter);
 136:         htinit(htaddr);
 137:         if (errcnt++ == 10) {
 138:             printf("\n(FATAL ERROR)\n");
 139:             return(-1);
 140:         }
 141:         htstrategy(io, HT_SREV);
 142:         goto retry;
 143:     }
 144:     return(io->i_cc+htaddr->htfc);
 145: }
 146: 
 147: htinit(htaddr)
 148:     register struct htdevice *htaddr;
 149: {
 150:     register int omt, ocs2;
 151: 
 152:     omt = htaddr->httc & 03777;
 153:     ocs2 = htaddr->htcs2 & 07;
 154: 
 155:     htaddr->htcs2 = HTCS2_CLR;
 156:     htaddr->htcs2 = ocs2;
 157:     htaddr->httc = omt;
 158:     htaddr->htcs1 = HT_DCLR|HT_GO;
 159: }

Defined functions

htclose defined in line 51; used 2 times
htinit defined in line 147; used 2 times
htopen defined in line 30; used 2 times
htseek defined in line 62; used 2 times
htstrategy defined in line 86; used 9 times

Defined variables

HTcsr defined in line 21; used 2 times

Defined macros

H_1600BPI defined in line 19; used 1 times
H_NOREWIND defined in line 18; never used
NHT defined in line 17; used 2 times
Last modified: 1997-01-21
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3535
Valid CSS Valid XHTML 1.0 Strict