patch-2.3.99-pre6 linux/include/video/fbcon.h

Next file: linux/init/main.c
Previous file: linux/include/net/x25.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.99-pre5/linux/include/video/fbcon.h linux/include/video/fbcon.h
@@ -192,6 +192,43 @@
 #define SCROLL_YNOPARTIAL	__SCROLL_YNOPARTIAL
 
 
+#if defined(__sparc__)
+
+/* We map all of our framebuffers such that big-endian accesses
+ * are what we want, so the following is sufficient.
+ */
+
+#define fb_readb sbus_readb
+#define fb_readw sbus_readw
+#define fb_readl sbus_readl
+#define fb_writeb sbus_writeb
+#define fb_writew sbus_writew
+#define fb_writel sbus_writel
+#define fb_memset sbus_memset_io
+
+#elif defined(__i386__) || defined(__alpha__)
+
+#define fb_readb __raw_readb
+#define fb_readw __raw_readw
+#define fb_readl __raw_readl
+#define fb_writeb __raw_writeb
+#define fb_writew __raw_writew
+#define fb_writel __raw_writel
+#define fb_memset memset_io
+
+#else
+
+#define fb_readb(addr) (*(volatile u8 *) (addr))
+#define fb_readw(addr) (*(volatile u16 *) (addr))
+#define fb_readl(addr) (*(volatile u32 *) (addr))
+#define fb_writeb(b,addr) (*(volatile u8 *) (addr) = (b))
+#define fb_writew(b,addr) (*(volatile u16 *) (addr) = (b))
+#define fb_writel(b,addr) (*(volatile u32 *) (addr) = (b))
+#define fb_memset memset
+
+#endif
+
+
 extern void fbcon_redraw_bmove(struct display *, int, int, int, int, int, int);
 
 
@@ -489,17 +526,68 @@
 
 static __inline__ void *fb_memclear_small(void *s, size_t count)
 {
-    return(memset(s, 0, count));
+    char *xs = (char *) s;
+
+    while (count--)
+	fb_writeb(0, xs++);
+
+    return s;
 }
 
 static __inline__ void *fb_memclear(void *s, size_t count)
 {
-    return(memset(s, 0, count));
+    unsigned long xs = (unsigned long) s;
+
+    if (count < 8)
+	goto rest;
+
+    if (xs & 1) {
+	fb_writeb(0, xs++);
+	count--;
+    }
+    if (xs & 2) {
+	fb_writew(0, xs);
+	xs += 2;
+	count -= 2;
+    }
+    while (count > 3) {
+	fb_writel(0, xs);
+	xs += 4;
+	count -= 4;
+    }
+rest:
+    while (count--)
+	fb_writeb(0, xs++);
+
+    return s;
 }
 
 static __inline__ void *fb_memset255(void *s, size_t count)
 {
-    return(memset(s, 255, count));
+    unsigned long xs = (unsigned long) s;
+
+    if (count < 8)
+	goto rest;
+
+    if (xs & 1) {
+	fb_writeb(0xff, xs++);
+	count--;
+    }
+    if (xs & 2) {
+	fb_writew(0xffff, xs);
+	xs += 2;
+	count -= 2;
+    }
+    while (count > 3) {
+	fb_writel(0xffffffff, xs);
+	xs += 4;
+	count -= 4;
+    }
+rest:
+    while (count--)
+	fb_writeb(0xff, xs++);
+
+    return s;
 }
 
 #if defined(__i386__)
@@ -553,7 +641,7 @@
     return dst;
 }
 
-#else /* !i386 */
+#else /* !__i386__ */
 
     /*
      *  Anyone who'd like to write asm functions for other CPUs?
@@ -562,53 +650,130 @@
 
 static __inline__ void *fb_memmove(void *d, const void *s, size_t count)
 {
-    return(memmove(d, s, count));
-}
+    unsigned long dst, src;
 
-static __inline__ void fast_memmove(char *dst, const char *src, size_t size)
-{
-    memmove(dst, src, size);
-}
+    if (d < s) {
+	dst = (unsigned long) d;
+	src = (unsigned long) s;
 
-#endif /* !i386 */
+	if ((count < 8) || ((dst ^ src) & 3))
+	    goto restup;
 
