VOGONS


First post, by pupnik

User metadata
Rank Newbie
Rank
Newbie

Hello,

Since changes from 0.65 to 0.70 (somewhere around early 2007) an error was introduced into the ega/vga for ARM cpu (arm926ej-s)

[sbox-SB_Arm2: ~] > gcc -v
Reading specs from /scratchbox/compilers/cs2005q3.2-glibc-arm/lib/gcc/arm-none-linux-gnueabi/3.4.4/specs
Reading specs from /scratchbox/compilers/cs2005q3.2-glibc-arm/gcc.specs
rename spec cpp to old_cpp
Configured with: /home/kl/cs2005q3-2_toolchain/gcc/glibc/work/gcc-2005q3-2/configure --build=i386-linux --host=i386-linux --target=arm-none-linux-gnueabi --prefix=/scratchbox/compilers/cs2005q3.2-glibc-arm --with-headers=/scratchbox/compilers/cs2005q3.2-glibc-arm/usr/include --enable-languages=c,c++ --enable-shared --enable-threads --disable-checking --enable-symvers=gnu --program-prefix=arm-linux- --with-gnu-ld --enable-__cxa_atexit --disable-libssp --disable-libstdcxx-pch --with-cpu= --enable-interwork
Thread model: posix
gcc version 3.4.4 (release) (CodeSourcery ARM 2005q3-2)

Dosbox 0.72 // Nokia 770 arm926ej-s screenshots
VGATest 0Dh
Mode_0Dh_b_BAD.png
Mode_0Dh_c_BAD.png
VGATest 0Eh
Mode_0Eh_a_BAD.png
VGATest 10h
Mode_10h_a_BAD.png
VGATest 12h
Mode_12h_a_BAD.png

I'll try to find which commits caused this by building cvs versions.. when i figure out how to do a checkout @ date in the past.

Thanks - Cheers!

Reply 1 of 13, by pupnik

User metadata
Rank Newbie
Rank
Newbie

cvs 2007-01-03 works
cvs 2007-01-23 works
cvs 2007-01-25 has the error!

2007-01-24 17:29 harekiet

* include/render.h, include/vga.h, src/gui/render.cpp,
src/gui/render_loops.h, src/gui/render_scalers.cpp,
src/gui/render_simple.h, src/gui/render_templates.h,
src/gui/sdlmain.cpp, src/hardware/vga.cpp,
src/hardware/vga_crtc.cpp, src/hardware/vga_draw.cpp,
src/hardware/vga_memory.cpp, src/hardware/vga_misc.cpp,
src/hardware/vga_other.cpp, src/ints/int10.cpp,
src/ints/int10_modes.cpp: Fixes to hercules emulation, better
detection and bank switching Fixes to tandy emulation, 640x200x16
mode and different sizes bank. EGA/VGA memory changes detection
for faster rendering added Renderer does initial pass to check for
needing to lock buffer

Reply 2 of 13, by vasyl

User metadata
Rank Oldbie
Rank
Oldbie

That was really complex change touching quite a few aspects of video memory emulation. The issue looks like endianness bug in which case it should affect other large-endian CPUs. Did anyone see this bug on non-Intel Macs?

Reply 3 of 13, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Afaik it's the unchained ega only, not that much was changed for those,
but i fail to see why it looks that funny (endianness might be the cause
due to the (Bit32u*) forced casting).

Reply 4 of 13, by vasyl

User metadata
Rank Oldbie
Rank
Oldbie

Either in vga_memory or in vga_draw, there are a few places where pointers are casted to Bit32u*. In addition to endianness, there is another possibility: some ARM CPUs have very peculiar way of dealing with unaligned accesses -- those get quietly aligned to proper boundary. If that is the case some other ports should crash on those spots badly.

Reply 5 of 13, by pupnik

User metadata
Rank Newbie
Rank
Newbie

On a tip from Harekiet i tried reversing byte order here - didn't fix...

