[PATCH] fbcon endianness fix

Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
Wed, 27 Jan 1999 11:10:34 +0100 (CET)


Hi Linus,

There exists an endianness bug in the frame buffer console code.

All accesses to the VT buffers by the high level console code are done using
the scr_{read,write}w() inline functions. For performance reasons, these
functions use native byte ordering, except when using VGA text mode on big
endian hardware (we want to keep the VT buffer for the current VT in the memory
on the graphics board, so it has to be in little endian ordering).

However, the frame buffer console code assumes the VT buffer is always in
native byte ordering. This didn't cause any problems until recently, when
people started using both vgacon and fbcon at the same time on PPC boxes,
causing a corrupted display (character and attribute data exchanged).

The first patch (PART 1) updates all frame buffer code to use scr_readw() to
access the passed character/attribute strings in the various *_putcs()
functions. Since 'scr_readw(s)' is an inline equivalent of '*s' in the common
case, this doesn't cause any performance penalty nor change of behavior. The
only exception is the case where both vgacon and fbcon are used on a big endian
machine. This patch is a bug fix.

The second patch (PART 2) adds the `const' keyword to all pointers passed to
the read access functions for VT buffers. This patch is a sanity fix.

Thanks for applying these patches to your tree!

--------------------------------- PART 1 ---------------------------------

diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/cgsixfb.c linux/drivers/video/cgsixfb.c
--- native-2.2.0/drivers/video/cgsixfb.c Wed Dec 23 19:49:06 1998
+++ linux/drivers/video/cgsixfb.c Sun Jan 24 20:26:56 1999
@@ -352,8 +352,8 @@
do {
i = fbc->s;
} while (i & 0x10000000);
- fbc->fg = attr_fgcol(p,*s);
- fbc->bg = attr_bgcol(p,*s);
+ fbc->fg = attr_fgcol(p, scr_readw(s));
+ fbc->bg = attr_bgcol(p, scr_readw(s));
fbc->mode = 0x140000;
fbc->alu = 0xe880fc30;
fbc->pixelm = ~(0);
@@ -379,15 +379,15 @@
fbc->x1 = (x += 4 * fontwidth(p)) - 1;
fbc->y0 = y;
if (fontheightlog(p)) {
- fd1 = p->fontdata + ((*s++ & p->charmask) << fontheightlog(p));
- fd2 = p->fontdata + ((*s++ & p->charmask) << fontheightlog(p));
- fd3 = p->fontdata + ((*s++ & p->charmask) << fontheightlog(p));
- fd4 = p->fontdata + ((*s++ & p->charmask) << fontheightlog(p));
+ fd1 = p->fontdata + ((scr_readw(s++) & p->charmask) << fontheightlog(p));
+ fd2 = p->fontdata + ((scr_readw(s++) & p->charmask) << fontheightlog(p));
+ fd3 = p->fontdata + ((scr_readw(s++) & p->charmask) << fontheightlog(p));
+ fd4 = p->fontdata + ((scr_readw(s++) & p->charmask) << fontheightlog(p));
} else {
- fd1 = p->fontdata + ((*s++ & p->charmask) * fontheight(p));
- fd2 = p->fontdata + ((*s++ & p->charmask) * fontheight(p));
- fd3 = p->fontdata + ((*s++ & p->charmask) * fontheight(p));
- fd4 = p->fontdata + ((*s++ & p->charmask) * fontheight(p));
+ fd1 = p->fontdata + ((scr_readw(s++) & p->charmask) * fontheight(p));
+ fd2 = p->fontdata + ((scr_readw(s++) & p->charmask) * fontheight(p));
+ fd3 = p->fontdata + ((scr_readw(s++) & p->charmask) * fontheight(p));
+ fd4 = p->fontdata + ((scr_readw(s++) & p->charmask) * fontheight(p));
}
if (fontwidth(p) == 8) {
for (i = 0; i < fontheight(p); i++)
@@ -408,11 +408,11 @@
fbc->x1 = (x += 2 * fontwidth(p)) - 1;
fbc->y0 = y;
if (fontheightlog(p)) {
- fd1 = p->fontdata + ((*s++ & p->charmask) << (fontheightlog(p) + 1));
- fd2 = p->fontdata + ((*s++ & p->charmask) << (fontheightlog(p) + 1));
+ fd1 = p->fontdata + ((scr_readw(s++) & p->charmask) << (fontheightlog(p) + 1));
+ fd2 = p->fontdata + ((scr_readw(s++) & p->charmask) << (fontheightlog(p) + 1));
} else {
- fd1 = p->fontdata + (((*s++ & p->charmask) * fontheight(p)) << 1);
- fd2 = p->fontdata + (((*s++ & p->charmask) * fontheight(p)) << 1);
+ fd1 = p->fontdata + (((scr_readw(s++) & p->charmask) * fontheight(p)) << 1);
+ fd2 = p->fontdata + (((scr_readw(s++) & p->charmask) * fontheight(p)) << 1);
}
for (i = 0; i < fontheight(p); i++) {
fbc->font = ((((u32)*(u16 *)fd1) << fontwidth(p)) | ((u32)*(u16 *)fd2)) << (16 - fontwidth(p));
@@ -428,9 +428,9 @@
fbc->x1 = (x += fontwidth(p)) - 1;
fbc->y0 = y;
if (fontheightlog(p))
- i = ((*s++ & p->charmask) << fontheightlog(p));
+ i = ((scr_readw(s++) & p->charmask) << fontheightlog(p));
else
- i = ((*s++ & p->charmask) * fontheight(p));
+ i = ((scr_readw(s++) & p->charmask) * fontheight(p));
if (fontwidth(p) <= 8) {
fd1 = p->fontdata + i;
for (i = 0; i < fontheight(p); i++)
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/creatorfb.c linux/drivers/video/creatorfb.c
--- native-2.2.0/drivers/video/creatorfb.c Thu Jan 21 23:32:24 1999
+++ linux/drivers/video/creatorfb.c Sun Jan 24 20:26:56 1999
@@ -433,8 +433,8 @@

FFBWait(fbc);
FFBFifo(fbc, 2);
- fbc->fg = ((u32 *)p->dispsw_data)[attr_fgcol(p,*s)];
- fbc->bg = ((u32 *)p->dispsw_data)[attr_bgcol(p,*s)];
+ fbc->fg = ((u32 *)p->dispsw_data)[attr_fgcol(p,scr_readw(s))];
+ fbc->bg = ((u32 *)p->dispsw_data)[attr_bgcol(p,scr_readw(s))];
xy = fb->s.ffb.xy_margin;
if (fontwidthlog(p))
xy += (xx << fontwidthlog(p));
@@ -452,15 +452,15 @@
fbc->fontinc = 0x10000;
fbc->fontxy = xy;
if (fontheightlog(p)) {
- fd1 = p->fontdata + ((*s++ & p->charmask) << fontheightlog(p));
- fd2 = p->fontdata + ((*s++ & p->charmask) << fontheightlog(p));
- fd3 = p->fontdata + ((*s++ & p->charmask) << fontheightlog(p));
- fd4 = p->fontdata + ((*s++ & p->charmask) << fontheightlog(p));
+ fd1 = p->fontdata + ((scr_readw(s++) & p->charmask) << fontheightlog(p));
+ fd2 = p->fontdata + ((scr_readw(s++) & p->charmask) << fontheightlog(p));
+ fd3 = p->fontdata + ((scr_readw(s++) & p->charmask) << fontheightlog(p));
+ fd4 = p->fontdata + ((scr_readw(s++) & p->charmask) << fontheightlog(p));
} else {
- fd1 = p->fontdata + ((*s++ & p->charmask) * fontheight(p));
- fd2 = p->fontdata + ((*s++ & p->charmask) * fontheight(p));
- fd3 = p->fontdata + ((*s++ & p->charmask) * fontheight(p));
- fd4 = p->fontdata + ((*s++ & p->charmask) * fontheight(p));
+ fd1 = p->fontdata + ((scr_readw(s++) & p->charmask) * fontheight(p));
+ fd2 = p->fontdata + ((scr_readw(s++) & p->charmask) * fontheight(p));
+ fd3 = p->fontdata + ((scr_readw(s++) & p->charmask) * fontheight(p));
+ fd4 = p->fontdata + ((scr_readw(s++) & p->charmask) * fontheight(p));
}
FFBFifo(fbc, fontheight(p));
if (fontwidth(p) == 8) {
@@ -483,11 +483,11 @@
fbc->fontinc = 0x10000;
fbc->fontxy = xy;
if (fontheightlog(p)) {
- fd1 = p->fontdata + ((*s++ & p->charmask) << (fontheightlog(p) + 1));
- fd2 = p->fontdata + ((*s++ & p->charmask) << (fontheightlog(p) + 1));
+ fd1 = p->fontdata + ((scr_readw(s++) & p->charmask) << (fontheightlog(p) + 1));
+ fd2 = p->fontdata + ((scr_readw(s++) & p->charmask) << (fontheightlog(p) + 1));
} else {
- fd1 = p->fontdata + (((*s++ & p->charmask) * fontheight(p)) << 1);
- fd2 = p->fontdata + (((*s++ & p->charmask) * fontheight(p)) << 1);
+ fd1 = p->fontdata + (((scr_readw(s++) & p->charmask) * fontheight(p)) << 1);
+ fd2 = p->fontdata + (((scr_readw(s++) & p->charmask) * fontheight(p)) << 1);
}
FFBFifo(fbc, fontheight(p));
for (i = 0; i < fontheight(p); i++) {
@@ -504,9 +504,9 @@
fbc->fontinc = 0x10000;
fbc->fontxy = xy;
if (fontheightlog(p))
- i = ((*s++ & p->charmask) << fontheightlog(p));
+ i = ((scr_readw(s++) & p->charmask) << fontheightlog(p));
else
- i = ((*s++ & p->charmask) * fontheight(p));
+ i = ((scr_readw(s++) & p->charmask) * fontheight(p));
FFBFifo(fbc, fontheight(p));
if (fontwidth(p) <= 8) {
fd1 = p->fontdata + i;
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/fbcon-afb.c linux/drivers/video/fbcon-afb.c
--- native-2.2.0/drivers/video/fbcon-afb.c Mon Oct 5 19:36:11 1998
+++ linux/drivers/video/fbcon-afb.c Sun Jan 24 21:36:38 1999
@@ -290,12 +290,12 @@
int fg0, bg0, fg, bg;

dest0 = p->screen_base+yy*fontheight(p)*p->next_line+xx;
- fg0 = attr_fgcol(p,*s);
- bg0 = attr_bgcol(p,*s);
+ fg0 = attr_fgcol(p, scr_readw(s));
+ bg0 = attr_bgcol(p, scr_readw(s));

while (count--)
if (xx&3 || count < 3) { /* Slow version */
- c1 = *s++ & p->charmask;
+ c1 = scr_readw(s++) & p->charmask;
dest1 = dest0++;
xx++;

@@ -322,10 +322,10 @@
dest1 += p->next_plane;
} while (--i);
} else { /* Fast version */
- c1 = s[0] & p->charmask;
- c2 = s[1] & p->charmask;
- c3 = s[2] & p->charmask;
- c4 = s[3] & p->charmask;
+ c1 = scr_readw(&s[0]) & p->charmask;
+ c2 = scr_readw(&s[1]) & p->charmask;
+ c3 = scr_readw(&s[2]) & p->charmask;
+ c4 = scr_readw(&s[3]) & p->charmask;

dest1 = dest0;
cdat10 = p->fontdata+c1*fontheight(p);
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/fbcon-cfb16.c linux/drivers/video/fbcon-cfb16.c
--- native-2.2.0/drivers/video/fbcon-cfb16.c Mon Oct 5 19:36:11 1998
+++ linux/drivers/video/fbcon-cfb16.c Sun Jan 24 21:36:45 1999
@@ -177,8 +177,8 @@
u32 eorx, fgx, bgx;

dest0 = p->screen_base + yy * fontheight(p) * bytes + xx * fontwidth(p) * 2;
- fgx = ((u16 *)p->dispsw_data)[attr_fgcol(p, *s)];
- bgx = ((u16 *)p->dispsw_data)[attr_bgcol(p, *s)];
+ fgx = ((u16 *)p->dispsw_data)[attr_fgcol(p, scr_readw(s))];
+ bgx = ((u16 *)p->dispsw_data)[attr_bgcol(p, scr_readw(s))];
fgx |= (fgx << 16);
bgx |= (bgx << 16);
eorx = fgx ^ bgx;
@@ -187,7 +187,7 @@
case 4:
case 8:
while (count--) {
- c = *s++ & p->charmask;
+ c = scr_readw(s++) & p->charmask;
cdat = p->fontdata + c * fontheight(p);
for (rows = fontheight(p), dest = dest0; rows--; dest += bytes) {
u8 bits = *cdat++;
@@ -204,7 +204,7 @@
case 12:
case 16:
while (count--) {
- c = *s++ & p->charmask;
+ c = scr_readw(s++) & p->charmask;
cdat = p->fontdata + (c * fontheight(p) << 1);
for (rows = fontheight(p), dest = dest0; rows--; dest += bytes) {
u8 bits = *cdat++;
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/fbcon-cfb2.c linux/drivers/video/fbcon-cfb2.c
--- native-2.2.0/drivers/video/fbcon-cfb2.c Mon Oct 5 19:36:01 1998
+++ linux/drivers/video/fbcon-cfb2.c Sun Jan 24 21:36:48 1999
@@ -156,15 +156,15 @@
u32 eorx, fgx, bgx;

dest0 = p->screen_base + yy * fontheight(p) * bytes + xx * 2;
- fgx=3/*attr_fgcol(p,*s)*/;
- bgx=attr_bgcol(p,*s);
+ fgx=3/*attr_fgcol(p,scr_readw(s))*/;
+ bgx=attr_bgcol(p,scr_readw(s));
fgx |= (fgx << 2);
fgx |= (fgx << 4);
bgx |= (bgx << 2);
bgx |= (bgx << 4);
eorx = fgx ^ bgx;
while (count--) {
- c = *s++ & p->charmask;
+ c = scr_readw(s++) & p->charmask;
cdat = p->fontdata + c * fontheight(p);

for (rows = fontheight(p), dest = dest0; rows-- ; dest += bytes) {
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/fbcon-cfb24.c linux/drivers/video/fbcon-cfb24.c
--- native-2.2.0/drivers/video/fbcon-cfb24.c Mon Oct 5 19:36:02 1998
+++ linux/drivers/video/fbcon-cfb24.c Sun Jan 24 20:26:56 1999
@@ -187,11 +187,11 @@
u32 eorx, fgx, bgx, d1, d2, d3, d4;

dest0 = p->screen_base + yy * fontheight(p) * bytes + xx * fontwidth(p) * 3;
- fgx = ((u32 *)p->dispsw_data)[attr_fgcol(p, *s)];
- bgx = ((u32 *)p->dispsw_data)[attr_bgcol(p, *s)];
+ fgx = ((u32 *)p->dispsw_data)[attr_fgcol(p, scr_readw(s))];
+ bgx = ((u32 *)p->dispsw_data)[attr_bgcol(p, scr_readw(s))];
eorx = fgx ^ bgx;
while (count--) {
- c = *s++ & p->charmask;
+ c = scr_readw(s++) & p->charmask;
if (fontwidth(p) <= 8)
cdat = p->fontdata + c * fontheight(p);

diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/fbcon-cfb32.c linux/drivers/video/fbcon-cfb32.c
--- native-2.2.0/drivers/video/fbcon-cfb32.c Mon Oct 5 19:36:02 1998
+++ linux/drivers/video/fbcon-cfb32.c Sun Jan 24 20:26:56 1999
@@ -163,11 +163,11 @@
u32 eorx, fgx, bgx;

dest0 = p->screen_base + yy * fontheight(p) * bytes + xx * fontwidth(p) * 4;
- fgx = ((u32 *)p->dispsw_data)[attr_fgcol(p, *s)];
- bgx = ((u32 *)p->dispsw_data)[attr_bgcol(p, *s)];
+ fgx = ((u32 *)p->dispsw_data)[attr_fgcol(p, scr_readw(s))];
+ bgx = ((u32 *)p->dispsw_data)[attr_bgcol(p, scr_readw(s))];
eorx = fgx ^ bgx;
while (count--) {
- c = *s++ & p->charmask;
+ c = scr_readw(s++) & p->charmask;
if (fontwidth(p) <= 8)
cdat = p->fontdata + c * fontheight(p);
else
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/fbcon-cfb4.c linux/drivers/video/fbcon-cfb4.c
--- native-2.2.0/drivers/video/fbcon-cfb4.c Mon Oct 5 19:36:02 1998
+++ linux/drivers/video/fbcon-cfb4.c Sun Jan 24 20:26:56 1999
@@ -158,8 +158,8 @@
u32 eorx, fgx, bgx;

dest0 = p->screen_base + yy * fontheight(p) * bytes + xx * 4;
- fgx=attr_fgcol(p,*s);
- bgx=attr_bgcol(p,*s);
+ fgx=attr_fgcol(p,scr_readw(s));
+ bgx=attr_bgcol(p,scr_readw(s));
fgx |= (fgx << 4);
fgx |= (fgx << 8);
fgx |= (fgx << 16);
@@ -168,7 +168,7 @@
bgx |= (bgx << 16);
eorx = fgx ^ bgx;
while (count--) {
- c = *s++ & p->charmask;
+ c = scr_readw(s++) & p->charmask;
cdat = p->fontdata + c * fontheight(p);

for (rows = fontheight(p), dest = dest0; rows-- ; dest += bytes) {
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/fbcon-cfb8.c linux/drivers/video/fbcon-cfb8.c
--- native-2.2.0/drivers/video/fbcon-cfb8.c Wed Dec 23 19:49:11 1998
+++ linux/drivers/video/fbcon-cfb8.c Sun Jan 24 20:26:56 1999
@@ -163,8 +163,8 @@
u32 eorx, fgx, bgx;

dest0 = p->screen_base + yy * fontheight(p) * bytes + xx * fontwidth(p);
- fgx=attr_fgcol(p,*s);
- bgx=attr_bgcol(p,*s);
+ fgx=attr_fgcol(p,scr_readw(s));
+ bgx=attr_bgcol(p,scr_readw(s));
fgx |= (fgx << 8);
fgx |= (fgx << 16);
bgx |= (bgx << 8);
@@ -173,7 +173,7 @@
switch (fontwidth(p)) {
case 4:
while (count--) {
- c = *s++ & p->charmask;
+ c = scr_readw(s++) & p->charmask;
cdat = p->fontdata + c * fontheight(p);

for (rows = fontheight(p), dest = dest0; rows-- ; dest += bytes)
@@ -183,7 +183,7 @@
break;
case 8:
while (count--) {
- c = *s++ & p->charmask;
+ c = scr_readw(s++) & p->charmask;
cdat = p->fontdata + c * fontheight(p);

for (rows = fontheight(p), dest = dest0; rows-- ; dest += bytes) {
@@ -196,7 +196,7 @@
case 12:
case 16:
while (count--) {
- c = *s++ & p->charmask;
+ c = scr_readw(s++) & p->charmask;
cdat = p->fontdata + (c * fontheight(p) << 1);

for (rows = fontheight(p), dest = dest0; rows-- ; dest += bytes) {
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/fbcon-ilbm.c linux/drivers/video/fbcon-ilbm.c
--- native-2.2.0/drivers/video/fbcon-ilbm.c Mon Oct 5 19:36:02 1998
+++ linux/drivers/video/fbcon-ilbm.c Sun Jan 24 20:26:56 1999
@@ -154,12 +154,12 @@
int fg0, bg0, fg, bg;

dest0 = p->screen_base+yy*fontheight(p)*p->next_line+xx;
- fg0 = attr_fgcol(p,*s);
- bg0 = attr_bgcol(p,*s);
+ fg0 = attr_fgcol(p,scr_readw(s));
+ bg0 = attr_bgcol(p,scr_readw(s));

while (count--)
if (xx&3 || count < 3) { /* Slow version */
- c1 = *s++ & p->charmask;
+ c1 = scr_readw(s++) & p->charmask;
dest = dest0++;
xx++;

@@ -185,10 +185,10 @@
}
}
} else { /* Fast version */
- c1 = s[0] & p->charmask;
- c2 = s[1] & p->charmask;
- c3 = s[2] & p->charmask;
- c4 = s[3] & p->charmask;
+ c1 = scr_readw(&s[0]) & p->charmask;
+ c2 = scr_readw(&s[1]) & p->charmask;
+ c3 = scr_readw(&s[2]) & p->charmask;
+ c4 = scr_readw(&s[3]) & p->charmask;

dest = dest0;
cdat1 = p->fontdata+c1*fontheight(p);
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/fbcon-iplan2p2.c linux/drivers/video/fbcon-iplan2p2.c
--- native-2.2.0/drivers/video/fbcon-iplan2p2.c Thu Jan 21 23:32:25 1999
+++ linux/drivers/video/fbcon-iplan2p2.c Sun Jan 24 20:26:56 1999
@@ -361,12 +361,12 @@
else
dest0 = (p->screen_base + yy * bytes * fontheight(p) +
(xx>>1)*4 + (xx & 1));
- fgx = expand2w(COLOR_2P(attr_fgcol(p,*s)));
- bgx = expand2w(COLOR_2P(attr_bgcol(p,*s)));
+ fgx = expand2w(COLOR_2P(attr_fgcol(p,scr_readw(s))));
+ bgx = expand2w(COLOR_2P(attr_bgcol(p,scr_readw(s))));
eorx = fgx ^ bgx;

while (count--) {
- c = *s++ & p->charmask;
+ c = scr_readw(s++) & p->charmask;
if (fontheightlog(p))
cdat = p->fontdata + (c << fontheightlog(p));
else
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/fbcon-iplan2p4.c linux/drivers/video/fbcon-iplan2p4.c
--- native-2.2.0/drivers/video/fbcon-iplan2p4.c Thu Jan 21 23:32:25 1999
+++ linux/drivers/video/fbcon-iplan2p4.c Sun Jan 24 20:26:56 1999
@@ -371,8 +371,8 @@
else
dest0 = (p->screen_base + yy * bytes * fontheight(p) +
(xx>>1)*8 + (xx & 1));
- fgx = expand4l(attr_fgcol(p,*s));
- bgx = expand4l(attr_bgcol(p,*s));
+ fgx = expand4l(attr_fgcol(p,scr_readw(s)));
+ bgx = expand4l(attr_bgcol(p,scr_readw(s)));
eorx = fgx ^ bgx;

while (count--) {
@@ -383,7 +383,7 @@
* cache :-(
*/

- c = *s++ & p->charmask;
+ c = scr_readw(s++) & p->charmask;
if (fontheightlog(p))
cdat = p->fontdata + (c << fontheightlog(p));
else
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/fbcon-iplan2p8.c linux/drivers/video/fbcon-iplan2p8.c
--- native-2.2.0/drivers/video/fbcon-iplan2p8.c Thu Jan 21 23:32:25 1999
+++ linux/drivers/video/fbcon-iplan2p8.c Sun Jan 24 20:26:56 1999
@@ -404,8 +404,8 @@
dest0 = (p->screen_base + yy * bytes * fontheight(p) +
(xx>>1)*16 + (xx & 1));

- expand8dl(attr_fgcol(p,*s), &fgx1, &fgx2);
- expand8dl(attr_bgcol(p,*s), &bgx1, &bgx2);
+ expand8dl(attr_fgcol(p,scr_readw(s)), &fgx1, &fgx2);
+ expand8dl(attr_bgcol(p,scr_readw(s)), &bgx1, &bgx2);
eorx1 = fgx1 ^ bgx1; eorx2 = fgx2 ^ bgx2;

while (count--) {
@@ -417,7 +417,7 @@
* cache :-(
*/

- c = *s++ & p->charmask;
+ c = scr_readw(s++) & p->charmask;
if (fontheightlog(p))
cdat = p->fontdata + (c << fontheightlog(p));
else
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/fbcon-mac.c linux/drivers/video/fbcon-mac.c
--- native-2.2.0/drivers/video/fbcon-mac.c Mon Oct 5 19:36:03 1998
+++ linux/drivers/video/fbcon-mac.c Sun Jan 24 20:26:56 1999
@@ -301,7 +301,7 @@
u16 c;

while (count--) {
- c = *s++;
+ c = scr_readw(s++);
fbcon_mac_putc(conp, p, c, yy, xx++);
}
}
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/fbcon-mfb.c linux/drivers/video/fbcon-mfb.c
--- native-2.2.0/drivers/video/fbcon-mfb.c Fri Nov 20 10:03:02 1998
+++ linux/drivers/video/fbcon-mfb.c Sun Jan 24 20:26:56 1999
@@ -117,12 +117,12 @@
u16 c;

dest0 = p->screen_base+yy*fontheight(p)*p->next_line+xx;
- bold = attr_bold(p,*s);
- revs = attr_reverse(p,*s);
- underl = attr_underline(p,*s);
+ bold = attr_bold(p,scr_readw(s));
+ revs = attr_reverse(p,scr_readw(s));
+ underl = attr_underline(p,scr_readw(s));

while (count--) {
- c = *s++ & p->charmask;
+ c = scr_readw(s++) & p->charmask;
dest = dest0++;
cdat = p->fontdata+c*fontheight(p);
for (rows = fontheight(p); rows--; dest += p->next_line) {
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/fbcon-vga.c linux/drivers/video/fbcon-vga.c
--- native-2.2.0/drivers/video/fbcon-vga.c Mon Oct 5 19:36:14 1998
+++ linux/drivers/video/fbcon-vga.c Sun Jan 24 20:26:56 1999
@@ -155,11 +155,11 @@
u16 sattr;
if (conp->vc_can_do_color)
while (count--)
- vga_writew(*s++, dst++);
+ vga_writew(scr_readw(s++), dst++);
else {
- sattr = fbcon_vga_attr(p, *s);
+ sattr = fbcon_vga_attr(p, scr_readw(s));
while (count--)
- vga_writew(sattr | ((int) (*s++) & 0xff), dst++);
+ vga_writew(sattr | ((int) (scr_readw(s++)) & 0xff), dst++);
}
}

diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/leofb.c linux/drivers/video/leofb.c
--- native-2.2.0/drivers/video/leofb.c Mon Oct 5 19:36:43 1998
+++ linux/drivers/video/leofb.c Sun Jan 24 20:26:56 1999
@@ -265,8 +265,8 @@
do {
i = us->csr;
} while (i & 0x20000000);
- ss->fg = attr_fgcol(p,*s) << 24;
- ss->bg = attr_bgcol(p,*s) << 24;
+ ss->fg = attr_fgcol(p,scr_readw(s)) << 24;
+ ss->bg = attr_bgcol(p,scr_readw(s)) << 24;
ss->rop = 0x310040;
ss->planemask = 0xff000000;
us->fontc2 = 0xFFFFFFFE;
@@ -287,15 +287,15 @@
while (count >= 4) {
count -= 4;
if (fontheightlog(p)) {
- fd1 = p->fontdata + ((*s++ & p->charmask) << fontheightlog(p));
- fd2 = p->fontdata + ((*s++ & p->charmask) << fontheightlog(p));
- fd3 = p->fontdata + ((*s++ & p->charmask) << fontheightlog(p));
- fd4 = p->fontdata + ((*s++ & p->charmask) << fontheightlog(p));
+ fd1 = p->fontdata + ((scr_readw(s++) & p->charmask) << fontheightlog(p));
+ fd2 = p->fontdata + ((scr_readw(s++) & p->charmask) << fontheightlog(p));
+ fd3 = p->fontdata + ((scr_readw(s++) & p->charmask) << fontheightlog(p));
+ fd4 = p->fontdata + ((scr_readw(s++) & p->charmask) << fontheightlog(p));
} else {
- fd1 = p->fontdata + ((*s++ & p->charmask) * fontheight(p));
- fd2 = p->fontdata + ((*s++ & p->charmask) * fontheight(p));
- fd3 = p->fontdata + ((*s++ & p->charmask) * fontheight(p));
- fd4 = p->fontdata + ((*s++ & p->charmask) * fontheight(p));
+ fd1 = p->fontdata + ((scr_readw(s++) & p->charmask) * fontheight(p));
+ fd2 = p->fontdata + ((scr_readw(s++) & p->charmask) * fontheight(p));
+ fd3 = p->fontdata + ((scr_readw(s++) & p->charmask) * fontheight(p));
+ fd4 = p->fontdata + ((scr_readw(s++) & p->charmask) * fontheight(p));
}
if (fontwidth(p) == 8) {
for (i = 0; i < fontheight(p); i++, u += 2048)
@@ -315,11 +315,11 @@
while (count >= 2) {
count -= 2;
if (fontheightlog(p)) {
- fd1 = p->fontdata + ((*s++ & p->charmask) << (fontheightlog(p) + 1));
- fd2 = p->fontdata + ((*s++ & p->charmask) << (fontheightlog(p) + 1));
+ fd1 = p->fontdata + ((scr_readw(s++) & p->charmask) << (fontheightlog(p) + 1));
+ fd2 = p->fontdata + ((scr_readw(s++) & p->charmask) << (fontheightlog(p) + 1));
} else {
- fd1 = p->fontdata + (((*s++ & p->charmask) * fontheight(p)) << 1);
- fd2 = p->fontdata + (((*s++ & p->charmask) * fontheight(p)) << 1);
+ fd1 = p->fontdata + (((scr_readw(s++) & p->charmask) * fontheight(p)) << 1);
+ fd2 = p->fontdata + (((scr_readw(s++) & p->charmask) * fontheight(p)) << 1);
}
for (i = 0; i < fontheight(p); i++, u += 2048) {
*u = ((((u32)*(u16 *)fd1) << fontwidth(p)) | ((u32)*(u16 *)fd2)) << (16 - fontwidth(p));
@@ -333,9 +333,9 @@
while (count) {
count--;
if (fontheightlog(p))
- i = ((*s++ & p->charmask) << fontheightlog(p));
+ i = ((scr_readw(s++) & p->charmask) << fontheightlog(p));
else
- i = ((*s++ & p->charmask) * fontheight(p));
+ i = ((scr_readw(s++) & p->charmask) * fontheight(p));
if (fontwidth(p) <= 8) {
fd1 = p->fontdata + i;
for (i = 0; i < fontheight(p); i++, u += 2048)
Binary files native-2.2.0/drivers/video/macmode and linux/drivers/video/macmode differ
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/matroxfb.c linux/drivers/video/matroxfb.c
--- native-2.2.0/drivers/video/matroxfb.c Thu Jan 21 20:20:00 1999
+++ linux/drivers/video/matroxfb.c Sun Jan 24 20:26:57 1999
@@ -1473,7 +1473,7 @@
mga_outl(M_FCOL, fgx);
mga_outl(M_BCOL, bgx);
while (count--) {
- u_int32_t ar3 = ACCESS_FBINFO(fastfont.mgabase) + (*s++ & p->charmask)*charcell;
+ u_int32_t ar3 = ACCESS_FBINFO(fastfont.mgabase) + (scr_readw(s++) & p->charmask)*charcell;

mga_fifo(4);
mga_outl(M_FXBNDRY, ((xx + fontwidth(p) - 1) << 16) | xx);
@@ -1531,7 +1531,7 @@
fxbndry = ((xx + fontwidth(p) - 1) << 16) | xx;
mmio = ACCESS_FBINFO(mmio.vbase);
while (count--) {
- u_int8_t* chardata = p->fontdata + (*s++ & p->charmask)*charcell;
+ u_int8_t* chardata = p->fontdata + (scr_readw(s++) & p->charmask)*charcell;

mga_fifo(5);
mga_writel(mmio, M_FXBNDRY, fxbndry);
@@ -1586,8 +1586,8 @@

DBG_HEAVY("matroxfb_cfb8_putcs");

- fgx = attr_fgcol(p, *s);
- bgx = attr_bgcol(p, *s);
+ fgx = attr_fgcol(p, scr_readw(s));
+ bgx = attr_bgcol(p, scr_readw(s));
fgx |= (fgx << 8);
fgx |= (fgx << 16);
bgx |= (bgx << 8);
@@ -1603,8 +1603,8 @@

DBG_HEAVY("matroxfb_cfb16_putcs");

- fgx = ((u_int16_t*)p->dispsw_data)[attr_fgcol(p, *s)];
- bgx = ((u_int16_t*)p->dispsw_data)[attr_bgcol(p, *s)];
+ fgx = ((u_int16_t*)p->dispsw_data)[attr_fgcol(p, scr_readw(s))];
+ bgx = ((u_int16_t*)p->dispsw_data)[attr_bgcol(p, scr_readw(s))];
fgx |= (fgx << 16);
bgx |= (bgx << 16);
ACCESS_FBINFO(curr.putcs)(fgx, bgx, p, s, count, yy, xx);
@@ -1618,8 +1618,8 @@

DBG_HEAVY("matroxfb_cfb32_putcs");

- fgx = ((u_int32_t*)p->dispsw_data)[attr_fgcol(p, *s)];
- bgx = ((u_int32_t*)p->dispsw_data)[attr_bgcol(p, *s)];
+ fgx = ((u_int32_t*)p->dispsw_data)[attr_fgcol(p, scr_readw(s))];
+ bgx = ((u_int32_t*)p->dispsw_data)[attr_bgcol(p, scr_readw(s))];
ACCESS_FBINFO(curr.putcs)(fgx, bgx, p, s, count, yy, xx);
}
#endif
@@ -2191,9 +2191,9 @@

step = ACCESS_FBINFO(devflags.textstep);
offs = yy * p->next_line + xx * step;
- attr = attr_fgcol(p,*s) | (attr_bgcol(p,*s) << 4);
+ attr = attr_fgcol(p,scr_readw(s)) | (attr_bgcol(p,scr_readw(s)) << 4);
while (count-- > 0) {
- unsigned int chr = ((*s++) & p->charmask) << 8;
+ unsigned int chr = ((scr_readw(s++)) & p->charmask) << 8;
if (chr & 0x10000) chr ^= 0x10008;
mga_writew(ACCESS_FBINFO(video.vbase), offs, ntohs(attr|chr));
offs += step;
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/mdacon.c linux/drivers/video/mdacon.c
--- native-2.2.0/drivers/video/mdacon.c Fri Jan 15 00:14:48 1999
+++ linux/drivers/video/mdacon.c Sun Jan 24 20:26:57 1999
@@ -429,7 +429,7 @@
u16 *dest = MDA_ADDR(x, y);

for (; count > 0; count--) {
- scr_writew(mda_convert_attr(*s++), dest++);
+ scr_writew(mda_convert_attr(scr_readw(s++)), dest++);
}
}

diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/newport_con.c linux/drivers/video/newport_con.c
--- native-2.2.0/drivers/video/newport_con.c Mon Oct 5 19:36:45 1998
+++ linux/drivers/video/newport_con.c Sun Jan 24 20:26:57 1999
@@ -200,7 +200,7 @@
int ypos, int xpos)
{
while (count--)
- newport_putc (vc, *s++, ypos, xpos++);
+ newport_putc (vc, scr_readw(s++), ypos, xpos++);
}

static void newport_cursor(struct vc_data *vc, int mode)
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/video/promcon.c linux/drivers/video/promcon.c
--- native-2.2.0/drivers/video/promcon.c Mon Oct 5 19:36:45 1998
+++ linux/drivers/video/promcon.c Tue Jan 26 20:43:50 1999
@@ -1,4 +1,4 @@
-/* $Id: promcon.c,v 1.12 1998/08/23 20:19:01 mj Exp $
+/* $Id: promcon.c,v 1.13 1999/01/19 09:56:46 jj Exp $
* Console driver utilizing PROM sun terminal emulation
*
* Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
@@ -230,7 +230,7 @@
int count, int y, int x)
{
unsigned char buf[256], *b = buf;
- unsigned short attr = *s;
+ unsigned short attr = scr_readw(s);
unsigned char save;
int i, last = 0;

@@ -256,9 +256,9 @@
}

if (inverted(attr))
- b += sprintf(b, "\033[7m%c\033[m", *s++);
+ b += sprintf(b, "\033[7m%c\033[m", scr_readw(s++));
else
- b += sprintf(b, "%c", *s++);
+ b += sprintf(b, "%c", scr_readw(s++));

strcpy(b, "\b\033[@");
b += 4;
@@ -295,14 +295,14 @@
promcon_puts(buf, b - buf);
b = buf;
}
- *b++ = *s++;
+ *b++ = scr_readw(s++);
}

px += count;

if (last) {
- save = *s++;
- b += sprintf(b, "%c\b\033[@%c", *s++, save);
+ save = scr_readw(s++);
+ b += sprintf(b, "%c\b\033[@%c", scr_readw(s++), save);
px++;
}

@@ -318,11 +318,12 @@
static void
promcon_putc(struct vc_data *conp, int c, int y, int x)
{
- unsigned short s = c;
+ unsigned short s;

if (console_blanked)
return;

+ scr_writew(c, &s);
promcon_putcs(conp, &s, 1, y, x);
}

@@ -591,8 +592,11 @@

__initfunc(void prom_con_init(void))
{
+#ifdef CONFIG_DUMMY_CONSOLE
if (conswitchp == &dummy_con)
take_over_console(&prom_con, 0, MAX_NR_CONSOLES-1, 1);
- else if (conswitchp == &prom_con)
+ else
+#endif
+ if (conswitchp == &prom_con)
promcon_init_unimap(vc_cons[fg_console].d);
}
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/char/console.c linux/drivers/char/console.c
--- native-2.2.0/drivers/char/console.c Thu Jan 21 23:31:54 1999
+++ linux/drivers/char/console.c Sun Jan 24 20:26:57 1999
@@ -2778,7 +2778,7 @@
set_cursor(currcons);
}

-u16 vcs_scr_readw(int currcons, u16 *org)
+u16 vcs_scr_readw(int currcons, const u16 *org)
{
if ((unsigned long)org == pos && softcursor_original != -1)
return softcursor_original;
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/include/video/fbcon.h linux/include/video/fbcon.h
--- native-2.2.0/include/video/fbcon.h Tue Dec 29 11:32:23 1998
+++ linux/include/video/fbcon.h Sun Jan 24 21:38:05 1999
@@ -13,6 +13,7 @@

#include <linux/config.h>
#include <linux/console_struct.h>
+#include <linux/vt_buffer.h>


/*

--------------------------------- PART 2 ---------------------------------

--- native-2.2.0/include/asm-alpha/vga.h Fri Jul 17 21:21:46 1998
+++ linux/include/asm-alpha/vga.h Sun Jan 24 20:26:57 1999
@@ -21,7 +21,7 @@
writew(val, (unsigned long) addr);
}

-extern inline u16 scr_readw(u16 *addr)
+extern inline u16 scr_readw(const u16 *addr)
{
if ((long) addr < 0)
return *addr;
@@ -37,12 +37,12 @@
memsetw_io(s, c, count);
}

-extern inline void scr_memcpyw_from(u16 *d, u16 *s, unsigned int count)
+extern inline void scr_memcpyw_from(u16 *d, const u16 *s, unsigned int count)
{
memcpy_fromio(d, s, count);
}

-extern inline void scr_memcpyw_to(u16 *d, u16 *s, unsigned int count)
+extern inline void scr_memcpyw_to(u16 *d, const u16 *s, unsigned int count)
{
memcpy_toio(d, s, count);
}
--- native-2.2.0/include/asm-mips/vga.h Fri Jul 17 21:21:58 1998
+++ linux/include/asm-mips/vga.h Sun Jan 24 20:26:57 1999
@@ -19,7 +19,7 @@
writew(val, (unsigned long) addr);
}

-extern inline u16 scr_readw(u16 *addr)
+extern inline u16 scr_readw(const u16 *addr)
{
if ((long) addr < 0)
return *addr;
--- native-2.2.0/include/asm-ppc/vga.h Fri Nov 20 10:03:28 1998
+++ linux/include/asm-ppc/vga.h Sun Jan 24 20:32:04 1999
@@ -16,7 +16,7 @@
st_le16(addr, val);
}

-extern inline u16 scr_readw(u16 *addr)
+extern inline u16 scr_readw(const u16 *addr)
{
return ld_le16(addr);
}
--- native-2.2.0/include/asm-sparc64/vga.h Fri Jul 17 21:22:08 1998
+++ linux/include/asm-sparc64/vga.h Sun Jan 24 20:26:57 1999
@@ -17,7 +17,7 @@
writew(val, (unsigned long) addr);
}

-static inline u16 scr_readw(u16 *addr)
+static inline u16 scr_readw(const u16 *addr)
{
if ((long) addr < 0)
return *addr;
--- native-2.2.0/include/linux/selection.h Wed Sep 30 21:37:37 1998
+++ linux/include/linux/selection.h Sun Jan 24 20:59:09 1999
@@ -38,7 +38,7 @@
extern void getconsxy(int currcons, char *p);
extern void putconsxy(int currcons, char *p);

-extern u16 vcs_scr_readw(int currcons, u16 *org);
+extern u16 vcs_scr_readw(int currcons, const u16 *org);
extern void vcs_scr_writew(int currcons, u16 val, u16 *org);

#endif
--- native-2.2.0/include/linux/vt_buffer.h Wed Sep 30 21:37:42 1998
+++ linux/include/linux/vt_buffer.h Sun Jan 24 20:59:09 1999
@@ -41,7 +41,7 @@
#endif

#ifndef VT_BUF_HAVE_MEMCPYW
-extern inline void scr_memcpyw(u16 *d, u16 *s, unsigned int count)
+extern inline void scr_memcpyw(u16 *d, const u16 *s, unsigned int count)
{
count /= 2;
while (count--)
@@ -50,7 +50,7 @@
#endif

#ifndef VT_BUF_HAVE_MEMMOVEW
-extern inline void scr_memmovew(u16 *d, u16 *s, unsigned int count)
+extern inline void scr_memmovew(u16 *d, const u16 *s, unsigned int count)
{
if (d < s)
scr_memcpyw(d, s, count);
@@ -65,14 +65,14 @@
#endif

#ifndef VT_BUF_HAVE_MEMCPYF
-extern inline void scr_memcpyw_from(u16 *d, u16 *s, unsigned int count)
+extern inline void scr_memcpyw_from(u16 *d, const u16 *s, unsigned int count)
{
count /= 2;
while (count--)
*d++ = scr_readw(s++);
}

-extern inline void scr_memcpyw_to(u16 *d, u16 *s, unsigned int count)
+extern inline void scr_memcpyw_to(u16 *d, const u16 *s, unsigned int count)
{
count /= 2;
while (count--)
diff -u --recursive --exclude-from=/home/geert/diff-excludes-linux --new-file native-2.2.0/drivers/char/console.c linux/drivers/char/console.c
--- native-2.2.0/drivers/char/console.c Thu Jan 21 23:31:54 1999
+++ linux/drivers/char/console.c Sun Jan 24 20:26:57 1999
@@ -2778,7 +2778,7 @@
set_cursor(currcons);
}

-u16 vcs_scr_readw(int currcons, u16 *org)
+u16 vcs_scr_readw(int currcons, const u16 *org)
{
if ((unsigned long)org == pos && softcursor_original != -1)
return softcursor_original;

Greetings,

Geert

--
Geert Uytterhoeven                     Geert.Uytterhoeven@cs.kuleuven.ac.be
Wavelets, Linux/{m68k~Amiga,PPC~CHRP}  http://www.cs.kuleuven.ac.be/~geert/
Department of Computer Science -- Katholieke Universiteit Leuven -- Belgium

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/