From: downsj Date: Mon, 3 Feb 1997 08:11:52 +0000 (+0000) Subject: rd -> hd X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5dc7580dab722aa6c63e4e669058582a2fa998a4;p=openbsd rd -> hd --- diff --git a/sys/arch/hp300/conf/GENERIC b/sys/arch/hp300/conf/GENERIC index d44f37380d6..4cffd809a3a 100644 --- a/sys/arch/hp300/conf/GENERIC +++ b/sys/arch/hp300/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.12 1997/02/03 04:47:05 downsj Exp $ +# $OpenBSD: GENERIC,v 1.13 1997/02/03 08:11:52 downsj Exp $ # $NetBSD: GENERIC,v 1.23 1997/01/31 06:12:57 thorpej Exp $ # # Generic kernel - one size fits all. @@ -100,7 +100,7 @@ hpibbus0 at nhpib0 hpibbus* at nhpib? hpibbus* at fhpib? -rd* at hpibbus? slave ? punit ? # HP-IB disks +hd* at hpibbus? slave ? punit ? # HP-IB disks ct* at hpibbus? slave ? punit ? # HP-IB cartridge tapes mt* at hpibbus? slave ? punit ? # HP-IB 9-track tape ppi0 at hpibbus0 slave 5 punit 0 # HP-IB plotter diff --git a/sys/arch/hp300/conf/files.hp300 b/sys/arch/hp300/conf/files.hp300 index 8673bf16eb9..70618b0bc25 100644 --- a/sys/arch/hp300/conf/files.hp300 +++ b/sys/arch/hp300/conf/files.hp300 @@ -1,4 +1,4 @@ -# $OpenBSD: files.hp300,v 1.2 1997/02/03 04:47:08 downsj Exp $ +# $OpenBSD: files.hp300,v 1.3 1997/02/03 08:11:52 downsj Exp $ # $NetBSD: files.hp300,v 1.22 1997/01/30 22:11:19 scottr Exp $ # # hp300-specific configuration info @@ -119,11 +119,11 @@ attach mt at hpibbus file arch/hp300/dev/mt.c mt needs-flag major {mt = 1} -device rd: disk -attach rd at hpibbus -file arch/hp300/dev/rd.c rd needs-flag -file arch/hp300/dev/rd_compat.c rd # XXX -major {rd = 2} +device hd: disk +attach hd at hpibbus +file arch/hp300/dev/hd.c hd needs-flag +file arch/hp300/dev/hd_compat.c hd # XXX +major {hd = 2} device ppi attach ppi at hpibbus diff --git a/sys/arch/hp300/dev/hd.c b/sys/arch/hp300/dev/hd.c new file mode 100644 index 00000000000..ddf1bb6401d --- /dev/null +++ b/sys/arch/hp300/dev/hd.c @@ -0,0 +1,1298 @@ +/* $OpenBSD: hd.c,v 1.1 1997/02/03 08:11:54 downsj Exp $ */ +/* $NetBSD: rd.c,v 1.27 1997/01/30 09:14:17 thorpej Exp $ */ + +/* + * Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved. + * 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 + * 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. + * + * from: Utah $Hdr: rd.c 1.44 92/12/26$ + * + * @(#)rd.c 8.2 (Berkeley) 5/19/94 + */ + +/* + * CS80/SS80 disk driver + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#ifdef USELEDS +#include +#endif + +#include +#include +#include +#include + +int hdmatch __P((struct device *, void *, void *)); +void hdattach __P((struct device *, struct device *, void *)); + +struct cfattach hd_ca = { + sizeof(struct hd_softc), hdmatch, hdattach +}; + +struct cfdriver hd_cd = { + NULL, "hd", DV_DISK +}; + +int hdident __P((struct device *, struct hd_softc *, + struct hpibbus_attach_args *)); +void hdreset __P((struct hd_softc *)); +void hdustart __P((struct hd_softc *)); +int hdgetinfo __P((dev_t)); +void hdrestart __P((void *)); +struct buf *hdfinish __P((struct hd_softc *, struct buf *)); + +void hdstart __P((void *)); +void hdintr __P((void *)); +void hdgo __P((void *)); + +bdev_decl(hd); +cdev_decl(hd); + +int hderrthresh = HDRETRY-1; /* when to start reporting errors */ + +#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 +}; + +int hddebug = 0x80; +#define HDB_FOLLOW 0x01 +#define HDB_STATUS 0x02 +#define HDB_IDENT 0x04 +#define HDB_IO 0x08 +#define HDB_ASYNC 0x10 +#define HDB_ERROR 0x80 +#endif + +/* + * Misc. HW description, indexed by sc_type. + * Nothing really critical here, could do without it. + */ +struct hdidentinfo hdidentinfo[] = { + { HD7946AID, 0, "7945A", NHD7945ABPT, + NHD7945ATRK, 968, 108416 }, + + { HD9134DID, 1, "9134D", NHD9134DBPT, + NHD9134DTRK, 303, 29088 }, + + { HD9134LID, 1, "9122S", NHD9122SBPT, + NHD9122STRK, 77, 1232 }, + + { HD7912PID, 0, "7912P", NHD7912PBPT, + NHD7912PTRK, 572, 128128 }, + + { HD7914PID, 0, "7914P", NHD7914PBPT, + NHD7914PTRK, 1152, 258048 }, + + { HD7958AID, 0, "7958A", NHD7958ABPT, + NHD7958ATRK, 1013, 255276 }, + + { HD7957AID, 0, "7957A", NHD7957ABPT, + NHD7957ATRK, 1036, 159544 }, + + { HD7933HID, 0, "7933H", NHD7933HBPT, + NHD7933HTRK, 1321, 789958 }, + + { HD9134LID, 1, "9134L", NHD9134LBPT, + NHD9134LTRK, 973, 77840 }, + + { HD7936HID, 0, "7936H", NHD7936HBPT, + NHD7936HTRK, 698, 600978 }, + + { HD7937HID, 0, "7937H", NHD7937HBPT, + NHD7937HTRK, 698, 1116102 }, + + { HD7914CTID, 0, "7914CT", NHD7914PBPT, + NHD7914PTRK, 1152, 258048 }, + + { HD7946AID, 0, "7946A", NHD7945ABPT, + NHD7945ATRK, 968, 108416 }, + + { HD9134LID, 1, "9122D", NHD9122SBPT, + NHD9122STRK, 77, 1232 }, + + { HD7957BID, 0, "7957B", NHD7957BBPT, + NHD7957BTRK, 1269, 159894 }, + + { HD7958BID, 0, "7958B", NHD7958BBPT, + NHD7958BTRK, 786, 297108 }, + + { HD7959BID, 0, "7959B", NHD7959BBPT, + NHD7959BTRK, 1572, 594216 }, + + { HD2200AID, 0, "2200A", NHD2200ABPT, + NHD2200ATRK, 1449, 654948 }, + + { HD2203AID, 0, "2203A", NHD2203ABPT, + NHD2203ATRK, 1449, 1309896 } +}; +int numhdidentinfo = sizeof(hdidentinfo) / sizeof(hdidentinfo[0]); + +int +hdmatch(parent, match, aux) + struct device *parent; + void *match, *aux; +{ + struct cfdata *cf = match; + struct hpibbus_attach_args *ha = aux; + + /* + * Set punit if operator specified one in the kernel + * configuration file. + */ + if (cf->hpibbuscf_punit != HPIBBUS_PUNIT_UNK && + cf->hpibbuscf_punit < HPIB_NPUNITS) + ha->ha_punit = cf->hpibbuscf_punit; + + if (hdident(parent, NULL, ha) == 0) { + /* + * XXX Some aging HP-IB drives are slow to + * XXX respond; give them a chance to catch + * XXX up and probe them again. + */ + delay(10000); + ha->ha_id = hpibid(parent->dv_unit, ha->ha_slave); + return (hdident(parent, NULL, ha)); + } + return (1); +} + +void +hdattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct hd_softc *sc = (struct hd_softc *)self; + struct hpibbus_attach_args *ha = aux; + + if (hdident(parent, sc, ha) == 0) { + printf("\n%s: didn't respond to describe command!\n", + sc->sc_dev.dv_xname); + return; + } + + /* + * Initialize and attach the disk structure. + */ + bzero(&sc->sc_dkdev, sizeof(sc->sc_dkdev)); + sc->sc_dkdev.dk_name = sc->sc_dev.dv_xname; + disk_attach(&sc->sc_dkdev); + + sc->sc_slave = ha->ha_slave; + sc->sc_punit = ha->ha_punit; + + /* 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 = hdstart; + sc->sc_hq.hq_go = hdgo; + sc->sc_hq.hq_intr = hdintr; + + sc->sc_flags = HDF_ALIVE; +#ifdef DEBUG + /* always report errors */ + if (hddebug & HDB_ERROR) + hderrthresh = 0; +#endif + + dk_establish(&sc->sc_dkdev, &sc->sc_dev); /* XXX */ +} + +int +hdident(parent, sc, ha) + struct device *parent; + struct hd_softc *sc; + struct hpibbus_attach_args *ha; +{ + struct hd_softc rsc; + struct hd_describe *desc = sc != NULL ? &sc->sc_hddesc : NULL; + u_char stat, cmd[3]; + char name[7]; + int i, id, n, ctlr, slave; + + 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 < numhdidentinfo; id++) + if (ha->ha_id == hdidentinfo[id].ri_hwid) + break; + if (id == numhdidentinfo || ha->ha_punit > hdidentinfo[id].ri_maxunum) + return (0); + + /* + * If we're just probing for the device, that's all the + * work we need to do. + */ + if (sc == NULL) + return (1); + + /* + * Reset device and collect description + */ + hdreset(sc); + cmd[0] = C_SUNIT(ha->ha_punit); + cmd[1] = C_SVOL(0); + cmd[2] = C_DESC; + 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)); + if (stat == 0) { + n = desc->d_name; + for (i = 5; i >= 0; i--) { + name[i] = (n & 0xf) + '0'; + n >>= 4; + } + } + +#ifdef DEBUG + if (hddebug & HDB_IDENT) { + printf("\n%s: name: %x ('%s')\n", + sc->sc_dev.dv_xname, 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); + printf("%s", sc->sc_dev.dv_xname); + } +#endif + + /* + * 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 (ha->ha_id) { + case HD7946AID: + if (bcmp(name, "079450", 6) == 0) + id = HD7945A; + else + id = HD7946A; + break; + + case HD9134LID: + if (bcmp(name, "091340", 6) == 0) + id = HD9134L; + else + id = HD9122D; + break; + + case HD9134DID: + if (bcmp(name, "091220", 6) == 0) + id = HD9122S; + else + id = HD9134D; + break; + } + + sc->sc_type = id; + + /* + * XXX We use DEV_BSIZE instead of the sector size value pulled + * XXX off the driver because all of this code assumes 512 byte + * XXX blocks. ICK! + */ + printf(": %s\n", hdidentinfo[id].ri_desc); + printf("%s: %d cylinders, %d heads, %d blocks, %d bytes/block\n", + sc->sc_dev.dv_xname, hdidentinfo[id].ri_ncyl, + hdidentinfo[id].ri_ntpc, hdidentinfo[id].ri_nblocks, + DEV_BSIZE); + + return (1); +} + +void +hdreset(rs) + register struct hd_softc *rs; +{ + int ctlr = rs->sc_dev.dv_parent->dv_unit; + int slave = rs->sc_slave; + u_char stat; + + rs->sc_clear.c_unit = C_SUNIT(rs->sc_punit); + rs->sc_clear.c_cmd = C_CLEAR; + hpibsend(ctlr, slave, C_TCMD, &rs->sc_clear, sizeof(rs->sc_clear)); + hpibswait(ctlr, slave); + hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat)); + + rs->sc_src.c_unit = C_SUNIT(HDCTLR); + rs->sc_src.c_nop = C_NOP; + rs->sc_src.c_cmd = C_SREL; + rs->sc_src.c_param = C_REL; + hpibsend(ctlr, slave, C_CMD, &rs->sc_src, sizeof(rs->sc_src)); + hpibswait(ctlr, slave); + hpibrecv(ctlr, 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(ctlr, slave, C_CMD, &rs->sc_ssmc, sizeof(rs->sc_ssmc)); + hpibswait(ctlr, slave); + hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat)); +#ifdef DEBUG + rs->sc_stats.hdresets++; +#endif +} + +/* + * Read or constuct a disklabel + */ +int +hdgetinfo(dev) + dev_t dev; +{ + int unit = hdunit(dev); + struct hd_softc *rs = hd_cd.cd_devs[unit]; + register struct disklabel *lp = rs->sc_dkdev.dk_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_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 + */ + msg = readdisklabel(hdlabdev(dev), hdstrategy, lp, NULL); + if (msg == NULL) + return(0); + + pi = lp->d_partitions; + printf("%s: WARNING: %s, ", rs->sc_dev.dv_xname, msg); +#ifdef COMPAT_NOLABEL + printf("using old default partitioning\n"); + hdmakedisklabel(unit, lp); +#else + printf("defining `c' partition as entire disk\n"); + pi[2].p_size = hdidentinfo[rs->sc_type].ri_nblocks; + /* XXX reset other info since readdisklabel screws with it */ + lp->d_npartitions = 3; + pi[0].p_size = 0; +#endif + return(0); +} + +int +hdopen(dev, flags, mode, p) + dev_t dev; + int flags, mode; + struct proc *p; +{ + register int unit = hdunit(dev); + register struct hd_softc *rs; + int error, mask, part; + + if (unit >= hd_cd.cd_ndevs || + (rs = hd_cd.cd_devs[unit]) == NULL || + (rs->sc_flags & HDF_ALIVE) == 0) + return (ENXIO); + + /* + * Wait for any pending opens/closes to complete + */ + while (rs->sc_flags & (HDF_OPENING|HDF_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_dkdev.dk_openmask == 0) { + rs->sc_flags |= HDF_OPENING; + error = hdgetinfo(dev); + rs->sc_flags &= ~HDF_OPENING; + wakeup((caddr_t)rs); + if (error) + return(error); + } + + part = hdpart(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: + rs->sc_dkdev.dk_copenmask |= mask; + break; + case S_IFBLK: + rs->sc_dkdev.dk_bopenmask |= mask; + break; + } + rs->sc_dkdev.dk_openmask = + rs->sc_dkdev.dk_copenmask | rs->sc_dkdev.dk_bopenmask; + + return(0); +} + +int +hdclose(dev, flag, mode, p) + dev_t dev; + int flag, mode; + struct proc *p; +{ + int unit = hdunit(dev); + struct hd_softc *rs = hd_cd.cd_devs[unit]; + register struct disk *dk = &rs->sc_dkdev; + int mask, s; + + mask = 1 << hdpart(dev); + if (mode == S_IFCHR) + dk->dk_copenmask &= ~mask; + else + dk->dk_bopenmask &= ~mask; + dk->dk_openmask = dk->dk_copenmask | dk->dk_bopenmask; + /* + * 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. + */ + if (dk->dk_openmask == 0) { + rs->sc_flags |= HDF_CLOSING; + s = splbio(); + while (rs->sc_tab.b_active) { + rs->sc_flags |= HDF_WANTED; + sleep((caddr_t)&rs->sc_tab, PRIBIO); + } + splx(s); + rs->sc_flags &= ~(HDF_CLOSING|HDF_WLABEL); + wakeup((caddr_t)rs); + } + return(0); +} + +void +hdstrategy(bp) + register struct buf *bp; +{ + int unit = hdunit(bp->b_dev); + struct hd_softc *rs = hd_cd.cd_devs[unit]; + register struct buf *dp = &rs->sc_tab; + register struct partition *pinfo; + register daddr_t bn; + register int sz, s; + int offset; + +#ifdef DEBUG + if (hddebug & HDB_FOLLOW) + printf("hdstrategy(%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'); +#endif + bn = bp->b_blkno; + sz = howmany(bp->b_bcount, DEV_BSIZE); + pinfo = &rs->sc_dkdev.dk_label->d_partitions[hdpart(bp->b_dev)]; + + /* Don't perform partition translation on RAW_PART. */ + offset = (hdpart(bp->b_dev) == RAW_PART) ? 0 : pinfo->p_offset; + + if (hdpart(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); + } + /* + * Check for write to write protected label + */ + if (bn + offset <= LABELSECTOR && +#if LABELSECTOR != 0 + bn + offset + sz > LABELSECTOR && +#endif + !(bp->b_flags & B_READ) && !(rs->sc_flags & HDF_WLABEL)) { + bp->b_error = EROFS; + goto bad; + } + } + bp->b_cylin = bn + offset; + s = splbio(); + disksort(dp, bp); + if (dp->b_active == 0) { + dp->b_active = 1; + hdustart(rs); + } + splx(s); + return; +bad: + bp->b_flags |= B_ERROR; +done: + biodone(bp); +} + +/* + * Called from timeout() when handling maintenance releases + */ +void +hdrestart(arg) + void *arg; +{ + int s = splbio(); + hdustart((struct hd_softc *)arg); + splx(s); +} + +void +hdustart(rs) + struct hd_softc *rs; +{ + register struct buf *bp; + + bp = rs->sc_tab.b_actf; + rs->sc_addr = bp->b_un.b_addr; + rs->sc_resid = bp->b_bcount; + if (hpibreq(rs->sc_dev.dv_parent, &rs->sc_hq)) + hdstart(rs); +} + +struct buf * +hdfinish(rs, bp) + register struct hd_softc *rs; + register struct buf *bp; +{ + register struct buf *dp = &rs->sc_tab; + + dp->b_errcnt = 0; + dp->b_actf = bp->b_actf; + bp->b_resid = 0; + biodone(bp); + hpibfree(rs->sc_dev.dv_parent, &rs->sc_hq); + if (dp->b_actf) + return (dp->b_actf); + dp->b_active = 0; + if (rs->sc_flags & HDF_WANTED) { + rs->sc_flags &= ~HDF_WANTED; + wakeup((caddr_t)dp); + } + return (NULL); +} + +void +hdstart(arg) + void *arg; +{ + struct hd_softc *rs = arg; + register struct buf *bp = rs->sc_tab.b_actf; + register int part, ctlr, slave; + + ctlr = rs->sc_dev.dv_parent->dv_unit; + slave = rs->sc_slave; + +again: +#ifdef DEBUG + if (hddebug & HDB_FOLLOW) + printf("hdstart(%s): bp %x, %c\n", sc->sc_dev.dv_xname, bp, + (bp->b_flags & B_READ) ? 'R' : 'W'); +#endif + part = hdpart(bp->b_dev); + rs->sc_flags |= HDF_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; + rs->sc_ioc.c_addr = HDBTOS(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; +#ifdef DEBUG + if (hddebug & HDB_IO) + printf("hdstart: hpibsend(%x, %x, %x, %x, %x)\n", + ctlr, slave, C_CMD, + &rs->sc_ioc.c_unit, sizeof(rs->sc_ioc)-2); +#endif + if (hpibsend(ctlr, slave, C_CMD, &rs->sc_ioc.c_unit, + sizeof(rs->sc_ioc)-2) == sizeof(rs->sc_ioc)-2) { + + /* Instrumentation. */ + disk_busy(&rs->sc_dkdev); + rs->sc_dkdev.dk_seek++; + +#ifdef DEBUG + if (hddebug & HDB_IO) + printf("hdstart: hpibawait(%x)\n", ctlr); +#endif + hpibawait(ctlr); + 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 hderror. + */ +#ifdef DEBUG + if (hddebug & HDB_ERROR) + printf("%s: hdstart: cmd %x adr %d blk %d len %d ecnt %d\n", + 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.hdretries++; +#endif + rs->sc_flags &= ~HDF_SEEK; + hdreset(rs); + if (rs->sc_tab.b_errcnt++ < HDRETRY) + goto again; + printf("%s: hdstart err: cmd 0x%x sect %d blk %d len %d\n", + rs->sc_dev.dv_xname, rs->sc_ioc.c_cmd, rs->sc_ioc.c_addr, + bp->b_blkno, rs->sc_resid); + bp->b_flags |= B_ERROR; + bp->b_error = EIO; + bp = hdfinish(rs, bp); + if (bp) { + rs->sc_addr = bp->b_un.b_addr; + rs->sc_resid = bp->b_bcount; + if (hpibreq(rs->sc_dev.dv_parent, &rs->sc_hq)) + goto again; + } +} + +void +hdgo(arg) + void *arg; +{ + struct hd_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; + + rw = bp->b_flags & B_READ; + + /* Instrumentation. */ + disk_busy(&rs->sc_dkdev); + +#ifdef USELEDS + if (inledcontrol == 0) + ledcontrol(0, 0, LED_DISK); +#endif + hpibgo(ctlr, slave, C_EXEC, rs->sc_addr, rs->sc_resid, rw, rw != 0); +} + +/* ARGSUSED */ +void +hdintr(arg) + void *arg; +{ + register struct hd_softc *rs = arg; + int unit = rs->sc_dev.dv_unit; + register struct buf *bp = rs->sc_tab.b_actf; + u_char stat = 13; /* in case hpibrecv fails */ + int rv, restart, ctlr, slave; + + ctlr = rs->sc_dev.dv_parent->dv_unit; + slave = rs->sc_slave; + +#ifdef DEBUG + if (hddebug & HDB_FOLLOW) + printf("hdintr(%d): bp %x, %c, flags %x\n", unit, bp, + (bp->b_flags & B_READ) ? 'R' : 'W', rs->sc_flags); + if (bp == NULL) { + printf("%s: bp == NULL\n", rs->sc_dev.dv_xname); + return; + } +#endif + disk_unbusy(&rs->sc_dkdev, (bp->b_bcount - bp->b_resid)); + + if (rs->sc_flags & HDF_SEEK) { + rs->sc_flags &= ~HDF_SEEK; + if (hpibustart(ctlr)) + hdgo(rs); + return; + } + if ((rs->sc_flags & HDF_SWAIT) == 0) { +#ifdef DEBUG + rs->sc_stats.hdpolltries++; +#endif + if (hpibpptest(ctlr, slave) == 0) { +#ifdef DEBUG + rs->sc_stats.hdpollwaits++; +#endif + + /* Instrumentation. */ + disk_busy(&rs->sc_dkdev); + rs->sc_flags |= HDF_SWAIT; + hpibawait(ctlr); + return; + } + } else + rs->sc_flags &= ~HDF_SWAIT; + rv = hpibrecv(ctlr, slave, C_QSTAT, &stat, 1); + if (rv != 1 || stat) { +#ifdef DEBUG + if (hddebug & HDB_ERROR) + printf("hdintr: recv failed or bad stat %d\n", stat); +#endif + restart = hderror(unit); +#ifdef DEBUG + rs->sc_stats.hdretries++; +#endif + if (rs->sc_tab.b_errcnt++ < HDRETRY) { + if (restart) + hdstart(rs); + return; + } + bp->b_flags |= B_ERROR; + bp->b_error = EIO; + } + if (hdfinish(rs, bp)) + hdustart(rs); +} + +int +hdstatus(rs) + register struct hd_softc *rs; +{ + register int c, s; + u_char stat; + int rv; + + c = rs->sc_dev.dv_parent->dv_unit; + s = rs->sc_slave; + 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 (hddebug & HDB_STATUS) + printf("hdstatus: send C_CMD failed %d != %d\n", + 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 (hddebug & HDB_STATUS) + printf("hdstatus: send C_EXEC failed %d != %d\n", + rv, sizeof(rs->sc_stat)); +#endif + return(1); + } + rv = hpibrecv(c, s, C_QSTAT, &stat, 1); + if (rv != 1 || stat) { +#ifdef DEBUG + if (hddebug & HDB_STATUS) + printf("hdstatus: recv failed %d or bad stat %d\n", + 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. + */ +int +hderror(unit) + int unit; +{ + struct hd_softc *rs = hd_cd.cd_devs[unit]; + register struct hd_stat *sp; + struct buf *bp; + daddr_t hwbn, pbn; + + if (hdstatus(rs)) { +#ifdef DEBUG + printf("%s: couldn't get status\n", rs->sc_dev.dv_xname); +#endif + hdreset(rs); + return(1); + } + sp = &rs->sc_stat; + if (sp->c_fef & FEF_REXMT) + return(1); + if (sp->c_fef & FEF_PF) { + hdreset(rs); + 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 HDWAITC and + * HDRETRY as defined, the range is 1 to 32 seconds. + */ + if (sp->c_fef & FEF_IMR) { + extern int hz; + int hdtimo = HDWAITC << rs->sc_tab.b_errcnt; +#ifdef DEBUG + printf("%s: internal maintenance, %d second timeout\n", + rs->sc_dev.dv_xname, hdtimo); + rs->sc_stats.hdtimeouts++; +#endif + hpibfree(rs->sc_dev.dv_parent, &rs->sc_hq); + timeout(hdrestart, rs, hdtimo * hz); + 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. + */ + if (rs->sc_tab.b_errcnt < hderrthresh) + 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. + */ + bp = rs->sc_tab.b_actf; + pbn = rs->sc_dkdev.dk_label->d_partitions[hdpart(bp->b_dev)].p_offset; + if ((sp->c_fef & FEF_CU) || (sp->c_fef & FEF_DR) || + (sp->c_ief & IEF_RRMASK)) { + hwbn = HDBTOS(pbn + bp->b_blkno); + pbn = bp->b_blkno; + } else { + hwbn = sp->c_blk; + pbn = HDSTOB(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("%s%c: hard error sn%d\n", rs->sc_dev.dv_xname, + 'a'+hdpart(bp->b_dev), pbn); + /* + * Now report the status as returned by the hardware with + * attempt at interpretation (unless debugging). + */ + printf("%s %s error:", rs->sc_dev.dv_xname, + (bp->b_flags & B_READ) ? "read" : "write"); +#ifdef DEBUG + if (hddebug & HDB_ERROR) { + /* status info */ + printf("\n volume: %d, unit: %d\n", + (sp->c_vu>>4)&0xF, sp->c_vu&0xF); + hdprinterr("reject", sp->c_ref, err_reject); + hdprinterr("fault", sp->c_fef, err_fault); + hdprinterr("access", sp->c_aef, err_access); + hdprinterr("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)); + /* command */ + printf(" ioc: "); + 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)); + return(1); + } +#endif + 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("P1-P10: "); + 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(1); +} + +int +hdread(dev, uio, flags) + dev_t dev; + struct uio *uio; + int flags; +{ + + return (physio(hdstrategy, NULL, dev, B_READ, minphys, uio)); +} + +int +hdwrite(dev, uio, flags) + dev_t dev; + struct uio *uio; + int flags; +{ + + return (physio(hdstrategy, NULL, dev, B_WRITE, minphys, uio)); +} + +int +hdioctl(dev, cmd, data, flag, p) + dev_t dev; + u_long cmd; + caddr_t data; + int flag; + struct proc *p; +{ + int unit = hdunit(dev); + struct hd_softc *sc = hd_cd.cd_devs[unit]; + register struct disklabel *lp = sc->sc_dkdev.dk_label; + 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[hdpart(dev)]; + return (0); + + case DIOCWLABEL: + if ((flag & FWRITE) == 0) + return (EBADF); + if (*(int *)data) + sc->sc_flags |= HDF_WLABEL; + else + sc->sc_flags &= ~HDF_WLABEL; + return (0); + + case DIOCSDINFO: + if ((flag & FWRITE) == 0) + return (EBADF); + return (setdisklabel(lp, (struct disklabel *)data, + (sc->sc_flags & HDF_WLABEL) ? 0 + : sc->sc_dkdev.dk_openmask, + (struct cpu_disklabel *)0)); + + case DIOCWDINFO: + if ((flag & FWRITE) == 0) + return (EBADF); + error = setdisklabel(lp, (struct disklabel *)data, + (sc->sc_flags & HDF_WLABEL) ? 0 + : sc->sc_dkdev.dk_openmask, + (struct cpu_disklabel *)0); + if (error) + return (error); + flags = sc->sc_flags; + sc->sc_flags = HDF_ALIVE | HDF_WLABEL; + error = writedisklabel(hdlabdev(dev), hdstrategy, lp, + (struct cpu_disklabel *)0); + sc->sc_flags = flags; + return (error); + } + return(EINVAL); +} + +int +hdsize(dev) + dev_t dev; +{ + register int unit = hdunit(dev); + struct hd_softc *rs; + int psize, didopen = 0; + + if (unit >= hd_cd.cd_ndevs || + (rs = hd_cd.cd_devs[unit]) == NULL || + (rs->sc_flags & HDF_ALIVE) == 0) + return (-1); + + /* + * We get called very early on (via swapconf) + * without the device being open so we may need + * to handle it here. + */ + if (rs->sc_dkdev.dk_openmask == 0) { + if (hdopen(dev, FREAD|FWRITE, S_IFBLK, NULL)) + return(-1); + didopen = 1; + } + psize = rs->sc_dkdev.dk_label->d_partitions[hdpart(dev)].p_size; + if (didopen) + (void) hdclose(dev, FREAD|FWRITE, S_IFBLK, NULL); + return (psize); +} + +#ifdef DEBUG +hdprinterr(str, err, tab) + char *str; + short err; + char *tab[]; +{ + register int i; + int printed; + + if (err == 0) + return; + printf(" %s error field:", str, err); + printed = 0; + for (i = 0; i < 16; i++) + if (err & (0x8000 >> i)) + printf("%s%s", printed++ ? " + " : " ", tab[i]); + printf("\n"); +} +#endif + +static int hddoingadump; /* simple mutex */ + +/* + * Non-interrupt driven, non-dma dump routine. + */ +int +hddump(dev, blkno, va, size) + dev_t dev; + daddr_t blkno; + caddr_t va; + size_t size; +{ + 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; + int ctlr, slave; + struct hd_softc *rs; + struct disklabel *lp; + char stat; + + /* Check for recursive dump; if so, punt. */ + if (hddoingadump) + return (EFAULT); + hddoingadump = 1; + + /* Decompose unit and partition. */ + unit = hdunit(dev); + part = hdpart(dev); + + /* Make sure dump device is ok. */ + if (unit >= hd_cd.cd_ndevs || + (rs = hd_cd.cd_devs[unit]) == NULL || + (rs->sc_flags & HDF_ALIVE) == 0) + return (ENXIO); + + ctlr = rs->sc_dev.dv_parent->dv_unit; + slave = rs->sc_slave; + + /* + * 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) + return (EINVAL); + + /* Offset block number to start of partition. */ + blkno += sectoff; + + while (totwrt > 0) { + nwrt = totwrt; /* XXX */ +#ifndef HD_DUMP_NOT_TRUSTED + /* + * Fill out and send HPIB command. + */ + 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; + rs->sc_ioc.c_addr = HDBTOS(blkno); + rs->sc_ioc.c_nop2 = C_NOP; + rs->sc_ioc.c_slen = C_SLEN; + rs->sc_ioc.c_len = nwrt * sectorsize; + rs->sc_ioc.c_cmd = C_WRITE; + hpibsend(ctlr, slave, C_CMD, &rs->sc_ioc.c_unit, + sizeof(rs->sc_ioc)-2); + if (hpibswait(ctlr, slave)) + return (EIO); + + /* + * Send the data. + */ + hpibsend(ctlr, slave, C_EXEC, va, nwrt * sectorsize); + (void) hpibswait(ctlr, slave); + hpibrecv(ctlr, slave, C_QSTAT, &stat, 1); + if (stat) + return (EIO); +#else /* HD_DUMP_NOT_TRUSTED */ + /* Let's just talk about this first... */ + printf("%s: dump addr %p, blk %d\n", sc->sc_dev.dv_xname, + va, blkno); + delay(500 * 1000); /* half a second */ +#endif /* HD_DUMP_NOT_TRUSTED */ + + /* update block count */ + totwrt -= nwrt; + blkno += nwrt; + va += sectorsize * nwrt; + } + hddoingadump = 0; + return (0); +} diff --git a/sys/arch/hp300/dev/hd_compat.c b/sys/arch/hp300/dev/hd_compat.c new file mode 100644 index 00000000000..4afd1f8a0be --- /dev/null +++ b/sys/arch/hp300/dev/hd_compat.c @@ -0,0 +1,293 @@ +/* $OpenBSD: hd_compat.c,v 1.1 1997/02/03 08:11:54 downsj Exp $ */ +/* $NetBSD: rd_compat.c,v 1.6 1997/01/30 09:14:18 thorpej Exp $ */ + +/* + * 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 + * 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. + * + * from: Utah $Hdr: rd_compat.c 1.1 92/12/21$ + * + * @(#)rd_compat.c 8.1 (Berkeley) 6/10/93 + */ + +/* + * Compatibility for CS80 disks without disklabels. + */ + +#include +#include +#include +#include +#include /* XXX */ + +#include + +#include +#include + +/* + * 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 { + daddr_t nblocks; + int cyloff; +} hd7945A_sizes[8] = { + HDSZ(15904), 1, /* A=cyl 1 thru 142 */ + HDSZ(20160), 143, /* B=cyl 143 thru 322 */ + HDSZ(108416), 0, /* C=cyl 0 thru 967 */ + HDSZ(40320), 143, /* D=cyl 143 thru 502 */ + HDSZ(0), 0, /* E= */ + HDSZ(0), 0, /* F= */ + HDSZ(72240), 323, /* G=cyl 323 thru 967 */ + HDSZ(52080), 503, /* H=cyl 503 thru 967 */ +}, hd9134D_sizes[8] = { + HDSZ(15936), 1, /* A=cyl 1 thru 166 */ + HDSZ(13056), 167, /* B=cyl 167 thru 302 */ + HDSZ(29088), 0, /* C=cyl 0 thru 302 */ + HDSZ(0), 0, /* D= */ + HDSZ(0), 0, /* E= */ + HDSZ(0), 0, /* F= */ + HDSZ(0), 0, /* G= */ + HDSZ(0), 0, /* H= */ +}, hd9122S_sizes[8] = { + HDSZ(0), 0, /* A= */ + HDSZ(0), 0, /* B= */ + HDSZ(1232), 0, /* C=cyl 0 thru 76 */ + HDSZ(0), 0, /* D= */ + HDSZ(0), 0, /* E= */ + HDSZ(0), 0, /* F= */ + HDSZ(0), 0, /* G= */ + HDSZ(0), 0, /* H= */ +}, hd7912P_sizes[8] = { + HDSZ(15904), 0, /* A=cyl 1 thru 71 */ + HDSZ(22400), 72, /* B=cyl 72 thru 171 */ + HDSZ(128128), 0, /* C=cyl 0 thru 571 */ + HDSZ(42560), 72, /* D=cyl 72 thru 261 */ + HDSZ(0), 292, /* E= */ + HDSZ(0), 542, /* F= */ + HDSZ(89600), 172, /* G=cyl 221 thru 571 */ + HDSZ(69440), 262, /* H=cyl 262 thru 571 */ +}, hd7914P_sizes[8] = { + HDSZ(15904), 1, /* A=cyl 1 thru 71 */ + HDSZ(40320), 72, /* B=cyl 72 thru 251 */ + HDSZ(258048), 0, /* C=cyl 0 thru 1151 */ + HDSZ(64960), 72, /* D=cyl 72 thru 361 */ + HDSZ(98560), 362, /* E=cyl 362 thru 801 */ + HDSZ(78400), 802, /* F=cyl 802 thru 1151 */ + HDSZ(201600), 252, /* G=cyl 221 thru 1151 */ + HDSZ(176960), 362, /* H=cyl 362 thru 1151 */ +}, hd7933H_sizes[8] = { + HDSZ(16146), 1, /* A=cyl 1 thru 27 */ + HDSZ(66976), 28, /* B=cyl 28 thru 139 */ + HDSZ(789958), 0, /* C=cyl 0 thru 1320 */ + HDSZ(16146), 140, /* D=cyl 140 thru 166 */ + HDSZ(165646), 167, /* E=cyl 167 thru 443 */ + HDSZ(165646), 444, /* F=cyl 444 thru 720 */ + HDSZ(706238), 140, /* G=cyl 140 thru 1320 */ + HDSZ(358800), 721, /* H=cyl 721 thru 1320 */ +}, hd9134L_sizes[8] = { + HDSZ(15920), 1, /* A=cyl 1 thru 199 */ + HDSZ(20000), 200, /* B=cyl 200 thru 449 */ + HDSZ(77840), 0, /* C=cyl 0 thru 972 */ + HDSZ(32000), 200, /* D=cyl 200 thru 599 */ + HDSZ(0), 0, /* E= */ + HDSZ(0), 0, /* F= */ + HDSZ(41840), 450, /* G=cyl 450 thru 972 */ + HDSZ(29840), 600, /* H=cyl 600 thru 972 */ +}, hd7957A_sizes[8] = { + HDSZ(16016), 1, /* A=cyl 1 thru 104 */ + HDSZ(24640), 105, /* B=cyl 105 thru 264 */ + HDSZ(159544), 0, /* C=cyl 0 thru 1035 */ + HDSZ(42350), 105, /* D=cyl 105 thru 379 */ + HDSZ(54824), 380, /* E=cyl 380 thru 735 */ + HDSZ(46200), 736, /* F=cyl 736 thru 1035 */ + HDSZ(118734), 265, /* G=cyl 265 thru 1035 */ + HDSZ(101024), 380, /* H=cyl 380 thru 1035 */ +}, hd7958A_sizes[8] = { + HDSZ(16128), 1, /* A=cyl 1 thru 64 */ + HDSZ(32256), 65, /* B=cyl 65 thru 192 */ + HDSZ(255276), 0, /* C=cyl 0 thru 1012 */ + HDSZ(48384), 65, /* D=cyl 65 thru 256 */ + HDSZ(100800), 257, /* E=cyl 257 thru 656 */ + HDSZ(89712), 657, /* F=cyl 657 thru 1012 */ + HDSZ(206640), 193, /* G=cyl 193 thru 1012 */ + HDSZ(190512), 257, /* H=cyl 257 thru 1012 */ +}, hd7957B_sizes[8] = { + HDSZ(16002), 1, /* A=cyl 1 thru 127 */ + HDSZ(32760), 128, /* B=cyl 128 thru 387 */ + HDSZ(159894), 0, /* C=cyl 0 thru 1268 */ + HDSZ(49140), 128, /* D=cyl 128 thru 517 */ + HDSZ(50400), 518, /* E=cyl 518 thru 917 */ + HDSZ(44226), 918, /* F=cyl 918 thru 1268 */ + HDSZ(111006), 388, /* G=cyl 388 thru 1268 */ + HDSZ(94626), 518, /* H=cyl 518 thru 1268 */ +}, hd7958B_sizes[8] = { + HDSZ(16254), 1, /* A=cyl 1 thru 43 */ + HDSZ(32886), 44, /* B=cyl 44 thru 130 */ + HDSZ(297108), 0, /* C=cyl 0 thru 785 */ + HDSZ(49140), 44, /* D=cyl 44 thru 173 */ + HDSZ(121716), 174, /* E=cyl 174 thru 495 */ + HDSZ(109620), 496, /* F=cyl 496 thru 785 */ + HDSZ(247590), 131, /* G=cyl 131 thru 785 */ + HDSZ(231336), 174, /* H=cyl 174 thru 785 */ +}, hd7959B_sizes[8] = { + HDSZ(16254), 1, /* A=cyl 1 thru 43 */ + HDSZ(49140), 44, /* B=cyl 44 thru 173 */ + HDSZ(594216), 0, /* C=cyl 0 thru 1571 */ + HDSZ(65772), 44, /* D=cyl 44 thru 217 */ + HDSZ(303912), 218, /* E=cyl 218 thru 1021 */ + HDSZ(207900), 1022, /* F=cyl 1022 thru 1571 */ + HDSZ(528444), 174, /* G=cyl 174 thru 1571 */ + HDSZ(511812), 218, /* H=cyl 218 thru 1571 */ +}, hd2200A_sizes[8] = { + HDSZ(16272), 1, /* A=cyl 1 thru 36 */ + HDSZ(49720), 37, /* B=cyl 37 thru 146 */ + HDSZ(654948), 0, /* C=cyl 0 thru 1448 */ + HDSZ(65992), 37, /* D=cyl 37 thru 182 */ + HDSZ(304648), 183, /* E=cyl 183 thru 856 */ + HDSZ(267584), 857, /* F=cyl 857 thru 1448 */ + HDSZ(588504), 147, /* G=cyl 147 thru 1448 */ + HDSZ(572232), 183, /* H=cyl 183 thru 1448 */ +}, hd2203A_sizes[8] = { + /* modelled after the 7937; i.e. bogus */ + HDSZ(16272), 1, /* A=cyl 1 thru 18 */ + HDSZ(67800), 19, /* B=cyl 19 thru 93 */ + HDSZ(1309896), 0, /* C=cyl 0 thru 1448 */ + HDSZ(16272), 94, /* D=cyl 19 thru 111 */ + HDSZ(305552), 112, /* E=cyl 112 thru 449 */ + HDSZ(305552), 450, /* F=cyl 450 thru 787 */ + HDSZ(1224920), 94, /* G=cyl 94 thru 1448 */ + HDSZ(597544), 788, /* H=cyl 788 thru 1448 */ +}, hd7936H_sizes[8] = { + HDSZ(16359), 1, /* A=cyl 1 thru 19 */ + HDSZ(67158), 20, /* B=cyl 20 thru 97 */ + HDSZ(600978), 0, /* C=cyl 0 thru 697 */ + HDSZ(16359), 98, /* D=cyl 98 thru 116 */ + HDSZ(120540), 117, /* E=cyl 117 thru 256 */ + HDSZ(120540), 256, /* F=cyl 256 thru 396 */ + HDSZ(516600), 98, /* G=cyl 98 thru 697 */ + HDSZ(259161), 397, /* H=cyl 397 thru 697 */ +}, hd7937H_sizes[8] = { + HDSZ(15990), 1, /* A=cyl 1 thru 10 */ + HDSZ(67158), 11, /* B=cyl 11 thru 52 */ + HDSZ(1116102), 0, /* C=cyl 0 thru 697 */ + HDSZ(124722), 53, /* D=cyl 53 thru 130 */ + HDSZ(163098), 131, /* E=cyl 131 thru 232 */ + HDSZ(287820), 233, /* F=cyl 233 thru 412 */ + HDSZ(1031355), 53, /* G=cyl 53 thru 697 */ + HDSZ(455715), 413, /* H=cyl 413 thru 697 */ +}; + +/* + * Indexed the same as hdidentinfo array. + */ +struct hdcompatinfo { + struct size *sizes; /* partition info */ +} hdcompatinfo[] = { + hd7945A_sizes, + hd9134D_sizes, + hd9122S_sizes, + hd7912P_sizes, + hd7914P_sizes, + hd7958A_sizes, + hd7957A_sizes, + hd7933H_sizes, + hd9134L_sizes, + hd7936H_sizes, + hd7937H_sizes, + hd7914P_sizes, + hd7945A_sizes, + hd9122S_sizes, + hd7957B_sizes, + hd7958B_sizes, + hd7959B_sizes, + hd2200A_sizes, + hd2203A_sizes, +}; +int nhdcompatinfo = sizeof(hdcompatinfo) / sizeof(hdcompatinfo[0]); + +hdmakedisklabel(unit, lp) + int unit; + struct disklabel *lp; +{ + extern struct cfdriver hd_cd; + register struct hd_softc *rs = hd_cd.cd_devs[unit]; + register struct hdcompatinfo *ci = &hdcompatinfo[rs->sc_type]; + struct hdidentinfo *ri = &hdidentinfo[rs->sc_type]; + register struct partition *pi; + register int dcount; + + lp->d_nsectors = ri->ri_nbpt; + lp->d_ntracks = ri->ri_ntpc; + lp->d_ncylinders = ri->ri_ncyl; + lp->d_secpercyl = ri->ri_nbpt * ri->ri_ntpc; + lp->d_secperunit = lp->d_secpercyl * ri->ri_ncyl; + lp->d_rpm = 3600; + lp->d_interleave = 1; + lp->d_npartitions = 8; + + pi = lp->d_partitions; + for (dcount = 0; dcount < lp->d_npartitions; dcount++) { + pi->p_size = ci->sizes[dcount].nblocks; + pi->p_offset = ci->sizes[dcount].cyloff * lp->d_secpercyl; + pi->p_fsize = 1024; + if (dcount == 1 || dcount == 3) + pi->p_fstype = FS_SWAP; + else if (dcount == 2) + pi->p_fstype = FS_BOOT; + else + pi->p_fstype = FS_BSDFFS; + pi->p_frag = 8; + pi++; + } +} diff --git a/sys/arch/hp300/dev/hdreg.h b/sys/arch/hp300/dev/hdreg.h new file mode 100644 index 00000000000..0ffa53a09e4 --- /dev/null +++ b/sys/arch/hp300/dev/hdreg.h @@ -0,0 +1,279 @@ +/* $OpenBSD: hdreg.h,v 1.1 1997/02/03 08:11:55 downsj Exp $ */ +/* $NetBSD: rdreg.h,v 1.7 1996/02/09 18:00:37 scottr Exp $ */ + +/* + * 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 + * 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. + * + * from: Utah $Hdr: rdreg.h 1.2 90/10/12$ + * + * @(#)rdreg.h 8.1 (Berkeley) 6/10/93 + */ + +struct hd_iocmd { + char c_pad; + char c_unit; + char c_volume; + char c_saddr; + short c_hiaddr; + long c_addr; + char c_nop2; + char c_slen; + long c_len; + char c_cmd; + char c_pad2; +}; + +struct hd_rscmd { + char c_unit; + char c_sram; + char c_ram; + char c_cmd; +}; + +struct hd_stat { + char c_vu; + char c_pend; + short c_ref; + short c_fef; + short c_aef; + short c_ief; + union { + char cu_raw[10]; + struct { + short cu_msw; + long cu_lsl; + } cu_sva; + struct { + long cu_cyhd; + short cu_sect; + } cu_tva; + } c_pf; +}; +#define c_raw c_pf.cu_raw +#define c_blk c_pf.cu_sva.cu_lsl /* for now */ +#define c_tva c_pf.cu_tva + +struct hd_ssmcmd { + char c_unit; + char c_cmd; + short c_refm; + short c_fefm; + short c_aefm; + short c_iefm; +}; + +struct hd_srcmd { + char c_unit; + char c_nop; + char c_cmd; + char c_param; +}; + +struct hd_clearcmd { + char c_unit; + char c_cmd; +}; + +struct hd_describe { + u_int d_iuw:16, /* controller: installed unit word */ + d_cmaxxfr:16, /* controller: max transfer rate (Kb) */ + d_ctype:8, /* controller: controller type */ + d_utype:8, /* unit: unit type */ + d_name:24, /* unit: name (6 BCD digits) */ + d_sectsize:16, /* unit: # of bytes per block (sector) */ + d_blkbuf:8, /* unit: # of blocks which can be buffered */ + d_burstsize:8, /* unit: recommended burst size */ + d_blocktime:16, /* unit: block time (u-sec) */ + d_uavexfr:16, /* unit: average transfer rate (Kb) */ + d_retry:16, /* unit: optimal retry time (1/100-sec) */ + d_access:16, /* unit: access time param (1/100-sec) */ + d_maxint:8, /* unit: maximum interleave */ + d_fvbyte:8, /* unit: fixed volume byte */ + d_rvbyte:8, /* unit: removeable volume byte */ + d_maxcyl:24, /* volume: maximum cylinder */ + d_maxhead:8, /* volume: maximum head */ + d_maxsect:16, /* volume: maximum sector on track */ + d_maxvsecth:16, /* volume: maximum sector on volume (MSW) */ + d_maxvsectl:32, /* volume: maximum sector on volume (LSWs) */ + d_interleave:8; /* volume: current interleave */ + }; + +/* HW ids */ +#define HD7946AID 0x220 /* also 7945A */ +#define HD9134DID 0x221 /* also 9122S */ +#define HD9134LID 0x222 /* also 9122D */ +#define HD7912PID 0x209 +#define HD7914CTID 0x20A +#define HD7914PID 0x20B +#define HD7958AID 0x22B +#define HD7957AID 0x22A +#define HD7933HID 0x212 +#define HD7936HID 0x213 /* just guessing -- as of yet unknown */ +#define HD7937HID 0x214 +#define HD7957BID 0x22C /* another guess based on 7958B */ +#define HD7958BID 0x22D +#define HD7959BID 0x22E /* another guess based on 7958B */ +#define HD2200AID 0x22F +#define HD2203AID 0x230 /* yet another guess */ + +/* SW ids -- indicies into hdidentinfo, order is arbitrary */ +#define HD7945A 0 +#define HD9134D 1 +#define HD9122S 2 +#define HD7912P 3 +#define HD7914P 4 +#define HD7958A 5 +#define HD7957A 6 +#define HD7933H 7 +#define HD9134L 8 +#define HD7936H 9 +#define HD7937H 10 +#define HD7914CT 11 +#define HD7946A 12 +#define HD9122D 13 +#define HD7957B 14 +#define HD7958B 15 +#define HD7959B 16 + +#define NHD7945ABPT 16 +#define NHD7945ATRK 7 +#define NHD9134DBPT 16 +#define NHD9134DTRK 6 +#define NHD9122SBPT 8 +#define NHD9122STRK 2 +#define NHD7912PBPT 32 +#define NHD7912PTRK 7 +#define NHD7914PBPT 32 +#define NHD7914PTRK 7 +#define NHD7933HBPT 46 +#define NHD7933HTRK 13 +#define NHD9134LBPT 16 +#define NHD9134LTRK 5 + +/* + * Several HP drives have an odd number of 256 byte sectors per track. + * This makes it rather difficult to break them into 512 and 1024 byte blocks. + * So...we just do like HPUX and don't bother to respect hardware track/head + * boundries -- we just mold the disk so that we use the entire capacity. + * HPUX also sometimes doen't abide by cylinder boundries, we attempt to + * whenever possible. + * + * DISK REAL (256 BPS) HPUX (1024 BPS) BSD (512 BPS) + * SPT x HD x CYL SPT x HD x CYL SPT x HD x CYL + * ----- --------------- --------------- -------------- + * 7936: 123 x 7 x 1396 25 x 7 x 1716 123 x 7 x 698 + * 7937: 123 x 13 x 1396 25 x 16 x 1395 123 x 13 x 698 + * + * 7957A: 63 x 5 x 1013 11 x 7 x 1036 22 x 7 x 1036 + * 7958A: 63 x 8 x 1013 21 x 6 x 1013 36 x 7 x 1013 + * + * 7957B: 63 x 4 x 1269 9 x 7 x 1269 18 x 7 x 1269 + * 7958B: 63 x 6 x 1572 21 x 9 x 786 42 x 9 x 786 + * 7959B: 63 x 12 x 1572 21 x 9 x 1572 42 x 9 x 1572 + * + * 2200A: 113 x 8 x 1449 113 x 2 x 1449 113 x 4 x 1449 + * 2203A: 113 x 16 x 1449 113 x 4 x 1449 113 x 8 x 1449 + */ +#define NHD7936HBPT 123 +#define NHD7936HTRK 7 +#define NHD7937HBPT 123 +#define NHD7937HTRK 13 +#define NHD7957ABPT 22 +#define NHD7957ATRK 7 +#define NHD7958ABPT 36 +#define NHD7958ATRK 7 +#define NHD7957BBPT 18 +#define NHD7957BTRK 7 +#define NHD7958BBPT 42 +#define NHD7958BTRK 9 +#define NHD7959BBPT 42 +#define NHD7959BTRK 9 +#define NHD2200ABPT 113 +#define NHD2200ATRK 4 +#define NHD2203ABPT 113 +#define NHD2203ATRK 8 + +/* controller "unit" number */ +#define HDCTLR 15 + +/* convert 512 byte count into DEV_BSIZE count */ +#define HDSZ(x) ((x) >> (DEV_BSHIFT-9)) + +/* convert block number into sector number and back */ +#define HDBTOS(x) ((x) << (DEV_BSHIFT-8)) +#define HDSTOB(x) ((x) >> (DEV_BSHIFT-8)) + +/* extract cyl/head/sect info from three-vector address */ +#define HDCYL(tva) ((u_long)(tva).cu_cyhd >> 8) +#define HDHEAD(tva) ((tva).cu_cyhd & 0xFF) +#define HDSECT(tva) ((tva).cu_sect) + +#define REF_MASK 0x0 +#define FEF_MASK 0x0 +#define AEF_MASK 0x0 +#define IEF_MASK 0xF970 + +#define FEF_CU 0x4000 /* cross-unit */ +#define FEF_DR 0x0080 /* diagnostic result */ +#define FEF_IMR 0x0008 /* internal maintenance release */ +#define FEF_PF 0x0002 /* power fail */ +#define FEF_REXMT 0x0001 /* retransmit */ +#define AEF_UD 0x0040 /* unrecoverable data */ +#define IEF_RRMASK 0xe000 /* request release bits */ +#define IEF_MD 0x0020 /* marginal data */ +#define IEF_RD 0x0010 /* recoverable data */ + +#define C_READ 0x00 +#define C_RAM 0x00 /* single vector (i.e. sector number) */ +#define C_WRITE 0x02 +#define C_CLEAR 0x08 +#define C_STATUS 0x0d +#define C_SADDR 0x10 +#define C_SLEN 0x18 +#define C_SUNIT(x) (0x20 | (x)) +#define C_SVOL(x) (0x40 | (x)) +#define C_NOP 0x34 +#define C_DESC 0x35 +#define C_SREL 0x3b +#define C_SSM 0x3e +#define C_SRAM 0x48 +#define C_REL 0xc0 + +#define C_CMD 0x05 +#define C_EXEC 0x0e +#define C_QSTAT 0x10 +#define C_TCMD 0x12 diff --git a/sys/arch/hp300/dev/hdvar.h b/sys/arch/hp300/dev/hdvar.h new file mode 100644 index 00000000000..051bdb246a5 --- /dev/null +++ b/sys/arch/hp300/dev/hdvar.h @@ -0,0 +1,106 @@ +/* $OpenBSD: hdvar.h,v 1.1 1997/02/03 08:11:55 downsj Exp $ */ +/* $NetBSD: rdvar.h,v 1.6 1997/01/30 09:14:19 thorpej Exp $ */ + +/* + * 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 + * 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. + * + * from: Utah $Hdr: rdvar.h 1.1 92/12/21$ + * + * @(#)rdvar.h 8.1 (Berkeley) 6/10/93 + */ + +struct hdidentinfo { + short ri_hwid; /* 2 byte HW id */ + short ri_maxunum; /* maximum allowed unit number */ + char *ri_desc; /* drive type description */ + int ri_nbpt; /* DEV_BSIZE blocks per track */ + int ri_ntpc; /* tracks per cylinder */ + int ri_ncyl; /* cylinders per unit */ + int ri_nblocks; /* DEV_BSIZE blocks on disk */ +}; + +struct hdstats { + long hdretries; + long hdresets; + long hdtimeouts; + long hdpolltries; + long hdpollwaits; +}; + +struct hd_softc { + struct device sc_dev; + struct disk sc_dkdev; + int sc_slave; /* HP-IB slave */ + int sc_punit; /* physical unit on slave */ + int sc_flags; + short sc_type; + char *sc_addr; + int sc_resid; + struct hd_describe sc_hddesc; + struct hpibqueue sc_hq; /* hpib job queue entry */ + struct hd_iocmd sc_ioc; + struct hd_rscmd sc_rsc; + struct hd_stat sc_stat; + struct hd_ssmcmd sc_ssmc; + struct hd_srcmd sc_src; + struct hd_clearcmd sc_clear; + struct buf sc_tab; /* buffer queue */ + struct hdstats sc_stats; +}; + +/* sc_flags values */ +#define HDF_ALIVE 0x01 +#define HDF_SEEK 0x02 +#define HDF_SWAIT 0x04 +#define HDF_OPENING 0x08 +#define HDF_CLOSING 0x10 +#define HDF_WANTED 0x20 +#define HDF_WLABEL 0x40 + +#define hdunit(x) (minor(x) >> 3) +#define hdpart(x) (minor(x) & 0x7) +#define hdpunit(x) ((x) & 7) +#define hdlabdev(d) (dev_t)(((int)(d)&~7)|2) /* hd?c */ + +#define b_cylin b_resid + +#define HDRETRY 5 +#define HDWAITC 1 /* min time for timeout in seconds */ + +#ifdef _KERNEL +extern struct hdidentinfo hdidentinfo[]; +#endif diff --git a/sys/arch/hp300/dev/rd.c b/sys/arch/hp300/dev/rd.c deleted file mode 100644 index 7af83b52b3d..00000000000 --- a/sys/arch/hp300/dev/rd.c +++ /dev/null @@ -1,1298 +0,0 @@ -/* $OpenBSD: rd.c,v 1.8 1997/02/03 04:47:42 downsj Exp $ */ -/* $NetBSD: rd.c,v 1.27 1997/01/30 09:14:17 thorpej Exp $ */ - -/* - * Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved. - * 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 - * 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. - * - * from: Utah $Hdr: rd.c 1.44 92/12/26$ - * - * @(#)rd.c 8.2 (Berkeley) 5/19/94 - */ - -/* - * CS80/SS80 disk driver - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#ifdef USELEDS -#include -#endif - -#include -#include -#include -#include - -int rdmatch __P((struct device *, void *, void *)); -void rdattach __P((struct device *, struct device *, void *)); - -struct cfattach rd_ca = { - sizeof(struct rd_softc), rdmatch, rdattach -}; - -struct cfdriver rd_cd = { - NULL, "rd", DV_DISK -}; - -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 rdstart __P((void *)); -void rdintr __P((void *)); -void rdgo __P((void *)); - -bdev_decl(rd); -cdev_decl(rd); - -int rderrthresh = RDRETRY-1; /* when to start reporting errors */ - -#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 -}; - -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 - -/* - * Misc. HW description, indexed by sc_type. - * Nothing really critical here, could do without it. - */ -struct rdidentinfo rdidentinfo[] = { - { 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 } -}; -int numrdidentinfo = sizeof(rdidentinfo) / sizeof(rdidentinfo[0]); - -int -rdmatch(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct cfdata *cf = match; - struct hpibbus_attach_args *ha = aux; - - /* - * Set punit if operator specified one in the kernel - * configuration file. - */ - if (cf->hpibbuscf_punit != HPIBBUS_PUNIT_UNK && - cf->hpibbuscf_punit < HPIB_NPUNITS) - ha->ha_punit = cf->hpibbuscf_punit; - - if (rdident(parent, NULL, ha) == 0) { - /* - * XXX Some aging HP-IB drives are slow to - * XXX respond; give them a chance to catch - * XXX up and probe them again. - */ - delay(10000); - ha->ha_id = hpibid(parent->dv_unit, ha->ha_slave); - return (rdident(parent, NULL, ha)); - } - return (1); -} - -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; - } - - /* - * Initialize and attach the disk structure. - */ - bzero(&sc->sc_dkdev, sizeof(sc->sc_dkdev)); - sc->sc_dkdev.dk_name = sc->sc_dev.dv_xname; - disk_attach(&sc->sc_dkdev); - - sc->sc_slave = ha->ha_slave; - sc->sc_punit = ha->ha_punit; - - /* 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; - - sc->sc_flags = RDF_ALIVE; -#ifdef DEBUG - /* always report errors */ - if (rddebug & RDB_ERROR) - rderrthresh = 0; -#endif - - dk_establish(&sc->sc_dkdev, &sc->sc_dev); /* XXX */ -} - -int -rdident(parent, sc, ha) - struct device *parent; - struct rd_softc *sc; - struct hpibbus_attach_args *ha; -{ - struct rd_softc rsc; - struct rd_describe *desc = sc != NULL ? &sc->sc_rddesc : NULL; - u_char stat, cmd[3]; - char name[7]; - int i, id, n, ctlr, slave; - - 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); - - /* - * If we're just probing for the device, that's all the - * work we need to do. - */ - if (sc == NULL) - return (1); - - /* - * Reset device and collect description - */ - rdreset(sc); - cmd[0] = C_SUNIT(ha->ha_punit); - cmd[1] = C_SVOL(0); - cmd[2] = C_DESC; - 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)); - if (stat == 0) { - n = desc->d_name; - for (i = 5; i >= 0; i--) { - name[i] = (n & 0xf) + '0'; - n >>= 4; - } - } - -#ifdef DEBUG - if (rddebug & RDB_IDENT) { - printf("\n%s: name: %x ('%s')\n", - sc->sc_dev.dv_xname, 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); - printf("%s", sc->sc_dev.dv_xname); - } -#endif - - /* - * 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 (ha->ha_id) { - 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; - } - - sc->sc_type = id; - - /* - * XXX We use DEV_BSIZE instead of the sector size value pulled - * XXX off the driver because all of this code assumes 512 byte - * XXX blocks. ICK! - */ - 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); -} - -void -rdreset(rs) - register struct rd_softc *rs; -{ - int ctlr = rs->sc_dev.dv_parent->dv_unit; - int slave = rs->sc_slave; - u_char stat; - - rs->sc_clear.c_unit = C_SUNIT(rs->sc_punit); - rs->sc_clear.c_cmd = C_CLEAR; - hpibsend(ctlr, slave, C_TCMD, &rs->sc_clear, sizeof(rs->sc_clear)); - hpibswait(ctlr, slave); - hpibrecv(ctlr, 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(ctlr, slave, C_CMD, &rs->sc_src, sizeof(rs->sc_src)); - hpibswait(ctlr, slave); - hpibrecv(ctlr, 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(ctlr, slave, C_CMD, &rs->sc_ssmc, sizeof(rs->sc_ssmc)); - hpibswait(ctlr, slave); - hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat)); -#ifdef DEBUG - rs->sc_stats.rdresets++; -#endif -} - -/* - * Read or constuct a disklabel - */ -int -rdgetinfo(dev) - dev_t dev; -{ - int unit = rdunit(dev); - struct rd_softc *rs = rd_cd.cd_devs[unit]; - register struct disklabel *lp = rs->sc_dkdev.dk_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_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 - */ - msg = readdisklabel(rdlabdev(dev), rdstrategy, lp, NULL); - if (msg == NULL) - return(0); - - pi = lp->d_partitions; - printf("%s: WARNING: %s, ", rs->sc_dev.dv_xname, msg); -#ifdef COMPAT_NOLABEL - printf("using old default partitioning\n"); - rdmakedisklabel(unit, lp); -#else - printf("defining `c' partition as entire disk\n"); - pi[2].p_size = rdidentinfo[rs->sc_type].ri_nblocks; - /* XXX reset other info since readdisklabel screws with it */ - lp->d_npartitions = 3; - pi[0].p_size = 0; -#endif - return(0); -} - -int -rdopen(dev, flags, mode, p) - dev_t dev; - int flags, mode; - struct proc *p; -{ - register int unit = rdunit(dev); - register struct rd_softc *rs; - int error, mask, part; - - if (unit >= rd_cd.cd_ndevs || - (rs = rd_cd.cd_devs[unit]) == NULL || - (rs->sc_flags & RDF_ALIVE) == 0) - return (ENXIO); - - /* - * 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_dkdev.dk_openmask == 0) { - rs->sc_flags |= RDF_OPENING; - error = rdgetinfo(dev); - rs->sc_flags &= ~RDF_OPENING; - wakeup((caddr_t)rs); - if (error) - return(error); - } - - 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: - rs->sc_dkdev.dk_copenmask |= mask; - break; - case S_IFBLK: - rs->sc_dkdev.dk_bopenmask |= mask; - break; - } - rs->sc_dkdev.dk_openmask = - rs->sc_dkdev.dk_copenmask | rs->sc_dkdev.dk_bopenmask; - - return(0); -} - -int -rdclose(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; -{ - int unit = rdunit(dev); - struct rd_softc *rs = rd_cd.cd_devs[unit]; - register struct disk *dk = &rs->sc_dkdev; - int mask, s; - - mask = 1 << rdpart(dev); - if (mode == S_IFCHR) - dk->dk_copenmask &= ~mask; - else - dk->dk_bopenmask &= ~mask; - dk->dk_openmask = dk->dk_copenmask | dk->dk_bopenmask; - /* - * 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. - */ - if (dk->dk_openmask == 0) { - rs->sc_flags |= RDF_CLOSING; - s = splbio(); - while (rs->sc_tab.b_active) { - rs->sc_flags |= RDF_WANTED; - sleep((caddr_t)&rs->sc_tab, PRIBIO); - } - splx(s); - rs->sc_flags &= ~(RDF_CLOSING|RDF_WLABEL); - wakeup((caddr_t)rs); - } - return(0); -} - -void -rdstrategy(bp) - register struct buf *bp; -{ - int unit = rdunit(bp->b_dev); - struct rd_softc *rs = rd_cd.cd_devs[unit]; - register struct buf *dp = &rs->sc_tab; - register struct partition *pinfo; - register daddr_t bn; - register int sz, s; - int offset; - -#ifdef DEBUG - 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'); -#endif - bn = bp->b_blkno; - sz = howmany(bp->b_bcount, DEV_BSIZE); - pinfo = &rs->sc_dkdev.dk_label->d_partitions[rdpart(bp->b_dev)]; - - /* 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); - } - /* - * Check for write to write protected label - */ - if (bn + offset <= LABELSECTOR && -#if LABELSECTOR != 0 - bn + offset + sz > LABELSECTOR && -#endif - !(bp->b_flags & B_READ) && !(rs->sc_flags & RDF_WLABEL)) { - bp->b_error = EROFS; - goto bad; - } - } - bp->b_cylin = bn + offset; - s = splbio(); - disksort(dp, bp); - if (dp->b_active == 0) { - dp->b_active = 1; - rdustart(rs); - } - splx(s); - return; -bad: - bp->b_flags |= B_ERROR; -done: - biodone(bp); -} - -/* - * Called from timeout() when handling maintenance releases - */ -void -rdrestart(arg) - void *arg; -{ - int s = splbio(); - rdustart((struct rd_softc *)arg); - splx(s); -} - -void -rdustart(rs) - struct rd_softc *rs; -{ - register struct buf *bp; - - bp = rs->sc_tab.b_actf; - rs->sc_addr = bp->b_un.b_addr; - rs->sc_resid = bp->b_bcount; - if (hpibreq(rs->sc_dev.dv_parent, &rs->sc_hq)) - rdstart(rs); -} - -struct buf * -rdfinish(rs, bp) - register struct rd_softc *rs; - register struct buf *bp; -{ - register struct buf *dp = &rs->sc_tab; - - dp->b_errcnt = 0; - dp->b_actf = bp->b_actf; - bp->b_resid = 0; - biodone(bp); - hpibfree(rs->sc_dev.dv_parent, &rs->sc_hq); - if (dp->b_actf) - return (dp->b_actf); - dp->b_active = 0; - if (rs->sc_flags & RDF_WANTED) { - rs->sc_flags &= ~RDF_WANTED; - wakeup((caddr_t)dp); - } - return (NULL); -} - -void -rdstart(arg) - void *arg; -{ - struct rd_softc *rs = arg; - register struct buf *bp = rs->sc_tab.b_actf; - register int part, ctlr, slave; - - ctlr = rs->sc_dev.dv_parent->dv_unit; - slave = rs->sc_slave; - -again: -#ifdef DEBUG - if (rddebug & RDB_FOLLOW) - printf("rdstart(%s): bp %x, %c\n", sc->sc_dev.dv_xname, bp, - (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; - 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; -#ifdef DEBUG - if (rddebug & RDB_IO) - printf("rdstart: hpibsend(%x, %x, %x, %x, %x)\n", - ctlr, slave, C_CMD, - &rs->sc_ioc.c_unit, sizeof(rs->sc_ioc)-2); -#endif - if (hpibsend(ctlr, slave, C_CMD, &rs->sc_ioc.c_unit, - sizeof(rs->sc_ioc)-2) == sizeof(rs->sc_ioc)-2) { - - /* Instrumentation. */ - disk_busy(&rs->sc_dkdev); - rs->sc_dkdev.dk_seek++; - -#ifdef DEBUG - if (rddebug & RDB_IO) - printf("rdstart: hpibawait(%x)\n", ctlr); -#endif - hpibawait(ctlr); - 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) - printf("%s: rdstart: cmd %x adr %d blk %d len %d ecnt %d\n", - 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++; -#endif - rs->sc_flags &= ~RDF_SEEK; - rdreset(rs); - if (rs->sc_tab.b_errcnt++ < RDRETRY) - goto again; - printf("%s: rdstart err: cmd 0x%x sect %d blk %d len %d\n", - rs->sc_dev.dv_xname, rs->sc_ioc.c_cmd, rs->sc_ioc.c_addr, - bp->b_blkno, rs->sc_resid); - bp->b_flags |= B_ERROR; - bp->b_error = EIO; - bp = rdfinish(rs, bp); - if (bp) { - rs->sc_addr = bp->b_un.b_addr; - rs->sc_resid = bp->b_bcount; - if (hpibreq(rs->sc_dev.dv_parent, &rs->sc_hq)) - goto again; - } -} - -void -rdgo(arg) - void *arg; -{ - 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; - - rw = bp->b_flags & B_READ; - - /* Instrumentation. */ - disk_busy(&rs->sc_dkdev); - -#ifdef USELEDS - if (inledcontrol == 0) - ledcontrol(0, 0, LED_DISK); -#endif - hpibgo(ctlr, slave, C_EXEC, rs->sc_addr, rs->sc_resid, rw, rw != 0); -} - -/* ARGSUSED */ -void -rdintr(arg) - void *arg; -{ - register struct rd_softc *rs = arg; - int unit = rs->sc_dev.dv_unit; - register struct buf *bp = rs->sc_tab.b_actf; - u_char stat = 13; /* in case hpibrecv fails */ - int rv, restart, ctlr, slave; - - ctlr = rs->sc_dev.dv_parent->dv_unit; - slave = rs->sc_slave; - -#ifdef DEBUG - 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); - if (bp == NULL) { - printf("%s: bp == NULL\n", rs->sc_dev.dv_xname); - return; - } -#endif - disk_unbusy(&rs->sc_dkdev, (bp->b_bcount - bp->b_resid)); - - if (rs->sc_flags & RDF_SEEK) { - rs->sc_flags &= ~RDF_SEEK; - if (hpibustart(ctlr)) - rdgo(rs); - return; - } - if ((rs->sc_flags & RDF_SWAIT) == 0) { -#ifdef DEBUG - rs->sc_stats.rdpolltries++; -#endif - if (hpibpptest(ctlr, slave) == 0) { -#ifdef DEBUG - rs->sc_stats.rdpollwaits++; -#endif - - /* Instrumentation. */ - disk_busy(&rs->sc_dkdev); - rs->sc_flags |= RDF_SWAIT; - hpibawait(ctlr); - return; - } - } else - rs->sc_flags &= ~RDF_SWAIT; - rv = hpibrecv(ctlr, slave, C_QSTAT, &stat, 1); - if (rv != 1 || stat) { -#ifdef DEBUG - if (rddebug & RDB_ERROR) - printf("rdintr: recv failed or bad stat %d\n", stat); -#endif - restart = rderror(unit); -#ifdef DEBUG - rs->sc_stats.rdretries++; -#endif - if (rs->sc_tab.b_errcnt++ < RDRETRY) { - if (restart) - rdstart(rs); - return; - } - bp->b_flags |= B_ERROR; - bp->b_error = EIO; - } - if (rdfinish(rs, bp)) - rdustart(rs); -} - -int -rdstatus(rs) - register struct rd_softc *rs; -{ - register int c, s; - u_char stat; - int rv; - - c = rs->sc_dev.dv_parent->dv_unit; - s = rs->sc_slave; - 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) - printf("rdstatus: send C_CMD failed %d != %d\n", - 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) - printf("rdstatus: send C_EXEC failed %d != %d\n", - 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) - printf("rdstatus: recv failed %d or bad stat %d\n", - 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. - */ -int -rderror(unit) - int unit; -{ - struct rd_softc *rs = rd_cd.cd_devs[unit]; - register struct rd_stat *sp; - struct buf *bp; - daddr_t hwbn, pbn; - - if (rdstatus(rs)) { -#ifdef DEBUG - printf("%s: couldn't get status\n", rs->sc_dev.dv_xname); -#endif - rdreset(rs); - return(1); - } - sp = &rs->sc_stat; - if (sp->c_fef & FEF_REXMT) - return(1); - if (sp->c_fef & FEF_PF) { - rdreset(rs); - 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; - int rdtimo = RDWAITC << rs->sc_tab.b_errcnt; -#ifdef DEBUG - printf("%s: internal maintenance, %d second timeout\n", - rs->sc_dev.dv_xname, rdtimo); - rs->sc_stats.rdtimeouts++; -#endif - hpibfree(rs->sc_dev.dv_parent, &rs->sc_hq); - timeout(rdrestart, rs, rdtimo * hz); - 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. - */ - if (rs->sc_tab.b_errcnt < rderrthresh) - 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. - */ - bp = rs->sc_tab.b_actf; - pbn = rs->sc_dkdev.dk_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 = 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. - */ - printf("%s%c: hard error sn%d\n", rs->sc_dev.dv_xname, - 'a'+rdpart(bp->b_dev), pbn); - /* - * Now report the status as returned by the hardware with - * attempt at interpretation (unless debugging). - */ - printf("%s %s error:", rs->sc_dev.dv_xname, - (bp->b_flags & B_READ) ? "read" : "write"); -#ifdef DEBUG - if (rddebug & RDB_ERROR) { - /* status info */ - 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)); - /* command */ - printf(" ioc: "); - 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)); - return(1); - } -#endif - 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("P1-P10: "); - 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(1); -} - -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)); -} - -int -rdioctl(dev, cmd, data, flag, p) - dev_t dev; - u_long cmd; - caddr_t data; - int flag; - struct proc *p; -{ - int unit = rdunit(dev); - struct rd_softc *sc = rd_cd.cd_devs[unit]; - register struct disklabel *lp = sc->sc_dkdev.dk_label; - 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 - : sc->sc_dkdev.dk_openmask, - (struct cpu_disklabel *)0)); - - case DIOCWDINFO: - if ((flag & FWRITE) == 0) - return (EBADF); - error = setdisklabel(lp, (struct disklabel *)data, - (sc->sc_flags & RDF_WLABEL) ? 0 - : sc->sc_dkdev.dk_openmask, - (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); - } - return(EINVAL); -} - -int -rdsize(dev) - dev_t dev; -{ - register int unit = rdunit(dev); - struct rd_softc *rs; - int psize, didopen = 0; - - if (unit >= rd_cd.cd_ndevs || - (rs = rd_cd.cd_devs[unit]) == NULL || - (rs->sc_flags & RDF_ALIVE) == 0) - return (-1); - - /* - * We get called very early on (via swapconf) - * without the device being open so we may need - * to handle it here. - */ - if (rs->sc_dkdev.dk_openmask == 0) { - if (rdopen(dev, FREAD|FWRITE, S_IFBLK, NULL)) - return(-1); - didopen = 1; - } - psize = rs->sc_dkdev.dk_label->d_partitions[rdpart(dev)].p_size; - if (didopen) - (void) rdclose(dev, FREAD|FWRITE, S_IFBLK, NULL); - return (psize); -} - -#ifdef DEBUG -rdprinterr(str, err, tab) - char *str; - short err; - char *tab[]; -{ - register int i; - int printed; - - if (err == 0) - return; - printf(" %s error field:", str, err); - printed = 0; - for (i = 0; i < 16; i++) - if (err & (0x8000 >> i)) - printf("%s%s", printed++ ? " + " : " ", tab[i]); - printf("\n"); -} -#endif - -static int rddoingadump; /* simple mutex */ - -/* - * Non-interrupt driven, non-dma dump routine. - */ -int -rddump(dev, blkno, va, size) - dev_t dev; - daddr_t blkno; - caddr_t va; - size_t size; -{ - 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; - int ctlr, slave; - struct rd_softc *rs; - struct disklabel *lp; - char stat; - - /* 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. */ - if (unit >= rd_cd.cd_ndevs || - (rs = rd_cd.cd_devs[unit]) == NULL || - (rs->sc_flags & RDF_ALIVE) == 0) - return (ENXIO); - - ctlr = rs->sc_dev.dv_parent->dv_unit; - slave = rs->sc_slave; - - /* - * 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) - return (EINVAL); - - /* 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. - */ - 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; - rs->sc_ioc.c_addr = RDBTOS(blkno); - rs->sc_ioc.c_nop2 = C_NOP; - rs->sc_ioc.c_slen = C_SLEN; - rs->sc_ioc.c_len = nwrt * sectorsize; - rs->sc_ioc.c_cmd = C_WRITE; - hpibsend(ctlr, slave, C_CMD, &rs->sc_ioc.c_unit, - sizeof(rs->sc_ioc)-2); - if (hpibswait(ctlr, slave)) - return (EIO); - - /* - * Send the data. - */ - hpibsend(ctlr, slave, C_EXEC, va, nwrt * sectorsize); - (void) hpibswait(ctlr, slave); - hpibrecv(ctlr, slave, C_QSTAT, &stat, 1); - if (stat) - return (EIO); -#else /* RD_DUMP_NOT_TRUSTED */ - /* Let's just talk about this first... */ - printf("%s: dump addr %p, blk %d\n", sc->sc_dev.dv_xname, - va, blkno); - delay(500 * 1000); /* half a second */ -#endif /* RD_DUMP_NOT_TRUSTED */ - - /* update block count */ - totwrt -= nwrt; - blkno += nwrt; - va += sectorsize * nwrt; - } - rddoingadump = 0; - return (0); -} diff --git a/sys/arch/hp300/dev/rd_compat.c b/sys/arch/hp300/dev/rd_compat.c deleted file mode 100644 index 6eec8ff55a0..00000000000 --- a/sys/arch/hp300/dev/rd_compat.c +++ /dev/null @@ -1,293 +0,0 @@ -/* $OpenBSD: rd_compat.c,v 1.5 1997/02/03 04:47:43 downsj Exp $ */ -/* $NetBSD: rd_compat.c,v 1.6 1997/01/30 09:14:18 thorpej Exp $ */ - -/* - * 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 - * 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. - * - * from: Utah $Hdr: rd_compat.c 1.1 92/12/21$ - * - * @(#)rd_compat.c 8.1 (Berkeley) 6/10/93 - */ - -/* - * Compatibility for CS80 disks without disklabels. - */ - -#include -#include -#include -#include -#include /* XXX */ - -#include - -#include -#include - -/* - * 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 { - daddr_t nblocks; - int cyloff; -} 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= */ - RDSZ(0), 0, /* F= */ - RDSZ(72240), 323, /* G=cyl 323 thru 967 */ - RDSZ(52080), 503, /* H=cyl 503 thru 967 */ -}, rd9134D_sizes[8] = { - 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= */ - RDSZ(0), 0, /* E= */ - RDSZ(0), 0, /* F= */ - RDSZ(0), 0, /* G= */ - RDSZ(0), 0, /* H= */ -}, rd9122S_sizes[8] = { - RDSZ(0), 0, /* A= */ - RDSZ(0), 0, /* B= */ - RDSZ(1232), 0, /* C=cyl 0 thru 76 */ - RDSZ(0), 0, /* D= */ - RDSZ(0), 0, /* E= */ - RDSZ(0), 0, /* F= */ - RDSZ(0), 0, /* G= */ - RDSZ(0), 0, /* H= */ -}, rd7912P_sizes[8] = { - 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= */ - RDSZ(0), 542, /* F= */ - RDSZ(89600), 172, /* G=cyl 221 thru 571 */ - RDSZ(69440), 262, /* H=cyl 262 thru 571 */ -}, rd7914P_sizes[8] = { - 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 */ -}, rd7933H_sizes[8] = { - 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 */ -}, rd9134L_sizes[8] = { - 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= */ - RDSZ(0), 0, /* F= */ - RDSZ(41840), 450, /* G=cyl 450 thru 972 */ - RDSZ(29840), 600, /* H=cyl 600 thru 972 */ -}, rd7957A_sizes[8] = { - 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 */ -}, rd7958A_sizes[8] = { - 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 */ -}, rd7957B_sizes[8] = { - 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 */ -}, rd7958B_sizes[8] = { - 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 */ -}, rd7959B_sizes[8] = { - 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 */ -}, rd2200A_sizes[8] = { - 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 */ -}, rd2203A_sizes[8] = { - /* 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 */ -}, rd7936H_sizes[8] = { - 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 */ -}, rd7937H_sizes[8] = { - 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 */ -}; - -/* - * Indexed the same as rdidentinfo array. - */ -struct rdcompatinfo { - struct size *sizes; /* partition info */ -} rdcompatinfo[] = { - rd7945A_sizes, - rd9134D_sizes, - rd9122S_sizes, - rd7912P_sizes, - rd7914P_sizes, - rd7958A_sizes, - rd7957A_sizes, - rd7933H_sizes, - rd9134L_sizes, - rd7936H_sizes, - rd7937H_sizes, - rd7914P_sizes, - rd7945A_sizes, - rd9122S_sizes, - rd7957B_sizes, - rd7958B_sizes, - rd7959B_sizes, - rd2200A_sizes, - rd2203A_sizes, -}; -int nrdcompatinfo = sizeof(rdcompatinfo) / sizeof(rdcompatinfo[0]); - -rdmakedisklabel(unit, lp) - int unit; - struct disklabel *lp; -{ - extern struct cfdriver rd_cd; - register struct rd_softc *rs = rd_cd.cd_devs[unit]; - register struct rdcompatinfo *ci = &rdcompatinfo[rs->sc_type]; - struct rdidentinfo *ri = &rdidentinfo[rs->sc_type]; - register struct partition *pi; - register int dcount; - - lp->d_nsectors = ri->ri_nbpt; - lp->d_ntracks = ri->ri_ntpc; - lp->d_ncylinders = ri->ri_ncyl; - lp->d_secpercyl = ri->ri_nbpt * ri->ri_ntpc; - lp->d_secperunit = lp->d_secpercyl * ri->ri_ncyl; - lp->d_rpm = 3600; - lp->d_interleave = 1; - lp->d_npartitions = 8; - - pi = lp->d_partitions; - for (dcount = 0; dcount < lp->d_npartitions; dcount++) { - pi->p_size = ci->sizes[dcount].nblocks; - pi->p_offset = ci->sizes[dcount].cyloff * lp->d_secpercyl; - pi->p_fsize = 1024; - if (dcount == 1 || dcount == 3) - pi->p_fstype = FS_SWAP; - else if (dcount == 2) - pi->p_fstype = FS_BOOT; - else - pi->p_fstype = FS_BSDFFS; - pi->p_frag = 8; - pi++; - } -} diff --git a/sys/arch/hp300/dev/rdreg.h b/sys/arch/hp300/dev/rdreg.h deleted file mode 100644 index ad1c9ccf478..00000000000 --- a/sys/arch/hp300/dev/rdreg.h +++ /dev/null @@ -1,279 +0,0 @@ -/* $OpenBSD: rdreg.h,v 1.4 1997/01/12 15:13:00 downsj Exp $ */ -/* $NetBSD: rdreg.h,v 1.7 1996/02/09 18:00:37 scottr Exp $ */ - -/* - * 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 - * 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. - * - * from: Utah $Hdr: rdreg.h 1.2 90/10/12$ - * - * @(#)rdreg.h 8.1 (Berkeley) 6/10/93 - */ - -struct rd_iocmd { - char c_pad; - char c_unit; - char c_volume; - char c_saddr; - short c_hiaddr; - long c_addr; - char c_nop2; - char c_slen; - long c_len; - char c_cmd; - char c_pad2; -}; - -struct rd_rscmd { - char c_unit; - char c_sram; - char c_ram; - char c_cmd; -}; - -struct rd_stat { - char c_vu; - char c_pend; - short c_ref; - short c_fef; - short c_aef; - short c_ief; - union { - char cu_raw[10]; - struct { - short cu_msw; - long cu_lsl; - } cu_sva; - struct { - long cu_cyhd; - short cu_sect; - } cu_tva; - } c_pf; -}; -#define c_raw c_pf.cu_raw -#define c_blk c_pf.cu_sva.cu_lsl /* for now */ -#define c_tva c_pf.cu_tva - -struct rd_ssmcmd { - char c_unit; - char c_cmd; - short c_refm; - short c_fefm; - short c_aefm; - short c_iefm; -}; - -struct rd_srcmd { - char c_unit; - char c_nop; - char c_cmd; - char c_param; -}; - -struct rd_clearcmd { - char c_unit; - char c_cmd; -}; - -struct rd_describe { - u_int d_iuw:16, /* controller: installed unit word */ - d_cmaxxfr:16, /* controller: max transfer rate (Kb) */ - d_ctype:8, /* controller: controller type */ - d_utype:8, /* unit: unit type */ - d_name:24, /* unit: name (6 BCD digits) */ - d_sectsize:16, /* unit: # of bytes per block (sector) */ - d_blkbuf:8, /* unit: # of blocks which can be buffered */ - d_burstsize:8, /* unit: recommended burst size */ - d_blocktime:16, /* unit: block time (u-sec) */ - d_uavexfr:16, /* unit: average transfer rate (Kb) */ - d_retry:16, /* unit: optimal retry time (1/100-sec) */ - d_access:16, /* unit: access time param (1/100-sec) */ - d_maxint:8, /* unit: maximum interleave */ - d_fvbyte:8, /* unit: fixed volume byte */ - d_rvbyte:8, /* unit: removeable volume byte */ - d_maxcyl:24, /* volume: maximum cylinder */ - d_maxhead:8, /* volume: maximum head */ - d_maxsect:16, /* volume: maximum sector on track */ - d_maxvsecth:16, /* volume: maximum sector on volume (MSW) */ - d_maxvsectl:32, /* volume: maximum sector on volume (LSWs) */ - d_interleave:8; /* volume: current interleave */ - }; - -/* HW ids */ -#define RD7946AID 0x220 /* also 7945A */ -#define RD9134DID 0x221 /* also 9122S */ -#define RD9134LID 0x222 /* also 9122D */ -#define RD7912PID 0x209 -#define RD7914CTID 0x20A -#define RD7914PID 0x20B -#define RD7958AID 0x22B -#define RD7957AID 0x22A -#define RD7933HID 0x212 -#define RD7936HID 0x213 /* just guessing -- as of yet unknown */ -#define RD7937HID 0x214 -#define RD7957BID 0x22C /* another guess based on 7958B */ -#define RD7958BID 0x22D -#define RD7959BID 0x22E /* another guess based on 7958B */ -#define RD2200AID 0x22F -#define RD2203AID 0x230 /* yet another guess */ - -/* SW ids -- indicies into rdidentinfo, order is arbitrary */ -#define RD7945A 0 -#define RD9134D 1 -#define RD9122S 2 -#define RD7912P 3 -#define RD7914P 4 -#define RD7958A 5 -#define RD7957A 6 -#define RD7933H 7 -#define RD9134L 8 -#define RD7936H 9 -#define RD7937H 10 -#define RD7914CT 11 -#define RD7946A 12 -#define RD9122D 13 -#define RD7957B 14 -#define RD7958B 15 -#define RD7959B 16 - -#define NRD7945ABPT 16 -#define NRD7945ATRK 7 -#define NRD9134DBPT 16 -#define NRD9134DTRK 6 -#define NRD9122SBPT 8 -#define NRD9122STRK 2 -#define NRD7912PBPT 32 -#define NRD7912PTRK 7 -#define NRD7914PBPT 32 -#define NRD7914PTRK 7 -#define NRD7933HBPT 46 -#define NRD7933HTRK 13 -#define NRD9134LBPT 16 -#define NRD9134LTRK 5 - -/* - * Several HP drives have an odd number of 256 byte sectors per track. - * This makes it rather difficult to break them into 512 and 1024 byte blocks. - * So...we just do like HPUX and don't bother to respect hardware track/head - * boundries -- we just mold the disk so that we use the entire capacity. - * HPUX also sometimes doen't abide by cylinder boundries, we attempt to - * whenever possible. - * - * DISK REAL (256 BPS) HPUX (1024 BPS) BSD (512 BPS) - * SPT x HD x CYL SPT x HD x CYL SPT x HD x CYL - * ----- --------------- --------------- -------------- - * 7936: 123 x 7 x 1396 25 x 7 x 1716 123 x 7 x 698 - * 7937: 123 x 13 x 1396 25 x 16 x 1395 123 x 13 x 698 - * - * 7957A: 63 x 5 x 1013 11 x 7 x 1036 22 x 7 x 1036 - * 7958A: 63 x 8 x 1013 21 x 6 x 1013 36 x 7 x 1013 - * - * 7957B: 63 x 4 x 1269 9 x 7 x 1269 18 x 7 x 1269 - * 7958B: 63 x 6 x 1572 21 x 9 x 786 42 x 9 x 786 - * 7959B: 63 x 12 x 1572 21 x 9 x 1572 42 x 9 x 1572 - * - * 2200A: 113 x 8 x 1449 113 x 2 x 1449 113 x 4 x 1449 - * 2203A: 113 x 16 x 1449 113 x 4 x 1449 113 x 8 x 1449 - */ -#define NRD7936HBPT 123 -#define NRD7936HTRK 7 -#define NRD7937HBPT 123 -#define NRD7937HTRK 13 -#define NRD7957ABPT 22 -#define NRD7957ATRK 7 -#define NRD7958ABPT 36 -#define NRD7958ATRK 7 -#define NRD7957BBPT 18 -#define NRD7957BTRK 7 -#define NRD7958BBPT 42 -#define NRD7958BTRK 9 -#define NRD7959BBPT 42 -#define NRD7959BTRK 9 -#define NRD2200ABPT 113 -#define NRD2200ATRK 4 -#define NRD2203ABPT 113 -#define NRD2203ATRK 8 - -/* controller "unit" number */ -#define RDCTLR 15 - -/* convert 512 byte count into DEV_BSIZE count */ -#define RDSZ(x) ((x) >> (DEV_BSHIFT-9)) - -/* convert block number into sector number and back */ -#define RDBTOS(x) ((x) << (DEV_BSHIFT-8)) -#define RDSTOB(x) ((x) >> (DEV_BSHIFT-8)) - -/* extract cyl/head/sect info from three-vector address */ -#define RDCYL(tva) ((u_long)(tva).cu_cyhd >> 8) -#define RDHEAD(tva) ((tva).cu_cyhd & 0xFF) -#define RDSECT(tva) ((tva).cu_sect) - -#define REF_MASK 0x0 -#define FEF_MASK 0x0 -#define AEF_MASK 0x0 -#define IEF_MASK 0xF970 - -#define FEF_CU 0x4000 /* cross-unit */ -#define FEF_DR 0x0080 /* diagnostic result */ -#define FEF_IMR 0x0008 /* internal maintenance release */ -#define FEF_PF 0x0002 /* power fail */ -#define FEF_REXMT 0x0001 /* retransmit */ -#define AEF_UD 0x0040 /* unrecoverable data */ -#define IEF_RRMASK 0xe000 /* request release bits */ -#define IEF_MD 0x0020 /* marginal data */ -#define IEF_RD 0x0010 /* recoverable data */ - -#define C_READ 0x00 -#define C_RAM 0x00 /* single vector (i.e. sector number) */ -#define C_WRITE 0x02 -#define C_CLEAR 0x08 -#define C_STATUS 0x0d -#define C_SADDR 0x10 -#define C_SLEN 0x18 -#define C_SUNIT(x) (0x20 | (x)) -#define C_SVOL(x) (0x40 | (x)) -#define C_NOP 0x34 -#define C_DESC 0x35 -#define C_SREL 0x3b -#define C_SSM 0x3e -#define C_SRAM 0x48 -#define C_REL 0xc0 - -#define C_CMD 0x05 -#define C_EXEC 0x0e -#define C_QSTAT 0x10 -#define C_TCMD 0x12 diff --git a/sys/arch/hp300/dev/rdvar.h b/sys/arch/hp300/dev/rdvar.h deleted file mode 100644 index 04fd3adeb5f..00000000000 --- a/sys/arch/hp300/dev/rdvar.h +++ /dev/null @@ -1,106 +0,0 @@ -/* $OpenBSD: rdvar.h,v 1.6 1997/02/03 04:47:43 downsj Exp $ */ -/* $NetBSD: rdvar.h,v 1.6 1997/01/30 09:14:19 thorpej Exp $ */ - -/* - * 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 - * 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. - * - * from: Utah $Hdr: rdvar.h 1.1 92/12/21$ - * - * @(#)rdvar.h 8.1 (Berkeley) 6/10/93 - */ - -struct rdidentinfo { - short ri_hwid; /* 2 byte HW id */ - short ri_maxunum; /* maximum allowed unit number */ - char *ri_desc; /* drive type description */ - int ri_nbpt; /* DEV_BSIZE blocks per track */ - int ri_ntpc; /* tracks per cylinder */ - int ri_ncyl; /* cylinders per unit */ - int ri_nblocks; /* DEV_BSIZE blocks on disk */ -}; - -struct rdstats { - long rdretries; - long rdresets; - long rdtimeouts; - long rdpolltries; - long rdpollwaits; -}; - -struct rd_softc { - struct device sc_dev; - struct disk sc_dkdev; - int sc_slave; /* HP-IB slave */ - int sc_punit; /* physical unit on slave */ - int sc_flags; - short sc_type; - char *sc_addr; - int sc_resid; - struct rd_describe sc_rddesc; - struct hpibqueue sc_hq; /* hpib job queue entry */ - struct rd_iocmd sc_ioc; - struct rd_rscmd sc_rsc; - struct rd_stat sc_stat; - struct rd_ssmcmd sc_ssmc; - struct rd_srcmd sc_src; - struct rd_clearcmd sc_clear; - struct buf sc_tab; /* buffer queue */ - struct rdstats sc_stats; -}; - -/* sc_flags values */ -#define RDF_ALIVE 0x01 -#define RDF_SEEK 0x02 -#define RDF_SWAIT 0x04 -#define RDF_OPENING 0x08 -#define RDF_CLOSING 0x10 -#define RDF_WANTED 0x20 -#define RDF_WLABEL 0x40 - -#define rdunit(x) (minor(x) >> 3) -#define rdpart(x) (minor(x) & 0x7) -#define rdpunit(x) ((x) & 7) -#define rdlabdev(d) (dev_t)(((int)(d)&~7)|2) /* rd?c */ - -#define b_cylin b_resid - -#define RDRETRY 5 -#define RDWAITC 1 /* min time for timeout in seconds */ - -#ifdef _KERNEL -extern struct rdidentinfo rdidentinfo[]; -#endif diff --git a/sys/arch/hp300/hp300/autoconf.c b/sys/arch/hp300/hp300/autoconf.c index 0e3428160e8..888dd232af9 100644 --- a/sys/arch/hp300/hp300/autoconf.c +++ b/sys/arch/hp300/hp300/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.10 1997/02/03 04:47:54 downsj Exp $ */ +/* $OpenBSD: autoconf.c,v 1.11 1997/02/03 08:11:59 downsj Exp $ */ /* $NetBSD: autoconf.c,v 1.31 1997/01/31 01:49:41 thorpej Exp $ */ /* @@ -355,7 +355,7 @@ device_register(dev, aux) goto linkup; } - if (bcmp(dev->dv_xname, "rd", 2) == 0) { + if (bcmp(dev->dv_xname, "hd", 2) == 0) { struct hpibbus_attach_args *ha = aux; dd->dd_slave = ha->ha_slave; @@ -421,7 +421,7 @@ struct nam2blk { int maj; } nam2blk[] = { { "ct", 0 }, - { "rd", 2 }, + { "hd", 2 }, { "sd", 4 }, }; @@ -838,7 +838,7 @@ findbootdev() punit = B_UNIT(bootdev); scsiboot = (type == 4); /* sd major */ - hpibboot = (type == 0 || type == 2); /* ct/rd major */ + hpibboot = (type == 0 || type == 2); /* ct/hd major */ netboot = (type == 6); /* le - special */ /* @@ -877,7 +877,7 @@ findbootdev() * Sanity check. */ if ((type == 0 && bcmp(booted_device->dv_xname, "ct", 2)) || - (type == 2 && bcmp(booted_device->dv_xname, "rd", 2))) { + (type == 2 && bcmp(booted_device->dv_xname, "hd", 2))) { printf("WARNING: boot device/type mismatch!\n"); printf("device = %s, type = %d\n", booted_device->dv_xname, type); @@ -950,7 +950,7 @@ findbootdev_slave(ddlist, ctlr, slave, punit) continue; } else { /* - * "rd" -> "hpibbus" -> "fhpib" + * "hd" -> "hpibbus" -> "fhpib" */ if (dd->dd_dev->dv_parent->dv_parent != cdd->dd_dev) continue; @@ -977,7 +977,7 @@ setbootdev() * Note our magic numbers for type: * * 0 == ct - * 2 == rd + * 2 == hd * 4 == sd * 6 == le * @@ -1006,7 +1006,7 @@ setbootdev() /* * Determine device type. */ - if (bcmp(root_device->dv_xname, "rd", 2) == 0) + if (bcmp(root_device->dv_xname, "hd", 2) == 0) type = 2; else if (bcmp(root_device->dv_xname, "sd", 2) == 0) type = 4; @@ -1022,7 +1022,7 @@ setbootdev() switch (type) { case 2: /* - * "rd" -> "hpibbus" -> "fhpib" + * "hd" -> "hpibbus" -> "fhpib" */ for (cdd = dev_data_list_hpib.lh_first, ctlr = 0; cdd != NULL; cdd = cdd->dd_clist.le_next, ctlr++) { diff --git a/sys/arch/hp300/hp300/conf.c b/sys/arch/hp300/hp300/conf.c index 124dc52e997..52d17b69d9a 100644 --- a/sys/arch/hp300/hp300/conf.c +++ b/sys/arch/hp300/hp300/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.11 1997/02/03 04:47:55 downsj Exp $ */ +/* $OpenBSD: conf.c,v 1.12 1997/02/03 08:12:00 downsj Exp $ */ /* $NetBSD: conf.c,v 1.34 1996/12/17 08:41:20 thorpej Exp $ */ /*- @@ -48,8 +48,8 @@ bdev_decl(ct); #include "mt.h" bdev_decl(mt); -#include "rd.h" -bdev_decl(rd); +#include "hd.h" +bdev_decl(hd); bdev_decl(sw); #include "sd.h" bdev_decl(sd); @@ -64,7 +64,7 @@ struct bdevsw bdevsw[] = { bdev_tape_init(NCT,ct), /* 0: cs80 cartridge tape */ bdev_tape_init(NMT,mt), /* 1: magnetic reel tape */ - bdev_disk_init(NRD,rd), /* 2: HPIB disk */ + bdev_disk_init(NHD,hd), /* 2: HPIB disk */ bdev_swap_init(1,sw), /* 3: swap pseudo-device */ bdev_disk_init(NSD,sd), /* 4: SCSI disk */ bdev_disk_init(NCCD,ccd), /* 5: concatenated disk driver */ @@ -115,7 +115,7 @@ cdev_decl(ptc); cdev_decl(log); cdev_decl(ct); cdev_decl(sd); -cdev_decl(rd); +cdev_decl(hd); #include "grf.h" cdev_decl(grf); #include "ppi.h" @@ -158,7 +158,7 @@ struct cdevsw cdevsw[] = cdev_log_init(1,log), /* 6: /dev/klog */ cdev_tape_init(NCT,ct), /* 7: cs80 cartridge tape */ cdev_disk_init(NSD,sd), /* 8: SCSI disk */ - cdev_disk_init(NRD,rd), /* 9: HPIB disk */ + cdev_disk_init(NHD,hd), /* 9: HPIB disk */ cdev_grf_init(NGRF,grf), /* 10: frame buffer */ cdev_ppi_init(NPPI,ppi), /* 11: printer/plotter interface */ cdev_tty_init(NDCA,dca), /* 12: built-in single-port serial */