1: /*
   2:  *	standalone TS11 - 1600 bpi tape driver
   3:  */
   4: 
   5: 
   6: #include <sys/param.h>
   7: #include <sys/inode.h>
   8: #include "../saio.h"
   9: 
  10: extern int tapemark;    /* flag to indicate tapemark encountered
  11: 			   (see SYS.c as to how its used) */
  12: 
  13: int cmdpkt[5];      /* command packet. extra location is mod 4 alignment */
  14: 
  15: struct  device
  16: {
  17:     int tsdb;       /* TS data buffer and bus address reg */
  18:     int tssr;       /* TS status register */
  19: };
  20: 
  21: struct  mespkt
  22: {
  23:     int mshdr;      /* message packet header word */
  24:     int mssiz;      /* size of message returned */
  25:     int msresid;    /* remaining count register */
  26:     int mstsx0;     /* extended status reg 0 */
  27:     int mstsx1;     /* extended status reg 1 */
  28:     int mstsx2;     /* extneded status reg 2 */
  29:     int mstsx3;     /* extended status reg 3 */
  30: };
  31: 
  32: struct compkt
  33: {
  34:     int tscom;      /* command packet command word */
  35:     int tsba;       /* memory address */
  36:     int tsbae;      /* extended address */
  37:     int tswc;       /* byte count, record count, etc. */
  38: };
  39: 
  40: struct  chrdat
  41: {
  42:     int msbptr;     /* pointer to message buffer */
  43:     int msbae;      /* hi address (bits 16 & 17) */
  44:     int msbsiz;     /* size of message buffer */
  45:     int mschar;     /* characteristics word */
  46: };
  47: 
  48: int tsptr;
  49: struct  chrdat  chrbuf;     /* characteristics buffer */
  50: struct  mespkt  mesbuf;     /* message buffer */
  51: 
  52: 
  53: 
  54: #define TSADDR  ((struct device *)0172520)
  55: /*	The following 3 lines are necessary to align com buffer on mod 4 */
  56: #define t_temp  (&cmdpkt[1])    /* get address of cmdpkt +2 */
  57: #define t_temp1 (t_temp & 0177776)
  58: #define combuf  ((struct compkt *)t_temp1)
  59: 
  60: 
  61:     /* bit definitions for command word in ts command packet */
  62: 
  63: #define ACK 0100000     /* acknowledge bit */
  64: #define CVC 040000      /* clear volume check */
  65: #define OPP 020000      /* opposite. reverse recovery */
  66: #define SWB 010000      /* swap bytes. for data xfer */
  67:     /* bit definitions for Command mode field during read command */
  68: #define RNEXT   0       /* read next (forward) */
  69: #define RPREV   0400        /* read previous (reverse) */
  70: #define RRPRV   01000       /* reread previous (space rev, read two) */
  71: #define RRNXT   01400       /* reread next (space fwd, read rev) */
  72:     /* bit definitions for Command mode field during write command */
  73: #define WNEXT   0       /* Write data next */
  74: #define WDRTY   01000       /* write data retry , space rev, erase, write data) */
  75:     /* bit definitions for command mode field during position command */
  76: #define SPCFWD  0       /* space records forward */
  77: #define SPCREV  0400        /* space records reverse */
  78: #define SKTPF   01000       /* skip tape marks forward */
  79: #define SKTPR   01400       /* skip tape marks reverse */
  80: #define RWIND   02000       /* rewind */
  81: 
  82:     /* bit definitions for command mode field during format command */
  83: #define WEOF    0       /* write tape mark */
  84: #define ERAS    0400        /* erase */
  85: #define WEOFE   01000       /* write tape mark entry */
  86:     /* bit definitions for command mode field during control command */
  87: #define MBREAL  0       /* message buffer release */
  88: #define REWUNL  0400        /* Rewind and unload */
  89: #define CLEAN   01000       /* clean */
  90:     /* additional definitions */
  91: #define IEI 0200        /* interrupt enable bit */
  92: 
  93:     /* command code definitions */
  94: #define NOP 0
  95: #define RCOM    01      /* read command */
  96: #define WCHAR   04      /* write characteristics */
  97: #define WCOM    05      /* write */
  98: #define WSUSM   06      /* write subsystem memory */
  99: #define POSIT   010     /* position command */
 100: #define FORMT   011     /* Format command */
 101: #define CONTRL  012     /* Control command */
 102: #define INIT    013     /* initialize */
 103: #define GSTAT   017     /* get status immediate */
 104: 
 105: 
 106:     /* definition of tssr bits */
 107: #define SC  0100000     /* special condition */
 108: #define UPE 040000      /* unibus parity error */
 109: #define SPE 020000      /* Serial bus parity error */
 110: #define RMR 010000      /* register modify refused */
 111: #define NXM 04000       /* non-existent memory */
 112: #define NBA 02000       /* Need Buffer address */
 113: #define SSR 0200        /* Sub-System ready */
 114: #define OFL 0100        /* off-line */
 115: 
 116:     /* fatal termination class codes */
 117: #define FTC 030     /* use this as a mask to get codes */
 118:     /* code = 00	see error code byte in tsx3 */
 119:     /* code = 01	I/O seq Crom or main Crom parity error */
 120:     /* code = 10	u-processor Crom parity error,I/O silo parity */
 121:     /*		serial bus parity, or other fatal */
 122:     /* code = 11	A/C low. drive ac low */
 123: 
 124:     /* termination class codes */
 125: #define TCC 016     /* mask for termination class codes */
 126:     /* code = 000	normal termination */
 127:     /* code = 001	Attention condition
 128: 	/* code = 010	Tape status alert
 129: 	/* code = 011	Function reject
 130: 	/* code = 100	Recoverable error - tape pos = 1 record down from
 131: 			start of function
 132: 	/* code = 101	Recoverable error - tape has not moved
 133: 	/* code = 110	Unrecoverable error - tape position lost
 134: 	/* code = 111	Fatal controller error - see fatal class bits */
 135: 
 136:     /* definition of message buffer header word */
 137: #define MAKC    0100000     /* acknowledge from controller */
 138: #define MCCF    07400       /* mask for class code field */
 139:     /* class codes are */
 140:     /*	0 = ATTN, on or ofline
 141: 		1 = ATTN, microdiagnostic failure
 142: 		0 = FAIL, serial bus parity error
 143: 		1 = FAIL, WRT LOCK
 144: 		2 = FAIL, interlock or non-executable function
 145: 		3 = FAIL, microdiagnostic error
 146: 	*/
 147: 
 148: #define MMSC    037 /* mask for message code field */
 149:     /* message codes are
 150: 		020	= end
 151: 		021	= FAIL
 152: 		022	= ERROR
 153: 		023	= Attention
 154: 
 155: 	/* definition of extended status reg 0 bits */
 156: #define TMK 0100000     /* Tape mark detected */
 157: #define RLS 040000      /* Record length short */
 158: #define LET 020000      /* Logical end of Tape */
 159: #define RLL 010000      /* Record length long */
 160: #define WLE 04000       /* Write lock error */
 161: #define NEF 02000       /* Non-executable function */
 162: #define ILC 01000       /* Illegal command */
 163: #define ILA 0400        /* Illegal address */
 164: #define MOT 0200        /* Capistan is moving */
 165: #define ONL 0100        /* On Line */
 166: #define IE  040     /* state of interrupt enable bit */
 167: #define VCK 020     /* Volume Check */
 168: #define PED 010     /* Phase encoded drive */
 169: #define WLK 04      /* Write locked */
 170: #define BOT 02      /* Tape at bot */
 171: #define EOT 01      /* Tape at eot */
 172: 
 173:     /* definitions of xstat1 */
 174: #define DLT 0100000     /* Data late error */
 175: #define COR 020000      /* Correctable data error */
 176: #define CRS 010000  /* Crease detected */
 177: #define TIG 04000       /* Trash in the gap */
 178: #define DBF 02000       /* Deskew Buffer Fail */
 179: #define SCK 01000       /* Speed check */
 180: #define IPR 0200        /* Invalid preamble */
 181: #define SYN 0100        /* Synch Failure */
 182: #define IPO 040     /* invalid postamble */
 183: #define IED 020     /* invalid end data */
 184: #define POS 010     /* postamble short */
 185: #define POL 04      /* postamble long */
 186: #define UNC 02      /* Uncorrectable data error */
 187: #define MTE 01      /* multi track error */
 188: 
 189:     /* Definitions of XSTAT2 bits */
 190: #define OPM 0100000     /* operation in progress (tape moving) */
 191: #define SIP 040000      /* Silo Parity error */
 192: #define BPE 020000      /* Serial bus Parity error at drive */
 193: #define CAF 010000      /* Capstan Acceleration fail */
 194: #define WCF 02000       /* Write card error */
 195: #define DTP 0477        /* mask for Dead track bits */
 196: 
 197:     /*	bit definitions for XSTAT3 */
 198: #define LMX 0200        /* Limit exceeded (tension arms) */
 199: #define OPI 0100        /* operation incomplete */
 200: #define REV 040     /* current operation in reverse */
 201: #define CRF 020     /* capstan response fail */
 202: #define DCK 010     /* density check */
 203: #define NOI 04      /* no tape mark or preamble */
 204: #define LXS 02      /* limit exceeded manual recovery */
 205: #define RIB 01      /* Reverse into BOT */
 206: 
 207: 
 208: #define SIO 01
 209: #define SSEEK   02
 210: #define SINIT   04
 211: #define SRETRY  010
 212: #define SCOM    020
 213: #define SOK 040
 214: #define SMAST   0100
 215: 
 216: #define S_WRITTEN   1
 217: 
 218: tsopen(io)
 219: register struct iob *io;
 220: {
 221:     register skip;
 222: 
 223:     tsptr = &combuf->tscom;
 224:     tsptr |= segflag;
 225:     combuf->tscom = (ACK|CVC|INIT);
 226:     TSADDR->tsdb = tsptr;
 227:     while ((TSADDR->tssr & SSR) == 0);
 228:     chrbuf.msbptr = &mesbuf;
 229:     chrbuf.msbae = segflag;
 230:     chrbuf.msbsiz = 016;
 231:     chrbuf.mschar = 0;
 232:     combuf->tscom = (ACK|CVC|WCHAR);
 233:     combuf->tsba = &chrbuf;
 234:     combuf->tsbae = segflag;
 235:     combuf->tswc = 010;
 236:     TSADDR->tsdb = tsptr;
 237:     while ((TSADDR->tssr & SSR) == 0);
 238:     tsstrategy(io,(RWIND|POSIT));
 239:     skip = io->i_boff;
 240:     while (skip--)
 241:     {
 242:         io->i_cc = 1;
 243:         while (tsstrategy(io, (SPCFWD|POSIT)));
 244:     }
 245: }
 246: tsclose(io)
 247: register struct iob *io;
 248: {
 249:     tsstrategy(io,(RWIND|POSIT));
 250: }
 251: tsstrategy(io, func)
 252: register struct iob *io;
 253: {
 254:     register unit, errcnt;
 255: 
 256:     unit = io->i_unit;
 257:     errcnt = 0;
 258:     combuf->tsba = io->i_ma;
 259:     combuf->tsbae = segflag;
 260:     combuf->tswc = io->i_cc;
 261:     if (func == READ)
 262:         combuf->tscom = ACK|RNEXT|RCOM;
 263:     else if (func == WRITE)
 264:         combuf->tscom = ACK|WNEXT|WCOM;
 265:     else if (func == SPCREV)
 266:     {
 267:         combuf->tscom = ACK|SPCREV|POSIT;
 268:         combuf->tswc = 1;
 269:     }
 270:     else
 271:         combuf->tscom = ACK|func;
 272:     TSADDR->tsdb = tsptr;
 273: retry:
 274:     while ((TSADDR->tssr & SSR) == 0);
 275:     if (mesbuf.mstsx0 & TMK)
 276:     {
 277:         tapemark = 1;
 278:         return(0);
 279:     }
 280:     if ((mesbuf.mshdr & MMSC) == 021 || (mesbuf.mshdr & MMSC) == 022)
 281:     {
 282:         if(errcnt == 0)
 283:             printf("tape error: er=%o",mesbuf.mstsx0);
 284:         if(errcnt == 10)
 285:         {
 286:             printf("\n");
 287:             return(-1);
 288:         }
 289:         errcnt++;
 290:         if(func == READ)
 291:             combuf->tscom = (ACK|RPREV|RCOM);
 292:         else if (func == WRITE)
 293:             combuf->tscom = (ACK|WDRTY|WCOM);
 294:         else
 295:         {
 296:             printf("\n");
 297:             return(-1);
 298:         }
 299:         TSADDR->tsdb = tsptr;
 300:         goto retry;
 301:     }
 302:     if(errcnt)
 303:         printf(" recovered by retry\n");
 304:     return (io->i_cc+mesbuf.msresid);
 305: }

