1: #
   2: /*
   3:  */
   4: 
   5: /*
   6:  * RK disk driver
   7:  */
   8: 
   9: #include "../param.h"
  10: #include "../buf.h"
  11: #include "../conf.h"
  12: #include "../user.h"
  13: 
  14: #define RKADDR  0177400
  15: #define NRK 4
  16: #define NRKBLK  4872
  17: 
  18: #define RESET   0
  19: #define GO  01
  20: #define DRESET  014
  21: #define IENABLE 0100
  22: #define DRY 0200
  23: #define ARDY    0100
  24: #define WLO 020000
  25: #define CTLRDY  0200
  26: 
  27: struct {
  28:     int rkds;
  29:     int rker;
  30:     int rkcs;
  31:     int rkwc;
  32:     int rkba;
  33:     int rkda;
  34: };
  35: 
  36: struct  devtab  rktab;
  37: struct  buf rrkbuf;
  38: 
  39: rkstrategy(abp)
  40: struct buf *abp;
  41: {
  42:     register struct buf *bp;
  43:     register *qc, *ql;
  44:     int d;
  45: 
  46:     bp = abp;
  47:     if(bp->b_flags&B_PHYS)
  48:         mapalloc(bp);
  49:     d = bp->b_dev.d_minor-7;
  50:     if(d <= 0)
  51:         d = 1;
  52:     if (bp->b_blkno >= NRKBLK*d) {
  53:         bp->b_flags =| B_ERROR;
  54:         iodone(bp);
  55:         return;
  56:     }
  57:     bp->av_forw = 0;
  58:     spl5();
  59:     if (rktab.d_actf==0)
  60:         rktab.d_actf = bp;
  61:     else
  62:         rktab.d_actl->av_forw = bp;
  63:     rktab.d_actl = bp;
  64:     if (rktab.d_active==0)
  65:         rkstart();
  66:     spl0();
  67: }
  68: 
  69: rkaddr(bp)
  70: struct buf *bp;
  71: {
  72:     register struct buf *p;
  73:     register int b;
  74:     int d, m;
  75: 
  76:     p = bp;
  77:     b = p->b_blkno;
  78:     m = p->b_dev.d_minor - 7;
  79:     if(m <= 0)
  80:         d = p->b_dev.d_minor;
  81:     else {
  82:         d = lrem(b, m);
  83:         b = ldiv(b, m);
  84:     }
  85:     return(d<<13 | (b/12)<<4 | b%12);
  86: }
  87: 
  88: rkstart()
  89: {
  90:     register struct buf *bp;
  91: 
  92:     if ((bp = rktab.d_actf) == 0)
  93:         return;
  94:     rktab.d_active++;
  95:     devstart(bp, &RKADDR->rkda, rkaddr(bp), 0);
  96: }
  97: 
  98: rkintr()
  99: {
 100:     register struct buf *bp;
 101: 
 102:     if (rktab.d_active == 0)
 103:         return;
 104:     bp = rktab.d_actf;
 105:     rktab.d_active = 0;
 106:     if (RKADDR->rkcs < 0) {     /* error bit */
 107:         deverror(bp, RKADDR->rker, RKADDR->rkds);
 108:         RKADDR->rkcs = RESET|GO;
 109:         while((RKADDR->rkcs&CTLRDY) == 0) ;
 110:         if (++rktab.d_errcnt <= 10) {
 111:             rkstart();
 112:             return;
 113:         }
 114:         bp->b_flags =| B_ERROR;
 115:     }
 116:     rktab.d_errcnt = 0;
 117:     rktab.d_actf = bp->av_forw;
 118:     iodone(bp);
 119:     rkstart();
 120: }
 121: 
 122: rkread(dev)
 123: {
 124: 
 125:     physio(rkstrategy, &rrkbuf, dev, B_READ);
 126: }
 127: 
 128: rkwrite(dev)
 129: {
 130: 
 131:     physio(rkstrategy, &rrkbuf, dev, B_WRITE);
 132: }

Defined functions

rkaddr defined in line 69; used 1 times
  • in line 95
rkintr defined in line 98; never used
rkread defined in line 122; never used
rkstart defined in line 88; used 3 times
rkstrategy defined in line 39; used 2 times
rkwrite defined in line 128; never used

Defined variables

rktab defined in line 36; used 13 times
rrkbuf defined in line 37; used 2 times

Defined macros

ARDY defined in line 23; never used
CTLRDY defined in line 25; used 1 times
DRESET defined in line 20; never used
DRY defined in line 22; never used
GO defined in line 19; used 1 times
IENABLE defined in line 21; never used
NRK defined in line 15; never used
NRKBLK defined in line 16; used 1 times
  • in line 52
RESET defined in line 18; used 1 times
RKADDR defined in line 14; used 6 times
WLO defined in line 24; never used
Last modified: 1975-07-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 832
Valid CSS Valid XHTML 1.0 Strict