Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions arch/arm/src/stm32h7/stm32_allocateheap.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ void up_allocate_heap(void **heap_start, size_t *heap_size)
DEBUGASSERT(ubase < (uintptr_t)SRAM_END);

/* Adjust that size to account for MPU alignment requirements.
* NOTE that there is an implicit assumption that the SRAM123_END
* is aligned to the MPU requirement.
* NOTE that there is an implicit assumption that SRAM_END is aligned
* to the MPU requirement.
*/

log2 = (int)mpu_log2regionfloor(usize);
DEBUGASSERT((SRAM_END & ((1 << log2) - 1)) == 0);

usize = (1 << log2);
ubase = SRAM123_END - usize;
ubase = SRAM_END - usize;

/* Return the user-space heap settings */

Expand Down Expand Up @@ -320,8 +320,8 @@ void up_allocate_kheap(void **heap_start, size_t *heap_size)
DEBUGASSERT(ubase < (uintptr_t)SRAM_END);

/* Adjust that size to account for MPU alignment requirements.
* NOTE that there is an implicit assumption that the SRAM123_END
* is aligned to the MPU requirement.
* NOTE that there is an implicit assumption that SRAM_END is aligned
* to the MPU requirement.
*/

log2 = (int)mpu_log2regionfloor(usize);
Expand Down
24 changes: 22 additions & 2 deletions arch/arm/src/stm32h7/stm32_mpuinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,26 @@
# endif
#endif

/****************************************************************************
* Private Functions
****************************************************************************/

#ifdef CONFIG_BUILD_PROTECTED
static void stm32_mpu_user_intsram(uintptr_t start, size_t size)
{
/* STM32H7 protected user memory can span AXI and D2 SRAM. Keep it
* Normal and non-shareable so that LDREX/STREX use the CPU-local
* exclusive monitor. Dual-core RPTUN shared memory is mapped separately
* below with shareable attributes.
*/

mpu_configure_region(start, size,
MPU_RASR_TEX_SO |
MPU_RASR_C |
MPU_RASR_AP_RWRW);
}
#endif

/****************************************************************************
* Public Functions
****************************************************************************/
Expand Down Expand Up @@ -94,7 +114,7 @@ void stm32_mpuinitialize(void)
mpu_user_flash(USERSPACE->us_textstart,
USERSPACE->us_textend - USERSPACE->us_textstart);

mpu_user_intsram(datastart, dataend - datastart);
stm32_mpu_user_intsram(datastart, dataend - datastart);
#endif

#ifdef CONFIG_RPTUN
Expand All @@ -121,7 +141,7 @@ void stm32_mpuinitialize(void)

void stm32_mpu_uheap(uintptr_t start, size_t size)
{
mpu_user_intsram(start, size);
stm32_mpu_user_intsram(start, size);
}
#endif

Expand Down
Loading