Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-7]: src/sys/arch/luna68k/dev Pull up following revision(s) (reque...



details:   https://anonhg.NetBSD.org/src/rev/efe5b953d6fd
branches:  netbsd-7
changeset: 798400:efe5b953d6fd
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Oct 05 20:12:49 2014 +0000

description:
Pull up following revision(s) (requested by tsutsui in ticket #130):
        sys/arch/luna68k/dev/omrasops.c: revision 1.17
        sys/arch/luna68k/dev/omrasops.c: revision 1.18
        sys/arch/luna68k/dev/omrasops.c: revision 1.19
        sys/arch/luna68k/dev/omrasopsvar.h: revision 1.3
        sys/arch/luna68k/dev/lunafb.c: revision 1.36
Pull readability changes from OpenBSD/luna88k.
- prepare and use unpack_attr() function to get fg and bg from attribute
- use proper variable names to clarify meanings
Tested on LUNA-II with 8bpp framebuffer.
Put dumb optimizations to avoid conditionals in putchar drawing loops.
~10% improvements of time cat results on LUNA-II 8bpp framebuffer.
Pull LUNA's framebuffer improvements by Kenji Aoyama from OpenBSD/luna88k.
http://marc.info/?l=openbsd-cvs&m=141199909120631&w=2
> Use raster(logic) operation, or ROP, function on LUNA frame buffer.
> It makes 4bpp wscons putchar ~20% faster.
This Makes 4bpp wscons putchar ~30% on LUNA-II.
Also use the similar ROP in 1bpp putchar and cursor functions
and the 1bpp putchar is also ~5% faster.
While here, reduce diffs from OpenBSD a bit.
Tested on all 1bpp/4bpp/8bpp framebuffers.

diffstat:

 sys/arch/luna68k/dev/lunafb.c      |    9 +-
 sys/arch/luna68k/dev/omrasops.c    |  377 +++++++++++++++++++++---------------
 sys/arch/luna68k/dev/omrasopsvar.h |   87 ++++++--
 3 files changed, 288 insertions(+), 185 deletions(-)

diffs (truncated from 835 to 300 lines):

diff -r aced92e00ebe -r efe5b953d6fd sys/arch/luna68k/dev/lunafb.c
--- a/sys/arch/luna68k/dev/lunafb.c     Sun Oct 05 20:00:54 2014 +0000
+++ b/sys/arch/luna68k/dev/lunafb.c     Sun Oct 05 20:12:49 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lunafb.c,v 1.35 2014/07/25 16:40:12 tsutsui Exp $ */
+/* $NetBSD: lunafb.c,v 1.35.2.1 2014/10/05 20:12:49 martin Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.35 2014/07/25 16:40:12 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.35.2.1 2014/10/05 20:12:49 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -75,11 +75,8 @@
 };
 
 #define        OMFB_RFCNT      0xB1000000      /* video h-origin/v-origin */
-#define        OMFB_PLANEMASK  0xB1040000      /* planemask register */
-#define        OMFB_FB_WADDR   0xB1080008      /* common plane */
-#define        OMFB_FB_RADDR   0xB10C0008      /* plane #0 */
-#define        OMFB_ROPFUNC    0xB12C0000      /* ROP function code */
 #define        OMFB_RAMDAC     0xC1100000      /* Bt454/Bt458 RAMDAC */
+
 #define        OMFB_SIZE       (0xB1300000 - 0xB1080000 + PAGE_SIZE)
 
 struct hwcmap {
diff -r aced92e00ebe -r efe5b953d6fd sys/arch/luna68k/dev/omrasops.c
--- a/sys/arch/luna68k/dev/omrasops.c   Sun Oct 05 20:00:54 2014 +0000
+++ b/sys/arch/luna68k/dev/omrasops.c   Sun Oct 05 20:12:49 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: omrasops.c,v 1.16 2013/12/28 09:17:23 tsutsui Exp $ */
+/* $NetBSD: omrasops.c,v 1.16.4.1 2014/10/05 20:12:49 martin Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.16 2013/12/28 09:17:23 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.16.4.1 2014/10/05 20:12:49 martin Exp $");
 
 /*
  * Designed speficically for 'm68k bitorder';
@@ -68,6 +68,7 @@
 static void    om4_eraserows(void *, int, int, long);
 static int     om1_allocattr(void *, int, int, int, long *);
 static int     om4_allocattr(void *, int, int, int, long *);
+static void    om4_unpack_attr(long, int *, int *, int *);
 
 static int     omrasops_init(struct rasops_info *, int, int);
 
@@ -77,13 +78,6 @@
 #define        ALIGNMASK       (0x1f)
 #define        BYTESDONE       (4)
 
-#define        W(p) (*(uint32_t *)(p))
-#define        R(p) (*(uint32_t *)((uint8_t *)(p) + 0x40000))
-#define        P0(p) (*(uint32_t *)((uint8_t *)(p) + 0x40000))
-#define        P1(p) (*(uint32_t *)((uint8_t *)(p) + 0x80000))
-#define        P2(p) (*(uint32_t *)((uint8_t *)(p) + 0xc0000))
-#define        P3(p) (*(uint32_t *)((uint8_t *)(p) + 0x100000))
-
 /*
  * macros to handle unaligned bit copy ops.
  * See src/sys/dev/rasops/rasops_mask.h for MI version.
@@ -95,13 +89,13 @@
 #define        FASTGETBITS(psrc, x, w, dst)                                    \
        asm("bfextu %3{%1:%2},%0"                                       \
            : "=d" (dst)                                                \
-           : "di" (x), "di" (w), "o" ((uint32_t *)(psrc)))
+           : "di" (x), "di" (w), "o" (*(uint32_t *)(psrc)))
 
 /* luna68k version PUTBITS() that puts w bits from bit x at pdst memory */
 /* XXX this macro assumes (x + w) <= 32 to handle unaligned residual bits */
 #define        FASTPUTBITS(src, x, w, pdst)                                    \
        asm("bfins %3,%0{%1:%2}"                                        \
-           : "+o" ((uint32_t *)(pdst))                                 \
+           : "+o" (*(uint32_t *)(pdst))                                \
            : "di" (x), "di" (w), "d" (src)                             \
            : "memory" );
 
@@ -136,16 +130,23 @@
        rmask = ALL1BITS << (-width & ALIGNMASK);
        if (width <= BLITWIDTH) {
                lmask &= rmask;
+               /* set lmask as ROP mask value, with THROUGH mode */
+               ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = lmask;
+
                while (height > 0) {
                        glyph = 0;
                        for (i = ri->ri_font->stride; i != 0; i--)
                                glyph = (glyph << 8) | *fb++;
                        glyph <<= (4 - ri->ri_font->stride) * NBBY;
                        glyph = (glyph >> align) ^ inverse;
-                       P0(p) = (P0(p) & ~lmask) | (glyph & lmask);
+
+                       *W(p) = glyph;
+
                        p += scanspan;
                        height--;
                }
+               /* reset mask value */
+               ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS;
        } else {
                uint8_t *q = p;
                uint32_t lhalf, rhalf;
@@ -156,14 +157,26 @@
                                glyph = (glyph << 8) | *fb++;
                        glyph <<= (4 - ri->ri_font->stride) * NBBY;
                        lhalf = (glyph >> align) ^ inverse;
-                       P0(p) = (P0(p) & ~lmask) | (lhalf & lmask);
+                       /* set lmask as ROP mask value, with THROUGH mode */
+                       ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] =
+                           lmask;
+                       
+                       *W(p) = lhalf;
+
                        p += BYTESDONE;
+
                        rhalf = (glyph << (BLITWIDTH - align)) ^ inverse;
-                       P0(p) = (rhalf & rmask) | (P0(p) & ~rmask);
+                       /* set rmask as ROP mask value, with THROUGH mode */
+                       ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] =
+                           rmask;
+
+                       *W(p) = rhalf;
 
                        p = (q += scanspan);
                        height--;
                }
+               /* reset mask value */
+               ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS;
        }
 }
 
