summaryrefslogtreecommitdiff
path: root/core/host/irq_handler.h
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2014-03-06 16:02:58 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-03-11 05:52:37 +0000
commit7aab81edce830e15134b52256ad3186e08951b10 (patch)
treee6197b4cc038172426b046153fc512ddefb019e8 /core/host/irq_handler.h
parent0e3ff013cc7814705137d373218ea7bfa0f94c2c (diff)
downloadchrome-ec-7aab81edce830e15134b52256ad3186e08951b10.tar.gz
force the compiler to use a valid register allocation for irq handlers
When we are calling the re-scheduling routine at the end of an irq handling routine, we need to ensure that the high registers are not currently saved on the system stack. On Cortex-M3/M4, the compiler is normally doing tail-call optimization there and behaving properly, but this fixes the fact that insanely large interrupt handling routines where sometimes not compile and not running properly (aka issue 24515). This also prepares for one more core-specific DECLARE_IRQ routine on Cortex-M0. Note: now on, the IRQ handling routines should no longer be "static". Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:24515 TEST=make -j buildall revert the workaround for 24515, see the issue happening only without this CL. Change-Id: Ic419369231925568df05815fd079ed191a5446db Reviewed-on: https://chromium-review.googlesource.com/189153 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'core/host/irq_handler.h')
-rw-r--r--core/host/irq_handler.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/core/host/irq_handler.h b/core/host/irq_handler.h
new file mode 100644
index 0000000000..d778ccf253
--- /dev/null
+++ b/core/host/irq_handler.h
@@ -0,0 +1,29 @@
+/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Helper to declare IRQ handling routines */
+
+#ifndef __IRQ_HANDLER_H
+#define __IRQ_HANDLER_H
+
+/* Helper macros to build the IRQ handler and priority struct names */
+#define IRQ_HANDLER(irqname) CONCAT3(irq_, irqname, _handler)
+#define IRQ_PRIORITY(irqname) CONCAT2(prio_, irqname)
+/*
+ * Macro to connect the interrupt handler "routine" to the irq number "irq" and
+ * ensure it is enabled in the interrupt controller with the right priority.
+ */
+#define DECLARE_IRQ(irq, routine, priority) \
+ void IRQ_HANDLER(irq)(void) \
+ { \
+ void *ret = __builtin_return_address(0); \
+ task_start_irq_handler(ret); \
+ routine(); \
+ task_resched_if_needed(ret); \
+ } \
+ const struct irq_priority IRQ_PRIORITY(irq) \
+ __attribute__((section(".rodata.irqprio"))) \
+ = {irq, priority}
+#endif /* __IRQ_HANDLER_H */