1: #
   2: 
   3: /*
   4:  * TM tape driver
   5:  */
   6: 
   7: #include <sys/param.h>
   8: #include <sys/inode.h>
   9: #include "../saio.h"
  10: 
  11: struct device {
  12:     int tmer;
  13:     int tmcs;
  14:     int tmbc;
  15:     char    *tmba;
  16:     int tmdb;
  17:     int tmrd;
  18: };
  19: 
  20: #define TMADDR ((struct device *)0172520)
  21: 
  22: #define GO  01
  23: #define RCOM    02
  24: #define WCOM    04
  25: #define WEOF    06
  26: #define SFORW   010
  27: #define SREV    012
  28: #define WIRG    014
  29: #define REW 016
  30: #define DENS    060000      /* 9-channel */
  31: #define IENABLE 0100
  32: #define CRDY    0200
  33: #define GAPSD   010000
  34: #define TUR 1
  35: #define SDWN    010
  36: #define HARD    0102200 /* ILC, EOT, NXM */
  37: #define EOF 0040000
  38: 
  39: #define SSEEK   1
  40: #define SIO 2
  41: 
  42: extern int tapemark;    /* flag to indicate tapemark
  43: 			has been encountered (see SYS.c) 	*/
  44: 
  45: 
  46: tmrew(io)
  47: register struct iob *io;
  48: {
  49:     tmstrategy(io, REW);
  50: }
  51: 
  52: tmopen(io)
  53: register struct iob *io;
  54: {
  55:     register skip;
  56: 
  57:     tmstrategy(io, REW);
  58:     skip = io->i_boff;
  59:     while (skip--) {
  60:         io->i_cc = 0;
  61:         while (tmstrategy(io, SFORW))
  62:             ;
  63:     }
  64: }
  65: tmstrategy(io, func)
  66: register struct iob *io;
  67: {
  68:     register int com, unit, errcnt;
  69: 
  70:     unit = io->i_unit;
  71:     errcnt = 0;
  72: retry:
  73:     tmquiet();
  74:     com = (unit<<8)|(segflag<<4)|DENS;
  75:     TMADDR->tmbc = -io->i_cc;
  76:     TMADDR->tmba = io->i_ma;
  77:     if (func == READ)
  78:         TMADDR->tmcs = com | RCOM | GO;
  79:     else if (func == WRITE)
  80:         TMADDR->tmcs = com | WCOM | GO;
  81:     else if (func == SREV) {
  82:         TMADDR->tmbc = -1;
  83:         TMADDR->tmcs = com | SREV | GO;
  84:         return(0);
  85:     } else
  86:         TMADDR->tmcs = com | func | GO;
  87:     while ((TMADDR->tmcs&CRDY) == 0)
  88:         ;
  89:     if (TMADDR->tmer&EOF)
  90:     {
  91:         tapemark=1;
  92:         return(0);
  93:     }
  94:     if (TMADDR->tmer < 0) {
  95:         if (errcnt == 0)
  96:             printf("tape error: er=%o", TMADDR->tmer);
  97:         if (errcnt==10) {
  98:             printf("\n");
  99:             return(-1);
 100:         }
 101:         errcnt++;
 102:         tmstrategy(io, SREV);
 103:         goto retry;
 104:     }
 105:     if (errcnt)
 106:         printf(" recovered by retry\n");
 107:     return( io->i_cc+TMADDR->tmbc );
 108: }
 109: 
 110: tmquiet()
 111: {
 112:     while ((TMADDR->tmcs&CRDY) == 0)
 113:         ;
 114:     while ((TMADDR->tmer&TUR) == 0)
 115:         ;
 116:     while ((TMADDR->tmer&SDWN) != 0)
 117:         ;
 118: }

Defined functions

tmopen defined in line 52; used 2 times
tmquiet defined in line 110; used 1 times
  • in line 73
tmrew defined in line 46; used 2 times
tmstrategy defined in line 65; used 6 times

Defined struct's

device defined in line 11; never used

Defined macros

CRDY defined in line 32; used 2 times
DENS defined in line 30; used 1 times
  • in line 74
EOF defined in line 37; used 1 times
  • in line 89
GAPSD defined in line 33; never used
GO defined in line 22; used 4 times
HARD defined in line 36; never used
IENABLE defined in line 31; never used
RCOM defined in line 23; used 1 times
  • in line 78
REW defined in line 29; used 2 times
SDWN defined in line 35; used 1 times
SFORW defined in line 26; used 1 times
  • in line 61
SIO defined in line 40; never used
SREV defined in line 27; used 3 times
SSEEK defined in line 39; never used
TMADDR defined in line 20; used 15 times
TUR defined in line 34; used 1 times
WCOM defined in line 24; used 1 times
  • in line 80
WEOF defined in line 25; never used
WIRG defined in line 28; never used
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 805
Valid CSS Valid XHTML 1.0 Strict