summaryrefslogtreecommitdiff
path: root/include/task.h
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2020-10-29 12:11:43 -0600
committerCommit Bot <commit-bot@chromium.org>2020-10-30 01:13:37 +0000
commit28103bb44ee8652d9b8f6b9bce09f04cce89f1d0 (patch)
tree9b6e8d254d23ec56ac0e8de60be3398c56299bfa /include/task.h
parent26dee43c5eb0964f10e08f06d9266ea9210550b3 (diff)
downloadchrome-ec-28103bb44ee8652d9b8f6b9bce09f04cce89f1d0.tar.gz
Zephyr: add support for shimming the mutex struct
This changes creates a common mutex_t which can be used in both platform/ec and zephyr code. It also adds an empty #define for k_mutex_init(mutex) such that the zephyr function can be used without affecting platform/ec. BRANCH=none BUG=b:171896666 TEST=Built platform/ec for boards: volteer & eve Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I6a711252732697ab120515d916bf388fdcd9544f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2508414 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Diffstat (limited to 'include/task.h')
-rw-r--r--include/task.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/include/task.h b/include/task.h
index 365edbb5eb..2f7f2cc73d 100644
--- a/include/task.h
+++ b/include/task.h
@@ -325,11 +325,19 @@ int task_reset(task_id_t id, int wait);
*/
void task_clear_pending_irq(int irq);
+#ifdef CONFIG_ZEPHYR
+typedef struct k_mutex mutex_t;
+
+#define mutex_lock(mtx) (k_mutex_lock(mtx, K_FOREVER))
+#define mutex_unlock(mtx) (k_mutex_unlock(mtx))
+#else
struct mutex {
uint32_t lock;
uint32_t waiters;
};
+typedef struct mutex mutex_t;
+
/**
* Lock a mutex.
*
@@ -338,12 +346,16 @@ struct mutex {
*
* Must not be used in interrupt context!
*/
-void mutex_lock(struct mutex *mtx);
+void mutex_lock(mutex_t *mtx);
/**
* Release a mutex previously locked by the same task.
*/
-void mutex_unlock(struct mutex *mtx);
+void mutex_unlock(mutex_t *mtx);
+
+/** Zephyr will try to init the mutex using `k_mutex_init()`. */
+#define k_mutex_init(mutex) 0
+#endif /* CONFIG_ZEPHYR */
struct irq_priority {
uint8_t irq;