diff options
| author | ad <ad@NetBSD.org> | 2000-11-26 17:44:02 +0000 |
|---|---|---|
| committer | ad <ad@NetBSD.org> | 2000-11-26 17:44:02 +0000 |
| commit | 57ea462da279b70d74164e94ef3b9ea1be1c7a4e (patch) | |
| tree | f89f4a0e43c535b743f91f89d7cbc6bb1e9b5317 /sys/dev | |
| parent | ee170a55280704e4079bf767997565dce90ec83b (diff) | |
lsu -> ld, by popular request.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/DEVNAMES | 4 | ||||
| -rw-r--r-- | sys/dev/i2o/files.i2o | 6 | ||||
| -rw-r--r-- | sys/dev/i2o/ld_iop.c | 470 | ||||
| -rw-r--r-- | sys/dev/ic/ld_cac.c (renamed from sys/dev/ic/lsu_cac.c) | 86 | ||||
| -rw-r--r-- | sys/dev/ld.c (renamed from sys/dev/lsu.c) | 172 | ||||
| -rw-r--r-- | sys/dev/ldvar.h | 77 | ||||
| -rw-r--r-- | sys/dev/pci/files.pci | 6 | ||||
| -rw-r--r-- | sys/dev/pci/ld_twe.c (renamed from sys/dev/pci/lsu_twe.c) | 104 |
8 files changed, 736 insertions, 189 deletions
diff --git a/sys/dev/DEVNAMES b/sys/dev/DEVNAMES index 37f4b3978d6..a16890d3193 100644 --- a/sys/dev/DEVNAMES +++ b/sys/dev/DEVNAMES @@ -1,4 +1,4 @@ -# $NetBSD: DEVNAMES,v 1.21 2000/11/20 19:27:16 jdolecek Exp $ +# $NetBSD: DEVNAMES,v 1.22 2000/11/26 17:44:04 ad Exp $ # # This file contains all used device names and defined attributes in # alphabetical order. New devices added to the system somewhere should first @@ -492,6 +492,7 @@ kft alpha kue MI lc MI lca alpha +ld MI le MI le24 MI Attribute le32 MI Attribute @@ -517,7 +518,6 @@ lpt pc532 lpt sgimips lpt sparc64 lsi64854 MI Attribute -lsu MI lxtphy MI m38813c hpcmips mace sgimips diff --git a/sys/dev/i2o/files.i2o b/sys/dev/i2o/files.i2o index c2b63e646bc..0b230d98726 100644 --- a/sys/dev/i2o/files.i2o +++ b/sys/dev/i2o/files.i2o @@ -1,12 +1,12 @@ -# $NetBSD: files.i2o,v 1.1 2000/11/08 19:45:31 ad Exp $ +# $NetBSD: files.i2o,v 1.2 2000/11/26 17:44:05 ad Exp $ defopt opt_i2o.h I2OVERBOSE I2ODEBUG device iop {tid = -1} file dev/i2o/iop.c iop needs-flag -attach lsu at iop with lsu_iop -file dev/i2o/lsu_iop.c lsu_iop +attach ld at iop with ld_iop +file dev/i2o/ld_iop.c ld_iop device iopsp: scsi attach iopsp at iop diff --git a/sys/dev/i2o/ld_iop.c b/sys/dev/i2o/ld_iop.c new file mode 100644 index 00000000000..889ec3dd0b9 --- /dev/null +++ b/sys/dev/i2o/ld_iop.c @@ -0,0 +1,470 @@ +/* $NetBSD: ld_iop.c,v 1.1 2000/11/26 17:44:05 ad Exp $ */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * I2O front-end for ld(4) driver, supporting random block storage class + * devices. Currently, this doesn't support anything more complex than + * fixed, direct access devices; hopefully, scsipi can take care of the + * rest. + */ + +#include "opt_i2o.h" +#include "rnd.h" + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/device.h> +#include <sys/buf.h> +#include <sys/endian.h> +#include <sys/dkio.h> +#include <sys/disk.h> +#include <sys/proc.h> +#if NRND > 0 +#include <sys/rnd.h> +#endif + +#include <machine/bus.h> + +#include <dev/ldvar.h> + +#include <dev/i2o/i2o.h> +#include <dev/i2o/iopvar.h> + +#define LD_IOP_MAXQUEUECNT 64 /* XXX */ + +struct ld_iop_softc { + struct ld_softc sc_ld; + struct iop_initiator sc_ii; + u_int sc_tid; +}; + +static void ld_iop_attach(struct device *, struct device *, void *); +static int ld_iop_dump(struct ld_softc *, void *, int, int); +static int ld_iop_flush(struct ld_softc *); +static void ld_iop_intr(struct device *, struct iop_msg *, void *); +static int ld_iop_start(struct ld_softc *, struct buf *); +static int ld_iop_match(struct device *, struct cfdata *, void *); + +struct cfattach ld_iop_ca = { + sizeof(struct ld_iop_softc), ld_iop_match, ld_iop_attach +}; + +#ifdef I2OVERBOSE +static const char *ld_iop_errors[] = { + "success", + "media error", + "failure communicating with device", + "device failure", + "device is not ready", + "media not present", + "media locked by another user", + "media failure", + "failure communicating to device", + "device bus failure", + "device locked by another user", + "device write protected", + "device reset", + "volume has changed, waiting for acknowledgement", +}; +#endif + +static int +ld_iop_match(struct device *parent, struct cfdata *match, void *aux) +{ + struct iop_attach_args *ia; + struct { + struct i2o_param_op_results pr; + struct i2o_param_read_results prr; + struct i2o_param_rbs_device_info bdi; + } param; + u_int32_t caps; + + ia = aux; + + if (ia->ia_class != I2O_CLASS_RANDOM_BLOCK_STORAGE) + return (0); + + if (iop_params_get((struct iop_softc *)parent, ia->ia_tid, + I2O_PARAM_RBS_DEVICE_INFO, ¶m, sizeof(param)) != 0) + return (0); + + caps = le32toh(param.bdi.capabilities); + + if (param.bdi.type != I2O_RBS_TYPE_DIRECT || + (caps & I2O_RBS_CAP_REMOVEABLE_MEDIA) != 0 || + (caps & I2O_RBS_CAP_REMOVEABLE_DEVICE) != 0) + return (0); + + /* + * Mark the physical device(s) that comprise(s) the block storage + * unit as being `in use'. + */ + iop_tid_markallused((struct iop_softc *)parent, ia->ia_tid); + return (1); +} + +static void +ld_iop_attach(struct device *parent, struct device *self, void *aux) +{ + struct iop_attach_args *ia; + struct ld_softc *ld; + struct ld_iop_softc *sc; + struct iop_softc *iop; + int rv; + char ident[64 + 1]; + u_int cachesz; + struct { + struct i2o_param_op_results pr; + struct i2o_param_read_results prr; + union { + struct i2o_param_rbs_cache_control cc; + struct i2o_param_rbs_device_info bdi; + struct i2o_param_device_identity di; + } p; + } param; + + sc = (struct ld_iop_softc *)self; + ld = &sc->sc_ld; + iop = (struct iop_softc *)parent; + ia = (struct iop_attach_args *)aux; + sc->sc_tid = ia->ia_tid; + + /* Register us as an initiator. */ + sc->sc_ii.ii_dv = self; + sc->sc_ii.ii_intr = ld_iop_intr; + sc->sc_ii.ii_flags = 0; + if (iop_initiator_register(iop, &sc->sc_ii) != 0) { + printf("%s: unable to register as an initiator\n", + self->dv_xname); + return; + } + + ld->sc_maxxfer = IOP_MAX_XFER; + ld->sc_maxqueuecnt = LD_IOP_MAXQUEUECNT; + ld->sc_dump = ld_iop_dump; + ld->sc_flush = ld_iop_flush; + ld->sc_start = ld_iop_start; + + /* Say what the device is. */ + printf(": "); + if (iop_params_get(iop, ia->ia_tid, I2O_PARAM_DEVICE_IDENTITY, ¶m, + sizeof(param)) == 0) { + iop_strvis(param.p.di.vendorinfo, + sizeof(param.p.di.vendorinfo), ident, sizeof(ident)); + printf("<%s, ", ident); + iop_strvis(param.p.di.productinfo, + sizeof(param.p.di.productinfo), ident, sizeof(ident)); + printf("%s, ", ident); + iop_strvis(param.p.di.revlevel, + sizeof(param.p.di.revlevel), ident, sizeof(ident)); + printf("%s> ", ident); + } + + /* Claim the device so that we don't get any nasty surprises. */ + rv = iop_tid_claim(iop, ia->ia_tid, sc->sc_ii.ii_ictx, + I2O_UTIL_CLAIM_RESET_SENSITIVE | + I2O_UTIL_CLAIM_STATE_SENSITIVE | + I2O_UTIL_CLAIM_CAPACITY_SENSITIVE | + I2O_UTIL_CLAIM_NO_PEER_SERVICE | + I2O_UTIL_CLAIM_NO_MANAGEMENT_SERVICE | + I2O_UTIL_CLAIM_PRIMARY_USER); + if (rv != 0) { + printf("%s: unable to claim device (%d)\n", + ld->sc_dv.dv_xname, rv); + goto bad; + } + + rv = iop_params_get(iop, ia->ia_tid, I2O_PARAM_RBS_DEVICE_INFO, ¶m, + sizeof(param)); + if (rv != 0) { + printf("%s: unable to retrieve device parameters (%d)\n", + ld->sc_dv.dv_xname, rv); + goto bad; + } + + ld->sc_secsize = le32toh(param.p.bdi.blocksize); + ld->sc_secperunit = (int) + (le64toh(param.p.bdi.capacity) / ld->sc_secsize); + + /* Build synthetic geometry. */ + if (ld->sc_secperunit <= 528 * 2048) /* 528MB */ + ld->sc_nheads = 16; + else if (ld->sc_secperunit <= 1024 * 2048) /* 1GB */ + ld->sc_nheads = 32; + else if (ld->sc_secperunit <= 21504 * 2048) /* 21GB */ + ld->sc_nheads = 64; + else if (ld->sc_secperunit <= 43008 * 2048) /* 42GB */ + ld->sc_nheads = 128; + else + ld->sc_nheads = 255; + + ld->sc_nsectors = 63; + ld->sc_ncylinders = ld->sc_secperunit / + (ld->sc_nheads * ld->sc_nsectors); + +#ifdef notyet + switch (param.p.bdi.type) { + case I2O_RBS_TYPE_DIRECT: + typestr = "direct access"; + break; + case I2O_RBS_TYPE_WORM: + typestr = "WORM"; + break; + case I2O_RBS_TYPE_CDROM: + typestr = "cdrom"; + break; + case I2O_RBS_TYPE_OPTICAL: + typestr = "optical"; + break; + default: + typestr = "unknown"; + break; + } + + if ((le32toh(param.p.bdi.capabilities) & I2O_RBS_CAP_REMOVEABLE_MEDIA) + != 0) { + ld->sc_flags = LDF_ENABLED | LDF_REMOVEABLE; + fixedstr = "removeable"; + } else { + ld->sc_flags = LDF_ENABLED; + fixedstr = "fixed"; + } +#endif + printf("direct access, fixed"); + + /* + * Determine if the device has an private cache. If so, print the + * cache size. Even if the device doesn't appear to have a cache, + * we perform a flush at shutdown, as it is still valid to do so. + */ + rv = iop_params_get(iop, ia->ia_tid, I2O_PARAM_RBS_CACHE_CONTROL, + ¶m, sizeof(param)); + if (rv != 0) { + printf("%s: unable to retrieve cache parameters (%d)\n", + ld->sc_dv.dv_xname, rv); + goto bad; + } + + if ((cachesz = le32toh(param.p.cc.totalcachesize)) != 0) + printf(", %dkB cache", cachesz >> 10); + + printf("\n"); + ld->sc_flags = LDF_ENABLED; + ldattach(ld); + return; + +bad: + iop_initiator_unregister(iop, &sc->sc_ii); +} + +static int +ld_iop_start(struct ld_softc *ld, struct buf *bp) +{ + struct iop_msg *im; + struct iop_softc *iop; + struct ld_iop_softc *sc; + struct i2o_rbs_block_read *mb; + int rv, flags, write; + u_int64_t ba; + + sc = (struct ld_iop_softc *)ld; + iop = (struct iop_softc *)ld->sc_dv.dv_parent; + + im = NULL; + if ((rv = iop_msg_alloc(iop, &sc->sc_ii, &im, IM_NOWAIT)) != 0) + goto bad; + im->im_dvcontext = bp; + + write = ((bp->b_flags & B_READ) == 0); + ba = (u_int64_t)bp->b_rawblkno * ld->sc_secsize; + + if (write) { + if (bp == NULL || (bp->b_flags & B_ASYNC) == 0) + flags = I2O_RBS_BLOCK_WRITE_CACHE_WT; + else + flags = I2O_RBS_BLOCK_WRITE_CACHE_WB; + } + + /* + * Fill the message frame. We can use the block_read structure for + * both reads and writes, as it's almost identical to the + * block_write structure. + * + * XXX We should be using the command time out facilities. + */ + mb = (struct i2o_rbs_block_read *)im->im_msg; + mb->msgflags = I2O_MSGFLAGS(i2o_rbs_block_read); + mb->msgfunc = I2O_MSGFUNC(sc->sc_tid, + write ? I2O_RBS_BLOCK_WRITE : I2O_RBS_BLOCK_READ); + mb->msgictx = sc->sc_ii.ii_ictx; + mb->msgtctx = im->im_tctx; + mb->flags = flags; + mb->datasize = bp->b_bcount; + mb->lowoffset = (u_int32_t)ba; + mb->highoffset = (u_int32_t)(ba >> 32); + + /* Map the data transfer. */ + if ((rv = iop_msg_map(iop, im, bp->b_data, bp->b_bcount, write)) != 0) + goto bad; + + /* Enqueue the command. */ + if ((rv = iop_msg_enqueue(iop, im)) != 0) { + iop_msg_unmap(iop, im); + goto bad; + } + + return (0); + +bad: + if (im != NULL) + iop_msg_free(iop, &sc->sc_ii, im); + return (rv); +} + +static int +ld_iop_dump(struct ld_softc *ld, void *data, int blkno, int blkcnt) +{ + struct iop_msg *im; + struct iop_softc *iop; + struct ld_iop_softc *sc; + struct i2o_rbs_block_write *mb; + int rv, bcount; + u_int64_t ba; + + sc = (struct ld_iop_softc *)ld; + iop = (struct iop_softc *)ld->sc_dv.dv_parent; + bcount = blkcnt * ld->sc_secsize; + ba = (u_int64_t)blkno * ld->sc_secsize; + + rv = iop_msg_alloc(iop, &sc->sc_ii, &im, IM_NOWAIT | IM_NOINTR); + if (rv != 0) + return (rv); + + mb = (struct i2o_rbs_block_write *)im->im_msg; + mb->msgflags = I2O_MSGFLAGS(i2o_rbs_block_write); + mb->msgfunc = I2O_MSGFUNC(sc->sc_tid, I2O_RBS_BLOCK_WRITE); + mb->msgictx = sc->sc_ii.ii_ictx; + mb->msgtctx = im->im_tctx; + mb->flags = I2O_RBS_BLOCK_WRITE_CACHE_WT; + mb->datasize = bcount; + mb->lowoffset = (u_int32_t)ba; + mb->highoffset = (u_int32_t)(ba >> 32); + + if ((rv = iop_msg_map(iop, im, data, bcount, 1)) != 0) { + iop_msg_free(iop, &sc->sc_ii, im); + return (rv); + } + + rv = iop_msg_send(iop, im, 5000) != 0 ? EIO : 0; + iop_msg_unmap(iop, im); + iop_msg_free(iop, &sc->sc_ii, im); + return (rv); +} + +static int +ld_iop_flush(struct ld_softc *ld) +{ + struct iop_msg *im; + struct iop_softc *iop; + struct ld_iop_softc *sc; + struct i2o_rbs_cache_flush *mb; + int rv; + + sc = (struct ld_iop_softc *)ld; + iop = (struct iop_softc *)ld->sc_dv.dv_parent; + + rv = iop_msg_alloc(iop, &sc->sc_ii, &im, IM_NOWAIT | IM_NOINTR); + if (rv != 0) + return (rv); + + mb = (struct i2o_rbs_cache_flush *)im->im_msg; + mb->msgflags = I2O_MSGFLAGS(i2o_rbs_cache_flush); + mb->msgfunc = I2O_MSGFUNC(sc->sc_tid, I2O_RBS_CACHE_FLUSH); + mb->msgictx = sc->sc_ii.ii_ictx; + mb->msgtctx = im->im_tctx; + mb->flags = 0; + + rv = iop_msg_send(iop, im, 10000); + iop_msg_free(iop, &sc->sc_ii, im); + return (rv); +} + +void +ld_iop_intr(struct device *dv, struct iop_msg *im, void *reply) +{ + struct i2o_rbs_reply *rb; + struct buf *bp; + struct ld_iop_softc *sc; + struct iop_softc *iop; +#ifdef I2OVERBOSE + int detail; + const char *errstr; +#endif + + rb = reply; + bp = im->im_dvcontext; + sc = (struct ld_iop_softc *)dv; + iop = (struct iop_softc *)dv->dv_parent; + +#ifdef I2OVERBOSE + if (rb->reqstatus != I2O_STATUS_SUCCESS) { + detail = le16toh(rb->detail); + if (detail > sizeof(ld_iop_errors) / sizeof(ld_iop_errors[0])) + errstr = "unknown error"; + else + errstr = ld_iop_errors[detail]; + printf("%s: %s\n", dv->dv_xname, errstr); +#else + if (rb->reqstatus != I2O_STATUS_SUCCESS) { +#endif + bp->b_flags |= B_ERROR; + bp->b_error = EIO; +#ifndef notyet + bp->b_resid = bp->b_bcount; + } else + bp->b_resid = 0; +#else + } + bp->b_resid = bp->b_bcount - le32toh(rb->transfercount); +#endif + + iop_msg_unmap(iop, im); + iop_msg_free(iop, &sc->sc_ii, im); + lddone(&sc->sc_ld, bp); +} diff --git a/sys/dev/ic/lsu_cac.c b/sys/dev/ic/ld_cac.c index f8b5f064334..7aad9dc21fa 100644 --- a/sys/dev/ic/lsu_cac.c +++ b/sys/dev/ic/ld_cac.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $NetBSD: ld_cac.c,v 1.1 2000/11/26 17:44:05 ad Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ /* - * Compaq array controller front-end for lsu(4) driver. + * Compaq array controller front-end for ld(4) driver. */ #include "rnd.h" @@ -56,45 +56,45 @@ #include <machine/bus.h> -#include <dev/lsuvar.h> +#include <dev/ldvar.h> #include <dev/ic/cacreg.h> #include <dev/ic/cacvar.h> -struct lsu_cac_softc { - struct lsu_softc sc_lsu; +struct ld_cac_softc { + struct ld_softc sc_ld; int sc_hwunit; }; -static void lsu_cac_attach(struct device *, struct device *, void *); -static void lsu_cac_done(struct device *, void *, int); -static int lsu_cac_dump(struct lsu_softc *, void *, int, int); -static int lsu_cac_match(struct device *, struct cfdata *, void *); -static int lsu_cac_start(struct lsu_softc *, struct buf *); +static void ld_cac_attach(struct device *, struct device *, void *); +static void ld_cac_done(struct device *, void *, int); +static int ld_cac_dump(struct ld_softc *, void *, int, int); +static int ld_cac_match(struct device *, struct cfdata *, void *); +static int ld_cac_start(struct ld_softc *, struct buf *); -struct cfattach lsu_cac_ca = { - sizeof(struct lsu_cac_softc), lsu_cac_match, lsu_cac_attach +struct cfattach ld_cac_ca = { + sizeof(struct ld_cac_softc), ld_cac_match, ld_cac_attach }; static int -lsu_cac_match(struct device *parent, struct cfdata *match, void *aux) +ld_cac_match(struct device *parent, struct cfdata *match, void *aux) { return (1); } static void -lsu_cac_attach(struct device *parent, struct device *self, void *aux) +ld_cac_attach(struct device *parent, struct device *self, void *aux) { struct cac_drive_info dinfo; struct cac_attach_args *caca; - struct lsu_softc *lsu; - struct lsu_cac_softc *sc; + struct ld_softc *ld; + struct ld_cac_softc *sc; struct cac_softc *cac; const char *type; - sc = (struct lsu_cac_softc *)self; - lsu = &sc->sc_lsu; + sc = (struct ld_cac_softc *)self; + ld = &sc->sc_ld; caca = (struct cac_attach_args *)aux; sc->sc_hwunit = caca->caca_unit; cac = (struct cac_softc *)parent; @@ -105,16 +105,16 @@ lsu_cac_attach(struct device *parent, struct device *self, void *aux) return; } - lsu->sc_ncylinders = CAC_GET2(dinfo.ncylinders); - lsu->sc_nheads = CAC_GET1(dinfo.nheads); - lsu->sc_nsectors = CAC_GET1(dinfo.nsectors); - lsu->sc_secsize = CAC_GET2(dinfo.secsize); - lsu->sc_maxxfer = CAC_MAX_XFER; - lsu->sc_maxqueuecnt = CAC_MAX_CCBS / cac->sc_nunits; /* XXX */ - lsu->sc_secperunit = lsu->sc_ncylinders * lsu->sc_nheads * - lsu->sc_nsectors; - lsu->sc_start = lsu_cac_start; - lsu->sc_dump = lsu_cac_dump; + ld->sc_ncylinders = CAC_GET2(dinfo.ncylinders); + ld->sc_nheads = CAC_GET1(dinfo.nheads); + ld->sc_nsectors = CAC_GET1(dinfo.nsectors); + ld->sc_secsize = CAC_GET2(dinfo.secsize); + ld->sc_maxxfer = CAC_MAX_XFER; + ld->sc_maxqueuecnt = CAC_MAX_CCBS / cac->sc_nunits; /* XXX */ + ld->sc_secperunit = ld->sc_ncylinders * ld->sc_nheads * + ld->sc_nsectors; + ld->sc_start = ld_cac_start; + ld->sc_dump = ld_cac_dump; switch (CAC_GET1(dinfo.mirror)) { case 0: @@ -137,24 +137,24 @@ lsu_cac_attach(struct device *parent, struct device *self, void *aux) printf(": %s array\n", type); /* XXX We should verify this... */ - lsu->sc_flags = LSUF_ENABLED; - lsuattach(lsu); + ld->sc_flags = LDF_ENABLED; + ldattach(ld); } static int -lsu_cac_start(struct lsu_softc *lsu, struct buf *bp) +ld_cac_start(struct ld_softc *ld, struct buf *bp) { int flags, cmd; struct cac_softc *cac; - struct lsu_cac_softc *sc; + struct ld_cac_softc *sc; struct cac_context cc; - sc = (struct lsu_cac_softc *)lsu; - cac = (struct cac_softc *)lsu->sc_dv.dv_parent; + sc = (struct ld_cac_softc *)ld; + cac = (struct cac_softc *)ld->sc_dv.dv_parent; - cc.cc_handler = lsu_cac_done; + cc.cc_handler = ld_cac_done; cc.cc_context = bp; - cc.cc_dv = &lsu->sc_dv; + cc.cc_dv = &ld->sc_dv; if ((bp->b_flags & B_READ) == 0) { cmd = CAC_CMD_WRITE; @@ -169,19 +169,19 @@ lsu_cac_start(struct lsu_softc *lsu, struct buf *bp) } static int -lsu_cac_dump(struct lsu_softc *lsu, void *data, int blkno, int blkcnt) +ld_cac_dump(struct ld_softc *ld, void *data, int blkno, int blkcnt) { - struct lsu_cac_softc *sc; + struct ld_cac_softc *sc; - sc = (struct lsu_cac_softc *)lsu; + sc = (struct ld_cac_softc *)ld; - return (cac_cmd((struct cac_softc *)lsu->sc_dv.dv_parent, - CAC_CMD_WRITE_MEDIA, data, blkcnt * lsu->sc_secsize, + return (cac_cmd((struct cac_softc *)ld->sc_dv.dv_parent, + CAC_CMD_WRITE_MEDIA, data, blkcnt * ld->sc_secsize, sc->sc_hwunit, blkno, CAC_CCB_DATA_OUT, NULL)); } static void -lsu_cac_done(struct device *dv, void *context, int error) +ld_cac_done(struct device *dv, void *context, int error) { struct buf *bp; @@ -194,5 +194,5 @@ lsu_cac_done(struct device *dv, void *context, int error) } else bp->b_resid = 0; - lsudone((struct lsu_softc *)dv, bp); + lddone((struct ld_softc *)dv, bp); } diff --git a/sys/dev/lsu.c b/sys/dev/ld.c index 810f8e12d0e..ad5d8f9cdc4 100644 --- a/sys/dev/lsu.c +++ b/sys/dev/ld.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $NetBSD: ld.c,v 1.1 2000/11/26 17:44:04 ad Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -62,32 +62,32 @@ #include <sys/rnd.h> #endif -#include <dev/lsuvar.h> +#include <dev/ldvar.h> -static void lsugetdefaultlabel(struct lsu_softc *, struct disklabel *); -static void lsugetdisklabel(struct lsu_softc *); -static int lsulock(struct lsu_softc *); -static void lsuminphys(struct buf *bp); -static void lsushutdown(void *); -static int lsustart(struct lsu_softc *, struct buf *); -static void lsuunlock(struct lsu_softc *); +static void ldgetdefaultlabel(struct ld_softc *, struct disklabel *); +static void ldgetdisklabel(struct ld_softc *); +static int ldlock(struct ld_softc *); +static void ldminphys(struct buf *bp); +static void ldshutdown(void *); +static int ldstart(struct ld_softc *, struct buf *); +static void ldunlock(struct ld_softc *); -extern struct cfdriver lsu_cd; +extern struct cfdriver ld_cd; -static struct dkdriver lsudkdriver = { lsustrategy }; -static void *lsu_sdh; +static struct dkdriver lddkdriver = { ldstrategy }; +static void *ld_sdh; void -lsuattach(struct lsu_softc *sc) +ldattach(struct ld_softc *sc) { char buf[9]; /* Initialise and attach the disk structure. */ - sc->sc_dk.dk_driver = &lsudkdriver; + sc->sc_dk.dk_driver = &lddkdriver; sc->sc_dk.dk_name = sc->sc_dv.dv_xname; disk_attach(&sc->sc_dk); - if ((sc->sc_flags & LSUF_ENABLED) == 0) { + if ((sc->sc_flags & LDF_ENABLED) == 0) { printf("%s: disabled\n", sc->sc_dv.dv_xname); return; } @@ -107,19 +107,19 @@ lsuattach(struct lsu_softc *sc) #endif /* Set the `shutdownhook'. */ - if (lsu_sdh == NULL) - lsu_sdh = shutdownhook_establish(lsushutdown, NULL); + if (ld_sdh == NULL) + ld_sdh = shutdownhook_establish(ldshutdown, NULL); BUFQ_INIT(&sc->sc_bufq); } static void -lsushutdown(void *cookie) +ldshutdown(void *cookie) { - struct lsu_softc *sc; + struct ld_softc *sc; int i; - for (i = 0; i < lsu_cd.cd_ndevs; i++) { - if ((sc = device_lookup(&lsu_cd, i)) == NULL) + for (i = 0; i < ld_cd.cd_ndevs; i++) { + if ((sc = device_lookup(&ld_cd, i)) == NULL) continue; if (sc->sc_flush != NULL && (*sc->sc_flush)(sc) != 0) printf("%s: unable to flush cache\n", @@ -128,26 +128,26 @@ lsushutdown(void *cookie) } int -lsuopen(dev_t dev, int flags, int fmt, struct proc *p) +ldopen(dev_t dev, int flags, int fmt, struct proc *p) { - struct lsu_softc *sc; + struct ld_softc *sc; int unit, part; unit = DISKUNIT(dev); - if ((sc = device_lookup(&lsu_cd, unit))== NULL) + if ((sc = device_lookup(&ld_cd, unit))== NULL) return (ENXIO); - if ((sc->sc_flags & LSUF_ENABLED) == 0) + if ((sc->sc_flags & LDF_ENABLED) == 0) return (ENODEV); part = DISKPART(dev); - lsulock(sc); + ldlock(sc); if (sc->sc_dk.dk_openmask == 0) - lsugetdisklabel(sc); + ldgetdisklabel(sc); /* Check that the partition exists. */ if (part != RAW_PART && (part >= sc->sc_dk.dk_label->d_npartitions || sc->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) { - lsuunlock(sc); + ldunlock(sc); return (ENXIO); } @@ -163,20 +163,20 @@ lsuopen(dev_t dev, int flags, int fmt, struct proc *p) sc->sc_dk.dk_openmask = sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask; - lsuunlock(sc); + ldunlock(sc); return (0); } int -lsuclose(dev_t dev, int flags, int fmt, struct proc *p) +ldclose(dev_t dev, int flags, int fmt, struct proc *p) { - struct lsu_softc *sc; + struct ld_softc *sc; int part, unit; unit = DISKUNIT(dev); part = DISKPART(dev); - sc = device_lookup(&lsu_cd, unit); - lsulock(sc); + sc = device_lookup(&ld_cd, unit); + ldlock(sc); switch (fmt) { case S_IFCHR: @@ -194,33 +194,33 @@ lsuclose(dev_t dev, int flags, int fmt, struct proc *p) printf("%s: unable to flush cache\n", sc->sc_dv.dv_xname); - lsuunlock(sc); + ldunlock(sc); return (0); } int -lsuread(dev_t dev, struct uio *uio, int ioflag) +ldread(dev_t dev, struct uio *uio, int ioflag) { - return (physio(lsustrategy, NULL, dev, B_READ, lsuminphys, uio)); + return (physio(ldstrategy, NULL, dev, B_READ, ldminphys, uio)); } int -lsuwrite(dev_t dev, struct uio *uio, int ioflag) +ldwrite(dev_t dev, struct uio *uio, int ioflag) { - return (physio(lsustrategy, NULL, dev, B_WRITE, lsuminphys, uio)); + return (physio(ldstrategy, NULL, dev, B_WRITE, ldminphys, uio)); } int -lsuioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p) +ldioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p) { - struct lsu_softc *sc; + struct ld_softc *sc; int part, unit, error; unit = DISKUNIT(dev); part = DISKPART(dev); - sc = device_lookup(&lsu_cd, unit); + sc = device_lookup(&ld_cd, unit); error = 0; switch (cmd) { @@ -239,9 +239,9 @@ lsuioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p) if ((flag & FWRITE) == 0) return (EBADF); - if ((error = lsulock(sc)) != 0) + if ((error = ldlock(sc)) != 0) return (error); - sc->sc_flags |= LSUF_LABELLING; + sc->sc_flags |= LDF_LABELLING; error = setdisklabel(sc->sc_dk.dk_label, (struct disklabel *)addr, /*sc->sc_dk.dk_openmask : */0, @@ -249,24 +249,24 @@ lsuioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p) if (error == 0 && cmd == DIOCWDINFO) error = writedisklabel( MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART), - lsustrategy, sc->sc_dk.dk_label, + ldstrategy, sc->sc_dk.dk_label, sc->sc_dk.dk_cpulabel); - sc->sc_flags &= ~LSUF_LABELLING; - lsuunlock(sc); + sc->sc_flags &= ~LDF_LABELLING; + ldunlock(sc); break; case DIOCWLABEL: if ((flag & FWRITE) == 0) return (EBADF); if (*(int *)addr) - sc->sc_flags |= LSUF_WLABEL; + sc->sc_flags |= LDF_WLABEL; else - sc->sc_flags &= ~LSUF_WLABEL; + sc->sc_flags &= ~LDF_WLABEL; break; case DIOCGDEFLABEL: - lsugetdefaultlabel(sc, (struct disklabel *)addr); + ldgetdefaultlabel(sc, (struct disklabel *)addr); break; default: @@ -278,12 +278,12 @@ lsuioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p) } void -lsustrategy(struct buf *bp) +ldstrategy(struct buf *bp) { - struct lsu_softc *sc; + struct ld_softc *sc; int s; - sc = device_lookup(&lsu_cd, DISKUNIT(bp->b_dev)); + sc = device_lookup(&ld_cd, DISKUNIT(bp->b_dev)); s = splbio(); if (sc->sc_queuecnt == sc->sc_maxqueuecnt) { @@ -292,11 +292,11 @@ lsustrategy(struct buf *bp) return; } splx(s); - lsustart(sc, bp); + ldstart(sc, bp); } static int -lsustart(struct lsu_softc *sc, struct buf *bp) +ldstart(struct ld_softc *sc, struct buf *bp) { struct disklabel *lp; int part, s, rv; @@ -329,7 +329,7 @@ lsustart(struct lsu_softc *sc, struct buf *bp) */ if (part != RAW_PART && bounds_check_with_label(bp, lp, - (sc->sc_flags & (LSUF_WLABEL | LSUF_LABELLING)) != 0) <= 0) { + (sc->sc_flags & (LDF_WLABEL | LDF_LABELLING)) != 0) <= 0) { bp->b_resid = bp->b_bcount; biodone(bp); return (-1); @@ -357,7 +357,7 @@ lsustart(struct lsu_softc *sc, struct buf *bp) bp->b_flags |= B_ERROR; bp->b_resid = bp->b_bcount; s = splbio(); - lsudone(sc, bp); + lddone(sc, bp); splx(s); } @@ -365,11 +365,11 @@ lsustart(struct lsu_softc *sc, struct buf *bp) } void -lsudone(struct lsu_softc *sc, struct buf *bp) +lddone(struct ld_softc *sc, struct buf *bp) { if ((bp->b_flags & B_ERROR) != 0) { - diskerr(bp, "lsu", "error", LOG_PRINTF, 0, sc->sc_dk.dk_label); + diskerr(bp, "ld", "error", LOG_PRINTF, 0, sc->sc_dk.dk_label); printf("\n"); } @@ -382,34 +382,34 @@ lsudone(struct lsu_softc *sc, struct buf *bp) while ((bp = BUFQ_FIRST(&sc->sc_bufq)) != NULL) { BUFQ_REMOVE(&sc->sc_bufq, bp); - if (!lsustart(sc, bp)) + if (!ldstart(sc, bp)) break; } } int -lsusize(dev_t dev) +ldsize(dev_t dev) { - struct lsu_softc *sc; + struct ld_softc *sc; int part, unit, omask, size; unit = DISKUNIT(dev); - if ((sc = device_lookup(&lsu_cd, unit)) == NULL) + if ((sc = device_lookup(&ld_cd, unit)) == NULL) return (ENODEV); - if ((sc->sc_flags & LSUF_ENABLED) == 0) + if ((sc->sc_flags & LDF_ENABLED) == 0) return (ENODEV); part = DISKPART(dev); omask = sc->sc_dk.dk_openmask & (1 << part); - if (omask == 0 && lsuopen(dev, 0, S_IFBLK, NULL) != 0) + if (omask == 0 && ldopen(dev, 0, S_IFBLK, NULL) != 0) return (-1); else if (sc->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP) size = -1; else size = sc->sc_dk.dk_label->d_partitions[part].p_size * (sc->sc_dk.dk_label->d_secsize / DEV_BSIZE); - if (omask == 0 && lsuclose(dev, 0, S_IFBLK, NULL) != 0) + if (omask == 0 && ldclose(dev, 0, S_IFBLK, NULL) != 0) return (-1); return (size); @@ -419,15 +419,15 @@ lsusize(dev_t dev) * Load the label information from the specified device. */ static void -lsugetdisklabel(struct lsu_softc *sc) +ldgetdisklabel(struct ld_softc *sc) { const char *errstring; - lsugetdefaultlabel(sc, sc->sc_dk.dk_label); + ldgetdefaultlabel(sc, sc->sc_dk.dk_label); /* Call the generic disklabel extraction routine. */ errstring = readdisklabel(MAKEDISKDEV(0, sc->sc_dv.dv_unit, RAW_PART), - lsustrategy, sc->sc_dk.dk_label, sc->sc_dk.dk_cpulabel); + ldstrategy, sc->sc_dk.dk_label, sc->sc_dk.dk_cpulabel); if (errstring != NULL) printf("%s: %s\n", sc->sc_dv.dv_xname, errstring); } @@ -436,7 +436,7 @@ lsugetdisklabel(struct lsu_softc *sc) * Construct a ficticious label. */ static void -lsugetdefaultlabel(struct lsu_softc *sc, struct disklabel *lp) +ldgetdefaultlabel(struct ld_softc *sc, struct disklabel *lp) { memset(lp, 0, sizeof(struct disklabel)); @@ -446,7 +446,7 @@ lsugetdefaultlabel(struct lsu_softc *sc, struct disklabel *lp) lp->d_nsectors = sc->sc_nsectors; lp->d_ncylinders = sc->sc_ncylinders; lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors; - lp->d_type = DTYPE_LSU; + lp->d_type = DTYPE_LD; strcpy(lp->d_typename, "unknown"); strcpy(lp->d_packname, "fictitious"); lp->d_secperunit = sc->sc_secperunit; @@ -471,16 +471,16 @@ lsugetdefaultlabel(struct lsu_softc *sc, struct disklabel *lp) * XXX Several drivers do this; it should be abstracted and made MP-safe. */ static int -lsulock(struct lsu_softc *sc) +ldlock(struct ld_softc *sc) { int error; - while ((sc->sc_flags & LSUF_LKHELD) != 0) { - sc->sc_flags |= LSUF_LKWANTED; - if ((error = tsleep(sc, PRIBIO | PCATCH, "lsulck", 0)) != 0) + while ((sc->sc_flags & LDF_LKHELD) != 0) { + sc->sc_flags |= LDF_LKWANTED; + if ((error = tsleep(sc, PRIBIO | PCATCH, "ldlck", 0)) != 0) return (error); } - sc->sc_flags |= LSUF_LKHELD; + sc->sc_flags |= LDF_LKHELD; return (0); } @@ -488,12 +488,12 @@ lsulock(struct lsu_softc *sc) * Unlock and wake up any waiters. */ static void -lsuunlock(struct lsu_softc *sc) +ldunlock(struct ld_softc *sc) { - sc->sc_flags &= ~LSUF_LKHELD; - if ((sc->sc_flags & LSUF_LKWANTED) != 0) { - sc->sc_flags &= ~LSUF_LKWANTED; + sc->sc_flags &= ~LDF_LKHELD; + if ((sc->sc_flags & LDF_LKWANTED) != 0) { + sc->sc_flags &= ~LDF_LKWANTED; wakeup(sc); } } @@ -502,9 +502,9 @@ lsuunlock(struct lsu_softc *sc) * Take a dump. */ int -lsudump(dev_t dev, daddr_t blkno, caddr_t va, size_t size) +lddump(dev_t dev, daddr_t blkno, caddr_t va, size_t size) { - struct lsu_softc *sc; + struct ld_softc *sc; struct disklabel *lp; int unit, part, nsects, sectoff, towrt, nblk, maxblkcnt, rv; static int dumping; @@ -517,9 +517,9 @@ lsudump(dev_t dev, daddr_t blkno, caddr_t va, size_t size) return (ENXIO); unit = DISKUNIT(dev); - if ((sc = device_lookup(&lsu_cd, unit)) == NULL) + if ((sc = device_lookup(&ld_cd, unit)) == NULL) return (ENXIO); - if ((sc->sc_flags & LSUF_ENABLED) == 0) + if ((sc->sc_flags & LDF_ENABLED) == 0) return (ENODEV); part = DISKPART(dev); @@ -561,11 +561,11 @@ lsudump(dev_t dev, daddr_t blkno, caddr_t va, size_t size) * Adjust the size of a transfer. */ static void -lsuminphys(struct buf *bp) +ldminphys(struct buf *bp) { - struct lsu_softc *sc; + struct ld_softc *sc; - sc = device_lookup(&lsu_cd, DISKUNIT(bp->b_dev)); + sc = device_lookup(&ld_cd, DISKUNIT(bp->b_dev)); if (bp->b_bcount > sc->sc_maxxfer) bp->b_bcount = sc->sc_maxxfer; diff --git a/sys/dev/ldvar.h b/sys/dev/ldvar.h new file mode 100644 index 00000000000..5f7a3dd51e4 --- /dev/null +++ b/sys/dev/ldvar.h @@ -0,0 +1,77 @@ +/* $NetBSD: ldvar.h,v 1.1 2000/11/26 17:44:04 ad Exp $ */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _DEV_LD_LDVAR_H_ +#define _DEV_LD_LDVAR_H_ + +struct ld_softc { + struct device sc_dv; + struct disk sc_dk; + struct buf_queue sc_bufq; +#if NRND > 0 + rndsource_element_t sc_rnd_source; +#endif + int sc_queuecnt; + + /* + * The following are filled by hardware specific attachment code. + */ + int sc_flags; /* control flags */ + int sc_secperunit; /* # sectors in total */ + int sc_ncylinders; /* # cylinders */ + int sc_nheads; /* # heads */ + int sc_nsectors; /* # sectors per track */ + int sc_secsize; /* sector size in bytes */ + int sc_maxxfer; /* max xfer size in bytes */ + int sc_maxqueuecnt; /* maximum h/w queue count */ + + int (*sc_dump)(struct ld_softc *, void *, int, int); + int (*sc_flush)(struct ld_softc *); + int (*sc_start)(struct ld_softc *, struct buf *); +}; + +#define LDF_ENABLED 0x01 /* device enabled */ +#define LDF_LKHELD 0x02 /* lock held */ +#define LDF_LKWANTED 0x04 /* lock wanted */ +#define LDF_WLABEL 0x08 /* label is writable */ +#define LDF_LABELLING 0x10 /* writing label */ + +void ldattach(struct ld_softc *); +void lddone(struct ld_softc *, struct buf *); + +#endif /* !_DEV_LD_LDVAR_H_ */ diff --git a/sys/dev/pci/files.pci b/sys/dev/pci/files.pci index 7816201c40a..1557cda9281 100644 --- a/sys/dev/pci/files.pci +++ b/sys/dev/pci/files.pci @@ -1,4 +1,4 @@ -# $NetBSD: files.pci,v 1.109 2000/11/14 23:40:44 matt Exp $ +# $NetBSD: files.pci,v 1.110 2000/11/26 17:44:06 ad Exp $ # # Config file and device description for machine-independent PCI code. # Included by ports that need it. Requires that the SCSI files be @@ -48,8 +48,8 @@ file dev/pci/twe.c twe defopt opt_twe.h TWE_MAX_QUEUECNT TWE_MAX_PU_QUEUECNT -attach lsu at twe with lsu_twe -file dev/pci/lsu_twe.c lsu_twe +attach ld at twe with ld_twe +file dev/pci/ld_twe.c ld_twe # Compaq RAID controllers attach cac at pci with cac_pci diff --git a/sys/dev/pci/lsu_twe.c b/sys/dev/pci/ld_twe.c index a67106d7700..1f93e846519 100644 --- a/sys/dev/pci/lsu_twe.c +++ b/sys/dev/pci/ld_twe.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $NetBSD: ld_twe.c,v 1.1 2000/11/26 17:44:06 ad Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ /* - * 3ware "Escalade" RAID controller front-end for lsu(4) driver. + * 3ware "Escalade" RAID controller front-end for ld(4) driver. */ #include "rnd.h" @@ -59,75 +59,75 @@ #include <uvm/uvm_extern.h> -#include <dev/lsuvar.h> +#include <dev/ldvar.h> #include <dev/pci/twereg.h> #include <dev/pci/twevar.h> -struct lsu_twe_softc { - struct lsu_softc sc_lsu; +struct ld_twe_softc { + struct ld_softc sc_ld; int sc_hwunit; }; -static void lsu_twe_attach(struct device *, struct device *, void *); -static int lsu_twe_dobio(struct lsu_twe_softc *, int, void *, int, int, +static void ld_twe_attach(struct device *, struct device *, void *); +static int ld_twe_dobio(struct ld_twe_softc *, int, void *, int, int, int, struct twe_context *); -static int lsu_twe_dump(struct lsu_softc *, void *, int, int); -static void lsu_twe_handler(struct twe_ccb *, int); -static int lsu_twe_match(struct device *, struct cfdata *, void *); -static int lsu_twe_start(struct lsu_softc *, struct buf *); +static int ld_twe_dump(struct ld_softc *, void *, int, int); +static void ld_twe_handler(struct twe_ccb *, int); +static int ld_twe_match(struct device *, struct cfdata *, void *); +static int ld_twe_start(struct ld_softc *, struct buf *); -struct cfattach lsu_twe_ca = { - sizeof(struct lsu_twe_softc), lsu_twe_match, lsu_twe_attach +struct cfattach ld_twe_ca = { + sizeof(struct ld_twe_softc), ld_twe_match, ld_twe_attach }; static int -lsu_twe_match(struct device *parent, struct cfdata *match, void *aux) +ld_twe_match(struct device *parent, struct cfdata *match, void *aux) { return (1); } static void -lsu_twe_attach(struct device *parent, struct device *self, void *aux) +ld_twe_attach(struct device *parent, struct device *self, void *aux) { struct twe_attach_args *twea; - struct lsu_twe_softc *sc; - struct lsu_softc *lsu; + struct ld_twe_softc *sc; + struct ld_softc *ld; struct twe_softc *twe; - sc = (struct lsu_twe_softc *)self; - lsu = &sc->sc_lsu; + sc = (struct ld_twe_softc *)self; + ld = &sc->sc_ld; twe = (struct twe_softc *)parent; twea = aux; sc->sc_hwunit = twea->twea_unit; - lsu->sc_flags = LSUF_ENABLED; - lsu->sc_maxxfer = TWE_MAX_XFER; - lsu->sc_secperunit = twe->sc_dsize[twea->twea_unit]; - lsu->sc_secsize = TWE_SECTOR_SIZE; - lsu->sc_maxqueuecnt = + ld->sc_flags = LDF_ENABLED; + ld->sc_maxxfer = TWE_MAX_XFER; + ld->sc_secperunit = twe->sc_dsize[twea->twea_unit]; + ld->sc_secsize = TWE_SECTOR_SIZE; + ld->sc_maxqueuecnt = min((twe->sc_nccbs - 1) / twe->sc_nunits, TWE_MAX_PU_QUEUECNT); - lsu->sc_start = lsu_twe_start; - lsu->sc_dump = lsu_twe_dump; + ld->sc_start = ld_twe_start; + ld->sc_dump = ld_twe_dump; /* Build synthetic geometry as per controller internal rules. */ - if (lsu->sc_secperunit > 0x200000) { - lsu->sc_nheads = 255; - lsu->sc_nsectors = 63; + if (ld->sc_secperunit > 0x200000) { + ld->sc_nheads = 255; + ld->sc_nsectors = 63; } else { - lsu->sc_nheads = 64; - lsu->sc_nsectors = 32; + ld->sc_nheads = 64; + ld->sc_nsectors = 32; } - lsu->sc_ncylinders = lsu->sc_secperunit / - (lsu->sc_nheads * lsu->sc_nsectors); + ld->sc_ncylinders = ld->sc_secperunit / + (ld->sc_nheads * ld->sc_nsectors); printf("\n"); - lsuattach(lsu); + ldattach(ld); } static int -lsu_twe_dobio(struct lsu_twe_softc *sc, int unit, void *data, int datasize, +ld_twe_dobio(struct ld_twe_softc *sc, int unit, void *data, int datasize, int blkno, int dowrite, struct twe_context *tx) { struct twe_ccb *ccb; @@ -135,7 +135,7 @@ lsu_twe_dobio(struct lsu_twe_softc *sc, int unit, void *data, int datasize, struct twe_softc *twe; int s, rv, flags; - twe = (struct twe_softc *)sc->sc_lsu.sc_dv.dv_parent; + twe = (struct twe_softc *)sc->sc_ld.sc_dv.dv_parent; flags = (dowrite ? TWE_CCB_DATA_OUT : TWE_CCB_DATA_IN); if ((rv = twe_ccb_alloc(twe, &ccb, flags)) != 0) @@ -183,35 +183,35 @@ lsu_twe_dobio(struct lsu_twe_softc *sc, int unit, void *data, int datasize, } static int -lsu_twe_start(struct lsu_softc *lsu, struct buf *bp) +ld_twe_start(struct ld_softc *ld, struct buf *bp) { struct twe_context tx; - struct lsu_twe_softc *sc; + struct ld_twe_softc *sc; struct twe_softc *twe; - sc = (struct lsu_twe_softc *)lsu; - twe = (struct twe_softc *)lsu->sc_dv.dv_parent; + sc = (struct ld_twe_softc *)ld; + twe = (struct twe_softc *)ld->sc_dv.dv_parent; - tx.tx_handler = lsu_twe_handler; + tx.tx_handler = ld_twe_handler; tx.tx_context = bp; - tx.tx_dv = &lsu->sc_dv; + tx.tx_dv = &ld->sc_dv; - return (lsu_twe_dobio(sc, sc->sc_hwunit, bp->b_data, bp->b_bcount, + return (ld_twe_dobio(sc, sc->sc_hwunit, bp->b_data, bp->b_bcount, bp->b_rawblkno, (bp->b_flags & B_READ) == 0, &tx)); } static void -lsu_twe_handler(struct twe_ccb *ccb, int error) +ld_twe_handler(struct twe_ccb *ccb, int error) { struct buf *bp; struct twe_context *tx; - struct lsu_twe_softc *sc; + struct ld_twe_softc *sc; struct twe_softc *twe; tx = &ccb->ccb_tx; bp = tx->tx_context; - sc = (struct lsu_twe_softc *)tx->tx_dv; - twe = (struct twe_softc *)sc->sc_lsu.sc_dv.dv_parent; + sc = (struct ld_twe_softc *)tx->tx_dv; + twe = (struct twe_softc *)sc->sc_ld.sc_dv.dv_parent; twe_ccb_unmap(twe, ccb); twe_ccb_free(twe, ccb); @@ -223,16 +223,16 @@ lsu_twe_handler(struct twe_ccb *ccb, int error) } else bp->b_resid = 0; - lsudone(&sc->sc_lsu, bp); + lddone(&sc->sc_ld, bp); } static int -lsu_twe_dump(struct lsu_softc *lsu, void *data, int blkno, int blkcnt) +ld_twe_dump(struct ld_softc *ld, void *data, int blkno, int blkcnt) { - struct lsu_twe_softc *sc; + struct ld_twe_softc *sc; - sc = (struct lsu_twe_softc *)lsu; + sc = (struct ld_twe_softc *)ld; - return (lsu_twe_dobio(sc, sc->sc_hwunit, data, blkcnt * lsu->sc_secsize, + return (ld_twe_dobio(sc, sc->sc_hwunit, data, blkcnt * ld->sc_secsize, blkno, 1, NULL)); } |
