boards: nsim: add initial support of normal/non-secure application
normal/non-secure application: nsim_sem_normal
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
diff --git a/boards/arc/nsim/arc_mpu_regions.c b/boards/arc/nsim/arc_mpu_regions.c
index 0f98c80..15e17f8 100644
--- a/boards/arc/nsim/arc_mpu_regions.c
+++ b/boards/arc/nsim/arc_mpu_regions.c
@@ -9,6 +9,10 @@
#include <arch/arc/v2/mpu/arc_mpu.h>
#include <linker/linker-defs.h>
+/*
+ * for secure firmware, MPU entries are only set up for secure world.
+ * All regions not listed here are shared by secure world and normal world.
+ */
static struct arc_mpu_region mpu_regions[] = {
#if DT_ICCM_SIZE > 0
/* Region ICCM */
@@ -24,11 +28,19 @@
DT_DCCM_SIZE * 1024,
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
#endif
+
+/*
+ * Region peripheral is shared by secure world and normal world by default,
+ * no need a static mpu entry. If some peripherals belong to secure world,
+ * add it here.
+ */
+#ifndef CONFIG_ARC_SECURE_FIRMWARE
/* Region Peripheral */
MPU_REGION_ENTRY("PERIPHERAL",
0xF0000000,
64 * 1024,
REGION_KERNEL_RAM_ATTR),
+#endif
};
struct arc_mpu_config mpu_config = {
diff --git a/boards/arc/nsim/nsim_sem.dts b/boards/arc/nsim/nsim_sem.dts
index f023c9e..61358c9 100644
--- a/boards/arc/nsim/nsim_sem.dts
+++ b/boards/arc/nsim/nsim_sem.dts
@@ -1,18 +1,32 @@
/*
- * Copyright (c) 2018, 2019, Synopsys, Inc. All rights reserved.
+ * Copyright (c) 2018, Synopsys, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
+
/dts-v1/;
#include "nsim_em.dtsi"
/ {
- model = "snps,nsim_sem";
- compatible = "snps,nsim_sem";
-};
-&cpu0 {
- clock-frequency = <5000000>;
+ model = "nsim_sem";
+ compatible = "snps,nsim_sem";
+
+ iccm0: iccm@0 {
+ device_type = "memory";
+ compatible = "arc,iccm";
+ reg = <0x0 0x40000>;
+ };
+
+ dccm0: dccm@80000000 {
+ device_type = "memory";
+ compatible = "arc,dccm";
+ reg = <0x80000000 0x40000>;
+ };
+
+ chosen {
+ zephyr,sram = &dccm0;
+ };
};
diff --git a/boards/arc/nsim/nsim_sem_defconfig b/boards/arc/nsim/nsim_sem_defconfig
index 5718c8b..b2a721f 100644
--- a/boards/arc/nsim/nsim_sem_defconfig
+++ b/boards/arc/nsim/nsim_sem_defconfig
@@ -16,3 +16,4 @@
CONFIG_UART_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_ARC_EXCEPTION_DEBUG=y
+CONFIG_TRUSTED_EXECUTION_SECURE=y
diff --git a/boards/arc/nsim/nsim_sem_mpu_stack_guard_defconfig b/boards/arc/nsim/nsim_sem_mpu_stack_guard_defconfig
index 78e027d..d2a02a2 100644
--- a/boards/arc/nsim/nsim_sem_mpu_stack_guard_defconfig
+++ b/boards/arc/nsim/nsim_sem_mpu_stack_guard_defconfig
@@ -17,3 +17,4 @@
CONFIG_UART_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_ARC_EXCEPTION_DEBUG=y
+CONFIG_TRUSTED_EXECUTION_SECURE=y
\ No newline at end of file
diff --git a/boards/arc/nsim/nsim_sem_normal.dts b/boards/arc/nsim/nsim_sem_normal.dts
new file mode 100644
index 0000000..8e8cffc
--- /dev/null
+++ b/boards/arc/nsim/nsim_sem_normal.dts
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2018, Synopsys, Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/dts-v1/;
+
+#include <mem.h>
+#include "nsim_em.dtsi"
+
+/ {
+
+ model = "nsim_sem_normal";
+ compatible = "snps,nsim_sem_normal";
+
+ iccm0: iccm@0 {
+ device_type = "memory";
+ compatible = "arc,iccm";
+ reg = <0x40000 DT_SIZE_K(256)>;
+ };
+
+ dccm0: dccm@80000000 {
+ device_type = "memory";
+ compatible = "arc,dccm";
+ reg = <0x80040000 DT_SIZE_K(256)>;
+ };
+
+ chosen {
+ zephyr,sram = &dccm0;
+ };
+
+};
diff --git a/boards/arc/nsim/nsim_sem_normal.yaml b/boards/arc/nsim/nsim_sem_normal.yaml
new file mode 100644
index 0000000..c940a46
--- /dev/null
+++ b/boards/arc/nsim/nsim_sem_normal.yaml
@@ -0,0 +1,11 @@
+identifier: nsim_sem_normal
+name: SEM in normal mode of Nsim simulator
+type: mcu
+arch: arc
+simulation: nsim
+toolchain:
+ - zephyr
+testing:
+ ignore_tags:
+ - net
+ - bluetooth
diff --git a/boards/arc/nsim/nsim_sem_normal_defconfig b/boards/arc/nsim/nsim_sem_normal_defconfig
new file mode 100644
index 0000000..0d3578f
--- /dev/null
+++ b/boards/arc/nsim/nsim_sem_normal_defconfig
@@ -0,0 +1,16 @@
+CONFIG_ARC=y
+CONFIG_CPU_ARCEM=y
+CONFIG_SOC_NSIM=y
+CONFIG_SOC_NSIM_SEM=y
+CONFIG_BOARD_NSIM=y
+CONFIG_SYS_CLOCK_TICKS_PER_SEC=100
+CONFIG_XIP=n
+CONFIG_BUILD_OUTPUT_BIN=n
+CONFIG_PRINTK=y
+CONFIG_ARCV2_INTERRUPT_UNIT=y
+CONFIG_ARCV2_TIMER=y
+CONFIG_CONSOLE=y
+CONFIG_UART_CONSOLE=y
+CONFIG_SERIAL=y
+CONFIG_ARC_EXCEPTION_DEBUG=y
+CONFIG_TRUSTED_EXECUTION_NONSECURE=y
diff --git a/soc/arc/snps_nsim/Kconfig.defconfig.em b/soc/arc/snps_nsim/Kconfig.defconfig.em
index dc50572..ba19eeb 100644
--- a/soc/arc/snps_nsim/Kconfig.defconfig.em
+++ b/soc/arc/snps_nsim/Kconfig.defconfig.em
@@ -16,7 +16,7 @@
config NUM_IRQS
# must be > the highest interrupt number used
- default 20
+ default 30
config ARC_MPU_VER
default 2
diff --git a/soc/arc/snps_nsim/Kconfig.defconfig.sem b/soc/arc/snps_nsim/Kconfig.defconfig.sem
index b605ff9..f832dba 100644
--- a/soc/arc/snps_nsim/Kconfig.defconfig.sem
+++ b/soc/arc/snps_nsim/Kconfig.defconfig.sem
@@ -16,7 +16,7 @@
config NUM_IRQS
# must be > the highest interrupt number used
- default 22
+ default 30
config ARC_MPU_VER
default 3