Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/vax First towards use of bus.h routines on vax. All...



details:   https://anonhg.NetBSD.org/src/rev/98d1f203912b
branches:  trunk
changeset: 471911:98d1f203912b
user:      ragge <ragge%NetBSD.org@localhost>
date:      Wed Apr 14 23:14:45 1999 +0000

description:
First towards use of bus.h routines on vax. Allocate DMA memory for
LANCE chip on vaxstations.

diffstat:

 sys/arch/vax/conf/files.vax  |    3 +-
 sys/arch/vax/include/bus.h   |   10 +-
 sys/arch/vax/include/vsbus.h |    9 +-
 sys/arch/vax/vax/bus_dma.c   |  749 +++++++++++++++++++++++++++++++++++++++++++
 sys/arch/vax/vax/ka410.c     |   15 +-
 sys/arch/vax/vax/ka43.c      |   34 +-
 sys/arch/vax/vax/ka46.c      |    8 +-
 sys/arch/vax/vax/ka48.c      |    6 +-
 sys/arch/vax/vsa/if_ln.c     |   36 +-
 sys/arch/vax/vsa/vsbus.c     |   27 +-
 10 files changed, 830 insertions(+), 67 deletions(-)

diffs (truncated from 1138 to 300 lines):

diff -r bcbba03e4245 -r 98d1f203912b sys/arch/vax/conf/files.vax
--- a/sys/arch/vax/conf/files.vax       Wed Apr 14 23:06:26 1999 +0000
+++ b/sys/arch/vax/conf/files.vax       Wed Apr 14 23:14:45 1999 +0000
@@ -1,4 +1,4 @@
-#       $NetBSD: files.vax,v 1.48 1999/03/26 22:04:07 ragge Exp $
+#       $NetBSD: files.vax,v 1.49 1999/04/14 23:14:45 ragge Exp $
 #
 # new style config file for vax architecture
 #
@@ -333,6 +333,7 @@
 file   arch/vax/vax/urem.s
 file   arch/vax/vax/udiv.s
 file   arch/vax/vax/trap.c
+file   arch/vax/vax/bus_dma.c
 
 file   arch/vax/vax/vm_machdep.c
 file   arch/vax/vax/autoconf.c
diff -r bcbba03e4245 -r 98d1f203912b sys/arch/vax/include/bus.h
--- a/sys/arch/vax/include/bus.h        Wed Apr 14 23:06:26 1999 +0000
+++ b/sys/arch/vax/include/bus.h        Wed Apr 14 23:14:45 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus.h,v 1.4 1999/03/23 21:29:05 drochner Exp $ */
+/*     $NetBSD: bus.h,v 1.5 1999/04/14 23:14:46 ragge Exp $    */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -1059,13 +1059,13 @@
            bus_size_t, int, bus_dmamap_t *));
 void   _bus_dmamap_destroy __P((bus_dma_tag_t, bus_dmamap_t));
 
