From 1eaac15cdb220df7536c74774a1ce7d1f0519c63 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sat, 24 Jan 2026 22:34:12 +0200 Subject: improve timer handling + Previous code assumed a timer would only trigger when requested, but didn't explicitly disable timers during init. Newer versions of qemu (>= 10?) seem to have some kind of timer set, unsure if that's via OpenSBI or what exactly but some slower tests were failing because of it. --- include/arch/timer.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include') diff --git a/include/arch/timer.h b/include/arch/timer.h index 8b832c9..8f235e6 100644 --- a/include/arch/timer.h +++ b/include/arch/timer.h @@ -30,12 +30,25 @@ ticks_t stat_timer(const void *fdt); /** * Set up timer interrupt for absolute ticks. + * At least currently assumes there is only one global timer, the kernel will + * ensure that the timer is scheduled to handle events in order. + * + * When setting a new timer, the current timer (if one is set) will + * not trigger an interrupt. For instance, if called from the interrupt handler + * of the existing interrupt, it won't re-trigger. * * @param ticks Time point for timer to trigger. * \todo Should maybe be stat_t? */ void set_timer(ticks_t ticks); +/** + * Stop the timer interrupts from happening altogether. Mainly called during + * init to avoid spurious interrupts and when all userspace timers have been + * handled. + */ +void clear_timer(); + /** * Get current ticks. * -- cgit v1.3