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