-static inline void eeh_memcpy_fromio(void *dest, void *src, unsigned long n) {
- void *vsrc = (void *)IO_TOKEN_TO_ADDR(src);
- memcpy(dest, vsrc, n);
+static inline void eeh_memcpy_fromio(void *dest, const volatile void __iomem *src, unsigned long n) {
+ void *vsrc = (void __force *) src;
+ void *destsave = dest;
+ unsigned long nsave = n;
+
+ while(n && (!EEH_CHECK_ALIGN(vsrc, 4) || !EEH_CHECK_ALIGN(dest, 4))) {
+ *((u8 *)dest) = *((volatile u8 *)vsrc);
+ __asm__ __volatile__ ("eieio" : : : "memory");
+ vsrc = (void *)((unsigned long)vsrc + 1);
+ dest = (void *)((unsigned long)dest + 1);
+ n--;
+ }
+ while(n > 4) {
+ *((u32 *)dest) = *((volatile u32 *)vsrc);
+ __asm__ __volatile__ ("eieio" : : : "memory");
+ vsrc = (void *)((unsigned long)vsrc + 4);
+ dest = (void *)((unsigned long)dest + 4);
+ n -= 4;
+ }
+ while(n) {
+ *((u8 *)dest) = *((volatile u8 *)vsrc);
+ __asm__ __volatile__ ("eieio" : : : "memory");
+ vsrc = (void *)((unsigned long)vsrc + 1);
+ dest = (void *)((unsigned long)dest + 1);
+ n--;
+ }
+ __asm__ __volatile__ ("sync" : : : "memory");
+