1: /*
2: * RP04/RP06 disk driver
3: */
4:
5: #include <sys/param.h>
6: #include <sys/inode.h>
7: #include "../saio.h"
8:
9: struct device
10: {
11: union {
12: int w;
13: char c[2];
14: } xpcs1; /* Control and Status register 1 */
15: int xpwc; /* Word count register */
16: caddr_t xpba; /* UNIBUS address register */
17: int xpda; /* Desired address register */
18: union {
19: int w;
20: char c[2];
21: } xpcs2; /* Control and Status register 2*/
22: int xpds; /* Drive Status */
23: int xper1; /* Error register 1 */
24: int xpas; /* Attention Summary */
25: int xpla; /* Look ahead */
26: int xpdb; /* Data buffer */
27: int xpmr; /* Maintenance register */
28: int xpdt; /* Drive type */
29: int xpsn; /* Serial number */
30: int xpof; /* Offset register */
31: int xpdc; /* Desired Cylinder address register*/
32: int xpcc; /* Current Cylinder */
33: int xper2; /* Error register 2 */
34: int xper3; /* Error register 3 */
35: int xpec1; /* Burst error bit position */
36: int xpec2; /* Burst error bit pattern */
37: int xpbae; /* 11/70 bus extension */
38: int xpcs3;
39: };
40:
41: #define XPADDR ((struct device *)0176700)
42:
43: /*
44: * Defines for Disk Type Independence
45: */
46: #define RP 022 /* RP04/5/6 */
47: #define RM2 025 /* RM02/3 */
48: #define RM3 024 /* RM02/3 */
49: #define RM5 027 /* RM05 */
50: #define RM5X 076 /* Emulex + Ampex 9300CD */
51: #define DVHP 077 /* Diva */
52:
53: #define HP_SECT 22
54: #define HP_TRAC 19
55: #define RM_SECT 32
56: #define RM_TRAC 5
57: #define DV_TRAC 19
58: #define DV_SECT 33
59:
60: #define P400 020
61: #define M400 0220
62: #define P800 040
63: #define M800 0240
64: #define P1200 060
65: #define M1200 0260
66:
67: #define GO 01
68: #define PRESET 020
69: #define RTC 016
70: #define OFFSET 014
71: #define SEARCH 030
72: #define RECAL 06
73: #define DCLR 010
74: #define WCOM 060
75: #define RCOM 070
76:
77: #define IE 0100
78: #define PIP 020000
79: #define DRY 0200
80: #define ERR 040000
81: #define TRE 040000
82: #define DCK 0100000
83: #define WLE 04000
84: #define ECH 0100
85: #define VV 0100
86: #define FMT22 010000
87:
88: extern char haveCSW; /* bool, set if switch register exists */
89: int xptype = 0; /* drive type; declared so we can patch */
90:
91: xpstrategy(io, func)
92: register struct iob *io;
93: {
94: register unit;
95: register i;
96: register nm_sect_per_cyl,nsect;
97: daddr_t bn;
98: int sn, cn, tn;
99:
100: if (((unit = io->i_unit) & 04) == 0)
101: bn = io->i_bn;
102: else {
103: unit &= 03;
104: bn = io->i_bn;
105: bn -= io->i_boff;
106: i = unit + 1;
107: unit = bn%i;
108: bn /= i;
109: bn += io->i_boff;
110: }
111:
112: XPADDR->xpcs2.w = unit;
113:
114: if((XPADDR->xpds & VV) == 0) {
115: XPADDR->xpcs1.c[0] = PRESET|GO;
116: XPADDR->xpof = FMT22;
117: }
118: /*
119: * This next weirdness handled the look up into the Drive Type
120: * register to tell what type of disk we have here.
121: * Look in switch register first (if there is one).
122: *
123: * Note: No need to look up after the first time.
124: */
125:
126: if (xptype == 0) {
127: if (haveCSW && (*CSW == RM2 || *CSW == RM3 || *CSW == RM5
128: || *CSW == RM5X || *CSW == RP || *CSW == DVHP))
129: xptype = *CSW;
130: else
131: xptype = (XPADDR->xpdt & 077);
132: }
133:
134: switch(xptype)
135: {
136:
137: case RM2:
138: case RM3:
139: nm_sect_per_cyl = RM_SECT * RM_TRAC;
140: nsect = RM_SECT;
141: break;
142:
143: case RM5:
144: case RM5X:
145: nm_sect_per_cyl = RM_SECT * HP_TRAC;
146: nsect = RM_SECT;
147: break;
148:
149: case RP:
150: nm_sect_per_cyl = HP_SECT * HP_TRAC;
151: nsect = HP_SECT;
152: break;
153:
154: case DVHP:
155: nm_sect_per_cyl = DV_SECT * DV_TRAC;
156: nsect = DV_SECT;
157: break;
158:
159: default:
160: printf("xp: unknown device type 0%o\n", xptype);
161: return(-1);
162: }
163: cn = bn/(nm_sect_per_cyl);
164: sn = bn%(nm_sect_per_cyl);
165: tn = sn/nsect;
166: sn = sn%nsect;
167:
168: XPADDR->xpdc = cn;
169: XPADDR->xpda = (tn << 8) + sn;
170: XPADDR->xpba = io->i_ma;
171: XPADDR->xpwc = -(io->i_cc>>1);
172: unit = (segflag << 8) | GO;
173: if (func == READ)
174: unit |= RCOM;
175: else if (func == WRITE)
176: unit |= WCOM;
177: XPADDR->xpcs1.w = unit;
178: while ((XPADDR->xpcs1.w&DRY) == 0)
179: ;
180: if (XPADDR->xpcs1.w & TRE) {
181: printf("disk error: cyl=%d track=%d sect=%d cs2=%o, er1=%o\n",
182: cn, tn, sn, XPADDR->xpcs2, XPADDR->xper1);
183: return(-1);
184: }
185: return(io->i_cc);
186: }
Defined functions
Defined variables
Defined struct's
device
defined in line
9;
never used
Defined macros
DCK
defined in line
82;
never used
DCLR
defined in line
73;
never used
DRY
defined in line
79; used 1 times
DVHP
defined in line
51; used 1 times
ECH
defined in line
84;
never used
ERR
defined in line
80;
never used
FMT22
defined in line
86; used 1 times
GO
defined in line
67; used 2 times
IE
defined in line
77;
never used
M1200
defined in line
65;
never used
M400
defined in line
61;
never used
M800
defined in line
63;
never used
P1200
defined in line
64;
never used
P400
defined in line
60;
never used
P800
defined in line
62;
never used
PIP
defined in line
78;
never used
RCOM
defined in line
75; used 1 times
RECAL
defined in line
72;
never used
RM2
defined in line
47; used 1 times
RM3
defined in line
48; used 1 times
RM5
defined in line
49; used 1 times
RM5X
defined in line
50; used 1 times
RP
defined in line
46; used 1 times
RTC
defined in line
69;
never used
TRE
defined in line
81; used 1 times
VV
defined in line
85; used 1 times
WCOM
defined in line
74; used 1 times
WLE
defined in line
83;
never used
XPADDR
defined in line
41; used 14 times