Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Apr 2017 20:18:38 +0000 (UTC)
From:      Bruce Evans <bde@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r316741 - head/sys/dev/syscons
Message-ID:  <201704122018.v3CKIcHe019866@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bde
Date: Wed Apr 12 20:18:38 2017
New Revision: 316741
URL: https://svnweb.freebsd.org/changeset/base/316741

Log:
  Improve drawing of the vga planar mode mouse image a little.  Unobfuscate
  the method a lot.
  
  Reduce the AND mask to the complement of the cursor's frame, so that area
  inside the frame is not drawn first in black and then in lightwhite.  The
  AND-OR method is only directly suitable for the text mouse image, since
  it doesn't go to the hardware there.  Planar mode Mouse cursor drawing
  takes 10-20 usec on my Haswell system (approx. 100 graphics accesses
  at 130 nsec each), so the transient was not visible.
  
  The method used the fancy read mode 1 and its color compare and color
  don't care registers with value 0 in them so that all colors matched.
  All that this did was make byte reads of frame buffer memory return 0xff,
  so that the x86 case could obfuscate read+write as "and".  The read must
  be done for its side effect on the graphics controller but is not used,
  except it must return 0xff to avoid affecting the write when the write
  is obfuscated as a read-modify-write "and".  Perhaps that was a good
  optimization for 8088 CPUs where each extra instruction byte took as
  long as a byte memory access.
  
  Just use read+write after removing the fancy read mode.  Remove x86
  ifdefs that did the "and".  After removing the "and" in the non-x86
  part of the ifdefs, fix 4 of 6 cases where the shift was wrong.

Modified:
  head/sys/dev/syscons/scvgarndr.c

Modified: head/sys/dev/syscons/scvgarndr.c
==============================================================================
--- head/sys/dev/syscons/scvgarndr.c	Wed Apr 12 20:08:39 2017	(r316740)
+++ head/sys/dev/syscons/scvgarndr.c	Wed Apr 12 20:18:38 2017	(r316741)
@@ -1038,34 +1038,26 @@ draw_pxlmouse_planar(scr_stat *scp, int 
 	yoff = y - rounddown(y, line_width);
 	ymax = imin(y + 16, scp->ypixel);
 
-	outw(GDCIDX, 0x0805);		/* read mode 1, write mode 0 */
+	outw(GDCIDX, 0x0005);		/* read mode 0, write mode 0 */
 	outw(GDCIDX, 0x0001);		/* set/reset enable */
-	outw(GDCIDX, 0x0002);		/* color compare */
-	outw(GDCIDX, 0x0007);		/* color don't care */
 	outw(GDCIDX, 0xff08);		/* bit mask */
 	outw(GDCIDX, 0x0803);		/* data rotate/function select (and) */
 	p = scp->sc->adp->va_window + line_width*y + x/8;
 	if (x < scp->xpixel - 8) {
 		for (i = y, j = 0; i < ymax; ++i, ++j) {
-			m = ~(mouse_and_mask[j] >> xoff);
-#if defined(__i386__) || defined(__amd64__)
-			*(u_char *)p &= m >> 8;
-			*(u_char *)(p + 1) &= m;
-#else
-			writeb(p, readb(p) & (m >> 8));
-			writeb(p + 1, readb(p + 1) & (m >> 8));
-#endif
+			m = ~((mouse_and_mask[j] & ~mouse_or_mask[j]) >> xoff);
+			readb(p);
+			writeb(p, m >> 8);
+			readb(p + 1);
+			writeb(p + 1, m);
 			p += line_width;
 		}
 	} else {
 		xoff += 8;
 		for (i = y, j = 0; i < ymax; ++i, ++j) {
-			m = ~(mouse_and_mask[j] >> xoff);
-#if defined(__i386__) || defined(__amd64__)
-			*(u_char *)p &= m;
-#else
-			writeb(p, readb(p) & (m >> 8));
-#endif
+			m = ~((mouse_and_mask[j] & ~mouse_or_mask[j]) >> xoff);
+			readb(p);
+			writeb(p, m);
 			p += line_width;
 		}
 	}
@@ -1074,27 +1066,20 @@ draw_pxlmouse_planar(scr_stat *scp, int 
 	if (x < scp->xpixel - 8) {
 		for (i = y, j = 0; i < ymax; ++i, ++j) {
 			m = mouse_or_mask[j] >> xoff;
-#if defined(__i386__) || defined(__amd64__)
-			*(u_char *)p &= m >> 8;
-			*(u_char *)(p + 1) &= m;
-#else
-			writeb(p, readb(p) & (m >> 8));
-			writeb(p + 1, readb(p + 1) & (m >> 8));
-#endif
+			readb(p);
+			writeb(p, m >> 8);
+			readb(p + 1);
+			writeb(p + 1, m);
 			p += line_width;
 		}
 	} else {
 		for (i = y, j = 0; i < ymax; ++i, ++j) {
 			m = mouse_or_mask[j] >> xoff;
-#if defined(__i386__) || defined(__amd64__)
-			*(u_char *)p &= m;
-#else
-			writeb(p, readb(p) & (m >> 8));
-#endif
+			readb(p);
+			writeb(p, m);
 			p += line_width;
 		}
 	}
-	outw(GDCIDX, 0x0005);		/* read mode 0, write mode 0 */
 	outw(GDCIDX, 0x0003);		/* data rotate/function select */
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704122018.v3CKIcHe019866>