From f7165395b4a54d7a536b3584e66ddbf9e7f8fadf Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Fri, 16 Feb 2024 12:30:18 -0800 Subject: [PATCH] xtensa: mpu: introduce CONFIG_XTENSA_MPU_ONLY_SOC_RANGES This allows the SoC to have total control on what MPU ranges to be programmed at boot. This overrides the generic ranges in the architecture core code. Signed-off-by: Daniel Leung --- arch/xtensa/Kconfig | 8 ++++++++ arch/xtensa/core/mpu.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 4d813498d9..8aa3d0fa96 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -243,6 +243,14 @@ config XTENSA_MPU_DEFAULT_MEM_TYPE If userspace is enabled, it will be used to restore the memory type of the region being removed from a memory domain. +config XTENSA_MPU_ONLY_SOC_RANGES + bool + help + Enable this by the SoC to indicate to the architecture code to use + the MPU ranges specified by SoC only, and skip the common ranges + defined in the core architecture code. This gives total control to + the SoC on the MPU ranges. + endif # XTENSA_MPU endif # CPU_HAS_MPU diff --git a/arch/xtensa/core/mpu.c b/arch/xtensa/core/mpu.c index 4efcf33d4b..29e3362977 100644 --- a/arch/xtensa/core/mpu.c +++ b/arch/xtensa/core/mpu.c @@ -72,6 +72,7 @@ static struct xtensa_mpu_map xtensa_mpu_map_fg_kernel; * definied in the processor configuration. */ +#ifndef CONFIG_XTENSA_MPU_ONLY_SOC_RANGES /** * Static definition of all code and data memory regions of the * current Zephyr image. This information must be available and @@ -129,6 +130,7 @@ static const struct xtensa_mpu_range mpu_zephyr_ranges[] = { .memory_type = CONFIG_XTENSA_MPU_DEFAULT_MEM_TYPE, }, }; +#endif /* !CONFIG_XTENSA_MPU_ONLY_SOC_RANGES */ /** * Return the pointer to the entry encompassing @a addr out of an array of MPU entries. @@ -679,6 +681,7 @@ void xtensa_mpu_init(void) xtensa_mpu_map_fg_kernel.entries[entry] = ent; } +#ifndef CONFIG_XTENSA_MPU_ONLY_SOC_RANGES /* * Add necessary MPU entries for the memory regions of base Zephyr image. */ @@ -696,6 +699,7 @@ void xtensa_mpu_init(void) (unsigned int)range->end, ret); } +#endif /* !CONFIG_XTENSA_MPU_ONLY_SOC_RANGES */ /* * Now for the entries for memory regions needed by SoC.