5350: # 5351: /* 5352: */ 5353: 5354: /* 5355: * RK disk driver 5356: */ 5357: 5358: #include "../param.h" 5359: #include "../buf.h" 5360: #include "../conf.h" 5361: #include "../user.h" 5362: 5363: #define RKADDR 0177400 5364: #define NRK 4 5365: #define NRKBLK 4872 5366: 5367: #define RESET 0 5368: #define GO 01 5369: #define DRESET 014 5370: #define IENABLE 0100 5371: #define DRY 0200 5372: #define ARDY 0100 5373: #define WLO 020000 5374: #define CTLRDY 0200 5375: 5376: struct { 5377: int rkds; 5378: int rker; 5379: int rkcs; 5380: int rkwc; 5381: int rkba; 5382: int rkda; 5383: }; 5384: /* --------------------------- */ 5385: 5386: struct devtab rktab; 5387: struct buf rrkbuf; 5388: 5389: rkstrategy(abp) 5390: struct buf *abp; 5391: { 5392: register struct buf *bp; 5393: register *qc, *ql; 5394: int d; 5395: 5396: bp = abp; 5397: if(bp->b_flags&B_PHYS) 5398: mapalloc(bp); 5399: d = bp->b_dev.d_minor-7; 5400: if(d <= 0) 5401: d = 1; 5402: if (bp->b_blkno >= NRKBLK*d) { 5403: bp->b_flags =| B_ERROR; 5404: iodone(bp); 5405: return; 5406: } 5407: bp->av_forw = 0; 5408: spl5(); 5409: if (rktab.d_actf==0) 5410: rktab.d_actf = bp; 5411: else 5412: rktab.d_actl->av_forw = bp; 5413: rktab.d_actl = bp; 5414: if (rktab.d_active==0) 5415: rkstart(); 5416: spl0(); 5417: } 5418: /* --------------------------- */ 5419: 5420: rkaddr(bp) 5421: struct buf *bp; 5422: { 5423: register struct buf *p; 5424: register int b; 5425: int d, m; 5426: 5427: p = bp; 5428: b = p->b_blkno; 5429: m = p->b_dev.d_minor - 7; 5430: if(m <= 0) 5431: d = p->b_dev.d_minor; 5432: else { 5433: d = lrem(b, m); 5434: b = ldiv(b, m); 5435: } 5436: return(d<<13 | (b/12)<<4 | b%12); 5437: } 5438: /* --------------------------- */ 5439: 5440: rkstart() 5441: { 5442: register struct buf *bp; 5443: 5444: if ((bp = rktab.d_actf) == 0) 5445: return; 5446: rktab.d_active++; 5447: devstart(bp, &RKADDR->rkda, rkaddr(bp), 0); 5448: } 5449: /* --------------------------- */ 5450: 5451: rkintr() 5452: { 5453: register struct buf *bp; 5454: 5455: if (rktab.d_active == 0) 5456: return; 5457: bp = rktab.d_actf; 5458: rktab.d_active = 0; 5459: if (RKADDR->rkcs < 0) { /* error bit */ 5460: deverror(bp, RKADDR->rker, RKADDR->rkds); 5461: RKADDR->rkcs = RESET|GO; 5462: while((RKADDR->rkcs&CTLRDY) == 0) ; 5463: if (++rktab.d_errcnt <= 10) { 5464: rkstart(); 5465: return; 5466: } 5467: bp->b_flags =| B_ERROR; 5468: } 5469: rktab.d_errcnt = 0; 5470: rktab.d_actf = bp->av_forw; 5471: iodone(bp); 5472: rkstart(); 5473: } 5474: /* --------------------------- */ 5475: 5476: rkread(dev) 5477: { 5478: 5479: physio(rkstrategy, &rrkbuf, dev, B_READ); 5480: } 5481: /* --------------------------- */ 5482: 5483: rkwrite(dev) 5484: { 5485: 5486: physio(rkstrategy, &rrkbuf, dev, B_WRITE); 5487: } 5488: /* --------------------------- */