|
AquilaOS documentation
How it works, and its code
|
x86: the High Precision Event Timer (HPET), as a clock. More...
Go to the source code of this file.
Macros | |
| #define | HPET_CAP 0x000 |
| #define | HPET_CNF 0x010 |
| #define | HPET_CNT 0x0F0 |
| #define | CNF_ENABLE 0x1 |
| #define | CNF_LEGACY 0x2 |
| #define | PERIOD_MAX_FS 100000000ULL |
Functions | |
| static uint32_t | reg32 (unsigned off) |
| Reads a 32-bit HPET register. | |
| static void | reg32_write (unsigned off, uint32_t val) |
| Writes a 32-bit HPET register. | |
| uint64_t | x86_hpet_read (void) |
| Reads the HPET's 64-bit counter. | |
| uint32_t | x86_hpet_read32 (void) |
| Reads the low half of the HPET's counter only: a single read, which matters because each read is slow under a hypervisor. | |
| uint64_t | x86_hpet_period_fs (void) |
| Returns the HPET counter's period. | |
| int | x86_hpet_init (void) |
| Finds the HPET and starts its counter. | |
Variables | |
| static volatile uint32_t * | regs |
| static uint64_t | period_fs |
x86: the High Precision Event Timer (HPET), as a clock.
Only the HPET's main counter is used, as a clock (sys/clock.c). ACPI's HPET table says where its registers are, which are mapped uncached. It counts at the period its capabilities say (10 ns on QEMU). "Legacy replacement" is left off, so the PIT keeps IRQ 0, and the comparators aren't used.
References: [1] - IA-PC HPET (High Precision Event Timers) Specification, Intel, 1.0a
Definition in file hpet.c.
| #define CNF_ENABLE 0x1 |
Definition at line 24 of file hpet.c.
Referenced by x86_hpet_init().
| #define CNF_LEGACY 0x2 |
Definition at line 25 of file hpet.c.
Referenced by x86_hpet_init().
| #define HPET_CAP 0x000 |
Definition at line 20 of file hpet.c.
Referenced by x86_hpet_init().
| #define HPET_CNF 0x010 |
Definition at line 21 of file hpet.c.
Referenced by x86_hpet_init().
| #define HPET_CNT 0x0F0 |
Definition at line 22 of file hpet.c.
Referenced by x86_hpet_init(), x86_hpet_read(), and x86_hpet_read32().
| #define PERIOD_MAX_FS 100000000ULL |
Definition at line 27 of file hpet.c.
Referenced by x86_hpet_init().
|
inlinestatic |
Reads a 32-bit HPET register.
Definition at line 33 of file hpet.c.
Referenced by reg32(), x86_hpet_init(), x86_hpet_read(), and x86_hpet_read32().
|
inlinestatic |
Writes a 32-bit HPET register.
Definition at line 39 of file hpet.c.
References reg32_write(), and regs.
Referenced by reg32_write(), and x86_hpet_init().
| int x86_hpet_init | ( | void | ) |
Finds the HPET and starts its counter.
Definition at line 90 of file hpet.c.
References acpi_gas::address, acpi_hpet::address, arch_mmio_map(), CNF_ENABLE, CNF_LEGACY, acpi_hpet::header, HPET_CAP, HPET_CNF, HPET_CNT, acpi_sdt_header::length, NULL, period_fs, PERIOD_MAX_FS, printk(), reg32(), reg32_write(), regs, acpi_gas::space, x86_acpi_table(), and x86_hpet_init().
Referenced by x86_clock_init(), and x86_hpet_init().
| uint64_t x86_hpet_period_fs | ( | void | ) |
Returns the HPET counter's period.
Definition at line 79 of file hpet.c.
References period_fs, and x86_hpet_period_fs().
Referenced by tsc_calibrate(), x86_clock_init(), and x86_hpet_period_fs().
| uint64_t x86_hpet_read | ( | void | ) |
Reads the HPET's 64-bit counter.
Its two halves are read again until the high half is the same before and after, so that a carry between them can't give a wrong value.
Definition at line 51 of file hpet.c.
References HPET_CNT, reg32(), and x86_hpet_read().
Referenced by tsc_calibrate(), and x86_hpet_read().
| uint32_t x86_hpet_read32 | ( | void | ) |
Reads the low half of the HPET's counter only: a single read, which matters because each read is slow under a hypervisor.
Definition at line 69 of file hpet.c.
References HPET_CNT, reg32(), and x86_hpet_read32().
Referenced by counter(), and x86_hpet_read32().
|
static |
Definition at line 30 of file hpet.c.
Referenced by x86_hpet_init(), and x86_hpet_period_fs().
|
static |
Definition at line 29 of file hpet.c.
Referenced by reg32(), reg32_write(), and x86_hpet_init().