I'm having trouble changing the font bitmap from VGA card. I am developing a 32-bit paging kernel for the x86 architecture. Following is the code:
Code: Select all
static void set_plane(unsigned p)
{
unsigned char pmask;
p &= 3;
pmask = 1 << p;
outportb(0x3CE, 4);
outportb(0x3CF, p);
outportb(0x3C4, 2);
outportb(0x3C5, pmask);
}
static void write_font(unsigned char *buf)
{
unsigned char seq2, seq4, gc4, gc5, gc6;
unsigned font_height, i, j;
unsigned char * ptr;
outportb(0x3C4, 2);
seq2 = inportb(0x3C5);
outportb(0x3C4, 4);
seq4 = inportb(0x3C5);
outportb(0x3C5, seq4 | 0x04);
outportb(0x3CE, 4);
gc4 = inportb(0x3CF);
outportb(0x3CE, 5);
gc5 = inportb(0x3CF);
outportb(0x3CF, gc5 & ~0x10);
outportb(0x3CE, 6);
gc6 = inportb(0x3CF);
outportb(0x3CF, gc6 & ~0x02);
set_plane(2);
font_height = 16;
ptr = (unsigned char *) 0xB8000;
for(i = 0; i < 256; i++)
{
for(j = 0; j < font_height; j++)
{
ptr[0x1000 + 32 * i + j] = buf[font_height * i + j];
}
}
outportb(0x3C4, 2);
outportb(0x3C5, seq2);
outportb(0x3C4, 4);
outportb(0x3C5, seq4);
outportb(0x3CE, 4);
outportb(0x3CF, gc4);
outportb(0x3CE, 5);
outportb(0x3CF, gc5);
outportb(0x3CE, 6);
outportb(0x3CF, gc6);
}
Does anyone know what could it be?

