[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OpenBSD under VMWare on Linux



Here is a patch.  Please try it.

Date: Wed, 31 Jan 2001 08:55:59 -0800 (PST)
From: Thorsten Lockert <tholo@sigmasoft.com>
Message-Id: <200101311655.f0VGtx820442@gandalf.sigmasoft.com>
To: deraadt@openbsd.org
Subject: /sys/dev/pci/if_le_pci.c diff, KNF, better

Index: if_le_pci.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_le_pci.c,v
retrieving revision 1.12
diff -u -r1.12 if_le_pci.c
--- if_le_pci.c	1999/08/10 08:10:35	1.12
+++ if_le_pci.c	2001/01/31 16:46:00
@@ -160,8 +160,11 @@
 	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 @@
 	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 @@
 
 	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;
Index: if_levar.h
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_levar.h,v
retrieving revision 1.4
diff -u -r1.4 if_levar.h
--- if_levar.h	1997/11/07 08:07:29	1.4
+++ if_levar.h	2001/01/31 16:46:00
@@ -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,


--7JfCtLOvnd9MIVvH--