1: /*
   2:  * Copyright (c) 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:  *	@(#)br.c	2.3 (2.11BSD) 1996/3/8
   7:  */
   8: 
   9: /*
  10:  * rp03-like disk driver
  11:  *  	modified to handle BR 1537 and 1711 controllers with
  12:  *	T300, T200, T80 and T50 drives.
  13:  */
  14: 
  15: #include "../h/param.h"
  16: #include "../pdpuba/brreg.h"
  17: #include "saio.h"
  18: 
  19: #define NBR 2
  20: #define SEC22   02400   /* T200 or T50 */
  21: #define CYL5    01400   /* T80 or T50 */
  22: 
  23:     struct  brdevice *BRcsr[NBR + 1] =
  24:         {
  25:         (struct brdevice *)0176710,
  26:         (struct brdevice *)0,
  27:         (struct brdevice *)-1
  28:         };
  29: 
  30: int brsctrk[NBR][8], brtrkcyl[NBR][8];
  31: 
  32: brstrategy(io, func)
  33:     register struct iob *io;
  34: {
  35:     register struct brdevice *braddr;
  36:     register int ctlr;
  37:     int com, cn, tn, sn, unit, sectrk, trkcyl, ctr, bae, lo16;
  38: 
  39:     unit = io->i_unit;
  40:     ctlr = io->i_ctlr;
  41:     braddr = BRcsr[ctlr];
  42: 
  43:     /* if we haven't gotten the characteristics yet, do so now. */
  44:     trkcyl = brtrkcyl[ctlr][unit];
  45:     if (!(sectrk = brsctrk[ctlr][unit])) {
  46:         /* give a home seek command, then wait for complete */
  47:         braddr->brcs.w = (unit << 8) | BR_HSEEK | BR_GO;
  48:         ctr = 0;
  49:         while ((braddr->brcs.w & BR_RDY) == 0 && --ctr)
  50:             continue;
  51:         if (braddr->brcs.w & BR_HE) {
  52:             printf("%s !ready\n", devname(io));
  53:             return(-1);
  54:         }
  55:         com = braddr->brae;
  56:         if (com & SEC22)
  57:             sectrk = 22;
  58:         else
  59:             sectrk = 32;
  60:         if (com & CYL5)
  61:             trkcyl = 5;
  62:         else
  63:             trkcyl = 19;
  64:         brsctrk[ctlr][unit] = sectrk;
  65:         brtrkcyl[ctlr][unit] = trkcyl;
  66:     }
  67:     cn = io->i_bn/(sectrk * trkcyl);
  68:     sn = io->i_bn%(sectrk * trkcyl);
  69:     tn = sn/sectrk;
  70:     sn = sn%sectrk;
  71: 
  72:     iomapadr(io->i_ma, &bae, &lo16);
  73:     braddr->brcs.w = (unit<<8);
  74:     braddr->brda = (tn<<8) | sn;
  75:     braddr->brca = cn;
  76:     braddr->brba = (caddr_t)lo16;
  77:     braddr->brwc = -(io->i_cc>>1);
  78:     braddr->brae = bae;
  79:     com = (bae<<4)|BR_GO;
  80:     if (func == READ)
  81:         com |= BR_RCOM;
  82:     else
  83:         com |= BR_WCOM;
  84:     braddr->brcs.w |= com;
  85:     while ((braddr->brcs.w& BR_RDY)==0)
  86:         continue;
  87:     if (braddr->brcs.w < 0) {   /* error bit */
  88:         printf("%s err: cy=%d tr=%d sc=%d er=%o ds=%o\n",
  89:             devname(io), cn, tn, sn, braddr->brer, braddr->brds);
  90:         return(-1);
  91:     }
  92:     return(io->i_cc);
  93: }
  94: 
  95: bropen(io)
  96:     struct iob *io;
  97: {
  98:     return(genopen(NBR, io));
  99: }

Defined functions

bropen defined in line 95; used 2 times
brstrategy defined in line 32; used 2 times

Defined variables

BRcsr defined in line 23; used 2 times
brsctrk defined in line 30; used 2 times
brtrkcyl defined in line 30; used 2 times

Defined macros

CYL5 defined in line 21; used 1 times
  • in line 60
NBR defined in line 19; used 4 times
SEC22 defined in line 20; used 1 times
  • in line 56
Last modified: 1996-03-09
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 607
Valid CSS Valid XHTML 1.0 Strict