summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>2001-01-31 23:05:18 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>2001-01-31 23:05:18 +0000
commitaf7194e9a1e27a135acd49055ab325f9229e8eec (patch)
treee96660288f74902e1f61338867a4fad5127983e1 /sys/dev/pci
parent2c0395e8c2b8f89db46e02886375cfae6ff1d28a (diff)
Allocate shared memory via the bus_dmamem/bus_dmamap interface; makes le
interface work under VMware as an additional bonus. ok theo@
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/if_le_pci.c36
-rw-r--r--sys/dev/pci/if_levar.h14
2 files changed, 44 insertions, 6 deletions
diff --git a/sys/dev/pci/if_le_pci.c b/sys/dev/pci/if_le_pci.c
index ac2bac39478..d940fbdef81 100644
--- a/sys/dev/pci/if_le_pci.c
+++ b/sys/dev/pci/if_le_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_le_pci.c,v 1.12 1999/08/10 08:10:35 deraadt Exp $ */
+/* $OpenBSD: if_le_pci.c,v 1.13 2001/01/31 23:05:17 tholo Exp $ */
/* $NetBSD: if_le_pci.c,v 1.13 1996/10/25 21:33:32 cgd Exp $ */
/*-
@@ -160,8 +160,11 @@ le_pci_attach(parent, self, aux)
bus_space_tag_t iot = pa->pa_iot;
pci_chipset_tag_t pc = pa->pa_pc;
pcireg_t csr;
- int i;
+ int i, rseg;
const char *intrstr;
+ bus_dma_segment_t seg;
+ bus_dmamap_t dmamap;
+ caddr_t kva;
switch (PCI_PRODUCT(pa->pa_id)) {
case PCI_PRODUCT_AMD_PCNET_PCI:
@@ -185,11 +188,34 @@ le_pci_attach(parent, self, aux)
for (i = 0; i < sizeof(sc->sc_arpcom.ac_enaddr); i++)
sc->sc_arpcom.ac_enaddr[i] = bus_space_read_1(iot, ioh, i);
- sc->sc_mem = malloc(16384, M_DEVBUF, M_NOWAIT);
- if (sc->sc_mem == 0) {
+ if (bus_dmamem_alloc(pa->pa_dmat, PCNET_MEMSIZE, PAGE_SIZE,
+ 0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) {
printf(": couldn't allocate memory for card\n");
return;
}
+ if (bus_dmamem_map(pa->pa_dmat, &seg, rseg, PCNET_MEMSIZE,
+ &kva, BUS_DMA_NOWAIT)) {
+ printf(": couldn't map memory for card\n");
+ bus_dmamem_free(pa->pa_dmat, &seg, rseg);
+ return;
+ }
+ if (bus_dmamap_create(pa->pa_dmat, PCNET_MEMSIZE, 1, 36384,
+ 0, BUS_DMA_NOWAIT, &dmamap)) {
+ printf(": couldn't create dma map\n");
+ bus_dmamem_unmap(pa->pa_dmat, kva, PCNET_MEMSIZE);
+ bus_dmamem_free(pa->pa_dmat, &seg, rseg);
+ return;
+ }
+ if (bus_dmamap_load(pa->pa_dmat, dmamap, kva, PCNET_MEMSIZE,
+ NULL, BUS_DMA_NOWAIT)) {
+ printf(": couldn't load dma map\n");
+ bus_dmamap_destroy(pa->pa_dmat, dmamap);
+ bus_dmamem_unmap(pa->pa_dmat, kva, PCNET_MEMSIZE);
+ bus_dmamem_free(pa->pa_dmat, &seg, rseg);
+ return;
+ }
+ sc->sc_mem = kva;
+ bzero(sc->sc_mem, PCNET_MEMSIZE);
printf("\n");
@@ -198,7 +224,7 @@ le_pci_attach(parent, self, aux)
sc->sc_conf3 = 0;
sc->sc_addr = vtophys(sc->sc_mem); /* XXX XXX XXX */
- sc->sc_memsize = 16384;
+ sc->sc_memsize = PCNET_MEMSIZE;
sc->sc_copytodesc = am7990_copytobuf_contig;
sc->sc_copyfromdesc = am7990_copyfrombuf_contig;
diff --git a/sys/dev/pci/if_levar.h b/sys/dev/pci/if_levar.h
index 59e1b7f338d..01c5e1ad1f8 100644
--- a/sys/dev/pci/if_levar.h
+++ b/sys/dev/pci/if_levar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_levar.h,v 1.4 1997/11/07 08:07:29 niklas Exp $ */
+/* $OpenBSD: if_levar.h,v 1.5 2001/01/31 23:05:17 tholo Exp $ */
/* $NetBSD: if_levar.h,v 1.3 1996/10/21 22:56:46 thorpej Exp $ */
/*
@@ -18,6 +18,18 @@
#define PCNET_PCI_RAP 0x12
/*
+ * Size of packet buffer
+ *
+ * The MI code will split this between initialization block, descriptors,
+ * transmit and receive buffers.
+ *
+ * Must be 8192 <= PCNET_MEMSIZE <= 262144 and a power of 2
+ */
+
+#define PCNET_MEMSIZE 16384
+
+
+/*
* Ethernet software status per interface.
*
* Each interface is referenced by a network interface structure,