aboutsummaryrefslogtreecommitdiff
path: root/include/arch
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2026-01-24 22:34:12 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2026-01-24 22:34:12 +0200
commit1eaac15cdb220df7536c74774a1ce7d1f0519c63 (patch)
tree71f23ded40498e429a37bc64c48aa0d8eb5b0802 /include/arch
parent9d735045e0b73b46443f9dacd1b42f5ac3e734de (diff)
downloadkmi-1eaac15cdb220df7536c74774a1ce7d1f0519c63.tar.gz
kmi-1eaac15cdb220df7536c74774a1ce7d1f0519c63.zip
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.
Diffstat (limited to 'include/arch')
-rw-r--r--include/arch/timer.h13
1 files changed, 13 insertions, 0 deletions
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,6 +30,12 @@ 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?
@@ -37,6 +43,13 @@ ticks_t stat_timer(const void *fdt);
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.
*
* @return Current tick count.