Source-Changes-HG archive

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

[src/trunk]: src/sys Use bus_dmamap_load() to obtain 128KB chunk for LANCE me...



details:   https://anonhg.NetBSD.org/src/rev/05dd4323c5bc
branches:  trunk
changeset: 476188:05dd4323c5bc
user:      nisimura <nisimura%NetBSD.org@localhost>
date:      Thu Sep 09 06:33:38 1999 +0000

description:
Use bus_dmamap_load() to obtain 128KB chunk for LANCE merging codes from
NetBSD/alpha.  Tested ok with DEC3000 and DECstation.

diffstat:

 sys/arch/pmax/pmax/machdep.c |   31 +------------
 sys/dev/tc/files.tc          |    4 +-
 sys/dev/tc/if_le_ioasic.c    |  100 ++++++++++++++++++++++++++++++++++--------
 sys/dev/tc/ioasicvar.h       |    6 +--
 4 files changed, 85 insertions(+), 56 deletions(-)

diffs (251 lines):

diff -r 59ac5d95c1af -r 05dd4323c5bc sys/arch/pmax/pmax/machdep.c
--- a/sys/arch/pmax/pmax/machdep.c      Thu Sep 09 06:30:10 1999 +0000
+++ b/sys/arch/pmax/pmax/machdep.c      Thu Sep 09 06:33:38 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.148 1999/06/26 17:03:48 simonb Exp $     */
+/*     $NetBSD: machdep.c,v 1.149 1999/09/09 06:33:38 nisimura Exp $   */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -43,13 +43,12 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.148 1999/06/26 17:03:48 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.149 1999/09/09 06:33:38 nisimura Exp $");
 
 /* from: Utah Hdr: machdep.c 1.63 91/04/24 */
 
 #include "fs_mfs.h"
 #include "opt_ddb.h"
-#include "le_ioasic.h"         /* XXX will go XXX */
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -137,7 +136,6 @@
 int    initcpu __P((void));
 
 /* XXX XXX XXX */
-u_long le_iomem;               /* 128K for lance chip via. ASIC */
 
 /* Old 4.4bsd/pmax-derived interrupt-enable method */
 
@@ -577,31 +575,6 @@
         * Set up CPU-specific registers, cache, etc.
         */
        initcpu();
-
-       /*
-        * XXX THE FOLLOWING SECTION NEEDS TO BE REPLACED
-        * XXX WITH BUS_DMA(9).
-        * XXXXXX Huh?  BUS_DMA(9)  doesnt support  gap16 lance copy buffers.
-        * XXXXXX We use the copy suport  in am7990 instead.
-        */
-
-#if NLE_IOASIC > 0
-       /*
-        * Steal 128k of memory for the LANCE chip on machine where
-        * it does DMA through the IOCTL ASIC.  It must be physically
-        * contiguous and aligned on a 128k boundary.
-        */
-       {
-               extern paddr_t avail_start, avail_end;
-               struct pglist mlist;
-
-               TAILQ_INIT(&mlist);
-               if (uvm_pglistalloc(128 * 1024, avail_start,
-                   avail_end - PAGE_SIZE, 128 * 1024, 0, &mlist, 1, FALSE))
-                       panic("startup: unable to steal LANCE DMA area");
-               le_iomem = VM_PAGE_TO_PHYS(mlist.tqh_first);
-       }
-#endif /* NLE_IOASIC */
 }
 
 
diff -r 59ac5d95c1af -r 05dd4323c5bc sys/dev/tc/files.tc
--- a/sys/dev/tc/files.tc       Thu Sep 09 06:30:10 1999 +0000
+++ b/sys/dev/tc/files.tc       Thu Sep 09 06:33:38 1999 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.tc,v 1.16 1999/04/13 19:06:54 ad Exp $
+#      $NetBSD: files.tc,v 1.17 1999/09/09 06:33:38 nisimura Exp $
 #
 # Config file and device description for machine-independent
 # TurboChannel code.  Included by ports that need it.
@@ -21,7 +21,7 @@
 attach le at ioasic with le_ioasic:    le24, le_dec_subr
 attach le at tc with le_tc:            le24, le_dec_subr
 
-file   dev/tc/if_le_ioasic.c           le_ioasic needs-flag # for le_iomem
+file   dev/tc/if_le_ioasic.c           le_ioasic
 file   dev/tc/if_le_tc.c               le_tc
 
 # ioasic audio
diff -r 59ac5d95c1af -r 05dd4323c5bc sys/dev/tc/if_le_ioasic.c
--- a/sys/dev/tc/if_le_ioasic.c Thu Sep 09 06:30:10 1999 +0000
+++ b/sys/dev/tc/if_le_ioasic.c Thu Sep 09 06:33:38 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_le_ioasic.c,v 1.12 1998/07/21 17:36:07 drochner Exp $       */
+/*     $NetBSD: if_le_ioasic.c,v 1.13 1999/09/09 06:33:38 nisimura Exp $       */
 
 /*
  * Copyright (c) 1996 Carnegie-Mellon University.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>                 /* RCS ID &  macro defns */
-__KERNEL_RCSID(0, "$NetBSD: if_le_ioasic.c,v 1.12 1998/07/21 17:36:07 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_ioasic.c,v 1.13 1999/09/09 06:33:38 nisimura Exp $");
 
 #include "opt_inet.h"
 
@@ -59,17 +59,24 @@
 
 #include <dev/tc/if_levar.h>
 #include <dev/tc/tcvar.h>
+#include <dev/tc/ioasicreg.h>
 #include <dev/tc/ioasicvar.h>
 
-extern caddr_t le_iomem;
-
-int    le_ioasic_match __P((struct device *, struct cfdata *, void *));
-void   le_ioasic_attach __P((struct device *, struct device *, void *));
-
 #if defined(_KERNEL) && !defined(_LKM)
 #include "opt_ddb.h"
 #endif
 
+caddr_t le_iomem;
+
+static int  le_ioasic_match __P((struct device *, struct cfdata *, void *));
+static void le_ioasic_attach __P((struct device *, struct device *, void *));
+
+struct cfattach le_ioasic_ca = {
+       sizeof(struct le_softc), le_ioasic_match, le_ioasic_attach
+};
+
+static void ioasic_lance_dma_setup __P((struct device *));
+
 #ifdef DDB
 #define        integrate
 #define hide
@@ -89,10 +96,6 @@
            int, int));
 hide void le_ioasic_zerobuf_gap16 __P((struct lance_softc *, int, int));
 
-struct cfattach le_ioasic_ca = {
-       sizeof(struct le_softc), le_ioasic_match, le_ioasic_attach
-};
-
 int
 le_ioasic_match(parent, match, aux)
        struct device *parent;
@@ -118,6 +121,13 @@
        register struct le_softc *lesc = (void *)self;
        register struct lance_softc *sc = &lesc->sc_am7990.lsc;
 
+       ioasic_lance_dma_setup(parent);
+
+       if (le_iomem == 0) {
+               printf("%s: DMA area not set up\n", sc->sc_dev.dv_xname);
+               return;
+       }
+
        lesc->sc_r1 = (struct lereg1 *)
                TC_DENSE_TO_SPARSE(TC_PHYS_TO_UNCACHED(d->iada_addr));
        sc->sc_mem = (void *)TC_PHYS_TO_UNCACHED(le_iomem);
@@ -128,15 +138,6 @@
        sc->sc_copyfrombuf = le_ioasic_copyfrombuf_gap16;
        sc->sc_zerobuf = le_ioasic_zerobuf_gap16;
 
