Skip to content

Commit ddcc5fb

Browse files
Julien Massotcarlescufi
authored andcommitted
arch: arm: aarch32: add ARMv8-R MPU support
ARMv8-R aarch32 processor has support for ARM PMSAv8-32. To add support for ARMv8-R we reuse the ARMv8-M effort and change access to the different registers such as rbar, rlar, mair, prselr. Signed-off-by: Julien Massot <[email protected]> Signed-off-by: Manuel Arguelles <[email protected]>
1 parent ff54de3 commit ddcc5fb

File tree

8 files changed

+383
-69
lines changed

8 files changed

+383
-69
lines changed

arch/arm/core/aarch32/mpu/Kconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ config ARM_MPU
1212
select THREAD_STACK_INFO
1313
select ARCH_HAS_EXECUTABLE_PAGE_BIT
1414
select MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT if !(CPU_HAS_NXP_MPU || ARMV8_M_BASELINE || ARMV8_M_MAINLINE)
15-
select MPU_REQUIRES_NON_OVERLAPPING_REGIONS if CPU_HAS_ARM_MPU && (ARMV8_M_BASELINE || ARMV8_M_MAINLINE)
15+
select MPU_REQUIRES_NON_OVERLAPPING_REGIONS if CPU_HAS_ARM_MPU && (ARMV8_M_BASELINE || ARMV8_M_MAINLINE || AARCH32_ARMV8_R)
16+
select MPU_GAP_FILLING if AARCH32_ARMV8_R
1617
help
1718
MCU implements Memory Protection Unit.
1819

@@ -46,6 +47,7 @@ config ARM_MPU
4647
config ARM_MPU_REGION_MIN_ALIGN_AND_SIZE
4748
int
4849
default 256 if ARM_MPU && ARMV6_M_ARMV8_M_BASELINE && !ARMV8_M_BASELINE
50+
default 64 if ARM_MPU && AARCH32_ARMV8_R
4951
default 32 if ARM_MPU
5052
default 4
5153
help

arch/arm/core/aarch32/mpu/arm_core_mpu.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ void z_arm_configure_static_mpu_regions(void)
155155
#endif /* CONFIG_MPU_REQUIRES_NON_OVERLAPPING_REGIONS */
156156
}
157157

158+
extern void arm_core_mpu_enable(void);
159+
extern void arm_core_mpu_disable(void);
158160
/**
159161
* @brief Use the HW-specific MPU driver to program
160162
* the dynamic MPU regions.
@@ -303,8 +305,14 @@ void z_arm_configure_dynamic_mpu_regions(struct k_thread *thread)
303305
#endif /* CONFIG_MPU_STACK_GUARD */
304306

305307
/* Configure the dynamic MPU regions */
308+
#ifdef CONFIG_AARCH32_ARMV8_R
309+
arm_core_mpu_disable();
310+
#endif
306311
arm_core_mpu_configure_dynamic_mpu_regions(dynamic_regions,
307312
region_num);
313+
#ifdef CONFIG_AARCH32_ARMV8_R
314+
arm_core_mpu_enable();
315+
#endif
308316
}
309317

310318
#if defined(CONFIG_USERSPACE)

arch/arm/core/aarch32/mpu/arm_mpu.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ static uint8_t static_regions_num;
4343
defined(CONFIG_CPU_CORTEX_M3) || \
4444
defined(CONFIG_CPU_CORTEX_M4) || \
4545
defined(CONFIG_CPU_CORTEX_M7) || \
46-
defined(CONFIG_CPU_AARCH32_CORTEX_R)
46+
defined(CONFIG_ARMV7_R)
4747
#include "arm_mpu_v7_internal.h"
4848
#elif defined(CONFIG_CPU_CORTEX_M23) || \
4949
defined(CONFIG_CPU_CORTEX_M33) || \
50-
defined(CONFIG_CPU_CORTEX_M55)
50+
defined(CONFIG_CPU_CORTEX_M55) || \
51+
defined(CONFIG_AARCH32_ARMV8_R)
5152
#include "arm_mpu_v8_internal.h"
5253
#else
5354
#error "Unsupported ARM CPU"
@@ -84,7 +85,7 @@ static int mpu_configure_region(const uint8_t index,
8485

8586
/* Populate internal ARM MPU region configuration structure. */
8687
region_conf.base = new_region->start;
87-
#if defined(CONFIG_CPU_AARCH32_CORTEX_R)
88+
#if defined(CONFIG_ARMV7_R)
8889
region_conf.size = size_to_mpu_rasr_size(new_region->size);
8990
#endif
9091
get_region_attr_from_mpu_partition_info(&region_conf.attr,

0 commit comments

Comments
 (0)