Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sun2/sun2 Added support for creating a bus_dma tag ...



details:   https://anonhg.NetBSD.org/src/rev/56b907ce8cfc
branches:  trunk
changeset: 508703:56b907ce8cfc
user:      fredette <fredette%NetBSD.org@localhost>
date:      Wed Apr 18 03:34:54 2001 +0000

description:
Added support for creating a bus_dma tag for the mbmem bus.

diffstat:

 sys/arch/sun2/sun2/mbmem.c |  50 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 49 insertions(+), 1 deletions(-)

diffs (98 lines):

diff -r f51af398fd29 -r 56b907ce8cfc sys/arch/sun2/sun2/mbmem.c
--- a/sys/arch/sun2/sun2/mbmem.c        Wed Apr 18 03:30:14 2001 +0000
+++ b/sys/arch/sun2/sun2/mbmem.c        Wed Apr 18 03:34:54 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mbmem.c,v 1.2 2001/04/10 12:37:49 fredette Exp $       */
+/*     $NetBSD: mbmem.c,v 1.3 2001/04/18 03:34:54 fredette Exp $       */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -42,8 +42,10 @@
 
 #include <uvm/uvm_extern.h>
 
+#define _SUN2_BUS_DMA_PRIVATE
 #include <machine/autoconf.h>
 #include <machine/pmap.h>
+#include <machine/dvma.h>
 
 #include <sun2/sun2/control.h>
 #include <sun2/sun2/machdep.h>
@@ -74,6 +76,10 @@
 static int _mbmem_bus_map __P((bus_space_tag_t, bus_type_t, bus_addr_t,
                               bus_size_t, int,
                               vaddr_t, bus_space_handle_t *));
+static int mbmem_dmamap_load __P((bus_dma_tag_t, bus_dmamap_t, void *,
+                               bus_size_t, struct proc *, int));
+static int mbmem_dmamap_load_raw __P((bus_dma_tag_t, bus_dmamap_t,
+                                   bus_dma_segment_t *, int, bus_size_t, int));
 
 static struct sun2_bus_space_tag mbmem_space_tag = {
        NULL,                           /* cookie */
@@ -86,6 +92,8 @@
        NULL                            /* bus_intr_establish */
 }; 
 
+static struct sun2_bus_dma_tag mbmem_dma_tag;
+
 static int
 mbmem_match(parent, cf, aux)
        struct device *parent;
@@ -127,6 +135,11 @@
        mbmem_space_tag.cookie = sc;
        mbmem_space_tag.parent = sc->sc_bustag;
 
+       mbmem_dma_tag = *sc->sc_dmatag;
+       mbmem_dma_tag._cookie = sc;
+       mbmem_dma_tag._dmamap_load = mbmem_dmamap_load;
+       mbmem_dma_tag._dmamap_load_raw = mbmem_dmamap_load_raw;
+
        /*
         * Prepare the skeleton attach arguments for our devices.
         * The values we give in the locators are indications to
@@ -135,6 +148,7 @@
         */
        sub_ca = *ca;
        sub_ca.ca_bustag = &mbmem_space_tag;
+       sub_ca.ca_dmatag = &mbmem_dma_tag;
        sub_ca.ca_intpri = LOCATOR_OPTIONAL;
        sub_ca.ca_intvec = LOCATOR_FORBIDDEN;
 
@@ -180,3 +194,37 @@
 
        return (bus_space_mmap(sc->sc_bustag, PMAP_MBMEM, paddr, flags, hp));
 }
+
+static int
+mbmem_dmamap_load(t, map, buf, buflen, p, flags)
+       bus_dma_tag_t t;
+       bus_dmamap_t map;
+       void *buf;
+       bus_size_t buflen;
+       struct proc *p;
+       int flags;
+{
+       int error;
+
+       error = _bus_dmamap_load(t, map, buf, buflen, p, flags);
+       if (error == 0)
+               map->dm_segs[0].ds_addr &= DVMA_MBMEM_SLAVE_MASK;
+       return (error);
+}
+
+static int
+mbmem_dmamap_load_raw(t, map, segs, nsegs, size, flags)
+       bus_dma_tag_t t;
+       bus_dmamap_t map;
+       bus_dma_segment_t *segs;
+       int nsegs;
+       bus_size_t size;
+       int flags;
+{
+       int error;
+
+       error = _bus_dmamap_load_raw(t, map, segs, nsegs, size, flags);
+       if (error == 0)
+               map->dm_segs[0].ds_addr &= DVMA_MBMEM_SLAVE_MASK;
+       return (error);
+}



Home | Main Index | Thread Index | Old Index