Created
September 17, 2014 14:01
-
-
Save ao-kenji/5a9a77efd82d9c07360c to your computer and use it in GitHub Desktop.
Using 'OR2' ROP version.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Index: omrasops.c | |
| =================================================================== | |
| RCS file: /cvs/src/sys/arch/luna88k/dev/omrasops.c,v | |
| retrieving revision 1.11 | |
| diff -u -r1.11 omrasops.c | |
| --- omrasops.c 2 Jan 2014 15:30:34 -0000 1.11 | |
| +++ omrasops.c 17 Sep 2014 13:53:16 -0000 | |
| @@ -158,7 +158,7 @@ | |
| struct rasops_info *ri = cookie; | |
| u_int8_t *p; | |
| int scanspan, startx, height, width, align, y; | |
| - u_int32_t lmask, rmask, glyph, glyphbg, fgpat, bgpat; | |
| + u_int32_t lmask, rmask, glyph; | |
| int i, fg, bg; | |
| u_int8_t *fb; | |
| @@ -183,20 +183,17 @@ | |
| glyph = (glyph << 8) | *fb++; | |
| glyph <<= (4 - ri->ri_font->stride) * NBBY; | |
| glyph = (glyph >> align); | |
| - glyphbg = glyph ^ ALL1BITS; | |
| - fgpat = (fg & 0x01) ? glyph : 0; | |
| - bgpat = (bg & 0x01) ? glyphbg : 0; | |
| - *P0(p) = (*P0(p) & ~lmask) | ((fgpat | bgpat) & lmask); | |
| - fgpat = (fg & 0x02) ? glyph : 0; | |
| - bgpat = (bg & 0x02) ? glyphbg : 0; | |
| - *P1(p) = (*P1(p) & ~lmask) | ((fgpat | bgpat) & lmask); | |
| - fgpat = (fg & 0x04) ? glyph : 0; | |
| - bgpat = (bg & 0x04) ? glyphbg : 0; | |
| - *P2(p) = (*P2(p) & ~lmask) | ((fgpat | bgpat) & lmask); | |
| - fgpat = (fg & 0x08) ? glyph : 0; | |
| - bgpat = (bg & 0x08) ? glyphbg : 0; | |
| - *P3(p) = (*P3(p) & ~lmask) | ((fgpat | bgpat) & lmask); | |
| + *(volatile u_int32_t *)OMFB_PLANEMASK = (~(fg|bg)) & 0x0f; | |
| + ((volatile u_int32_t *)OMFB_ROPFUNC)[5] = lmask; | |
| + *W(p) = 0; | |
| + *(volatile u_int32_t *)OMFB_PLANEMASK = fg & 0x0f; | |
| + ((volatile u_int32_t *)OMFB_ROPFUNC)[5] = lmask; | |
| + *W(p) = glyph; | |
| + *(volatile u_int32_t *)OMFB_PLANEMASK = bg & 0x0f; | |
| + /* function OR2 ( ~data | VRAM ) with lmask */ | |
| + ((volatile u_int32_t *)OMFB_ROPFUNC)[11] = lmask; | |
| + *W(p) = glyph; | |
| p += scanspan; | |
| height--; | |
| @@ -204,7 +201,6 @@ | |
| } else { | |
| u_int8_t *q = p; | |
| u_int32_t lhalf, rhalf; | |
| - u_int32_t lhalfbg, rhalfbg; | |
| while (height > 0) { | |
| glyph = 0; | |
| @@ -212,43 +208,40 @@ | |
| glyph = (glyph << 8) | *fb++; | |
| glyph <<= (4 - ri->ri_font->stride) * NBBY; | |
| lhalf = (glyph >> align); | |
| - lhalfbg = lhalf ^ ALL1BITS; | |
| - fgpat = (fg & 0x01) ? lhalf : 0; | |
| - bgpat = (bg & 0x01) ? lhalfbg : 0; | |
| - *P0(p) = (*P0(p) & ~lmask) | ((fgpat | bgpat) & lmask); | |
| - fgpat = (fg & 0x02) ? lhalf : 0; | |
| - bgpat = (bg & 0x02) ? lhalfbg : 0; | |
| - *P1(p) = (*P1(p) & ~lmask) | ((fgpat | bgpat) & lmask); | |
| - fgpat = (fg & 0x04) ? lhalf : 0; | |
| - bgpat = (bg & 0x04) ? lhalfbg : 0; | |
| - *P2(p) = (*P2(p) & ~lmask) | ((fgpat | bgpat) & lmask); | |
| - fgpat = (fg & 0x08) ? lhalf : 0; | |
| - bgpat = (bg & 0x08) ? lhalfbg : 0; | |
| - *P3(p) = (*P3(p) & ~lmask) | ((fgpat | bgpat) & lmask); | |
| + *(volatile u_int32_t *)OMFB_PLANEMASK = (~(fg|bg)) & 0x0f; | |
| + ((volatile u_int32_t *)OMFB_ROPFUNC)[5] = lmask; | |
| + *W(p) = 0; | |
| + *(volatile u_int32_t *)OMFB_PLANEMASK = fg & 0x0f; | |
| + ((volatile u_int32_t *)OMFB_ROPFUNC)[5] = lmask; | |
| + *W(p) = lhalf; | |
| + *(volatile u_int32_t *)OMFB_PLANEMASK = bg & 0x0f; | |
| + /* function OR2 ( ~data | VRAM ) with lmask */ | |
| + ((volatile u_int32_t *)OMFB_ROPFUNC)[11] = lmask; | |
| + *W(p) = lhalf; | |
| p += BYTESDONE; | |
| rhalf = (glyph << (BLITWIDTH - align)); | |
| - rhalfbg = rhalf ^ ALL1BITS; | |
| - fgpat = (fg & 0x01) ? rhalf : 0; | |
| - bgpat = (bg & 0x01) ? rhalfbg : 0; | |
| - *P0(p) = ((fgpat | bgpat) & rmask) | (*P0(p) & ~rmask); | |
| - fgpat = (fg & 0x02) ? rhalf : 0; | |
| - bgpat = (bg & 0x02) ? rhalfbg : 0; | |
| - *P1(p) = ((fgpat | bgpat) & rmask) | (*P1(p) & ~rmask); | |
| - fgpat = (fg & 0x04) ? rhalf : 0; | |
| - bgpat = (bg & 0x04) ? rhalfbg : 0; | |
| - *P2(p) = ((fgpat | bgpat) & rmask) | (*P2(p) & ~rmask); | |
| - fgpat = (fg & 0x08) ? rhalf : 0; | |
| - bgpat = (bg & 0x08) ? rhalfbg : 0; | |
| - *P3(p) = ((fgpat | bgpat) & rmask) | (*P3(p) & ~rmask); | |
| + *(volatile u_int32_t *)OMFB_PLANEMASK = (~(fg|bg)) & 0x0f; | |
| + ((volatile u_int32_t *)OMFB_ROPFUNC)[5] = rmask; | |
| + *W(p) = 0; | |
| + *(volatile u_int32_t *)OMFB_PLANEMASK = fg & 0x0f; | |
| + ((volatile u_int32_t *)OMFB_ROPFUNC)[5] = rmask; | |
| + *W(p) = rhalf; | |
| + *(volatile u_int32_t *)OMFB_PLANEMASK = bg & 0x0f; | |
| + /* function OR2 ( ~data | VRAM ) with rmask */ | |
| + ((volatile u_int32_t *)OMFB_ROPFUNC)[11] = rmask; | |
| + *W(p) = rhalf; | |
| p = (q += scanspan); | |
| height--; | |
| } | |
| } | |
| + /* reset ROP function for all planes */ | |
| + *(volatile u_int32_t *)OMFB_PLANEMASK = 0xff; /* select all planes */ | |
| + ((volatile u_int32_t *)OMFB_ROPFUNC)[5] = ALL1BITS; | |
| return 0; | |
| } | |
| Index: omrasops.h | |
| =================================================================== | |
| RCS file: /cvs/src/sys/arch/luna88k/dev/omrasops.h,v | |
| retrieving revision 1.2 | |
| diff -u -r1.2 omrasops.h | |
| --- omrasops.h 2 Jan 2014 15:30:34 -0000 1.2 | |
| +++ omrasops.h 17 Sep 2014 13:53:16 -0000 | |
| @@ -18,14 +18,17 @@ | |
| * Base addresses of LUNA's frame buffer | |
| * XXX: We consider only 1bpp and 4bpp for now | |
| */ | |
| + | |
| +#define OMFB_PLANEMASK 0xB1040000 /* BMSEL register */ | |
| #define OMFB_FB_WADDR 0xB1080008 /* common plane */ | |
| #define OMFB_FB_RADDR 0xB10C0008 /* plane #0 */ | |
| +#define OMFB_ROPFUNC 0xB12C0000 /* common ROP function */ | |
| /* | |
| * Helper macros | |
| */ | |
| -#define W(addr) ((u_int32_t *)(addr)) | |
| -#define R(addr) ((u_int32_t *)((u_int8_t *)(addr) + 0x40000)) | |
| +#define W(addr) ((u_int32_t *)(addr)) | |
| +#define R(addr) ((u_int32_t *)((u_int8_t *)(addr) + 0x40000)) | |
| #define P0(addr) ((u_int32_t *)((u_int8_t *)(addr) + 0x40000)) | |
| #define P1(addr) ((u_int32_t *)((u_int8_t *)(addr) + 0x80000)) | |
| #define P2(addr) ((u_int32_t *)((u_int8_t *)(addr) + 0xC0000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment