# 2.11BSD#431 - /usr/src/sys/pdpstand/hk.c

##### Functions

    hklabel           X
    hkopen            X
    hkstrategy        X

##### Variables

    HKcsr             X
    hk_drvtyp         X
    hk_mntflg         X

##### Macros

    N6CYL             X
    N7CYL             X
    NHK               X
    NSECT             X
    NTRAC             X

       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:  *	@(#)hk.c	2.3 (2.11BSD) 1997/11/7
       7:  */
       8:
       9: /*
      10:  *	RK06/07 disk driver for standalone
      11:  */
      12:
      13: #include "../h/param.h"
      14: #include "../pdpuba/hkreg.h"
      15: #include "saio.h"
      16:
      17: #define NHK 2
      18: #define NSECT   22
      19: #define NTRAC   3
      20: #define N7CYL   815
      21: #define N6CYL   411
      22:
      23:     struct  hkdevice *HKcsr[NHK + 1] =
      24:         {
      25:         (struct hkdevice *)0177440,
      26:         (struct hkdevice *)0,
      27:         (struct hkdevice *)-1
      28:         };
      29:
      30:     u_char  hk_mntflg[NHK];     /* Type known bitmap, 0 = unknown */
      31:     u_char  hk_drvtyp[NHK];     /* Drive type.  0 = RK06, 1 = RK07 */
      32:
      33: hkstrategy(io, func)
      34:     register struct iob *io;
      35:     {
      36:     int unit, com;
      37:     register struct hkdevice *hkaddr;
      38:     daddr_t bn;
      39:     int hktyp, drvbit, i;
      40:     int sn, cn, tn, ctlr, bae, lo16;
      41:
      42:     i = deveovchk(io);
      43:     if  (i < 0)
      44:         return(i);
      45:     unit = io->i_unit;
      46:     ctlr = io->i_ctlr;
      47:     hkaddr = HKcsr[ctlr];
      48:
      49:     drvbit = 1 << unit;
      50:     if  (hk_drvtyp[ctlr] & drvbit)
      51:         hktyp = 02000;
      52:     else
      53:         hktyp = 0;
      54:
      55:     bn = io->i_bn;
      56:     hkaddr->hkcs2 = HKCS2_SCLR;
      57:     while ((hkaddr->hkcs1 & HK_CRDY) == 0)
      58:         continue;
      59:     hkaddr->hkcs2 = unit;
      60:     hkaddr->hkcs1 = hktyp|HK_SELECT|HK_GO;
      61:     while ((hkaddr->hkcs1 & HK_CRDY) == 0)
      62:         continue;
      63:
      64:     if  ((hkaddr->hkds & HKDS_VV) == 0)
      65:         {
      66:         hkaddr->hkcs1 = hktyp|HK_PACK|HK_GO;
      67:         while   ((hkaddr->hkcs1 & HK_CRDY) == 0)
      68:             continue;
      69:         }
      70:     cn = bn/(NSECT*NTRAC);
      71:     sn = bn%(NSECT*NTRAC);
      72:     tn = sn/NSECT;
      73:     sn = sn%NSECT;
      74:
      75:     iomapadr(io->i_ma, &bae, &lo16);
      76:     hkaddr->hkcyl = cn;
      77:     hkaddr->hkda = (tn<<8) | sn;
      78:     hkaddr->hkba = (caddr_t)lo16;
      79:     hkaddr->hkwc = -(io->i_cc>>1);
      80:     com = hktyp|(bae << 8) | HK_GO;
      81:     if  (func == READ)
      82:         com |= HK_READ;
      83:     else if (func == WRITE)
      84:         com |= HK_WRITE;
      85:     hkaddr->hkcs1 = com;
      86:
      87:     while   ((hkaddr->hkcs1 & HK_CRDY) == 0)
      88:         continue;
      89:
      90:     if  (hkaddr->hkcs1 & HK_CERR)
      91:         {
      92:         printf("%s err: cy=%d tr=%d sc=%d cs2=%d er=%o\n",
      93:             devname(io), cn, tn, sn, hkaddr->hkcs2, hkaddr->hker);
      94:         return(-1);
      95:         }
      96:     return(io->i_cc);
      97:     }
      98:
      99: hkopen(io)
     100:     register struct iob *io;
     101:     {
     102:     register struct hkdevice *hkaddr;
     103:     int drvbit;
     104:     int unit, ctlr;
     105:
     106:     drvbit = 1 << io->i_unit;
     107:
     108:     if  (genopen(NHK, io) < 0)
     109:         return(-1);
     110:
     111:     if  ((hk_mntflg[ctlr] & drvbit) == 0)
     112:         {
     113:         hkaddr = HKcsr[ctlr];
     114:         hkaddr->hkcs2 = unit;
     115:         hkaddr->hkcs1 = HK_SELECT|HK_GO;
     116:         while   ((hkaddr->hkcs1 & HK_CRDY) == 0)
     117:             continue;
     118:         if  (hkaddr->hkcs1 & HK_CERR && hkaddr->hker & HKER_DTYE)
     119:             hk_drvtyp[ctlr] |= drvbit;
     120:         else
     121:             hk_drvtyp[ctlr] &= ~drvbit;
     122:         hk_mntflg[ctlr] |= drvbit;
     123:         }
     124:     if  (devlabel(io, READLABEL) < 0)
     125:         return(-1);
     126:     io->i_boff = io->i_label.d_partitions[io->i_part].p_offset;
     127:     return(0);
     128:     }
     129:
     130: /*
     131:  * This generates a default label.  'hkopen' has already been called and
     132:  * determined the drive type.
     133: */
     134:
     135: hklabel(io)
     136:     register struct iob *io;
     137:     {
     138:     register struct disklabel *lp = &io->i_label;
     139:     u_short ncyl, nblks;
     140:
     141:     if  (hk_drvtyp[io->i_ctlr] && (1 << io->i_unit))
     142:         ncyl = N7CYL;
     143:     else
     144:         ncyl = N6CYL;
     145:     lp->d_partitions[0].p_size = lp->d_secperunit = NSECT * NTRAC * ncyl;
     146:     lp->d_type = DTYPE_DEC;
     147:     lp->d_nsectors = NSECT;
     148:     lp->d_ntracks = NTRAC;
     149:     lp->d_secpercyl = NSECT * NTRAC;
     150:     lp->d_ncylinders = ncyl;
     151:     return(0);
     152:     }

#### Defined functions

hklabel defined in line 135; used 2 times

- in /usr/src/sys/pdpstand/conf.c line 18, 45

hkopen defined in line 99; used 2 times

- in /usr/src/sys/pdpstand/conf.c line 18, 44

hkstrategy defined in line 33; used 2 times

- in /usr/src/sys/pdpstand/conf.c line 18, 44

#### Defined variables

HKcsr defined in line 23; used 3 times

- in line 47, 113
- in /usr/src/sys/pdpstand/conf.c line 44

hk_drvtyp defined in line 31; used 4 times

- in line 50, 119-121(2), 141

hk_mntflg defined in line 30; used 2 times

- in line 111, 122

#### Defined macros

N6CYL defined in line 21; used 1 times

- in line 144

N7CYL defined in line 20; used 1 times

- in line 142

NHK defined in line 17; used 4 times

- in line 23, 30-31(2), 108

NSECT defined in line 18; used 7 times

- in line 70-73(4), 145-149(3)

NTRAC defined in line 19; used 5 times

- in line 70-71(2), 145-149(3)

Last modified: 1997-11-08 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1493 |