* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1990, 1993
* The Regents of the University of California. All rights reserved.
* 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.44 92/12/26$
* @(#)rd.c 8.1 (Berkeley) 6/10/93
#include <sys/disklabel.h>
#include <hp/dev/device.h>
#include <hp300/dev/rdreg.h>
#include <hp300/dev/rdvar.h>
#include <hp300/hp300/led.h>
int rdinit(), rdstart(), rdgo(), rdintr();
struct driver rddriver
= {
rdinit
, "rd", rdstart
, rdgo
, rdintr
,
struct rd_softc rd_softc
[NRD
];
int rderrthresh
= RDRETRY
-1; /* when to start reporting errors */
/* 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 */
struct rdstats rdstats
[NRD
];
* Misc. HW description, indexed by sc_type.
* Nothing really critical here, could do without it.
struct rdidentinfo rdidentinfo
[] = {
{ RD7946AID
, 0, "7945A", 108416 },
{ RD9134DID
, 1, "9134D", 29088 },
{ RD9134LID
, 1, "9122S", 1232 },
{ RD7912PID
, 0, "7912P", 128128 },
{ RD7914PID
, 0, "7914P", 258048 },
{ RD7958AID
, 0, "7958A", 255276 },
{ RD7957AID
, 0, "7957A", 159544 },
{ RD7933HID
, 0, "7933H", 789958 },
{ RD9134LID
, 1, "9134L", 77840 },
{ RD7936HID
, 0, "7936H", 600978 },
{ RD7937HID
, 0, "7937H", 1116102 },
{ RD7914CTID
, 0, "7914CT", 258048 },
{ RD7946AID
, 0, "7946A", 108416 },
{ RD9134LID
, 1, "9122D", 1232 },
{ RD7957BID
, 0, "7957B", 159894 },
{ RD7958BID
, 0, "7958B", 297108 },
{ RD7959BID
, 0, "7959B", 594216 },
{ RD2200AID
, 0, "2200A", 654948 },
{ RD2203AID
, 0, "2203A", 1309896 }
int numrdidentinfo
= sizeof(rdidentinfo
) / sizeof(rdidentinfo
[0]);
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_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
< numrdidentinfo
; i
++)
if (id
== rdidentinfo
[i
].ri_hwid
)
if (i
== numrdidentinfo
|| unit
> rdidentinfo
[i
].ri_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 (rdidentinfo
[id
].ri_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
, rdidentinfo
[id
].ri_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
++;
* Read or constuct a disklabel
register struct rd_softc
*rs
= &rd_softc
[unit
];
register struct disklabel
*lp
= &rs
->sc_info
.ri_label
;
register struct partition
*pi
;
char *msg
, *readdisklabel();
* Set some default values to use while reading the label
* or to use if there isn't a label.
bzero((caddr_t
)lp
, sizeof *lp
);
lp
->d_secsize
= DEV_BSIZE
;
lp
->d_partitions
[2].p_offset
= 0;
lp
->d_partitions
[2].p_size
= LABELSECTOR
+1;
* Now try to read the disklabel
msg
= readdisklabel(rdlabdev(dev
), rdstrategy
, lp
);
printf("rd%d: WARNING: %s, ", unit
, msg
);
printf("using old default partitioning\n");
rdmakedisklabel(unit
, lp
);
printf("defining `c' partition as entire disk\n");
pi
[2].p_size
= rdidentinfo
[rs
->sc_type
].ri_nblocks
;
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)
* Wait for any pending opens/closes to complete
while (rs
->sc_flags
& (RDF_OPENING
|RDF_CLOSING
))
sleep((caddr_t
)rs
, PRIBIO
);
* On first open, get label and partition info.
* We may block reading the label, so be careful
* to stop any other opens.
if (rs
->sc_info
.ri_open
== 0) {
rs
->sc_flags
|= RDF_OPENING
;
rs
->sc_flags
&= ~RDF_OPENING
;
if (rs
->sc_hd
->hp_dk
>= 0) {
/* guess at xfer rate based on 3600 rpm (60 rps) */
rs
->sc_wpms
= 60 * rs
->sc_info
.ri_label
.d_nsectors
dk_wpms
[rs
->sc_hd
->hp_dk
] = rs
->sc_wpms
;
rs
->sc_info
.ri_copen
|= mask
;
rs
->sc_info
.ri_bopen
|= mask
;
rs
->sc_info
.ri_open
|= mask
;
rdclose(dev
, flag
, mode
, p
)
register struct rd_softc
*rs
= &rd_softc
[unit
];
register struct rdinfo
*ri
= &rs
->sc_info
;
ri
->ri_open
= ri
->ri_bopen
| ri
->ri_copen
;
* On last close, we wait for all activity to cease since
* the label/parition info will become invalid. Since we
* might sleep, we must block any opens while we are here.
* Note we don't have to about other closes since we know
rs
->sc_flags
|= RDF_CLOSING
;
while (rdtab
[unit
].b_active
) {
rs
->sc_flags
|= RDF_WANTED
;
sleep((caddr_t
)&rdtab
[unit
], PRIBIO
);
rs
->sc_flags
&= ~(RDF_CLOSING
|RDF_WLABEL
);
int unit
= rdunit(bp
->b_dev
);
register struct rd_softc
*rs
= &rd_softc
[unit
];
register struct buf
*dp
= &rdtab
[unit
];
register struct partition
*pinfo
;
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
);
pinfo
= &rs
->sc_info
.ri_label
.d_partitions
[rdpart(bp
->b_dev
)];
if (bn
< 0 || bn
+ sz
> pinfo
->p_size
) {
bp
->b_resid
= bp
->b_bcount
;
bp
->b_bcount
= dbtob(sz
);
* Check for write to write protected label
if (bn
+ pinfo
->p_offset
<= LABELSECTOR
&&
bn
+ pinfo
->p_offset
+ sz
> LABELSECTOR
&&
!(bp
->b_flags
& B_READ
) && !(rs
->sc_flags
& RDF_WLABEL
)) {
bp
->b_cylin
= bn
+ pinfo
->p_offset
;
* 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
;
register struct buf
*dp
= &rdtab
[unit
];
if (rs
->sc_flags
& RDF_WANTED
) {
rs
->sc_flags
&= ~RDF_WANTED
;
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_cylin
);
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
);
bp
= rdfinish(unit
, rs
, bp
);
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;
ledcontrol(0, 0, LED_DISK
);
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
) {
if (rdfinish(unit
, rs
, bp
))
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
, (void *)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
.ri_label
.d_partitions
[rdpart(bp
->b_dev
)].p_offset
;
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));
return (physio(rdstrategy
, NULL
, dev
, B_READ
, minphys
, uio
));
return (physio(rdstrategy
, NULL
, dev
, B_WRITE
, minphys
, uio
));
rdioctl(dev
, cmd
, data
, flag
, p
)
register struct rd_softc
*sc
= &rd_softc
[unit
];
register struct disklabel
*lp
= &sc
->sc_info
.ri_label
;
*(struct disklabel
*)data
= *lp
;
((struct partinfo
*)data
)->disklab
= lp
;
((struct partinfo
*)data
)->part
=
&lp
->d_partitions
[rdpart(dev
)];
if ((flag
& FWRITE
) == 0)
sc
->sc_flags
|= RDF_WLABEL
;
sc
->sc_flags
&= ~RDF_WLABEL
;
if ((flag
& FWRITE
) == 0)
return (setdisklabel(lp
, (struct disklabel
*)data
,
(sc
->sc_flags
& RDF_WLABEL
) ? 0
if ((flag
& FWRITE
) == 0)
error
= setdisklabel(lp
, (struct disklabel
*)data
,
(sc
->sc_flags
& RDF_WLABEL
) ? 0
sc
->sc_flags
= RDF_ALIVE
| RDF_WLABEL
;
error
= writedisklabel(rdlabdev(dev
), rdstrategy
, lp
);
register int unit
= rdunit(dev
);
register struct rd_softc
*rs
= &rd_softc
[unit
];
if (unit
>= NRD
|| (rs
->sc_flags
& RDF_ALIVE
) == 0)
* We get called very early on (via swapconf)
* without the device being open so we may need
if (rs
->sc_info
.ri_open
== 0) {
if (rdopen(dev
, FREAD
|FWRITE
, S_IFBLK
, NULL
))
psize
= rs
->sc_info
.ri_label
.d_partitions
[rdpart(dev
)].p_size
;
(void) rdclose(dev
, FREAD
|FWRITE
, S_IFBLK
, NULL
);
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 struct partition
*pinfo
;
register int maddr
, pages
, i
;
extern int lowram
, dumpsize
;
if (unit
>= NRD
|| (rs
->sc_flags
& RDF_ALIVE
) == 0)
pinfo
= &rs
->sc_info
.ri_label
.d_partitions
[part
];
/* dump parameters in range? */
if (dumplo
< 0 || dumplo
>= pinfo
->p_size
||
pinfo
->p_fstype
!= FS_SWAP
)
if (dumplo
+ ctod(pages
) > pinfo
->p_size
)
pages
= dtoc(pinfo
->p_size
- dumplo
);
baddr
= dumplo
+ pinfo
->p_offset
;
if (!hpibreq(&rs
->sc_dq
)) {
printf("[ drive %d reset ] ", unit
);
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
))
pmap_enter(kernel_pmap
, (vm_offset_t
)vmmap
, maddr
,
hpibsend(hp
->hp_ctlr
, hp
->hp_slave
, C_EXEC
, vmmap
, NBPG
);
(void) hpibswait(hp
->hp_ctlr
, hp
->hp_slave
);
hpibrecv(hp
->hp_ctlr
, hp
->hp_slave
, C_QSTAT
, &stat
, 1);