0001
0002
0003 #include <linux/export.h>
0004 #include <linux/types.h>
0005 #include <linux/io.h>
0006
0007
0008
0009
0010 void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
0011 {
0012 while (count && !IS_ALIGNED((unsigned long)from, 4)) {
0013 *(u8 *)to = __raw_readb(from);
0014 from++;
0015 to++;
0016 count--;
0017 }
0018
0019 while (count >= 4) {
0020 *(u32 *)to = __raw_readl(from);
0021 from += 4;
0022 to += 4;
0023 count -= 4;
0024 }
0025
0026 while (count) {
0027 *(u8 *)to = __raw_readb(from);
0028 from++;
0029 to++;
0030 count--;
0031 }
0032 }
0033 EXPORT_SYMBOL(__memcpy_fromio);
0034
0035
0036
0037
0038 void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
0039 {
0040 while (count && !IS_ALIGNED((unsigned long)to, 4)) {
0041 __raw_writeb(*(u8 *)from, to);
0042 from++;
0043 to++;
0044 count--;
0045 }
0046
0047 while (count >= 4) {
0048 __raw_writel(*(u32 *)from, to);
0049 from += 4;
0050 to += 4;
0051 count -= 4;
0052 }
0053
0054 while (count) {
0055 __raw_writeb(*(u8 *)from, to);
0056 from++;
0057 to++;
0058 count--;
0059 }
0060 }
0061 EXPORT_SYMBOL(__memcpy_toio);
0062
0063
0064
0065
0066 void __memset_io(volatile void __iomem *dst, int c, size_t count)
0067 {
0068 u32 qc = (u8)c;
0069
0070 qc |= qc << 8;
0071 qc |= qc << 16;
0072
0073 while (count && !IS_ALIGNED((unsigned long)dst, 4)) {
0074 __raw_writeb(c, dst);
0075 dst++;
0076 count--;
0077 }
0078
0079 while (count >= 4) {
0080 __raw_writel(qc, dst);
0081 dst += 4;
0082 count -= 4;
0083 }
0084
0085 while (count) {
0086 __raw_writeb(c, dst);
0087 dst++;
0088 count--;
0089 }
0090 }
0091 EXPORT_SYMBOL(__memset_io);