Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arc Implement bus_space_mmap().



details:   https://anonhg.NetBSD.org/src/rev/8dad5718a586
branches:  trunk
changeset: 514510:8dad5718a586
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Sep 04 06:57:26 2001 +0000

description:
Implement bus_space_mmap().

diffstat:

 sys/arch/arc/arc/bus_space.c |  24 +++++++++++++++++++++++-
 sys/arch/arc/include/bus.h   |  15 +++++++++++++--
 2 files changed, 36 insertions(+), 3 deletions(-)

diffs (95 lines):

diff -r cbe8dfe204ea -r 8dad5718a586 sys/arch/arc/arc/bus_space.c
--- a/sys/arch/arc/arc/bus_space.c      Tue Sep 04 06:26:18 2001 +0000
+++ b/sys/arch/arc/arc/bus_space.c      Tue Sep 04 06:57:26 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_space.c,v 1.3 2000/11/09 06:05:40 thorpej Exp $    */
+/*     $NetBSD: bus_space.c,v 1.4 2001/09/04 06:57:26 thorpej Exp $    */
 /*     NetBSD: bus_machdep.c,v 1.1 2000/01/26 18:48:00 drochner Exp    */
 
 /*-
@@ -68,6 +68,7 @@
        bst->bs_map = arc_bus_space_map;
        bst->bs_unmap = arc_bus_space_unmap;
        bst->bs_subregion = arc_bus_space_subregion;
+       bst->bs_mmap = arc_bus_space_mmap;
        bst->bs_alloc = arc_bus_space_alloc;
        bst->bs_free = arc_bus_space_free;
        bst->bs_aux = NULL;
@@ -252,6 +253,27 @@
        return (0);
 }
 
+paddr_t
+arc_bus_space_mmap(bst, addr, off, prot, flags)
+       bus_space_tag_t bst;
+       bus_addr_t addr;
+       off_t off;
+       int prot;
+       int flags;
+{
+
+       /*
+        * XXX We do not disallow mmap'ing of EISA/PCI I/O space here,
+        * XXX which we should be doing.
+        */
+
+       if (addr < bst->bs_start ||
+           (addr + off) >= (bst->bs_start + bst->bs_size))
+               return (-1);
+
+       return (mips_btop(bst->bs_pbase + (addr - bst->bs_start) + off));
+}
+
 int
 arc_bus_space_alloc(bst, start, end, size, align, boundary, flags, addrp, bshp)
        bus_space_tag_t bst;
diff -r cbe8dfe204ea -r 8dad5718a586 sys/arch/arc/include/bus.h
--- a/sys/arch/arc/include/bus.h        Tue Sep 04 06:26:18 2001 +0000
+++ b/sys/arch/arc/include/bus.h        Tue Sep 04 06:57:26 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus.h,v 1.11 2001/07/19 15:32:11 thorpej Exp $ */
+/*     $NetBSD: bus.h,v 1.12 2001/09/04 06:57:27 thorpej Exp $ */
 /*     NetBSD: bus.h,v 1.27 2000/03/15 16:44:50 drochner Exp   */
 /*     $OpenBSD: bus.h,v 1.15 1999/08/11 23:15:21 niklas Exp $ */
 
@@ -158,6 +158,7 @@
                                bus_size_t));
        int     (*bs_subregion) __P((bus_space_tag_t, bus_space_handle_t,
                                bus_size_t, bus_size_t, bus_space_handle_t *));
+       paddr_t (*bs_mmap) __P((bus_space_tag_t, bus_addr_t, off_t, int, int));
 
        /* allocation/deallocation */
        int     (*bs_alloc) __P((bus_space_tag_t, bus_addr_t, bus_addr_t,
@@ -208,6 +209,7 @@
            bus_size_t));
 int    arc_bus_space_subregion __P((bus_space_tag_t, bus_space_handle_t,
            bus_size_t, bus_size_t, bus_space_handle_t *));
+paddr_t        arc_bus_space_mmap __P((bus_space_tag_t, bus_addr_t, off_t, int, int));
 int    arc_bus_space_alloc __P((bus_space_tag_t, bus_addr_t, bus_addr_t,
            bus_size_t, bus_size_t, bus_size_t, int, bus_addr_t *,
            bus_space_handle_t *));
@@ -242,7 +244,7 @@
  * MACHINE DEPENDENT, NOT PORTABLE INTERFACE:
  * (cannot be implemented on e.g. I/O space on i386, non-linear space on alpha)
  * Return physical address of a region.
- * A helper function for device mmap entry.
+ * A helper function for machine-dependent device mmap entry.
  */
 #define bus_space_paddr(bst, bsh, pap)                                 \
        (*(bst)->bs_paddr)(bst, bsh, pap)
@@ -258,6 +260,15 @@
        ((void *)(bsh))
 
 /*
+ *     paddr_t bus_space_mmap __P((bus_space_tag_t, bus_addr_t, off_t,
+ *         int, int));
+ *
+ * Mmap bus space on behalf of the user.
+ */
+#define        bus_space_mmap(bst, addr, off, prot, flags)                     \
+       (*(bst)->bs_mmap)((bst), (addr), (off), (prot), (flags))
+
+/*
  *     int bus_space_map __P((bus_space_tag_t t, bus_addr_t addr,
  *         bus_size_t size, int flags, bus_space_handle_t *bshp));
  *



Home | Main Index | Thread Index | Old Index