HPET: Difference between revisions
[unchecked revision] | [unchecked revision] |
Content deleted Content added
No edit summary |
m Bot: Replace deprecated source tag with syntaxhighlight |
||
(11 intermediate revisions by 8 users not shown) | |||
Line 1:
:''This page is not meant as a full description of HPET, only as a lightweight introduction. If you need any information not covered by this article, consult the [http://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/software-developers-hpet-spec-1-0a.pdf HPET specification].''
'''HPET''', or High Precision Event Timer, is a piece of hardware designed by Intel and Microsoft to replace older [[PIT]] and [[RTC]]. It consists of (usually 64-bit) main counter (which counts up), as well as from 3 to 32 32-bit or 64
▲HPET, or High Precision Event Timer, is a piece of hardware designed by Intel and Microsoft to replace older [[PIT]] and [[RTC]]. It consists of (usually 64-bit) main counter (which counts up), as well as from 3 to 32 32 or 64 bit wide comparators. HPET is programmed using memory mapped IO, and the base address of HPET can be found using [[ACPI]].
==Detecting HPET using ACPI==
The [http://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/software-developers-hpet-spec-1-0a.pdf HPET specification] defines an ACPI 2.0 table that is to be used to detect presence, address and capabilities of HPET present in the system. If this table doesn't exist, you should assume there is no HPET and you should fall back to [[PIT]] or the [[APIC timer]].
<
{
{
{
</syntaxhighlight>
==HPET - timer vs comparators==
Line 101 ⟶ 99:
===FSB mapping===
This mapping is almost identical to PCI's Message Signaled Interrupts. The "Timer N FSB Interrupt Route Register" which defines how FSB interrupts are configured can be found in the specification. FSB interrupts are enabled using "Tn_FSB_EN_CNF" field in timer's configuration register. This mapping mode will not be further discussed in this article.
==HPET registers==
Line 112 ⟶ 110:
!Type
|-
|0x000 -
|General Capabilities and ID Register
|Read only
Line 150 ⟶ 148:
|63:32
|COUNTER_CLK_PERIOD
|Main counter tick period in
|-
|31-16
Line 299 ⟶ 297:
General initialization:
1. Find HPET base address in 'HPET' ACPI table.
2. Calculate HPET frequency (f = 10^15 / period).
3. Save minimal tick (either from ACPI table or configuration register).
4. Initialize comparators.
5. Set ENABLE_CNF bit.
Timer N initialization:
1. Determine if timer N is periodic capable, save that information to avoid re-reading it every time.
2. Determine allowed interrupt routing for current timer and allocate an interrupt for it.
Line 319 ⟶ 324:
To enable one-shot mode:
<
// "time" is time in
if (time < COUNTER_CLK_PERIOD)
{
Line 328 ⟶ 333:
write_register_64(timer_configuration(n), (ioapic_input << 9) | (1 << 2));
write_register_64(timer_comparator(n), read_register(main_counter) + time);
</syntaxhighlight>
I hope the above code is obvious. If it's not, please analyze the meaning of specific fields in registers used above.
Line 336 ⟶ 341:
To enable periodic mode:
<
// "time" is time in
if (time < COUNTER_CLK_PERIOD)
{
Line 346 ⟶ 351:
write_register_64(timer_comparator(n), read_register(main_counter) + time);
write_register_64(timer_comparator(n), time);
</syntaxhighlight>
This snippet requires some more comments.
Line 361 ⟶ 366:
==See also==
* [[IOAPIC]]
* [[APIC]]
* [[APIC timer]]
* [[PIT]]
* [[RTC]]
Line 367 ⟶ 374:
* [http://en.wikipedia.org/wiki/High_Precision_Event_Timer HPET article on Wikipedia]
* [http://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/software-developers-hpet-spec-1-0a.pdf Intel's HPET Specification v1.0a]
[[Category:Common Devices]]
[[Category:Interrupts]]
[[Category:Timers]]
|