1: /*
   2:  *	SCCS id	@(#)rf.c	2.1 (Berkeley)	8/5/83
   3:  */
   4: 
   5: #include "rf.h"
   6: #if NRF > 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/rfreg.h>
  14: 
  15: #define NRFBLK  1024
  16: 
  17: struct  rfdevice *RFADDR;
  18: 
  19: struct  buf rftab;
  20: struct  buf rrfbuf;
  21: 
  22: rfattach(addr, unit)
  23: struct rfdevice *addr;
  24: {
  25:     if (unit != 0)
  26:         return(0);
  27:     RFADDR = addr;
  28:     return(1);
  29: }
  30: 
  31: rfstrategy(bp)
  32: register struct buf *bp;
  33: {
  34:     if (RFADDR == (struct rfdevice * NULL)) {
  35:         bp->b_error = ENXIO;
  36:         goto errexit;
  37:     }
  38:     if (bp->b_blkno >= NRFBLK * (minor(bp->b_dev) + 1)) {
  39:         bp->b_error = EINVAL;
  40: errexit:
  41:         bp->b_flags |= B_ERROR;
  42:         iodone(bp);
  43:         return;
  44:     }
  45: #ifdef  UNIBUS_MAP
  46:     mapalloc(bp);
  47: #endif
  48:     bp->av_forw = (struct buf *) NULL;
  49:     (void) _spl5();
  50:     if (rftab.b_actf == NULL)
  51:         rftab.b_actf = bp;
  52:     else
  53:         rftab.b_actl->av_forw = bp;
  54:     rftab.b_actl = bp;
  55:     if (rftab.b_active == NULL)
  56:         rfstart();
  57:     (void) _spl0();
  58: }
  59: 
  60: rfstart()
  61: {
  62:     register struct rfdevice *rfaddr = RFADDR;
  63:     register struct buf *bp;
  64:     register com;
  65: 
  66:     if ((bp = rftab.b_actf) == (struct buf *) NULL)
  67:         return;
  68:     rftab.b_active++;
  69:     rfaddr->rfdar = (short) (bp->b_blkno << 8) & 0177777;
  70:     rfaddr->rfdae = (short) (bp->b_blkno >> 8) & 037;
  71:     rfaddr->rfcma = bp->b_un.b_addr;
  72:     rfaddr->rfwc = - (bp->b_bcount >> 1);
  73:     com = (bp->b_xmem & 3) << 4;
  74:     if (bp->b_flags & B_READ)
  75:         com |= RF_RCOM | RF_IENABLE | RF_GO;
  76:     else
  77:         com |= RF_WCOM | RF_IENABLE | RF_GO;
  78:     rfaddr->rfdcs = com;
  79: 
  80: #ifdef  RF_DKN
  81:     dk_busy |= 1 << RF_DKN;
  82:     dk_numb[RF_DKN]++;
  83:     dk_wds[RF_DKN] += (bp->b_bcount) >> 6;
  84: #endif
  85: }
  86: 
  87: rfintr()
  88: {
  89:     register struct rfdevice *rfaddr = RFADDR;
  90:     register struct buf *bp;
  91: 
  92:     if (rftab.b_active == (struct buf *) NULL)
  93:         return;
  94: #ifdef  RF_DKN
  95:     dk_busy &= ~ (1 << RF_DKN);
  96: #endif
  97:     bp = rftab.b_actf;
  98:     rftab.b_active = (struct buf *) NULL;
  99:     if (rfaddr->rfdcs & RF_ERR) {
 100:         while ((rfaddr->rfdcs & RF_RDY) == 0)
 101:             ;
 102:         if (rfaddr->rfdcs & RF_WLO)
 103:             /*
 104: 			 *	Give up on write locked devices
 105: 			 *	immediately.
 106: 			 */
 107:             printf("rf%d: write locked\n", minor(bp->b_dev));
 108:         else
 109:             {
 110: #ifdef  UCB_DEVERR
 111:             harderr(bp, "rf");
 112:             printf("cs=%b dae=%b\n", rfaddr->rfdcs,
 113:                 RF_BITS, rfaddr->rfdae, RFDAE_BITS);
 114: #else
 115:             deverror(bp, rfaddr->rfdcs, rfaddr->rfdae);
 116: #endif
 117:             rfaddr->rfdcs = RF_CTLCLR;
 118:             if (++rftab.b_errcnt <= 10) {
 119:                 rfstart();
 120:                 return;
 121:             }
 122:         }
 123:         bp->b_flags |= B_ERROR;
 124:     }
 125:     rftab.b_errcnt = 0;
 126:     rftab.b_actf = bp->av_forw;
 127:     bp->b_resid = -(rfaddr->rfwc << 1);
 128:     iodone(bp);
 129:     rfstart();
 130: }
 131: 
 132: rfread(dev)
 133: dev_t   dev;
 134: {
 135:     physio(rfstrategy, &rrfbuf, dev, B_READ);
 136: }
 137: 
 138: rfwrite(dev)
 139: dev_t   dev;
 140: {
 141:     physio(rfstrategy, &rrfbuf, dev, B_WRITE);
 142: }
 143: #endif	NRF

Defined functions

rfattach defined in line 22; never used
rfintr defined in line 87; never used
rfread defined in line 132; never used
rfstart defined in line 60; used 3 times
rfstrategy defined in line 31; used 2 times
rfwrite defined in line 138; never used

Defined variables

RFADDR defined in line 17; used 4 times
rftab defined in line 19; used 13 times
rrfbuf defined in line 20; used 2 times

Defined macros

NRFBLK defined in line 15; used 1 times
  • in line 38
Last modified: 1983-08-06
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 869
Valid CSS Valid XHTML 1.0 Strict