summaryrefslogtreecommitdiff
path: root/zephyr/linker
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-02-11 14:38:59 -0700
committerCommit Bot <commit-bot@chromium.org>2021-02-13 00:29:22 +0000
commitab1d9102b8a7f57f63e4ed21a08113f4e4cba6be (patch)
tree54290c2d0ba3cd7176b92e65bd99e0cc6e71562d /zephyr/linker
parentc56806bb8d262f003b92134fdc8987ac51f6824e (diff)
downloadchrome-ec-ab1d9102b8a7f57f63e4ed21a08113f4e4cba6be.tar.gz
zephyr: Add support for CONFIG_MPU
Add this option so that the Memory-Protection Unit (MPU) can be enabled. The implementation is still to be worked out. Note that CONFIG_PLATFORM_EC_EXTERNAL_STORAGE is not defined, as it should be. That work is ongoing elsewhere. BUG=b:180039888 BRANCH=none TEST=build zephyr volteer Build ECOS for volteer Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: Ie26e8ba4b3f0b8024930e42fbbb03f0f2a26f3da Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2691566 Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr/linker')
-rw-r--r--zephyr/linker/CMakeLists.txt3
-rw-r--r--zephyr/linker/iram_text.ld23
2 files changed, 26 insertions, 0 deletions
diff --git a/zephyr/linker/CMakeLists.txt b/zephyr/linker/CMakeLists.txt
index 4d8b26f631..3aa22c98e2 100644
--- a/zephyr/linker/CMakeLists.txt
+++ b/zephyr/linker/CMakeLists.txt
@@ -4,3 +4,6 @@
# Add the fixed sections to the output image.
zephyr_linker_sources(ROM_START SORT_KEY 1 fixed-sections.ld)
+
+# Support protection of part of the internal RAM
+zephyr_linker_sources(RWDATA SORT_KEY 1 iram_text.ld)
diff --git a/zephyr/linker/iram_text.ld b/zephyr/linker/iram_text.ld
new file mode 100644
index 0000000000..3ea3f4db7e
--- /dev/null
+++ b/zephyr/linker/iram_text.ld
@@ -0,0 +1,23 @@
+/* Copyright 2021 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 CONFIG_ARCH_POSIX
+
+/* This code taken from core/cortex-m/ec.lds.S */
+
+#if defined(CONFIG_PLATFORM_EC_MPU)
+/* MPU regions must be aligned to a 32-byte boundary */
+#define _IRAM_ALIGN 32
+#else
+#define _IRAM_ALIGN 4
+#endif
+
+ . = ALIGN(_IRAM_ALIGN);
+ __iram_text_start = .;
+ *(.iram.text)
+ . = ALIGN(_IRAM_ALIGN);
+ __iram_text_end = .;
+
+#endif /* CONFIG_ARCH_POSIX */