summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2020-10-01 15:52:04 -0600
committerCommit Bot <commit-bot@chromium.org>2020-10-12 23:13:49 +0000
commitb63257f8641c9f3c9497ee2847ac68032dc6b707 (patch)
treec064b5b9b6d1468cbf59f2febb54b01740dfb380
parent9dfd286309e0b43a905bf77a56923d29027f505b (diff)
downloadchrome-ec-b63257f8641c9f3c9497ee2847ac68032dc6b707.tar.gz
zephyr: add strtoi shim function
When I compile volteer, I only need one stdlib style function and it is something we made ourselves. There is a long verion in Zephyr and long and int are the same size for 32-bit MCUs so we just need to forward the implementation. Also remove compilation of our existing platform/ec util file since Zephyr already provides these basic stdlib like functions. BRANCH=none BUG=b:169935794 TEST=Run Zephyr image on Volteer using this function. TEST=Build and run posix-ec target as well Change-Id: Idb4ea4d5e0a6ad3da8ddc5781e16aeb6e666d85f Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2444371 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--include/task.h4
-rw-r--r--zephyr/CMakeLists.txt1
-rw-r--r--zephyr/shim/src/CMakeLists.txt1
-rw-r--r--zephyr/shim/src/util.c14
4 files changed, 18 insertions, 2 deletions
diff --git a/include/task.h b/include/task.h
index 0b244a2a18..365edbb5eb 100644
--- a/include/task.h
+++ b/include/task.h
@@ -371,6 +371,7 @@ struct irq_def {
* Implement the DECLARE_IRQ(irq, routine, priority) macro which is
* a core specific helper macro to declare an interrupt handler "routine".
*/
+#ifndef CONFIG_ZEPHYR
#ifdef CONFIG_COMMON_RUNTIME
#include "irq_handler.h"
#else
@@ -383,6 +384,7 @@ struct irq_def {
/* Include ec.irqlist here for compilation dependency */
#define ENABLE_IRQ(x)
#include "ec.irqlist"
-#endif
+#endif /* CONFIG_COMMON_RUNTIME */
+#endif /* !CONFIG_ZEPHYR */
#endif /* __CROS_EC_TASK_H */
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt
index e7c9d322f2..2569d832c4 100644
--- a/zephyr/CMakeLists.txt
+++ b/zephyr/CMakeLists.txt
@@ -35,5 +35,4 @@ zephyr_include_directories_ifdef(
add_subdirectory_ifdef(CONFIG_PLATFORM_EC "shim/src")
# Shimmed modules
-zephyr_sources_ifdef(CONFIG_PLATFORM_EC "${PLATFORM_EC}/common/util.c")
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_TIMER "${PLATFORM_EC}/common/timer.c")
diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt
index 5f8eaf88ad..f87b114949 100644
--- a/zephyr/shim/src/CMakeLists.txt
+++ b/zephyr/shim/src/CMakeLists.txt
@@ -3,4 +3,5 @@
# found in the LICENSE file.
zephyr_sources(console.c)
+zephyr_sources(util.c)
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_TIMER hwtimer.c)
diff --git a/zephyr/shim/src/util.c b/zephyr/shim/src/util.c
new file mode 100644
index 0000000000..998a0db01d
--- /dev/null
+++ b/zephyr/shim/src/util.c
@@ -0,0 +1,14 @@
+/* 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.
+ */
+
+#include <common.h>
+#include <stdlib.h>
+
+/* Int and Long are same size, just forward to existing Long implementation */
+int strtoi(const char *nptr, char **endptr, int base)
+{
+ return strtol(nptr, endptr, base);
+}
+BUILD_ASSERT(sizeof(int) == sizeof(long));