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:  *	@(#)ts.c	2.3 (2.11BSD) 1996/3/8
   7:  */
   8: 
   9: /*
  10:  *	Stand-alone TS11/TU80/TS05/TK25 magtape driver.
  11:  */
  12: 
  13: #include "../h/param.h"
  14: #include "../pdpuba/tsreg.h"
  15: #include "saio.h"
  16: 
  17: extern int tapemark;    /* flag to indicate tapemark encountered
  18: 			   (see sys.c as to how its used) */
  19: 
  20: #define NTS 2
  21: 
  22:     struct  tsdevice *TScsr[NTS + 1] =
  23:         {
  24:         (struct tsdevice *)0172520,
  25:         (struct tsdevice *)0,
  26:         (struct tsdevice *)-1
  27:         };
  28: 
  29: caddr_t tsptr[NTS];
  30: struct  ts_char chrbuf[NTS];        /* characteristics buffer */
  31: struct  ts_sts  mesbuf[NTS];        /* message buffer */
  32: struct  ts_cmd  *combuf[NTS];       /* command packet buffer */
  33: char    softspace[(NTS * sizeof(struct ts_cmd)) + 3];
  34: 
  35:     /* bit definitions for Command mode field during read command */
  36: #define TS_RPREV    0400    /* read previous (reverse) */
  37: 
  38: tsopen(io)
  39:     register struct iob *io;
  40: {
  41:     int skip, bae, lo16;
  42:     register struct tsdevice *tsaddr;
  43:     register struct ts_char *chrb;
  44:     struct ts_cmd *cmb;
  45:     int ctlr = io->i_ctlr;
  46:     char *cp;
  47: 
  48:     if (genopen(NTS, io) < 0)
  49:         return(-1);
  50:     io->i_flgs |= F_TAPE;
  51:     tsaddr = TScsr[ctlr];
  52: 
  53:     /* combuf must be aligned on a mod 4 byte boundary */
  54:     cp = (char *)((u_short)softspace + 3 & ~3);
  55:     cp += (ctlr * sizeof (struct ts_cmd));
  56:     cmb = combuf[ctlr] = (struct ts_cmd *)cp;
  57: 
  58:     iomapadr(cmb, &bae, &lo16);
  59:     tsptr[ctlr] = (caddr_t)(lo16 | bae);
  60:     cmb->c_cmd = (TS_ACK|TS_CVC|TS_INIT);
  61:     tsaddr->tsdb = (u_short) tsptr[ctlr];
  62:     while ((tsaddr->tssr & TS_SSR) == 0)
  63:         continue;
  64: 
  65:     chrb = &chrbuf[ctlr];
  66:     iomapadr(&mesbuf, &bae, &lo16);
  67:     chrb->char_bptr = lo16;
  68:     chrb->char_bae = bae;
  69:     chrb->char_size = 016;
  70:     chrb->char_mode = 0;
  71: 
  72:     cmb->c_cmd = (TS_ACK|TS_CVC|TS_SETCHR);
  73:     iomapadr(&chrbuf, &bae, &lo16);
  74:     cmb->c_loba = lo16;
  75:     cmb->c_hiba = bae;
  76:     cmb->c_size = 010;
  77:     tsaddr->tsdb = (u_short) tsptr[ctlr];
  78:     while ((tsaddr->tssr & TS_SSR) == 0)
  79:         continue;
  80: 
  81:     tsstrategy(io, TS_REW);
  82:     skip = io->i_part;
  83:     while (skip--) {
  84:         io->i_cc = 0;
  85:         while (tsstrategy(io, TS_SFORWF))
  86:             continue;
  87:     }
  88:     return(0);
  89: }
  90: 
  91: tsclose(io)
  92:     struct iob *io;
  93: {
  94:     tsstrategy(io, TS_REW);
  95: }
  96: 
  97: tsstrategy(io, func)
  98:     register struct iob *io;
  99: {
 100:     register int ctlr = io->i_ctlr;
 101:     int errcnt, unit = io->i_unit, bae, lo16;
 102:     register struct tsdevice *tsaddr = TScsr[ctlr];
 103: 
 104:     errcnt = 0;
 105:     iomapadr(io->i_ma, &bae, &lo16);
 106:     combuf[ctlr]->c_loba = lo16;
 107:     combuf[ctlr]->c_hiba = bae;
 108:     combuf[ctlr]->c_size = io->i_cc;
 109:     if (func == TS_SFORW || func == TS_SFORWF || func == TS_SREV ||
 110:         func == TS_SREVF)
 111:         combuf[ctlr]->c_repcnt = 1;
 112:     if (func == READ)
 113:         combuf[ctlr]->c_cmd = TS_ACK|TS_RCOM;
 114:     else if (func == WRITE)
 115:         combuf[ctlr]->c_cmd = TS_ACK|TS_WCOM;
 116:     else
 117:         combuf[ctlr]->c_cmd = TS_ACK|func;
 118:     tsaddr->tsdb = (u_short) tsptr[ctlr];
 119: retry:
 120:     while ((tsaddr->tssr & TS_SSR) == 0)
 121:         continue;
 122:     if (mesbuf[ctlr].s_xs0 & TS_TMK) {
 123:         tapemark = 1;
 124:         return(0);
 125:     }
 126:     if (tsaddr->tssr & TS_SC) {
 127:         if (errcnt == 0)
 128:             printf("\n%s err sr=%o xs0=%o xs1=%o xs2=%o xs3=%o",
 129:             devname(io), tsaddr->tssr,
 130:             mesbuf[ctlr].s_xs0, mesbuf[ctlr].s_xs1,
 131:             mesbuf[ctlr].s_xs2, mesbuf[ctlr].s_xs3);
 132:         if (errcnt++ == 10) {
 133:             printf("\n(FATAL ERROR)\n");
 134:             return(-1);
 135:         }
 136:         if (func == READ)
 137:             combuf[ctlr]->c_cmd = (TS_ACK|TS_RPREV|TS_RCOM);
 138:         else if (func == WRITE)
 139:             combuf[ctlr]->c_cmd = (TS_ACK|TS_RETRY|TS_WCOM);
 140:         else {
 141:             putchar('\n');
 142:             return(-1);
 143:         }
 144:         tsaddr->tsdb = (u_short) tsptr[ctlr];
 145:         goto retry;
 146:     }
 147:     return (io->i_cc+mesbuf[ctlr].s_rbpcr);
 148: }
 149: 
 150: tsseek(io, space)
 151:     register struct iob *io;
 152:     int space;
 153:     {
 154:     int fnc;
 155: 
 156:     if  (space < 0)
 157:         {
 158:         fnc = TS_SREV;
 159:         space = -space;
 160:         }
 161:     else
 162:         fnc = TS_SFORW;
 163:     while   (space--)
 164:         {
 165:         io->i_cc = 0;
 166:         tsstrategy(io, fnc);
 167:         }
 168:     return(0);
 169:     }

Defined functions

tsclose defined in line 91; used 2 times
tsopen defined in line 38; used 2 times
tsseek defined in line 150; used 2 times
tsstrategy defined in line 97; used 6 times

Defined variables

TScsr defined in line 22; used 3 times
chrbuf defined in line 30; used 2 times
combuf defined in line 32; used 10 times
mesbuf defined in line 31; used 7 times
softspace defined in line 33; used 1 times
  • in line 54
tsptr defined in line 29; used 5 times

Defined macros

NTS defined in line 20; used 7 times
TS_RPREV defined in line 36; used 1 times
Last modified: 1996-03-09
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 708
Valid CSS Valid XHTML 1.0 Strict