From 66ba2aac4875e9131a630c29cea989551ac4cabd Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Fri, 29 Jun 2018 16:14:00 -0700 Subject: 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. --- bsp/include/sifive/devices/clic.h | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 bsp/include/sifive/devices/clic.h (limited to 'bsp/include/sifive') 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 */ -- cgit v1.2.3