Update for sys/buf.h/disksort_*() changes.

This commit is contained in:
thorpej 2000-01-21 23:39:55 +00:00
parent 52242fdf9f
commit dc59bc1db3
30 changed files with 210 additions and 296 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: fd.c,v 1.11 1999/02/08 16:33:17 bouyer Exp $ */
/* $NetBSD: fd.c,v 1.12 2000/01/21 23:39:55 thorpej Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995 Charles M. Hannum.
@ -86,7 +86,6 @@
/* XXX misuse a flag to identify format operation */
#define B_FORMAT B_XXX
#define b_cylin b_resid
#ifdef FD_DEBUG
int fdc_debug = 0;
@ -211,7 +210,8 @@ struct fd_softc {
TAILQ_ENTRY(fd_softc) sc_drivechain;
int sc_ops; /* I/O ops since last switch */
struct buf sc_q; /* head of buf chain */
struct buf_queue sc_q; /* pending I/O requests */
int sc_active; /* number of active I/O operations */
};
bdev_decl(fd);
@ -504,6 +504,7 @@ fdattach(parent, self, aux)
else
printf(": density unknown\n");
BUFQ_FIRST(&fd->sc_q);
fd->sc_cylin = -1;
fd->sc_drive = drive;
fd->sc_deftype = type;
@ -610,19 +611,19 @@ fdstrategy(bp)
bp->b_bcount = sz << DEV_BSHIFT;
}
bp->b_cylin = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE) / fd->sc_type->seccyl;
bp->b_cylinder = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE) / fd->sc_type->seccyl;
#ifdef FD_DEBUG
if (fdc_debug > 1)
printf("fdstrategy: b_blkno %d b_bcount %ld blkno %d cylin %ld\n",
bp->b_blkno, bp->b_bcount, fd->sc_blkno, bp->b_cylin);
bp->b_blkno, bp->b_bcount, fd->sc_blkno, bp->b_cylinder);
#endif
/* Queue transfer on drive, activate drive and controller if idle. */
s = splbio();
disksort(&fd->sc_q, bp);
disksort_cylinder(&fd->sc_q, bp);
untimeout(fd_motor_off, fd); /* a good idea */
if (!fd->sc_q.b_active)
if (fd->sc_active == 0)
fdstart(fd);
#ifdef DIAGNOSTIC
else {
@ -651,7 +652,7 @@ fdstart(fd)
int active = fdc->sc_drives.tqh_first != 0;
/* Link into controller queue. */
fd->sc_q.b_active = 1;
fd->sc_active = 1;
TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
/* If controller not already active, start it. */
@ -675,14 +676,14 @@ fdfinish(fd, bp)
if (fd->sc_drivechain.tqe_next && ++fd->sc_ops >= 8) {
fd->sc_ops = 0;
TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain);
if (bp->b_actf) {
if (BUFQ_NEXT(bp) != NULL) {
TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
} else
fd->sc_q.b_active = 0;
fd->sc_active = 0;
}
bp->b_resid = fd->sc_bcount;
fd->sc_skip = 0;
fd->sc_q.b_actf = bp->b_actf;
BUFQ_REMOVE(&fd->sc_q);
biodone(bp);
/* turn off motor 5s from now */
@ -973,7 +974,7 @@ fdctimeout(arg)
s = splbio();
fdcstatus(&fd->sc_dv, 0, "timeout");
if (fd->sc_q.b_actf)
if (BUFQ_FIRST(&fd->sc_q) != NULL)
fdc->sc_state++;
else
fdc->sc_state = DEVIDLE;
@ -1125,11 +1126,11 @@ loop:
}
/* Is there a transfer to this drive? If not, deactivate drive. */
bp = fd->sc_q.b_actf;
bp = BUFQ_FIRST(&fd->sc_q);
if (bp == NULL) {
fd->sc_ops = 0;
TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain);
fd->sc_q.b_active = 0;
fd->sc_active = 0;
goto loop;
}
@ -1174,12 +1175,12 @@ loop:
doseek:
if ((fdc->sc_flags & FDC_EIS) &&
(bp->b_flags & B_FORMAT) == 0) {
fd->sc_cylin = bp->b_cylin;
fd->sc_cylin = bp->b_cylinder;
/* We use implied seek */
goto doio;
}
if (fd->sc_cylin == bp->b_cylin)
if (fd->sc_cylin == bp->b_cylinder)
goto doio;
/* specify command */
@ -1191,7 +1192,7 @@ loop:
/* seek function */
OUT_FDC(fdc, NE7CMD_SEEK, SEEKTIMEDOUT);
OUT_FDC(fdc, fd->sc_drive, SEEKTIMEDOUT); /* drive number */
OUT_FDC(fdc, bp->b_cylin * fd->sc_type->step, SEEKTIMEDOUT);
OUT_FDC(fdc, bp->b_cylinder * fd->sc_type->step, SEEKTIMEDOUT);
fd->sc_cylin = -1;
fdc->sc_state = SEEKWAIT;
@ -1297,7 +1298,7 @@ loop:
/* Make sure seek really happened. */
if (fdc->sc_nstat != 2 || (st0 & 0xf8) != 0x20 ||
cyl != bp->b_cylin * fd->sc_type->step) {
cyl != bp->b_cylinder * fd->sc_type->step) {
#ifdef FD_DEBUG
if (fdc_debug)
fdcstatus(&fd->sc_dv, 2, "seek failed");
@ -1305,7 +1306,7 @@ loop:
fdcretry(fdc);
goto loop;
}
fd->sc_cylin = bp->b_cylin;
fd->sc_cylin = bp->b_cylinder;
goto doio;
case IOTIMEDOUT:
@ -1389,7 +1390,7 @@ loop:
fd->sc_skip += fd->sc_nbytes;
fd->sc_bcount -= fd->sc_nbytes;
if (!finfo && fd->sc_bcount > 0) {
bp->b_cylin = fd->sc_blkno / fd->sc_type->seccyl;
bp->b_cylinder = fd->sc_blkno / fd->sc_type->seccyl;
goto doseek;
}
fdfinish(fd, bp);
@ -1469,7 +1470,7 @@ fdcretry(fdc)
struct buf *bp;
fd = fdc->sc_drives.tqh_first;
bp = fd->sc_q.b_actf;
bp = BUFQ_FIRST(&fd->sc_q);
fdc->sc_overruns = 0;
if (fd->sc_opts & FDOPT_NORETRY)

View File

