Research V7 development
[unix-history] / usr / sys / dev / rf.c
CommitLineData
a4a6e3a7
DR
1#
2/*
3 * RF disk driver
4 */
5
6#include "../h/param.h"
7#include "../h/systm.h"
8#include "../h/buf.h"
9#include "../h/conf.h"
10#include "../h/dir.h"
11#include "../h/user.h"
12
13struct device {
14 int rfcs;
15 int rfwc;
16 char *rfba;
17 int rfda;
18 int rfdae;
19};
20
21struct buf rftab;
22struct buf rrfbuf;
23
24#define NRFBLK 1024
25#define RFADDR ((struct device *)0177460)
26
27#define GO 01
28#define RCOM 04
29#define WCOM 02
30#define CTLCLR 0400
31#define IENABLE 0100
32
33/*
34 * Monitoring device number
35 */
36#define DK_N 0
37
38rfstrategy(bp)
39register struct buf *bp;
40{
41 if(bp->b_flags&B_PHYS)
42 mapalloc(bp);
43 if (bp->b_blkno >= NRFBLK*(minor(bp->b_dev)+1)) {
44 bp->b_flags |= B_ERROR;
45 iodone(bp);
46 return;
47 }
48 bp->av_forw = 0;
49 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 spl0();
58}
59
60rfstart()
61{
62 register struct buf *bp;
63 register int com;
64
65 if ((bp = rftab.b_actf) == NULL)
66 return;
67 rftab.b_active++;
68 RFADDR->rfda = (int)(bp->b_blkno<<8)&0177777;
69 RFADDR->rfdae = (int)(bp->b_blkno>>8)&037;
70 RFADDR->rfba = bp->b_un.b_addr;
71 RFADDR->rfwc = -(bp->b_bcount>>1);
72 com = (bp->b_xmem&3) << 4;
73 com |= (bp->b_flags & B_READ) ? RCOM+GO+IENABLE : WCOM+GO+IENABLE;
74 RFADDR->rfcs = com;
75 dk_busy |= 1<<DK_N;
76 dk_numb[DK_N] += 1;
77 com = (-bp->b_bcount>>5) & 03777;
78 dk_wds[DK_N] += com;
79}
80
81rfintr()
82{
83 register struct buf *bp;
84
85 if (rftab.b_active == NULL)
86 return;
87 dk_busy &= ~(1<<DK_N);
88 bp = rftab.b_actf;
89 rftab.b_active = NULL;
90 if (RFADDR->rfcs < 0) { /* error bit */
91 deverror(bp, RFADDR->rfcs, RFADDR->rfdae);
92 RFADDR->rfcs = CTLCLR;
93 if (++rftab.b_errcnt <= 10) {
94 rfstart();
95 return;
96 }
97 bp->b_flags |= B_ERROR;
98 }
99 rftab.b_errcnt = 0;
100 rftab.b_actf = bp->av_forw;
101 bp->b_resid = 0;
102 iodone(bp);
103 rfstart();
104}
105
106rfread(dev)
107{
108
109 physio(rfstrategy, &rrfbuf, dev, B_READ);
110}
111
112rfwrite(dev)
113{
114
115 physio(rfstrategy, &rrfbuf, dev, B_WRITE);
116}