summaryrefslogtreecommitdiff
path: root/zephyr/shim/core
diff options
context:
space:
mode:
authorFabio Baltieri <fabiobaltieri@google.com>2021-06-14 16:44:22 +0000
committerCommit Bot <commit-bot@chromium.org>2021-06-14 21:37:51 +0000
commit2c58e541897163dcb879a3755884d193fb0011a9 (patch)
tree4fc7434dad1e7a4ee19e524158bd82445fda71b3 /zephyr/shim/core
parent9efe07cf273a1bbe9bde1854a2884809d3c11be7 (diff)
downloadchrome-ec-2c58e541897163dcb879a3755884d193fb0011a9.tar.gz
zephyr: shim: move mpu code under core/cortex-m
The MPU code is cortex-m specific, so move it out of shim/src and into shim/core/cortex-m. BRANCH=none BUG=b:180039888 TEST=build & run on volteer Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ic77d6f58751822e3dad461f9236f5b43da764164 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2961189 Reviewed-by: Yuval Peress <peress@chromium.org>
Diffstat (limited to 'zephyr/shim/core')
-rw-r--r--zephyr/shim/core/cortex-m/CMakeLists.txt1
-rw-r--r--zephyr/shim/core/cortex-m/mpu.c36
2 files changed, 37 insertions, 0 deletions
diff --git a/zephyr/shim/core/cortex-m/CMakeLists.txt b/zephyr/shim/core/cortex-m/CMakeLists.txt
index 2481b49efe..ca5fd0f04c 100644
--- a/zephyr/shim/core/cortex-m/CMakeLists.txt
+++ b/zephyr/shim/core/cortex-m/CMakeLists.txt
@@ -3,3 +3,4 @@
# found in the LICENSE file.
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_SOFTWARE_PANIC software_panic.c)
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MPU mpu.c)
diff --git a/zephyr/shim/core/cortex-m/mpu.c b/zephyr/shim/core/cortex-m/mpu.c
new file mode 100644
index 0000000000..64e5a93db0
--- /dev/null
+++ b/zephyr/shim/core/cortex-m/mpu.c
@@ -0,0 +1,36 @@
+/* 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.
+ */
+
+#include "config.h"
+#include "mpu.h"
+#include "logging/log.h"
+#include <arch/arm/aarch32/cortex_m/cmsis.h>
+
+LOG_MODULE_REGISTER(shim_mpu, LOG_LEVEL_ERR);
+
+void mpu_enable(void)
+{
+ for (int index = 0; index < mpu_config.num_regions; index++) {
+ MPU->RNR = index;
+ MPU->RASR |= MPU_RASR_ENABLE_Msk;
+ LOG_DBG("[%d] %08x %08x", index, MPU->RBAR, MPU->RASR);
+ }
+}
+
+static int mpu_disable_fixed_regions(const struct device *dev)
+{
+ /* MPU is configured and enabled by the Zephyr init code, disable the
+ * fixed sections by default.
+ */
+ for (int index = 0; index < mpu_config.num_regions; index++) {
+ MPU->RNR = index;
+ MPU->RASR &= ~MPU_RASR_ENABLE_Msk;
+ LOG_DBG("[%d] %08x %08x", index, MPU->RBAR, MPU->RASR);
+ }
+
+ return 0;
+}
+
+SYS_INIT(mpu_disable_fixed_regions, PRE_KERNEL_1, 50);