* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1990 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* from: Utah $Hdr: rd.c 1.38 90/10/12$
* @(#)rd.c 7.9 (Berkeley) 5/7/91
#include "sys/disklabel.h"
#include "vm/vm_statistics.h"
int rdinit(), rdstart(), rdgo(), rdintr();
struct driver rddriver
= {
rdinit
, "rd", rdstart
, rdgo
, rdintr
,
struct rd_ssmcmd sc_ssmc
;
struct rd_clearcmd sc_clear
;
#define RDB_DUMP 0x80000000
/* error message tables */
"channel parity error", /* 0x2000 */
"illegal opcode", /* 0x0400 */
"module addressing", /* 0x0200 */
"address bounds", /* 0x0100 */
"parameter bounds", /* 0x0080 */
"illegal parameter", /* 0x0040 */
"message sequence", /* 0x0020 */
"message length", /* 0x0008 */
"cross unit", /* 0x4000 */
"controller fault", /* 0x1000 */
"unit fault", /* 0x0200 */
"diagnostic result", /* 0x0080 */
"operator release request", /* 0x0020 */
"diagnostic release request", /* 0x0010 */
"internal maintenance release request", /* 0x0008 */
"power fail", /* 0x0002 */
"retransmit" /* 0x0001 */
"illegal parallel operation", /* 0x8000 */
"uninitialized media", /* 0x4000 */
"no spares available", /* 0x2000 */
"not ready", /* 0x1000 */
"write protect", /* 0x0800 */
"no data found", /* 0x0400 */
"unrecoverable data overflow", /* 0x0080 */
"unrecoverable data", /* 0x0040 */
"end of file", /* 0x0010 */
"end of volume", /* 0x0008 */
"operator release request", /* 0x8000 */
"diagnostic release request", /* 0x4000 */
"internal maintenance release request", /* 0x2000 */
"media wear", /* 0x1000 */
"latency induced", /* 0x0800 */
"auto sparing invoked", /* 0x0100 */
"recoverable data overflow", /* 0x0040 */
"marginal data", /* 0x0020 */
"recoverable data", /* 0x0010 */
"maintenance track overflow", /* 0x0004 */
* CS/80 partitions. We reserve the first cylinder for a LIF
* style boot directory (the 8k allowed in the BSD filesystem
* is just way too small). This boot area is outside of all but
* the C partition. This implies that you cannot use the C
* partition on a bootable disk since the filesystem would overlay
* the boot area. You must use the A partition.
* These maps support four basic layouts:
* A/B/G: This is the "traditional" setup for a bootable disk.
* A is the root partition, B the swap, and G a user partition.
* A/D/H: This is a setup for bootable systems requiring more swap
* (e.g. those who use HPCL). It has A as the root, D as a
* larger swap, and H as a smaller user partition.
* A/D/E/F: Similar to A/D/H with E and F breaking H into two partitions.
* E could be used for /usr and F for users.
* C: This gives a single, non-bootable, large user filesystem.
* Good for second drives on a machine (e.g. /usr/src).
struct size rd7945A_sizes
[8] = {
RDSZ(15904), 1, /* A=cyl 1 thru 142 */
RDSZ(20160), 143, /* B=cyl 143 thru 322 */
RDSZ(108416), 0, /* C=cyl 0 thru 967 */
RDSZ(40320), 143, /* D=cyl 143 thru 502 */
RDSZ(0), 0, /* E=<undefined> */
RDSZ(0), 0, /* F=<undefined> */
RDSZ(72240), 323, /* G=cyl 323 thru 967 */
RDSZ(52080), 503, /* H=cyl 503 thru 967 */
RDSZ(15936), 1, /* A=cyl 1 thru 166 */
RDSZ(13056), 167, /* B=cyl 167 thru 302 */
RDSZ(29088), 0, /* C=cyl 0 thru 302 */
RDSZ(0), 0, /* D=<undefined> */
RDSZ(0), 0, /* E=<undefined> */
RDSZ(0), 0, /* F=<undefined> */
RDSZ(0), 0, /* G=<undefined> */
RDSZ(0), 0, /* H=<undefined> */
RDSZ(0), 0, /* A=<undefined> */
RDSZ(0), 0, /* B=<undefined> */
RDSZ(1232), 0, /* C=cyl 0 thru 76 */
RDSZ(0), 0, /* D=<undefined> */
RDSZ(0), 0, /* E=<undefined> */
RDSZ(0), 0, /* F=<undefined> */
RDSZ(0), 0, /* G=<undefined> */
RDSZ(0), 0, /* H=<undefined> */
RDSZ(15904), 0, /* A=cyl 1 thru 71 */
RDSZ(22400), 72, /* B=cyl 72 thru 171 */
RDSZ(128128), 0, /* C=cyl 0 thru 571 */
RDSZ(42560), 72, /* D=cyl 72 thru 261 */
RDSZ(0), 292, /* E=<undefined> */
RDSZ(0), 542, /* F=<undefined> */
RDSZ(89600), 172, /* G=cyl 221 thru 571 */
RDSZ(69440), 262, /* H=cyl 262 thru 571 */
RDSZ(15904), 1, /* A=cyl 1 thru 71 */
RDSZ(40320), 72, /* B=cyl 72 thru 251 */
RDSZ(258048), 0, /* C=cyl 0 thru 1151 */
RDSZ(64960), 72, /* D=cyl 72 thru 361 */
RDSZ(98560), 362, /* E=cyl 362 thru 801 */
RDSZ(78400), 802, /* F=cyl 802 thru 1151 */
RDSZ(201600), 252, /* G=cyl 221 thru 1151 */
RDSZ(176960), 362, /* H=cyl 362 thru 1151 */
RDSZ(16146), 1, /* A=cyl 1 thru 27 */
RDSZ(66976), 28, /* B=cyl 28 thru 139 */
RDSZ(789958), 0, /* C=cyl 0 thru 1320 */
RDSZ(16146), 140, /* D=cyl 140 thru 166 */
RDSZ(165646), 167, /* E=cyl 167 thru 443 */
RDSZ(165646), 444, /* F=cyl 444 thru 720 */
RDSZ(706238), 140, /* G=cyl 140 thru 1320 */
RDSZ(358800), 721, /* H=cyl 721 thru 1320 */
RDSZ(15920), 1, /* A=cyl 1 thru 199 */
RDSZ(20000), 200, /* B=cyl 200 thru 449 */
RDSZ(77840), 0, /* C=cyl 0 thru 972 */
RDSZ(32000), 200, /* D=cyl 200 thru 599 */
RDSZ(0), 0, /* E=<undefined> */
RDSZ(0), 0, /* F=<undefined> */
RDSZ(41840), 450, /* G=cyl 450 thru 972 */
RDSZ(29840), 600, /* H=cyl 600 thru 972 */
RDSZ(16016), 1, /* A=cyl 1 thru 104 */
RDSZ(24640), 105, /* B=cyl 105 thru 264 */
RDSZ(159544), 0, /* C=cyl 0 thru 1035 */
RDSZ(42350), 105, /* D=cyl 105 thru 379 */
RDSZ(54824), 380, /* E=cyl 380 thru 735 */
RDSZ(46200), 736, /* F=cyl 736 thru 1035 */
RDSZ(118734), 265, /* G=cyl 265 thru 1035 */
RDSZ(101024), 380, /* H=cyl 380 thru 1035 */
RDSZ(16128), 1, /* A=cyl 1 thru 64 */
RDSZ(32256), 65, /* B=cyl 65 thru 192 */
RDSZ(255276), 0, /* C=cyl 0 thru 1012 */
RDSZ(48384), 65, /* D=cyl 65 thru 256 */
RDSZ(100800), 257, /* E=cyl 257 thru 656 */
RDSZ(89712), 657, /* F=cyl 657 thru 1012 */
RDSZ(206640), 193, /* G=cyl 193 thru 1012 */
RDSZ(190512), 257, /* H=cyl 257 thru 1012 */
RDSZ(16002), 1, /* A=cyl 1 thru 127 */
RDSZ(32760), 128, /* B=cyl 128 thru 387 */
RDSZ(159894), 0, /* C=cyl 0 thru 1268 */
RDSZ(49140), 128, /* D=cyl 128 thru 517 */
RDSZ(50400), 518, /* E=cyl 518 thru 917 */
RDSZ(44226), 918, /* F=cyl 918 thru 1268 */
RDSZ(111006), 388, /* G=cyl 388 thru 1268 */
RDSZ(94626), 518, /* H=cyl 518 thru 1268 */
RDSZ(16254), 1, /* A=cyl 1 thru 43 */
RDSZ(32886), 44, /* B=cyl 44 thru 130 */
RDSZ(297108), 0, /* C=cyl 0 thru 785 */
RDSZ(49140), 44, /* D=cyl 44 thru 173 */
RDSZ(121716), 174, /* E=cyl 174 thru 495 */
RDSZ(109620), 496, /* F=cyl 496 thru 785 */
RDSZ(247590), 131, /* G=cyl 131 thru 785 */
RDSZ(231336), 174, /* H=cyl 174 thru 785 */
RDSZ(16254), 1, /* A=cyl 1 thru 43 */
RDSZ(49140), 44, /* B=cyl 44 thru 173 */
RDSZ(594216), 0, /* C=cyl 0 thru 1571 */
RDSZ(65772), 44, /* D=cyl 44 thru 217 */
RDSZ(303912), 218, /* E=cyl 218 thru 1021 */
RDSZ(207900), 1022, /* F=cyl 1022 thru 1571 */
RDSZ(528444), 174, /* G=cyl 174 thru 1571 */
RDSZ(511812), 218, /* H=cyl 218 thru 1571 */
RDSZ(16272), 1, /* A=cyl 1 thru 36 */
RDSZ(49720), 37, /* B=cyl 37 thru 146 */
RDSZ(654948), 0, /* C=cyl 0 thru 1448 */
RDSZ(65992), 37, /* D=cyl 37 thru 182 */
RDSZ(304648), 183, /* E=cyl 183 thru 856 */
RDSZ(267584), 857, /* F=cyl 857 thru 1448 */
RDSZ(588504), 147, /* G=cyl 147 thru 1448 */
RDSZ(572232), 183, /* H=cyl 183 thru 1448 */
/* modelled after the 7937; i.e. bogus */
RDSZ(16272), 1, /* A=cyl 1 thru 18 */
RDSZ(67800), 19, /* B=cyl 19 thru 93 */
RDSZ(1309896), 0, /* C=cyl 0 thru 1448 */
RDSZ(16272), 94, /* D=cyl 19 thru 111 */
RDSZ(305552), 112, /* E=cyl 112 thru 449 */
RDSZ(305552), 450, /* F=cyl 450 thru 787 */
RDSZ(1224920), 94, /* G=cyl 94 thru 1448 */
RDSZ(597544), 788, /* H=cyl 788 thru 1448 */
* These values would not work for 1k,
* since the number of cylinders would be different.
RDSZ(16359), 1, /* A=cyl 1 thru 19 */
RDSZ(67158), 20, /* B=cyl 20 thru 97 */
RDSZ(600978), 0, /* C=cyl 0 thru 697 */
RDSZ(16359), 98, /* D=cyl 98 thru 116 */
RDSZ(120540), 117, /* E=cyl 117 thru 256 */
RDSZ(120540), 256, /* F=cyl 256 thru 396 */
RDSZ(516600), 98, /* G=cyl 98 thru 697 */
RDSZ(259161), 397, /* H=cyl 397 thru 697 */
RDSZ(15990), 1, /* A=cyl 1 thru 10 */
RDSZ(67158), 11, /* B=cyl 11 thru 52 */
RDSZ(1116102), 0, /* C=cyl 0 thru 697 */
RDSZ(124722), 53, /* D=cyl 53 thru 130 */
RDSZ(163098), 131, /* E=cyl 131 thru 232 */
RDSZ(287820), 233, /* F=cyl 233 thru 412 */
RDSZ(1031355), 53, /* G=cyl 53 thru 697 */
RDSZ(455715), 413, /* H=cyl 413 thru 697 */
RDSZ(15990), 1, /* A=cyl 1 thru 10 */
RDSZ(67158), 11, /* B=cyl 11 thru 52 */
RDSZ(1116102), 0, /* C=cyl 0 thru 697 */
RDSZ(15990), 53, /* D=cyl 53 thru 62 */
RDSZ(246246), 63, /* E=cyl 63 thru 216 */
RDSZ(246246), 217, /* F=cyl 217 thru 370 */
RDSZ(1031355), 53, /* G=cyl 53 thru 697 */
RDSZ(522873), 371, /* H=cyl 371 thru 697 */
int nbpt
; /* DEV_BSIZE blocks per track */
int ntpc
; /* tracks per cylinder */
int nbpc
; /* blocks per cylinder */
struct size
*sizes
; /* default partition info (if no disklabel) */
short hwid
; /* 2 byte HW id */
short maxunum
; /* maximum allowed unit number */
char *desc
; /* drive type description */
struct rdinfo rdinfo
[] = {
NRD7945ABPT
, NRD7945ATRK
, NRD7945ABPT
* NRD7945ATRK
,
rd7945A_sizes
, RD7946AID
, 0, "7945A",
NRD9134DBPT
, NRD9134DTRK
, NRD9134DBPT
* NRD9134DTRK
,
rd9134D_sizes
, RD9134DID
, 1, "9134D",
NRD9122SBPT
, NRD9122STRK
, NRD9122SBPT
* NRD9122STRK
,
rd9122S_sizes
, RD9134LID
, 1, "9122S",
NRD7912PBPT
, NRD7912PTRK
, NRD7912PBPT
* NRD7912PTRK
,
rd7912P_sizes
, RD7912PID
, 0, "7912P",
NRD7914PBPT
, NRD7914PTRK
, NRD7914PBPT
* NRD7914PTRK
,
rd7914P_sizes
, RD7914PID
, 0, "7914P",
NRD7958ABPT
, NRD7958ATRK
, NRD7958ABPT
* NRD7958ATRK
,
rd7958A_sizes
, RD7958AID
, 0, "7958A",
NRD7957ABPT
, NRD7957ATRK
, NRD7957ABPT
* NRD7957ATRK
,
rd7957A_sizes
, RD7957AID
, 0, "7957A",
NRD7933HBPT
, NRD7933HTRK
, NRD7933HBPT
* NRD7933HTRK
,
rd7933H_sizes
, RD7933HID
, 0, "7933H",
NRD9134LBPT
, NRD9134LTRK
, NRD9134LBPT
* NRD9134LTRK
,
rd9134L_sizes
, RD9134LID
, 1, "9134L",
NRD7936HBPT
, NRD7936HTRK
, NRD7936HBPT
* NRD7936HTRK
,
rd7936H_sizes
, RD7936HID
, 0, "7936H",
NRD7937HBPT
, NRD7937HTRK
, NRD7937HBPT
* NRD7937HTRK
,
rd7937H_sizes
, RD7937HID
, 0, "7937H",
NRD7914PBPT
, NRD7914PTRK
, NRD7914PBPT
* NRD7914PTRK
,
rd7914P_sizes
, RD7914CTID
, 0, "7914CT",
NRD7945ABPT
, NRD7945ATRK
, NRD7945ABPT
* NRD7945ATRK
,
rd7945A_sizes
, RD7946AID
, 0, "7946A",
NRD9122SBPT
, NRD9122STRK
, NRD9122SBPT
* NRD9122STRK
,
rd9122S_sizes
, RD9134LID
, 1, "9122D",
NRD7957BBPT
, NRD7957BTRK
, NRD7957BBPT
* NRD7957BTRK
,
rd7957B_sizes
, RD7957BID
, 0, "7957B",
NRD7958BBPT
, NRD7958BTRK
, NRD7958BBPT
* NRD7958BTRK
,
rd7958B_sizes
, RD7958BID
, 0, "7958B",
NRD7959BBPT
, NRD7959BTRK
, NRD7959BBPT
* NRD7959BTRK
,
rd7959B_sizes
, RD7959BID
, 0, "7959B",
NRD2200ABPT
, NRD2200ATRK
, NRD2200ABPT
* NRD2200ATRK
,
rd2200A_sizes
, RD2200AID
, 0, "2200A",
NRD2203ABPT
, NRD2203ATRK
, NRD2203ABPT
* NRD2203ATRK
,
rd2203A_sizes
, RD2203AID
, 0, "2203A",
int nrdinfo
= sizeof(rdinfo
) / sizeof(rdinfo
[0]);
#define rdunit(x) (minor(x) >> 3)
#define rdpart(x) (minor(x) & 0x7)
#define rdpunit(x) ((x) & 7)
#define RDWAITC 1 /* min time for timeout in seconds */
int rderrthresh
= RDRETRY
-1; /* when to start reporting errors */
register struct hp_device
*hd
;
register struct rd_softc
*rs
= &rd_softc
[hd
->hp_unit
];
rs
->sc_punit
= rdpunit(hd
->hp_flags
);
rs
->sc_type
= rdident(rs
, hd
);
rs
->sc_dq
.dq_ctlr
= hd
->hp_ctlr
;
rs
->sc_dq
.dq_unit
= hd
->hp_unit
;
rs
->sc_dq
.dq_slave
= hd
->hp_slave
;
rs
->sc_dq
.dq_driver
= &rddriver
;
rs
->sc_info
= &rdinfo
[rs
->sc_type
];
rs
->sc_flags
= RDF_ALIVE
;
/* always report errors */
register int ctlr
, slave
, id
, i
;
* Grab device id and make sure:
* 1. It is a CS80 device.
* 2. It is one of the types we support.
* 3. If it is a 7946, we are accessing the disk unit (0)
id
= hpibid(ctlr
, slave
);
printf("hpibid(%d, %d) -> %x\n", ctlr
, slave
, id
);
for (i
= 0; i
< nrdinfo
; i
++)
if (id
== rdinfo
[i
].hwid
)
if (i
== nrdinfo
|| unit
> rdinfo
[i
].maxunum
)
* Reset drive and collect device description.
* Don't really use the description info right now but
* might come in handy in the future (for disk labels).
hpibsend(ctlr
, slave
, C_CMD
, cmd
, sizeof(cmd
));
hpibrecv(ctlr
, slave
, C_EXEC
, &desc
, 37);
hpibrecv(ctlr
, slave
, C_QSTAT
, &stat
, sizeof(stat
));
bzero(name
, sizeof(name
));
register int n
= desc
.d_name
;
for (i
= 5; i
>= 0; i
--) {
name
[i
] = (n
& 0xf) + '0';
/* use drive characteristics to calculate xfer rate */
rs
->sc_wpms
= 1000000 * (desc
.d_sectsize
/2) / desc
.d_blocktime
;
if (rddebug
& RDB_IDENT
) {
printf("rd%d: name: %x ('%s')\n",
lunit
, desc
.d_name
, name
);
printf(" iuw %x, maxxfr %d, ctype %d\n",
desc
.d_iuw
, desc
.d_cmaxxfr
, desc
.d_ctype
);
printf(" utype %d, bps %d, blkbuf %d, burst %d, blktime %d\n",
desc
.d_utype
, desc
.d_sectsize
,
desc
.d_blkbuf
, desc
.d_burstsize
, desc
.d_blocktime
);
printf(" avxfr %d, ort %d, atp %d, maxint %d, fv %x, rv %x\n",
desc
.d_uavexfr
, desc
.d_retry
, desc
.d_access
,
desc
.d_maxint
, desc
.d_fvbyte
, desc
.d_rvbyte
);
printf(" maxcyl/head/sect %d/%d/%d, maxvsect %d, inter %d\n",
desc
.d_maxcyl
, desc
.d_maxhead
, desc
.d_maxsect
,
desc
.d_maxvsectl
, desc
.d_interleave
);
* Take care of a couple of anomolies:
* 1. 7945A and 7946A both return same HW id
* 2. 9122S and 9134D both return same HW id
* 3. 9122D and 9134L both return same HW id
switch (rdinfo
[id
].hwid
) {
if (bcmp(name
, "079450", 6) == 0)
if (bcmp(name
, "091340", 6) == 0)
if (bcmp(name
, "091220", 6) == 0)
printf("rd%d: %s\n", lunit
, rdinfo
[id
].desc
);
register struct rd_softc
*rs
;
register struct hp_device
*hd
;
rs
->sc_clear
.c_unit
= C_SUNIT(rs
->sc_punit
);
rs
->sc_clear
.c_cmd
= C_CLEAR
;
hpibsend(hd
->hp_ctlr
, hd
->hp_slave
, C_TCMD
, &rs
->sc_clear
,
hpibswait(hd
->hp_ctlr
, hd
->hp_slave
);
hpibrecv(hd
->hp_ctlr
, hd
->hp_slave
, C_QSTAT
, &stat
, sizeof(stat
));
rs
->sc_src
.c_unit
= C_SUNIT(RDCTLR
);
rs
->sc_src
.c_nop
= C_NOP
;
rs
->sc_src
.c_cmd
= C_SREL
;
rs
->sc_src
.c_param
= C_REL
;
hpibsend(hd
->hp_ctlr
, hd
->hp_slave
, C_CMD
, &rs
->sc_src
,
hpibswait(hd
->hp_ctlr
, hd
->hp_slave
);
hpibrecv(hd
->hp_ctlr
, hd
->hp_slave
, C_QSTAT
, &stat
, sizeof(stat
));
rs
->sc_ssmc
.c_unit
= C_SUNIT(rs
->sc_punit
);
rs
->sc_ssmc
.c_cmd
= C_SSM
;
rs
->sc_ssmc
.c_refm
= REF_MASK
;
rs
->sc_ssmc
.c_fefm
= FEF_MASK
;
rs
->sc_ssmc
.c_aefm
= AEF_MASK
;
rs
->sc_ssmc
.c_iefm
= IEF_MASK
;
hpibsend(hd
->hp_ctlr
, hd
->hp_slave
, C_CMD
, &rs
->sc_ssmc
,
hpibswait(hd
->hp_ctlr
, hd
->hp_slave
);
hpibrecv(hd
->hp_ctlr
, hd
->hp_slave
, C_QSTAT
, &stat
, sizeof(stat
));
rdstats
[hd
->hp_unit
].rdresets
++;
rdopen(dev
, flags
, mode
, p
)
register int unit
= rdunit(dev
);
register struct rd_softc
*rs
= &rd_softc
[unit
];
if (unit
>= NRD
|| (rs
->sc_flags
& RDF_ALIVE
) == 0)
if (rs
->sc_hd
->hp_dk
>= 0) {
/* guess at xfer rate based on 3600 rpm (60 rps) */
rs
->sc_wpms
= 60 * rs
->sc_info
->nbpt
* DEV_BSIZE
/ 2;
dk_wpms
[rs
->sc_hd
->hp_dk
] = rs
->sc_wpms
;
register int unit
= rdunit(bp
->b_dev
);
register struct rd_softc
*rs
= &rd_softc
[unit
];
register struct size
*pinfo
= &rs
->sc_info
->sizes
[rdpart(bp
->b_dev
)];
register struct buf
*dp
= &rdtab
[unit
];
if (rddebug
& RDB_FOLLOW
)
printf("rdstrategy(%x): dev %x, bn %x, bcount %x, %c\n",
bp
, bp
->b_dev
, bp
->b_blkno
, bp
->b_bcount
,
(bp
->b_flags
& B_READ
) ? 'R' : 'W');
sz
= howmany(bp
->b_bcount
, DEV_BSIZE
);
if (bn
< 0 || bn
+ sz
> pinfo
->nblocks
) {
sz
= pinfo
->nblocks
- bn
;
bp
->b_resid
= bp
->b_bcount
;
bp
->b_bcount
= dbtob(sz
);
bp
->b_cylin
= bn
/ rs
->sc_info
->nbpc
+ pinfo
->cyloff
;
* Called from timeout() when handling maintenance releases
register struct rd_softc
*rs
= &rd_softc
[unit
];
rs
->sc_addr
= bp
->b_un
.b_addr
;
rs
->sc_resid
= bp
->b_bcount
;
register struct rd_softc
*rs
= &rd_softc
[unit
];
register struct buf
*bp
= rdtab
[unit
].b_actf
;
register struct hp_device
*hp
= rs
->sc_hd
;
if (rddebug
& RDB_FOLLOW
)
printf("rdstart(%d): bp %x, %c\n", unit
, bp
,
(bp
->b_flags
& B_READ
) ? 'R' : 'W');
part
= rdpart(bp
->b_dev
);
rs
->sc_flags
|= RDF_SEEK
;
rs
->sc_ioc
.c_unit
= C_SUNIT(rs
->sc_punit
);
rs
->sc_ioc
.c_volume
= C_SVOL(0);
rs
->sc_ioc
.c_saddr
= C_SADDR
;
rs
->sc_ioc
.c_addr
= RDBTOS(bp
->b_blkno
+ rs
->sc_info
->nbpc
*
rs
->sc_info
->sizes
[part
].cyloff
);
rs
->sc_ioc
.c_nop2
= C_NOP
;
rs
->sc_ioc
.c_slen
= C_SLEN
;
rs
->sc_ioc
.c_len
= rs
->sc_resid
;
rs
->sc_ioc
.c_cmd
= bp
->b_flags
& B_READ
? C_READ
: C_WRITE
;
printf("rdstart: hpibsend(%x, %x, %x, %x, %x)\n",
hp
->hp_ctlr
, hp
->hp_slave
, C_CMD
,
&rs
->sc_ioc
.c_unit
, sizeof(rs
->sc_ioc
)-2);
if (hpibsend(hp
->hp_ctlr
, hp
->hp_slave
, C_CMD
, &rs
->sc_ioc
.c_unit
,
sizeof(rs
->sc_ioc
)-2) == sizeof(rs
->sc_ioc
)-2) {
dk_busy
|= 1 << hp
->hp_dk
;
printf("rdstart: hpibawait(%x)\n", hp
->hp_ctlr
);
* Experience has shown that the hpibwait in this hpibsend will
* occasionally timeout. It appears to occur mostly on old 7914
* drives with full maintenance tracks. We should probably
* integrate this with the backoff code in rderror.
printf("rd%d: rdstart: cmd %x adr %d blk %d len %d ecnt %d\n",
unit
, rs
->sc_ioc
.c_cmd
, rs
->sc_ioc
.c_addr
,
bp
->b_blkno
, rs
->sc_resid
, rdtab
[unit
].b_errcnt
);
rdstats
[unit
].rdretries
++;
rs
->sc_flags
&= ~RDF_SEEK
;
if (rdtab
[unit
].b_errcnt
++ < RDRETRY
)
printf("rd%d: rdstart err: cmd 0x%x sect %d blk %d len %d\n",
unit
, rs
->sc_ioc
.c_cmd
, rs
->sc_ioc
.c_addr
,
bp
->b_blkno
, rs
->sc_resid
);
rdtab
[unit
].b_errcnt
= 0;
rdtab
[unit
].b_actf
= bp
->b_actf
;
rdtab
[unit
].b_active
= 0;
rs
->sc_addr
= bp
->b_un
.b_addr
;
rs
->sc_resid
= bp
->b_bcount
;
register struct rd_softc
*rs
= &rd_softc
[unit
];
register struct hp_device
*hp
= rs
->sc_hd
;
struct buf
*bp
= rdtab
[unit
].b_actf
;
dk_busy
|= 1 << hp
->hp_dk
;
dk_wds
[hp
->hp_dk
] += rs
->sc_resid
>> 6;
hpibgo(hp
->hp_ctlr
, hp
->hp_slave
, C_EXEC
,
rs
->sc_addr
, rs
->sc_resid
, bp
->b_flags
& B_READ
);
register struct rd_softc
*rs
= &rd_softc
[unit
];
register struct buf
*bp
= rdtab
[unit
].b_actf
;
register struct hp_device
*hp
= rs
->sc_hd
;
u_char stat
= 13; /* in case hpibrecv fails */
if (rddebug
& RDB_FOLLOW
)
printf("rdintr(%d): bp %x, %c, flags %x\n", unit
, bp
,
(bp
->b_flags
& B_READ
) ? 'R' : 'W', rs
->sc_flags
);
printf("rd%d: bp == NULL\n", unit
);
dk_busy
&= ~(1 << hp
->hp_dk
);
if (rs
->sc_flags
& RDF_SEEK
) {
rs
->sc_flags
&= ~RDF_SEEK
;
if (hpibustart(hp
->hp_ctlr
))
if ((rs
->sc_flags
& RDF_SWAIT
) == 0) {
rdstats
[unit
].rdpolltries
++;
if (hpibpptest(hp
->hp_ctlr
, hp
->hp_slave
) == 0) {
rdstats
[unit
].rdpollwaits
++;
dk_busy
|= 1 << hp
->hp_dk
;
rs
->sc_flags
|= RDF_SWAIT
;
rs
->sc_flags
&= ~RDF_SWAIT
;
rv
= hpibrecv(hp
->hp_ctlr
, hp
->hp_slave
, C_QSTAT
, &stat
, 1);
printf("rdintr: recv failed or bad stat %d\n", stat
);
rdstats
[unit
].rdretries
++;
if (rdtab
[unit
].b_errcnt
++ < RDRETRY
) {
rdtab
[unit
].b_errcnt
= 0;
rdtab
[unit
].b_actf
= bp
->b_actf
;
rdtab
[unit
].b_active
= 0;
register struct rd_softc
*rs
;
rs
->sc_rsc
.c_unit
= C_SUNIT(rs
->sc_punit
);
rs
->sc_rsc
.c_sram
= C_SRAM
;
rs
->sc_rsc
.c_ram
= C_RAM
;
rs
->sc_rsc
.c_cmd
= C_STATUS
;
bzero((caddr_t
)&rs
->sc_stat
, sizeof(rs
->sc_stat
));
rv
= hpibsend(c
, s
, C_CMD
, &rs
->sc_rsc
, sizeof(rs
->sc_rsc
));
if (rv
!= sizeof(rs
->sc_rsc
)) {
if (rddebug
& RDB_STATUS
)
printf("rdstatus: send C_CMD failed %d != %d\n",
rv
= hpibrecv(c
, s
, C_EXEC
, &rs
->sc_stat
, sizeof(rs
->sc_stat
));
if (rv
!= sizeof(rs
->sc_stat
)) {
if (rddebug
& RDB_STATUS
)
printf("rdstatus: send C_EXEC failed %d != %d\n",
rv
, sizeof(rs
->sc_stat
));
rv
= hpibrecv(c
, s
, C_QSTAT
, &stat
, 1);
if (rddebug
& RDB_STATUS
)
printf("rdstatus: recv failed %d or bad stat %d\n",
* Returns 1 if request should be restarted,
* 0 if we should just quietly give up.
struct rd_softc
*rs
= &rd_softc
[unit
];
register struct rd_stat
*sp
;
printf("rd%d: couldn't get status\n", unit
);
if (sp
->c_fef
& FEF_REXMT
)
if (sp
->c_fef
& FEF_PF
) {
* Unit requests release for internal maintenance.
* We just delay awhile and try again later. Use expontially
* increasing backoff ala ethernet drivers since we don't really
* know how long the maintenance will take. With RDWAITC and
* RDRETRY as defined, the range is 1 to 32 seconds.
if (sp
->c_fef
& FEF_IMR
) {
int rdtimo
= RDWAITC
<< rdtab
[unit
].b_errcnt
;
printf("rd%d: internal maintenance, %d second timeout\n",
rdstats
[unit
].rdtimeouts
++;
timeout(rdrestart
, unit
, rdtimo
*hz
);
* Only report error if we have reached the error reporting
* threshhold. By default, this will only report after the
* retry limit has been exceeded.
if (rdtab
[unit
].b_errcnt
< rderrthresh
)
* First conjure up the block number at which the error occured.
* Note that not all errors report a block number, in that case
pbn
= rs
->sc_info
->nbpc
*
rs
->sc_info
->sizes
[rdpart(bp
->b_dev
)].cyloff
;
if ((sp
->c_fef
& FEF_CU
) || (sp
->c_fef
& FEF_DR
) ||
(sp
->c_ief
& IEF_RRMASK
)) {
hwbn
= RDBTOS(pbn
+ bp
->b_blkno
);
pbn
= RDSTOB(hwbn
) - pbn
;
* Now output a generic message suitable for badsect.
* Note that we don't use harderr cuz it just prints
* out b_blkno which is just the beginning block number
* of the transfer, not necessary where the error occured.
printf("rd%d%c: hard error sn%d\n",
rdunit(bp
->b_dev
), 'a'+rdpart(bp
->b_dev
), pbn
);
* Now report the status as returned by the hardware with
* attempt at interpretation (unless debugging).
unit
, (bp
->b_flags
& B_READ
) ? "read" : "write");
if (rddebug
& RDB_ERROR
) {
printf("\n volume: %d, unit: %d\n",
(sp
->c_vu
>>4)&0xF, sp
->c_vu
&0xF);
rdprinterr("reject", sp
->c_ref
, err_reject
);
rdprinterr("fault", sp
->c_fef
, err_fault
);
rdprinterr("access", sp
->c_aef
, err_access
);
rdprinterr("info", sp
->c_ief
, err_info
);
printf(" block: %d, P1-P10: ", hwbn
);
printf("%s", hexstr(*(u_int
*)&sp
->c_raw
[0], 8));
printf("%s", hexstr(*(u_int
*)&sp
->c_raw
[4], 8));
printf("%s\n", hexstr(*(u_short
*)&sp
->c_raw
[8], 4));
printf("%s", hexstr(*(u_int
*)&rs
->sc_ioc
.c_pad
, 8));
printf("%s", hexstr(*(u_short
*)&rs
->sc_ioc
.c_hiaddr
, 4));
printf("%s", hexstr(*(u_int
*)&rs
->sc_ioc
.c_addr
, 8));
printf("%s", hexstr(*(u_short
*)&rs
->sc_ioc
.c_nop2
, 4));
printf("%s", hexstr(*(u_int
*)&rs
->sc_ioc
.c_len
, 8));
printf("%s\n", hexstr(*(u_short
*)&rs
->sc_ioc
.c_cmd
, 4));
printf(" v%d u%d, R0x%x F0x%x A0x%x I0x%x\n",
(sp
->c_vu
>>4)&0xF, sp
->c_vu
&0xF,
sp
->c_ref
, sp
->c_fef
, sp
->c_aef
, sp
->c_ief
);
printf("%s", hexstr(*(u_int
*)&sp
->c_raw
[0], 8));
printf("%s", hexstr(*(u_int
*)&sp
->c_raw
[4], 8));
printf("%s\n", hexstr(*(u_short
*)&sp
->c_raw
[8], 4));
register int unit
= rdunit(dev
);
return (physio(rdstrategy
, NULL
, dev
, B_READ
, minphys
, uio
));
register int unit
= rdunit(dev
);
return (physio(rdstrategy
, NULL
, dev
, B_WRITE
, minphys
, uio
));
rdioctl(dev
, cmd
, data
, flag
, p
)
register int unit
= rdunit(dev
);
register struct rd_softc
*rs
= &rd_softc
[unit
];
if (unit
>= NRD
|| (rs
->sc_flags
& RDF_ALIVE
) == 0)
return(rs
->sc_info
->sizes
[rdpart(dev
)].nblocks
);
rdprinterr(str
, err
, tab
)
printf(" %s error field:", str
, err
);
printf("%s%s", printed
++ ? " + " : " ", tab
[i
]);
* Non-interrupt driven, non-dma dump routine.
register struct rd_softc
*rs
= &rd_softc
[unit
];
register struct hp_device
*hp
= rs
->sc_hd
;
register int maddr
, pages
, i
;
extern int lowram
, dumpsize
;
printf("rddump(%x): u %d p %d dumplo %d ram %x pmem %d\n",
dev
, unit
, part
, dumplo
, lowram
, ctod(pages
));
if (unit
>= NRD
|| (rs
->sc_flags
& RDF_ALIVE
) == 0)
if (!hpibreq(&rs
->sc_dq
)) {
/* is this a safe thing to do?? */
printf("[ drive %d reset ] ", unit
);
/* dump parameters in range? */
if (dumplo
< 0 || dumplo
>= rs
->sc_info
->sizes
[part
].nblocks
)
if (dumplo
+ ctod(pages
) > rs
->sc_info
->sizes
[part
].nblocks
)
pages
= dtoc(rs
->sc_info
->sizes
[part
].nblocks
- dumplo
);
baddr
= dumplo
+ rs
->sc_info
->nbpc
* rs
->sc_info
->sizes
[part
].cyloff
;
printf("rddump: dumping %d pages from %x to disk block %d\n",
for (i
= 0; i
< pages
; i
++) {
#define NPGMB (1024*1024/NBPG)
/* print out how many Mbs we have dumped */
if (i
&& (i
% NPGMB
) == 0)
printf("%d ", i
/ NPGMB
);
rs
->sc_ioc
.c_unit
= C_SUNIT(rs
->sc_punit
);
rs
->sc_ioc
.c_volume
= C_SVOL(0);
rs
->sc_ioc
.c_saddr
= C_SADDR
;
rs
->sc_ioc
.c_addr
= RDBTOS(baddr
);
rs
->sc_ioc
.c_nop2
= C_NOP
;
rs
->sc_ioc
.c_slen
= C_SLEN
;
rs
->sc_ioc
.c_cmd
= C_WRITE
;
hpibsend(hp
->hp_ctlr
, hp
->hp_slave
, C_CMD
,
&rs
->sc_ioc
.c_unit
, sizeof(rs
->sc_ioc
)-2);
if (hpibswait(hp
->hp_ctlr
, hp
->hp_slave
)) {
printf("rddump: IOC wait timeout\n");
pmap_enter(pmap_kernel(), vmmap
, maddr
, VM_PROT_READ
, TRUE
);
hpibsend(hp
->hp_ctlr
, hp
->hp_slave
, C_EXEC
, vmmap
, NBPG
);
if (hpibswait(hp
->hp_ctlr
, hp
->hp_slave
)) {
printf("rddump: write wait timeout\n");
hpibrecv(hp
->hp_ctlr
, hp
->hp_slave
, C_QSTAT
, &stat
, 1);
printf("rddump: write failed, status %x\n",