Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/mipsco bus_space_mmap support based on -arc impleme...



details:   https://anonhg.NetBSD.org/src/rev/594ca0fd5af6
branches:  trunk
changeset: 514961:594ca0fd5af6
user:      wdk <wdk%NetBSD.org@localhost>
date:      Sat Sep 15 00:49:53 2001 +0000

description:
bus_space_mmap support based on -arc implementation

diffstat:

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

diffs (88 lines):

diff -r 117b2960980b -r 594ca0fd5af6 sys/arch/mipsco/include/bus.h
--- a/sys/arch/mipsco/include/bus.h     Sat Sep 15 00:46:13 2001 +0000
+++ b/sys/arch/mipsco/include/bus.h     Sat Sep 15 00:49:53 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus.h,v 1.6 2001/07/19 15:32:15 thorpej Exp $  */
+/*     $NetBSD: bus.h,v 1.7 2001/09/15 00:49:53 wdk Exp $      */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -158,6 +158,8 @@
                                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,
@@ -217,6 +219,8 @@
            bus_size_t));
 int    mipsco_bus_space_subregion __P((bus_space_tag_t, bus_space_handle_t,
            bus_size_t, bus_size_t, bus_space_handle_t *));
+paddr_t        mipsco_bus_space_mmap __P((bus_space_tag_t, bus_addr_t, off_t,
+           int, int));
 int    mipsco_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 *));
@@ -267,6 +271,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));
  *
diff -r 117b2960980b -r 594ca0fd5af6 sys/arch/mipsco/mipsco/bus_space.c
--- a/sys/arch/mipsco/mipsco/bus_space.c        Sat Sep 15 00:46:13 2001 +0000
+++ b/sys/arch/mipsco/mipsco/bus_space.c        Sat Sep 15 00:49:53 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_space.c,v 1.2 2001/03/30 23:17:04 wdk Exp $        */
+/*     $NetBSD: bus_space.c,v 1.3 2001/09/15 00:49:54 wdk Exp $        */
 
 /*
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -67,6 +67,7 @@
        bst->bs_map = mipsco_bus_space_map;
        bst->bs_unmap = mipsco_bus_space_unmap;
        bst->bs_subregion = mipsco_bus_space_subregion;
+       bst->bs_mmap = mipsco_bus_space_mmap;
        bst->bs_alloc = mipsco_bus_space_alloc;
        bst->bs_free = mipsco_bus_space_free;
        bst->bs_aux = NULL;
@@ -250,6 +251,27 @@
        return (0);
 }
 
+paddr_t
+mipsco_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 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
 mipsco_bus_space_alloc(bst, start, end, size, align, boundary, flags, addrp, bshp)
        bus_space_tag_t bst;



Home | Main Index | Thread Index | Old Index