class VGA_ChainedEGA_Handler : public PageHandler {

...
colors0_3 =
//ARNIM Harekiet
Expand16Table[3][temp.b[3]] |
Expand16Table[2][temp.b[2]] |
Expand16Table[1][temp.b[1]] |
Expand16Table[0][temp.b[0]];
*(Bit32u *)write_pixels=colors0_3;
temp.d=pixels.d & 0x0f0f0f0f;
colors4_7 =
Expand16Table[3][temp.b[3]] |
Expand16Table[2][temp.b[2]] |
Expand16Table[1][temp.b[1]] |
Expand16Table[0][temp.b[0]];
*(Bit32u *)(write_pixels+4)=colors4_7;

Reply 6 of 13, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

First check that you're at the unchained handlers, or change both to be sure.
Then you didn't change the code, just re-arranged it. The first line should
read something like

Expand16Table[0][temp.b[3]]

so you actually change the ordering, the other ones respectively.

Reply 7 of 13, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

we are actually making progress
the bugs are caused by unalligned memory acces.
forcing the cpu to workaround those makes it work. However that is not a workable solution. We are trying to find a workaround.

(it is caused by the the vga.mem.leanar[start] which is casted to 32u (and friends))

Water flows down the stream
How to ask questions the smart way!

Reply 9 of 13, by pupnik

User metadata
Rank Newbie
Rank
Newbie

Thanks to Serge for pointing-out this trick:

"If you set 'echo 3 > /proc/cpu/alignment' and it 'fixes' the problem, alignment issues are really involved. You can also check 'dmesg' output after running dosbox and it will show addresses of instructions causing problems. Setting 'echo 4 > /proc/cpu/alignment' will generate signal and terminate program on improper alignment, it is useful if you can run it in gdb or want to get a coredump."

Here is an example of a warning generated:

[96001.396148] Alignment trap: dosbox (1363) PC=0x000962d0 Instr=0xe5802004 Addres s=0x014ab5eb FSR 0x813

Here is the backgrace of the first hangup:

http://pastebin.ca/725398

Removing these casts allowed chained mode to run.

diff src/hardware/vga_memory.cpp src/hardware/vga_memory.cpp~
234c234
< pixels.d=(vga.mem.linear)[start];
---
> pixels.d=((Bit32u*)vga.mem.linear)[start];
237c237
< (vga.mem.linear)[start]=pixels.d;
---
> ((Bit32u*)vga.mem.linear)[start]=pixels.d;
247c247
< *write_pixels=colors0_3;
---
> *(Bit32u *)write_pixels=colors0_3;
254c254
< *(write_pixels+4)=colors4_7;
---
> *(Bit32u *)(write_pixels+4)=colors4_7;
256,257c256,257
< *(write_pixels+512*1024)=colors0_3;
< *(write_pixels+512*1024+4)=colors4_7;
---
> *(Bit32u *)(write_pixels+512*1024)=colors0_3;
> *(Bit32u *)(write_pixels+512*1024+4)=colors4_7;

Reply 10 of 13, by pupnik

User metadata
Rank Newbie
Rank
Newbie

c2woody suggested changes which yield proper visual results in vgatest.

(AWESOME)

From the Jan.25 cvs

diff vga_memory.cpp vga_memory.cpp.orig
117,118c117
< //vga.latch.d=((Bit32u*)vga.mem.linear)[start];
< vga.latch.d=host_readd((HostPt)(&((Bit32u*)vga.mem.linear)[start]));
---
> vga.latch.d=((Bit32u*)vga.mem.linear)[start];
161,162c160
< //pixels.d=((Bit32u*)vga.mem.linear)[start];
< pixels.d=host_readd((HostPt)(&((Bit32u*)vga.mem.linear)[start]));
---
> pixels.d=((Bit32u*)vga.mem.linear)[start];
232,233c230
< // pixels.d=((Bit32u*)vga.mem.linear)[start];
< pixels.d=host_readd((HostPt)(&((Bit32u*)vga.mem.linear)[start]));
---
> pixels.d=((Bit32u*)vga.mem.linear)[start];
236,237c233
< // ((Bit32u*)vga.mem.linear)[start]=pixels.d;
< host_writed((HostPt)(&((Bit32u*)vga.mem.linear)[start]),pixels.d);
---
> ((Bit32u*)vga.mem.linear)[start]=pixels.d;
247,248c243
< // *(Bit32u *)write_pixels=colors0_3;
< host_writed((HostPt)write_pixels,colors0_3);
---
> *(Bit32u *)write_pixels=colors0_3;
255,256c250
< // *(Bit32u *)(write_pixels+4)=colors4_7;
< host_writed((HostPt)(write_pixels+4),colors4_7);
---
> *(Bit32u *)(write_pixels+4)=colors4_7;
258,261c252,253
< // *(Bit32u *)(write_pixels+512*1024)=colors0_3;
< // *(Bit32u *)(write_pixels+512*1024+4)=colors4_7;
< host_writed((HostPt)(write_pixels+512*1024),colors0_3);
< host_writed((HostPt)(write_pixels+512*1024+4),colors4_7);
---
> *(Bit32u *)(write_pixels+512*1024)=colors0_3;
> *(Bit32u *)(write_pixels+512*1024+4)=colors4_7;

Running with the kernel unaligned memory trap still throws an exception later on at line 426:

writeHandler(addr+0,(Bit8u)(val >> 0));  // triggers unaligned trap - PUPNIK

I will try to get the video capture going to provide better feedback. There are still some odd errors drawing in some modes.

Cheers 😀

Reply 12 of 13, by Freddo

User metadata
Rank Oldbie
Rank
Oldbie

Congrats on fixing the bug! 😁

pupnik wrote:

Dosbox 0.72 // Nokia 770 arm926ej-s screenshots

This is very cool. The Nokia 770 got a 252 MHz ARM CPU, no? I'm curious, though, how well does DOSBox run on such machine?