[openib-general] [PATCH 1 of 20] Introduce __memcpy_toio32

Bryan O'Sullivan bos at pathscale.com
Wed Dec 28 16:31:20 PST 2005


This routine is an arch-independent building block for memcpy_toio32.
It copies data to a memory-mapped I/O region, using 32-bit accesses.
This style of access is required by some devices.

Signed-off-by: Bryan O'Sullivan <bos at pathscale.com>

diff -r a56fd6a8895d -r ef833f6712e7 include/asm-generic/iomap.h
--- a/include/asm-generic/iomap.h	Wed Dec 28 14:19:42 2005 -0800
+++ b/include/asm-generic/iomap.h	Wed Dec 28 14:19:42 2005 -0800
@@ -56,6 +56,15 @@
 extern void fastcall iowrite16_rep(void __iomem *port, const void *buf, unsigned long count);
 extern void fastcall iowrite32_rep(void __iomem *port, const void *buf, unsigned long count);
 
+/*
+ * __memcpy_toio32 - copy data to MMIO space, in 32-bit units
+ *
+ * @to: destination, in MMIO space (must be 32-bit aligned)
+ * @from: source (must be 32-bit aligned)
+ * @count: number of 32-bit quantities to copy
+ */
+void fastcall __memcpy_toio32(void __iomem *to, const void *from, size_t count);
+
 /* Create a virtual mapping cookie for an IO port range */
 extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
 extern void ioport_unmap(void __iomem *);
diff -r a56fd6a8895d -r ef833f6712e7 lib/iomap.c
--- a/lib/iomap.c	Wed Dec 28 14:19:42 2005 -0800
+++ b/lib/iomap.c	Wed Dec 28 14:19:42 2005 -0800
@@ -187,6 +187,17 @@
 EXPORT_SYMBOL(iowrite16_rep);
 EXPORT_SYMBOL(iowrite32_rep);
 
+void fastcall __memcpy_toio32(void __iomem *d, const void *s, size_t count)
+{
+	u32 __iomem *dst = d;
+	const u32 *src = s;
+	size_t i;
+
+	for (i = 0; i < count; i++)
+		__raw_writel(*src++, dst++);
+	wmb();
+}
+
 /* Create a virtual mapping cookie for an IO port range */
 void __iomem *ioport_map(unsigned long port, unsigned int nr)
 {



More information about the general mailing list