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:  *	@(#)idc.c	7.1 (Berkeley) 6/5/86
   7:  */
   8: 
   9: /*
  10:  * IDC (RB730)
  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/idcreg.h"
  19: #include "../vaxuba/ubareg.h"
  20: 
  21: #include "saio.h"
  22: #include "savax.h"
  23: 
  24: u_short idcstd[] = { 0175606 };
  25: short   rb02_off[] = { 0, 400, 0, -1, -1, -1, -1, -1 };
  26: short   rb80_off[] = { 0, 37, 0, -1, -1, -1, 115, 305 };
  27: 
  28: int idc_type[4];
  29: 
  30: idcopen(io)
  31:     register struct iob *io;
  32: {
  33:     register struct idcdevice *idcaddr;
  34:     register int i;
  35: 
  36:     idcaddr = (struct idcdevice *)((caddr_t)ubauba(io->i_unit) + 0x200);
  37:     if (io->i_boff < 0 || io->i_boff > 7)
  38:         _stop("idc bad unit");
  39:     idcaddr->idcmpr = IDCGS_GETSTAT;
  40:     idcaddr->idccsr = IDC_GETSTAT|(io->i_unit<<8);
  41:     idcwait(idcaddr);
  42:     i = idcaddr->idcmpr;
  43:     idcaddr->idccsr = IDC_CRDY|(1<<(io->i_unit+16));
  44:     idcwait(idcaddr);
  45:     idcaddr->idccsr = (io->i_unit<<8)|IDC_RHDR;
  46:     idcwait(idcaddr);
  47:     if (idcaddr->idccsr & IDC_ERR) {
  48:         printf("idc error: idccsr %x\n", idcaddr->idccsr);
  49:         _stop("idc fatal error");
  50:     }
  51:     i = idcaddr->idcmpr;
  52:     i = idcaddr->idcmpr;
  53:     if (idcaddr->idccsr & IDC_R80) {
  54:         idc_type[io->i_unit] = 1;
  55:         io->i_boff = rb80_off[io->i_boff] * NRB80SECT * NRB80TRK;
  56:     } else {
  57:         idc_type[io->i_unit] = 0;
  58:         io->i_boff = rb02_off[io->i_boff] * NRB02SECT/2 * NRB02TRK;
  59:     }
  60:     if (io->i_boff < 0)
  61:         _stop("idc%d: bad unit type", io->i_unit);
  62: }
  63: 
  64: idcstrategy(io, func)
  65:     register struct iob *io;
  66: {
  67:     register struct idcdevice *idcaddr;
  68:     int com;
  69:     daddr_t bn;
  70:     short dn, cn, sn, tn;
  71:     short ccleft, thiscc = 0;
  72:     int ubinfo, errcnt = 0;
  73: 
  74:     idcaddr = (struct idcdevice *)((caddr_t)ubauba(io->i_unit) + 0x200);
  75:     ubinfo = ubasetup(io, 1);
  76:     bn = io->i_bn;
  77:     ccleft = io->i_cc;
  78: retry:
  79:     dn = io->i_unit;
  80:     if (idc_type[dn]) {
  81:         cn = bn/(NRB80SECT*NRB80TRK);
  82:         sn = bn%NRB80SECT;
  83:         tn = (bn / NRB80SECT) % NRB80TRK;
  84:         thiscc = (NRB80SECT - sn) * 512;
  85:     } else {
  86:         cn = 2*bn/(NRB02SECT*NRB02TRK);
  87:         sn = (2*bn)%NRB02SECT;
  88:         tn = (2*bn / NRB02SECT) % NRB02TRK;
  89:         thiscc = (NRB02SECT - sn) * 256;
  90:     }
  91:     thiscc = MIN(thiscc, ccleft);
  92:     ccleft -= thiscc;
  93:     idcaddr->idccsr = IDC_CRDY|IDC_SEEK|(dn<<8)|(1<<(dn+16));
  94:     idcaddr->idcdar = (cn<<16)|(tn<<8)|sn;
  95:     idcaddr->idccsr = IDC_SEEK|(dn<<8);
  96:     idcwait(idcaddr);
  97:     idcaddr->idccsr &= ~IDC_ATTN;
  98:     com = dn<<8;
  99:     if (func == READ)
 100:         com |= IDC_READ;
 101:     else
 102:         com |= IDC_WRITE;
 103:     idcaddr->idccsr = IDC_CRDY|com;
 104:     idcaddr->idcbar = ubinfo&0x3ffff;
 105:     idcaddr->idcbcr = -thiscc;
 106:     idcaddr->idcdar = (cn<<16)|(tn<<8)|sn;
 107:     idcaddr->idccsr = com;
 108:     idcwait(idcaddr);
 109:     if (idcaddr->idccsr & IDC_ERR) {
 110:         printf("idc%d error: (cyl,trk,sec)=(%d,%d,%d) csr=%b\n",
 111:             dn, cn, tn, sn, idcaddr->idccsr, IDCCSR_BITS);
 112:         if (errcnt == 10) {
 113:             printf("idc: unrecovered error\n");
 114:             ubafree(io, ubinfo);
 115:             return (-1);
 116:         }
 117:         errcnt++;
 118:         goto retry;
 119:     }
 120:     if (errcnt)
 121:         printf("idc: recovered by retry\n");
 122:     if (ccleft) {
 123:         bn += thiscc/NBPG;
 124:         ubinfo += thiscc;
 125:         goto retry;
 126:     }
 127:     ubafree(io, ubinfo);
 128:     return (io->i_cc);
 129: }
 130: 
 131: idcwait(idcaddr)
 132:     register struct idcdevice *idcaddr;
 133: {
 134:     register int i;
 135: 
 136:     while ((idcaddr->idccsr & (IDC_CRDY|IDC_DRDY)) != (IDC_CRDY|IDC_DRDY))
 137:         for (i = 10; i; i--)
 138:             ;
 139: }
 140: 
 141: /*ARGSUSED*/
 142: idcioctl(io, cmd, arg)
 143:     struct iob *io;
 144:     int cmd;
 145:     caddr_t arg;
 146: {
 147: 
 148:     return (ECMD);
 149: }

Defined functions

idcioctl defined in line 142; used 2 times
idcopen defined in line 30; used 2 times
idcstrategy defined in line 64; used 2 times
idcwait defined in line 131; used 5 times

Defined variables

idc_type defined in line 28; used 3 times
idcstd defined in line 24; never used
rb02_off defined in line 25; used 1 times
  • in line 58
rb80_off defined in line 26; used 1 times
  • in line 55
Last modified: 1986-06-05
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1071
Valid CSS Valid XHTML 1.0 Strict