Source-Changes-HG archive

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

[src/uebayasi-xip]: src/sys Initial implemention of bus_space_physload(9) for...



details:   https://anonhg.NetBSD.org/src/rev/f95f9e2ee2ab
branches:  uebayasi-xip
changeset: 751697:f95f9e2ee2ab
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Wed Apr 28 14:56:13 2010 +0000

description:
Initial implemention of bus_space_physload(9) for NetBSD/arm (only i.MX31
for now).

diffstat:

 sys/arch/arm/conf/files.arm    |   3 +-
 sys/arch/arm/imx/imx31_space.c |  52 +++++++++++++++++++++++++++++++++++++++--
 sys/arch/arm/include/bus.h     |  42 ++++++++++++++++++++++++++++++++-
 sys/arch/evbarm/conf/std.imx31 |   3 +-
 sys/dev/flash.c                |   4 +-
 5 files changed, 95 insertions(+), 9 deletions(-)

diffs (203 lines):

diff -r b1d045d35ef5 -r f95f9e2ee2ab sys/arch/arm/conf/files.arm
--- a/sys/arch/arm/conf/files.arm       Wed Apr 28 13:41:41 2010 +0000
+++ b/sys/arch/arm/conf/files.arm       Wed Apr 28 14:56:13 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.arm,v 1.97 2009/12/27 05:14:56 uebayasi Exp $
+#      $NetBSD: files.arm,v 1.97.2.1 2010/04/28 14:56:13 uebayasi Exp $
 
 # temporary define to allow easy moving to ../arch/arm/arm32
 defflag                                ARM32
@@ -37,6 +37,7 @@
 
 # Board-specific bus_space(9) definitions
 defflag  opt_arm_bus_space.h   __BUS_SPACE_HAS_STREAM_METHODS
+                               __BUS_SPACE_HAS_PHYSLOAD_METHODS
 
 # Floating point emulator
 defflag                                ARMFPE
diff -r b1d045d35ef5 -r f95f9e2ee2ab sys/arch/arm/imx/imx31_space.c
--- a/sys/arch/arm/imx/imx31_space.c    Wed Apr 28 13:41:41 2010 +0000
+++ b/sys/arch/arm/imx/imx31_space.c    Wed Apr 28 14:56:13 2010 +0000
@@ -1,7 +1,7 @@
-/* $Id: imx31_space.c,v 1.3 2009/11/07 07:27:41 cegger Exp $ */
+/* $Id: imx31_space.c,v 1.3.2.1 2010/04/28 14:56:14 uebayasi Exp $ */
 
 /* derived from: */
-/*     $NetBSD: imx31_space.c,v 1.3 2009/11/07 07:27:41 cegger Exp $ */
+/*     $NetBSD: imx31_space.c,v 1.3.2.1 2010/04/28 14:56:14 uebayasi Exp $ */
 
 /*
  * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
@@ -104,7 +104,7 @@
        imx31_bs_vaddr,
 
        /* mmap */
-       bs_notimpl_bs_mmap,
+       imx31_bs_mmap,
 
        /* barrier */
        imx31_bs_barrier,
@@ -162,6 +162,12 @@
        generic_armv4_bs_c_2,
        bs_notimpl_bs_c_4,
        bs_notimpl_bs_c_8,
+
+       /* physload */
+       imx31_bs_physload,
+       imx31_bs_physunload,
+       imx31_bs_physload_device,
+       imx31_bs_physunload_device,
 };
 
 int
@@ -268,4 +274,44 @@
        panic("imx31_io_bs_free(): not implemented\n");
 }
 
+paddr_t
+imx31_bs_mmap(void *t, bus_addr_t addr, off_t off, int prot, int flags)
+{
 
+       /* XXX */
+       return arm_btop(addr + off);
+}
+
+/* XXX generic */
+
+void *
+imx31_bs_physload(void *t, bus_addr_t addr, bus_size_t size, int prot, int flags)
+{
+       const paddr_t start = imx31_bs_mmap(t, addr, 0, prot, flags);
+       const paddr_t end = imx31_bs_mmap(t, addr + size, 0, prot, flags);
+
+       return uvm_page_physload(start, end, start, end, 0/* XXX freelist */);
+}
+
+void
+imx31_bs_physunload(void *t, void *phys)
+{
+
+       uvm_page_physunload(phys);
+}
+
+void *
+imx31_bs_physload_device(void *t, bus_addr_t addr, bus_size_t size, int prot, int flags)
+{
+       const paddr_t start = imx31_bs_mmap(t, addr, 0, prot, flags);
+       const paddr_t end = imx31_bs_mmap(t, addr + size, 0, prot, flags);
+
+       return uvm_page_physload_device(start, end, start, end, 0/* XXX freelist */);
+}
+
+void
+imx31_bs_physunload_device(void *t, void *phys)
+{
+
+       uvm_page_physunload_device(phys);
+}
diff -r b1d045d35ef5 -r f95f9e2ee2ab sys/arch/arm/include/bus.h
--- a/sys/arch/arm/include/bus.h        Wed Apr 28 13:41:41 2010 +0000
+++ b/sys/arch/arm/include/bus.h        Wed Apr 28 14:56:13 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus.h,v 1.20 2009/03/14 14:45:55 dsl Exp $     */
+/*     $NetBSD: bus.h,v 1.20.2.1 2010/04/28 14:56:14 uebayasi Exp $    */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -271,6 +271,15 @@
        void            (*bs_wr_8_s)(void *, bus_space_handle_t,
                            bus_size_t, const u_int64_t *, bus_size_t);
 #endif /* __BUS_SPACE_HAS_STREAM_METHODS */
