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