summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2015-08-07 17:01:58 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-08-11 00:06:18 +0000
commit9968fb396639e7412cdb20aae4db2c31c4439490 (patch)
tree46f3a00878fbb9f0cfa86774d96de96b498bebf2
parent2911e38022a950d9f0e85ed7480829bf21d34a1f (diff)
downloadchrome-ec-9968fb396639e7412cdb20aae4db2c31c4439490.tar.gz
cortex-m: catch misconfigured interrupts early
The code in core/cortex-m/init.S limits the number of installed vectors to CONFIG_IRQ_COUNT. But the DECLARE_IRQ macro installing interrupt servicing routines does not care about this limitation. This results in corrupted interrupt configuration, which is hard to debug. This patch makes sure that there is a compilation error in case DECLARE_IRQ is passed interrupt number which out of bounds. A similar change needs to be introduced for cortex-m0. BRANCH=none BUG=chromium:518898 TEST=tried building cr50 with one of interrupt numbers exceeding CONFIG_IRQ_COUNT, observed a compilation error. Change-Id: Ie7bc623da6bf7371579b2242064f81a83053df17 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/291843 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--core/cortex-m/irq_handler.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/core/cortex-m/irq_handler.h b/core/cortex-m/irq_handler.h
index 0d659b0610..c309b48102 100644
--- a/core/cortex-m/irq_handler.h
+++ b/core/cortex-m/irq_handler.h
@@ -24,6 +24,9 @@
#define DECLARE_IRQ(irq, routine, priority) DECLARE_IRQ_(irq, routine, priority)
#define DECLARE_IRQ_(irq, routine, priority) \
void IRQ_HANDLER(irq)(void) __attribute__((naked)); \
+ typedef struct { \
+ int dummy[irq >= CONFIG_IRQ_COUNT ? -1 : 1]; \
+ } irq_num_check_##irq; \
void __keep routine(void); \
void IRQ_HANDLER(irq)(void) \
{ \