Recently, i've been trying to get the HPET to work properly as a source for event timing in my kernel. As much as I love the PIT, I'd like something with a little more precision (and the ability to provide a stable time source).
It took me a couple of tries to figure it out, but my HPET code seems to work reliably in VMWare. The problem is that it fails silently while running in VirtualBox. I was wondering if anybody else has tried to do this on vbox and succeeded.
What i'm trying to do is set up a one-shot interrupt from the HPET to trigger a timer callback. VirtualBox is reporting an HPET via ACPI, and the information i'm getting seems to be sane. I've made sure my I/O APIC mapping is set up properly, and i'm using level triggered interrupts. ( This is so that i can detect an overrun of the HPET timer beyond my intended interrupt time, supposing the delta between the time that was current during delta calculation and the time that i set the HPET counter enabled was smaller than the actual time that passed ).
I have the comparator already set up as 32-bit, level triggered, interrupts disabled.
Every time I set the HPET counter comparator to trigger, i do these steps (which took some trial and error to figure out, as the HPET specification is somewhat ambiguous:
source file
Code: Select all
::HW::ACPI::HPET :: SetCounterComparratorWritable ( & CounterInfo, true );
::HW::ACPI::HPET :: WriteCounterComparrator32 ( & CounterInfo, NextInternalTimeout );
::HW::ACPI::HPET :: ClearCounterInterruptLevel ( & CounterInfo );
::HW::ACPI::HPET :: SetCounterEnabled ( & CounterInfo, true );
Like I said before, this works perfectly fine in VMWare, which i usually trust to be more accurate and more quick-to-fail on problems, but seems to just not work in virtualbox. I'm really stuck here, and at the moment, I don't have hardware I feel comfortable testing on, so any help here would be greatly appreciated.