1: /*
   2:  *	SCCS id	@(#)rk.c	2.1 (Berkeley)	9/1/83
   3:  */
   4: 
   5: #include "rk.h"
   6: #if NRK > 0
   7: #include "param.h"
   8: #include <sys/systm.h>
   9: #include <sys/buf.h>
  10: #include <sys/conf.h>
  11: #include <sys/dir.h>
  12: #include <sys/user.h>
  13: #include <sys/rkreg.h>
  14: 
  15: #define NRKBLK  4872    /* Number of blocks per drive */
  16: 
  17: struct  rkdevice *RKADDR;
  18: 
  19: struct  buf rktab;
  20: #ifdef  UCB_DBUFS
  21: struct  buf rrkbuf[NRK];
  22: #else
  23: struct  buf rrkbuf;
  24: #endif
  25: 
  26: rkattach(addr, unit)
  27: struct rkdevice *addr;
  28: {
  29:     if (unit != 0)
  30:         return(0);
  31:     RKADDR = addr;
  32:     return(1);
  33: }
  34: 
  35: rkstrategy(bp)
  36: register struct buf *bp;
  37: {
  38:     register s;
  39: 
  40:     if (RKADDR == (struct rkdevice *) NULL) {
  41:         bp->b_error = ENXIO;
  42:         goto errexit;
  43:     }
  44:     if (bp->b_blkno >= NRKBLK) {
  45:         bp->b_error = EINVAL;
  46: errexit:
  47:         bp->b_flags |= B_ERROR;
  48:         iodone(bp);
  49:         return;
  50:     }
  51: #ifdef UNIBUS_MAP
  52:     mapalloc(bp);
  53: #endif
  54:     bp->av_forw = (struct buf *)NULL;
  55:     s = spl5();
  56:     if(rktab.b_actf == NULL)
  57:         rktab.b_actf = bp;
  58:     else
  59:         rktab.b_actl->av_forw = bp;
  60:     rktab.b_actl = bp;
  61:     if(rktab.b_active == NULL)
  62:         rkstart();
  63:     splx(s);
  64: }
  65: 
  66: rkstart()
  67: {
  68:     register struct rkdevice *rkaddr = RKADDR;
  69:     register struct buf *bp;
  70:     register com;
  71:     daddr_t bn;
  72:     int dn, cn, sn;
  73: 
  74:     if ((bp = rktab.b_actf) == NULL)
  75:         return;
  76:     rktab.b_active++;
  77:     bn = bp->b_blkno;
  78:     dn = minor(bp->b_dev);
  79:     cn = bn / 12;
  80:     sn = bn % 12;
  81:     rkaddr->rkda = (dn << 13) | (cn << 4) | sn;
  82:     rkaddr->rkba = bp->b_un.b_addr;
  83:     rkaddr->rkwc = -(bp->b_bcount >> 1);
  84:     com = ((bp->b_xmem & 3) << 4) | RKCS_IDE | RKCS_GO;
  85:     if(bp->b_flags & B_READ)
  86:         com |= RKCS_RCOM;
  87:     else
  88:         com |= RKCS_WCOM;
  89:     rkaddr->rkcs = com;
  90: 
  91: #ifdef  RK_DKN
  92:     dk_busy |= 1 << RK_DKN;
  93:     dk_numb[RK_DKN]++;
  94:     dk_wds[RK_DKN] += bp->b_bcount >> 6;
  95: #endif	RK_DKN
  96: }
  97: 
  98: rkintr()
  99: {
 100:     register struct rkdevice *rkaddr = RKADDR;
 101:     register struct buf *bp;
 102: 
 103:     if (rktab.b_active == NULL)
 104:         return;
 105: #ifdef  RK_DKN
 106:     dk_busy &= ~(1 << RK_DKN);
 107: #endif	RK_DKN
 108:     bp = rktab.b_actf;
 109:     rktab.b_active = NULL;
 110:     if (rkaddr->rkcs & RKCS_ERR) {
 111:         while ((rkaddr->rkcs & RKCS_RDY) == 0)
 112:             ;
 113:         if (rkaddr->rker & RKER_WLO)
 114:             /*
 115: 			 *	Give up on write locked devices
 116: 			 *	immediately.
 117: 			 */
 118:             printf("rk%d: write locked\n", minor(bp->b_dev));
 119:         else
 120:             {
 121: #ifdef  UCB_DEVERR
 122:             harderr(bp, "rk");
 123:             printf("er=%b ds=%b\n", rkaddr->rker, RKER_BITS,
 124:                 rkaddr->rkds, RK_BITS);
 125: #else
 126:             deverror(bp, rkaddr->rker, rkaddr->rkds);
 127: #endif
 128:             rkaddr->rkcs = RKCS_RESET | RKCS_GO;
 129:             while((rkaddr->rkcs & RKCS_RDY) == 0)
 130:                 ;
 131:             if (++rktab.b_errcnt <= 10) {
 132:                 rkstart();
 133:                 return;
 134:             }
 135:         }
 136:         bp->b_flags |= B_ERROR;
 137:     }
 138:     rktab.b_errcnt = 0;
 139:     rktab.b_actf = bp->av_forw;
 140:     bp->b_resid = -(rkaddr->rkwc << 1);
 141:     iodone(bp);
 142:     rkstart();
 143: }
 144: 
 145: rkread(dev)
 146: dev_t   dev;
 147: {
 148: #ifdef  UCB_DBUFS
 149:     register int unit = (minor(dev) >> 3) & 07;
 150: 
 151:     if (unit >= NRK)
 152:         u.u_error = ENXIO;
 153:     else
 154:         physio(rkstrategy, &rrkbuf[unit], dev, B_READ);
 155: #else
 156:     physio(rkstrategy, &rrkbuf, dev, B_READ);
 157: #endif
 158: }
 159: 
 160: rkwrite(dev)
 161: dev_t   dev;
 162: {
 163: #ifdef  UCB_DBUFS
 164:     register int unit = (minor(dev) >> 3) & 07;
 165: 
 166:     if (unit >= NRK)
 167:         u.u_error = ENXIO;
 168:     else
 169:         physio(rkstrategy, &rrkbuf[unit], dev, B_WRITE);
 170: #else
 171:     physio(rkstrategy, &rrkbuf, dev, B_WRITE);
 172: #endif
 173: }
 174: #endif	NRK

Defined functions

rkattach defined in line 26; never used
rkintr defined in line 98; used 4 times
rkread defined in line 145; never used
rkstart defined in line 66; used 3 times
rkstrategy defined in line 35; used 4 times
rkwrite defined in line 160; never used

Defined variables

RKADDR defined in line 17; used 4 times
rktab defined in line 19; used 15 times
rrkbuf defined in line 23; used 4 times

Defined macros

NRKBLK defined in line 15; used 1 times
  • in line 44
Last modified: 1983-09-02
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 968
Valid CSS Valid XHTML 1.0 Strict