|
|
1.1 root 1: /* hp.c 4.1 11/9/80 */
2:
3: /*
4: * RP06/RM03/RM05 disk driver
5: */
6:
7: #include "../h/param.h"
8: #include "../h/inode.h"
9: #include "../h/pte.h"
10: #include "../h/mba.h"
11: #include "saio.h"
12:
13: struct device
14: {
15: int hpcs1; /* control and Status register 1 */
16: int hpds; /* Drive Status */
17: int hper1; /* Error register 1 */
18: int hpmr; /* Maintenance */
19: int hpas; /* Attention Summary */
20: int hpda; /* Desired address register */
21: int hpdt; /* Drive type */
22: int hpla; /* Look ahead */
23: int hpsn; /* serial number */
24: int hpof; /* Offset register */
25: int hpdc; /* Desired Cylinder address register */
26: int hpcc; /* Current Cylinder */
27: int hper2; /* Error register 2 */
28: int hper3; /* Error register 3 */
29: int hpec1; /* Burst error bit position */
30: int hpec2; /* Burst error bit pattern */
31: };
32:
33: #define HPMBA PHYSMBA0
34: #define HPMBANUM 0
35:
36: #define NHP 8
37: #define RP 022
38: #define RM 024
39: #define RM5 027
40: #define NSECT 22
41: #define NTRAC 19
42: #define NRMSECT 32
43: #define NRMTRAC 5
44: #define SDIST 2
45: #define RDIST 6
46:
47: char hp_type[NHP] = { 0 }; /* drive type */
48:
49: #define GO 01
50: #define PRESET 020
51: #define RTC 016
52: #define OFFSET 014
53: #define SEARCH 030
54: #define RECAL 06
55: #define DCLR 010
56: #define WCOM 060
57: #define RCOM 070
58:
59: #define IE 0100
60: #define PIP 020000
61: #define DRY 0200
62: #define ERR 040000
63: #define TRE 040000
64: #define DCK 0100000
65: #define WLE 04000
66: #define ECH 0100
67: #define VV 0100
68: #define DPR 0400
69: #define MOL 010000
70: #define FMT22 010000
71:
72: struct size {
73: daddr_t cyloff;
74: } hp_sizes[8] = {
75: 0, 38, 0, -1, -1, -1, 118, -1
76: }, rm_sizes[8] = {
77: 0, 100, 0, -1, -1, -1, 310, -1
78: }, rm5_sizes[9] = {
79: 0, 27, 0, 562, 589, 681, 562, 82
80: };
81:
82: hpopen(io)
83: register struct iob *io;
84: {
85: register unit = io->i_unit;
86: struct device *hpaddr;
87:
88: if ((mbaact&(1<<HPMBANUM)) == 0)
89: mbainit(HPMBANUM);
90: hpaddr = mbadev(HPMBA,unit);
91: if (hp_type[unit] == 0)
92: hp_type[unit] = hpaddr->hpdt;
93: if (hp_sizes[io->i_boff].cyloff == -1 ||
94: io->i_boff < 0 || io->i_boff > 7)
95: _stop("hp bad minor");
96: switch (hp_type[unit]) {
97: case RM:
98: io->i_boff = rm_sizes[io->i_boff].cyloff * NRMSECT * NRMTRAC;
99: break;
100: case RM5:
101: io->i_boff = rm5_sizes[io->i_boff].cyloff * NRMSECT * NTRAC;
102: break;
103: case RP:
104: io->i_boff = hp_sizes[io->i_boff].cyloff * NSECT * NTRAC;
105: break;
106: default:
107: _stop("unknown drive type");
108: }
109: }
110:
111: hpstrategy(io, func)
112: register struct iob *io;
113: {
114: int unit, nspc, ns, cn, tn, sn;
115: daddr_t bn;
116: struct device *hpaddr;
117:
118: unit = io->i_unit;
119: bn = io->i_bn;
120: hpaddr = mbadev(HPMBA, unit);
121: if (hp_type[unit] == 0)
122: hp_type[unit] = hpaddr->hpdt;
123: if((hpaddr->hpds & VV) == 0) {
124: hpaddr->hpcs1 = PRESET|GO;
125: hpaddr->hpof = FMT22;
126: }
127: switch (hp_type[unit]) {
128: case RM:
129: nspc = NRMSECT*NRMTRAC; ns = NRMSECT; break;
130: case RM5:
131: nspc = NRMSECT*NTRAC; ns = NRMSECT; break;
132: case RP:
133: nspc = NSECT*NTRAC; ns = NSECT; break;
134: }
135: cn = bn/nspc;
136: sn = bn%nspc;
137: tn = sn/ns;
138: sn = sn%ns;
139: hpaddr->hpdc = cn;
140: hpaddr->hpda = (tn << 8) + sn;
141: mbastart(io, (int *)hpaddr, func);
142: while((hpaddr->hpds & DRY) == 0)
143: ;
144: if(hpaddr->hpds&ERR) {
145: printf("disk error: cyl=%d track=%d sect=%d ds=%X, er1=%X\n",
146: cn, tn, sn,
147: hpaddr->hpds, hpaddr->hper1);
148: return (-1);
149: }
150: return(io->i_cc);
151: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.