[coreboot] VGA cleanup advice

Nicky Sielicki sielicki at nicky.io
Tue Oct 27 18:09:42 CET 2015


Hello list,

I'm interested in cleaning up some of the VGA programming in coreboot.

I was trying to figure out why GM45 "native" textmode isn't working. I
noticed the following bit of code

> northbridge/intel/gm45/gma.c:144
>
>	const u8 cr[] = { 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
>		    0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00,
>		    0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3,
>		    0xff
>	};
>	vga_cr_write(0x11, 0);
>	for (i = 0; i <= 0x18; i++)
>		vga_cr_write(i, cr[i]);
>
>	<...>
>	vga_textmode_init();

That for-loop generates the following statement:

> 'vga_cr_write(0x11, 0x8e)'

Looking at some VGA documentation, and noticing that 0x8e has a MSB of
1, I realized that this statement just locked CRTC registers 00h-07h!
(http://www.osdever.net/FreeVGA/vga/crtcreg.htm#11)

That's no good, because the subsequent call to vga_textmode_init() tries
to write to some of those CRTC registers, and it's not checking if
they're locked. It assumes that no one else is working with VGA
registers.

It's worth noting that GM45 isn't the only platform where this CRTC
locking is occuring. A couple others follow this same practice of
loading the CR registers into an array, writing them, and then calling
vga_textmode_init(). That's probably not what we want, and I'm looking
for advice on cleaning this up.

I think what we want to do is avoid having the VGA registers touched
from outside drivers/pc80/vga/. That means that we need to add or extend
functions to it in order to disincentivize writing them directly-- but
is it possible to accomodate every use case? What functions aren't being
provided currently, and why is it necessary/easiest to write them
directly?

On the other hand, an easier fix is to just have vga_textmode_init()
check that the registers it writes to are unlocked.

Thanks,
Nicky Sielicki



More information about the coreboot mailing list