Calibrating the local APIC timer without PIT or RTC
Posted: Mon Jul 25, 2011 7:11 am
From the introduction to the HPET spec, HPET is "intended to initially supplement and eventually replace the legacy 8254 Programmable Interval Timer and the Real Time Clock Periodic Interrupt generation functions". Despite the fact that the last update to this specification was in 2004 and this hasn't happened yet, I am trying to find an alternative "non-legacy" method of calibrating the local APIC timer for use as a scheduler interrupt in a microkernel, should this actually become the case.
Currently, within my kernel I am using the HPET to synchronize the LAPIC. Basically I reset the HPET main counter to 0, the LAPIC timer counter to 0xffffffff and start both running, then wait a certain amount of time - this delay is currently just waiting for the TSC to increment a certain amount - then read both and calculate a bus frequency. Whilst this works, and appears to give accurate values, it does require me to parse the ACPI tables within the kernel, as I believe this is the only official way to find out about HPET timers?
This wouldn't be a problem if I wasn't trying to write a microkernel where I hope to later load a system initialization process which parses the ACPI tables and loads the driver processes as required. I am currently duplicating the ACPI table parsing code within the kernel itself and the processes, which seems wasteful. I obviously need the LAPIC timer set up before I can load other processes and start task switching between them.
My question therefore is whether there is another way to calibrate the LAPIC timer (without the PIT or RTC interrupt) or whether there is a simpler way of finding the HPET timers? Of note, my SMBIOS tables do not provide the system bus speed.
Regards,
John.
Currently, within my kernel I am using the HPET to synchronize the LAPIC. Basically I reset the HPET main counter to 0, the LAPIC timer counter to 0xffffffff and start both running, then wait a certain amount of time - this delay is currently just waiting for the TSC to increment a certain amount - then read both and calculate a bus frequency. Whilst this works, and appears to give accurate values, it does require me to parse the ACPI tables within the kernel, as I believe this is the only official way to find out about HPET timers?
This wouldn't be a problem if I wasn't trying to write a microkernel where I hope to later load a system initialization process which parses the ACPI tables and loads the driver processes as required. I am currently duplicating the ACPI table parsing code within the kernel itself and the processes, which seems wasteful. I obviously need the LAPIC timer set up before I can load other processes and start task switching between them.
My question therefore is whether there is another way to calibrate the LAPIC timer (without the PIT or RTC interrupt) or whether there is a simpler way of finding the HPET timers? Of note, my SMBIOS tables do not provide the system bus speed.
Regards,
John.