From owner-svn-src-all@freebsd.org Wed Apr 12 20:18:39 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BE608D3AACD; Wed, 12 Apr 2017 20:18:39 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 99E8CC44; Wed, 12 Apr 2017 20:18:39 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3CKIcp5019867; Wed, 12 Apr 2017 20:18:38 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3CKIcHe019866; Wed, 12 Apr 2017 20:18:38 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201704122018.v3CKIcHe019866@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Wed, 12 Apr 2017 20:18:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316741 - head/sys/dev/syscons X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Apr 2017 20:18:39 -0000 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 */ }