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.
Calibrating the local APIC timer without PIT or RTC
Re: Calibrating the local APIC timer without PIT or RTC
Hi,
The only other alternatives (excluding HPET, PIT and RTC interrupts) is polling the RTC's "seconds" (which would be slow) or using the ACPI timer (which would also involve parsing ACPI tables).
Cheers,
Brendan
It is the only official way.jnc100 wrote: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?
I'd calibrate the local APIC timers during boot (in boot code that runs before the kernel is started); mostly to shift the code out of the kernel.jnc100 wrote: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.
The only other alternatives (excluding HPET, PIT and RTC interrupts) is polling the RTC's "seconds" (which would be slow) or using the ACPI timer (which would also involve parsing ACPI tables).
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: Calibrating the local APIC timer without PIT or RTC
Many thanks. Guess I will continue to use the HPET (when available).
Regards,
John.
Regards,
John.
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: Calibrating the local APIC timer without PIT or RTC
One option would be to set the kernel to start the local APIC with a "reasonable" tick rate and then having the user-space ACPI server hand over the information the kernel needs to it