summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorad <ad@NetBSD.org>2000-10-19 14:28:46 +0000
committerad <ad@NetBSD.org>2000-10-19 14:28:46 +0000
commit67fe5fbbb44caa6f2ddb443a33b098334eef4e38 (patch)
tree9399aa51055453973c8a0319ef1b8a13b197c75c /sys/dev/ic
parent66f3f07ca530b92c5512d310a5ce3599bb115edc (diff)
Update for lsu; untested.
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/ca.c684
-rw-r--r--sys/dev/ic/cac.c40
-rw-r--r--sys/dev/ic/cacvar.h9
3 files changed, 17 insertions, 716 deletions
diff --git a/sys/dev/ic/ca.c b/sys/dev/ic/ca.c
deleted file mode 100644
index b4167691e13..00000000000
--- a/sys/dev/ic/ca.c
+++ /dev/null
@@ -1,684 +0,0 @@
-/* $NetBSD: ca.c,v 1.10 2000/09/01 12:23:57 ad Exp $ */
-
-/*-
- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum and 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.
- */
-
-/*
- * Originally written by Julian Elischer (julian@dialix.oz.au)
- * for TRW Financial Systems for use under the MACH(2.5) operating system.
- *
- * TRW Financial Systems, in accordance with their agreement with Carnegie
- * Mellon University, makes this software available to CMU to distribute
- * or use in any manner that they see fit as long as this message is kept with
- * the software. For this reason TFS also grants any other persons or
- * organisations permission to use or modify this software.
- *
- * TFS supplies this software to be publicly redistributed
- * on the understanding that TFS is not responsible for the correct
- * functioning of this software in any circumstances.
- *
- * Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992
- */
-
-/*
- * Disk driver for Compaq arrays, based on sd.c (revision 1.157).
- */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ca.c,v 1.10 2000/09/01 12:23:57 ad Exp $");
-
-#include "rnd.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/device.h>
-#include <sys/queue.h>
-#include <sys/proc.h>
-#include <sys/buf.h>
-#include <sys/endian.h>
-#include <sys/disklabel.h>
-#include <sys/disk.h>
-#include <sys/dkio.h>
-#include <sys/stat.h>
-#include <sys/lock.h>
-#include <sys/conf.h>
-#include <sys/fcntl.h>
-#if NRND > 0
-#include <sys/rnd.h>
-#endif
-
-#include <machine/bswap.h>
-#include <machine/bus.h>
-
-#include <dev/ic/cacreg.h>
-#include <dev/ic/cacvar.h>
-
-#define CAUNIT(dev) DISKUNIT(dev)
-#define CAPART(dev) DISKPART(dev)
-#define CAMINOR(unit, part) DISKMINOR(unit, part)
-#define CAMAKEDEV(maj, unit, part) MAKEDISKDEV(maj, unit, part)
-
-#define CALABELDEV(dev) (CAMAKEDEV(major(dev), CAUNIT(dev), RAW_PART))
-
-/* #define CA_ENABLE_SYNC_XFER */
-
-struct ca_softc {
- struct device sc_dv;
- int sc_unit;
- int sc_flags;
- struct cac_softc *sc_cac;
- struct disk sc_dk;
-#if NRND > 0
- rndsource_element_t sc_rnd_source;
-#endif
-
- /* Parameters from controller. */
- int sc_ncylinders;
- int sc_nheads;
- int sc_nsectors;
- int sc_secsize;
- int sc_secperunit;
- int sc_mirror;
-};
-
-#define CAF_ENABLED 0x01 /* device enabled */
-#define CAF_LOCKED 0x02 /* lock held */
-#define CAF_WANTED 0x04 /* lock wanted */
-#define CAF_WLABEL 0x08 /* label is writable */
-#define CAF_LABELLING 0x10 /* writing label */
-
-static int calock __P((struct ca_softc *));
-static void caunlock __P((struct ca_softc *));
-static int camatch __P((struct device *, struct cfdata *, void *));
-static void caattach __P((struct device *, struct device *, void *));
-static void cadone __P((struct cac_ccb *, int));
-static void cagetdisklabel __P((struct ca_softc *));
-static void cagetdefaultlabel __P((struct ca_softc *, struct disklabel *));
-
-struct cfattach ca_ca = {
- sizeof(struct ca_softc), camatch, caattach
-};
-
-extern struct cfdriver ca_cd;
-
-struct dkdriver cadkdriver = { castrategy };
-
-static int
-camatch(parent, match, aux)
- struct device *parent;
- struct cfdata *match;
- void *aux;
-{
-
- return (1);
-}
-
-static void
-caattach(parent, self, aux)
- struct device *parent;
- struct device *self;
- void *aux;
-{
- struct cac_drive_info dinfo;
- struct cac_attach_args *caca;
- struct ca_softc *sc;
- char *type;
- int mb;
-
- sc = (struct ca_softc *)self;
- caca = (struct cac_attach_args *)aux;
- sc->sc_cac = (struct cac_softc *)parent;
- sc->sc_unit = caca->caca_unit;
-
- if (cac_cmd(sc->sc_cac, CAC_CMD_GET_LOG_DRV_INFO, &dinfo, sizeof(dinfo),
- sc->sc_unit, 0, CAC_CCB_DATA_IN, NULL)) {
- printf("%s: CMD_GET_LOG_DRV_INFO failed\n",
- sc->sc_dv.dv_xname);
- return;
- }
-
- sc->sc_ncylinders = CAC_GET2(dinfo.ncylinders);
- sc->sc_nheads = CAC_GET1(dinfo.nheads);
- sc->sc_nsectors = CAC_GET1(dinfo.nsectors);
- sc->sc_secsize = CAC_GET2(dinfo.secsize);
- sc->sc_mirror = CAC_GET1(dinfo.mirror);
- sc->sc_secperunit = sc->sc_ncylinders * sc->sc_nheads * sc->sc_nsectors;
-
- switch (sc->sc_mirror) {
- case 0:
- type = "standalone disk or RAID0";
- break;
- case 1:
- type = "RAID4";
- break;
- case 2:
- type = "RAID1";
- break;
- case 3:
- type = "RAID5";
- break;
- default:
- type = "unknown type of";
- break;
- }
-
- printf(": %s array\n", type);
-
- mb = sc->sc_secperunit / (1048576 / sc->sc_secsize);
- printf("%s: %uMB, %u cyl, %u head, %u sec, %d bytes/sect "
- "x %d sectors\n", sc->sc_dv.dv_xname, mb, sc->sc_ncylinders,
- sc->sc_nheads, sc->sc_nsectors, sc->sc_secsize, sc->sc_secperunit);
-
- /* Initialize and attach the disk structure */
- sc->sc_dk.dk_driver = &cadkdriver;
- sc->sc_dk.dk_name = sc->sc_dv.dv_xname;
- disk_attach(&sc->sc_dk);
- sc->sc_flags |= CAF_ENABLED;
-
-#if NRND > 0
- /* Attach the device into the rnd source list. */
- rnd_attach_source(&sc->sc_rnd_source, sc->sc_dv.dv_xname,
- RND_TYPE_DISK, 0);
-#endif
-}
-
-int
-caopen(dev, flags, fmt, p)
- dev_t dev;
- int flags;
- int fmt;
- struct proc *p;
-{
- struct ca_softc *sc;
- int part;
-
- sc = device_lookup(&ca_cd, CAUNIT(dev));
- if (sc == NULL)
- return (ENXIO);
- if ((sc->sc_flags & CAF_ENABLED) == 0)
- return (ENODEV);
- part = CAPART(dev);
- calock(sc);
-
- if (sc->sc_dk.dk_openmask == 0)
- cagetdisklabel(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)) {
- caunlock(sc);
- return (ENXIO);
- }
-
- /* Insure only one open at a time. */
- switch (fmt) {
- case S_IFCHR:
- sc->sc_dk.dk_copenmask |= (1 << part);
- break;
- case S_IFBLK:
- sc->sc_dk.dk_bopenmask |= (1 << part);
- break;
- }
- sc->sc_dk.dk_openmask =
- sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask;
-
- caunlock(sc);
- return (0);
-}
-
-int
-caclose(dev, flags, fmt, p)
- dev_t dev;
- int flags;
- int fmt;
- struct proc *p;
-{
- struct ca_softc *sc;
- int part;
-
- sc = device_lookup(&ca_cd, CAUNIT(dev));
- part = CAPART(dev);
- calock(sc);
-
- switch (fmt) {
- case S_IFCHR:
- sc->sc_dk.dk_copenmask &= ~(1 << part);
- break;
- case S_IFBLK:
- sc->sc_dk.dk_bopenmask &= ~(1 << part);
- break;
- }
- sc->sc_dk.dk_openmask =
- sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask;
-
- caunlock(sc);
- return (0);
-}
-
-int
-caread(dev, uio, ioflag)
- dev_t dev;
- struct uio *uio;
- int ioflag;
-{
-
- return (physio(castrategy, NULL, dev, B_READ, cac_minphys, uio));
-}
-
-int
-cawrite(dev, uio, ioflag)
- dev_t dev;
- struct uio *uio;
- int ioflag;
-{
-
- return (physio(castrategy, NULL, dev, B_WRITE, cac_minphys, uio));
-}
-
-int
-caioctl(dev, cmd, addr, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t addr;
- int32_t flag;
- struct proc *p;
-{
- struct ca_softc *sc;
- int part, error;
-
- sc = device_lookup(&ca_cd, CAUNIT(dev));
- part = CAPART(dev);
- error = 0;
-
- switch (cmd) {
- case DIOCGDINFO:
- memcpy(addr, sc->sc_dk.dk_label, sizeof(struct disklabel));
- return (0);
-
- case DIOCGPART:
- ((struct partinfo *)addr)->disklab = sc->sc_dk.dk_label;
- ((struct partinfo *)addr)->part =
- &sc->sc_dk.dk_label->d_partitions[part];
- break;
-
- case DIOCWDINFO:
- case DIOCSDINFO:
- if ((flag & FWRITE) == 0)
- return (EBADF);
-
- if ((error = calock(sc)) != 0)
- return (error);
- sc->sc_flags |= CAF_LABELLING;
-
- error = setdisklabel(sc->sc_dk.dk_label,
- (struct disklabel *)addr, /*sc->sc_dk.dk_openmask : */0,
- sc->sc_dk.dk_cpulabel);
- if (error == 0 && cmd == DIOCWDINFO)
- error = writedisklabel(CALABELDEV(dev), castrategy,
- sc->sc_dk.dk_label, sc->sc_dk.dk_cpulabel);
-
- sc->sc_flags &= ~CAF_LABELLING;
- caunlock(sc);
- break;
-
- case DIOCKLABEL:
- /* XXX */
- break;
-
- case DIOCWLABEL:
- if ((flag & FWRITE) == 0)
- return (EBADF);
- if (*(int *)addr)
- sc->sc_flags |= CAF_WLABEL;
- else
- sc->sc_flags &= ~CAF_WLABEL;
- break;
-
- case DIOCGDEFLABEL:
- cagetdefaultlabel(sc, (struct disklabel *)addr);
- break;
-
- default:
- error = ENOTTY;
- break;
- }
-
- return (error);
-}
-
-/*
- * Read/write a buffer.
- */
-void
-castrategy(bp)
- struct buf *bp;
-{
- struct cac_context cc;
- struct disklabel *lp;
- struct ca_softc *sc;
- int part, blkno, flg, cmd;
-
- sc = device_lookup(&ca_cd, CAUNIT(bp->b_dev));
- part = CAPART(bp->b_dev);
-
- lp = sc->sc_dk.dk_label;
-
- /*
- * The transfer must be a whole number of blocks, offset must not be
- * negative.
- */
- if ((bp->b_bcount % lp->d_secsize) != 0 || bp->b_blkno < 0) {
- bp->b_flags |= B_ERROR;
- biodone(bp);
- }
-
- /*
- * If it's a null transfer, return immediatly.
- */
- if (bp->b_bcount == 0) {
- bp->b_resid = bp->b_bcount;
- biodone(bp);
- return;
- }
-
- /*
- * Do bounds checking, adjust transfer. If error, process.
- * If end of partition, just return.
- */
- if (part != RAW_PART &&
- bounds_check_with_label(bp, lp,
- (sc->sc_flags & (CAF_WLABEL | CAF_LABELLING)) != 0) <= 0) {
- bp->b_resid = bp->b_bcount;
- biodone(bp);
- return;
- }
-
- /*
- * Now convert the block number to absolute and put it in
- * terms of the device's logical block size.
- */
- if (lp->d_secsize >= DEV_BSIZE)
- blkno = bp->b_blkno / (lp->d_secsize / DEV_BSIZE);
- else
- blkno = bp->b_blkno * (DEV_BSIZE / lp->d_secsize);
-
- if (bp->b_dev != RAW_PART)
- blkno += lp->d_partitions[part].p_offset;
-
- bp->b_rawblkno = blkno;
-
- /*
- * Which command to issue. Don't let synchronous writes linger in
- * the controller's cache.
- */
- if ((bp->b_flags & B_READ) != 0) {
- cmd = CAC_CMD_READ;
- flg = CAC_CCB_DATA_IN;
-#ifdef CA_ENABLE_SYNC_XFER
- } else if ((bp->b_flags & B_ASYNC) == 0) {
- cmd = CAC_CMD_WRITE_MEDIA;
- flg = CAC_CCB_DATA_OUT;
-#endif
- } else {
- cmd = CAC_CMD_WRITE;
- flg = CAC_CCB_DATA_OUT;
- }
-
- cc.cc_context = bp;
- cc.cc_handler = cadone;
- cc.cc_dv = &sc->sc_dv;
-
- disk_busy(&sc->sc_dk);
- cac_cmd(sc->sc_cac, cmd, bp->b_data, bp->b_bcount, sc->sc_unit, blkno,
- flg, &cc);
-}
-
-/*
- * Handle completed transfers.
- */
-static void
-cadone(ccb, error)
- struct cac_ccb *ccb;
- int error;
-{
- struct buf *bp;
- struct ca_softc *sc;
-
- sc = (struct ca_softc *)ccb->ccb_context.cc_dv;
- bp = (struct buf *)ccb->ccb_context.cc_context;
-
- if (error) {
- bp->b_flags |= B_ERROR;
- bp->b_error = EIO;
- bp->b_resid = bp->b_bcount;
- } else
- bp->b_resid = bp->b_bcount - ccb->ccb_datasize;
-
- disk_unbusy(&sc->sc_dk, ccb->ccb_datasize);
-#if NRND > 0
- rnd_add_uint32(&sc->sc_rnd_source, bp->b_rawblkno);
-#endif
- biodone(bp);
-}
-
-int
-casize(dev)
- dev_t dev;
-{
- struct ca_softc *sc;
- int part, omask, size;
-
- sc = device_lookup(&ca_cd, CAUNIT(dev));
- if (sc == NULL)
- return (ENXIO);
- if ((sc->sc_flags & CAF_ENABLED) == 0)
- return (ENODEV);
- part = CAPART(dev);
-
- omask = sc->sc_dk.dk_openmask & (1 << part);
-
- if (omask == 0 && caopen(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 && caclose(dev, 0, S_IFBLK, NULL) != 0)
- return (-1);
-
- return (size);
-}
-
-/*
- * Load the label information from the specified device.
- */
-static void
-cagetdisklabel(sc)
- struct ca_softc *sc;
-{
- struct disklabel *lp;
- char *errstring;
-
- lp = sc->sc_dk.dk_label;
-
- memset(sc->sc_dk.dk_cpulabel, 0, sizeof(struct cpu_disklabel));
- cagetdefaultlabel(sc, lp);
-
- if (lp->d_secpercyl == 0) {
- lp->d_secpercyl = 100;
- /* as long as it's not 0 - readdisklabel divides by it (?) */
- }
-
- /* Call the generic disklabel extraction routine. */
- errstring = readdisklabel(CAMAKEDEV(0, sc->sc_dv.dv_unit, RAW_PART),
- castrategy, lp, sc->sc_dk.dk_cpulabel);
- if (errstring != NULL)
- printf("%s: %s\n", sc->sc_dv.dv_xname, errstring);
-}
-
-/*
- * Construct a ficticious label.
- */
-static void
-cagetdefaultlabel(sc, lp)
- struct ca_softc *sc;
- struct disklabel *lp;
-{
-
- memset(lp, 0, sizeof(struct disklabel));
-
- lp->d_secsize = sc->sc_secsize;
- lp->d_ntracks = sc->sc_nheads;
- 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_SCSI; /* XXX */
- strcpy(lp->d_typename, "unknown");
- strcpy(lp->d_packname, "fictitious");
- lp->d_secperunit = sc->sc_secperunit;
- lp->d_rpm = 7200;
- lp->d_interleave = 1;
- lp->d_flags = 0;
-
- lp->d_partitions[RAW_PART].p_offset = 0;
- lp->d_partitions[RAW_PART].p_size =
- lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
- lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
- lp->d_npartitions = RAW_PART + 1;
-
- lp->d_magic = DISKMAGIC;
- lp->d_magic2 = DISKMAGIC;
- lp->d_checksum = dkcksum(lp);
-}
-
-/*
- * Wait interruptibly for an exclusive lock.
- *
- * XXX
- * Several drivers do this; it should be abstracted and made MP-safe.
- */
-static int
-calock(sc)
- struct ca_softc *sc;
-{
- int error;
-
- while ((sc->sc_flags & CAF_LOCKED) != 0) {
- sc->sc_flags |= CAF_WANTED;
- if ((error = tsleep(sc, PRIBIO | PCATCH, "calck", 0)) != 0)
- return (error);
- }
- sc->sc_flags |= CAF_LOCKED;
- return (0);
-}
-
-/*
- * Unlock and wake up any waiters.
- */
-static void
-caunlock(sc)
- struct ca_softc *sc;
-{
-
- sc->sc_flags &= ~CAF_LOCKED;
- if ((sc->sc_flags & CAF_WANTED) != 0) {
- sc->sc_flags &= ~CAF_WANTED;
- wakeup(sc);
- }
-}
-
-/*
- * Take a dump.
- */
-int
-cadump(dev, blkno, va, size)
- dev_t dev;
- daddr_t blkno;
- caddr_t va;
- size_t size;
-{
- struct ca_softc *sc;
- struct disklabel *lp;
- int part, nsects, sectoff, totwrt, nwrt;
- static int dumping;
-
- /* Check if recursive dump; if so, punt. */
- if (dumping)
- return (EFAULT);
- dumping = 1;
-
- sc = device_lookup(&ca_cd, CAUNIT(dev));
- if (sc == NULL)
- return (ENXIO);
- if ((sc->sc_flags & CAF_ENABLED) == 0)
- return (ENODEV);
- part = CAPART(dev);
-
- /* Convert to disk sectors. Request must be a multiple of size. */
- lp = sc->sc_dk.dk_label;
- if ((size % lp->d_secsize) != 0)
- return (EFAULT);
- totwrt = size / lp->d_secsize;
- blkno = dbtob(blkno) / lp->d_secsize; /* 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 = max(65536 / lp->d_secsize, totwrt); /* XXX */
-
- if (cac_cmd(sc->sc_cac, CAC_CMD_WRITE_MEDIA, va,
- nwrt * lp->d_secsize, sc->sc_unit, blkno,
- CAC_CCB_DATA_OUT, NULL))
- return (ENXIO);
-
- totwrt -= nwrt;
- blkno += nwrt;
- va += lp->d_secsize * nwrt;
- }
-
- dumping = 0;
- return (0);
-}
diff --git a/sys/dev/ic/cac.c b/sys/dev/ic/cac.c
index 1ed7bcda8f6..92462145640 100644
--- a/sys/dev/ic/cac.c
+++ b/sys/dev/ic/cac.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cac.c,v 1.12 2000/09/08 12:16:17 ad Exp $ */
+/* $NetBSD: cac.c,v 1.13 2000/10/19 14:28:46 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
static struct cac_ccb *cac_ccb_alloc(struct cac_softc *, int);
static void cac_ccb_done(struct cac_softc *, struct cac_ccb *);
static void cac_ccb_free(struct cac_softc *, struct cac_ccb *);
-static void cac_ccb_poll(struct cac_softc *, struct cac_ccb *, int);
+static int cac_ccb_poll(struct cac_softc *, struct cac_ccb *, int);
static int cac_ccb_start(struct cac_softc *, struct cac_ccb *);
static int cac_print(void *, const char *);
static void cac_shutdown(void *);
@@ -231,7 +231,7 @@ cac_submatch(struct device *parent, struct cfdata *cf, void *aux)
caca = (struct cac_attach_args *)aux;
- if (cf->cacacf_unit != CACACF_UNIT_UNKNOWN &&
+ if (cf->cacacf_unit != CACCF_UNIT_DEFAULT &&
cf->cacacf_unit != caca->caca_unit)
return (0);
@@ -280,7 +280,7 @@ cac_cmd(struct cac_softc *sc, int command, void *data, int datasize,
if ((ccb = cac_ccb_alloc(sc, 0)) == NULL) {
printf("%s: unable to alloc CCB", sc->sc_dv.dv_xname);
- return (1);
+ return (ENOMEM);
}
if ((flags & (CAC_CCB_DATA_IN | CAC_CCB_DATA_OUT)) != 0) {
@@ -331,9 +331,8 @@ cac_cmd(struct cac_softc *sc, int command, void *data, int datasize,
ccb->ccb_flags |= CAC_CCB_ACTIVE;
#endif
(*sc->sc_cl->cl_submit)(sc, ccb);
- cac_ccb_poll(sc, ccb, 2000);
+ rv = cac_ccb_poll(sc, ccb, 2000);
cac_ccb_free(sc, ccb);
- rv = 0;
}
} else {
memcpy(&ccb->ccb_context, context, sizeof(struct cac_context));
@@ -348,11 +347,11 @@ cac_cmd(struct cac_softc *sc, int command, void *data, int datasize,
/*
* Wait for the specified CCB to complete. Must be called at splbio.
*/
-static void
+static int
cac_ccb_poll(struct cac_softc *sc, struct cac_ccb *wantccb, int timo)
{
struct cac_ccb *ccb;
-
+
timo *= 10;
do {
@@ -362,11 +361,14 @@ cac_ccb_poll(struct cac_softc *sc, struct cac_ccb *wantccb, int timo)
DELAY(100);
}
- if (timo == 0)
- panic("%s: cac_ccb_poll: timeout", sc->sc_dv.dv_xname);
-
+ if (timo == 0) {
+ printf("%s: timeout", sc->sc_dv.dv_xname);
+ return (EBUSY);
+ }
cac_ccb_done(sc, ccb);
} while (ccb != wantccb);
+
+ return (0);
}
/*
@@ -382,7 +384,7 @@ cac_ccb_start(struct cac_softc *sc, struct cac_ccb *ccb)
while ((ccb = SIMPLEQ_FIRST(&sc->sc_ccb_queue)) != NULL) {
if ((*sc->sc_cl->cl_fifo_full)(sc))
- return (-1);
+ return (EBUSY);
SIMPLEQ_REMOVE_HEAD(&sc->sc_ccb_queue, ccb, ccb_chain);
#ifdef DIAGNOSTIC
ccb->ccb_flags |= CAC_CCB_ACTIVE;
@@ -474,8 +476,8 @@ cac_ccb_free(struct cac_softc *sc, struct cac_ccb *ccb)
{
int s;
- s = splbio();
ccb->ccb_flags = 0;
+ s = splbio();
SIMPLEQ_INSERT_HEAD(&sc->sc_ccb_free, ccb, ccb_chain);
if (SIMPLEQ_NEXT(ccb, ccb_chain) == NULL)
wakeup_one(&sc->sc_ccb_free);
@@ -483,18 +485,6 @@ cac_ccb_free(struct cac_softc *sc, struct cac_ccb *ccb)
}
/*
- * Adjust the size of a transfer.
- */
-void
-cac_minphys(struct buf *bp)
-{
-
- if (bp->b_bcount > CAC_MAX_XFER)
- bp->b_bcount = CAC_MAX_XFER;
- minphys(bp);
-}
-
-/*
* Board specific linkage shared between multiple bus types.
*/
diff --git a/sys/dev/ic/cacvar.h b/sys/dev/ic/cacvar.h
index 112014c3abe..1caa5af8534 100644
--- a/sys/dev/ic/cacvar.h
+++ b/sys/dev/ic/cacvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: cacvar.h,v 1.6 2000/09/01 12:12:29 ad Exp $ */
+/* $NetBSD: cacvar.h,v 1.7 2000/10/19 14:28:47 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -124,17 +124,12 @@ struct cac_attach_args {
int caca_unit;
};
-#define CACACF_UNIT 0
-
-#define cacacf_unit cf_loc[CACACF_UNIT]
-
-#define CACACF_UNIT_UNKNOWN -1
+#define cacacf_unit cf_loc[CACCF_UNIT]
int cac_cmd(struct cac_softc *, int, void *, int, int, int, int,
struct cac_context *);
int cac_init(struct cac_softc *, const char *, int);
int cac_intr(void *);
-void cac_minphys(struct buf *);
extern struct cac_linkage cac_l0;