|
|
1.1 root 1: /*
2: * Copyright (c) 1988 University of Utah.
3: * Copyright (c) 1982, 1990 The Regents of the University of California.
4: * All rights reserved.
5: *
6: * This code is derived from software contributed to Berkeley by
7: * the Systems Programming Group of the University of Utah Computer
8: * Science Department.
9: *
10: * Redistribution and use in source and binary forms, with or without
11: * modification, are permitted provided that the following conditions
12: * are met:
13: * 1. Redistributions of source code must retain the above copyright
14: * notice, this list of conditions and the following disclaimer.
15: * 2. Redistributions in binary form must reproduce the above copyright
16: * notice, this list of conditions and the following disclaimer in the
17: * documentation and/or other materials provided with the distribution.
18: * 3. All advertising materials mentioning features or use of this software
19: * must display the following acknowledgement:
20: * This product includes software developed by the University of
21: * California, Berkeley and its contributors.
22: * 4. Neither the name of the University nor the names of its contributors
23: * may be used to endorse or promote products derived from this software
24: * without specific prior written permission.
25: *
26: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36: * SUCH DAMAGE.
37: *
38: * from: Utah $Hdr: rd.c 1.38 90/10/12$
39: *
1.1.1.2 ! root 40: * from: @(#)rd.c 7.9 (Berkeley) 5/7/91
! 41: * rd.c,v 1.2 1993/05/22 07:56:45 cgd Exp
1.1 root 42: */
43:
44: /*
45: * CS80/SS80 disk driver
46: */
47: #include "rd.h"
48: #if NRD > 0
49:
50: #include "sys/param.h"
51: #include "sys/systm.h"
52: #include "sys/errno.h"
53: #include "sys/dkstat.h"
54: #include "sys/disklabel.h"
55: #include "sys/buf.h"
56: #include "sys/uio.h"
57:
58: #include "device.h"
59: #include "rdreg.h"
60:
61: #include "vm/vm_param.h"
62: #include "vm/lock.h"
63: #include "vm/vm_statistics.h"
64: #include "vm/pmap.h"
65: #include "vm/vm_prot.h"
66:
67: int rdinit(), rdstart(), rdgo(), rdintr();
68: struct driver rddriver = {
69: rdinit, "rd", rdstart, rdgo, rdintr,
70: };
71:
72: struct rd_softc {
73: struct hp_device *sc_hd;
74: int sc_flags;
75: short sc_type;
76: short sc_punit;
77: char *sc_addr;
78: int sc_resid;
79: u_int sc_wpms;
80: struct rdinfo *sc_info;
81: struct devqueue sc_dq;
82: struct rd_iocmd sc_ioc;
83: struct rd_rscmd sc_rsc;
84: struct rd_stat sc_stat;
85: struct rd_ssmcmd sc_ssmc;
86: struct rd_srcmd sc_src;
87: struct rd_clearcmd sc_clear;
88: } rd_softc[NRD];
89:
90: /* sc_flags values */
91: #define RDF_ALIVE 0x1
92: #define RDF_SEEK 0x2
93: #define RDF_SWAIT 0x4
94:
95: struct size {
96: daddr_t nblocks;
97: int cyloff;
98: };
99:
100: #ifdef DEBUG
101: int rddebug = 0x80;
102: #define RDB_FOLLOW 0x01
103: #define RDB_STATUS 0x02
104: #define RDB_IDENT 0x04
105: #define RDB_IO 0x08
106: #define RDB_ASYNC 0x10
107: #define RDB_ERROR 0x80
108: #define RDB_DUMP 0x80000000
109:
110: struct rdstats {
111: long rdretries;
112: long rdresets;
113: long rdtimeouts;
114: long rdpolltries;
115: long rdpollwaits;
116: } rdstats[NRD];
117:
118: /* error message tables */
119: char *err_reject[] = {
120: 0, 0,
121: "channel parity error", /* 0x2000 */
122: 0, 0,
123: "illegal opcode", /* 0x0400 */
124: "module addressing", /* 0x0200 */
125: "address bounds", /* 0x0100 */
126: "parameter bounds", /* 0x0080 */
127: "illegal parameter", /* 0x0040 */
128: "message sequence", /* 0x0020 */
129: 0,
130: "message length", /* 0x0008 */
131: 0, 0, 0
132: };
133:
134: char *err_fault[] = {
135: 0,
136: "cross unit", /* 0x4000 */
137: 0,
138: "controller fault", /* 0x1000 */
139: 0, 0,
140: "unit fault", /* 0x0200 */
141: 0,
142: "diagnostic result", /* 0x0080 */
143: 0,
144: "operator release request", /* 0x0020 */
145: "diagnostic release request", /* 0x0010 */
146: "internal maintenance release request", /* 0x0008 */
147: 0,
148: "power fail", /* 0x0002 */
149: "retransmit" /* 0x0001 */
150: };
151:
152: char *err_access[] = {
153: "illegal parallel operation", /* 0x8000 */
154: "uninitialized media", /* 0x4000 */
155: "no spares available", /* 0x2000 */
156: "not ready", /* 0x1000 */
157: "write protect", /* 0x0800 */
158: "no data found", /* 0x0400 */
159: 0, 0,
160: "unrecoverable data overflow", /* 0x0080 */
161: "unrecoverable data", /* 0x0040 */
162: 0,
163: "end of file", /* 0x0010 */
164: "end of volume", /* 0x0008 */
165: 0, 0, 0
166: };
167:
168: char *err_info[] = {
169: "operator release request", /* 0x8000 */
170: "diagnostic release request", /* 0x4000 */
171: "internal maintenance release request", /* 0x2000 */
172: "media wear", /* 0x1000 */
173: "latency induced", /* 0x0800 */
174: 0, 0,
175: "auto sparing invoked", /* 0x0100 */
176: 0,
177: "recoverable data overflow", /* 0x0040 */
178: "marginal data", /* 0x0020 */
179: "recoverable data", /* 0x0010 */
180: 0,
181: "maintenance track overflow", /* 0x0004 */
182: 0, 0
183: };
184: #endif
185:
186: /*
187: * CS/80 partitions. We reserve the first cylinder for a LIF
188: * style boot directory (the 8k allowed in the BSD filesystem
189: * is just way too small). This boot area is outside of all but
190: * the C partition. This implies that you cannot use the C
191: * partition on a bootable disk since the filesystem would overlay
192: * the boot area. You must use the A partition.
193: *
194: * These maps support four basic layouts:
195: *
196: * A/B/G: This is the "traditional" setup for a bootable disk.
197: * A is the root partition, B the swap, and G a user partition.
198: * A/D/H: This is a setup for bootable systems requiring more swap
199: * (e.g. those who use HPCL). It has A as the root, D as a
200: * larger swap, and H as a smaller user partition.
201: * A/D/E/F: Similar to A/D/H with E and F breaking H into two partitions.
202: * E could be used for /usr and F for users.
203: * C: This gives a single, non-bootable, large user filesystem.
204: * Good for second drives on a machine (e.g. /usr/src).
205: */
206: struct size rd7945A_sizes[8] = {
207: RDSZ(15904), 1, /* A=cyl 1 thru 142 */
208: RDSZ(20160), 143, /* B=cyl 143 thru 322 */
209: RDSZ(108416), 0, /* C=cyl 0 thru 967 */
210: RDSZ(40320), 143, /* D=cyl 143 thru 502 */
211: RDSZ(0), 0, /* E=<undefined> */
212: RDSZ(0), 0, /* F=<undefined> */
213: RDSZ(72240), 323, /* G=cyl 323 thru 967 */
214: RDSZ(52080), 503, /* H=cyl 503 thru 967 */
215: }, rd9134D_sizes[8] = {
216: RDSZ(15936), 1, /* A=cyl 1 thru 166 */
217: RDSZ(13056), 167, /* B=cyl 167 thru 302 */
218: RDSZ(29088), 0, /* C=cyl 0 thru 302 */
219: RDSZ(0), 0, /* D=<undefined> */
220: RDSZ(0), 0, /* E=<undefined> */
221: RDSZ(0), 0, /* F=<undefined> */
222: RDSZ(0), 0, /* G=<undefined> */
223: RDSZ(0), 0, /* H=<undefined> */
224: }, rd9122S_sizes[8] = {
225: RDSZ(0), 0, /* A=<undefined> */
226: RDSZ(0), 0, /* B=<undefined> */
227: RDSZ(1232), 0, /* C=cyl 0 thru 76 */
228: RDSZ(0), 0, /* D=<undefined> */
229: RDSZ(0), 0, /* E=<undefined> */
230: RDSZ(0), 0, /* F=<undefined> */
231: RDSZ(0), 0, /* G=<undefined> */
232: RDSZ(0), 0, /* H=<undefined> */
233: }, rd7912P_sizes[8] = {
234: RDSZ(15904), 0, /* A=cyl 1 thru 71 */
235: RDSZ(22400), 72, /* B=cyl 72 thru 171 */
236: RDSZ(128128), 0, /* C=cyl 0 thru 571 */
237: RDSZ(42560), 72, /* D=cyl 72 thru 261 */
238: RDSZ(0), 292, /* E=<undefined> */
239: RDSZ(0), 542, /* F=<undefined> */
240: RDSZ(89600), 172, /* G=cyl 221 thru 571 */
241: RDSZ(69440), 262, /* H=cyl 262 thru 571 */
242: }, rd7914P_sizes[8] = {
243: RDSZ(15904), 1, /* A=cyl 1 thru 71 */
244: RDSZ(40320), 72, /* B=cyl 72 thru 251 */
245: RDSZ(258048), 0, /* C=cyl 0 thru 1151 */
246: RDSZ(64960), 72, /* D=cyl 72 thru 361 */
247: RDSZ(98560), 362, /* E=cyl 362 thru 801 */
248: RDSZ(78400), 802, /* F=cyl 802 thru 1151 */
249: RDSZ(201600), 252, /* G=cyl 221 thru 1151 */
250: RDSZ(176960), 362, /* H=cyl 362 thru 1151 */
251: }, rd7933H_sizes[8] = {
252: RDSZ(16146), 1, /* A=cyl 1 thru 27 */
253: RDSZ(66976), 28, /* B=cyl 28 thru 139 */
254: RDSZ(789958), 0, /* C=cyl 0 thru 1320 */
255: RDSZ(16146), 140, /* D=cyl 140 thru 166 */
256: RDSZ(165646), 167, /* E=cyl 167 thru 443 */
257: RDSZ(165646), 444, /* F=cyl 444 thru 720 */
258: RDSZ(706238), 140, /* G=cyl 140 thru 1320 */
259: RDSZ(358800), 721, /* H=cyl 721 thru 1320 */
260: }, rd9134L_sizes[8] = {
261: RDSZ(15920), 1, /* A=cyl 1 thru 199 */
262: RDSZ(20000), 200, /* B=cyl 200 thru 449 */
263: RDSZ(77840), 0, /* C=cyl 0 thru 972 */
264: RDSZ(32000), 200, /* D=cyl 200 thru 599 */
265: RDSZ(0), 0, /* E=<undefined> */
266: RDSZ(0), 0, /* F=<undefined> */
267: RDSZ(41840), 450, /* G=cyl 450 thru 972 */
268: RDSZ(29840), 600, /* H=cyl 600 thru 972 */
269: }, rd7957A_sizes[8] = {
270: RDSZ(16016), 1, /* A=cyl 1 thru 104 */
271: RDSZ(24640), 105, /* B=cyl 105 thru 264 */
272: RDSZ(159544), 0, /* C=cyl 0 thru 1035 */
273: RDSZ(42350), 105, /* D=cyl 105 thru 379 */
274: RDSZ(54824), 380, /* E=cyl 380 thru 735 */
275: RDSZ(46200), 736, /* F=cyl 736 thru 1035 */
276: RDSZ(118734), 265, /* G=cyl 265 thru 1035 */
277: RDSZ(101024), 380, /* H=cyl 380 thru 1035 */
278: }, rd7958A_sizes[8] = {
279: RDSZ(16128), 1, /* A=cyl 1 thru 64 */
280: RDSZ(32256), 65, /* B=cyl 65 thru 192 */
281: RDSZ(255276), 0, /* C=cyl 0 thru 1012 */
282: RDSZ(48384), 65, /* D=cyl 65 thru 256 */
283: RDSZ(100800), 257, /* E=cyl 257 thru 656 */
284: RDSZ(89712), 657, /* F=cyl 657 thru 1012 */
285: RDSZ(206640), 193, /* G=cyl 193 thru 1012 */
286: RDSZ(190512), 257, /* H=cyl 257 thru 1012 */
287: }, rd7957B_sizes[8] = {
288: RDSZ(16002), 1, /* A=cyl 1 thru 127 */
289: RDSZ(32760), 128, /* B=cyl 128 thru 387 */
290: RDSZ(159894), 0, /* C=cyl 0 thru 1268 */
291: RDSZ(49140), 128, /* D=cyl 128 thru 517 */
292: RDSZ(50400), 518, /* E=cyl 518 thru 917 */
293: RDSZ(44226), 918, /* F=cyl 918 thru 1268 */
294: RDSZ(111006), 388, /* G=cyl 388 thru 1268 */
295: RDSZ(94626), 518, /* H=cyl 518 thru 1268 */
296: }, rd7958B_sizes[8] = {
297: RDSZ(16254), 1, /* A=cyl 1 thru 43 */
298: RDSZ(32886), 44, /* B=cyl 44 thru 130 */
299: RDSZ(297108), 0, /* C=cyl 0 thru 785 */
300: RDSZ(49140), 44, /* D=cyl 44 thru 173 */
301: RDSZ(121716), 174, /* E=cyl 174 thru 495 */
302: RDSZ(109620), 496, /* F=cyl 496 thru 785 */
303: RDSZ(247590), 131, /* G=cyl 131 thru 785 */
304: RDSZ(231336), 174, /* H=cyl 174 thru 785 */
305: }, rd7959B_sizes[8] = {
306: RDSZ(16254), 1, /* A=cyl 1 thru 43 */
307: RDSZ(49140), 44, /* B=cyl 44 thru 173 */
308: RDSZ(594216), 0, /* C=cyl 0 thru 1571 */
309: RDSZ(65772), 44, /* D=cyl 44 thru 217 */
310: RDSZ(303912), 218, /* E=cyl 218 thru 1021 */
311: RDSZ(207900), 1022, /* F=cyl 1022 thru 1571 */
312: RDSZ(528444), 174, /* G=cyl 174 thru 1571 */
313: RDSZ(511812), 218, /* H=cyl 218 thru 1571 */
314: }, rd2200A_sizes[8] = {
315: RDSZ(16272), 1, /* A=cyl 1 thru 36 */
316: RDSZ(49720), 37, /* B=cyl 37 thru 146 */
317: RDSZ(654948), 0, /* C=cyl 0 thru 1448 */
318: RDSZ(65992), 37, /* D=cyl 37 thru 182 */
319: RDSZ(304648), 183, /* E=cyl 183 thru 856 */
320: RDSZ(267584), 857, /* F=cyl 857 thru 1448 */
321: RDSZ(588504), 147, /* G=cyl 147 thru 1448 */
322: RDSZ(572232), 183, /* H=cyl 183 thru 1448 */
323: }, rd2203A_sizes[8] = {
324: /* modelled after the 7937; i.e. bogus */
325: RDSZ(16272), 1, /* A=cyl 1 thru 18 */
326: RDSZ(67800), 19, /* B=cyl 19 thru 93 */
327: RDSZ(1309896), 0, /* C=cyl 0 thru 1448 */
328: RDSZ(16272), 94, /* D=cyl 19 thru 111 */
329: RDSZ(305552), 112, /* E=cyl 112 thru 449 */
330: RDSZ(305552), 450, /* F=cyl 450 thru 787 */
331: RDSZ(1224920), 94, /* G=cyl 94 thru 1448 */
332: RDSZ(597544), 788, /* H=cyl 788 thru 1448 */
333:
334: #if DEV_BSIZE == 512
335: /*
336: * These values would not work for 1k,
337: * since the number of cylinders would be different.
338: */
339: }, rd7936H_sizes[8] = {
340: RDSZ(16359), 1, /* A=cyl 1 thru 19 */
341: RDSZ(67158), 20, /* B=cyl 20 thru 97 */
342: RDSZ(600978), 0, /* C=cyl 0 thru 697 */
343: RDSZ(16359), 98, /* D=cyl 98 thru 116 */
344: RDSZ(120540), 117, /* E=cyl 117 thru 256 */
345: RDSZ(120540), 256, /* F=cyl 256 thru 396 */
346: RDSZ(516600), 98, /* G=cyl 98 thru 697 */
347: RDSZ(259161), 397, /* H=cyl 397 thru 697 */
348: }, rd7937H_sizes[8] = {
349: #ifdef UTAH
350: RDSZ(15990), 1, /* A=cyl 1 thru 10 */
351: RDSZ(67158), 11, /* B=cyl 11 thru 52 */
352: RDSZ(1116102), 0, /* C=cyl 0 thru 697 */
353: RDSZ(124722), 53, /* D=cyl 53 thru 130 */
354: RDSZ(163098), 131, /* E=cyl 131 thru 232 */
355: RDSZ(287820), 233, /* F=cyl 233 thru 412 */
356: RDSZ(1031355), 53, /* G=cyl 53 thru 697 */
357: RDSZ(455715), 413, /* H=cyl 413 thru 697 */
358: #else
359: RDSZ(15990), 1, /* A=cyl 1 thru 10 */
360: RDSZ(67158), 11, /* B=cyl 11 thru 52 */
361: RDSZ(1116102), 0, /* C=cyl 0 thru 697 */
362: RDSZ(15990), 53, /* D=cyl 53 thru 62 */
363: RDSZ(246246), 63, /* E=cyl 63 thru 216 */
364: RDSZ(246246), 217, /* F=cyl 217 thru 370 */
365: RDSZ(1031355), 53, /* G=cyl 53 thru 697 */
366: RDSZ(522873), 371, /* H=cyl 371 thru 697 */
367: #endif
368: #endif
369: };
370:
371: struct rdinfo {
372: int nbpt; /* DEV_BSIZE blocks per track */
373: int ntpc; /* tracks per cylinder */
374: int nbpc; /* blocks per cylinder */
375: struct size *sizes; /* default partition info (if no disklabel) */
376: short hwid; /* 2 byte HW id */
377: short maxunum; /* maximum allowed unit number */
378: char *desc; /* drive type description */
379: };
380:
381: struct rdinfo rdinfo[] = {
382: NRD7945ABPT, NRD7945ATRK, NRD7945ABPT * NRD7945ATRK,
383: rd7945A_sizes, RD7946AID, 0, "7945A",
384: NRD9134DBPT, NRD9134DTRK, NRD9134DBPT * NRD9134DTRK,
385: rd9134D_sizes, RD9134DID, 1, "9134D",
386: NRD9122SBPT, NRD9122STRK, NRD9122SBPT * NRD9122STRK,
387: rd9122S_sizes, RD9134LID, 1, "9122S",
388: NRD7912PBPT, NRD7912PTRK, NRD7912PBPT * NRD7912PTRK,
389: rd7912P_sizes, RD7912PID, 0, "7912P",
390: NRD7914PBPT, NRD7914PTRK, NRD7914PBPT * NRD7914PTRK,
391: rd7914P_sizes, RD7914PID, 0, "7914P",
392: NRD7958ABPT, NRD7958ATRK, NRD7958ABPT * NRD7958ATRK,
393: rd7958A_sizes, RD7958AID, 0, "7958A",
394: NRD7957ABPT, NRD7957ATRK, NRD7957ABPT * NRD7957ATRK,
395: rd7957A_sizes, RD7957AID, 0, "7957A",
396: NRD7933HBPT, NRD7933HTRK, NRD7933HBPT * NRD7933HTRK,
397: rd7933H_sizes, RD7933HID, 0, "7933H",
398: NRD9134LBPT, NRD9134LTRK, NRD9134LBPT * NRD9134LTRK,
399: rd9134L_sizes, RD9134LID, 1, "9134L",
400: NRD7936HBPT, NRD7936HTRK, NRD7936HBPT * NRD7936HTRK,
401: rd7936H_sizes, RD7936HID, 0, "7936H",
402: NRD7937HBPT, NRD7937HTRK, NRD7937HBPT * NRD7937HTRK,
403: rd7937H_sizes, RD7937HID, 0, "7937H",
404: NRD7914PBPT, NRD7914PTRK, NRD7914PBPT * NRD7914PTRK,
405: rd7914P_sizes, RD7914CTID, 0, "7914CT",
406: NRD7945ABPT, NRD7945ATRK, NRD7945ABPT * NRD7945ATRK,
407: rd7945A_sizes, RD7946AID, 0, "7946A",
408: NRD9122SBPT, NRD9122STRK, NRD9122SBPT * NRD9122STRK,
409: rd9122S_sizes, RD9134LID, 1, "9122D",
410: NRD7957BBPT, NRD7957BTRK, NRD7957BBPT * NRD7957BTRK,
411: rd7957B_sizes, RD7957BID, 0, "7957B",
412: NRD7958BBPT, NRD7958BTRK, NRD7958BBPT * NRD7958BTRK,
413: rd7958B_sizes, RD7958BID, 0, "7958B",
414: NRD7959BBPT, NRD7959BTRK, NRD7959BBPT * NRD7959BTRK,
415: rd7959B_sizes, RD7959BID, 0, "7959B",
416: NRD2200ABPT, NRD2200ATRK, NRD2200ABPT * NRD2200ATRK,
417: rd2200A_sizes, RD2200AID, 0, "2200A",
418: NRD2203ABPT, NRD2203ATRK, NRD2203ABPT * NRD2203ATRK,
419: rd2203A_sizes, RD2203AID, 0, "2203A",
420: };
421: int nrdinfo = sizeof(rdinfo) / sizeof(rdinfo[0]);
422:
423: struct buf rdtab[NRD];
424:
425: #define rdunit(x) (minor(x) >> 3)
426: #define rdpart(x) (minor(x) & 0x7)
427: #define rdpunit(x) ((x) & 7)
428: #define b_cylin b_resid
429: #define RDRETRY 5
430: #define RDWAITC 1 /* min time for timeout in seconds */
431:
432: int rderrthresh = RDRETRY-1; /* when to start reporting errors */
433:
434: rdinit(hd)
435: register struct hp_device *hd;
436: {
437: register struct rd_softc *rs = &rd_softc[hd->hp_unit];
438:
439: rs->sc_hd = hd;
440: rs->sc_punit = rdpunit(hd->hp_flags);
441: rs->sc_type = rdident(rs, hd);
442: if (rs->sc_type < 0)
443: return(0);
444: rs->sc_dq.dq_ctlr = hd->hp_ctlr;
445: rs->sc_dq.dq_unit = hd->hp_unit;
446: rs->sc_dq.dq_slave = hd->hp_slave;
447: rs->sc_dq.dq_driver = &rddriver;
448: rs->sc_info = &rdinfo[rs->sc_type];
449: rs->sc_flags = RDF_ALIVE;
450: #ifdef DEBUG
451: /* always report errors */
452: if (rddebug & RDB_ERROR)
453: rderrthresh = 0;
454: #endif
455: return(1);
456: }
457:
458: rdident(rs, hd)
459: struct rd_softc *rs;
460: struct hp_device *hd;
461: {
462: struct rd_describe desc;
463: u_char stat, cmd[3];
464: int unit, lunit;
465: char name[7];
466: register int ctlr, slave, id, i;
467:
468: ctlr = hd->hp_ctlr;
469: slave = hd->hp_slave;
470: unit = rs->sc_punit;
471: lunit = hd->hp_unit;
472:
473: /*
474: * Grab device id and make sure:
475: * 1. It is a CS80 device.
476: * 2. It is one of the types we support.
477: * 3. If it is a 7946, we are accessing the disk unit (0)
478: */
479: id = hpibid(ctlr, slave);
480: #ifdef DEBUG
481: if (rddebug & RDB_IDENT)
482: printf("hpibid(%d, %d) -> %x\n", ctlr, slave, id);
483: #endif
484: if ((id & 0x200) == 0)
485: return(-1);
486: for (i = 0; i < nrdinfo; i++)
487: if (id == rdinfo[i].hwid)
488: break;
489: if (i == nrdinfo || unit > rdinfo[i].maxunum)
490: return(-1);
491: id = i;
492:
493: /*
494: * Reset drive and collect device description.
495: * Don't really use the description info right now but
496: * might come in handy in the future (for disk labels).
497: */
498: rdreset(rs, hd);
499: cmd[0] = C_SUNIT(unit);
500: cmd[1] = C_SVOL(0);
501: cmd[2] = C_DESC;
502: hpibsend(ctlr, slave, C_CMD, cmd, sizeof(cmd));
503: hpibrecv(ctlr, slave, C_EXEC, &desc, 37);
504: hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
505: bzero(name, sizeof(name));
506: if (!stat) {
507: register int n = desc.d_name;
508: for (i = 5; i >= 0; i--) {
509: name[i] = (n & 0xf) + '0';
510: n >>= 4;
511: }
512: /* use drive characteristics to calculate xfer rate */
513: rs->sc_wpms = 1000000 * (desc.d_sectsize/2) / desc.d_blocktime;
514: }
515: #ifdef DEBUG
516: if (rddebug & RDB_IDENT) {
517: printf("rd%d: name: %x ('%s')\n",
518: lunit, desc.d_name, name);
519: printf(" iuw %x, maxxfr %d, ctype %d\n",
520: desc.d_iuw, desc.d_cmaxxfr, desc.d_ctype);
521: printf(" utype %d, bps %d, blkbuf %d, burst %d, blktime %d\n",
522: desc.d_utype, desc.d_sectsize,
523: desc.d_blkbuf, desc.d_burstsize, desc.d_blocktime);
524: printf(" avxfr %d, ort %d, atp %d, maxint %d, fv %x, rv %x\n",
525: desc.d_uavexfr, desc.d_retry, desc.d_access,
526: desc.d_maxint, desc.d_fvbyte, desc.d_rvbyte);
527: printf(" maxcyl/head/sect %d/%d/%d, maxvsect %d, inter %d\n",
528: desc.d_maxcyl, desc.d_maxhead, desc.d_maxsect,
529: desc.d_maxvsectl, desc.d_interleave);
530: }
531: #endif
532: /*
533: * Take care of a couple of anomolies:
534: * 1. 7945A and 7946A both return same HW id
535: * 2. 9122S and 9134D both return same HW id
536: * 3. 9122D and 9134L both return same HW id
537: */
538: switch (rdinfo[id].hwid) {
539: case RD7946AID:
540: if (bcmp(name, "079450", 6) == 0)
541: id = RD7945A;
542: else
543: id = RD7946A;
544: break;
545:
546: case RD9134LID:
547: if (bcmp(name, "091340", 6) == 0)
548: id = RD9134L;
549: else
550: id = RD9122D;
551: break;
552:
553: case RD9134DID:
554: if (bcmp(name, "091220", 6) == 0)
555: id = RD9122S;
556: else
557: id = RD9134D;
558: break;
559: }
560: printf("rd%d: %s\n", lunit, rdinfo[id].desc);
561: return(id);
562: }
563:
564: rdreset(rs, hd)
565: register struct rd_softc *rs;
566: register struct hp_device *hd;
567: {
568: u_char stat;
569:
570: rs->sc_clear.c_unit = C_SUNIT(rs->sc_punit);
571: rs->sc_clear.c_cmd = C_CLEAR;
572: hpibsend(hd->hp_ctlr, hd->hp_slave, C_TCMD, &rs->sc_clear,
573: sizeof(rs->sc_clear));
574: hpibswait(hd->hp_ctlr, hd->hp_slave);
575: hpibrecv(hd->hp_ctlr, hd->hp_slave, C_QSTAT, &stat, sizeof(stat));
576: rs->sc_src.c_unit = C_SUNIT(RDCTLR);
577: rs->sc_src.c_nop = C_NOP;
578: rs->sc_src.c_cmd = C_SREL;
579: rs->sc_src.c_param = C_REL;
580: hpibsend(hd->hp_ctlr, hd->hp_slave, C_CMD, &rs->sc_src,
581: sizeof(rs->sc_src));
582: hpibswait(hd->hp_ctlr, hd->hp_slave);
583: hpibrecv(hd->hp_ctlr, hd->hp_slave, C_QSTAT, &stat, sizeof(stat));
584: rs->sc_ssmc.c_unit = C_SUNIT(rs->sc_punit);
585: rs->sc_ssmc.c_cmd = C_SSM;
586: rs->sc_ssmc.c_refm = REF_MASK;
587: rs->sc_ssmc.c_fefm = FEF_MASK;
588: rs->sc_ssmc.c_aefm = AEF_MASK;
589: rs->sc_ssmc.c_iefm = IEF_MASK;
590: hpibsend(hd->hp_ctlr, hd->hp_slave, C_CMD, &rs->sc_ssmc,
591: sizeof(rs->sc_ssmc));
592: hpibswait(hd->hp_ctlr, hd->hp_slave);
593: hpibrecv(hd->hp_ctlr, hd->hp_slave, C_QSTAT, &stat, sizeof(stat));
594: #ifdef DEBUG
595: rdstats[hd->hp_unit].rdresets++;
596: #endif
597: }
598:
599: int
600: rdopen(dev, flags, mode, p)
601: dev_t dev;
602: int flags, mode;
603: struct proc *p;
604: {
605: register int unit = rdunit(dev);
606: register struct rd_softc *rs = &rd_softc[unit];
607:
608: if (unit >= NRD || (rs->sc_flags & RDF_ALIVE) == 0)
609: return(ENXIO);
610: if (rs->sc_hd->hp_dk >= 0) {
611: /* guess at xfer rate based on 3600 rpm (60 rps) */
612: if (rs->sc_wpms == 0)
613: rs->sc_wpms = 60 * rs->sc_info->nbpt * DEV_BSIZE / 2;
614: dk_wpms[rs->sc_hd->hp_dk] = rs->sc_wpms;
615: }
616: return(0);
617: }
618:
619: rdstrategy(bp)
620: register struct buf *bp;
621: {
622: register int unit = rdunit(bp->b_dev);
623: register struct rd_softc *rs = &rd_softc[unit];
624: register struct size *pinfo = &rs->sc_info->sizes[rdpart(bp->b_dev)];
625: register struct buf *dp = &rdtab[unit];
626: register daddr_t bn;
627: register int sz, s;
628:
629: #ifdef DEBUG
630: if (rddebug & RDB_FOLLOW)
631: printf("rdstrategy(%x): dev %x, bn %x, bcount %x, %c\n",
632: bp, bp->b_dev, bp->b_blkno, bp->b_bcount,
633: (bp->b_flags & B_READ) ? 'R' : 'W');
634: #endif
635: bn = bp->b_blkno;
636: sz = howmany(bp->b_bcount, DEV_BSIZE);
637: if (bn < 0 || bn + sz > pinfo->nblocks) {
638: sz = pinfo->nblocks - bn;
639: if (sz == 0) {
640: bp->b_resid = bp->b_bcount;
641: goto done;
642: }
643: if (sz < 0) {
644: bp->b_error = EINVAL;
645: bp->b_flags |= B_ERROR;
646: goto done;
647: }
648: bp->b_bcount = dbtob(sz);
649: }
650: bp->b_cylin = bn / rs->sc_info->nbpc + pinfo->cyloff;
651: s = splbio();
652: disksort(dp, bp);
653: if (dp->b_active == 0) {
654: dp->b_active = 1;
655: rdustart(unit);
656: }
657: splx(s);
658: return;
659: done:
660: biodone(bp);
661: }
662:
663: /*
664: * Called from timeout() when handling maintenance releases
665: */
666: rdrestart(unit)
667: int unit;
668: {
669: int s = splbio();
670: rdustart(unit);
671: splx(s);
672: }
673:
674: rdustart(unit)
675: register int unit;
676: {
677: register struct buf *bp;
678: register struct rd_softc *rs = &rd_softc[unit];
679:
680: bp = rdtab[unit].b_actf;
681: rs->sc_addr = bp->b_un.b_addr;
682: rs->sc_resid = bp->b_bcount;
683: if (hpibreq(&rs->sc_dq))
684: rdstart(unit);
685: }
686:
687: rdstart(unit)
688: register int unit;
689: {
690: register struct rd_softc *rs = &rd_softc[unit];
691: register struct buf *bp = rdtab[unit].b_actf;
692: register struct hp_device *hp = rs->sc_hd;
693: register int part;
694:
695: again:
696: #ifdef DEBUG
697: if (rddebug & RDB_FOLLOW)
698: printf("rdstart(%d): bp %x, %c\n", unit, bp,
699: (bp->b_flags & B_READ) ? 'R' : 'W');
700: #endif
701: part = rdpart(bp->b_dev);
702: rs->sc_flags |= RDF_SEEK;
703: rs->sc_ioc.c_unit = C_SUNIT(rs->sc_punit);
704: rs->sc_ioc.c_volume = C_SVOL(0);
705: rs->sc_ioc.c_saddr = C_SADDR;
706: rs->sc_ioc.c_hiaddr = 0;
707: rs->sc_ioc.c_addr = RDBTOS(bp->b_blkno + rs->sc_info->nbpc *
708: rs->sc_info->sizes[part].cyloff);
709: rs->sc_ioc.c_nop2 = C_NOP;
710: rs->sc_ioc.c_slen = C_SLEN;
711: rs->sc_ioc.c_len = rs->sc_resid;
712: rs->sc_ioc.c_cmd = bp->b_flags & B_READ ? C_READ : C_WRITE;
713: #ifdef DEBUG
714: if (rddebug & RDB_IO)
715: printf("rdstart: hpibsend(%x, %x, %x, %x, %x)\n",
716: hp->hp_ctlr, hp->hp_slave, C_CMD,
717: &rs->sc_ioc.c_unit, sizeof(rs->sc_ioc)-2);
718: #endif
719: if (hpibsend(hp->hp_ctlr, hp->hp_slave, C_CMD, &rs->sc_ioc.c_unit,
720: sizeof(rs->sc_ioc)-2) == sizeof(rs->sc_ioc)-2) {
721: if (hp->hp_dk >= 0) {
722: dk_busy |= 1 << hp->hp_dk;
723: dk_seek[hp->hp_dk]++;
724: }
725: #ifdef DEBUG
726: if (rddebug & RDB_IO)
727: printf("rdstart: hpibawait(%x)\n", hp->hp_ctlr);
728: #endif
729: hpibawait(hp->hp_ctlr);
730: return;
731: }
732: /*
733: * Experience has shown that the hpibwait in this hpibsend will
734: * occasionally timeout. It appears to occur mostly on old 7914
735: * drives with full maintenance tracks. We should probably
736: * integrate this with the backoff code in rderror.
737: */
738: #ifdef DEBUG
739: if (rddebug & RDB_ERROR)
740: printf("rd%d: rdstart: cmd %x adr %d blk %d len %d ecnt %d\n",
741: unit, rs->sc_ioc.c_cmd, rs->sc_ioc.c_addr,
742: bp->b_blkno, rs->sc_resid, rdtab[unit].b_errcnt);
743: rdstats[unit].rdretries++;
744: #endif
745: rs->sc_flags &= ~RDF_SEEK;
746: rdreset(rs, hp);
747: if (rdtab[unit].b_errcnt++ < RDRETRY)
748: goto again;
749: printf("rd%d: rdstart err: cmd 0x%x sect %d blk %d len %d\n",
750: unit, rs->sc_ioc.c_cmd, rs->sc_ioc.c_addr,
751: bp->b_blkno, rs->sc_resid);
752: rdtab[unit].b_errcnt = 0;
753: rdtab[unit].b_actf = bp->b_actf;
754: bp->b_flags |= B_ERROR;
755: bp->b_error = EIO;
756: bp->b_resid = 0;
757: biodone(bp);
758: hpibfree(&rs->sc_dq);
759: bp = rdtab[unit].b_actf;
760: if (bp == NULL) {
761: rdtab[unit].b_active = 0;
762: return;
763: }
764: rs->sc_addr = bp->b_un.b_addr;
765: rs->sc_resid = bp->b_bcount;
766: if (hpibreq(&rs->sc_dq))
767: goto again;
768: }
769:
770: rdgo(unit)
771: register int unit;
772: {
773: register struct rd_softc *rs = &rd_softc[unit];
774: register struct hp_device *hp = rs->sc_hd;
775: struct buf *bp = rdtab[unit].b_actf;
776:
777: if (hp->hp_dk >= 0) {
778: dk_busy |= 1 << hp->hp_dk;
779: dk_xfer[hp->hp_dk]++;
780: dk_wds[hp->hp_dk] += rs->sc_resid >> 6;
781: }
782: hpibgo(hp->hp_ctlr, hp->hp_slave, C_EXEC,
783: rs->sc_addr, rs->sc_resid, bp->b_flags & B_READ);
784: }
785:
786: rdintr(unit)
787: register int unit;
788: {
789: register struct rd_softc *rs = &rd_softc[unit];
790: register struct buf *bp = rdtab[unit].b_actf;
791: register struct hp_device *hp = rs->sc_hd;
792: u_char stat = 13; /* in case hpibrecv fails */
793: int rv, restart;
794:
795: #ifdef DEBUG
796: if (rddebug & RDB_FOLLOW)
797: printf("rdintr(%d): bp %x, %c, flags %x\n", unit, bp,
798: (bp->b_flags & B_READ) ? 'R' : 'W', rs->sc_flags);
799: if (bp == NULL) {
800: printf("rd%d: bp == NULL\n", unit);
801: return;
802: }
803: #endif
804: if (hp->hp_dk >= 0)
805: dk_busy &= ~(1 << hp->hp_dk);
806: if (rs->sc_flags & RDF_SEEK) {
807: rs->sc_flags &= ~RDF_SEEK;
808: if (hpibustart(hp->hp_ctlr))
809: rdgo(unit);
810: return;
811: }
812: if ((rs->sc_flags & RDF_SWAIT) == 0) {
813: #ifdef DEBUG
814: rdstats[unit].rdpolltries++;
815: #endif
816: if (hpibpptest(hp->hp_ctlr, hp->hp_slave) == 0) {
817: #ifdef DEBUG
818: rdstats[unit].rdpollwaits++;
819: #endif
820: if (hp->hp_dk >= 0)
821: dk_busy |= 1 << hp->hp_dk;
822: rs->sc_flags |= RDF_SWAIT;
823: hpibawait(hp->hp_ctlr);
824: return;
825: }
826: } else
827: rs->sc_flags &= ~RDF_SWAIT;
828: rv = hpibrecv(hp->hp_ctlr, hp->hp_slave, C_QSTAT, &stat, 1);
829: if (rv != 1 || stat) {
830: #ifdef DEBUG
831: if (rddebug & RDB_ERROR)
832: printf("rdintr: recv failed or bad stat %d\n", stat);
833: #endif
834: restart = rderror(unit);
835: #ifdef DEBUG
836: rdstats[unit].rdretries++;
837: #endif
838: if (rdtab[unit].b_errcnt++ < RDRETRY) {
839: if (restart)
840: rdstart(unit);
841: return;
842: }
843: bp->b_flags |= B_ERROR;
844: bp->b_error = EIO;
845: }
846: rdtab[unit].b_errcnt = 0;
847: rdtab[unit].b_actf = bp->b_actf;
848: bp->b_resid = 0;
849: biodone(bp);
850: hpibfree(&rs->sc_dq);
851: if (rdtab[unit].b_actf)
852: rdustart(unit);
853: else
854: rdtab[unit].b_active = 0;
855: }
856:
857: rdstatus(rs)
858: register struct rd_softc *rs;
859: {
860: register int c, s;
861: u_char stat;
862: int rv;
863:
864: c = rs->sc_hd->hp_ctlr;
865: s = rs->sc_hd->hp_slave;
866: rs->sc_rsc.c_unit = C_SUNIT(rs->sc_punit);
867: rs->sc_rsc.c_sram = C_SRAM;
868: rs->sc_rsc.c_ram = C_RAM;
869: rs->sc_rsc.c_cmd = C_STATUS;
870: bzero((caddr_t)&rs->sc_stat, sizeof(rs->sc_stat));
871: rv = hpibsend(c, s, C_CMD, &rs->sc_rsc, sizeof(rs->sc_rsc));
872: if (rv != sizeof(rs->sc_rsc)) {
873: #ifdef DEBUG
874: if (rddebug & RDB_STATUS)
875: printf("rdstatus: send C_CMD failed %d != %d\n",
876: rv, sizeof(rs->sc_rsc));
877: #endif
878: return(1);
879: }
880: rv = hpibrecv(c, s, C_EXEC, &rs->sc_stat, sizeof(rs->sc_stat));
881: if (rv != sizeof(rs->sc_stat)) {
882: #ifdef DEBUG
883: if (rddebug & RDB_STATUS)
884: printf("rdstatus: send C_EXEC failed %d != %d\n",
885: rv, sizeof(rs->sc_stat));
886: #endif
887: return(1);
888: }
889: rv = hpibrecv(c, s, C_QSTAT, &stat, 1);
890: if (rv != 1 || stat) {
891: #ifdef DEBUG
892: if (rddebug & RDB_STATUS)
893: printf("rdstatus: recv failed %d or bad stat %d\n",
894: rv, stat);
895: #endif
896: return(1);
897: }
898: return(0);
899: }
900:
901: /*
902: * Deal with errors.
903: * Returns 1 if request should be restarted,
904: * 0 if we should just quietly give up.
905: */
906: rderror(unit)
907: int unit;
908: {
909: struct rd_softc *rs = &rd_softc[unit];
910: register struct rd_stat *sp;
911: struct buf *bp;
912: daddr_t hwbn, pbn;
913:
914: if (rdstatus(rs)) {
915: #ifdef DEBUG
916: printf("rd%d: couldn't get status\n", unit);
917: #endif
918: rdreset(rs, rs->sc_hd);
919: return(1);
920: }
921: sp = &rs->sc_stat;
922: if (sp->c_fef & FEF_REXMT)
923: return(1);
924: if (sp->c_fef & FEF_PF) {
925: rdreset(rs, rs->sc_hd);
926: return(1);
927: }
928: /*
929: * Unit requests release for internal maintenance.
930: * We just delay awhile and try again later. Use expontially
931: * increasing backoff ala ethernet drivers since we don't really
932: * know how long the maintenance will take. With RDWAITC and
933: * RDRETRY as defined, the range is 1 to 32 seconds.
934: */
935: if (sp->c_fef & FEF_IMR) {
936: extern int hz;
937: int rdtimo = RDWAITC << rdtab[unit].b_errcnt;
938: #ifdef DEBUG
939: printf("rd%d: internal maintenance, %d second timeout\n",
940: unit, rdtimo);
941: rdstats[unit].rdtimeouts++;
942: #endif
943: hpibfree(&rs->sc_dq);
944: timeout(rdrestart, unit, rdtimo*hz);
945: return(0);
946: }
947: /*
948: * Only report error if we have reached the error reporting
949: * threshhold. By default, this will only report after the
950: * retry limit has been exceeded.
951: */
952: if (rdtab[unit].b_errcnt < rderrthresh)
953: return(1);
954:
955: /*
956: * First conjure up the block number at which the error occured.
957: * Note that not all errors report a block number, in that case
958: * we just use b_blkno.
959: */
960: bp = rdtab[unit].b_actf;
961: pbn = rs->sc_info->nbpc *
962: rs->sc_info->sizes[rdpart(bp->b_dev)].cyloff;
963: if ((sp->c_fef & FEF_CU) || (sp->c_fef & FEF_DR) ||
964: (sp->c_ief & IEF_RRMASK)) {
965: hwbn = RDBTOS(pbn + bp->b_blkno);
966: pbn = bp->b_blkno;
967: } else {
968: hwbn = sp->c_blk;
969: pbn = RDSTOB(hwbn) - pbn;
970: }
971: /*
972: * Now output a generic message suitable for badsect.
973: * Note that we don't use harderr cuz it just prints
974: * out b_blkno which is just the beginning block number
975: * of the transfer, not necessary where the error occured.
976: */
977: printf("rd%d%c: hard error sn%d\n",
978: rdunit(bp->b_dev), 'a'+rdpart(bp->b_dev), pbn);
979: /*
980: * Now report the status as returned by the hardware with
981: * attempt at interpretation (unless debugging).
982: */
983: printf("rd%d %s error:",
984: unit, (bp->b_flags & B_READ) ? "read" : "write");
985: #ifdef DEBUG
986: if (rddebug & RDB_ERROR) {
987: /* status info */
988: printf("\n volume: %d, unit: %d\n",
989: (sp->c_vu>>4)&0xF, sp->c_vu&0xF);
990: rdprinterr("reject", sp->c_ref, err_reject);
991: rdprinterr("fault", sp->c_fef, err_fault);
992: rdprinterr("access", sp->c_aef, err_access);
993: rdprinterr("info", sp->c_ief, err_info);
994: printf(" block: %d, P1-P10: ", hwbn);
995: printf("%s", hexstr(*(u_int *)&sp->c_raw[0], 8));
996: printf("%s", hexstr(*(u_int *)&sp->c_raw[4], 8));
997: printf("%s\n", hexstr(*(u_short *)&sp->c_raw[8], 4));
998: /* command */
999: printf(" ioc: ");
1000: printf("%s", hexstr(*(u_int *)&rs->sc_ioc.c_pad, 8));
1001: printf("%s", hexstr(*(u_short *)&rs->sc_ioc.c_hiaddr, 4));
1002: printf("%s", hexstr(*(u_int *)&rs->sc_ioc.c_addr, 8));
1003: printf("%s", hexstr(*(u_short *)&rs->sc_ioc.c_nop2, 4));
1004: printf("%s", hexstr(*(u_int *)&rs->sc_ioc.c_len, 8));
1005: printf("%s\n", hexstr(*(u_short *)&rs->sc_ioc.c_cmd, 4));
1006: return(1);
1007: }
1008: #endif
1009: printf(" v%d u%d, R0x%x F0x%x A0x%x I0x%x\n",
1010: (sp->c_vu>>4)&0xF, sp->c_vu&0xF,
1011: sp->c_ref, sp->c_fef, sp->c_aef, sp->c_ief);
1012: printf("P1-P10: ");
1013: printf("%s", hexstr(*(u_int *)&sp->c_raw[0], 8));
1014: printf("%s", hexstr(*(u_int *)&sp->c_raw[4], 8));
1015: printf("%s\n", hexstr(*(u_short *)&sp->c_raw[8], 4));
1016: return(1);
1017: }
1018:
1019: int
1020: rdread(dev, uio, flags)
1021: dev_t dev;
1022: struct uio *uio;
1023: int flags;
1024: {
1025: register int unit = rdunit(dev);
1026:
1027: return (physio(rdstrategy, NULL, dev, B_READ, minphys, uio));
1028: }
1029:
1030: int
1031: rdwrite(dev, uio, flags)
1032: dev_t dev;
1033: struct uio *uio;
1034: int flags;
1035: {
1036: register int unit = rdunit(dev);
1037:
1038: return (physio(rdstrategy, NULL, dev, B_WRITE, minphys, uio));
1039: }
1040:
1041: int
1042: rdioctl(dev, cmd, data, flag, p)
1043: dev_t dev;
1044: int cmd;
1045: caddr_t data;
1046: int flag;
1047: struct proc *p;
1048: {
1049: return(EINVAL);
1050: }
1051:
1052: int
1053: rdsize(dev)
1054: dev_t dev;
1055: {
1056: register int unit = rdunit(dev);
1057: register struct rd_softc *rs = &rd_softc[unit];
1058:
1059: if (unit >= NRD || (rs->sc_flags & RDF_ALIVE) == 0)
1060: return(-1);
1061: return(rs->sc_info->sizes[rdpart(dev)].nblocks);
1062: }
1063:
1064: #ifdef DEBUG
1065: rdprinterr(str, err, tab)
1066: char *str;
1067: short err;
1068: char *tab[];
1069: {
1070: register int i;
1071: int printed;
1072:
1073: if (err == 0)
1074: return;
1075: printf(" %s error field:", str, err);
1076: printed = 0;
1077: for (i = 0; i < 16; i++)
1078: if (err & (0x8000 >> i))
1079: printf("%s%s", printed++ ? " + " : " ", tab[i]);
1080: printf("\n");
1081: }
1082: #endif
1083:
1084: /*
1085: * Non-interrupt driven, non-dma dump routine.
1086: */
1087: int
1088: rddump(dev)
1089: dev_t dev;
1090: {
1091: int part = rdpart(dev);
1092: int unit = rdunit(dev);
1093: register struct rd_softc *rs = &rd_softc[unit];
1094: register struct hp_device *hp = rs->sc_hd;
1095: register daddr_t baddr;
1096: register int maddr, pages, i;
1097: char stat;
1098: extern int lowram, dumpsize;
1099: #ifdef DEBUG
1100: extern int pmapdebug;
1101: pmapdebug = 0;
1102: #endif
1103:
1104: pages = dumpsize;
1105: #ifdef DEBUG
1106: if (rddebug & RDB_DUMP)
1107: printf("rddump(%x): u %d p %d dumplo %d ram %x pmem %d\n",
1108: dev, unit, part, dumplo, lowram, ctod(pages));
1109: #endif
1110: /* is drive ok? */
1111: if (unit >= NRD || (rs->sc_flags & RDF_ALIVE) == 0)
1112: return (ENXIO);
1113: /* HPIB idle? */
1114: if (!hpibreq(&rs->sc_dq)) {
1115: #ifdef DEBUG
1116: /* is this a safe thing to do?? */
1117: hpibreset(hp->hp_ctlr);
1118: rdreset(rs, rs->sc_hd);
1119: printf("[ drive %d reset ] ", unit);
1120: #else
1121: return (EFAULT);
1122: #endif
1123: }
1124: /* dump parameters in range? */
1125: if (dumplo < 0 || dumplo >= rs->sc_info->sizes[part].nblocks)
1126: return (EINVAL);
1127: if (dumplo + ctod(pages) > rs->sc_info->sizes[part].nblocks)
1128: pages = dtoc(rs->sc_info->sizes[part].nblocks - dumplo);
1129: maddr = lowram;
1130: baddr = dumplo + rs->sc_info->nbpc * rs->sc_info->sizes[part].cyloff;
1131: #ifdef DEBUG
1132: if (rddebug & RDB_DUMP)
1133: printf("rddump: dumping %d pages from %x to disk block %d\n",
1134: pages, maddr, baddr);
1135: #endif
1136: for (i = 0; i < pages; i++) {
1137: #ifdef DEBUG
1138: #define NPGMB (1024*1024/NBPG)
1139: /* print out how many Mbs we have dumped */
1140: if (i && (i % NPGMB) == 0)
1141: printf("%d ", i / NPGMB);
1142: #undef NPBMG
1143: #endif
1144: rs->sc_ioc.c_unit = C_SUNIT(rs->sc_punit);
1145: rs->sc_ioc.c_volume = C_SVOL(0);
1146: rs->sc_ioc.c_saddr = C_SADDR;
1147: rs->sc_ioc.c_hiaddr = 0;
1148: rs->sc_ioc.c_addr = RDBTOS(baddr);
1149: rs->sc_ioc.c_nop2 = C_NOP;
1150: rs->sc_ioc.c_slen = C_SLEN;
1151: rs->sc_ioc.c_len = NBPG;
1152: rs->sc_ioc.c_cmd = C_WRITE;
1153: hpibsend(hp->hp_ctlr, hp->hp_slave, C_CMD,
1154: &rs->sc_ioc.c_unit, sizeof(rs->sc_ioc)-2);
1155: if (hpibswait(hp->hp_ctlr, hp->hp_slave)) {
1156: #ifdef DEBUG
1157: if (rddebug & RDB_DUMP)
1158: printf("rddump: IOC wait timeout\n");
1159: #endif
1160: return (EIO);
1161: }
1162: pmap_enter(pmap_kernel(), vmmap, maddr, VM_PROT_READ, TRUE);
1163: hpibsend(hp->hp_ctlr, hp->hp_slave, C_EXEC, vmmap, NBPG);
1164: if (hpibswait(hp->hp_ctlr, hp->hp_slave)) {
1165: #ifdef DEBUG
1166: if (rddebug & RDB_DUMP)
1167: printf("rddump: write wait timeout\n");
1168: #endif
1169: }
1170: hpibrecv(hp->hp_ctlr, hp->hp_slave, C_QSTAT, &stat, 1);
1171: if (stat) {
1172: #ifdef DEBUG
1173: if (rddebug & RDB_DUMP)
1174: printf("rddump: write failed, status %x\n",
1175: stat);
1176: #endif
1177: return (EIO);
1178: }
1179: maddr += NBPG;
1180: baddr += ctod(1);
1181: }
1182: return (0);
1183: }
1184: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.