1: /*
   2:  * Copyright (c) 1982, 1986 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)rk.c	7.1 (Berkeley) 6/5/86
   7:  */
   8: 
   9: /*
  10:  * RK611/RK07
  11:  */
  12: #include "../machine/pte.h"
  13: 
  14: #include "../h/param.h"
  15: #include "../h/inode.h"
  16: #include "../h/fs.h"
  17: 
  18: #include "../vaxuba/ubareg.h"
  19: #include "../vaxuba/rkreg.h"
  20: 
  21: #include "saio.h"
  22: #include "savax.h"
  23: 
  24: u_short rkstd[] = { 0777440 };
  25: short   rk_off[] = { 0, 241, 0, -1, -1, -1, 393, -1 };
  26: 
  27: rkopen(io)
  28:     register struct iob *io;
  29: {
  30:     register struct rkdevice *rkaddr = (struct rkdevice *)ubamem(io->i_unit, rkstd[0]);
  31: 
  32:     if (rk_off[io->i_boff] == -1 ||
  33:         io->i_boff < 0 || io->i_boff > 7)
  34:         _stop("rk bad unit");
  35:     io->i_boff = rk_off[io->i_boff] * NRKSECT*NRKTRK;
  36:     rkaddr->rkcs2 = RKCS2_SCLR;
  37:     rkwait(rkaddr);
  38: }
  39: 
  40: rkstrategy(io, func)
  41:     register struct iob *io;
  42: {
  43:     register struct rkdevice *rkaddr = (struct rkdevice *)ubamem(io->i_unit, rkstd[0]);
  44:     int com;
  45:     daddr_t bn;
  46:     short dn, cn, sn, tn;
  47:     int ubinfo, errcnt = 0;
  48: 
  49: retry:
  50:     ubinfo = ubasetup(io, 1);
  51:     bn = io->i_bn;
  52:     dn = io->i_unit;
  53:     cn = bn/(NRKSECT*NRKTRK);
  54:     sn = bn%NRKSECT;
  55:     tn = (bn / NRKSECT) % NRKTRK;
  56:     rkaddr->rkcs2 = dn;
  57:     rkaddr->rkcs1 = RK_CDT|RK_PACK|RK_GO;
  58:     rkwait(rkaddr);
  59:     rkaddr->rkcs1 = RK_CDT|RK_DCLR|RK_GO;
  60:     rkwait(rkaddr);
  61:     rkaddr->rkda = sn | (tn << 8);
  62:     rkaddr->rkcyl = cn;
  63:     rkaddr->rkba = ubinfo;
  64:     rkaddr->rkwc = -(io->i_cc >> 1);
  65:     com = RK_CDT|((ubinfo>>8)&0x300)|RK_GO;
  66:     if (func == READ)
  67:         com |= RK_READ;
  68:     else
  69:         com |= RK_WRITE;
  70:     rkaddr->rkcs1 = com;
  71:     rkwait(rkaddr);
  72:     while ((rkaddr->rkds & RKDS_SVAL) == 0)
  73:         ;
  74:     ubafree(io, ubinfo);
  75:     if (rkaddr->rkcs1 & RK_CERR) {
  76:         printf("rk error: (cyl,trk,sec)=(%d,%d,%d) cs2=%b er=%b\n",
  77:             cn, tn, sn, rkaddr->rkcs2, RKCS2_BITS,
  78:             rkaddr->rker, RKER_BITS);
  79:         rkaddr->rkcs1 = RK_CDT|RK_DCLR|RK_GO;
  80:         rkwait(rkaddr);
  81:         if (errcnt == 10) {
  82:             printf("rk: unrecovered error\n");
  83:             return (-1);
  84:         }
  85:         errcnt++;
  86:         goto retry;
  87:     }
  88:     if (errcnt)
  89:         printf("rk: recovered by retry\n");
  90:     return (io->i_cc);
  91: }
  92: 
  93: rkwait(rkaddr)
  94:     register struct rkdevice *rkaddr;
  95: {
  96: 
  97:     while ((rkaddr->rkcs1 & RK_CRDY) == 0)
  98:         ;
  99: }
 100: 
 101: /*ARGSUSED*/
 102: rkioctl(io, cmd, arg)
 103:     struct iob *io;
 104:     int cmd;
 105:     caddr_t arg;
 106: {
 107: 
 108:     return (ECMD);
 109: }

Defined functions

rkioctl defined in line 102; used 4 times
rkopen defined in line 27; used 4 times
rkstrategy defined in line 40; used 4 times
rkwait defined in line 93; used 5 times

Defined variables

rk_off defined in line 25; used 2 times
rkstd defined in line 24; used 2 times
Last modified: 1986-06-05
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1079
Valid CSS Valid XHTML 1.0 Strict