From 9a48ce3051744fac20762199d67ffc380c1de1f6 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Sat, 20 Jul 2024 10:37:26 +0300 Subject: [PATCH] stm32/mpu: Define the last used MPU region number. The reason for this change is that it makes allows custom code, that needs to use an MPU region, to find a free one by using this macro or starting from the max number and downwards, without concern that it might change in the future. Signed-off-by: iabdalkader --- ports/stm32/mpu.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ports/stm32/mpu.h b/ports/stm32/mpu.h index 5ef146618..a87c04a58 100644 --- a/ports/stm32/mpu.h +++ b/ports/stm32/mpu.h @@ -36,12 +36,18 @@ #define MPU_REGION_QSPI3 (MPU_REGION_NUMBER3) #define MPU_REGION_SDRAM1 (MPU_REGION_NUMBER4) #define MPU_REGION_SDRAM2 (MPU_REGION_NUMBER5) -#define MPU_REGION_OPENAMP (MPU_REGION_NUMBER15) // Only relevant on CPUs with D-Cache, must be higher priority than SDRAM #define MPU_REGION_DMA_UNCACHED_1 (MPU_REGION_NUMBER6) #define MPU_REGION_DMA_UNCACHED_2 (MPU_REGION_NUMBER7) +#ifdef MPU_REGION_NUMBER8 +#define MPU_REGION_OPENAMP (MPU_REGION_NUMBER8) +#define MPU_REGION_LAST_USED (MPU_REGION_NUMBER8) +#else +#define MPU_REGION_LAST_USED (MPU_REGION_NUMBER7) +#endif + // Attribute value to disable a region entirely, remove it from the MPU // (i.e. the MPU_REGION_ENABLE bit is unset.) #define MPU_CONFIG_DISABLE 0 @@ -135,6 +141,7 @@ static inline void mpu_config_end(uint32_t irq_state) { #define MPU_REGION_SIG (MPU_REGION_NUMBER0) #define MPU_REGION_ETH (MPU_REGION_NUMBER1) +#define MPU_REGION_LAST_USED (MPU_REGION_NUMBER1) #define ST_DEVICE_SIGNATURE_BASE (0x08fff800) #define ST_DEVICE_SIGNATURE_LIMIT (0x08ffffff)