summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-02-15 23:48:41 -0700
committerCommit Bot <commit-bot@chromium.org>2021-02-18 01:10:46 +0000
commitc8090e9f301c5a5313327f869f30db5dd26f7750 (patch)
treee51e1c01c97e83500884690cb19f650fb0da7ca6
parentb9588a7499d15e4539720ec87624351a68011337 (diff)
downloadchrome-ec-c8090e9f301c5a5313327f869f30db5dd26f7750.tar.gz
zephyr: implement cortex-m's interrupt_disable()
Add implementation in lieu of Zephyr APIs. Zephyr's support for irq_disable() doesn't disable all interrupts (see Zephyr's include/arch/arm/aarch32/asm_inline_gcc.h for more information). The implementation is done via a #define inside the system.c file, this is done on purpose to avoid leaking the interrupt_disable() functionality outside of sysjump. All other uses of disabling interrupts should be done via irq_lock(). BRANCH=none BUG=b:174481378 TEST=build/flash volteer, run sysjump command Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Idccb93211296f81796ce4ba200c62adc5c19e691 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2695959
-rw-r--r--common/system.c14
-rw-r--r--zephyr/shim/src/tasks.c9
2 files changed, 13 insertions, 10 deletions
diff --git a/common/system.c b/common/system.c
index 76561f786f..a8b9961b74 100644
--- a/common/system.c
+++ b/common/system.c
@@ -46,6 +46,18 @@
/* Round up to a multiple of 4 */
#define ROUNDUP4(x) (((x) + 3) & ~3)
+#ifdef CONFIG_ZEPHYR
+#ifdef CONFIG_CPU_CORTEX_M
+/*
+ * For cortex-m we cannot use irq_lock() for disabling all the interrupts
+ * because it leaves some (NMI and faults) still enabled.
+ */
+#define interrupt_disable_all() __asm__("cpsid i")
+#endif
+#else /* !CONFIG_ZEPHYR */
+#define interrupt_disable_all() interrupt_disable()
+#endif /* CONFIG_ZEPHYR */
+
/* Data for an individual jump tag */
struct jump_tag {
uint16_t tag; /* Tag ID */
@@ -550,7 +562,7 @@ static void jump_to_image(uintptr_t init_addr)
hook_notify(HOOK_SYSJUMP);
/* Disable interrupts before jump */
- interrupt_disable();
+ interrupt_disable_all();
#ifdef CONFIG_DMA
/* Disable all DMA channels to avoid memory corruption */
diff --git a/zephyr/shim/src/tasks.c b/zephyr/shim/src/tasks.c
index b8406dd1e6..b4994d0140 100644
--- a/zephyr/shim/src/tasks.c
+++ b/zephyr/shim/src/tasks.c
@@ -229,12 +229,3 @@ int task_start_called(void)
{
return 1;
}
-
-void interrupt_disable(void)
-{
- /*
- * TODO (b:174481378) system.c needed an implementation of this. Though
- * it's not yet clear where we call interrupt_enable() from. These two
- * calls should be replaced with irq_lock and irq_unlock.
- */
-}