Bochs' RTC Periodic Interrupt (aka IRQ 8) going nuts
Posted: Sun Dec 29, 2013 10:31 pm
Hello. I've had this problem before with Bochs's PIT before -- basically, it sends more interrupts than it should. I understand Bochs is not designed to emulate realtime execution, but for timekeeping it would be nice.
To fix the PIT problem I used
Which fixed it. Since then, I have moved wall clock timekeeping to the RTC periodic interrupt service. It works fine on VBox and QEMU, but again the interrupts are too fast.
What's the setting to fix it?
EDIT:
To fix the PIT problem I used
Code: Select all
clock: sync=realtime, time0=utc, rtc_sync=1
What's the setting to fix it?
EDIT:
Code: Select all
void InitialiseTimer()
{
Kernel::HardwareAbstraction::Interrupts::SetGate(32 + 8, (uint64_t)Time::RTCHandler, 0x08, 0xEE);
IOPort::WriteByte(0x70, 0x8B); // select register B, and disable NMI
uint8_t prev = IOPort::ReadByte(0x71); // read the current value of register B
IOPort::WriteByte(0x70, 0x8B); // set the index again (a read will reset the index to register D)
IOPort::WriteByte(0x71, prev | 0x40); // write the previous value ORed with 0x40. This turns on bit 6 of register B
uint8_t rate = RTCTImerShiftAmt; // rate must be above 2 and not over 15
IOPort::WriteByte(0x70, 0x8A); // set index to register A, disable NMI
prev = IOPort::ReadByte(0x71); // get initial value of register A
IOPort::WriteByte(0x70, 0x8A); // reset index to A
IOPort::WriteByte(0x71, (prev & 0xF0) | rate); //write only our rate to A. Note, rate is the bottom 4 bits.
IOPort::WriteByte(0x70, 0x0C);
IOPort::ReadByte(0x71);
}