QEMUs font implementation behaving strangely
Posted: Fri Jul 09, 2010 2:57 am
Hi again.
I though that I've reach a point where I would be able to handle most problems myself, but I stand corrected. I've recently been playing around with some very basic VGA stuff in order to load a new font into the VGA memory. My implementation works very well in Bochs and on real hardware, but QEMU seems to be using an entirely different implementation of the VGA hardware.
Well, in text mode standard VGA hardware has the ability to store a total of 8 sets of fonts in the 64 KB memory chunk at 0xA0000. Each font using 0x2000 bytes of memory. The font in use is selected using the Character Map Select Register (03h) in the Sequencer Register (0x3C4/0x3C5). I've chosen to load a 8x8 font at 0xA0000 and a 8x16 font at 0xA2000 which enables me to make quick switches between 80x25 and 80x50 mode. This works as expected in Bochs and on my laptop.
For some time I've tried to figure out how the hell Qemu handles fonts and I partially understand it now, but I doesn't make much sense to me. Qemu uses 0x4000 bytes of memory for each font, but it only uses every second slot, so to speak. First character is stored at 0xA0000, but then it skips a slot (each slot is normally 32 bytes) and stores the next character at 0xA0040. Furthermore it also skips every second byte in each slot, so that each line of a char is stored at e.g. 0xA0000, 0xA0002, 0xA0004 and so on. Finally because each font uses twice the normal size, the values normally written to the Character Map Select Register in order to select a specific font does not match.
I suspect that there's some kind of switch that changes this behaviour? Have anyone got an idea on how I get around this problem, I find it a little odd.
Thanks in advance.
I though that I've reach a point where I would be able to handle most problems myself, but I stand corrected. I've recently been playing around with some very basic VGA stuff in order to load a new font into the VGA memory. My implementation works very well in Bochs and on real hardware, but QEMU seems to be using an entirely different implementation of the VGA hardware.
Well, in text mode standard VGA hardware has the ability to store a total of 8 sets of fonts in the 64 KB memory chunk at 0xA0000. Each font using 0x2000 bytes of memory. The font in use is selected using the Character Map Select Register (03h) in the Sequencer Register (0x3C4/0x3C5). I've chosen to load a 8x8 font at 0xA0000 and a 8x16 font at 0xA2000 which enables me to make quick switches between 80x25 and 80x50 mode. This works as expected in Bochs and on my laptop.
For some time I've tried to figure out how the hell Qemu handles fonts and I partially understand it now, but I doesn't make much sense to me. Qemu uses 0x4000 bytes of memory for each font, but it only uses every second slot, so to speak. First character is stored at 0xA0000, but then it skips a slot (each slot is normally 32 bytes) and stores the next character at 0xA0040. Furthermore it also skips every second byte in each slot, so that each line of a char is stored at e.g. 0xA0000, 0xA0002, 0xA0004 and so on. Finally because each font uses twice the normal size, the values normally written to the Character Map Select Register in order to select a specific font does not match.
I suspect that there's some kind of switch that changes this behaviour? Have anyone got an idea on how I get around this problem, I find it a little odd.
Thanks in advance.