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