summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2020-09-23 08:16:57 -0600
committerCommit Bot <commit-bot@chromium.org>2020-10-01 19:14:29 +0000
commit1434fa7a1d5fed910c86f479aab75fee6521bb5d (patch)
tree519d7c8a9fb7d4b64b0a65db3c364a1aae7816ca
parent47548f0f7b4ad89cdeef0cb48f3adbea9d92d570 (diff)
downloadchrome-ec-1434fa7a1d5fed910c86f479aab75fee6521bb5d.tar.gz
zephyr: implement atomic.h
This implements a compatibility layer with the deprecated_* atomic operations using Zephyr's APIs. BUG=b:169151160 BRANCH=none TEST=compile timer.c in follow-up CL Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I49fa1afc28790ab14a91d472141a01e2370b24ac Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427096 Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r--zephyr/shim/include/atomic.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/zephyr/shim/include/atomic.h b/zephyr/shim/include/atomic.h
new file mode 100644
index 0000000000..249b5d0bd9
--- /dev/null
+++ b/zephyr/shim/include/atomic.h
@@ -0,0 +1,45 @@
+/* Copyright 2020 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.
+ */
+
+#ifndef __CROS_EC_ATOMIC_H
+#define __CROS_EC_ATOMIC_H
+
+#include <sys/atomic.h>
+
+/*
+ * Below EC APIs are being deprecated and replaced with the Zephyr
+ * APIs. We already get the Zephyr APIs from sys/atomic.h. The
+ * definitions here are provided so we can shim-in modules using the
+ * deprecated APIs while the transition is under way.
+ */
+static inline void deprecated_atomic_clear(uint32_t volatile *addr,
+ uint32_t bits)
+{
+ atomic_and((atomic_t *)addr, bits);
+}
+
+static inline void deprecated_atomic_or(uint32_t volatile *addr, uint32_t bits)
+{
+ atomic_or((atomic_t *)addr, bits);
+}
+
+static inline void deprecated_atomic_add(uint32_t volatile *addr,
+ uint32_t value)
+{
+ atomic_add((atomic_t *)addr, value);
+}
+
+static inline void deprecated_atomic_sub(uint32_t volatile *addr,
+ uint32_t value)
+{
+ atomic_sub((atomic_t *)addr, value);
+}
+
+static inline uint32_t deprecated_atomic_read_clear(uint32_t volatile *addr)
+{
+ return atomic_clear((atomic_t *)addr);
+}
+
+#endif /* __CROS_EC_ATOMIC_H */