Skip to content

HPET

union hpet_timer_general_capabilities {
uint64_t raw;
struct {
uint64_t rev_id;
uint64_t num_timers;
uint64_t counter_size;
uint64_t reserved;
uint64_t leg_rt_cap;
uint64_t vendor_id;
uint64_t counter_clock_period;
};
};
union hpet_timer_config {
uint64_t raw;
struct {
uint64_t reserved0;
uint64_t interrupt_type;
uint64_t interrupt_enable;
uint64_t type;
uint64_t periodic_capable;
uint64_t size_capable;
uint64_t value_set;
uint64_t reserved1;
uint64_t timer_32bit;
uint64_t ioapic_route;
uint64_t fsb_int_enable;
uint64_t fsb_int_delivery;
uint64_t reserved2;
uint64_t route_cap;
};
};
void hpet_write64(uint64_t offset, uint64_t value);
uint64_t hpet_read64(uint64_t offset);
#define HPET_GEN_CAP_ID_OFFSET 0x0
#define HPET_GEN_CONF_OFFSET 0x10
#define HPET_GEN_INT_STAT_OFFSET 0x20
#define HPET_IRQ_BASE 2
#define HPET_MAIN_COUNTER_OFFSET 0xF0
#define HPET_TIMER_CONF_OFFSET(num) (0x100 + (num * 0x20))
#define HPET_TIMER_COMPARATOR_OFFSET(num) (HPET_TIMER_CONF_OFFSET(num) + 0x8)
#define HPET_CURRENT (smp_core_id() % hpet_timer_count)
#define HPET_IRQ_LINE 2