@ -1,4 +1,4 @@
/* $NetBSD: xd.c,v 1.24 1999/09/17 20:07:18 thorpej Exp $ */
/* $NetBSD: xd.c,v 1.25 2000/01/21 23:39:55 thorpej Exp $ */
/*
*
@ -439,9 +439,7 @@ xdcattach(parent, self, aux)
/* init queue of waiting bufs */
xdc->sc_wq.b_active = 0;
xdc->sc_wq.b_actf = 0;
xdc->sc_wq.b_actb = &xdc->sc_wq.b_actf;
BUFQ_INIT(&xdc->sc_wq);
/*
* section 7 of the manual tells us how to init the controller:
@ -1026,7 +1024,6 @@ xdstrategy(bp)
{
struct xd_softc *xd;
struct xdc_softc *parent;
struct buf *wq;
int s, unit;
unit = DISKUNIT(bp->b_dev);
@ -1077,7 +1074,7 @@ xdstrategy(bp)
/* first, give jobs in front of us a chance */
parent = xd->parent;
while (parent->nfree > 0 && parent->sc_wq.b_actf)
while (parent->nfree > 0 && BUFQ_FIRST(&parent->sc_wq) != NULL)
if (xdc_startbuf(parent, NULL, NULL) != XD_ERR_AOK)
break;
@ -1086,11 +1083,7 @@ xdstrategy(bp)
* buffs will get picked up later by xdcintr().
*/
if (parent->nfree == 0) {
wq = &xd->parent->sc_wq;
bp->b_actf = 0;
bp->b_actb = wq->b_actb;
*wq->b_actb = bp;
wq->b_actb = &bp->b_actf;
BUFQ_INSERT_TAIL(&parent->sc_wq, bp);
splx(s);
return;
}
@ -1138,7 +1131,7 @@ xdcintr(v)
xdc_start(xdcsc, XDC_MAXIOPB);
/* fill up any remaining iorq's with queue'd buffers */
while (xdcsc->nfree > 0 && xdcsc->sc_wq.b_actf)
while (xdcsc->nfree > 0 && BUFQ_FIRST(&xdcsc->sc_wq) != NULL)
if (xdc_startbuf(xdcsc, NULL, NULL) != XD_ERR_AOK)
break;
@ -1369,7 +1362,6 @@ xdc_startbuf(xdcsc, xdsc, bp)
int rqno, partno;
struct xd_iorq *iorq;
struct xd_iopb *iopb;
struct buf *wq;
u_long block;
caddr_t dbuf;
@ -1382,15 +1374,10 @@ xdc_startbuf(xdcsc, xdsc, bp)
/* get buf */
if (bp == NULL) {
bp = xdcsc->sc_wq.b_actf;
if (!bp)
bp = BUFQ_FIRST(&xdcsc->sc_wq);
if (bp == NULL)
panic("xdc_startbuf bp");
wq = bp->b_actf;
if (wq)
wq->b_actb = bp->b_actb;
else
xdcsc->sc_wq.b_actb = bp->b_actb;
*bp->b_actb = wq;
BUFQ_REMOVE(&xdcsc->sc_wq, bp);
xdsc = xdcsc->sc_drives[DISKUNIT(bp->b_dev)];
}
partno = DISKPART(bp->b_dev);
@ -1431,11 +1418,7 @@ xdc_startbuf(xdcsc, xdsc, bp)
printf("%s: warning: out of DVMA space\n",
xdcsc->sc_dev.dv_xname);
XDC_FREE(xdcsc, rqno);
wq = &xdcsc->sc_wq; /* put at end of queue */
bp->b_actf = 0;
bp->b_actb = wq->b_actb;
*wq->b_actb = bp;
wq->b_actb = &bp->b_actf;
BUFQ_INSERT_TAIL(&xdcsc->sc_wq, bp);
return (XD_ERR_FAIL); /* XXX: need some sort of
* call-back scheme here? */
}
@ -1636,7 +1619,7 @@ xdc_piodriver(xdcsc, iorqno, freeone)
/* now that we've drained everything, start up any bufs that have
* queued */
while (xdcsc->nfree > 0 && xdcsc->sc_wq.b_actf)
while (xdcsc->nfree > 0 && BUFQ_FIRST(&xdcsc->sc_wq) != NULL)
if (xdc_startbuf(xdcsc, NULL, NULL) != XD_ERR_AOK)
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: xdvar.h,v 1.5 1998/01/26 21:03:43 gwr Exp $ */
/* $NetBSD: xdvar.h,v 1.6 2000/01/21 23:39:55 thorpej Exp $ */
/*
*
@ -149,7 +149,7 @@ struct xdc_softc {
struct xd_iorq *reqs; /* i/o requests */
struct xd_iopb *iopbase; /* iopb base addr (maps iopb->iorq) */
struct xd_iopb *dvmaiopb; /* iopb base in DVMA space, not kvm */
struct buf sc_wq; /* queue'd IOPBs for this controller */
struct buf_queue sc_wq; /* queue'd IOPBs for this controller */
char freereq[XDC_MAXIOPB]; /* free list (stack) */
char waitq[XDC_MAXIOPB]; /* wait queue */
u_char nfree; /* number of iopbs free */

View File

@ -1,4 +1,4 @@
/* $NetBSD: xy.c,v 1.23 1999/09/17 20:07:18 thorpej Exp $ */
/* $NetBSD: xy.c,v 1.24 2000/01/21 23:39:55 thorpej Exp $ */
/*
*
@ -503,9 +503,7 @@ xyattach(parent, self, aux)
xy->parent = xyc;
/* init queue of waiting bufs */
xy->xyq.b_active = 0;
xy->xyq.b_actf = 0;
xy->xyq.b_actb = &xy->xyq.b_actf; /* XXX b_actb: not used? */
BUFQ_INIT(&xy->xyq);
xy->xyrq = &xyc->reqs[xa->driveno];
xy->xy_drive = xa->driveno;
@ -1023,7 +1021,7 @@ xystrategy(bp)
s = splbio(); /* protect the queues */
disksort(&xy->xyq, bp);
disksort_blkno(&xy->xyq, bp); /* XXX disksort_cylinder */
/* start 'em up */
@ -1634,8 +1632,7 @@ xyc_reset(xycsc, quiet, blastmode, error, xysc)
/* Sun3: map/unmap regardless of B_PHYS */
dvma_mapout(iorq->dbufbase,
iorq->buf->b_bcount);
iorq->xy->xyq.b_actf =
iorq->buf->b_actf;
BUFQ_REMOVE(&iorq->xy->xyq, iorq->buf);
disk_unbusy(&iorq->xy->sc_dk,
(iorq->buf->b_bcount -
iorq->buf->b_resid));
@ -1681,9 +1678,9 @@ xyc_start(xycsc, iorq)
if (iorq == NULL) {
for (lcv = 0; lcv < XYC_MAXDEV ; lcv++) {
if ((xy = xycsc->sc_drives[lcv]) == NULL) continue;
if (xy->xyq.b_actf == NULL) continue;
if (BUFQ_FIRST(&xy->xyq) == NULL) continue;
if (xy->xyrq->mode != XY_SUB_FREE) continue;
xyc_startbuf(xycsc, xy, xy->xyq.b_actf);
xyc_startbuf(xycsc, xy, BUFQ_FIRST(&xy->xyq));
}
}
xyc_submit_iorq(xycsc, iorq, XY_SUB_NOQ);
@ -1813,7 +1810,7 @@ xyc_remove_iorq(xycsc)
/* Sun3: map/unmap regardless of B_PHYS */
dvma_mapout(iorq->dbufbase,
iorq->buf->b_bcount);
iorq->xy->xyq.b_actf = bp->b_actf;
BUFQ_REMOVE(&iorq->xy->xyq, bp);
disk_unbusy(&iorq->xy->sc_dk,
(bp->b_bcount - bp->b_resid));
iorq->mode = XY_SUB_FREE;

View File