-#endif
+	if (dst & 1) {
+	    fb_writeb(fb_readb(src++), dst++);
+	    count--;
+	}
+	if (dst & 2) {
+	    fb_writew(fb_readw(src), dst);
+	    src += 2;
+	    dst += 2;
+	    count -= 2;
+	}
+	while (count > 3) {
+	    fb_writel(fb_readl(src), dst);
+	    src += 4;
+	    dst += 4;
+	    count -= 4;
+	}
+
+    restup:
+	while (count--)
+	    fb_writeb(fb_readb(src++), dst++);
+    } else {
+	dst = (unsigned long) d + count - 1;
+	src = (unsigned long) s + count - 1;
 
+	if ((count < 8) || ((dst ^ src) & 3))
+	    goto restdown;
 
-#if defined(__sparc__)
+	if (dst & 1) {
+	    fb_writeb(fb_readb(src--), dst--);
+	    count--;
+	}
+	if (dst & 2) {
+	    fb_writew(fb_readw(src), dst);
+	    src -= 2;
+	    dst -= 2;
+	    count -= 2;
+	}
+	while (count > 3) {
+	    fb_writel(fb_readl(src), dst);
+	    src -= 4;
+	    dst -= 4;
+	    count -= 4;
+	}
+
+    restdown:
+	while (count--)
+	    fb_writeb(fb_readb(src--), dst--);
+    }
 
-/* We map all of our framebuffers such that big-endian accesses
- * are what we want, so the following is sufficient.
- */
+    return d;
+}
 
-#define fb_readb sbus_readb
-#define fb_readw sbus_readw
-#define fb_readl sbus_readl
-#define fb_writeb sbus_writeb
-#define fb_writew sbus_writew
-#define fb_writel sbus_writel
-#define fb_memset sbus_memset_io
+static __inline__ void fast_memmove(char *d, const char *s, size_t count)
+{
+    unsigned long dst, src;
 
-#elif defined(__i386__) || defined(__alpha__)
+    if (d < s) {
+	dst = (unsigned long) d;
+	src = (unsigned long) s;
 
-#define fb_readb __raw_readb
-#define fb_readw __raw_readw
-#define fb_readl __raw_readl
-#define fb_writeb __raw_writeb
-#define fb_writew __raw_writew
-#define fb_writel __raw_writel
-#define fb_memset memset_io
+	if ((count < 8) || ((dst ^ src) & 3))
+	    goto restup;
 
-#else
+	if (dst & 1) {
+	    fb_writeb(fb_readb(src++), dst++);
+	    count--;
+	}
+	if (dst & 2) {
+	    fb_writew(fb_readw(src), dst);
+	    src += 2;
+	    dst += 2;
+	    count -= 2;
+	}
+	while (count > 3) {
+	    fb_writel(fb_readl(src), dst);
+	    src += 4;
+	    dst += 4;
+	    count -= 4;
+	}
+
+    restup:
+	while (count--)
+	    fb_writeb(fb_readb(src++), dst++);
+    } else {
+	dst = (unsigned long) d + count - 1;
+	src = (unsigned long) s + count - 1;
 
-#define fb_readb(addr) (*(volatile u8 *) (addr))
-#define fb_readw(addr) (*(volatile u16 *) (addr))
-#define fb_readl(addr) (*(volatile u32 *) (addr))
-#define fb_writeb(b,addr) (*(volatile u8 *) (addr) = (b))
-#define fb_writew(b,addr) (*(volatile u16 *) (addr) = (b))
-#define fb_writel(b,addr) (*(volatile u32 *) (addr) = (b))
-#define fb_memset memset
+	if ((count < 8) || ((dst ^ src) & 3))
+	    goto restdown;
 
-#endif
+	if (dst & 1) {
+	    fb_writeb(fb_readb(src--), dst--);
+	    count--;
+	}
+	if (dst & 2) {
+	    fb_writew(fb_readw(src), dst);
+	    src -= 2;
+	    dst -= 2;
+	    count -= 2;
+	}
+	while (count > 3) {
+	    fb_writel(fb_readl(src), dst);
+	    src -= 4;
+	    dst -= 4;
+	    count -= 4;
+	}
+
+    restdown:
+	while (count--)
+	    fb_writeb(fb_readb(src--), dst--);
+    }
+}
+
+#endif /* !__i386__ */
+
+#endif /* !__mc68000__ */
 
 #endif /* _VIDEO_FBCON_H */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)