@@ -173,9 +186,10 @@
        struct rasops_info *ri = cookie;
        uint8_t *p;
        int scanspan, startx, height, width, align, y;
-       uint32_t lmask, rmask, glyph;
-       uint32_t glyphbg, fg, bg;
-       int i;
+       uint32_t lmask, rmask, glyph, glyphbg, fgpat, bgpat;
+       uint32_t fgmask0, fgmask1, fgmask2, fgmask3;
+       uint32_t bgmask0, bgmask1, bgmask2, bgmask3;
+       int i, fg, bg;
        uint8_t *fb;
 
        scanspan = ri->ri_stride;
@@ -184,14 +198,30 @@
        height = ri->ri_font->fontheight;
        fb = (uint8_t *)ri->ri_font->data +
            (uc - ri->ri_font->firstchar) * ri->ri_fontscale;
+       om4_unpack_attr(attr, &fg, &bg, NULL);
+       fgmask0 = (fg & 0x01) ? ALL1BITS : ALL0BITS;
+       fgmask1 = (fg & 0x02) ? ALL1BITS : ALL0BITS;
+       fgmask2 = (fg & 0x04) ? ALL1BITS : ALL0BITS;
+       fgmask3 = (fg & 0x08) ? ALL1BITS : ALL0BITS;
+       bgmask0 = (bg & 0x01) ? ALL1BITS : ALL0BITS;
+       bgmask1 = (bg & 0x02) ? ALL1BITS : ALL0BITS;
+       bgmask2 = (bg & 0x04) ? ALL1BITS : ALL0BITS;
+       bgmask3 = (bg & 0x08) ? ALL1BITS : ALL0BITS;
 
        p = (uint8_t *)ri->ri_bits + y * scanspan + ((startx / 32) * 4);
        align = startx & ALIGNMASK;
        width = ri->ri_font->fontwidth + align;
        lmask = ALL1BITS >> align;
        rmask = ALL1BITS << (-width & ALIGNMASK);
