1998-01-12 21:30:41 +03:00
|
|
|
/* $NetBSD: rd.c,v 1.36 1998/01/12 18:31:06 thorpej Exp $ */
|
1997-10-04 13:59:35 +04:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Jason R. Thorpe.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 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 NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 SUCH DAMAGE.
|
|
|
|
*/
|
1994-10-26 10:22:45 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1988 University of Utah.
|
1994-05-23 09:58:16 +04:00
|
|
|
* Copyright (c) 1982, 1990, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-05-13 17:56:20 +04:00
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* the Systems Programming Group of the University of Utah Computer
|
|
|
|
* Science Department.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 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
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1994-05-23 09:58:16 +04:00
|
|
|
* from: Utah $Hdr: rd.c 1.44 92/12/26$
|
|
|
|
*
|
1994-10-26 10:22:45 +03:00
|
|
|
* @(#)rd.c 8.2 (Berkeley) 5/19/94
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CS80/SS80 disk driver
|
|
|
|
*/
|
|
|
|
|
1994-02-10 16:59:25 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/buf.h>
|
1997-03-31 11:32:14 +04:00
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/device.h>
|
1996-01-08 01:01:38 +03:00
|
|
|
#include <sys/disk.h>
|
1997-03-31 11:32:14 +04:00
|
|
|
#include <sys/disklabel.h>
|
1994-05-23 09:58:16 +04:00
|
|
|
#include <sys/fcntl.h>
|
1997-03-31 11:32:14 +04:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/stat.h>
|
1997-01-30 12:14:10 +03:00
|
|
|
|
|
|
|
#include <hp300/dev/hpibvar.h>
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1994-02-10 16:59:25 +03:00
|
|
|
#include <hp300/dev/rdreg.h>
|
1994-05-23 09:58:16 +04:00
|
|
|
#include <hp300/dev/rdvar.h>
|
1997-01-30 12:14:10 +03:00
|
|
|
|
1997-05-06 01:07:31 +04:00
|
|
|
#include "opt_useleds.h"
|
|
|
|
|
|
|
|
#ifdef USELEDS
|
|
|
|
#include <hp300/hp300/leds.h>
|
|
|
|
#endif
|
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
int rderrthresh = RDRETRY-1; /* when to start reporting errors */
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* error message tables */
|
|
|
|
char *err_reject[] = {
|
|
|
|
0, 0,
|
|
|
|
"channel parity error", /* 0x2000 */
|
|
|
|
0, 0,
|
|
|
|
"illegal opcode", /* 0x0400 */
|
|
|
|
"module addressing", /* 0x0200 */
|
|
|
|
"address bounds", /* 0x0100 */
|
|
|
|
"parameter bounds", /* 0x0080 */
|
|
|
|
"illegal parameter", /* 0x0040 */
|
|
|
|
"message sequence", /* 0x0020 */
|
|
|
|
0,
|
|
|
|
"message length", /* 0x0008 */
|
|
|
|
0, 0, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
char *err_fault[] = {
|
|
|
|
0,
|
|
|
|
"cross unit", /* 0x4000 */
|
|
|
|
0,
|
|
|
|
"controller fault", /* 0x1000 */
|
|
|
|
0, 0,
|
|
|
|
"unit fault", /* 0x0200 */
|
|
|
|
0,
|
|
|
|
"diagnostic result", /* 0x0080 */
|
|
|
|
0,
|
|
|
|
"operator release request", /* 0x0020 */
|
|
|
|
"diagnostic release request", /* 0x0010 */
|
|
|
|
"internal maintenance release request", /* 0x0008 */
|
|
|
|
0,
|
|
|
|
"power fail", /* 0x0002 */
|
|
|
|
"retransmit" /* 0x0001 */
|
|
|
|
};
|
|
|
|
|
|
|
|
char *err_access[] = {
|
|
|
|
"illegal parallel operation", /* 0x8000 */
|
|
|
|
"uninitialized media", /* 0x4000 */
|
|
|
|
"no spares available", /* 0x2000 */
|
|
|
|
"not ready", /* 0x1000 */
|
|
|
|
"write protect", /* 0x0800 */
|
|
|
|
"no data found", /* 0x0400 */
|
|
|
|
0, 0,
|
|
|
|
"unrecoverable data overflow", /* 0x0080 */
|
|
|
|
"unrecoverable data", /* 0x0040 */
|
|
|
|
0,
|
|
|
|
"end of file", /* 0x0010 */
|
|
|
|
"end of volume", /* 0x0008 */
|
|
|
|
0, 0, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
char *err_info[] = {
|
|
|
|
"operator release request", /* 0x8000 */
|
|
|
|
"diagnostic release request", /* 0x4000 */
|
|
|
|
"internal maintenance release request", /* 0x2000 */
|
|
|
|
"media wear", /* 0x1000 */
|
|
|
|
"latency induced", /* 0x0800 */
|
|
|
|
0, 0,
|
|
|
|
"auto sparing invoked", /* 0x0100 */
|
|
|
|
0,
|
|
|
|
"recoverable data overflow", /* 0x0040 */
|
|
|
|
"marginal data", /* 0x0020 */
|
|
|
|
"recoverable data", /* 0x0010 */
|
|
|
|
0,
|
|
|
|
"maintenance track overflow", /* 0x0004 */
|
|
|
|
0, 0
|
|
|
|
};
|
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
int rddebug = 0x80;
|
|
|
|
#define RDB_FOLLOW 0x01
|
|
|
|
#define RDB_STATUS 0x02
|
|
|
|
#define RDB_IDENT 0x04
|
|
|
|
#define RDB_IO 0x08
|
|
|
|
#define RDB_ASYNC 0x10
|
|
|
|
#define RDB_ERROR 0x80
|
|
|
|
#endif
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
/*
|
1994-05-23 09:58:16 +04:00
|
|
|
* Misc. HW description, indexed by sc_type.
|
|
|
|
* Nothing really critical here, could do without it.
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
1994-05-23 09:58:16 +04:00
|
|
|
struct rdidentinfo rdidentinfo[] = {
|
1995-11-19 22:07:18 +03:00
|
|
|
{ RD7946AID, 0, "7945A", NRD7945ABPT,
|
|
|
|
NRD7945ATRK, 968, 108416 },
|
|
|
|
|
|
|
|
{ RD9134DID, 1, "9134D", NRD9134DBPT,
|
|
|
|
NRD9134DTRK, 303, 29088 },
|
|
|
|
|
|
|
|
{ RD9134LID, 1, "9122S", NRD9122SBPT,
|
|
|
|
NRD9122STRK, 77, 1232 },
|
|
|
|
|
|
|
|
{ RD7912PID, 0, "7912P", NRD7912PBPT,
|
|
|
|
NRD7912PTRK, 572, 128128 },
|
|
|
|
|
|
|
|
{ RD7914PID, 0, "7914P", NRD7914PBPT,
|
|
|
|
NRD7914PTRK, 1152, 258048 },
|
|
|
|
|
|
|
|
{ RD7958AID, 0, "7958A", NRD7958ABPT,
|
|
|
|
NRD7958ATRK, 1013, 255276 },
|
|
|
|
|
|
|
|
{ RD7957AID, 0, "7957A", NRD7957ABPT,
|
|
|
|
NRD7957ATRK, 1036, 159544 },
|
|
|
|
|
|
|
|
{ RD7933HID, 0, "7933H", NRD7933HBPT,
|
|
|
|
NRD7933HTRK, 1321, 789958 },
|
|
|
|
|
|
|
|
{ RD9134LID, 1, "9134L", NRD9134LBPT,
|
|
|
|
NRD9134LTRK, 973, 77840 },
|
|
|
|
|
|
|
|
{ RD7936HID, 0, "7936H", NRD7936HBPT,
|
|
|
|
NRD7936HTRK, 698, 600978 },
|
|
|
|
|
|
|
|
{ RD7937HID, 0, "7937H", NRD7937HBPT,
|
|
|
|
NRD7937HTRK, 698, 1116102 },
|
|
|
|
|
|
|
|
{ RD7914CTID, 0, "7914CT", NRD7914PBPT,
|
|
|
|
NRD7914PTRK, 1152, 258048 },
|
|
|
|
|
|
|
|
{ RD7946AID, 0, "7946A", NRD7945ABPT,
|
|
|
|
NRD7945ATRK, 968, 108416 },
|
|
|
|
|
|
|
|
{ RD9134LID, 1, "9122D", NRD9122SBPT,
|
|
|
|
NRD9122STRK, 77, 1232 },
|
|
|
|
|
|
|
|
{ RD7957BID, 0, "7957B", NRD7957BBPT,
|
|
|
|
NRD7957BTRK, 1269, 159894 },
|
|
|
|
|
|
|
|
{ RD7958BID, 0, "7958B", NRD7958BBPT,
|
|
|
|
NRD7958BTRK, 786, 297108 },
|
|
|
|
|
|
|
|
{ RD7959BID, 0, "7959B", NRD7959BBPT,
|
|
|
|
NRD7959BTRK, 1572, 594216 },
|
|
|
|
|
|
|
|
{ RD2200AID, 0, "2200A", NRD2200ABPT,
|
|
|
|
NRD2200ATRK, 1449, 654948 },
|
|
|
|
|
|
|
|
{ RD2203AID, 0, "2203A", NRD2203ABPT,
|
|
|
|
NRD2203ATRK, 1449, 1309896 }
|
1993-05-13 17:56:20 +04:00
|
|
|
};
|
1994-05-23 09:58:16 +04:00
|
|
|
int numrdidentinfo = sizeof(rdidentinfo) / sizeof(rdidentinfo[0]);
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1997-04-03 02:37:21 +04:00
|
|
|
bdev_decl(rd);
|
|
|
|
cdev_decl(rd);
|
|
|
|
|
|
|
|
int rdident __P((struct device *, struct rd_softc *,
|
|
|
|
struct hpibbus_attach_args *));
|
|
|
|
void rdreset __P((struct rd_softc *));
|
|
|
|
void rdustart __P((struct rd_softc *));
|
|
|
|
int rdgetinfo __P((dev_t));
|
|
|
|
void rdrestart __P((void *));
|
|
|
|
struct buf *rdfinish __P((struct rd_softc *, struct buf *));
|
|
|
|
|
|
|
|
void rdrestart __P((void *));
|
|
|
|
void rdustart __P((struct rd_softc *));
|
|
|
|
struct buf *rdfinish __P((struct rd_softc *, struct buf *));
|
|
|
|
void rdstart __P((void *));
|
|
|
|
void rdgo __P((void *));
|
|
|
|
void rdintr __P((void *));
|
|
|
|
int rdstatus __P((struct rd_softc *));
|
|
|
|
int rderror __P((int));
|
|
|
|
#ifdef DEBUG
|
|
|
|
void rdprinterr __P((char *, short, char **));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int rdmatch __P((struct device *, struct cfdata *, void *));
|
|
|
|
void rdattach __P((struct device *, struct device *, void *));
|
|
|
|
|
|
|
|
struct cfattach rd_ca = {
|
|
|
|
sizeof(struct rd_softc), rdmatch, rdattach
|
|
|
|
};
|
|
|
|
|
1998-01-12 21:30:41 +03:00
|
|
|
extern struct cfdriver rd_cd;
|
1997-04-03 02:37:21 +04:00
|
|
|
|
1995-12-02 21:21:49 +03:00
|
|
|
int
|
1997-01-30 12:14:10 +03:00
|
|
|
rdmatch(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:14:10 +03:00
|
|
|
struct hpibbus_attach_args *ha = aux;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1997-01-30 12:14:10 +03:00
|
|
|
/*
|
|
|
|
* Set punit if operator specified one in the kernel
|
|
|
|
* configuration file.
|
|
|
|
*/
|
1997-07-22 19:20:20 +04:00
|
|
|
if (match->hpibbuscf_punit != HPIBBUSCF_PUNIT_DEFAULT &&
|
1997-01-30 12:14:10 +03:00
|
|
|
match->hpibbuscf_punit < HPIB_NPUNITS)
|
|
|
|
ha->ha_punit = match->hpibbuscf_punit;
|
|
|
|
|
|
|
|
if (rdident(parent, NULL, ha) == 0) {
|
1996-01-10 23:54:29 +03:00
|
|
|
/*
|
1997-01-30 12:14:10 +03:00
|
|
|
* XXX Some aging HP-IB drives are slow to
|
|
|
|
* XXX respond; give them a chance to catch
|
|
|
|
* XXX up and probe them again.
|
1996-01-10 23:54:29 +03:00
|
|
|
*/
|
1997-01-30 12:14:10 +03:00
|
|
|
delay(10000);
|
|
|
|
ha->ha_id = hpibid(parent->dv_unit, ha->ha_slave);
|
|
|
|
return (rdident(parent, NULL, ha));
|
1996-01-10 23:54:29 +03:00
|
|
|
}
|
1997-01-30 12:14:10 +03:00
|
|
|
return (1);
|
|
|
|
}
|
1996-01-08 01:01:38 +03:00
|
|
|
|
1997-01-30 12:14:10 +03:00
|
|
|
void
|
|
|
|
rdattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct rd_softc *sc = (struct rd_softc *)self;
|
|
|
|
struct hpibbus_attach_args *ha = aux;
|
|
|
|
|
|
|
|
if (rdident(parent, sc, ha) == 0) {
|
|
|
|
printf("\n%s: didn't respond to describe command!\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
return;
|
|
|
|
}
|
1996-01-08 01:01:38 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize and attach the disk structure.
|
|
|
|
*/
|
1997-01-30 12:14:10 +03:00
|
|
|
bzero(&sc->sc_dkdev, sizeof(sc->sc_dkdev));
|
|
|
|
sc->sc_dkdev.dk_name = sc->sc_dev.dv_xname;
|
|
|
|
disk_attach(&sc->sc_dkdev);
|
1995-12-02 21:21:49 +03:00
|
|
|
|
1997-01-30 12:14:10 +03:00
|
|
|
sc->sc_slave = ha->ha_slave;
|
|
|
|
sc->sc_punit = ha->ha_punit;
|
1995-12-02 21:21:49 +03:00
|
|
|
|
1997-01-30 12:14:10 +03:00
|
|
|
/* Initialize the hpib job queue entry */
|
|
|
|
sc->sc_hq.hq_softc = sc;
|
|
|
|
sc->sc_hq.hq_slave = sc->sc_slave;
|
|
|
|
sc->sc_hq.hq_start = rdstart;
|
|
|
|
sc->sc_hq.hq_go = rdgo;
|
|
|
|
sc->sc_hq.hq_intr = rdintr;
|
1995-12-02 21:21:49 +03:00
|
|
|
|
1997-01-30 12:14:10 +03:00
|
|
|
sc->sc_flags = RDF_ALIVE;
|
1993-05-13 17:56:20 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* always report errors */
|
|
|
|
if (rddebug & RDB_ERROR)
|
|
|
|
rderrthresh = 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1995-12-02 21:21:49 +03:00
|
|
|
int
|
1997-01-30 12:14:10 +03:00
|
|
|
rdident(parent, sc, ha)
|
|
|
|
struct device *parent;
|
|
|
|
struct rd_softc *sc;
|
|
|
|
struct hpibbus_attach_args *ha;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:14:10 +03:00
|
|
|
struct rd_describe *desc = sc != NULL ? &sc->sc_rddesc : NULL;
|
1993-05-13 17:56:20 +04:00
|
|
|
u_char stat, cmd[3];
|
|
|
|
char name[7];
|
1997-01-30 12:14:10 +03:00
|
|
|
int i, id, n, ctlr, slave;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1997-01-30 12:14:10 +03:00
|
|
|
ctlr = parent->dv_unit;
|
|
|
|
slave = ha->ha_slave;
|
|
|
|
|
|
|
|
/* Verify that we have a CS80 device. */
|
|
|
|
if ((ha->ha_id & 0x200) == 0)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
/* Is it one of the disks we support? */
|
|
|
|
for (id = 0; id < numrdidentinfo; id++)
|
|
|
|
if (ha->ha_id == rdidentinfo[id].ri_hwid)
|
|
|
|
break;
|
|
|
|
if (id == numrdidentinfo || ha->ha_punit > rdidentinfo[id].ri_maxunum)
|
|
|
|
return (0);
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
/*
|
1997-01-30 12:14:10 +03:00
|
|
|
* If we're just probing for the device, that's all the
|
|
|
|
* work we need to do.
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
1997-01-30 12:14:10 +03:00
|
|
|
if (sc == NULL)
|
|
|
|
return (1);
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
/*
|
1997-01-30 12:14:10 +03:00
|
|
|
* Reset device and collect description
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
1997-01-30 12:14:10 +03:00
|
|
|
rdreset(sc);
|
|
|
|
cmd[0] = C_SUNIT(ha->ha_punit);
|
1993-05-13 17:56:20 +04:00
|
|
|
cmd[1] = C_SVOL(0);
|
|
|
|
cmd[2] = C_DESC;
|
|
|
|
hpibsend(ctlr, slave, C_CMD, cmd, sizeof(cmd));
|
1995-11-19 22:07:18 +03:00
|
|
|
hpibrecv(ctlr, slave, C_EXEC, desc, 37);
|
1993-05-13 17:56:20 +04:00
|
|
|
hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
|
1997-01-30 12:14:10 +03:00
|
|
|
bzero(name, sizeof(name));
|
|
|
|
if (stat == 0) {
|
|
|
|
n = desc->d_name;
|
1993-05-13 17:56:20 +04:00
|
|
|
for (i = 5; i >= 0; i--) {
|
|
|
|
name[i] = (n & 0xf) + '0';
|
|
|
|
n >>= 4;
|
|
|
|
}
|
|
|
|
}
|
1997-01-30 12:14:10 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (rddebug & RDB_IDENT) {
|
1997-01-30 12:14:10 +03:00
|
|
|
printf("\n%s: name: %x ('%s')\n",
|
|
|
|
sc->sc_dev.dv_xname, desc->d_name, name);
|
1996-10-13 07:14:05 +04:00
|
|
|
printf(" iuw %x, maxxfr %d, ctype %d\n",
|
1997-01-30 12:14:10 +03:00
|
|
|
desc->d_iuw, desc->d_cmaxxfr, desc->d_ctype);
|
1996-10-13 07:14:05 +04:00
|
|
|
printf(" utype %d, bps %d, blkbuf %d, burst %d, blktime %d\n",
|
1997-01-30 12:14:10 +03:00
|
|
|
desc->d_utype, desc->d_sectsize,
|
|
|
|
desc->d_blkbuf, desc->d_burstsize, desc->d_blocktime);
|
1996-10-13 07:14:05 +04:00
|
|
|
printf(" avxfr %d, ort %d, atp %d, maxint %d, fv %x, rv %x\n",
|
1997-01-30 12:14:10 +03:00
|
|
|
desc->d_uavexfr, desc->d_retry, desc->d_access,
|
|
|
|
desc->d_maxint, desc->d_fvbyte, desc->d_rvbyte);
|
1996-10-13 07:14:05 +04:00
|
|
|
printf(" maxcyl/head/sect %d/%d/%d, maxvsect %d, inter %d\n",
|
1997-01-30 12:14:10 +03:00
|
|
|
desc->d_maxcyl, desc->d_maxhead, desc->d_maxsect,
|
|
|
|
desc->d_maxvsectl, desc->d_interleave);
|
|
|
|
printf("%s", sc->sc_dev.dv_xname);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
#endif
|
1997-01-30 12:14:10 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
1997-01-30 12:14:10 +03:00
|
|
|
switch (ha->ha_id) {
|
1993-05-13 17:56:20 +04:00
|
|
|
case RD7946AID:
|
|
|
|
if (bcmp(name, "079450", 6) == 0)
|
|
|
|
id = RD7945A;
|
|
|
|
else
|
|
|
|
id = RD7946A;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RD9134LID:
|
|
|
|
if (bcmp(name, "091340", 6) == 0)
|
|
|
|
id = RD9134L;
|
|
|
|
else
|
|
|
|
id = RD9122D;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RD9134DID:
|
|
|
|
if (bcmp(name, "091220", 6) == 0)
|
|
|
|
id = RD9122S;
|
|
|
|
else
|
|
|
|
id = RD9134D;
|
|
|
|
break;
|
|
|
|
}
|
1997-01-30 12:14:10 +03:00
|
|
|
|
|
|
|
sc->sc_type = id;
|
|
|
|
|
1995-11-19 22:07:18 +03:00
|
|
|
/*
|
|
|
|
* XXX We use DEV_BSIZE instead of the sector size value pulled
|
1997-01-30 12:14:10 +03:00
|
|
|
* XXX off the driver because all of this code assumes 512 byte
|
|
|
|
* XXX blocks. ICK!
|
1995-11-19 22:07:18 +03:00
|
|
|
*/
|
1997-01-30 12:14:10 +03:00
|
|
|
printf(": %s\n", rdidentinfo[id].ri_desc);
|
|
|
|
printf("%s: %d cylinders, %d heads, %d blocks, %d bytes/block\n",
|
|
|
|
sc->sc_dev.dv_xname, rdidentinfo[id].ri_ncyl,
|
|
|
|
rdidentinfo[id].ri_ntpc, rdidentinfo[id].ri_nblocks,
|
|
|
|
DEV_BSIZE);
|
|
|
|
|
|
|
|
return (1);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1997-01-30 12:14:10 +03:00
|
|
|
void
|
|
|
|
rdreset(rs)
|
1997-03-31 11:32:14 +04:00
|
|
|
struct rd_softc *rs;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:14:10 +03:00
|
|
|
int ctlr = rs->sc_dev.dv_parent->dv_unit;
|
|
|
|
int slave = rs->sc_slave;
|
1993-05-13 17:56:20 +04:00
|
|
|
u_char stat;
|
|
|
|
|
|
|
|
rs->sc_clear.c_unit = C_SUNIT(rs->sc_punit);
|
|
|
|
rs->sc_clear.c_cmd = C_CLEAR;
|
1997-01-30 12:14:10 +03:00
|
|
|
hpibsend(ctlr, slave, C_TCMD, &rs->sc_clear, sizeof(rs->sc_clear));
|
|
|
|
hpibswait(ctlr, slave);
|
|
|
|
hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
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;
|
1997-01-30 12:14:10 +03:00
|
|
|
hpibsend(ctlr, slave, C_CMD, &rs->sc_src, sizeof(rs->sc_src));
|
|
|
|
hpibswait(ctlr, slave);
|
|
|
|
hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
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;
|
1997-01-30 12:14:10 +03:00
|
|
|
hpibsend(ctlr, slave, C_CMD, &rs->sc_ssmc, sizeof(rs->sc_ssmc));
|
|
|
|
hpibswait(ctlr, slave);
|
|
|
|
hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
|
1993-05-13 17:56:20 +04:00
|
|
|
#ifdef DEBUG
|
1997-01-30 12:14:10 +03:00
|
|
|
rs->sc_stats.rdresets++;
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
/*
|
|
|
|
* Read or constuct a disklabel
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
rdgetinfo(dev)
|
|
|
|
dev_t dev;
|
|
|
|
{
|
|
|
|
int unit = rdunit(dev);
|
1997-01-30 12:14:10 +03:00
|
|
|
struct rd_softc *rs = rd_cd.cd_devs[unit];
|
1997-03-31 11:32:14 +04:00
|
|
|
struct disklabel *lp = rs->sc_dkdev.dk_label;
|
|
|
|
struct partition *pi;
|
|
|
|
char *msg;
|
1994-05-23 09:58:16 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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_type = DTYPE_HPIB;
|
|
|
|
lp->d_secsize = DEV_BSIZE;
|
|
|
|
lp->d_nsectors = 32;
|
|
|
|
lp->d_ntracks = 20;
|
|
|
|
lp->d_ncylinders = 1;
|
|
|
|
lp->d_secpercyl = 32*20;
|
|
|
|
lp->d_npartitions = 3;
|
|
|
|
lp->d_partitions[2].p_offset = 0;
|
|
|
|
lp->d_partitions[2].p_size = LABELSECTOR+1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now try to read the disklabel
|
|
|
|
*/
|
1995-12-09 10:31:03 +03:00
|
|
|
msg = readdisklabel(rdlabdev(dev), rdstrategy, lp, NULL);
|
1994-05-23 09:58:16 +04:00
|
|
|
if (msg == NULL)
|
1997-03-31 11:32:14 +04:00
|
|
|
return (0);
|
1994-05-23 09:58:16 +04:00
|
|
|
|
|
|
|
pi = lp->d_partitions;
|
1997-01-30 12:14:10 +03:00
|
|
|
printf("%s: WARNING: %s, ", rs->sc_dev.dv_xname, msg);
|
1994-05-23 09:58:16 +04:00
|
|
|
#ifdef COMPAT_NOLABEL
|
1996-10-13 07:14:05 +04:00
|
|
|
printf("using old default partitioning\n");
|
1994-05-23 09:58:16 +04:00
|
|
|
rdmakedisklabel(unit, lp);
|
|
|
|
#else
|
1996-10-13 07:14:05 +04:00
|
|
|
printf("defining `c' partition as entire disk\n");
|
1994-05-23 09:58:16 +04:00
|
|
|
pi[2].p_size = rdidentinfo[rs->sc_type].ri_nblocks;
|
1994-05-27 21:18:50 +04:00
|
|
|
/* XXX reset other info since readdisklabel screws with it */
|
|
|
|
lp->d_npartitions = 3;
|
|
|
|
pi[0].p_size = 0;
|
1994-05-23 09:58:16 +04:00
|
|
|
#endif
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
int
|
|
|
|
rdopen(dev, flags, mode, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flags, mode;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1997-03-31 11:32:14 +04:00
|
|
|
int unit = rdunit(dev);
|
|
|
|
struct rd_softc *rs;
|
1997-01-07 12:29:30 +03:00
|
|
|
int error, mask, part;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1997-01-30 12:14:10 +03:00
|
|
|
if (unit >= rd_cd.cd_ndevs ||
|
|
|
|
(rs = rd_cd.cd_devs[unit]) == NULL ||
|
|
|
|
(rs->sc_flags & RDF_ALIVE) == 0)
|
|
|
|
return (ENXIO);
|
1994-05-23 09:58:16 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
1996-01-08 01:01:38 +03:00
|
|
|
if (rs->sc_dkdev.dk_openmask == 0) {
|
1994-05-23 09:58:16 +04:00
|
|
|
rs->sc_flags |= RDF_OPENING;
|
|
|
|
error = rdgetinfo(dev);
|
|
|
|
rs->sc_flags &= ~RDF_OPENING;
|
|
|
|
wakeup((caddr_t)rs);
|
|
|
|
if (error)
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
1997-01-07 12:29:30 +03:00
|
|
|
part = rdpart(dev);
|
|
|
|
mask = 1 << part;
|
|
|
|
|
|
|
|
/* Check that the partition exists. */
|
|
|
|
if (part != RAW_PART &&
|
|
|
|
(part > rs->sc_dkdev.dk_label->d_npartitions ||
|
|
|
|
rs->sc_dkdev.dk_label->d_partitions[part].p_fstype == FS_UNUSED))
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
/* Ensure only one open at a time. */
|
|
|
|
switch (mode) {
|
|
|
|
case S_IFCHR:
|
1996-01-08 01:01:38 +03:00
|
|
|
rs->sc_dkdev.dk_copenmask |= mask;
|
1997-01-07 12:29:30 +03:00
|
|
|
break;
|
|
|
|
case S_IFBLK:
|
1996-01-08 01:01:38 +03:00
|
|
|
rs->sc_dkdev.dk_bopenmask |= mask;
|
1997-01-07 12:29:30 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
rs->sc_dkdev.dk_openmask =
|
|
|
|
rs->sc_dkdev.dk_copenmask | rs->sc_dkdev.dk_bopenmask;
|
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rdclose(dev, flag, mode, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, mode;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
int unit = rdunit(dev);
|
1997-01-30 12:14:10 +03:00
|
|
|
struct rd_softc *rs = rd_cd.cd_devs[unit];
|
1997-03-31 11:32:14 +04:00
|
|
|
struct disk *dk = &rs->sc_dkdev;
|
1994-05-23 09:58:16 +04:00
|
|
|
int mask, s;
|
|
|
|
|
|
|
|
mask = 1 << rdpart(dev);
|
|
|
|
if (mode == S_IFCHR)
|
1996-01-08 01:01:38 +03:00
|
|
|
dk->dk_copenmask &= ~mask;
|
1994-05-23 09:58:16 +04:00
|
|
|
else
|
1996-01-08 01:01:38 +03:00
|
|
|
dk->dk_bopenmask &= ~mask;
|
|
|
|
dk->dk_openmask = dk->dk_copenmask | dk->dk_bopenmask;
|
1994-05-23 09:58:16 +04:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
* we are the last one.
|
|
|
|
*/
|
1996-01-08 01:01:38 +03:00
|
|
|
if (dk->dk_openmask == 0) {
|
1994-05-23 09:58:16 +04:00
|
|
|
rs->sc_flags |= RDF_CLOSING;
|
|
|
|
s = splbio();
|
1997-01-30 12:14:10 +03:00
|
|
|
while (rs->sc_tab.b_active) {
|
1994-05-23 09:58:16 +04:00
|
|
|
rs->sc_flags |= RDF_WANTED;
|
1997-01-30 12:14:10 +03:00
|
|
|
sleep((caddr_t)&rs->sc_tab, PRIBIO);
|
1994-05-23 09:58:16 +04:00
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
rs->sc_flags &= ~(RDF_CLOSING|RDF_WLABEL);
|
|
|
|
wakeup((caddr_t)rs);
|
|
|
|
}
|
1993-05-13 17:56:20 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
1994-01-11 20:19:37 +03:00
|
|
|
void
|
1993-05-13 17:56:20 +04:00
|
|
|
rdstrategy(bp)
|
1997-03-31 11:32:14 +04:00
|
|
|
struct buf *bp;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1994-05-23 09:58:16 +04:00
|
|
|
int unit = rdunit(bp->b_dev);
|
1997-01-30 12:14:10 +03:00
|
|
|
struct rd_softc *rs = rd_cd.cd_devs[unit];
|
1997-03-31 11:32:14 +04:00
|
|
|
struct buf *dp = &rs->sc_tab;
|
|
|
|
struct partition *pinfo;
|
|
|
|
daddr_t bn;
|
|
|
|
int sz, s;
|
1997-01-07 12:29:30 +03:00
|
|
|
int offset;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (rddebug & RDB_FOLLOW)
|
1997-04-03 02:37:21 +04:00
|
|
|
printf("rdstrategy(%p): dev %x, bn %x, bcount %lx, %c\n",
|
1993-05-13 17:56:20 +04:00
|
|
|
bp, bp->b_dev, bp->b_blkno, bp->b_bcount,
|
|
|
|
(bp->b_flags & B_READ) ? 'R' : 'W');
|
|
|
|
#endif
|
|
|
|
bn = bp->b_blkno;
|
|
|
|
sz = howmany(bp->b_bcount, DEV_BSIZE);
|
1996-01-08 01:01:38 +03:00
|
|
|
pinfo = &rs->sc_dkdev.dk_label->d_partitions[rdpart(bp->b_dev)];
|
1997-01-07 12:29:30 +03:00
|
|
|
|
|
|
|
/* Don't perform partition translation on RAW_PART. */
|
|
|
|
offset = (rdpart(bp->b_dev) == RAW_PART) ? 0 : pinfo->p_offset;
|
|
|
|
|
|
|
|
if (rdpart(bp->b_dev) != RAW_PART) {
|
|
|
|
/*
|
|
|
|
* XXX This block of code belongs in
|
|
|
|
* XXX bounds_check_with_label()
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (bn < 0 || bn + sz > pinfo->p_size) {
|
|
|
|
sz = pinfo->p_size - bn;
|
|
|
|
if (sz == 0) {
|
|
|
|
bp->b_resid = bp->b_bcount;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (sz < 0) {
|
|
|
|
bp->b_error = EINVAL;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
bp->b_bcount = dbtob(sz);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1997-01-07 12:29:30 +03:00
|
|
|
/*
|
|
|
|
* Check for write to write protected label
|
|
|
|
*/
|
|
|
|
if (bn + offset <= LABELSECTOR &&
|
1994-05-23 09:58:16 +04:00
|
|
|
#if LABELSECTOR != 0
|
1997-01-07 12:29:30 +03:00
|
|
|
bn + offset + sz > LABELSECTOR &&
|
1994-05-23 09:58:16 +04:00
|
|
|
#endif
|
1997-01-07 12:29:30 +03:00
|
|
|
!(bp->b_flags & B_READ) && !(rs->sc_flags & RDF_WLABEL)) {
|
|
|
|
bp->b_error = EROFS;
|
|
|
|
goto bad;
|
|
|
|
}
|
1994-05-23 09:58:16 +04:00
|
|
|
}
|
1997-01-07 12:29:30 +03:00
|
|
|
bp->b_cylin = bn + offset;
|
1993-05-13 17:56:20 +04:00
|
|
|
s = splbio();
|
|
|
|
disksort(dp, bp);
|
|
|
|
if (dp->b_active == 0) {
|
|
|
|
dp->b_active = 1;
|
1997-01-30 12:14:10 +03:00
|
|
|
rdustart(rs);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
return;
|
1994-05-23 09:58:16 +04:00
|
|
|
bad:
|
|
|
|
bp->b_flags |= B_ERROR;
|
1993-05-13 17:56:20 +04:00
|
|
|
done:
|
|
|
|
biodone(bp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called from timeout() when handling maintenance releases
|
|
|
|
*/
|
1994-05-23 09:58:16 +04:00
|
|
|
void
|
1994-05-05 14:10:21 +04:00
|
|
|
rdrestart(arg)
|
|
|
|
void *arg;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
|
|
|
int s = splbio();
|
1997-01-30 12:14:10 +03:00
|
|
|
rdustart((struct rd_softc *)arg);
|
1993-05-13 17:56:20 +04:00
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
1997-01-30 12:14:10 +03:00
|
|
|
void
|
|
|
|
rdustart(rs)
|
|
|
|
struct rd_softc *rs;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-03-31 11:32:14 +04:00
|
|
|
struct buf *bp;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1997-01-30 12:14:10 +03:00
|
|
|
bp = rs->sc_tab.b_actf;
|
1993-05-13 17:56:20 +04:00
|
|
|
rs->sc_addr = bp->b_un.b_addr;
|
|
|
|
rs->sc_resid = bp->b_bcount;
|
1997-01-30 12:14:10 +03:00
|
|
|
if (hpibreq(rs->sc_dev.dv_parent, &rs->sc_hq))
|
|
|
|
rdstart(rs);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
struct buf *
|
1997-01-30 12:14:10 +03:00
|
|
|
rdfinish(rs, bp)
|
1997-03-31 11:32:14 +04:00
|
|
|
struct rd_softc *rs;
|
|
|
|
struct buf *bp;
|
1994-05-23 09:58:16 +04:00
|
|
|
{
|
1997-03-31 11:32:14 +04:00
|
|
|
struct buf *dp = &rs->sc_tab;
|
1994-05-23 09:58:16 +04:00
|
|
|
|
|
|
|
dp->b_errcnt = 0;
|
|
|
|
dp->b_actf = bp->b_actf;
|
|
|
|
bp->b_resid = 0;
|
|
|
|
biodone(bp);
|
1997-01-30 12:14:10 +03:00
|
|
|
hpibfree(rs->sc_dev.dv_parent, &rs->sc_hq);
|
1994-05-23 09:58:16 +04:00
|
|
|
if (dp->b_actf)
|
1997-01-30 12:14:10 +03:00
|
|
|
return (dp->b_actf);
|
1994-05-23 09:58:16 +04:00
|
|
|
dp->b_active = 0;
|
|
|
|
if (rs->sc_flags & RDF_WANTED) {
|
|
|
|
rs->sc_flags &= ~RDF_WANTED;
|
|
|
|
wakeup((caddr_t)dp);
|
|
|
|
}
|
1997-01-30 12:14:10 +03:00
|
|
|
return (NULL);
|
1994-05-23 09:58:16 +04:00
|
|
|
}
|
|
|
|
|
1997-01-30 12:14:10 +03:00
|
|
|
void
|
|
|
|
rdstart(arg)
|
|
|
|
void *arg;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:14:10 +03:00
|
|
|
struct rd_softc *rs = arg;
|
1997-03-31 11:32:14 +04:00
|
|
|
struct buf *bp = rs->sc_tab.b_actf;
|
|
|
|
int part, ctlr, slave;
|
1997-01-30 12:14:10 +03:00
|
|
|
|
|
|
|
ctlr = rs->sc_dev.dv_parent->dv_unit;
|
|
|
|
slave = rs->sc_slave;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
again:
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (rddebug & RDB_FOLLOW)
|
1997-04-03 02:37:21 +04:00
|
|
|
printf("rdstart(%s): bp %p, %c\n", rs->sc_dev.dv_xname, bp,
|
1993-05-13 17:56:20 +04:00
|
|
|
(bp->b_flags & B_READ) ? 'R' : 'W');
|
|
|
|
#endif
|
|
|
|
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_hiaddr = 0;
|
1994-05-23 09:58:16 +04:00
|
|
|
rs->sc_ioc.c_addr = RDBTOS(bp->b_cylin);
|
1993-05-13 17:56:20 +04:00
|
|
|
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;
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (rddebug & RDB_IO)
|
1997-04-03 02:37:21 +04:00
|
|
|
printf("rdstart: hpibsend(%x, %x, %x, %p, %x)\n",
|
1997-01-30 12:14:10 +03:00
|
|
|
ctlr, slave, C_CMD,
|
1993-05-13 17:56:20 +04:00
|
|
|
&rs->sc_ioc.c_unit, sizeof(rs->sc_ioc)-2);
|
|
|
|
#endif
|
1997-01-30 12:14:10 +03:00
|
|
|
if (hpibsend(ctlr, slave, C_CMD, &rs->sc_ioc.c_unit,
|
1993-05-13 17:56:20 +04:00
|
|
|
sizeof(rs->sc_ioc)-2) == sizeof(rs->sc_ioc)-2) {
|
1996-01-08 01:01:38 +03:00
|
|
|
|
|
|
|
/* Instrumentation. */
|
|
|
|
disk_busy(&rs->sc_dkdev);
|
|
|
|
rs->sc_dkdev.dk_seek++;
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (rddebug & RDB_IO)
|
1997-01-30 12:14:10 +03:00
|
|
|
printf("rdstart: hpibawait(%x)\n", ctlr);
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
1997-01-30 12:14:10 +03:00
|
|
|
hpibawait(ctlr);
|
1993-05-13 17:56:20 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (rddebug & RDB_ERROR)
|
1997-04-03 02:37:21 +04:00
|
|
|
printf("%s: rdstart: cmd %x adr %lx blk %d len %d ecnt %ld\n",
|
1997-01-30 12:14:10 +03:00
|
|
|
rs->sc_dev.dv_xname, rs->sc_ioc.c_cmd, rs->sc_ioc.c_addr,
|
|
|
|
bp->b_blkno, rs->sc_resid, rs->sc_tab.b_errcnt);
|
|
|
|
rs->sc_stats.rdretries++;
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
|
|
|
rs->sc_flags &= ~RDF_SEEK;
|
1997-01-30 12:14:10 +03:00
|
|
|
rdreset(rs);
|
|
|
|
if (rs->sc_tab.b_errcnt++ < RDRETRY)
|
1993-05-13 17:56:20 +04:00
|
|
|
goto again;
|
1997-03-31 11:32:14 +04:00
|
|
|
printf("%s: rdstart err: cmd 0x%x sect %ld blk %d len %d\n",
|
1997-01-30 12:14:10 +03:00
|
|
|
rs->sc_dev.dv_xname, rs->sc_ioc.c_cmd, rs->sc_ioc.c_addr,
|
1993-05-13 17:56:20 +04:00
|
|
|
bp->b_blkno, rs->sc_resid);
|
|
|
|
bp->b_flags |= B_ERROR;
|
|
|
|
bp->b_error = EIO;
|
1997-01-30 12:14:10 +03:00
|
|
|
bp = rdfinish(rs, bp);
|
1994-05-23 09:58:16 +04:00
|
|
|
if (bp) {
|
|
|
|
rs->sc_addr = bp->b_un.b_addr;
|
|
|
|
rs->sc_resid = bp->b_bcount;
|
1997-01-30 12:14:10 +03:00
|
|
|
if (hpibreq(rs->sc_dev.dv_parent, &rs->sc_hq))
|
1994-05-23 09:58:16 +04:00
|
|
|
goto again;
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-01-30 12:14:10 +03:00
|
|
|
void
|
|
|
|
rdgo(arg)
|
|
|
|
void *arg;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:14:10 +03:00
|
|
|
struct rd_softc *rs = arg;
|
|
|
|
struct buf *bp = rs->sc_tab.b_actf;
|
|
|
|
int rw, ctlr, slave;
|
|
|
|
|
|
|
|
ctlr = rs->sc_dev.dv_parent->dv_unit;
|
|
|
|
slave = rs->sc_slave;
|
1995-10-09 10:57:43 +03:00
|
|
|
|
|
|
|
rw = bp->b_flags & B_READ;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1996-01-08 01:01:38 +03:00
|
|
|
/* Instrumentation. */
|
|
|
|
disk_busy(&rs->sc_dkdev);
|
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
#ifdef USELEDS
|
1997-05-06 01:07:31 +04:00
|
|
|
ledcontrol(0, 0, LED_DISK);
|
1994-05-23 09:58:16 +04:00
|
|
|
#endif
|
1997-01-30 12:14:10 +03:00
|
|
|
hpibgo(ctlr, slave, C_EXEC, rs->sc_addr, rs->sc_resid, rw, rw != 0);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1997-01-30 12:14:10 +03:00
|
|
|
/* ARGSUSED */
|
|
|
|
void
|
1996-02-14 05:43:54 +03:00
|
|
|
rdintr(arg)
|
|
|
|
void *arg;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-03-31 11:32:14 +04:00
|
|
|
struct rd_softc *rs = arg;
|
1997-01-30 12:14:10 +03:00
|
|
|
int unit = rs->sc_dev.dv_unit;
|
1997-03-31 11:32:14 +04:00
|
|
|
struct buf *bp = rs->sc_tab.b_actf;
|
1993-05-13 17:56:20 +04:00
|
|
|
u_char stat = 13; /* in case hpibrecv fails */
|
1997-01-30 12:14:10 +03:00
|
|
|
int rv, restart, ctlr, slave;
|
|
|
|
|
|
|
|
ctlr = rs->sc_dev.dv_parent->dv_unit;
|
|
|
|
slave = rs->sc_slave;
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (rddebug & RDB_FOLLOW)
|
1997-04-03 02:37:21 +04:00
|
|
|
printf("rdintr(%d): bp %p, %c, flags %x\n", unit, bp,
|
1993-05-13 17:56:20 +04:00
|
|
|
(bp->b_flags & B_READ) ? 'R' : 'W', rs->sc_flags);
|
|
|
|
if (bp == NULL) {
|
1997-01-30 12:14:10 +03:00
|
|
|
printf("%s: bp == NULL\n", rs->sc_dev.dv_xname);
|
1993-05-13 17:56:20 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
1996-01-08 01:01:38 +03:00
|
|
|
disk_unbusy(&rs->sc_dkdev, (bp->b_bcount - bp->b_resid));
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
if (rs->sc_flags & RDF_SEEK) {
|
|
|
|
rs->sc_flags &= ~RDF_SEEK;
|
1997-01-30 12:14:10 +03:00
|
|
|
if (hpibustart(ctlr))
|
|
|
|
rdgo(rs);
|
1993-05-13 17:56:20 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((rs->sc_flags & RDF_SWAIT) == 0) {
|
|
|
|
#ifdef DEBUG
|
1997-01-30 12:14:10 +03:00
|
|
|
rs->sc_stats.rdpolltries++;
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
1997-01-30 12:14:10 +03:00
|
|
|
if (hpibpptest(ctlr, slave) == 0) {
|
1993-05-13 17:56:20 +04:00
|
|
|
#ifdef DEBUG
|
1997-01-30 12:14:10 +03:00
|
|
|
rs->sc_stats.rdpollwaits++;
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
1996-01-08 01:01:38 +03:00
|
|
|
|
|
|
|
/* Instrumentation. */
|
|
|
|
disk_busy(&rs->sc_dkdev);
|
1993-05-13 17:56:20 +04:00
|
|
|
rs->sc_flags |= RDF_SWAIT;
|
1997-01-30 12:14:10 +03:00
|
|
|
hpibawait(ctlr);
|
1993-05-13 17:56:20 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
rs->sc_flags &= ~RDF_SWAIT;
|
1997-01-30 12:14:10 +03:00
|
|
|
rv = hpibrecv(ctlr, slave, C_QSTAT, &stat, 1);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (rv != 1 || stat) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (rddebug & RDB_ERROR)
|
1996-10-13 07:14:05 +04:00
|
|
|
printf("rdintr: recv failed or bad stat %d\n", stat);
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
|
|
|
restart = rderror(unit);
|
|
|
|
#ifdef DEBUG
|
1997-01-30 12:14:10 +03:00
|
|
|
rs->sc_stats.rdretries++;
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
1997-01-30 12:14:10 +03:00
|
|
|
if (rs->sc_tab.b_errcnt++ < RDRETRY) {
|
1993-05-13 17:56:20 +04:00
|
|
|
if (restart)
|
1997-01-30 12:14:10 +03:00
|
|
|
rdstart(rs);
|
1993-05-13 17:56:20 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
bp->b_flags |= B_ERROR;
|
|
|
|
bp->b_error = EIO;
|
|
|
|
}
|
1997-01-30 12:14:10 +03:00
|
|
|
if (rdfinish(rs, bp))
|
|
|
|
rdustart(rs);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1997-01-30 12:14:10 +03:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
rdstatus(rs)
|
1997-03-31 11:32:14 +04:00
|
|
|
struct rd_softc *rs;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-03-31 11:32:14 +04:00
|
|
|
int c, s;
|
1993-05-13 17:56:20 +04:00
|
|
|
u_char stat;
|
|
|
|
int rv;
|
|
|
|
|
1997-01-30 12:14:10 +03:00
|
|
|
c = rs->sc_dev.dv_parent->dv_unit;
|
|
|
|
s = rs->sc_slave;
|
1993-05-13 17:56:20 +04:00
|
|
|
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)) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (rddebug & RDB_STATUS)
|
1996-10-13 07:14:05 +04:00
|
|
|
printf("rdstatus: send C_CMD failed %d != %d\n",
|
1993-05-13 17:56:20 +04:00
|
|
|
rv, sizeof(rs->sc_rsc));
|
|
|
|
#endif
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
rv = hpibrecv(c, s, C_EXEC, &rs->sc_stat, sizeof(rs->sc_stat));
|
|
|
|
if (rv != sizeof(rs->sc_stat)) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (rddebug & RDB_STATUS)
|
1996-10-13 07:14:05 +04:00
|
|
|
printf("rdstatus: send C_EXEC failed %d != %d\n",
|
1993-05-13 17:56:20 +04:00
|
|
|
rv, sizeof(rs->sc_stat));
|
|
|
|
#endif
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
rv = hpibrecv(c, s, C_QSTAT, &stat, 1);
|
|
|
|
if (rv != 1 || stat) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (rddebug & RDB_STATUS)
|
1996-10-13 07:14:05 +04:00
|
|
|
printf("rdstatus: recv failed %d or bad stat %d\n",
|
1993-05-13 17:56:20 +04:00
|
|
|
rv, stat);
|
|
|
|
#endif
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Deal with errors.
|
|
|
|
* Returns 1 if request should be restarted,
|
|
|
|
* 0 if we should just quietly give up.
|
|
|
|
*/
|
1997-01-30 12:14:10 +03:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
rderror(unit)
|
|
|
|
int unit;
|
|
|
|
{
|
1997-01-30 12:14:10 +03:00
|
|
|
struct rd_softc *rs = rd_cd.cd_devs[unit];
|
1997-03-31 11:32:14 +04:00
|
|
|
struct rd_stat *sp;
|
1993-05-13 17:56:20 +04:00
|
|
|
struct buf *bp;
|
|
|
|
daddr_t hwbn, pbn;
|
1997-03-31 11:32:14 +04:00
|
|
|
char *hexstr __P((int, int)); /* XXX */
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
if (rdstatus(rs)) {
|
|
|
|
#ifdef DEBUG
|
1997-01-30 12:14:10 +03:00
|
|
|
printf("%s: couldn't get status\n", rs->sc_dev.dv_xname);
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
1997-01-30 12:14:10 +03:00
|
|
|
rdreset(rs);
|
1993-05-13 17:56:20 +04:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
sp = &rs->sc_stat;
|
|
|
|
if (sp->c_fef & FEF_REXMT)
|
|
|
|
return(1);
|
|
|
|
if (sp->c_fef & FEF_PF) {
|
1997-01-30 12:14:10 +03:00
|
|
|
rdreset(rs);
|
1993-05-13 17:56:20 +04:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* 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) {
|
|
|
|
extern int hz;
|
1997-01-30 12:14:10 +03:00
|
|
|
int rdtimo = RDWAITC << rs->sc_tab.b_errcnt;
|
1993-05-13 17:56:20 +04:00
|
|
|
#ifdef DEBUG
|
1996-10-13 07:14:05 +04:00
|
|
|
printf("%s: internal maintenance, %d second timeout\n",
|
1997-01-30 12:14:10 +03:00
|
|
|
rs->sc_dev.dv_xname, rdtimo);
|
|
|
|
rs->sc_stats.rdtimeouts++;
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
1997-01-30 12:14:10 +03:00
|
|
|
hpibfree(rs->sc_dev.dv_parent, &rs->sc_hq);
|
|
|
|
timeout(rdrestart, rs, rdtimo * hz);
|
1993-05-13 17:56:20 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Only report error if we have reached the error reporting
|
|
|
|
* threshhold. By default, this will only report after the
|
|
|
|
* retry limit has been exceeded.
|
|
|
|
*/
|
1997-01-30 12:14:10 +03:00
|
|
|
if (rs->sc_tab.b_errcnt < rderrthresh)
|
1993-05-13 17:56:20 +04:00
|
|
|
return(1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First conjure up the block number at which the error occured.
|
|
|
|
* Note that not all errors report a block number, in that case
|
|
|
|
* we just use b_blkno.
|
|
|
|
*/
|
1997-01-30 12:14:10 +03:00
|
|
|
bp = rs->sc_tab.b_actf;
|
1996-01-08 01:01:38 +03:00
|
|
|
pbn = rs->sc_dkdev.dk_label->d_partitions[rdpart(bp->b_dev)].p_offset;
|
1993-05-13 17:56:20 +04:00
|
|
|
if ((sp->c_fef & FEF_CU) || (sp->c_fef & FEF_DR) ||
|
|
|
|
(sp->c_ief & IEF_RRMASK)) {
|
|
|
|
hwbn = RDBTOS(pbn + bp->b_blkno);
|
|
|
|
pbn = bp->b_blkno;
|
|
|
|
} else {
|
|
|
|
hwbn = sp->c_blk;
|
|
|
|
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.
|
|
|
|
*/
|
1997-01-30 12:14:10 +03:00
|
|
|
printf("%s%c: hard error sn%d\n", rs->sc_dev.dv_xname,
|
|
|
|
'a'+rdpart(bp->b_dev), pbn);
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Now report the status as returned by the hardware with
|
|
|
|
* attempt at interpretation (unless debugging).
|
|
|
|
*/
|
1997-01-30 12:14:10 +03:00
|
|
|
printf("%s %s error:", rs->sc_dev.dv_xname,
|
|
|
|
(bp->b_flags & B_READ) ? "read" : "write");
|
1993-05-13 17:56:20 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (rddebug & RDB_ERROR) {
|
|
|
|
/* status info */
|
1996-10-13 07:14:05 +04:00
|
|
|
printf("\n volume: %d, unit: %d\n",
|
1993-05-13 17:56:20 +04:00
|
|
|
(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);
|
1996-10-13 07:14:05 +04:00
|
|
|
printf(" block: %d, P1-P10: ", hwbn);
|
1997-04-10 00:01:04 +04:00
|
|
|
printf("0x%x", *(u_int *)&sp->c_raw[0]);
|
|
|
|
printf("0x%x", *(u_int *)&sp->c_raw[4]);
|
|
|
|
printf("0x%x\n", *(u_short *)&sp->c_raw[8]);
|
1993-05-13 17:56:20 +04:00
|
|
|
/* command */
|
1996-10-13 07:14:05 +04:00
|
|
|
printf(" ioc: ");
|
1997-04-10 00:01:04 +04:00
|
|
|
printf("0x%x", *(u_int *)&rs->sc_ioc.c_pad);
|
|
|
|
printf("0x%x", *(u_short *)&rs->sc_ioc.c_hiaddr);
|
|
|
|
printf("0x%x", *(u_int *)&rs->sc_ioc.c_addr);
|
|
|
|
printf("0x%x", *(u_short *)&rs->sc_ioc.c_nop2);
|
|
|
|
printf("0x%x", *(u_int *)&rs->sc_ioc.c_len);
|
|
|
|
printf("0x%x\n", *(u_short *)&rs->sc_ioc.c_cmd);
|
1993-05-13 17:56:20 +04:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
#endif
|
1996-10-13 07:14:05 +04:00
|
|
|
printf(" v%d u%d, R0x%x F0x%x A0x%x I0x%x\n",
|
1993-05-13 17:56:20 +04:00
|
|
|
(sp->c_vu>>4)&0xF, sp->c_vu&0xF,
|
|
|
|
sp->c_ref, sp->c_fef, sp->c_aef, sp->c_ief);
|
1996-10-13 07:14:05 +04:00
|
|
|
printf("P1-P10: ");
|
1997-04-10 00:01:04 +04:00
|
|
|
printf("0x%x", *(u_int *)&sp->c_raw[0]);
|
|
|
|
printf("0x%x", *(u_int *)&sp->c_raw[4]);
|
|
|
|
printf("0x%x\n", *(u_short *)&sp->c_raw[8]);
|
1993-05-13 17:56:20 +04:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
1995-08-04 12:12:57 +04:00
|
|
|
int
|
|
|
|
rdread(dev, uio, flags)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
|
|
|
int flags;
|
|
|
|
{
|
|
|
|
|
|
|
|
return (physio(rdstrategy, NULL, dev, B_READ, minphys, uio));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rdwrite(dev, uio, flags)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
|
|
|
int flags;
|
|
|
|
{
|
|
|
|
|
|
|
|
return (physio(rdstrategy, NULL, dev, B_WRITE, minphys, uio));
|
|
|
|
}
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
int
|
|
|
|
rdioctl(dev, cmd, data, flag, p)
|
|
|
|
dev_t dev;
|
1997-01-30 12:14:10 +03:00
|
|
|
u_long cmd;
|
1993-05-13 17:56:20 +04:00
|
|
|
caddr_t data;
|
|
|
|
int flag;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1994-05-23 09:58:16 +04:00
|
|
|
int unit = rdunit(dev);
|
1997-01-30 12:14:10 +03:00
|
|
|
struct rd_softc *sc = rd_cd.cd_devs[unit];
|
1997-03-31 11:32:14 +04:00
|
|
|
struct disklabel *lp = sc->sc_dkdev.dk_label;
|
1994-05-23 09:58:16 +04:00
|
|
|
int error, flags;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case DIOCGDINFO:
|
|
|
|
*(struct disklabel *)data = *lp;
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case DIOCGPART:
|
|
|
|
((struct partinfo *)data)->disklab = lp;
|
|
|
|
((struct partinfo *)data)->part =
|
|
|
|
&lp->d_partitions[rdpart(dev)];
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case DIOCWLABEL:
|
|
|
|
if ((flag & FWRITE) == 0)
|
|
|
|
return (EBADF);
|
|
|
|
if (*(int *)data)
|
|
|
|
sc->sc_flags |= RDF_WLABEL;
|
|
|
|
else
|
|
|
|
sc->sc_flags &= ~RDF_WLABEL;
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case DIOCSDINFO:
|
|
|
|
if ((flag & FWRITE) == 0)
|
|
|
|
return (EBADF);
|
|
|
|
return (setdisklabel(lp, (struct disklabel *)data,
|
|
|
|
(sc->sc_flags & RDF_WLABEL) ? 0
|
1996-01-08 01:01:38 +03:00
|
|
|
: sc->sc_dkdev.dk_openmask,
|
1994-05-23 09:58:16 +04:00
|
|
|
(struct cpu_disklabel *)0));
|
|
|
|
|
|
|
|
case DIOCWDINFO:
|
|
|
|
if ((flag & FWRITE) == 0)
|
|
|
|
return (EBADF);
|
|
|
|
error = setdisklabel(lp, (struct disklabel *)data,
|
|
|
|
(sc->sc_flags & RDF_WLABEL) ? 0
|
1996-01-08 01:01:38 +03:00
|
|
|
: sc->sc_dkdev.dk_openmask,
|
1994-05-23 09:58:16 +04:00
|
|
|
(struct cpu_disklabel *)0);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
flags = sc->sc_flags;
|
|
|
|
sc->sc_flags = RDF_ALIVE | RDF_WLABEL;
|
|
|
|
error = writedisklabel(rdlabdev(dev), rdstrategy, lp,
|
|
|
|
(struct cpu_disklabel *)0);
|
|
|
|
sc->sc_flags = flags;
|
|
|
|
return (error);
|
|
|
|
}
|
1993-05-13 17:56:20 +04:00
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rdsize(dev)
|
|
|
|
dev_t dev;
|
|
|
|
{
|
1997-03-31 11:32:14 +04:00
|
|
|
int unit = rdunit(dev);
|
1997-01-30 12:14:10 +03:00
|
|
|
struct rd_softc *rs;
|
1994-05-23 09:58:16 +04:00
|
|
|
int psize, didopen = 0;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1997-01-30 12:14:10 +03:00
|
|
|
if (unit >= rd_cd.cd_ndevs ||
|
|
|
|
(rs = rd_cd.cd_devs[unit]) == NULL ||
|
|
|
|
(rs->sc_flags & RDF_ALIVE) == 0)
|
|
|
|
return (-1);
|
1994-05-23 09:58:16 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We get called very early on (via swapconf)
|
|
|
|
* without the device being open so we may need
|
|
|
|
* to handle it here.
|
|
|
|
*/
|
1996-01-08 01:01:38 +03:00
|
|
|
if (rs->sc_dkdev.dk_openmask == 0) {
|
1994-05-23 09:58:16 +04:00
|
|
|
if (rdopen(dev, FREAD|FWRITE, S_IFBLK, NULL))
|
|
|
|
return(-1);
|
|
|
|
didopen = 1;
|
|
|
|
}
|
1997-06-24 04:44:03 +04:00
|
|
|
psize = rs->sc_dkdev.dk_label->d_partitions[rdpart(dev)].p_size *
|
|
|
|
(rs->sc_dkdev.dk_label->d_secsize / DEV_BSIZE);
|
1994-05-23 09:58:16 +04:00
|
|
|
if (didopen)
|
|
|
|
(void) rdclose(dev, FREAD|FWRITE, S_IFBLK, NULL);
|
|
|
|
return (psize);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1997-04-03 02:37:21 +04:00
|
|
|
void
|
1993-05-13 17:56:20 +04:00
|
|
|
rdprinterr(str, err, tab)
|
|
|
|
char *str;
|
|
|
|
short err;
|
1997-04-03 02:37:21 +04:00
|
|
|
char **tab;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-03-31 11:32:14 +04:00
|
|
|
int i;
|
1993-05-13 17:56:20 +04:00
|
|
|
int printed;
|
|
|
|
|
|
|
|
if (err == 0)
|
|
|
|
return;
|
1997-04-03 02:37:21 +04:00
|
|
|
printf(" %s error %d field:", str, err);
|
1993-05-13 17:56:20 +04:00
|
|
|
printed = 0;
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
if (err & (0x8000 >> i))
|
1996-10-13 07:14:05 +04:00
|
|
|
printf("%s%s", printed++ ? " + " : " ", tab[i]);
|
|
|
|
printf("\n");
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1996-10-06 04:14:12 +04:00
|
|
|
static int rddoingadump; /* simple mutex */
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Non-interrupt driven, non-dma dump routine.
|
|
|
|
*/
|
|
|
|
int
|
1996-10-06 04:14:12 +04:00
|
|
|
rddump(dev, blkno, va, size)
|
1993-05-13 17:56:20 +04:00
|
|
|
dev_t dev;
|
1996-10-06 04:14:12 +04:00
|
|
|
daddr_t blkno;
|
|
|
|
caddr_t va;
|
|
|
|
size_t size;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1996-10-06 04:14:12 +04:00
|
|
|
int sectorsize; /* size of a disk sector */
|
|
|
|
int nsects; /* number of sectors in partition */
|
|
|
|
int sectoff; /* sector offset of partition */
|
|
|
|
int totwrt; /* total number of sectors left to write */
|
|
|
|
int nwrt; /* current number of sectors to write */
|
|
|
|
int unit, part;
|
1997-01-30 12:14:10 +03:00
|
|
|
int ctlr, slave;
|
1996-10-06 04:14:12 +04:00
|
|
|
struct rd_softc *rs;
|
|
|
|
struct disklabel *lp;
|
1993-05-13 17:56:20 +04:00
|
|
|
char stat;
|
|
|
|
|
1996-10-06 04:14:12 +04:00
|
|
|
/* Check for recursive dump; if so, punt. */
|
|
|
|
if (rddoingadump)
|
|
|
|
return (EFAULT);
|
|
|
|
rddoingadump = 1;
|
|
|
|
|
|
|
|
/* Decompose unit and partition. */
|
|
|
|
unit = rdunit(dev);
|
|
|
|
part = rdpart(dev);
|
|
|
|
|
|
|
|
/* Make sure dump device is ok. */
|
1997-01-30 12:14:10 +03:00
|
|
|
if (unit >= rd_cd.cd_ndevs ||
|
|
|
|
(rs = rd_cd.cd_devs[unit]) == NULL ||
|
|
|
|
(rs->sc_flags & RDF_ALIVE) == 0)
|
1993-05-13 17:56:20 +04:00
|
|
|
return (ENXIO);
|
1997-01-30 12:14:10 +03:00
|
|
|
|
|
|
|
ctlr = rs->sc_dev.dv_parent->dv_unit;
|
|
|
|
slave = rs->sc_slave;
|
1996-10-06 04:14:12 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert to disk sectors. Request must be a multiple of size.
|
|
|
|
*/
|
|
|
|
lp = rs->sc_dkdev.dk_label;
|
|
|
|
sectorsize = lp->d_secsize;
|
|
|
|
if ((size % sectorsize) != 0)
|
|
|
|
return (EFAULT);
|
|
|
|
totwrt = size / sectorsize;
|
|
|
|
blkno = dbtob(blkno) / sectorsize; /* blkno in DEV_BSIZE units */
|
|
|
|
|
|
|
|
nsects = lp->d_partitions[part].p_size;
|
|
|
|
sectoff = lp->d_partitions[part].p_offset;
|
|
|
|
|
|
|
|
/* Check transfer bounds against partition size. */
|
|
|
|
if ((blkno < 0) || (blkno + totwrt) > nsects)
|
1994-05-23 09:58:16 +04:00
|
|
|
return (EINVAL);
|
1996-10-06 04:14:12 +04:00
|
|
|
|
|
|
|
/* Offset block number to start of partition. */
|
|
|
|
blkno += sectoff;
|
|
|
|
|
|
|
|
while (totwrt > 0) {
|
|
|
|
nwrt = totwrt; /* XXX */
|
|
|
|
#ifndef RD_DUMP_NOT_TRUSTED
|
|
|
|
/*
|
|
|
|
* Fill out and send HPIB command.
|
|
|
|
*/
|
1993-05-13 17:56:20 +04:00
|
|
|
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_hiaddr = 0;
|
1996-10-06 04:14:12 +04:00
|
|
|
rs->sc_ioc.c_addr = RDBTOS(blkno);
|
1993-05-13 17:56:20 +04:00
|
|
|
rs->sc_ioc.c_nop2 = C_NOP;
|
|
|
|
rs->sc_ioc.c_slen = C_SLEN;
|
1996-10-06 04:14:12 +04:00
|
|
|
rs->sc_ioc.c_len = nwrt * sectorsize;
|
1993-05-13 17:56:20 +04:00
|
|
|
rs->sc_ioc.c_cmd = C_WRITE;
|
1997-01-30 12:14:10 +03:00
|
|
|
hpibsend(ctlr, slave, C_CMD, &rs->sc_ioc.c_unit,
|
|
|
|
sizeof(rs->sc_ioc)-2);
|
|
|
|
if (hpibswait(ctlr, slave))
|
1993-05-13 17:56:20 +04:00
|
|
|
return (EIO);
|
1996-10-06 04:14:12 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Send the data.
|
|
|
|
*/
|
1997-01-30 12:14:10 +03:00
|
|
|
hpibsend(ctlr, slave, C_EXEC, va, nwrt * sectorsize);
|
|
|
|
(void) hpibswait(ctlr, slave);
|
|
|
|
hpibrecv(ctlr, slave, C_QSTAT, &stat, 1);
|
1994-05-23 09:58:16 +04:00
|
|
|
if (stat)
|
1993-05-13 17:56:20 +04:00
|
|
|
return (EIO);
|
1996-10-06 04:14:12 +04:00
|
|
|
#else /* RD_DUMP_NOT_TRUSTED */
|
|
|
|
/* Let's just talk about this first... */
|
1997-01-30 12:14:10 +03:00
|
|
|
printf("%s: dump addr %p, blk %d\n", sc->sc_dev.dv_xname,
|
1996-10-06 04:14:12 +04:00
|
|
|
va, blkno);
|
|
|
|
delay(500 * 1000); /* half a second */
|
|
|
|
#endif /* RD_DUMP_NOT_TRUSTED */
|
|
|
|
|
|
|
|
/* update block count */
|
|
|
|
totwrt -= nwrt;
|
|
|
|
blkno += nwrt;
|
|
|
|
va += sectorsize * nwrt;
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1996-10-06 04:14:12 +04:00
|
|
|
rddoingadump = 0;
|
1993-05-13 17:56:20 +04:00
|
|
|
return (0);
|
|
|
|
}
|