summaryrefslogtreecommitdiff
path: root/bsp/include/sifive/devices
diff options
context:
space:
mode:
authorPalmer Dabbelt <palmer@dabbelt.com>2018-06-29 16:14:00 -0700
committerPalmer Dabbelt <palmer@dabbelt.com>2018-06-29 16:15:05 -0700
commit66ba2aac4875e9131a630c29cea989551ac4cabd (patch)
tree2605f4e81388a0513e742829ad932a93be1935c2 /bsp/include/sifive/devices
parent20541dcc0b415199bd87410aa05b8302f18edaf5 (diff)
Add a CLIC interrupt example
This example is fairly simple, but it does at least demonstrate how to use a C-based preemptable interrupt handler that's been registered in CLIC mode on a SiFive E21.
Diffstat (limited to 'bsp/include/sifive/devices')
-rw-r--r--bsp/include/sifive/devices/clic.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/bsp/include/sifive/devices/clic.h b/bsp/include/sifive/devices/clic.h
new file mode 100644
index 0000000..b31e1ce
--- /dev/null
+++ b/bsp/include/sifive/devices/clic.h
@@ -0,0 +1,49 @@
+// See LICENSE for license details.
+
+#ifndef _SIFIVE_CLIC_H
+#define _SIFIVE_CLIC_H
+
+#define CLIC_CTRL_ADDR _AC(0x2000000,UL)
+
+#define CLIC_MSIP 0x0000
+#define CLIC_MSIP_size 0x4
+#define CLIC_MTIMECMP 0x4000
+#define CLIC_MTIMECMP_size 0x8
+#define CLIC_MTIME 0xBFF8
+#define CLIC_MTIME_size 0x8
+
+#define CLIC_INTIP 0x0800000
+#define CLIC_INTIE 0x0800400
+#define CLIC_INTCFG 0x0800800
+#define CLIC_CFG 0x0800c00
+
+// These interrupt IDs are consistent across old and new mtvec modes
+#define SSIPID 1
+#define MSIPID 3
+#define STIPID 5
+#define MTIPID 7
+#define SEIPID 9
+#define MEIPID 11
+#define CSIPID 12
+#define LOCALINTIDBASE 16
+
+#define CLIC_REG(offset) _REG32(CLIC_CTRL_ADDR, offset)
+#define CLIC_REG8(offset) (*(volatile uint8_t *)((CLIC_CTRL_ADDR) + (offset)))
+
+#ifndef CLINT_CTRL_ADDR
+#define CLINT_CTRL_ADDR CLIC_CTRL_ADDR
+#endif
+#ifndef CLINT_REG
+#define CLINT_REG CLIC_REG
+#endif
+#ifndef CLINT_MSIP
+#define CLINT_MSIP CLIC_MSIP
+#endif
+#ifndef CLINT_MTIME
+#define CLINT_MTIME CLIC_MTIME
+#endif
+#ifndef CLINT_MTIMECMP
+#define CLINT_MTIMECMP CLIC_MTIMECMP
+#endif
+
+#endif /* _SIFIVE_CLIC_H */