Defined functions

tsclose defined in line 246; used 2 times
tsopen defined in line 218; used 2 times
tsstrategy defined in line 251; used 5 times

Defined variables

chrbuf defined in line 49; used 5 times
cmdpkt defined in line 13; used 1 times
  • in line 56
mesbuf defined in line 50; used 6 times
tsptr defined in line 48; used 6 times

Defined struct's

chrdat defined in line 40; used 2 times
  • in line 49(2)
compkt defined in line 32; never used
device defined in line 15; never used
mespkt defined in line 21; used 2 times
  • in line 50(2)

Defined macros

ACK defined in line 63; used 8 times
BOT defined in line 170; never used
BPE defined in line 192; never used
CAF defined in line 193; never used
CLEAN defined in line 89; never used
CONTRL defined in line 101; never used
COR defined in line 175; never used
CRF defined in line 201; never used
CRS defined in line 176; never used
CVC defined in line 64; used 2 times
DBF defined in line 178; never used
DCK defined in line 202; never used
DLT defined in line 174; never used
DTP defined in line 195; never used
EOT defined in line 171; never used
ERAS defined in line 84; never used
FORMT defined in line 100; never used
FTC defined in line 117; never used
GSTAT defined in line 103; never used
IE defined in line 166; never used
IED defined in line 183; never used
IEI defined in line 91; never used
ILA defined in line 163; never used
ILC defined in line 162; never used
INIT defined in line 102; used 1 times
IPO defined in line 182; never used
IPR defined in line 180; never used
LET defined in line 158; never used
LMX defined in line 198; never used
LXS defined in line 204; never used
MAKC defined in line 137; never used
MBREAL defined in line 87; never used
MCCF defined in line 138; never used
MMSC defined in line 148; used 2 times
  • in line 280(2)
