1 #include <linux/string.h>
2 #include <linux/module.h>
5 #define movs(type,to,from) \
6 asm volatile("movs" type:"=&D" (to), "=&S" (from):"0" (to), "1" (from):"memory")
8 /* Originally from i386/string.h */
9 static __always_inline
void rep_movs(void *to
, const void *from
, size_t n
)
11 unsigned long d0
, d1
, d2
;
12 asm volatile("rep ; movsl\n\t"
16 "1:\ttestb $1,%b4\n\t"
20 : "=&c" (d0
), "=&D" (d1
), "=&S" (d2
)
21 : "0" (n
/ 4), "q" (n
), "1" ((long)to
), "2" ((long)from
)
25 void memcpy_fromio(void *to
, const volatile void __iomem
*from
, size_t n
)
30 /* Align any unaligned source IO */
31 if (unlikely(1 & (unsigned long)from
)) {
35 if (n
> 1 && unlikely(2 & (unsigned long)from
)) {
39 rep_movs(to
, (const void *)from
, n
);
41 EXPORT_SYMBOL(memcpy_fromio
);
43 void memcpy_toio(volatile void __iomem
*to
, const void *from
, size_t n
)
48 /* Align any unaligned destination IO */
49 if (unlikely(1 & (unsigned long)to
)) {
53 if (n
> 1 && unlikely(2 & (unsigned long)to
)) {
57 rep_movs((void *)to
, (const void *) from
, n
);
59 EXPORT_SYMBOL(memcpy_toio
);
61 void memset_io(volatile void __iomem
*a
, int b
, size_t c
)
64 * TODO: memset can mangle the IO patterns quite a bit.
65 * perhaps it would be better to use a dumb one:
67 memset((void *)a
, b
, c
);
69 EXPORT_SYMBOL(memset_io
);