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