Source-Changes-HG archive

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

[src/uebayasi-xip]: src/sys/arch/powerpc Support bus_space_physload(9) and fr...



details:   https://anonhg.NetBSD.org/src/rev/2f0207945565
branches:  uebayasi-xip
changeset: 751760:2f0207945565
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Wed Aug 11 13:20:07 2010 +0000

description:
Support bus_space_physload(9) and friends.

diffstat:

 sys/arch/powerpc/conf/files.powerpc  |   3 +-
 sys/arch/powerpc/include/bus.h       |  52 ++++++++++++++++++++++++++++++++++-
 sys/arch/powerpc/powerpc/bus_space.c |  53 ++++++++++++++++++++++++++++++++++-
 3 files changed, 104 insertions(+), 4 deletions(-)

diffs (187 lines):

diff -r c6bf1093e5c0 -r 2f0207945565 sys/arch/powerpc/conf/files.powerpc
--- a/sys/arch/powerpc/conf/files.powerpc       Wed Aug 11 13:14:55 2010 +0000
+++ b/sys/arch/powerpc/conf/files.powerpc       Wed Aug 11 13:20:07 2010 +0000
@@ -1,9 +1,10 @@
-#      $NetBSD: files.powerpc,v 1.71.4.1 2010/04/30 14:39:41 uebayasi Exp $
+#      $NetBSD: files.powerpc,v 1.71.4.2 2010/08/11 13:20:07 uebayasi Exp $
 
 defflag        opt_altivec.h   ALTIVEC K_ALTIVEC
 defflag        opt_openpic.h   OPENPIC OPENPIC_SERIAL_MODE
 defparam opt_ppcparam.h        L2CR_CONFIG L3CR_CONFIG INTSTK CLOCKBASE
 defflag        opt_ppcarch.h   PPC_OEA PPC_OEA601 PPC_OEA64 PPC_OEA64_BRIDGE PPC_MPC8XX PPC_IBM4XX PPC_IBM403 PPC_BOOKE
+                       __BUS_SPACE_HAS_PHYSLOAD_METHODS
 defflag opt_pmap.h     PMAPDEBUG PMAPCHECK PMAPCOUNTERS
 defparam opt_pmap.h    PTEGCOUNT PMAP_MEMLIMIT
 
diff -r c6bf1093e5c0 -r 2f0207945565 sys/arch/powerpc/include/bus.h
--- a/sys/arch/powerpc/include/bus.h    Wed Aug 11 13:14:55 2010 +0000
+++ b/sys/arch/powerpc/include/bus.h    Wed Aug 11 13:20:07 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus.h,v 1.20 2008/04/28 20:23:32 martin Exp $  */
+/*     $NetBSD: bus.h,v 1.20.20.1 2010/08/11 13:20:07 uebayasi Exp $   */
 /*     $OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $    */
 
 /*-
@@ -110,6 +110,8 @@
  */
 typedef uint32_t bus_addr_t;
 typedef uint32_t bus_size_t;
+#define        PRIxBUSADDR     PRIx32
+#define        PRIxBUSSIZE     PRIx32
 
 #ifndef __HAVE_LOCAL_BUS_SPACE
 typedef        uint32_t bus_space_handle_t;
@@ -211,6 +213,14 @@
        const struct powerpc_bus_space_set *pbs_set;
        const struct powerpc_bus_space_set *pbs_set_stream;
        const struct powerpc_bus_space_copy *pbs_copy;
+
+#ifdef __BUS_SPACE_HAS_PHYSLOAD_METHODS
+       void *(*pbs_physload)(bus_space_tag_t, bus_addr_t, bus_size_t, int);
+       void (*pbs_physunload)(bus_space_tag_t, void *);
+       void *(*pbs_physload_device)(bus_space_tag_t, bus_addr_t, bus_size_t,
+           int, int);
+       void (*pbs_physunload_device)(bus_space_tag_t, void *);
+#endif
 };
 
 #define _BUS_SPACE_STRIDE(t, o) \
@@ -618,6 +628,46 @@
 
 #endif /* !__HAVE_LOCAL_BUS_SPACE */
 
