From ef232f34d0759917d612fa06aac53cebd5786f26 Mon Sep 17 00:00:00 2001 From: Ryan McClelland Date: Sun, 9 Feb 2025 13:31:08 -0800 Subject: [PATCH] arch: arm: fix compile issue if MEM_ATTR=n and ARM_MPU=y It's possible to have MEM_ATTR=n and ARM_MPU=y. This fixes the compile issue with it by compiling out the calls to define the DT mpu regions. Signed-off-by: Ryan McClelland --- arch/arm/core/mpu/arm_mpu.c | 8 ++++---- arch/arm/core/mpu/nxp_mpu.c | 8 ++++---- arch/arm64/core/cortex_r/arm_mpu.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/arm/core/mpu/arm_mpu.c b/arch/arm/core/mpu/arm_mpu.c index bec7b18a4f2..e66c02ec067 100644 --- a/arch/arm/core/mpu/arm_mpu.c +++ b/arch/arm/core/mpu/arm_mpu.c @@ -93,7 +93,7 @@ static int region_allocate_and_init(const uint8_t index, (reg).dt_addr, \ (reg).dt_size, \ _ATTR) - +#ifdef CONFIG_MEM_ATTR /* This internal function programs the MPU regions defined in the DT when using * the `zephyr,memory-attr = <( DT_MEM_ARM(...) )>` property. */ @@ -158,7 +158,7 @@ static int mpu_configure_regions_from_dt(uint8_t *reg_index) return 0; } - +#endif /* CONFIG_MEM_ATTR */ /* This internal function programs an MPU region * of a given configuration at a given MPU index. */ @@ -459,13 +459,13 @@ int z_arm_mpu_init(void) /* Update the number of programmed MPU regions. */ static_regions_num = mpu_config.num_regions; - +#ifdef CONFIG_MEM_ATTR /* DT-defined MPU regions. */ if (mpu_configure_regions_from_dt(&static_regions_num) == -EINVAL) { __ASSERT(0, "Failed to allocate MPU regions from DT\n"); return -EINVAL; } - +#endif /* CONFIG_MEM_ATTR */ /* Clear all regions before enabling MPU */ for (int i = static_regions_num; i < get_num_regions(); i++) { mpu_clear_region(i); diff --git a/arch/arm/core/mpu/nxp_mpu.c b/arch/arm/core/mpu/nxp_mpu.c index b0fe24c6bf6..ae893086901 100644 --- a/arch/arm/core/mpu/nxp_mpu.c +++ b/arch/arm/core/mpu/nxp_mpu.c @@ -151,7 +151,7 @@ static int region_allocate_and_init(const uint8_t index, .end = (reg).dt_addr + (reg).dt_size, \ .attr = _ATTR, \ } - +#ifdef CONFIG_MEM_ATTR /* This internal function programs the MPU regions defined in the DT when using * the `zephyr,memory-attr = <( DT_MEM_ARM(...) )>` property. */ @@ -198,7 +198,7 @@ static int mpu_configure_regions_from_dt(uint8_t *reg_index) return 0; } - +#endif /* CONFIG_MEM_ATTR */ /** * This internal function is utilized by the MPU driver to combine a given * region attribute configuration and size and fill-in a driver-specific @@ -700,13 +700,13 @@ int z_arm_mpu_init(void) /* Update the number of programmed MPU regions. */ static_regions_num = mpu_config.num_regions; - +#ifdef CONFIG_MEM_ATTR /* DT-defined MPU regions. */ if (mpu_configure_regions_from_dt(&static_regions_num) == -EINVAL) { __ASSERT(0, "Failed to allocate MPU regions from DT\n"); return -EINVAL; } - +#endif /* CONFIG_MEM_ATTR */ arm_core_mpu_enable(); return 0; diff --git a/arch/arm64/core/cortex_r/arm_mpu.c b/arch/arm64/core/cortex_r/arm_mpu.c index 2bd6d265c9a..3053d90cb75 100644 --- a/arch/arm64/core/cortex_r/arm_mpu.c +++ b/arch/arm64/core/cortex_r/arm_mpu.c @@ -196,7 +196,7 @@ static ALWAYS_INLINE void region_init(const uint32_t index, .limit = (reg).dt_addr + (reg).dt_size, \ .attr = _ATTR, \ } - +#ifdef CONFIG_MEM_ATTR /* This internal function programs the MPU regions defined in the DT when using * the `zephyr,memory-attr = <( DT_MEM_ARM(...) )>` property. */ @@ -247,7 +247,7 @@ static int mpu_configure_regions_from_dt(uint8_t *reg_index) return 0; } - +#endif /* CONFIG_MEM_ATTR */ /* * @brief MPU default configuration * @@ -303,13 +303,13 @@ FUNC_NO_STACK_PROTECTOR void z_arm64_mm_init(bool is_primary_core) /* Update the number of programmed MPU regions. */ tmp_static_num = mpu_config.num_regions; - +#ifdef CONFIG_MEM_ATTR /* DT-defined MPU regions. */ if (mpu_configure_regions_from_dt(&tmp_static_num) == -EINVAL) { __ASSERT(0, "Failed to allocate MPU regions from DT\n"); return; } - +#endif arm_core_mpu_enable(); if (!is_primary_core) {