aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-12-04 00:20:36 -0700
committerJosh Rahm <joshuarahm@gmail.com>2024-12-04 00:20:36 -0700
commitd6d04862de9126d0930ae1f4b95ff6077c6eda63 (patch)
treee5266c4017d41b1e77be8bbefa8abafb90fa1504 /include
parent47885d62b689bececb58b7bf9479a5c1ff1c9b5c (diff)
downloadch573-d6d04862de9126d0930ae1f4b95ff6077c6eda63.tar.gz
ch573-d6d04862de9126d0930ae1f4b95ff6077c6eda63.tar.bz2
ch573-d6d04862de9126d0930ae1f4b95ff6077c6eda63.zip
Basic interrupts are working.
Diffstat (limited to 'include')
-rw-r--r--include/isr_vector.h16
-rw-r--r--include/systick.h9
2 files changed, 25 insertions, 0 deletions
diff --git a/include/isr_vector.h b/include/isr_vector.h
index 6059875..3d4070a 100644
--- a/include/isr_vector.h
+++ b/include/isr_vector.h
@@ -51,3 +51,19 @@ void irq_on_wdog_bat(void);
_real__irq_on_##name(); \
} \
static void __attribute__((noinline)) _real__irq_on_##name(void)
+
+inline static void enable_interrupts()
+{
+ int mstatus;
+ asm volatile ("csrr %0, mstatus" : "=r"(mstatus));
+ mstatus |= 0x88;
+ asm volatile ("csrw mstatus, %0" : : "r"(mstatus));
+}
+
+inline static void disable_interrupts()
+{
+ int mstatus;
+ asm volatile ("csrr %0, mstatus" : "=r"(mstatus));
+ mstatus &= ~0x88;
+ asm volatile ("csrw mstatus, %0" : : "r"(mstatus));
+}
diff --git a/include/systick.h b/include/systick.h
new file mode 100644
index 0000000..8933a31
--- /dev/null
+++ b/include/systick.h
@@ -0,0 +1,9 @@
+#pragma once
+
+#include <stdint.h>
+
+void set_systick(uint64_t systick_value);
+
+uint64_t get_systick();
+
+int systick_interrupt();