Skip to content

Commit

Permalink
stm32/mpu: Define the last used MPU region number.
Browse files Browse the repository at this point in the history
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 <i.abdalkader@gmail.com>
  • Loading branch information
iabdalkader authored and dpgeorge committed Aug 8, 2024
1 parent bc7e39d commit 9a48ce3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ports/stm32/mpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9a48ce3

Please sign in to comment.