MOT defined in line 164; never used
MTE defined in line 187; never used
NBA defined in line 112; never used
NEF defined in line 161; never used
NOI defined in line 203; never used
NOP defined in line 94; never used
NXM defined in line 111; never used
OFL defined in line 114; never used
ONL defined in line 165; never used
OPI defined in line 199; never used
OPM defined in line 190; never used
OPP defined in line 65; never used
PED defined in line 168; never used
POL defined in line 185; never used
POS defined in line 184; never used
POSIT defined in line 99; used 4 times
RCOM defined in line 95; used 2 times
REV defined in line 200; never used
REWUNL defined in line 88; never used
RIB defined in line 205; never used
RLL defined in line 159; never used
RLS defined in line 157; never used
RMR defined in line 110; never used
RNEXT defined in line 68; used 1 times
RPREV defined in line 69; used 1 times
RRNXT defined in line 71; never used
RRPRV defined in line 70; never used
RWIND defined in line 80; used 2 times
SC defined in line 107; never used
SCK defined in line 179; never used
SCOM defined in line 212; never used
SINIT defined in line 210; never used
SIO defined in line 208; never used
SIP defined in line 191; never used
SKTPF defined in line 78; never used
SKTPR defined in line 79; never used
SMAST defined in line 214; never used
SOK defined in line 213; never used
SPCFWD defined in line 76; used 1 times
SPCREV defined in line 77; used 2 times
SPE defined in line 109; never used
SRETRY defined in line 211; never used
SSEEK defined in line 209; never used
SSR defined in line 113; used 3 times
SWB defined in line 66; never used
SYN defined in line 181; never used
S_WRITTEN defined in line 216; never used
TCC defined in line 125; never used
TIG defined in line 177; never used
TMK defined in line 156; used 1 times
TSADDR defined in line 54; used 7 times
UNC defined in line 186; never used
UPE defined in line 108; never used
VCK defined in line 167; never used
WCF defined in line 194; never used
WCHAR defined in line 96; used 1 times
WCOM defined in line 97; used 2 times
WDRTY defined in line 74; used 1 times
WEOF defined in line 83; never used
WEOFE defined in line 85; never used
WLE defined in line 160; never used
WLK defined in line 169; never used
WNEXT defined in line 73; used 1 times
WSUSM defined in line 98; never used
combuf defined in line 58; used 16 times
t_temp defined in line 56; used 1 times
  • in line 57
t_temp1 defined in line 57; used 1 times
  • in line 58
Last modified: 1982-11-21
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1768
Valid CSS Valid XHTML 1.0 Strict