+
+       /* select all planes for later ROP function target */
+       *(volatile uint32_t *)OMFB_PLANEMASK = 0xff;
+
        if (width <= BLITWIDTH) {
                lmask &= rmask;
+               /* set lmask as ROP mask value, with THROUGH mode */
+               ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = lmask;
+
                while (height > 0) {
                        glyph = 0;
                        for (i = ri->ri_font->stride; i != 0; i--)
@@ -199,21 +229,25 @@
                        glyph <<= (4 - ri->ri_font->stride) * NBBY;
                        glyph = (glyph >> align);
                        glyphbg = glyph ^ ALL1BITS;
-                       fg = (attr & 0x01000000) ? glyph : 0;
-                       bg = (attr & 0x00010000) ? glyphbg : 0;
-                       P0(p) = (P0(p) & ~lmask) | ((fg | bg) & lmask);
-                       fg = (attr & 0x02000000) ? glyph : 0;
-                       bg = (attr & 0x00020000) ? glyphbg : 0;
-                       P1(p) = (P1(p) & ~lmask) | ((fg | bg) & lmask);
-                       fg = (attr & 0x04000000) ? glyph : 0;
-                       bg = (attr & 0x00040000) ? glyphbg : 0;
-                       P2(p) = (P2(p) & ~lmask) | ((fg | bg) & lmask);
-                       fg = (attr & 0x08000000) ? glyph : 0;
-                       bg = (attr & 0x00080000) ? glyphbg : 0;
-                       P3(p) = (P3(p) & ~lmask) | ((fg | bg) & lmask);
+
+                       fgpat = glyph   & fgmask0;
+                       bgpat = glyphbg & bgmask0;
+                       *P0(p) = (fgpat | bgpat);
+                       fgpat = glyph   & fgmask1;
+                       bgpat = glyphbg & bgmask1;
+                       *P1(p) = (fgpat | bgpat);
+                       fgpat = glyph   & fgmask2;
+                       bgpat = glyphbg & bgmask2;
+                       *P2(p) = (fgpat | bgpat);
+                       fgpat = glyph   & fgmask3;
+                       bgpat = glyphbg & bgmask3;
+                       *P3(p) = (fgpat | bgpat);
+
                        p += scanspan;
                        height--;
                }
+               /* reset mask value */
+               ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS;
        } else {
                uint8_t *q = p;
                uint32_t lhalf, rhalf;
@@ -226,38 +260,52 @@
                        glyph <<= (4 - ri->ri_font->stride) * NBBY;
                        lhalf = (glyph >> align);
                        lhalfbg = lhalf ^ ALL1BITS;
-                       fg = (attr & 0x01000000) ? lhalf : 0;
-                       bg = (attr & 0x00010000) ? lhalfbg : 0;
-                       P0(p) = (P0(p) & ~lmask) | ((fg | bg) & lmask);
-                       fg = (attr & 0x02000000) ? lhalf : 0;
-                       bg = (attr & 0x00020000) ? lhalfbg : 0;
-                       P1(p) = (P1(p) & ~lmask) | ((fg | bg) & lmask);
-                       fg = (attr & 0x04000000) ? lhalf : 0;
-                       bg = (attr & 0x00040000) ? lhalfbg : 0;
-                       P2(p) = (P2(p) & ~lmask) | ((fg | bg) & lmask);
-                       fg = (attr & 0x08000000) ? lhalf : 0;
-                       bg = (attr & 0x00080000) ? lhalfbg : 0;
-                       P3(p) = (P3(p) & ~lmask) | ((fg | bg) & lmask);
+                       /* set lmask as ROP mask value, with THROUGH mode */
+                       ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] =
+                           lmask;
+
+                       fgpat = lhalf   & fgmask0;
+                       bgpat = lhalfbg & bgmask0;
+                       *P0(p) = (fgpat | bgpat);
+                       fgpat = lhalf   & fgmask1;
+                       bgpat = lhalfbg & bgmask1;
+                       *P1(p) = (fgpat | bgpat);
+                       fgpat = lhalf   & fgmask2;
+                       bgpat = lhalfbg & bgmask2;
+                       *P2(p) = (fgpat | bgpat);
+                       fgpat = lhalf   & fgmask3;
+                       bgpat = lhalfbg & bgmask3;
+                       *P3(p) = (fgpat | bgpat);
+
                        p += BYTESDONE;