@ -1,4 +1,4 @@
/* $NetBSD: xyvar.h,v 1.4 1998/01/26 21:03:45 gwr Exp $ */
/* $NetBSD: xyvar.h,v 1.5 2000/01/21 23:39:55 thorpej Exp $ */
/*
*
@ -114,7 +114,7 @@ struct xy_softc {
u_char nsect; /* number of sectors per track */
u_char hw_spt; /* as above, but includes spare sectors */
struct xy_iorq *xyrq; /* this disk's ioreq structure */
struct buf xyq; /* queue'd I/O requests */
struct buf_queue xyq; /* queue'd I/O requests */
struct dkbad dkb; /* bad144 sectors */
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: hp.c,v 1.19 1999/08/14 11:33:09 ragge Exp $ */
/* $NetBSD: hp.c,v 1.20 2000/01/21 23:39:56 thorpej Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* All rights reserved.
@ -134,6 +134,7 @@ hpattach(parent, self, aux)
/*
* Init the common struct for both the adapter and its slaves.
*/
BUFQ_INIT(&sc->sc_md.md_q);
sc->sc_md.md_softc = (void *)sc; /* Pointer to this softc */
sc->sc_md.md_mba = (void *)parent; /* Pointer to parent softc */
sc->sc_md.md_start = hpstart; /* Disk start routine */
@ -191,8 +192,8 @@ hpstrategy(bp)
goto done;
s = splbio();
gp = sc->sc_md.md_q.b_actf;
disksort(&sc->sc_md.md_q, bp);
gp = BUFQ_FIRST(&sc->sc_md.md_q);
disksort_blkno(&sc->sc_md.md_q, bp); /* XXX disksort_cylinder */
if (gp == 0)
mbaqueue(&sc->sc_md);
@ -215,7 +216,7 @@ hpstart(md)
struct mba_regs *mr = md->md_mba->sc_mbareg;
volatile struct hp_regs *hr;
struct disklabel *lp = sc->sc_disk.dk_label;
struct buf *bp = md->md_q.b_actf;
struct buf *bp = BUFQ_FIRST(&md->md_q);
unsigned bn, cn, sn, tn;
int part = DISKPART(bp->b_dev);
@ -368,7 +369,7 @@ hpfinish(md, mbasr, attn)
int mbasr, *attn;
{
struct hp_softc *sc = md->md_softc;
struct buf *bp = md->md_q.b_actf;
struct buf *bp = BUFQ_FIRST(&md->md_q);
volatile struct mba_regs *mr = md->md_mba->sc_mbareg;
volatile struct hp_regs *hr = (void *)&mr->mba_md[DISKUNIT(bp->b_dev)];
int er1, er2;
@ -407,8 +408,8 @@ hper2:
printf("massbuss error :%s %x\n",
sc->sc_dev.dv_xname, mbasr);
md->md_q.b_actf->b_resid = 0;
disk_unbusy(&sc->sc_disk, md->md_q.b_actf->b_bcount);
BUFQ_FIRST(&md->md_q)->b_resid = 0;
disk_unbusy(&sc->sc_disk, BUFQ_FIRST(&md->md_q)->b_bcount);
return XFER_FINISH;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mba.c,v 1.16 2000/01/17 04:57:31 matt Exp $ */
/* $NetBSD: mba.c,v 1.17 2000/01/21 23:39:56 thorpej Exp $ */
/*
* Copyright (c) 1994, 1996 Ludd, University of Lule}, Sweden.
* All rights reserved.
@ -189,7 +189,7 @@ mbaintr(mba)
return; /* During autoconfig */
md = sc->sc_first;
bp = md->md_q.b_actf;
bp = BUFQ_FIRST(&md->md_q);
/*
* A data-transfer interrupt. Current operation is finished,
* call that device's finish routine to see what to do next.
@ -206,13 +206,13 @@ mbaintr(mba)
* If more to transfer, start the adapter again
* by calling mbastart().
*/
md->md_q.b_actf = bp->b_actf;
BUFQ_REMOVE(&md->md_q, bp);
sc->sc_first = md->md_back;
md->md_back = 0;
if (sc->sc_first == 0)
sc->sc_last = (void *)&sc->sc_first;
if (md->md_q.b_actf) {
if (BUFQ_FIRST(&md->md_q) != NULL) {
sc->sc_last->md_back = md;
sc->sc_last = md;
}
@ -287,9 +287,10 @@ mbastart(sc)
{
struct mba_device *md = sc->sc_first;
volatile struct mba_regs *mr = sc->sc_mbareg;
struct buf *bp = md->md_q.b_actf;
struct buf *bp = BUFQ_FIRST(&md->md_q);
disk_reallymapin(md->md_q.b_actf, sc->sc_mbareg->mba_map, 0, PG_V);
disk_reallymapin(BUFQ_FIRST(&md->md_q), sc->sc_mbareg->mba_map,
0, PG_V);
sc->sc_state = SC_ACTIVE;
mr->mba_var = ((u_int)bp->b_un.b_addr & VAX_PGOFSET);

View File

@ -1,4 +1,4 @@
/* $NetBSD: mbavar.h,v 1.4 1996/04/08 18:39:01 ragge Exp $ */
/* $NetBSD: mbavar.h,v 1.5 2000/01/21 23:39:56 thorpej Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden
* All rights reserved.
@ -97,7 +97,7 @@ struct mba_device {
enum xfer_action (*md_finish) __P((struct mba_device *, int, int *));
void *md_softc; /* Backpointer to this units softc. */
struct mba_softc *md_mba;
struct buf md_q; /* Buffer head for transfers */
struct buf_queue md_q; /* queue of I/O requests */
};
struct mba_softc {

View File

@ -1,4 +1,4 @@
/* $NetBSD: ctu.c,v 1.5 1996/10/13 03:35:36 christos Exp $ */
/* $NetBSD: ctu.c,v 1.6 2000/01/21 23:39:57 thorpej Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* All rights reserved.
@ -80,7 +80,7 @@ volatile struct tu_softc {
int sc_bbytes; /* Number of xfer'd bytes this block */
int sc_op; /* Read/write */
int sc_xmtok; /* set if OK to xmit */
struct buf sc_q; /* Current buffer */
struct buf_queue sc_q; /* pending I/O requests */
} tu_sc;
struct ivec_dsp tu_recv, tu_xmit;
@ -104,6 +104,8 @@ ctuattach()
{
extern struct ivec_dsp idsptch;
BUFQ_INIT(&tu_sc.sc_q);
bcopy(&idsptch, &tu_recv, sizeof(struct ivec_dsp));
bcopy(&idsptch, &tu_xmit, sizeof(struct ivec_dsp));
scb->scb_csrint = (void *)&tu_recv;
@ -177,12 +179,11 @@ ctustrategy(bp)
#endif
if (bp->b_blkno >= 512) {
iodone(bp);
biodone(bp);
return;
}
bp->b_cylinder = bp->b_blkno;
s = splimp();
disksort((struct buf *)&tu_sc.sc_q, bp); /* Why not use disksort? */
disksort_blkno(&tu_sc.sc_q, bp); /* Why not use disksort? */
if (tu_sc.sc_state == SC_READY)
ctustart(bp);
splx(s);
@ -248,7 +249,7 @@ cturintr(arg)
int status = mfpr(PR_CSRD);
struct buf *bp;
bp = tu_sc.sc_q.b_actf;
bp = BUFQ_FIRST(&tu_sc.sc_q);
switch (tu_sc.sc_state) {
case SC_UNUSED:
@ -268,12 +269,12 @@ cturintr(arg)
#ifdef TUDEBUG
printf("Xfer ok\n");
#endif
tu_sc.sc_q.b_actf = bp->b_actf;
iodone(bp);
BUFQ_REMOVE(&tu_sc.sc_q, bp);
biodone(bp);
tu_sc.sc_xmtok = 1;
tu_sc.sc_state = SC_READY;
if (tu_sc.sc_q.b_actf)
ctustart(tu_sc.sc_q.b_actf);
if (BUFQ_FIRST(&tu_sc.sc_q) != NULL)
ctustart(BUFQ_FIRST(&tu_sc.sc_q));
}
break;
}
@ -298,7 +299,7 @@ cturintr(arg)
break;
case SC_RESTART:
ctustart(tu_sc.sc_q.b_actf);
ctustart(BUFQ_FIRST(&tu_sc.sc_q));
break;
default:
@ -402,7 +403,7 @@ ctuwatch(arg)
if (tu_sc.sc_state == SC_GET_RESP && tu_sc.sc_tpblk != 0 &&
tu_sc.sc_tpblk == oldtp && (tu_sc.sc_tpblk % 128 != 0)) {
printf("tu0: lost recv interrupt\n");
ctustart(tu_sc.sc_q.b_actf);
ctustart(BUFQ_FIRST(&tu_sc.sc_q));
return;
}
if (tu_sc.sc_state == SC_RESTART)

View File

@ -1,4 +1,4 @@
/* $NetBSD: fd.c,v 1.28 1999/03/24 14:07:38 minoura Exp $ */
/* $NetBSD: fd.c,v 1.29 2000/01/21 23:39:57 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -122,8 +122,6 @@ int fddebug = 0;
#define FDUNIT(dev) (minor(dev) / 8)
#define FDTYPE(dev) (minor(dev) % 8)
#define b_cylin b_resid
enum fdc_state {
DEVIDLE = 0,
MOTORWAIT,
@ -241,7 +239,8 @@ struct fd_softc {
TAILQ_ENTRY(fd_softc) sc_drivechain;
int sc_ops; /* I/O ops since last switch */
struct buf sc_q; /* head of buf chain */
struct buf_queue sc_q; /* pending I/O requests */
int sc_active; /* number of active I/O operations */
u_char *sc_copybuf; /* for secsize >=3 */
u_char sc_part; /* for secsize >=3 */
#define SEC_P10 0x02 /* first part */
@ -588,6 +587,7 @@ fdattach(parent, self, aux)
else
printf(": density unknown\n");
BUFQ_INIT(&fd->sc_q);
fd->sc_cylin = -1;
fd->sc_drive = drive;
fd->sc_deftype = type;
@ -670,17 +670,17 @@ fdstrategy(bp)
bp->b_bcount = sz << DEV_BSHIFT;
}
bp->b_cylin = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE)
bp->b_cylinder = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE)
/ (fd->sc_type->seccyl * (1 << (fd->sc_type->secsize - 2)));
DPRINTF(("fdstrategy: %s b_blkno %d b_bcount %ld cylin %ld\n",
bp->b_flags & B_READ ? "read" : "write",
bp->b_blkno, bp->b_bcount, bp->b_cylin));
bp->b_blkno, bp->b_bcount, bp->b_cylinder));
/* Queue transfer on drive, activate drive and controller if idle. */
s = splbio();
disksort(&fd->sc_q, bp);
disksort_cylinder(&fd->sc_q, bp);
untimeout(fd_motor_off, fd); /* a good idea */
if (!fd->sc_q.b_active)
if (fd->sc_active == 0)
fdstart(fd);
#ifdef DIAGNOSTIC
else {
@ -709,7 +709,7 @@ fdstart(fd)
int active = fdc->sc_drives.tqh_first != 0;
/* Link into controller queue. */
fd->sc_q.b_active = 1;
fd->sc_active = 1;
TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
/* If controller not already active, start it. */
@ -733,14 +733,14 @@ fdfinish(fd, bp)
if (fd->sc_drivechain.tqe_next && ++fd->sc_ops >= 8) {
fd->sc_ops = 0;
TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain);
if (bp->b_actf) {
if (BUFQ_NEXT(bp) != NULL) {
TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
} else
fd->sc_q.b_active = 0;
fd->sc_active = 0;
}
bp->b_resid = fd->sc_bcount;
fd->sc_skip = 0;
fd->sc_q.b_actf = bp->b_actf;
BUFQ_REMOVE(&fd->sc_q, bp);
#if NRND > 0
rnd_add_uint32(&fd->rnd_source, bp->b_blkno);
@ -1023,7 +1023,7 @@ fdctimeout(arg)
s = splbio();
fdcstatus(&fd->sc_dev, 0, "timeout");
if (fd->sc_q.b_actf)
if (BUFQ_FIRST(&fd->sc_q) != NULL)
fdc->sc_state++;
else
fdc->sc_state = DEVIDLE;
@ -1081,11 +1081,11 @@ loop:
}
/* Is there a transfer to this drive? If not, deactivate drive. */
bp = fd->sc_q.b_actf;
bp = BUFQ_FIRST(&fd->sc_q);
if (bp == NULL) {
fd->sc_ops = 0;
TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain);
fd->sc_q.b_active = 0;
fd->sc_active = 0;
goto loop;
}
@ -1126,7 +1126,7 @@ loop:
case DOSEEK:
doseek:
DPRINTF(("fdcintr: in DOSEEK\n"));
if (fd->sc_cylin == bp->b_cylin)
if (fd->sc_cylin == bp->b_cylinder)
goto doio;
out_fdc(iot, ioh, NE7CMD_SPECIFY);/* specify command */
@ -1135,7 +1135,7 @@ loop:
out_fdc(iot, ioh, NE7CMD_SEEK); /* seek function */
out_fdc(iot, ioh, fd->sc_drive); /* drive number */
out_fdc(iot, ioh, bp->b_cylin * fd->sc_type->step);
out_fdc(iot, ioh, bp->b_cylinder * fd->sc_type->step);
fd->sc_cylin = -1;
fdc->sc_state = SEEKWAIT;
@ -1221,7 +1221,7 @@ loop:
else
out_fdc(iot, ioh, NE7CMD_WRITE); /* WRITE */
out_fdc(iot, ioh, (head << 2) | fd->sc_drive);
out_fdc(iot, ioh, bp->b_cylin); /* cylinder */
out_fdc(iot, ioh, bp->b_cylinder); /* cylinder */
out_fdc(iot, ioh, head);
out_fdc(iot, ioh, sec + 1); /* sector +1 */
out_fdc(iot, ioh, type->secsize); /* sector size */
@ -1242,7 +1242,7 @@ loop:
fdc_dmastart(fdc, B_READ, fd->sc_copybuf, 1024);
out_fdc(iot, ioh, NE7CMD_READ); /* READ */
out_fdc(iot, ioh, (head << 2) | fd->sc_drive);
out_fdc(iot, ioh, bp->b_cylin); /* cylinder */
out_fdc(iot, ioh, bp->b_cylinder); /* cylinder */
out_fdc(iot, ioh, head);
out_fdc(iot, ioh, sec + 1); /* sector +1 */
out_fdc(iot, ioh, type->secsize); /* sector size */
@ -1293,7 +1293,7 @@ loop:
}
out_fdc(iot, ioh, NE7CMD_WRITE); /* WRITE */
out_fdc(iot, ioh, (head << 2) | fd->sc_drive);
out_fdc(iot, ioh, bp->b_cylin); /* cylinder */
out_fdc(iot, ioh, bp->b_cylinder); /* cylinder */
out_fdc(iot, ioh, head);
out_fdc(iot, ioh, sec + 1); /* sector +1 */
out_fdc(iot, ioh, fd->sc_type->secsize); /* sector size */
@ -1326,14 +1326,14 @@ loop:
goto loop;
} else if (tmp != 2 ||
(st0 & 0xf8) != 0x20 ||
cyl != bp->b_cylin) {
cyl != bp->b_cylinder) {
#ifdef FDDEBUG
fdcstatus(&fd->sc_dev, 2, "seek failed");
#endif
fdcretry(fdc);
goto loop;
}
fd->sc_cylin = bp->b_cylin;
fd->sc_cylin = bp->b_cylinder;
goto doio;
case IOTIMEDOUT:
@ -1377,7 +1377,7 @@ loop:
fd->sc_bcount -= fd->sc_nbytes;
DPRINTF(("fd->sc_bcount = %d\n", fd->sc_bcount));
if (fd->sc_bcount > 0) {
bp->b_cylin = fd->sc_blkno
bp->b_cylinder = fd->sc_blkno
/ (fd->sc_type->seccyl
* (1 << (fd->sc_type->secsize - 2)));
goto doseek;
@ -1484,7 +1484,7 @@ fdcretry(fdc)
DPRINTF(("fdcretry:\n"));
fd = fdc->sc_drives.tqh_first;
bp = fd->sc_q.b_actf;
bp = BUFQ_FIRST(&fd->sc_q);
switch (fdc->sc_errors) {
case 0:

View File

@ -1,4 +1,4 @@
/* $NetBSD: wd.c,v 1.199 1999/12/23 21:23:19 leo Exp $ */
/* $NetBSD: wd.c,v 1.200 2000/01/21 23:39:57 thorpej Exp $ */
/*
* Copyright (c) 1998 Manuel Bouyer. All rights reserved.
@ -133,7 +133,7 @@ struct wd_softc {
/* General disk infos */
struct device sc_dev;
struct disk sc_dk;
struct buf sc_q;
struct buf_queue sc_q;
/* IDE disk soft states */
struct ata_bio sc_wdc_bio; /* current transfer */
struct buf *sc_bp; /* buf being transfered */
@ -261,6 +261,8 @@ wdattach(parent, self, aux)
char buf[41], c, *p, *q;
WDCDEBUG_PRINT(("wdattach\n"), DEBUG_FUNCS | DEBUG_PROBE);
BUFQ_INIT(&wd->sc_q);
wd->openings = aa_link->aa_openings;
wd->drvp = aa_link->aa_drv_data;;
wd->wdc_softc = parent;
@ -400,8 +402,8 @@ wddetach(self, flags)
s = splbio();
/* Kill off any queued buffers. */
while ((bp = sc->sc_q.b_actf) != NULL) {
sc->sc_q.b_actf = bp->b_actf;
while ((bp = BUFQ_FIRST(&sc->sc_q)) != NULL) {
BUFQ_REMOVE(&sc->sc_q, bp);
bp->b_error = EIO;
bp->b_flags |= B_ERROR;
bp->b_resid = bp->b_bcount;
@ -471,7 +473,7 @@ wdstrategy(bp)
goto done;
/* Queue transfer on drive, activate drive and controller if idle. */
s = splbio();
disksort(&wd->sc_q, bp);
disksort_blkno(&wd->sc_q, bp);
wdstart(wd);
splx(s);
return;
@ -491,17 +493,16 @@ wdstart(arg)
void *arg;
{
struct wd_softc *wd = arg;
struct buf *dp, *bp=0;
struct buf *bp = NULL;
WDCDEBUG_PRINT(("wdstart %s\n", wd->sc_dev.dv_xname),
DEBUG_XFERS);
while (wd->openings > 0) {
/* Is there a buf for us ? */
dp = &wd->sc_q;
if ((bp = dp->b_actf) == NULL) /* yes, an assign */
return;
dp->b_actf = bp->b_actf;
if ((bp = BUFQ_FIRST(&wd->sc_q)) == NULL)
return;
BUFQ_REMOVE(&wd->sc_q, bp);
/*
* Make the command. First lock the device

View File

@ -1,4 +1,4 @@
/* $NetBSD: rrunner.c,v 1.13 1999/06/20 16:44:49 thorpej Exp $ */
/* $NetBSD: rrunner.c,v 1.14 2000/01/21 23:39:58 thorpej Exp $ */
/*
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -300,6 +300,7 @@ eshconfig(sc)
sc->sc_send.ec_offset = 0;
sc->sc_send.ec_descr = sc->sc_send_ring;
TAILQ_INIT(&sc->sc_send.ec_di_queue);
BUFQ_INIT(&sc->sc_send.ec_buf_queue);
for (i = 0; i < RR_MAX_SNAP_RECV_RING_SIZE; i++)
if (bus_dmamap_create(sc->sc_dmat, RR_DMA_MAX, 1, RR_DMA_MAX,
@ -1428,16 +1429,7 @@ esh_fpstrategy(bp)
*/
struct esh_send_ring_ctl *ring = &sc->sc_send;
if (ring->ec_queue != NULL) {
assert(ring->ec_lastqueue);
ring->ec_lastqueue->b_actf = bp;
} else {
ring->ec_queue = bp;
}
ring->ec_lastqueue = bp;
bp->b_actf = NULL;
BUFQ_INSERT_TAIL(&ring->ec_buf_queue, bp);
#ifdef ESH_PRINTF
printf("esh_fpstrategy: ready to call eshstart to write!\n");
#endif
@ -2080,7 +2072,8 @@ eshstart(ifp)
if ((sc->sc_flags & ESH_FL_FP_RING_UP) != 0 &&
send->ec_cur_mbuf == NULL && send->ec_cur_buf == NULL &&
send->ec_cur_dmainfo == NULL && send->ec_queue != NULL) {
send->ec_cur_dmainfo == NULL &&
BUFQ_FIRST(&send->ec_buf_queue) != NULL) {
struct buf *bp;
#ifdef ESH_PRINTF
@ -2088,10 +2081,8 @@ eshstart(ifp)
send->ec_queue);
#endif
bp = send->ec_cur_buf = send->ec_queue;
send->ec_queue = send->ec_queue->b_actf;
if (send->ec_queue == NULL)
send->ec_lastqueue = NULL;
bp = send->ec_cur_buf = BUFQ_FIRST(&send->ec_buf_queue);
BUFQ_REMOVE(&send->ec_buf_queue, bp);
send->ec_offset = 0;
send->ec_len = bp->b_bcount;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rrunnervar.h,v 1.5 1998/11/20 04:12:58 kml Exp $ */
/* $NetBSD: rrunnervar.h,v 1.6 2000/01/21 23:39:58 thorpej Exp $ */
/* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
@ -114,8 +114,7 @@ struct esh_send_ring_ctl {
struct buf *ec_cur_buf; /* current buf being processed */
struct esh_dmainfo *ec_cur_dmainfo;
/* current dmainfo being processed */
struct buf *ec_queue; /* queue of bufs to send */
struct buf *ec_lastqueue; /* last entry in the queue */
struct buf_queue ec_buf_queue; /* queue of bufs to send */
int ec_error; /* encountered error? */
u_int16_t ec_producer; /* latest buffer driver produced */
u_int16_t ec_consumer; /* latest buffer runcode consumed */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mcd.c,v 1.63 1999/02/08 16:33:17 bouyer Exp $ */
/* $NetBSD: mcd.c,v 1.64 2000/01/21 23:39:58 thorpej Exp $ */
/*
* Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved.
@ -144,7 +144,8 @@ struct mcd_softc {
#define MCD_MD_UNKNOWN -1
int lastupc;
#define MCD_UPC_UNKNOWN -1
struct buf buf_queue;
struct buf_queue buf_queue;
int active;
u_char readcmd;
u_char debug;
u_char probe;
@ -245,6 +246,8 @@ mcdattach(parent, self, aux)
return;
}
BUFQ_INIT(&sc->buf_queue);
/*
* Initialize and attach the disk structure.
*/
@ -489,9 +492,9 @@ mcdstrategy(bp)
/* Queue it. */
s = splbio();
disksort(&sc->buf_queue, bp);
disksort_blkno(&sc->buf_queue, bp);
splx(s);
if (!sc->buf_queue.b_active)
if (!sc->active)
mcdstart(sc);
return;
@ -506,23 +509,22 @@ void
mcdstart(sc)
struct mcd_softc *sc;
{
struct buf *bp, *dp = &sc->buf_queue;
struct buf *bp;
int s;
loop:
s = splbio();
bp = dp->b_actf;
if (bp == NULL) {
if ((bp = BUFQ_FIRST(&sc->buf_queue)) == NULL) {
/* Nothing to do. */
dp->b_active = 0;
sc->active = 0;
splx(s);
return;
}
/* Block found to process; dequeue. */
MCD_TRACE("start: found block bp=0x%x\n", bp, 0, 0, 0);
dp->b_actf = bp->b_actf;
BUFQ_REMOVE(&sc->buf_queue, bp);
splx(s);
/* Changed media? */
@ -534,7 +536,7 @@ loop:
goto loop;
}
dp->b_active = 1;
sc->active = 1;
/* Instrumentation. */
s = splbio();

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.21 2000/01/21 12:14:53 tsutsui Exp $ */
/* $NetBSD: md.c,v 1.22 2000/01/21 23:39:57 thorpej Exp $ */
/*
* Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
@ -84,7 +84,7 @@ struct md_softc {
struct device sc_dev; /* REQUIRED first entry */
struct disk sc_dkdev; /* hook for generic disk handling */
struct md_conf sc_md;
struct buf *sc_buflist;
struct buf_queue sc_buflist;
};
/* shorthand for fields in sc_md: */
#define sc_addr sc_md.md_addr
@ -147,6 +147,8 @@ md_attach(parent, self, aux)
{
struct md_softc *sc = (struct md_softc *)self;
BUFQ_INIT(&sc->sc_buflist);
/* XXX - Could accept aux info here to set the config. */
#ifdef MEMORY_DISK_HOOKS
/*
@ -339,9 +341,8 @@ mdstrategy(bp)
#if MEMORY_DISK_SERVER
case MD_UMEM_SERVER:
/* Just add this job to the server's queue. */
bp->b_actf = sc->sc_buflist;
sc->sc_buflist = bp;
if (bp->b_actf == NULL) {
BUFQ_INSERT_TAIL(&sc->sc_buflist, bp);
if (BUFQ_FIRST(&sc->sc_buflist) == bp) {
/* server queue was empty. */
wakeup((caddr_t)sc);
/* see md_server_loop() */
@ -504,16 +505,14 @@ md_server_loop(sc)
for (;;) {
/* Wait for some work to arrive. */
while (sc->sc_buflist == NULL) {
while ((bp = BUFQ_FIRST(&sc->sc_buflist)) == NULL) {
error = tsleep((caddr_t)sc, md_sleep_pri, "md_idle", 0);
if (error)
return error;
}
/* Unlink buf from head of list. */
bp = sc->sc_buflist;
sc->sc_buflist = bp->b_actf;
bp->b_actf = NULL;
BUFQ_REMOVE(&sc->sc_buflist, bp);
/* Do the transfer to/from user space. */
error = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mscp_disk.c,v 1.21 1999/06/06 19:16:18 ragge Exp $ */
/* $NetBSD: mscp_disk.c,v 1.22 2000/01/21 23:39:59 thorpej Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* Copyright (c) 1988 Regents of the University of California.
@ -288,7 +288,7 @@ raclose(dev, flags, fmt, p)
#if notyet
if (ra->ra_openpart == 0) {
s = splimp();
while (udautab[unit].b_actf)
while (BUFQ_FIRST(&udautab[unit]) != NULL)
sleep((caddr_t)&udautab[unit], PZERO - 1);
splx(s);
ra->ra_state = CLOSED;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mscp_subr.c,v 1.12 1999/06/06 19:16:18 ragge Exp $ */
/* $NetBSD: mscp_subr.c,v 1.13 2000/01/21 23:39:59 thorpej Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* Copyright (c) 1988 Regents of the University of California.
@ -160,7 +160,7 @@ mscp_attach(parent, self, aux)
mi->mi_rsp.mri_size = NRSP;
mi->mi_rsp.mri_desc = mi->mi_uda->mp_ca.ca_rspdsc;
mi->mi_rsp.mri_ring = mi->mi_uda->mp_rsp;
SIMPLEQ_INIT(&mi->mi_resq);
BUFQ_INIT(&mi->mi_resq);
if (mscp_init(mi)) {
printf("%s: can't init, controller hung\n",
@ -451,7 +451,7 @@ mscp_intr(mi)
/*
* If there are any not-yet-handled request, try them now.
*/
if (SIMPLEQ_FIRST(&mi->mi_resq))
if (BUFQ_FIRST(&mi->mi_resq))
mscp_kickaway(mi);
}
@ -485,10 +485,7 @@ mscp_strategy(bp, usc)
struct mscp_softc *mi = (void *)usc;
int s = splimp();
/* SIMPLEQ_INSERT_TAIL(&mi->mi_resq, bp, xxx) */
bp->b_actf = NULL;
*mi->mi_resq.sqh_last = bp;
mi->mi_resq.sqh_last = &bp->b_actf;
BUFQ_INSERT_TAIL(&mi->mi_resq, bp);
mscp_kickaway(mi);
splx(s);
}
@ -502,7 +499,7 @@ mscp_kickaway(mi)
struct mscp *mp;
int next;
while ((bp = SIMPLEQ_FIRST(&mi->mi_resq))) {
while ((bp = BUFQ_FIRST(&mi->mi_resq)) != NULL) {
/*
* Ok; we are ready to try to start a xfer. Get a MSCP packet
* and try to start...
@ -535,11 +532,7 @@ mscp_kickaway(mi)
bp->b_resid = next;
(*mi->mi_me->me_fillin)(bp, mp);
(*mi->mi_mc->mc_go)(mi->mi_dev.dv_parent, &mi->mi_xi[next]);
if ((mi->mi_resq.sqh_first = bp->b_actf) == NULL)
mi->mi_resq.sqh_last = &mi->mi_resq.sqh_first;
#if 0
mi->mi_w = bp->b_actf;
#endif
BUFQ_REMOVE(&mi->mi_resq, bp);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mscpvar.h,v 1.7 1999/06/06 19:16:18 ragge Exp $ */
/* $NetBSD: mscpvar.h,v 1.8 2000/01/21 23:39:59 thorpej Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* Copyright (c) 1988 Regents of the University of California.
@ -191,7 +191,7 @@ struct mscp_softc {
bus_space_handle_t mi_iph; /* initialisation and polling */
bus_space_handle_t mi_sah; /* status & address (read part) */
bus_space_handle_t mi_swh; /* status & address (write part) */
SIMPLEQ_HEAD(, buf) mi_resq; /* While waiting for packets */
struct buf_queue mi_resq; /* While waiting for packets */
};
/* mi_flags */

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_esh_pci.c,v 1.5 1998/07/05 06:49:15 jonathan Exp $ */
/* $NetBSD: if_esh_pci.c,v 1.6 2000/01/21 23:39:59 thorpej Exp $ */
/*
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -54,6 +54,7 @@
#include <sys/syslog.h>
#include <sys/select.h>
#include <sys/device.h>
#include <sys/buf.h>
#include <net/if.h>
#include <net/if_dl.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: uda.c,v 1.30 1999/06/06 19:14:49 ragge Exp $ */
/* $NetBSD: uda.c,v 1.31 2000/01/21 23:39:59 thorpej Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* Copyright (c) 1988 Regents of the University of California.
@ -60,27 +60,13 @@
#include "ioconf.h"
/*
* Variants of SIMPLEQ macros for use with buf structs.
*/
#define BUFQ_INSERT_TAIL(head, elm) { \
(elm)->b_actf = NULL; \
*(head)->sqh_last = (elm); \
(head)->sqh_last = &(elm)->b_actf; \
}
#define BUFQ_REMOVE_HEAD(head, elm) { \
if (((head)->sqh_first = (elm)->b_actf) == NULL) \
(head)->sqh_last = &(head)->sqh_first; \
}
/*
* Software status, per controller.
*/
struct uda_softc {
struct device sc_dev; /* Autoconfig info */
struct uba_unit sc_unit; /* Struct common for UBA to communicate */
SIMPLEQ_HEAD(, buf) sc_bufq; /* bufs awaiting for resources */
struct buf_queue sc_bufq; /* bufs awaiting for resources */
struct mscp_pack *sc_uuda; /* Unibus address of uda struct */
struct mscp_pack sc_uda; /* Struct for uda communication */
bus_dma_tag_t sc_dmat;
@ -224,7 +210,7 @@ udaattach(parent, self, aux)
sc->sc_sah = ua->ua_ioh + 2;
sc->sc_dmat = ua->ua_dmat;
ctlr = sc->sc_dev.dv_unit;
SIMPLEQ_INIT(&sc->sc_bufq);
BUFQ_INIT(&sc->sc_bufq);
/*
* Fill in the uba_unit struct, so we can communicate with the uba.

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_netbsdkintf.c,v 1.46 2000/01/09 03:39:13 oster Exp $ */
/* $NetBSD: rf_netbsdkintf.c,v 1.47 2000/01/21 23:39:59 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
@ -214,7 +214,7 @@ struct raid_softc {
char sc_xname[20]; /* XXX external name */
struct disk sc_dkdev; /* generic disk device info */
struct pool sc_cbufpool; /* component buffer pool */
struct buf buf_queue; /* used for the device queue */
struct buf_queue buf_queue; /* used for the device queue */
};
/* sc_flags */
#define RAIDF_INITED 0x01 /* unit has been initialized */
@ -325,9 +325,7 @@ raidattach(num)
bzero(raid_softc, num * sizeof(struct raid_softc));
for (raidID = 0; raidID < num; raidID++) {
raid_softc[raidID].buf_queue.b_actf = NULL;
raid_softc[raidID].buf_queue.b_actb =
&raid_softc[raidID].buf_queue.b_actf;
BUFQ_INIT(&raid_softc[raidID].buf_queue);
RF_Calloc(raidPtrs[raidID], 1, sizeof(RF_Raid_t),
(RF_Raid_t *));
if (raidPtrs[raidID] == NULL) {
@ -522,7 +520,6 @@ raidstrategy(bp)
RF_Raid_t *raidPtr;
struct raid_softc *rs = &raid_softc[raidID];
struct disklabel *lp;
struct buf *dp;
int wlabel;
if ((rs->sc_flags & RAIDF_INITED) ==0) {
@ -572,12 +569,7 @@ raidstrategy(bp)
bp->b_resid = 0;
/* stuff it onto our queue */
dp = &rs->buf_queue;
bp->b_actf = NULL;
bp->b_actb = dp->b_actb;
*dp->b_actb = bp;
dp->b_actb = &bp->b_actf;
BUFQ_INSERT_TAIL(&rs->buf_queue, bp);
raidstart(raidPtrs[raidID]);
@ -1361,7 +1353,6 @@ raidstart(raidPtr)
struct raid_softc *rs;
int do_async;
struct buf *bp;
struct buf *dp;
unit = raidPtr->raidid;
rs = &raid_softc[unit];
@ -1372,21 +1363,11 @@ raidstart(raidPtr)
RF_UNLOCK_MUTEX(raidPtr->mutex);
/* get the next item, if any, from the queue */
dp = &rs->buf_queue;
bp = dp->b_actf;
if (bp == NULL) {
if ((bp = BUFQ_FIRST(&rs->buf_queue)) == NULL) {
/* nothing more to do */
return;
}
/* update structures */
dp = bp->b_actf;
if (dp != NULL) {
dp->b_actb = bp->b_actb;
} else {
rs->buf_queue.b_actb = bp->b_actb;
}
*bp->b_actb = dp;
BUFQ_REMOVE(&rs->buf_queue, bp);
/* Ok, for the bp we have here, bp->b_blkno is relative to the
* partition.. Need to make it absolute to the underlying

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd.c,v 1.134 1999/11/03 20:50:18 matt Exp $ */
/* $NetBSD: cd.c,v 1.135 2000/01/21 23:40:00 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -159,6 +159,8 @@ cdattach(parent, cd, sc_link, ops)
{
SC_DEBUG(sc_link, SDEV_DB2, ("cdattach: "));
BUFQ_INIT(&cd->buf_queue);
/*
* Store information needed to contact our base driver
*/
@ -229,8 +231,8 @@ cddetach(self, flags)
s = splbio();
/* Kill off any queued buffers. */
while ((bp = cd->buf_queue.b_actf) != NULL) {
cd->buf_queue.b_actf = bp->b_actf;
while ((bp = BUFQ_FIRST(&cd->buf_queue)) != NULL) {
BUFQ_REMOVE(&cd->buf_queue, bp);
bp->b_error = EIO;
bp->b_flags |= B_ERROR;
bp->b_resid = bp->b_bcount;
@ -544,7 +546,7 @@ cdstrategy(bp)
/*
* Place it in the queue of disk activities for this disk
*/
disksort(&cd->buf_queue, bp);
disksort_blkno(&cd->buf_queue, bp);
/*
* Tell the device to get going on the transfer if it's
@ -589,7 +591,6 @@ cdstart(v)
register struct scsipi_link *sc_link = cd->sc_link;
struct disklabel *lp = cd->sc_dk.dk_label;
struct buf *bp = 0;
struct buf *dp;
struct scsipi_rw_big cmd_big;
#if NCD_SCSIBUS > 0
struct scsi_rw cmd_small;
@ -617,10 +618,9 @@ cdstart(v)
/*
* See if there is a buf with work for us to do..
*/
dp = &cd->buf_queue;
if ((bp = dp->b_actf) == NULL) /* yes, an assign */
if ((bp = BUFQ_FIRST(&cd->buf_queue)) == NULL)
return;
dp->b_actf = bp->b_actf;
BUFQ_REMOVE(&cd->buf_queue, bp);
/*
* If the device has become invalid, abort all the

View File

@ -1,4 +1,4 @@
/* $NetBSD: cdvar.h,v 1.11 1999/09/23 11:04:34 enami Exp $ */
/* $NetBSD: cdvar.h,v 1.12 2000/01/21 23:40:00 thorpej Exp $ */
/*
* Copyright (c) 1997 Manuel Bouyer. All rights reserved.
@ -48,7 +48,7 @@ struct cd_softc {
int blksize;
u_long disksize; /* total number sectors */
} params;
struct buf buf_queue;
struct buf_queue buf_queue;
char name[16]; /* product name, for default disklabel */
const struct cd_ops *sc_ops; /* our bus-dependent ops vector */

View File

@ -1,4 +1,4 @@
/* $NetBSD: sd.c,v 1.154 1999/12/23 21:23:30 leo Exp $ */
/* $NetBSD: sd.c,v 1.155 2000/01/21 23:40:00 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -137,6 +137,8 @@ sdattach(parent, sd, sc_link, ops)
SC_DEBUG(sc_link, SDEV_DB2, ("sdattach: "));
BUFQ_INIT(&sd->buf_queue);
/*
* Store information needed to contact our base driver
*/
@ -264,8 +266,8 @@ sddetach(self, flags)
s = splbio();
/* Kill off any queued buffers. */
while ((bp = sd->buf_queue.b_actf) != NULL) {
sd->buf_queue.b_actf = bp->b_actf;
while ((bp = BUFQ_FIRST(&sd->buf_queue)) != NULL) {
BUFQ_REMOVE(&sd->buf_queue, bp);
bp->b_error = EIO;
bp->b_flags |= B_ERROR;
bp->b_resid = bp->b_bcount;
@ -597,7 +599,7 @@ sdstrategy(bp)
/*
* Place it in the queue of disk activities for this disk
*/
disksort(&sd->buf_queue, bp);
disksort_blkno(&sd->buf_queue, bp);
/*
* Tell the device to get going on the transfer if it's
@ -642,7 +644,6 @@ sdstart(v)
register struct scsipi_link *sc_link = sd->sc_link;
struct disklabel *lp = sd->sc_dk.dk_label;
struct buf *bp = 0;
struct buf *dp;
struct scsipi_rw_big cmd_big;
#if NSD_SCSIBUS > 0
struct scsi_rw cmd_small;
@ -670,10 +671,9 @@ sdstart(v)
/*
* See if there is a buf with work for us to do..
*/
dp = &sd->buf_queue;
if ((bp = dp->b_actf) == NULL) /* yes, an assign */
if ((bp = BUFQ_FIRST(&sd->buf_queue)) == NULL)
return;
dp->b_actf = bp->b_actf;
BUFQ_REMOVE(&sd->buf_queue, bp);
/*
* If the device has become invalid, abort all the

View File

@ -1,4 +1,4 @@
/* $NetBSD: sdvar.h,v 1.9 1999/09/11 21:42:58 thorpej Exp $ */
/* $NetBSD: sdvar.h,v 1.10 2000/01/21 23:40:00 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -78,7 +78,7 @@ struct sd_softc {
u_long disksize; /* total number sectors */
u_long rot_rate; /* rotational rate, in RPM */
} params;
struct buf buf_queue;
struct buf_queue buf_queue;
u_int8_t type;
char name[16]; /* product name, for default disklabel */
const struct sd_ops *sc_ops; /* our bus-dependent ops vector */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ss.c,v 1.28 2000/01/19 01:00:07 abs Exp $ */
/* $NetBSD: ss.c,v 1.29 2000/01/21 23:40:00 thorpej Exp $ */
/*
* Copyright (c) 1995 Kenneth Stailey. All rights reserved.
@ -159,9 +159,7 @@ ssattach(parent, self, aux)
/*
* Set up the buf queue for this device
*/
ss->buf_queue.b_active = 0;
ss->buf_queue.b_actf = 0;
ss->buf_queue.b_actb = &ss->buf_queue.b_actf;
BUFQ_INIT(&ss->buf_queue);
ss->flags &= ~SSF_AUTOCONF;
}
@ -332,7 +330,6 @@ ssstrategy(bp)
struct buf *bp;
{
struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(bp->b_dev)];
struct buf *dp;
int s;
SC_DEBUG(ss->sc_link, SDEV_DB1,
@ -361,11 +358,7 @@ ssstrategy(bp)
* at the end (a bit silly because we only have on user..
* (but it could fork()))
*/
dp = &ss->buf_queue;
bp->b_actf = NULL;
bp->b_actb = dp->b_actb;
*dp->b_actb = bp;
dp->b_actb = &bp->b_actf;
BUFQ_INSERT_TAIL(&ss->buf_queue, bp);
/*
* Tell the device to get going on the transfer if it's
@ -405,7 +398,7 @@ ssstart(v)
{
struct ss_softc *ss = v;
struct scsipi_link *sc_link = ss->sc_link;
register struct buf *bp, *dp;
register struct buf *bp;
SC_DEBUG(sc_link, SDEV_DB2, ("ssstart "));
/*
@ -423,14 +416,9 @@ ssstart(v)
/*
* See if there is a buf with work for us to do..
*/
dp = &ss->buf_queue;
if ((bp = dp->b_actf) == NULL)
if ((bp = BUFQ_FIRST(&ss->buf_queue)) == NULL)
return;
if ((dp = bp->b_actf) != NULL)
dp->b_actb = bp->b_actb;
else
ss->buf_queue.b_actb = bp->b_actb;
*bp->b_actb = dp;
BUFQ_REMOVE(&ss->buf_queue, bp);
if (ss->special && ss->special->read) {
(ss->special->read)(ss, bp);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ssvar.h,v 1.6 1998/04/22 19:44:19 pk Exp $ */
/* $NetBSD: ssvar.h,v 1.7 2000/01/21 23:40:00 thorpej Exp $ */
/*
* Copyright (c) 1995 Kenneth Stailey. All rights reserved.
@ -67,7 +67,7 @@ struct ss_softc {
#define SSF_AUTOCONF 0x04 /* set during auto-configuration */
struct scsipi_link *sc_link; /* contains our targ, lun, etc. */
struct scan_io sio;
struct buf buf_queue; /* the queue of pending IO operations */
struct buf_queue buf_queue; /* the queue of pending IO operations */
u_int quirks; /* scanner is only mildly twisted */
#define SS_Q_GET_BUFFER_SIZE 0x0001 /* poll for available data in ssread() */
/* truncate to byte boundry is assumed by default unless one of these is set */

View File

@ -1,4 +1,4 @@
/* $NetBSD: st.c,v 1.116 2000/01/13 00:18:27 nisimura Exp $ */
/* $NetBSD: st.c,v 1.117 2000/01/21 23:40:00 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -335,7 +335,7 @@ struct st_softc {
* additional sense data needed
* for mode sense/select.
*/
struct buf buf_queue; /* the queue of pending IO */
struct buf_queue buf_queue; /* the queue of pending IO */
/* operations */
#if NRND > 0
rndsource_element_t rnd_source;
@ -493,9 +493,7 @@ stattach(parent, self, aux)
/*
* Set up the buf queue for this device
*/
st->buf_queue.b_active = 0;
st->buf_queue.b_actf = 0;
st->buf_queue.b_actb = &st->buf_queue.b_actf;
BUFQ_INIT(&st->buf_queue);
#if NRND > 0
rnd_attach_source(&st->rnd_source, st->sc_dev.dv_xname,
@ -1076,7 +1074,6 @@ ststrategy(bp)
struct buf *bp;
{
struct st_softc *st = st_cd.cd_devs[STUNIT(bp->b_dev)];
struct buf *dp;
int s;
SC_DEBUG(st->sc_link, SDEV_DB1,
@ -1121,11 +1118,7 @@ ststrategy(bp)
* at the end (a bit silly because we only have on user..
* (but it could fork()))
*/
dp = &st->buf_queue;
bp->b_actf = NULL;
bp->b_actb = dp->b_actb;
*dp->b_actb = bp;
dp->b_actb = &bp->b_actf;
BUFQ_INSERT_TAIL(&st->buf_queue, bp);
/*
* Tell the device to get going on the transfer if it's
@ -1167,7 +1160,7 @@ ststart(v)
{
struct st_softc *st = v;
struct scsipi_link *sc_link = st->sc_link;
register struct buf *bp, *dp;
register struct buf *bp;
struct scsi_rw_tape cmd;
int flags, error;
@ -1184,14 +1177,9 @@ ststart(v)
return;
}
dp = &st->buf_queue;
if ((bp = dp->b_actf) == NULL)
if ((bp = BUFQ_FIRST(&st->buf_queue)) == NULL)
return;
if ((dp = bp->b_actf) != NULL)
dp->b_actb = bp->b_actb;
else
st->buf_queue.b_actb = bp->b_actb;
*bp->b_actb = dp;
BUFQ_REMOVE(&st->buf_queue, bp);
/*
* if the device has been unmounted bye the user

View File

@ -1,4 +1,4 @@
/* $NetBSD: vnd.c,v 1.62 1999/11/17 09:34:03 fvdl Exp $ */
/* $NetBSD: vnd.c,v 1.63 2000/01/21 23:39:57 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -134,8 +134,6 @@ int dovndcluster = 1;
int vnddebug = 0x00;
#endif
#define b_cylin b_resid
#define vndunit(x) DISKUNIT(x)
struct vndxfer {
@ -183,20 +181,23 @@ void
vndattach(num)
int num;
{
int i;
char *mem;
register u_long size;
if (num <= 0)
return;
size = num * sizeof(struct vnd_softc);
mem = malloc(size, M_DEVBUF, M_NOWAIT);
i = num * sizeof(struct vnd_softc);
mem = malloc(i, M_DEVBUF, M_NOWAIT);
if (mem == NULL) {
printf("WARNING: no memory for vnode disks\n");
return;
}
bzero(mem, size);
bzero(mem, i);
vnd_softc = (struct vnd_softc *)mem;
numvnd = num;
for (i = 0; i < numvnd; i++)
BUFQ_INIT(&vnd_softc[i].sc_tab);
}
int
@ -472,7 +473,6 @@ vndstrategy(bp)
/*
* Just sort by block number
*/
nbp->vb_buf.b_cylin = nbp->vb_buf.b_blkno;
s = splbio();
if (vnx->vx_error != 0) {
VND_PUTBUF(vnd, nbp);
@ -480,7 +480,7 @@ vndstrategy(bp)
}
vnx->vx_pending++;
bgetvp(vp, &nbp->vb_buf);
disksort(&vnd->sc_tab, &nbp->vb_buf);
disksort_blkno(&vnd->sc_tab, &nbp->vb_buf);
vndstart(vnd);
splx(s);
bn += sz;
@ -528,12 +528,12 @@ vndstart(vnd)
vnd->sc_flags |= VNF_BUSY;
while (vnd->sc_tab.b_active < vnd->sc_maxactive) {
bp = vnd->sc_tab.b_actf;
while (vnd->sc_active < vnd->sc_maxactive) {
bp = BUFQ_FIRST(&vnd->sc_tab);
if (bp == NULL)
break;
vnd->sc_tab.b_actf = bp->b_actf;
vnd->sc_tab.b_active++;
BUFQ_REMOVE(&vnd->sc_tab, bp);
vnd->sc_active++;
#ifdef DEBUG
if (vnddebug & VDB_IO)
printf("vndstart(%ld): bp %p vp %p blkno 0x%x addr %p cnt 0x%lx\n",
@ -623,7 +623,7 @@ vndiodone(bp)
}
}
vnd->sc_tab.b_active--;
vnd->sc_active--;
vndstart(vnd);
splx(s);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: vndvar.h,v 1.4 1998/07/31 02:24:26 thorpej Exp $ */
/* $NetBSD: vndvar.h,v 1.5 2000/01/21 23:39:57 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -116,7 +116,8 @@ struct vnd_softc {
struct vnode *sc_vp; /* vnode */
struct ucred *sc_cred; /* credentials */
int sc_maxactive; /* max # of active requests */
struct buf sc_tab; /* transfer queue */
struct buf_queue sc_tab; /* transfer queue */
int sc_active; /* number of active transfers */
char sc_xname[8]; /* XXX external name */
struct disk sc_dkdev; /* generic disk device info */
struct vndgeom sc_geom; /* virtual geometry */