-       if (le_iomem == 0) {
-               printf("%s: DMA area not set up\n", sc->sc_dev.dv_xname);
-               return;
-       }
-
-#ifndef __alpha__
-       ioasic_lance_dma_setup(le_iomem);       /* XXX more thought */
-#endif
-
        dec_le_common_attach(&lesc->sc_am7990, ioasic_lance_ether_address());
 
        ioasic_intr_establish(parent, d->iada_cookie, TC_IPL_NET,
@@ -401,3 +402,62 @@
                xfer = min(len, 16);
        }
 }
+
+#define        LE_IOASIC_MEMSIZE       (128*1024)
+#define        LE_IOASIC_MEMALIGN      (128*1024)
+
+void
+ioasic_lance_dma_setup(parent)
+       struct device *parent;
+{
+       struct ioasic_softc *sc = (void *)parent;
+       bus_dma_tag_t dmat = sc->sc_dmat;
+       bus_dma_segment_t seg;
+       tc_addr_t tca;
+       int rseg;
+
+       /*
+        * Allocate a DMA area for the chip.
+        */
+       if (bus_dmamem_alloc(dmat, LE_IOASIC_MEMSIZE, LE_IOASIC_MEMALIGN,
+           0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) {
+               printf("%s: can't allocate DMA area for LANCE\n",
+                   sc->sc_dv.dv_xname);
+               return;
+       }
+       if (bus_dmamem_map(dmat, &seg, rseg, LE_IOASIC_MEMSIZE,
+           &le_iomem, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) {
+               printf("%s: can't map DMA area for LANCE\n",
+                   sc->sc_dv.dv_xname);
+               bus_dmamem_free(dmat, &seg, rseg);
+               return;
+       }
+
+       /*
+        * Create and load the DMA map for the DMA area.
+        */
+       if (bus_dmamap_create(dmat, LE_IOASIC_MEMSIZE, 1,
+           LE_IOASIC_MEMSIZE, 0, BUS_DMA_NOWAIT, &sc->sc_lance_dmam)) {
+               printf("%s: can't create DMA map\n", sc->sc_dv.dv_xname);
+               goto bad;
+       }
+       if (bus_dmamap_load(dmat, sc->sc_lance_dmam,
+           le_iomem, LE_IOASIC_MEMSIZE, NULL, BUS_DMA_NOWAIT)) {
+               printf("%s: can't load DMA map\n", sc->sc_dv.dv_xname);
+               goto bad;
+       }
+
+       tca = (tc_addr_t)sc->sc_lance_dmam->dm_segs[0].ds_addr;
+       *(u_int32_t *)(ioasic_base + IOASIC_LANCE_DMAPTR)
+               = ((tca << 3) & ~(tc_addr_t)0x1f) | ((tca >> 29) & 0x1f);
+       tc_wmb();
+
+       *(u_int32_t *)(ioasic_base + IOASIC_CSR) |= IOASIC_CSR_DMAEN_LANCE;
+       tc_wmb();
+       return;
+
+ bad:
+       bus_dmamem_unmap(dmat, le_iomem, LE_IOASIC_MEMSIZE);
+       bus_dmamem_free(dmat, &seg, rseg);
+       le_iomem = 0;
+}
diff -r 59ac5d95c1af -r 05dd4323c5bc sys/dev/tc/ioasicvar.h
--- a/sys/dev/tc/ioasicvar.h    Thu Sep 09 06:30:10 1999 +0000
+++ b/sys/dev/tc/ioasicvar.h    Thu Sep 09 06:33:38 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ioasicvar.h,v 1.8 1999/03/28 17:47:28 drochner Exp $   */
+/*     $NetBSD: ioasicvar.h,v 1.9 1999/09/09 06:33:38 nisimura Exp $   */
 
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
@@ -89,7 +89,3 @@
 char   *ioasic_lance_ether_address __P((void));
 void   ioasic_attach_devs __P((struct ioasic_softc *sc, 
            struct ioasic_dev *ioasic_devs, int ioasic_ndevs));
-
-#ifndef alpha
-void   ioasic_lance_dma_setup __P((void *));
-#endif



Home | Main Index | Thread Index | Old Index