+
                        rhalf = (glyph << (BLITWIDTH - align));
                        rhalfbg = rhalf ^ ALL1BITS;
-                       fg = (attr & 0x01000000) ? rhalf : 0;
-                       bg = (attr & 0x00010000) ? rhalfbg : 0;
-                       P0(p) = ((fg | bg) & rmask) | (P0(p) & ~rmask);
-                       fg = (attr & 0x02000000) ? rhalf : 0;
-                       bg = (attr & 0x00020000) ? rhalfbg : 0;
-                       P1(p) = ((fg | bg) & rmask) | (P1(p) & ~rmask);
-                       fg = (attr & 0x04000000) ? rhalf : 0;
-                       bg = (attr & 0x00040000) ? rhalfbg : 0;
-                       P2(p) = ((fg | bg) & rmask) | (P2(p) & ~rmask);
-                       fg = (attr & 0x08000000) ? rhalf : 0;
-                       bg = (attr & 0x00080000) ? rhalfbg : 0;
-                       P3(p) = ((fg | bg) & rmask) | (P3(p) & ~rmask);
+                       /* set rmask as ROP mask value, with THROUGH mode */
+                       ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] =
+                           rmask;
+
+                       fgpat = rhalf   & fgmask0;
+                       bgpat = rhalfbg & bgmask0;
+                       *P0(p) = (fgpat | bgpat);
+                       fgpat = rhalf   & fgmask1;
+                       bgpat = rhalfbg & bgmask1;
+                       *P1(p) = (fgpat | bgpat);
+                       fgpat = rhalf   & fgmask2;
+                       bgpat = rhalfbg & bgmask2;
+                       *P2(p) = (fgpat | bgpat);
+                       fgpat = rhalf   & fgmask3;
+                       bgpat = rhalfbg & bgmask3;
+                       *P3(p) = (fgpat | bgpat);
 
                        p = (q += scanspan);
                        height--;
                }
+               /* reset mask value */
+               ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS;
        }
+       /* select plane #0 only; XXX need this ? */
+       *(volatile uint32_t *)OMFB_PLANEMASK = 0x01;
 }
 



Home | Main Index | Thread Index | Old Index