- Remove dead code.
- Make synchronous writes optional, disabled by default (*way* too slow). - Handle case where dm_nsegs > CAC_SG_SIZE. - Fix a couple of silly bugs. - Fix use of __attribute__((__packed__));
This commit is contained in:
parent
282dcaac92
commit
424f6471cb
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ca.c,v 1.1 2000/03/16 14:52:23 ad Exp $ */
|
||||
/* $NetBSD: ca.c,v 1.2 2000/03/20 18:48:34 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
||||
@ -58,7 +58,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ca.c,v 1.1 2000/03/16 14:52:23 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ca.c,v 1.2 2000/03/20 18:48:34 ad Exp $");
|
||||
|
||||
#include "rnd.h"
|
||||
|
||||
@ -94,6 +94,8 @@ __KERNEL_RCSID(0, "$NetBSD: ca.c,v 1.1 2000/03/16 14:52:23 ad Exp $");
|
||||
|
||||
#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;
|
||||
@ -141,14 +143,7 @@ camatch(parent, match, aux)
|
||||
struct cfdata *match;
|
||||
void *aux;
|
||||
{
|
||||
#if 0
|
||||
struct cac_attach_args *caca;
|
||||
|
||||
caca = (struct cac_attach_args *)aux;
|
||||
|
||||
/* Unit 0 is the controller */
|
||||
return (caca->caca_unit != 0);
|
||||
#endif
|
||||
return (1);
|
||||
}
|
||||
|
||||
@ -462,12 +457,14 @@ castrategy(bp)
|
||||
if ((bp->b_flags & B_READ) != 0) {
|
||||
cmd = CAC_CMD_READ;
|
||||
flg = CAC_CCB_DATA_IN;
|
||||
} else if ((bp->b_flags & B_ASYNC) != 0) {
|
||||
cmd = CAC_CMD_WRITE;
|
||||
flg = CAC_CCB_DATA_OUT;
|
||||
} else {
|
||||
#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;
|
||||
@ -499,7 +496,7 @@ cadone(ccb, error)
|
||||
bp->b_error = EIO;
|
||||
bp->b_resid = bp->b_bcount;
|
||||
} else
|
||||
bp->b_resid = 0;
|
||||
bp->b_resid = bp->b_bcount - ccb->ccb_datasize;
|
||||
|
||||
disk_unbusy(&sc->sc_dk, 0);
|
||||
#if NRND > 0
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cac.c,v 1.1 2000/03/16 14:52:24 ad Exp $ */
|
||||
/* $NetBSD: cac.c,v 1.2 2000/03/20 18:48:34 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -41,7 +41,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: cac.c,v 1.1 2000/03/16 14:52:24 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: cac.c,v 1.2 2000/03/20 18:48:34 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -66,7 +66,7 @@ static int cac_submatch __P((struct device *, struct cfdata *, void *));
|
||||
static void cac_ccb_poll __P((struct cac_softc *, struct cac_ccb *, int));
|
||||
static void cac_shutdown __P((void *));
|
||||
|
||||
static SIMPLEQ_HEAD(, cac_softc) cac_hba; /* tailq of HBA softc's */
|
||||
static SIMPLEQ_HEAD(, cac_softc) cac_hba; /* list of HBA softc's */
|
||||
static void *cac_sdh; /* shutdown hook */
|
||||
|
||||
/*
|
||||
@ -276,7 +276,9 @@ cac_cmd(sc, command, data, datasize, drive, blkno, flags, context)
|
||||
{
|
||||
struct cac_ccb *ccb;
|
||||
struct cac_sgb *sgb;
|
||||
int s, i, rv;
|
||||
int s, i, rv, size, nsegs;
|
||||
|
||||
size = 0;
|
||||
|
||||
if ((ccb = cac_ccb_alloc(sc, 0)) == NULL) {
|
||||
printf("%s: unable to alloc CCB", sc->sc_dv.dv_xname);
|
||||
@ -292,26 +294,35 @@ cac_cmd(sc, command, data, datasize, drive, blkno, flags, context)
|
||||
BUS_DMASYNC_PREWRITE);
|
||||
|
||||
sgb = ccb->ccb_seg;
|
||||
nsegs = min(ccb->ccb_dmamap_xfer->dm_nsegs, CAC_SG_SIZE);
|
||||
|
||||
for (i = 0; i < ccb->ccb_dmamap_xfer->dm_nsegs; i++, sgb++) {
|
||||
for (i = 0; i < nsegs; i++, sgb++) {
|
||||
size += ccb->ccb_dmamap_xfer->dm_segs[i].ds_len;
|
||||
sgb->length =
|
||||
htole32(ccb->ccb_dmamap_xfer->dm_segs[i].ds_len);
|
||||
sgb->addr =
|
||||
htole32(ccb->ccb_dmamap_xfer->dm_segs[i].ds_addr);
|
||||
}
|
||||
} else {
|
||||
size = datasize;
|
||||
nsegs = 0;
|
||||
}
|
||||
|
||||
/* XXXDEBUG */
|
||||
if (size != datasize)
|
||||
printf("%s: datasize %d != %d", sc->sc_dv.dv_xname, datasize, size);
|
||||
|
||||
ccb->ccb_hdr.drive = drive;
|
||||
ccb->ccb_hdr.size = htole16((sizeof(struct cac_req) +
|
||||
sizeof(struct cac_sgb) * CAC_SG_SIZE) >> 2);
|
||||
|
||||
ccb->ccb_req.bcount = htole16(howmany(datasize, DEV_BSIZE));
|
||||
ccb->ccb_req.bcount = htole16(howmany(size, DEV_BSIZE));
|
||||
ccb->ccb_req.command = command;
|
||||
ccb->ccb_req.sgcount = i;
|
||||
ccb->ccb_req.blkno = htole32(blkno);
|
||||
|
||||
ccb->ccb_flags = flags;
|
||||
ccb->ccb_datasize = datasize;
|
||||
ccb->ccb_datasize = size;
|
||||
|
||||
if (context == NULL) {
|
||||
memset(&ccb->ccb_context, 0, sizeof(struct cac_context));
|
||||
@ -342,9 +353,11 @@ cac_ccb_poll(sc, ccb, timo)
|
||||
struct cac_ccb *ccb;
|
||||
int timo;
|
||||
{
|
||||
struct cac_ccb *ccb_done = NULL;
|
||||
struct cac_ccb *ccb_done;
|
||||
paddr_t completed;
|
||||
int off;
|
||||
|
||||
ccb_done = NULL;
|
||||
|
||||
for (;;) {
|
||||
for (; timo != 0; timo--) {
|
||||
@ -461,8 +474,6 @@ cac_ccb_alloc(sc, nosleep)
|
||||
}
|
||||
|
||||
splx(s);
|
||||
if (ccb != NULL)
|
||||
memset(ccb, 0, 276); /* XXX */
|
||||
return (ccb);
|
||||
}
|
||||
|
||||
@ -494,6 +505,7 @@ cac_minphys(bp)
|
||||
struct buf *bp;
|
||||
{
|
||||
|
||||
if (bp->b_bcount > CAC_MAX_XFER / DEV_BSIZE) /* XXX */
|
||||
bp->b_bcount = CAC_MAX_XFER / DEV_BSIZE; /* XXX */
|
||||
if (bp->b_bcount > CAC_MAX_XFER)
|
||||
bp->b_bcount = CAC_MAX_XFER;
|
||||
minphys(bp);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cacreg.h,v 1.1 2000/03/16 14:52:24 ad Exp $ */
|
||||
/* $NetBSD: cacreg.h,v 1.2 2000/03/20 18:48:34 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -112,34 +112,34 @@
|
||||
#define CAC_RET_CMD_REJECTED 0x14
|
||||
|
||||
struct cac_drive_info {
|
||||
u_int16_t secsize __attribute__ ((packed));
|
||||
u_int32_t secperunit __attribute__ ((packed));
|
||||
u_int16_t ncylinders __attribute__ ((packed));
|
||||
u_int8_t nheads __attribute__ ((packed));
|
||||
u_int8_t signature __attribute__ ((packed));
|
||||
u_int8_t psectors __attribute__ ((packed));
|
||||
u_int16_t wprecomp __attribute__ ((packed));
|
||||
u_int8_t max_acc __attribute__ ((packed));
|
||||
u_int8_t control __attribute__ ((packed));
|
||||
u_int16_t pcylinders __attribute__ ((packed));
|
||||
u_int8_t ptracks __attribute__ ((packed));
|
||||
u_int16_t landing_zone __attribute__ ((packed));
|
||||
u_int8_t nsectors __attribute__ ((packed));
|
||||
u_int8_t checksum __attribute__ ((packed));
|
||||
u_int8_t mirror __attribute__ ((packed));
|
||||
};
|
||||
u_int16_t secsize;
|
||||
u_int32_t secperunit;
|
||||
u_int16_t ncylinders;
|
||||
u_int8_t nheads;
|
||||
u_int8_t signature;
|
||||
u_int8_t psectors;
|
||||
u_int16_t wprecomp;
|
||||
u_int8_t max_acc;
|
||||
u_int8_t control;
|
||||
u_int16_t pcylinders;
|
||||
u_int8_t ptracks;
|
||||
u_int16_t landing_zone;
|
||||
u_int8_t nsectors;
|
||||
u_int8_t checksum;
|
||||
u_int8_t mirror;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
struct cac_controller_info {
|
||||
u_int8_t num_drvs __attribute__ ((packed));
|
||||
u_int32_t signature __attribute__ ((packed));
|
||||
u_int8_t firm_rev[4] __attribute__ ((packed));
|
||||
};
|
||||
u_int8_t num_drvs;
|
||||
u_int32_t signature;
|
||||
u_int8_t firm_rev[4];
|
||||
} __attribute__((__packed__));
|
||||
|
||||
struct cac_hdr {
|
||||
u_int8_t drive; /* logical drive */
|
||||
u_int8_t priority; /* block priority */
|
||||
u_int16_t size; /* size of request, in words */
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
struct cac_req {
|
||||
u_int16_t next; /* offset of next request */
|
||||
@ -149,12 +149,12 @@ struct cac_req {
|
||||
u_int16_t bcount; /* block count */
|
||||
u_int8_t sgcount; /* number of scatter/gather entries */
|
||||
u_int8_t reserved; /* reserved */
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
struct cac_sgb {
|
||||
u_int32_t length; /* length of S/G segment */
|
||||
u_int32_t addr; /* physical address of block */
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/*
|
||||
* Stupid macros to deal with alignment/endianness issues.
|
||||
|
Loading…
Reference in New Issue
Block a user