Page 1 of 1

VIA Unichrome FrameBuffer Memory Problem

Posted: Sat Jan 19, 2008 8:01 am
by Kenny
Hi

I have been trying to put together a Graphics Driver for my VIA Unichrome CLE266 CX that is just sufficient to push the screenmode into a FrameBuffered 1024x768x32bitx60Hz.

Using the VGA specifications and the free-available VIA Framebuffer source, I have succeded in getting the mode to display correctly, but I have having an odd problem with the actual accessing of the the FrameBuffer memory.

The Display mode I am using should use exactly 3Mb of memory for it's buffer, and should be a simple packed-pixel (or chunky) display mode. The problem I am getting is that when I try to access the buffer memory in odd numbered megabytes, it actually access the memory in the previous, even numbered, megabyte (for example, accessing the memory 1Mb into the buffer actually access the memory at the beginning of the buffer).

According to the PCI Configuration for the card, the graphics card memory starts at 0xE0000000, and I have assigned 64Mb of shared memory to the card through the BIOS, both of which I have proven experimentally.

To demonstrate this, I used the following code:

Code: Select all

{
	// Perform a few reads and writes to test the memory
	unsigned int* lTestA = (unsigned int *)0xE0000000;	// Start of Framebuffer Memory
	unsigned int* lTestB = (unsigned int *)0xE0100000;	// 1Mb
	unsigned int* lTestC = (unsigned int *)0xE0200000;	// 2Mb
	unsigned int* lTestD = (unsigned int *)0xE0300000;	// 3Mb

	*lTestA = 0xDE;
	*lTestB = 0xAD;
	*lTestC = 0xBE;
	*lTestD = 0xEF;

	kprintf("TestA = 0x%02X\n", *lTestA);
	kprintf("TestB = 0x%02X\n", *lTestB);
	kprintf("TestC = 0x%02X\n", *lTestC);
	kprintf("TestD = 0x%02X\n", *lTestD);
}
The output of this is, unfortunately:

Code: Select all

TestA = 0xAD
TestB = 0xAD
TestC = 0xEF
TestD = 0xEF
The write to TestB overwrote the data in TestA, and similarly TestD overwrote TestC.

The on-screen result is that the top and bottom thirds of the screen work correctly, but the middle one-third of my screen displays garbage data. Any attempt to write to this middle one-third actually overwrites the data in the top one-third.

My only thought is that this is some kind of behaviour designed to emulate a 1Mb graphics card, so any writes above 1Mb wrap around, but I haven't been able to find any setting to control this.


Has anyone had experience with this specific system or of a similar problem that I could experiment with that may yield a solution?

Are there any VGA configuration options that I may have missed that cause a similar effect in VGA modes?

Posted: Sat Jan 19, 2008 8:56 am
by Ready4Dis
This might sound a bit odd, but are you sure you have A20 working right? If not, it would cause every other MB to not work properly, like you are seeing.

Posted: Sat Jan 19, 2008 1:25 pm
by Dex
I agree with Ready4Dis, Here is a example of in theory A20 should not make a difference.
But it does, so you need to enable A20 or try a differant ver, as some A20 code does not work on some PC.
There was a big topic on this problem, on the forum about 3 years ago, you may beable to find it with search.

Posted: Sat Jan 19, 2008 6:10 pm
by Kenny
Hmmm, thinking about it, that would explain a thing or two that didn't seem to work quite correctly with the memory manager ... :oops:

I shall look into this

Posted: Sat Jan 19, 2008 11:51 pm
by Kenny
Absolutely spot on, top marks. My thanks to you both.

Despite reading many tutorials on setting up 32-bit protected mode, the one I implemented didn't include the section on enabling the A20 line.

A quick tweak to the loader and all is well, and in glorious 32bit technicolour to boot.

Posted: Tue Jan 22, 2008 1:28 pm
by Ready4Dis
Kenny wrote:Absolutely spot on, top marks. My thanks to you both.

Despite reading many tutorials on setting up 32-bit protected mode, the one I implemented didn't include the section on enabling the A20 line.

A quick tweak to the loader and all is well, and in glorious 32bit technicolour to boot.
Well, glad it's working now, let us know how it goes. If you don't mind me asking, how are you setting the display? Any links/tutorials, not that I have a unichrome to test with, just wondering for when i am ready to start writing some video drivers for other machines.