Do a bit of spring cleaning.

This commit is contained in:
thorpej 1997-05-05 21:02:39 +00:00
parent 82cab4fef4
commit 73b24faec6
2 changed files with 25 additions and 27 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dma.c,v 1.18 1997/04/27 21:02:34 thorpej Exp $ */ /* $NetBSD: dma.c,v 1.19 1997/05/05 21:02:39 thorpej Exp $ */
/* /*
* Copyright (c) 1995, 1996, 1997 * Copyright (c) 1995, 1996, 1997
@ -72,7 +72,6 @@ struct dma_chain {
struct dma_channel { struct dma_channel {
struct dmaqueue *dm_job; /* current job */ struct dmaqueue *dm_job; /* current job */
struct dma_softc *dm_softc; /* pointer back to softc */
struct dmadevice *dm_hwaddr; /* registers if DMA_C */ struct dmadevice *dm_hwaddr; /* registers if DMA_C */
struct dmaBdevice *dm_Bhwaddr; /* registers if not DMA_C */ struct dmaBdevice *dm_Bhwaddr; /* registers if not DMA_C */
char dm_flags; /* misc. flags */ char dm_flags; /* misc. flags */
@ -83,14 +82,13 @@ struct dma_channel {
}; };
struct dma_softc { struct dma_softc {
char *sc_xname; /* XXX external name */
struct dmareg *sc_dmareg; /* pointer to our hardware */ struct dmareg *sc_dmareg; /* pointer to our hardware */
struct dma_channel sc_chan[NDMACHAN]; /* 2 channels */ struct dma_channel sc_chan[NDMACHAN]; /* 2 channels */
TAILQ_HEAD(, dmaqueue) sc_queue; /* job queue */ TAILQ_HEAD(, dmaqueue) sc_queue; /* job queue */
char sc_type; /* A, B, or C */ char sc_type; /* A, B, or C */
int sc_ipl; /* our interrupt level */ int sc_ipl; /* our interrupt level */
void *sc_ih; /* interrupt cookie */ void *sc_ih; /* interrupt cookie */
} Dma_softc; } dma_softc;
/* types */ /* types */
#define DMA_B 0 #define DMA_B 0
@ -120,10 +118,13 @@ long dmaword[NDMACHAN];
long dmalword[NDMACHAN]; long dmalword[NDMACHAN];
#endif #endif
/*
* Initialize the DMA engine, called by dioattach()
*/
void void
dmainit() dmainit()
{ {
struct dma_softc *sc = &Dma_softc; struct dma_softc *sc = &dma_softc;
struct dmareg *dma; struct dmareg *dma;
struct dma_channel *dc; struct dma_channel *dc;
int i; int i;
@ -132,7 +133,6 @@ dmainit()
/* There's just one. */ /* There's just one. */
sc->sc_dmareg = (struct dmareg *)DMA_BASE; sc->sc_dmareg = (struct dmareg *)DMA_BASE;
dma = sc->sc_dmareg; dma = sc->sc_dmareg;
sc->sc_xname = "dma0";
/* /*
* Determine the DMA type. A DMA_A or DMA_B will fail the * Determine the DMA type. A DMA_A or DMA_B will fail the
@ -156,7 +156,6 @@ dmainit()
for (i = 0; i < NDMACHAN; i++) { for (i = 0; i < NDMACHAN; i++) {
dc = &sc->sc_chan[i]; dc = &sc->sc_chan[i];
dc->dm_softc = sc;
dc->dm_job = NULL; dc->dm_job = NULL;
switch (i) { switch (i) {
case 0: case 0:
@ -180,7 +179,7 @@ dmainit()
timeout(dmatimeout, sc, 30 * hz); timeout(dmatimeout, sc, 30 * hz);
#endif #endif
printf("%s: 98620%c, 2 channels, %d bit\n", sc->sc_xname, printf("98620%c, 2 channels, %d bit DMA\n",
rev, (rev == 'B') ? 16 : 32); rev, (rev == 'B') ? 16 : 32);
/* /*
@ -197,7 +196,7 @@ dmainit()
void void
dmacomputeipl() dmacomputeipl()
{ {
struct dma_softc *sc = &Dma_softc; struct dma_softc *sc = &dma_softc;
if (sc->sc_ih != NULL) if (sc->sc_ih != NULL)
intr_disestablish(sc->sc_ih); intr_disestablish(sc->sc_ih);
@ -214,7 +213,7 @@ int
dmareq(dq) dmareq(dq)
struct dmaqueue *dq; struct dmaqueue *dq;
{ {
struct dma_softc *sc = &Dma_softc; struct dma_softc *sc = &dma_softc;
int i, chan, s; int i, chan, s;
#if 1 #if 1
@ -259,7 +258,7 @@ dmafree(dq)
struct dmaqueue *dq; struct dmaqueue *dq;
{ {
int unit = dq->dq_chan; int unit = dq->dq_chan;
struct dma_softc *sc = &Dma_softc; struct dma_softc *sc = &dma_softc;
struct dma_channel *dc = &sc->sc_chan[unit]; struct dma_channel *dc = &sc->sc_chan[unit];
struct dmaqueue *dn; struct dmaqueue *dn;
int chan, s; int chan, s;
@ -332,7 +331,7 @@ dmago(unit, addr, count, flags)
int count; int count;
int flags; int flags;
{ {
struct dma_softc *sc = &Dma_softc; struct dma_softc *sc = &dma_softc;
struct dma_channel *dc = &sc->sc_chan[unit]; struct dma_channel *dc = &sc->sc_chan[unit];
char *dmaend = NULL; char *dmaend = NULL;
int seg, tcount; int seg, tcount;
@ -469,14 +468,14 @@ dmago(unit, addr, count, flags)
} }
dmatimo[unit] = 1; dmatimo[unit] = 1;
#endif #endif
DMA_ARM(dc); DMA_ARM(sc, dc);
} }
void void
dmastop(unit) dmastop(unit)
int unit; int unit;
{ {
struct dma_softc *sc = &Dma_softc; struct dma_softc *sc = &dma_softc;
struct dma_channel *dc = &sc->sc_chan[unit]; struct dma_channel *dc = &sc->sc_chan[unit];
#ifdef DEBUG #ifdef DEBUG
@ -545,8 +544,7 @@ dmaintr(arg)
dc->dm_flags, i, stat, dc->dm_cur + 1); dc->dm_flags, i, stat, dc->dm_cur + 1);
} }
if (stat & DMA_ARMED) if (stat & DMA_ARMED)
printf("%s, chan %d: intr when armed\n", printf("dma channel %d: intr when armed\n", i);
sc->sc_xname, i);
#endif #endif
/* /*
* Load the next segemnt, or finish up if we're done. * Load the next segemnt, or finish up if we're done.
@ -564,7 +562,7 @@ dmaintr(arg)
(dc->dm_flags & DMAF_NOINTR)) (dc->dm_flags & DMAF_NOINTR))
dc->dm_cmd &= ~DMA_ENAB; dc->dm_cmd &= ~DMA_ENAB;
DMA_CLEAR(dc); DMA_CLEAR(dc);
DMA_ARM(dc); DMA_ARM(sc, dc);
} else } else
dmastop(i); dmastop(i);
} }
@ -583,8 +581,8 @@ dmatimeout(arg)
s = splbio(); s = splbio();
if (dmatimo[i]) { if (dmatimo[i]) {
if (dmatimo[i] > 1) if (dmatimo[i] > 1)
printf("%s: chan %d timeout #%d\n", printf("dma channel %d timeout #%d\n",
sc->sc_xname, i, dmatimo[i]-1); i, dmatimo[i]-1);
dmatimo[i]++; dmatimo[i]++;
} }
splx(s); splx(s);

View File

@ -1,4 +1,4 @@
/* $NetBSD: dmareg.h,v 1.11 1997/04/27 20:58:56 thorpej Exp $ */ /* $NetBSD: dmareg.h,v 1.12 1997/05/05 21:02:40 thorpej Exp $ */
/* /*
* Copyright (c) 1982, 1990, 1993 * Copyright (c) 1982, 1990, 1993
@ -116,8 +116,8 @@ struct dmareg {
#define DMA_STAT(dc) dc->dm_Bhwaddr->dmaB_stat #define DMA_STAT(dc) dc->dm_Bhwaddr->dmaB_stat
#if defined(HP320) #if defined(HP320)
#define DMA_ARM(dc) \ #define DMA_ARM(sc, dc) \
if (dc->dm_softc->sc_type == DMA_B) { \ if (sc->sc_type == DMA_B) { \
struct dmaBdevice *dma = dc->dm_Bhwaddr; \ struct dmaBdevice *dma = dc->dm_Bhwaddr; \
dma->dmaB_addr = dc->dm_chain[dc->dm_cur].dc_addr; \ dma->dmaB_addr = dc->dm_chain[dc->dm_cur].dc_addr; \
dma->dmaB_count = dc->dm_chain[dc->dm_cur].dc_count - 1; \ dma->dmaB_count = dc->dm_chain[dc->dm_cur].dc_count - 1; \
@ -129,7 +129,7 @@ struct dmareg {
dma->dma_cmd = dc->dm_cmd; \ dma->dma_cmd = dc->dm_cmd; \
} }
#else #else
#define DMA_ARM(dc) \ #define DMA_ARM(sc, dc) \
{ \ { \
struct dmadevice *dma = dc->dm_hwaddr; \ struct dmadevice *dma = dc->dm_hwaddr; \
dma->dma_addr = dc->dm_chain[dc->dm_cur].dc_addr; \ dma->dma_addr = dc->dm_chain[dc->dm_cur].dc_addr; \