+#ifdef __BUS_SPACE_HAS_PHYSLOAD_METHODS
+/*
+ *     void *bus_space_physload (bus_space_tag_t t, bus_addr_t addr,
+ *         bus_size_t size, int freelist);
+ *
+ * Allocate general purpose managed memory segment for a given bus space.
+ */
+
+#define bus_space_physload(t, a, s, fl)                                        \
+    ((*(t)->pbs_physload)((t), (a), (s), (fl)))
+
+/*
+ *     void *bus_space_physunload (bus_space_tag_t t, void *phys);
+ *
+ * Free general purpose managed memory segment for a given bus space.
+ */
+
+#define bus_space_physunload(t, phys)                                  \
+    ((*(t)->pbs_physunload)((t), (phys)))
+
+/*
+ *     void *bus_space_physload_device (bus_space_tag_t t, bus_addr_t addr,
+ *         bus_size_t size, int freelist);
+ *
+ * Allocate managed device memory segment for a given bus space.
+ */
+
+#define bus_space_physload_device(t, a, s, prot, flags)                        \
+    ((*(t)->pbs_physload_device)((t), (a), (s), (prot), (flags)))
+
+/*
+ *     void *bus_space_physunload_device (bus_space_tag_t t, void *phys);
+ *
+ * Allocate managed device memory segment for a given bus space.
+ */
+
+#define bus_space_physunload_device(t, phys)                           \
+    ((*(t)->pbs_physunload_device)((t), (phys)))
+#endif
+
 /*
  * Bus DMA methods.
  */
diff -r c6bf1093e5c0 -r 2f0207945565 sys/arch/powerpc/powerpc/bus_space.c
--- a/sys/arch/powerpc/powerpc/bus_space.c      Wed Aug 11 13:14:55 2010 +0000
+++ b/sys/arch/powerpc/powerpc/bus_space.c      Wed Aug 11 13:20:07 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_space.c,v 1.20.20.1 2010/04/30 14:39:45 uebayasi Exp $     */
+/*     $NetBSD: bus_space.c,v 1.20.20.2 2010/08/11 13:20:08 uebayasi Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.20.20.1 2010/04/30 14:39:45 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.20.20.2 2010/08/11 13:20:08 uebayasi Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -42,6 +42,7 @@
 #include <sys/malloc.h>
 
 #include <uvm/uvm_extern.h>
+#include <uvm/uvm_prot.h>
 
 #define _POWERPC_BUS_SPACE_PRIVATE
 #include <machine/bus.h>
@@ -394,6 +395,13 @@
 static int memio_alloc(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 *);
 static void memio_free(bus_space_tag_t, bus_space_handle_t, bus_size_t);
+#ifdef __BUS_SPACE_HAS_PHYSLOAD_METHODS
+static void *memio_physload(bus_space_tag_t, bus_addr_t, bus_size_t, int);
+static void memio_physunload(bus_space_tag_t, void *);
+static void *memio_physload_device(bus_space_tag_t, bus_addr_t, bus_size_t,
+       int, int);
+static void memio_physunload_device(bus_space_tag_t, void *);
+#endif
 
 static int extent_flags;
 
@@ -483,6 +491,14 @@
                }
        }
 #endif
+
+#ifdef __BUS_SPACE_HAS_PHYSLOAD_METHODS
+       t->pbs_physload = memio_physload;
+       t->pbs_physunload = memio_physunload;
+       t->pbs_physload_device = memio_physload_device;
+       t->pbs_physunload_device = memio_physunload_device;
+#endif
+
        return 0;
 }
 
@@ -753,3 +769,36 @@
        /* memio_unmap() does all that we need to do. */
        memio_unmap(t, bsh, size);
 }
+
+#ifdef __BUS_SPACE_HAS_PHYSLOAD_METHODS
+static void *
+memio_physload(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int freelist)
+{
+       const paddr_t start = memio_mmap(t, bpa, 0, VM_PROT_ALL, 0) >> PAGE_SHIFT;
+       const paddr_t end = memio_mmap(t, bpa + size, 0, VM_PROT_ALL, 0) >> PAGE_SHIFT;
+
+       return uvm_page_physload(start, end, start, end, freelist);
+}
+
+static void
+memio_physunload(bus_space_tag_t t, void *phys)
+{
+       uvm_page_physunload(phys);
+}
+
+static void *
+memio_physload_device(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int prot,
+    int flags)
+{
+       const paddr_t start = memio_mmap(t, bpa, 0, prot, flags) >> PAGE_SHIFT;
+       const paddr_t end = memio_mmap(t, bpa + size, 0, prot, flags) >> PAGE_SHIFT;
+
+       return uvm_page_physload_device(start, end, start, end, prot, flags);
+}
+
+static void
+memio_physunload_device(bus_space_tag_t t, void *phys)
+{
+       uvm_page_physunload_device(phys);
+}
+#endif



Home | Main Index | Thread Index | Old Index