Module Name:    src
Committed By:   uebayasi
Date:           Wed Apr 28 14:56:14 UTC 2010

Modified Files:
        src/sys/arch/arm/conf [uebayasi-xip]: files.arm
        src/sys/arch/arm/imx [uebayasi-xip]: imx31_space.c
        src/sys/arch/arm/include [uebayasi-xip]: bus.h
        src/sys/arch/evbarm/conf [uebayasi-xip]: std.imx31
        src/sys/dev [uebayasi-xip]: flash.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.97.2.1 src/sys/arch/arm/conf/files.arm
cvs rdiff -u -r1.3 -r1.3.2.1 src/sys/arch/arm/imx/imx31_space.c
cvs rdiff -u -r1.20 -r1.20.2.1 src/sys/arch/arm/include/bus.h
cvs rdiff -u -r1.3 -r1.3.2.1 src/sys/arch/evbarm/conf/std.imx31
cvs rdiff -u -r1.1.2.5 -r1.1.2.6 src/sys/dev/flash.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/conf/files.arm
diff -u src/sys/arch/arm/conf/files.arm:1.97 src/sys/arch/arm/conf/files.arm:1.97.2.1
--- src/sys/arch/arm/conf/files.arm:1.97	Sun Dec 27 05:14:56 2009
+++ src/sys/arch/arm/conf/files.arm	Wed Apr 28 14:56:13 2010
@@ -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

Index: src/sys/arch/arm/imx/imx31_space.c
diff -u src/sys/arch/arm/imx/imx31_space.c:1.3 src/sys/arch/arm/imx/imx31_space.c:1.3.2.1
--- src/sys/arch/arm/imx/imx31_space.c:1.3	Sat Nov  7 07:27:41 2009
+++ src/sys/arch/arm/imx/imx31_space.c	Wed Apr 28 14:56:14 2010
@@ -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);
+}

Index: src/sys/arch/arm/include/bus.h
diff -u src/sys/arch/arm/include/bus.h:1.20 src/sys/arch/arm/include/bus.h:1.20.2.1
--- src/sys/arch/arm/include/bus.h:1.20	Sat Mar 14 14:45:55 2009
+++ src/sys/arch/arm/include/bus.h	Wed Apr 28 14:56:14 2010
@@ -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 */
 
 /*

Index: src/sys/arch/evbarm/conf/std.imx31
diff -u src/sys/arch/evbarm/conf/std.imx31:1.3 src/sys/arch/evbarm/conf/std.imx31:1.3.2.1
--- src/sys/arch/evbarm/conf/std.imx31:1.3	Sun Dec 27 05:14:56 2009
+++ src/sys/arch/evbarm/conf/std.imx31	Wed Apr 28 14:56:14 2010
@@ -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

Index: src/sys/dev/flash.c
diff -u src/sys/dev/flash.c:1.1.2.5 src/sys/dev/flash.c:1.1.2.6
--- src/sys/dev/flash.c:1.1.2.5	Wed Apr 28 13:41:41 2010
+++ src/sys/dev/flash.c	Wed Apr 28 14:56:13 2010
@@ -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,

Reply via email to