diff options
-rw-r--r-- | arch/sparc/include/asm/io_32.h | 31 | ||||
-rw-r--r-- | arch/sparc/include/asm/io_64.h | 31 | ||||
-rw-r--r-- | drivers/video/fbmem.c | 46 | ||||
-rw-r--r-- | include/linux/fb.h | 6 |
4 files changed, 82 insertions, 32 deletions
diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h index 2889574608db..c2ced21c9dc1 100644 --- a/arch/sparc/include/asm/io_32.h +++ b/arch/sparc/include/asm/io_32.h | |||
@@ -208,6 +208,21 @@ _memset_io(volatile void __iomem *dst, int c, __kernel_size_t n) | |||
208 | #define memset_io(d,c,sz) _memset_io(d,c,sz) | 208 | #define memset_io(d,c,sz) _memset_io(d,c,sz) |
209 | 209 | ||
210 | static inline void | 210 | static inline void |
211 | _sbus_memcpy_fromio(void *dst, const volatile void __iomem *src, | ||
212 | __kernel_size_t n) | ||
213 | { | ||
214 | char *d = dst; | ||
215 | |||
216 | while (n--) { | ||
217 | char tmp = sbus_readb(src); | ||
218 | *d++ = tmp; | ||
219 | src++; | ||
220 | } | ||
221 | } | ||
222 | |||
223 | #define sbus_memcpy_fromio(d, s, sz) _sbus_memcpy_fromio(d, s, sz) | ||
224 | |||
225 | static inline void | ||
211 | _memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n) | 226 | _memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n) |
212 | { | 227 | { |
213 | char *d = dst; | 228 | char *d = dst; |
@@ -222,6 +237,22 @@ _memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n) | |||
222 | #define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz) | 237 | #define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz) |
223 | 238 | ||
224 | static inline void | 239 | static inline void |
240 | _sbus_memcpy_toio(volatile void __iomem *dst, const void *src, | ||
241 | __kernel_size_t n) | ||
242 | { | ||
243 | const char *s = src; | ||
244 | volatile void __iomem *d = dst; | ||
245 | |||
246 | while (n--) { | ||
247 | char tmp = *s++; | ||
248 | sbus_writeb(tmp, d); | ||
249 | d++; | ||
250 | } | ||
251 | } | ||
252 | |||
253 | #define sbus_memcpy_toio(d, s, sz) _sbus_memcpy_toio(d, s, sz) | ||
254 | |||
255 | static inline void | ||
225 | _memcpy_toio(volatile void __iomem *dst, const void *src, __kernel_size_t n) | 256 | _memcpy_toio(volatile void __iomem *dst, const void *src, __kernel_size_t n) |
226 | { | 257 | { |
227 | const char *s = src; | 258 | const char *s = src; |
diff --git a/arch/sparc/include/asm/io_64.h b/arch/sparc/include/asm/io_64.h index 9517d063c79c..9c8965415f0a 100644 --- a/arch/sparc/include/asm/io_64.h +++ b/arch/sparc/include/asm/io_64.h | |||
@@ -419,6 +419,21 @@ _memset_io(volatile void __iomem *dst, int c, __kernel_size_t n) | |||
419 | #define memset_io(d,c,sz) _memset_io(d,c,sz) | 419 | #define memset_io(d,c,sz) _memset_io(d,c,sz) |
420 | 420 | ||
421 | static inline void | 421 | static inline void |
422 | _sbus_memcpy_fromio(void *dst, const volatile void __iomem *src, | ||
423 | __kernel_size_t n) | ||
424 | { | ||
425 | char *d = dst; | ||
426 | |||
427 | while (n--) { | ||
428 | char tmp = sbus_readb(src); | ||
429 | *d++ = tmp; | ||
430 | src++; | ||
431 | } | ||
432 | } | ||
433 | |||
434 | #define sbus_memcpy_fromio(d, s, sz) _sbus_memcpy_fromio(d, s, sz) | ||
435 | |||
436 | static inline void | ||
422 | _memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n) | 437 | _memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n) |
423 | { | 438 | { |
424 | char *d = dst; | 439 | char *d = dst; |
@@ -433,6 +448,22 @@ _memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n) | |||
433 | #define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz) | 448 | #define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz) |
434 | 449 | ||
435 | static inline void | 450 | static inline void |
451 | _sbus_memcpy_toio(volatile void __iomem *dst, const void *src, | ||
452 | __kernel_size_t n) | ||
453 | { | ||
454 | const char *s = src; | ||
455 | volatile void __iomem *d = dst; | ||
456 | |||
457 | while (n--) { | ||
458 | char tmp = *s++; | ||
459 | sbus_writeb(tmp, d); | ||
460 | d++; | ||
461 | } | ||
462 | } | ||
463 | |||
464 | #define sbus_memcpy_toio(d, s, sz) _sbus_memcpy_toio(d, s, sz) | ||
465 | |||
466 | static inline void | ||
436 | _memcpy_toio(volatile void __iomem *dst, const void *src, __kernel_size_t n) | 467 | _memcpy_toio(volatile void __iomem *dst, const void *src, __kernel_size_t n) |
437 | { | 468 | { |
438 | const char *s = src; | 469 | const char *s = src; |
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index a43442341ddd..0e6aa3d96a42 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c | |||
@@ -697,9 +697,9 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | |||
697 | struct inode *inode = file->f_path.dentry->d_inode; | 697 | struct inode *inode = file->f_path.dentry->d_inode; |
698 | int fbidx = iminor(inode); | 698 | int fbidx = iminor(inode); |
699 | struct fb_info *info = registered_fb[fbidx]; | 699 | struct fb_info *info = registered_fb[fbidx]; |
700 | u32 *buffer, *dst; | 700 | u8 *buffer, *dst; |
701 | u32 __iomem *src; | 701 | u8 __iomem *src; |
702 | int c, i, cnt = 0, err = 0; | 702 | int c, cnt = 0, err = 0; |
703 | unsigned long total_size; | 703 | unsigned long total_size; |
704 | 704 | ||
705 | if (!info || ! info->screen_base) | 705 | if (!info || ! info->screen_base) |
@@ -730,7 +730,7 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | |||
730 | if (!buffer) | 730 | if (!buffer) |
731 | return -ENOMEM; | 731 | return -ENOMEM; |
732 | 732 | ||
733 | src = (u32 __iomem *) (info->screen_base + p); | 733 | src = (u8 __iomem *) (info->screen_base + p); |
734 | 734 | ||
735 | if (info->fbops->fb_sync) | 735 | if (info->fbops->fb_sync) |
736 | info->fbops->fb_sync(info); | 736 | info->fbops->fb_sync(info); |
@@ -738,17 +738,9 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | |||
738 | while (count) { | 738 | while (count) { |
739 | c = (count > PAGE_SIZE) ? PAGE_SIZE : count; | 739 | c = (count > PAGE_SIZE) ? PAGE_SIZE : count; |
740 | dst = buffer; | 740 | dst = buffer; |
741 | for (i = c >> 2; i--; ) | 741 | fb_memcpy_fromfb(dst, src, c); |
742 | *dst++ = fb_readl(src++); | 742 | dst += c; |
743 | if (c & 3) { | 743 | src += c; |
744 | u8 *dst8 = (u8 *) dst; | ||
745 | u8 __iomem *src8 = (u8 __iomem *) src; | ||
746 | |||
747 | for (i = c & 3; i--;) | ||
748 | *dst8++ = fb_readb(src8++); | ||
749 | |||
750 | src = (u32 __iomem *) src8; | ||
751 | } | ||
752 | 744 | ||
753 | if (copy_to_user(buf, buffer, c)) { | 745 | if (copy_to_user(buf, buffer, c)) { |
754 | err = -EFAULT; | 746 | err = -EFAULT; |
@@ -772,9 +764,9 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | |||
772 | struct inode *inode = file->f_path.dentry->d_inode; | 764 | struct inode *inode = file->f_path.dentry->d_inode; |
773 | int fbidx = iminor(inode); | 765 | int fbidx = iminor(inode); |
774 | struct fb_info *info = registered_fb[fbidx]; | 766 | struct fb_info *info = registered_fb[fbidx]; |
775 | u32 *buffer, *src; | 767 | u8 *buffer, *src; |
776 | u32 __iomem *dst; | 768 | u8 __iomem *dst; |
777 | int c, i, cnt = 0, err = 0; | 769 | int c, cnt = 0, err = 0; |
778 | unsigned long total_size; | 770 | unsigned long total_size; |
779 | 771 | ||
780 | if (!info || !info->screen_base) | 772 | if (!info || !info->screen_base) |
@@ -811,7 +803,7 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | |||
811 | if (!buffer) | 803 | if (!buffer) |
812 | return -ENOMEM; | 804 | return -ENOMEM; |
813 | 805 | ||
814 | dst = (u32 __iomem *) (info->screen_base + p); | 806 | dst = (u8 __iomem *) (info->screen_base + p); |
815 | 807 | ||
816 | if (info->fbops->fb_sync) | 808 | if (info->fbops->fb_sync) |
817 | info->fbops->fb_sync(info); | 809 | info->fbops->fb_sync(info); |
@@ -825,19 +817,9 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | |||
825 | break; | 817 | break; |
826 | } | 818 | } |
827 | 819 | ||
828 | for (i = c >> 2; i--; ) | 820 | fb_memcpy_tofb(dst, src, c); |
829 | fb_writel(*src++, dst++); | 821 | dst += c; |
830 | 822 | src += c; | |
831 | if (c & 3) { | ||
832 | u8 *src8 = (u8 *) src; | ||
833 | u8 __iomem *dst8 = (u8 __iomem *) dst; | ||
834 | |||
835 | for (i = c & 3; i--; ) | ||
836 | fb_writeb(*src8++, dst8++); | ||
837 | |||
838 | dst = (u32 __iomem *) dst8; | ||
839 | } | ||
840 | |||
841 | *ppos += c; | 823 | *ppos += c; |
842 | buf += c; | 824 | buf += c; |
843 | cnt += c; | 825 | cnt += c; |
diff --git a/include/linux/fb.h b/include/linux/fb.h index f0268deca658..7fca3dc4e475 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h | |||
@@ -931,6 +931,8 @@ static inline struct apertures_struct *alloc_apertures(unsigned int max_num) { | |||
931 | #define fb_writel sbus_writel | 931 | #define fb_writel sbus_writel |
932 | #define fb_writeq sbus_writeq | 932 | #define fb_writeq sbus_writeq |
933 | #define fb_memset sbus_memset_io | 933 | #define fb_memset sbus_memset_io |
934 | #define fb_memcpy_fromfb sbus_memcpy_fromio | ||
935 | #define fb_memcpy_tofb sbus_memcpy_toio | ||
934 | 936 | ||
935 | #elif defined(__i386__) || defined(__alpha__) || defined(__x86_64__) || defined(__hppa__) || defined(__sh__) || defined(__powerpc__) || defined(__avr32__) || defined(__bfin__) | 937 | #elif defined(__i386__) || defined(__alpha__) || defined(__x86_64__) || defined(__hppa__) || defined(__sh__) || defined(__powerpc__) || defined(__avr32__) || defined(__bfin__) |
936 | 938 | ||
@@ -943,6 +945,8 @@ static inline struct apertures_struct *alloc_apertures(unsigned int max_num) { | |||
943 | #define fb_writel __raw_writel | 945 | #define fb_writel __raw_writel |
944 | #define fb_writeq __raw_writeq | 946 | #define fb_writeq __raw_writeq |
945 | #define fb_memset memset_io | 947 | #define fb_memset memset_io |
948 | #define fb_memcpy_fromfb memcpy_fromio | ||
949 | #define fb_memcpy_tofb memcpy_toio | ||
946 | 950 | ||
947 | #else | 951 | #else |
948 | 952 | ||
@@ -955,6 +959,8 @@ static inline struct apertures_struct *alloc_apertures(unsigned int max_num) { | |||
955 | #define fb_writel(b,addr) (*(volatile u32 *) (addr) = (b)) | 959 | #define fb_writel(b,addr) (*(volatile u32 *) (addr) = (b)) |
956 | #define fb_writeq(b,addr) (*(volatile u64 *) (addr) = (b)) | 960 | #define fb_writeq(b,addr) (*(volatile u64 *) (addr) = (b)) |
957 | #define fb_memset memset | 961 | #define fb_memset memset |
962 | #define fb_memcpy_fromfb memcpy | ||
963 | #define fb_memcpy_tofb memcpy | ||
958 | 964 | ||
959 | #endif | 965 | #endif |
960 | 966 | ||