/* timer.h — ARM Generic Timer for Raspberry Pi 5 */ #ifndef TIMER_H #define TIMER_H #include /* Timer frequency (read from CNTFRQ_EL0, typically 54MHz on Pi 5) */ static inline uint64_t timer_get_freq(void) { uint64_t freq; __asm__ volatile("mrs %0, cntfrq_el0" : "=r"(freq)); return freq; } /* Current counter value */ static inline uint64_t timer_get_count(void) { uint64_t count; __asm__ volatile("mrs %0, cntpct_el0" : "=r"(count)); return count; } /* Initialize timer for periodic tick (100 Hz) */ void timer_init(void); /* Timer IRQ handler — called from vectors.S */ void timer_irq(void); /* Get tick count */ uint64_t timer_ticks(void); #endif /* TIMER_H */