I'm currently working on getting the PIC and PIT to work correctly. I believe I got the PIC working correctly, but the PIT causes problems for me. When I try to change the timer frequency, I get a IRQ7 for some frequencies. The behaviour of Bochs and VirtualBox is different, which complicates things even further... Another strange thing is that I cannot mask this IRQ for some reason.
What I do now is:
- Map the PIC to 0x20
- Mask all interrupts (just for now, as a test case)
- Enable interrupts
The code that I use for changing the PIT frequency:
(I hardcoded the 0x36, which sets the options of the command word. It initializes counter 0 as a squarewave and sets LSB and then MSB.
Code: Select all
void setPIT(uint32_t frequency)
{
uint16_t tickPeriod = (uint16_t)(1193180 / frequency);
ticks = 0;
outb(0x43, 0x36);
outb(0x40, tickPeriod & 0xff);
outb(0x40, tickPeriod >> 8);
}
I found people with a similar issue here, but since I'm running on an emulator, this must be something else...