summaryrefslogtreecommitdiff
path: root/include/task.h
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2020-11-02 12:11:11 -0700
committerCommit Bot <commit-bot@chromium.org>2020-11-08 19:31:12 +0000
commitc47740eca17a2fe652b7bb13f5b2949687884e79 (patch)
treee8efbfdac3fc0f01520e0997560f0095297d4b79 /include/task.h
parent25ae7edffcceb662d5d2ebe92d19bf6f191d8bd5 (diff)
downloadchrome-ec-c47740eca17a2fe652b7bb13f5b2949687884e79.tar.gz
Zephyr: add more compliant implementation for irq_(un)lock
This change replaces the stubbed irq_(un)lock static functions defined in task.h with new functions that behave more like the Zephyr implementation of irq_(un)lock functions. This should make the migration from interrupt_(dis|en)able to Zephyr more seamless. BRANCH=none BUG=b:172060699 TEST=Added unit tests, make runtests -j, and built for various boards: eve, volteer, arcada_ish, atlas, hatch, kohaku, nocturne, samus, and scarlet Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ia7ad2b8d7d411a11699353bf5d3cc36a261fad14 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2511720
Diffstat (limited to 'include/task.h')
-rw-r--r--include/task.h32
1 files changed, 23 insertions, 9 deletions
diff --git a/include/task.h b/include/task.h
index cf72e57680..680c753c62 100644
--- a/include/task.h
+++ b/include/task.h
@@ -85,15 +85,29 @@ void interrupt_enable(void);
* interrupt_disable() and interrupt_enable().
*/
#ifndef CONFIG_ZEPHYR
-__maybe_unused static inline uint32_t irq_lock(void)
-{
- interrupt_disable();
- return 0;
-}
-__maybe_unused static inline void irq_unlock(uint32_t key)
-{
- interrupt_enable();
-}
+/**
+ * Perform the same operation as interrupt_disable but allow nesting. The
+ * return value from this function should be used as the argument to
+ * irq_unlock. Do not attempt to parse the value, it is a representation
+ * of the state and not an indication of any form of count.
+ *
+ * For more information see:
+ * https://docs.zephyrproject.org/latest/reference/kernel/other/interrupts.html#c.irq_lock
+ *
+ * @return Lock key to use for restoring the state via irq_unlock.
+ */
+uint32_t irq_lock(void);
+
+/**
+ * Perform the same operation as interrupt_enable but allow nesting. The key
+ * should be the unchanged value returned by irq_lock.
+ *
+ * For more information see:
+ * https://docs.zephyrproject.org/latest/reference/kernel/other/interrupts.html#c.irq_unlock
+ *
+ * @param key The lock-out key used to restore the interrupt state.
+ */
+void irq_unlock(uint32_t key);
#endif /* CONFIG_ZEPHYR */
/**