Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Conform bus_dmamem_{alloc, map} usage to bus_dma(9) specs.
details: https://anonhg.NetBSD.org/src/rev/05d85c52ce88
branches: trunk
changeset: 485964:05d85c52ce88
user: pk <pk%NetBSD.org@localhost>
date: Tue May 09 22:42:08 2000 +0000
description:
Conform bus_dmamem_{alloc,map} usage to bus_dma(9) specs.
diffstat:
sys/arch/sparc/dev/if_ie_obio.c | 62 ++++++++-----
sys/arch/sparc/dev/if_le_obio.c | 47 ++++++++--
sys/dev/ic/hme.c | 43 ++++++----
sys/dev/ic/hmevar.h | 3 +-
sys/dev/ic/i82586var.h | 4 +-
sys/dev/sbus/be.c | 27 +++++-
sys/dev/sbus/if_le.c | 41 +++++++--
sys/dev/sbus/if_le_ledma.c | 38 ++++++--
sys/dev/sbus/qe.c | 31 ++++++-
sys/dev/vme/xd.c | 170 +++++++++++++++++++++++++++------------
sys/dev/vme/xdvar.h | 4 +-
sys/dev/vme/xy.c | 168 +++++++++++++++++++++++++--------------
sys/dev/vme/xyvar.h | 34 ++++---
13 files changed, 460 insertions(+), 212 deletions(-)
diffs (truncated from 1192 to 300 lines):
diff -r d26ee4c7467e -r 05d85c52ce88 sys/arch/sparc/dev/if_ie_obio.c
--- a/sys/arch/sparc/dev/if_ie_obio.c Tue May 09 22:39:35 2000 +0000
+++ b/sys/arch/sparc/dev/if_ie_obio.c Tue May 09 22:42:08 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ie_obio.c,v 1.13 2000/01/11 12:59:46 pk Exp $ */
+/* $NetBSD: if_ie_obio.c,v 1.14 2000/05/09 22:42:08 pk Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -279,11 +279,14 @@
union obio_attach_args *uoba = aux;
struct obio4_attach_args *oba = &uoba->uoba_oba4;
struct ie_softc *sc = (void *) self;
+ bus_dma_tag_t dmatag = oba->oba_dmatag;
bus_space_handle_t bh;
bus_dma_segment_t seg;
int rseg;
+ int error;
paddr_t pa;
struct intrhand *ih;
+ bus_size_t msize;
u_long iebase;
u_int8_t myaddr[ETHER_ADDR_LEN];
extern void myetheraddr(u_char *); /* should be elsewhere */
@@ -298,7 +301,7 @@
sc->ie_bus_read16 = ie_obio_read16;
sc->ie_bus_write16 = ie_obio_write16;
sc->ie_bus_write24 = ie_obio_write24;
- sc->sc_msize = 65536; /* XXX */
+ sc->sc_msize = msize = 65536; /* XXX */
if (obio_bus_map(oba->oba_bustag, oba->oba_paddr,
0,
@@ -313,32 +316,42 @@
/*
* Allocate control & buffer memory.
*/
- if (bus_dmamem_alloc(oba->oba_dmatag, sc->sc_msize, 64*1024, 0,
+ if ((error = bus_dmamap_create(dmatag, msize, 1, msize, NBPG,
+ BUS_DMA_NOWAIT|BUS_DMA_24BIT,
+ &sc->sc_dmamap)) != 0) {
+ printf("%s: DMA map create error %d\n",
+ sc->sc_dev.dv_xname, error);
+ return;
+ }
+ if ((error = bus_dmamem_alloc(dmatag, msize, 64*1024, 0,
&seg, 1, &rseg,
- BUS_DMA_NOWAIT | BUS_DMA_24BIT) != 0) {
- printf("%s @ obio: DMA memory allocation error\n",
- self->dv_xname);
+ BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) {
+ printf("%s: DMA memory allocation error %d\n",
+ self->dv_xname, error);
return;
}
-#if 0
- if (bus_dmamem_map(oba->oba_dmatag, &seg, rseg, sc->sc_msize,
- (caddr_t *)&sc->sc_maddr,
- BUS_DMA_NOWAIT|BUS_DMA_COHERENT) != 0) {
- printf("%s @ obio: DMA memory map error\n", self->dv_xname);
- bus_dmamem_free(oba->oba_dmatag, &seg, rseg);
+
+ /* Map DMA buffer in CPU addressable space */
+ if ((error = bus_dmamem_map(dmatag, &seg, rseg, msize,
+ (caddr_t *)&sc->sc_maddr,
+ BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
+ printf("%s: DMA buffer map error %d\n",
+ sc->sc_dev.dv_xname, error);
+ bus_dmamem_free(dmatag, &seg, rseg);
return;
}
-#else
- /*
- * We happen to know we can use the DVMA address directly as
- * a CPU virtual address on machines where this driver can
- * attach (sun4's). So we possibly save a MMU resource
- * by not asking for a double mapping.
- */
- sc->sc_maddr = (void *)seg.ds_addr;
-#endif
- wzero(sc->sc_maddr, sc->sc_msize);
+ /* Load the segment */
+ if ((error = bus_dmamap_load_raw(dmatag, sc->sc_dmamap,
+ &seg, rseg, msize, BUS_DMA_NOWAIT)) != 0) {
+ printf("%s: DMA buffer map load error %d\n",
+ sc->sc_dev.dv_xname, error);
+ bus_dmamem_unmap(dmatag, sc->sc_maddr, msize);
+ bus_dmamem_free(dmatag, &seg, rseg);
+ return;
+ }
+
+ wzero(sc->sc_maddr, msize);
sc->bh = (bus_space_handle_t)(sc->sc_maddr);
/*
@@ -385,7 +398,8 @@
sc->scp = IE_SCP_ADDR & PGOFSET;
/* Calculate the 24-bit base of i82586 operations */
- iebase = (u_long)seg.ds_addr - (u_long)IEOB_ADBASE;
+ iebase = (u_long)sc->sc_dmamap->dm_segs[0].ds_addr -
+ (u_long)IEOB_ADBASE;
ie_obio_write16(sc, IE_ISCP_SCB(sc->iscp), sc->scb);
ie_obio_write24(sc, IE_ISCP_BASE(sc->iscp), iebase);
ie_obio_write24(sc, IE_SCP_ISCP(sc->scp), iebase + sc->iscp);
@@ -395,7 +409,7 @@
* are used for buffers.
*/
sc->buf_area = NBPG;
- sc->buf_area_sz = sc->sc_msize - NBPG;
+ sc->buf_area_sz = msize - NBPG;
if (i82586_proberam(sc) == 0) {
printf(": memory probe failed\n");
diff -r d26ee4c7467e -r 05d85c52ce88 sys/arch/sparc/dev/if_le_obio.c
--- a/sys/arch/sparc/dev/if_le_obio.c Tue May 09 22:39:35 2000 +0000
+++ b/sys/arch/sparc/dev/if_le_obio.c Tue May 09 22:42:08 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le_obio.c,v 1.6 2000/01/11 12:59:46 pk Exp $ */
+/* $NetBSD: if_le_obio.c,v 1.7 2000/05/09 22:42:08 pk Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -68,6 +68,7 @@
struct am7990_softc sc_am7990; /* glue to MI code */
bus_space_tag_t sc_bustag;
bus_dma_tag_t sc_dmatag;
+ bus_dmamap_t sc_dmamap;
bus_space_handle_t sc_reg; /* LANCE registers */
};
@@ -157,12 +158,14 @@
struct le_softc *lesc = (struct le_softc *)self;
struct lance_softc *sc = &lesc->sc_am7990.lsc;
bus_dma_segment_t seg;
+ bus_dma_tag_t dmatag;
int rseg;
+ int error;
/* XXX the following declarations should be elsewhere */
extern void myetheraddr __P((u_char *));
lesc->sc_bustag = oba->oba_bustag;
- lesc->sc_dmatag = oba->oba_dmatag;
+ lesc->sc_dmatag = dmatag = oba->oba_dmatag;
if (obio_bus_map(oba->oba_bustag, oba->oba_paddr,
0, 2 * sizeof(u_int16_t),
@@ -172,21 +175,43 @@
return;
}
- if (bus_dmamem_alloc(lesc->sc_dmatag, MEMSIZE, NBPG, 0,
- &seg, 1, &rseg,
- BUS_DMA_NOWAIT | BUS_DMA_24BIT) != 0) {
- printf("%s @ obio: DMA memory allocation error\n",
- self->dv_xname);
+ /* Get a DMA handle */
+ if ((error = bus_dmamap_create(dmatag, MEMSIZE, 1, MEMSIZE, 0,
+ BUS_DMA_NOWAIT|BUS_DMA_24BIT,
+ &lesc->sc_dmamap)) != 0) {
+ printf("%s: DMA map create error %d\n",
+ self->dv_xname, error);
return;
}
- if (bus_dmamem_map(lesc->sc_dmatag, &seg, rseg, MEMSIZE,
+
+ /* Allocate DMA buffer */
+ if ((error = bus_dmamem_alloc(dmatag, MEMSIZE, NBPG, 0,
+ &seg, 1, &rseg,
+ BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) {
+ printf("%s: DMA memory allocation error %d\n",
+ self->dv_xname, error);
+ return;
+ }
+ /* Map DMA buffer into kernel space */
+ if ((error = bus_dmamem_map(dmatag, &seg, rseg, MEMSIZE,
(caddr_t *)&sc->sc_mem,
- BUS_DMA_NOWAIT|BUS_DMA_COHERENT) != 0) {
- printf("%s @ obio: DMA memory map error\n", self->dv_xname);
+ BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
+ printf("%s: DMA memory map error %d\n", self->dv_xname, error);
bus_dmamem_free(lesc->sc_dmatag, &seg, rseg);
return;
}
- sc->sc_addr = seg.ds_addr & 0xffffff;
+ /* Load DMA buffer */
+ if ((error = bus_dmamap_load_raw(dmatag, lesc->sc_dmamap,
+ &seg, rseg,
+ MEMSIZE, BUS_DMA_NOWAIT)) != 0) {
+ printf("%s: DMA buffer map load error %d\n",
+ self->dv_xname, error);
+ bus_dmamem_unmap(dmatag, (caddr_t)sc->sc_mem, MEMSIZE);
+ bus_dmamem_free(dmatag, &seg, rseg);
+ return;
+ }
+
+ sc->sc_addr = lesc->sc_dmamap->dm_segs[0].ds_addr & 0xffffff;
sc->sc_memsize = MEMSIZE;
sc->sc_conf3 = LE_C3_BSWP | LE_C3_ACON | LE_C3_BCON;
diff -r d26ee4c7467e -r 05d85c52ce88 sys/dev/ic/hme.c
--- a/sys/dev/ic/hme.c Tue May 09 22:39:35 2000 +0000
+++ b/sys/dev/ic/hme.c Tue May 09 22:42:08 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hme.c,v 1.10 2000/04/05 05:54:02 mrg Exp $ */
+/* $NetBSD: hme.c,v 1.11 2000/05/09 22:51:33 pk Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -134,6 +134,7 @@
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
struct mii_data *mii = &sc->sc_mii;
struct mii_softc *child;
+ bus_dma_tag_t dmatag = sc->sc_dmatag;
bus_dma_segment_t seg;
bus_size_t size;
int rseg, error;
@@ -200,36 +201,44 @@
2048 + /* RX descriptors */
sc->sc_rb.rb_ntbuf * _HME_BUFSZ + /* TX buffers */
sc->sc_rb.rb_nrbuf * _HME_BUFSZ; /* TX buffers */
- if ((error = bus_dmamem_alloc(sc->sc_dmatag, size,
+
+ if ((error = bus_dmamap_create(dmatag, size, 1, size, NBPG,
+ BUS_DMA_NOWAIT, &sc->sc_dmamap)) != 0) {
+ printf("%s: DMA map create error %d\n",
+ sc->sc_dev.dv_xname, error);
+ return;
+ }
+
+ /* Allocate DMA buffer */
+ if ((error = bus_dmamem_alloc(dmatag, size,
2048, 0,
&seg, 1, &rseg, BUS_DMA_NOWAIT)) != 0) {
printf("%s: DMA buffer alloc error %d\n",
sc->sc_dev.dv_xname, error);
return;
}
- sc->sc_rb.rb_dmabase = seg.ds_addr;
- /* Map DMA memory in CPU adressable space */
- if ((error = bus_dmamem_map(sc->sc_dmatag, &seg, rseg, size,
+ /* Load the buffer */
+ if ((error = bus_dmamap_load_raw(dmatag, sc->sc_dmamap,
+ &seg, rseg, size, BUS_DMA_NOWAIT)) != 0) {
+ printf("%s: DMA buffer map load error %d\n",
+ sc->sc_dev.dv_xname, error);
+ bus_dmamem_free(dmatag, &seg, rseg);
+ return;
+ }
+ sc->sc_rb.rb_dmabase = sc->sc_dmamap->dm_segs[0].ds_addr;
+
+ /* Map DMA memory in CPU addressable space */
+ if ((error = bus_dmamem_map(dmatag, &seg, rseg, size,
&sc->sc_rb.rb_membase,
BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
printf("%s: DMA buffer map error %d\n",
sc->sc_dev.dv_xname, error);
- bus_dmamem_free(sc->sc_dmatag, &seg, rseg);
+ bus_dmamap_unload(dmatag, sc->sc_dmamap);
+ bus_dmamem_free(dmatag, &seg, rseg);
return;
}
-#if 0
- /*
- * Install default copy routines if not supplied.
- */
- if (sc->sc_copytobuf == NULL)
- sc->sc_copytobuf = hme_copytobuf_contig;
-
- if (sc->sc_copyfrombuf == NULL)
- sc->sc_copyfrombuf = hme_copyfrombuf_contig;
-#endif
-
printf(": address %s\n", ether_sprintf(sc->sc_enaddr));
/* Initialize ifnet structure. */
diff -r d26ee4c7467e -r 05d85c52ce88 sys/dev/ic/hmevar.h
--- a/sys/dev/ic/hmevar.h Tue May 09 22:39:35 2000 +0000
+++ b/sys/dev/ic/hmevar.h Tue May 09 22:42:08 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hmevar.h,v 1.3 2000/03/23 07:01:30 thorpej Exp $ */
+/* $NetBSD: hmevar.h,v 1.4 2000/05/09 22:51:34 pk Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -73,6 +73,7 @@
/* The following bus handles are to be provided by the bus front-end */
bus_space_tag_t sc_bustag; /* bus tag */
bus_dma_tag_t sc_dmatag; /* bus dma tag */
+ bus_dmamap_t sc_dmamap; /* bus dma handle */
bus_space_handle_t sc_seb; /* HME Global registers */
bus_space_handle_t sc_erx; /* HME ERX registers */
bus_space_handle_t sc_etx; /* HME ETX registers */
diff -r d26ee4c7467e -r 05d85c52ce88 sys/dev/ic/i82586var.h
--- a/sys/dev/ic/i82586var.h Tue May 09 22:39:35 2000 +0000
+++ b/sys/dev/ic/i82586var.h Tue May 09 22:42:08 2000 +0000
@@ -1,4 +1,4 @@
Home |
Main Index |
Thread Index |
Old Index