+
+#ifdef __BUS_SPACE_HAS_PHYSLOAD_METHODS
+       void *          (*bs_physload)(void *, bus_addr_t, bus_size_t,
+                           int, int);
+       void            (*bs_physunload)(void *, void *);
+       void *          (*bs_physload_device)(void *, bus_addr_t, bus_size_t,
+                           int, int);
+       void            (*bs_physunload_device)(void *, void *);
+#endif
 };
 
 
@@ -690,6 +699,19 @@
            bus_size_t offset1, bus_space_handle_t bsh2,                \
            bus_size_t offset2, bus_size_t count);
 
+#ifdef __BUS_SPACE_HAS_PHYSLOAD_METHODS
+#define bs_physload_proto(f)                                           \
+void * __bs_c(f,_bs_physload)(void *t,                                 \
+           bus_addr_t addr, bus_size_t size, int prot, int flags);
+#define bs_physunload_proto(f)                                         \
+void   __bs_c(f,_bs_physunload)(void *t, void *phys)
+#define bs_physload_device_proto(f)                                    \
+void * __bs_c(f,_bs_physload_device)(void *t,                          \
+           bus_addr_t addr, bus_size_t size, int prot, int flags);
+#define bs_physunload_device_proto(f)                                  \
+void   __bs_c(f,_bs_physunload_device)(void *t, void *phys)
+#endif
+
 #define bs_protos(f)           \
 bs_map_proto(f);               \
 bs_unmap_proto(f);             \
@@ -734,10 +756,26 @@
 bs_c_1_proto(f);               \
 bs_c_2_proto(f);               \
 bs_c_4_proto(f);               \
-bs_c_8_proto(f);
+bs_c_8_proto(f);               \
+bs_physload_proto(f);          \
+bs_physunload_proto(f);                \
+bs_physload_device_proto(f);   \
+bs_physunload_device_proto(f);
 
 #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
 
+/*
+ * Load bus space as a physical segment for managed access.
+ */
+#define bus_space_physload(t, a, s, p, f)                              \
+       (*(t)->bs_physload)((t)->bs_cookie, (a), (s), (p), (f))
+#define bus_space_physunload(t, p)                                     \
+       (*(t)->bs_physunload)((t)->bs_cookie, (p))
+#define bus_space_physload_device(t, a, s, p, f)                       \
+       (*(t)->bs_physload_device)((t)->bs_cookie, (a), (s), (p), (f))
+#define bus_space_physunload_device(t, p)                              \
+       (*(t)->bs_physunload_device)((t)->bs_cookie, (p))
+
 /* Bus Space DMA macros */
 
 /*
diff -r b1d045d35ef5 -r f95f9e2ee2ab sys/arch/evbarm/conf/std.imx31
--- a/sys/arch/evbarm/conf/std.imx31    Wed Apr 28 13:41:41 2010 +0000
+++ b/sys/arch/evbarm/conf/std.imx31    Wed Apr 28 14:56:13 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: std.imx31,v 1.3 2009/12/27 05:14:56 uebayasi Exp $
+#      $NetBSD: std.imx31,v 1.3.2.1 2010/04/28 14:56:14 uebayasi Exp $
 #
 # standard NetBSD/evbarm options for FreeScale I.MX31 
 
@@ -25,4 +25,5 @@
 makeoptions    CPPFLAGS+="-I$S/../../../include"
 
 options        ARM_INTR_IMPL="<arch/arm/imx/imx31_intr.h>"
+options        __BUS_SPACE_HAS_PHYSLOAD_METHODS
 options                ARM_GENERIC_TODR
diff -r b1d045d35ef5 -r f95f9e2ee2ab sys/dev/flash.c
--- a/sys/dev/flash.c   Wed Apr 28 13:41:41 2010 +0000
+++ b/sys/dev/flash.c   Wed Apr 28 14:56:13 2010 +0000
@@ -1,4 +1,4 @@
-/*     $Id: flash.c,v 1.1.2.5 2010/04/28 13:41:41 uebayasi Exp $       */
+/*     $Id: flash.c,v 1.1.2.6 2010/04/28 14:56:13 uebayasi Exp $       */
 
 /*-
  * Copyright (c) 2010 Tsubai Masanari.  All rights reserved.
@@ -238,7 +238,7 @@
 #endif
 
 #ifdef XIP
-#ifndef __HAVE_BUS_SPACE_PHYSLOAD
+#ifndef __BUS_SPACE_HAS_PHYSLOAD
 #error bus_space_physload_device(9) must be supported to use XIP!
 #else
        sc->sc_phys = bus_space_physload_device(sc->sc_iot, sc->sc_addr, sc->sc_size,



Home | Main Index | Thread Index | Old Index