-int    _bus_dmamap_load_direct __P((bus_dma_tag_t, bus_dmamap_t,
+int    _bus_dmamap_load __P((bus_dma_tag_t, bus_dmamap_t,
            void *, bus_size_t, struct proc *, int));
-int    _bus_dmamap_load_mbuf_direct __P((bus_dma_tag_t,
+int    _bus_dmamap_load_mbuf __P((bus_dma_tag_t,
            bus_dmamap_t, struct mbuf *, int));
-int    _bus_dmamap_load_uio_direct __P((bus_dma_tag_t,
+int    _bus_dmamap_load_uio __P((bus_dma_tag_t,
            bus_dmamap_t, struct uio *, int));
-int    _bus_dmamap_load_raw_direct __P((bus_dma_tag_t,
+int    _bus_dmamap_load_raw __P((bus_dma_tag_t,
            bus_dmamap_t, bus_dma_segment_t *, int, bus_size_t, int));
 
 void   _bus_dmamap_unload __P((bus_dma_tag_t, bus_dmamap_t));
diff -r bcbba03e4245 -r 98d1f203912b sys/arch/vax/include/vsbus.h
--- a/sys/arch/vax/include/vsbus.h      Wed Apr 14 23:06:26 1999 +0000
+++ b/sys/arch/vax/include/vsbus.h      Wed Apr 14 23:14:45 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vsbus.h,v 1.7 1999/03/13 15:16:47 ragge Exp $ */
+/*     $NetBSD: vsbus.h,v 1.8 1999/04/14 23:14:46 ragge Exp $ */
 /*
  * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
  * All rights reserved.
@@ -37,6 +37,11 @@
  * used by all VAXstations.
  */
 
+#ifndef _VAX_VSBUS_H_
+#define _VAX_VSBUS_H_
+
+#include <machine/bus.h>
+
 struct vsbus_attach_args {
        vaddr_t va_addr;                /* virtual CSR address */
        paddr_t va_paddr;               /* physical CSR address */
@@ -44,6 +49,7 @@
        short   va_br;                  /* Interrupt level */
        short   va_cvec;                /* Interrupt vector address */
        u_char  va_maskno;              /* Interrupt vector in mask */
+       bus_dma_tag_t va_dmat;
 };
 
 /*
@@ -66,3 +72,4 @@
 
 u_char vsbus_setmask __P((unsigned char));
 void   vsbus_clrintr __P((unsigned char));
+#endif /* _VAX_VSBUS_H_ */
diff -r bcbba03e4245 -r 98d1f203912b sys/arch/vax/vax/bus_dma.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/vax/vax/bus_dma.c        Wed Apr 14 23:14:45 1999 +0000
@@ -0,0 +1,749 @@
+/*     $NetBSD: bus_dma.c,v 1.1 1999/04/14 23:14:46 ragge Exp $        */
+
+/*-
+ * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the NetBSD
+ *     Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * bus_dma routines for vax. File copied from arm32/bus_dma.c.
+ * NetBSD: bus_dma.c,v 1.11 1998/09/21 22:53:35 thorpej Exp
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/map.h>
+#include <sys/proc.h>
+#include <sys/buf.h>
+#include <sys/reboot.h>
+#include <sys/conf.h>
+#include <sys/file.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/vnode.h>
+#include <sys/device.h>
+
+#include <vm/vm.h>
+#include <vm/vm_kern.h>
+#include <vm/vm_page.h>
+
+#include <uvm/uvm_extern.h>
+
+#define _VAX_BUS_DMA_PRIVATE
+#include <machine/bus.h>
+
+#include <machine/ka43.h>
+#include <machine/sid.h>
+
+extern vaddr_t avail_start, avail_end, virtual_avail;
+
+int    _bus_dmamap_load_buffer __P((bus_dma_tag_t, bus_dmamap_t, void *,
+           bus_size_t, struct proc *, int, vm_offset_t *, int *, int));
+int    _bus_dma_inrange __P((bus_dma_segment_t *, int, bus_addr_t));
+int    _bus_dmamem_alloc_range __P((bus_dma_tag_t, bus_size_t, bus_size_t,
+           bus_size_t, bus_dma_segment_t*, int, int *, int, vaddr_t, vaddr_t));
+/*
+ * Common function for DMA map creation.  May be called by bus-specific
+ * DMA map creation functions.
+ */
+int
+_bus_dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp)
+       bus_dma_tag_t t;
+       bus_size_t size;
+       int nsegments;
+       bus_size_t maxsegsz;
+       bus_size_t boundary;
+       int flags;
+       bus_dmamap_t *dmamp;
+{
+       struct vax_bus_dmamap *map;
+       void *mapstore;
+       size_t mapsize;
+
+#ifdef DEBUG_DMA
+       printf("dmamap_create: t=%p size=%lx nseg=%x msegsz=%lx boundary=%lx flags=%x\n",
+           t, size, nsegments, maxsegsz, boundary, flags);
+#endif /* DEBUG_DMA */
+
+       /*
+        * Allocate and initialize the DMA map.  The end of the map
+        * is a variable-sized array of segments, so we allocate enough
+        * room for them in one shot.
+        *
+        * Note we don't preserve the WAITOK or NOWAIT flags.  Preservation
+        * of ALLOCNOW notifies others that we've reserved these resources,
+        * and they are not to be freed.
+        *
+        * The bus_dmamap_t includes one bus_dma_segment_t, hence
+        * the (nsegments - 1).
+        */
+       mapsize = sizeof(struct vax_bus_dmamap) +
+           (sizeof(bus_dma_segment_t) * (nsegments - 1));
+       if ((mapstore = malloc(mapsize, M_DMAMAP,
+           (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL)
+               return (ENOMEM);
+
+       bzero(mapstore, mapsize);
+       map = (struct vax_bus_dmamap *)mapstore;
+       map->_dm_size = size;
+       map->_dm_segcnt = nsegments;
+       map->_dm_maxsegsz = maxsegsz;
+       map->_dm_boundary = boundary;
+       map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
+       map->dm_mapsize = 0;            /* no valid mappings */
+       map->dm_nsegs = 0;
+
+       *dmamp = map;
+#ifdef DEBUG_DMA
+       printf("dmamap_create:map=%p\n", map);
+#endif /* DEBUG_DMA */
+       return (0);
+}
+
+/*
+ * Common function for DMA map destruction.  May be called by bus-specific
+ * DMA map destruction functions.
+ */
+void
+_bus_dmamap_destroy(t, map)
+       bus_dma_tag_t t;
+       bus_dmamap_t map;
+{
+
+#ifdef DEBUG_DMA
+       printf("dmamap_destroy: t=%p map=%p\n", t, map);
+#endif /* DEBUG_DMA */
+#ifdef DIAGNOSTIC
+       if (map->dm_nsegs > 0)
+               printf("bus_dmamap_destroy() called for map with valid mappings\n");
+#endif /* DIAGNOSTIC */
+       free(map, M_DEVBUF);
+}
+
+/*
+ * Common function for loading a DMA map with a linear buffer.  May
+ * be called by bus-specific DMA map load functions.
+ */
+int
+_bus_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;
+{
+       vm_offset_t lastaddr;
+       int seg, error;
+
+#ifdef DEBUG_DMA
+       printf("dmamap_load: t=%p map=%p buf=%p len=%lx p=%p f=%d\n",
+           t, map, buf, buflen, p, flags);
+#endif /* DEBUG_DMA */
+
+       /*
+        * Make sure that on error condition we return "no valid mappings".
+        */
+       map->dm_mapsize = 0;
+       map->dm_nsegs = 0;
+
+       if (buflen > map->_dm_size)
+               return (EINVAL);
+
+       seg = 0;
+       error = _bus_dmamap_load_buffer(t, map, buf, buflen, p, flags,
+           &lastaddr, &seg, 1);
+       if (error == 0) {
+               map->dm_mapsize = buflen;
+               map->dm_nsegs = seg + 1;
+       }
+#ifdef DEBUG_DMA
+       printf("dmamap_load: error=%d\n", error);
+#endif /* DEBUG_DMA */
+       return (error);
+}
+
+/*
+ * Like _bus_dmamap_load(), but for mbufs.
+ */
+int
+_bus_dmamap_load_mbuf(t, map, m0, flags)
+       bus_dma_tag_t t;
+       bus_dmamap_t map;
+       struct mbuf *m0;
+       int flags;
+{
+       vm_offset_t lastaddr;
+       int seg, error, first;
+       struct mbuf *m;
+
+#ifdef DEBUG_DMA
+       printf("dmamap_load_mbuf: t=%p map=%p m0=%p f=%d\n",
+           t, map, m0, flags);
+#endif /* DEBUG_DMA */
+
+       /*
+        * Make sure that on error condition we return "no valid mappings."



Home | Main Index | Thread Index | Old Index