In mpu_armv7.h, why while loop is used in ARM_MPU_Load function which runs at every 4th iteration? #1265
-
The following modified function does not work and it creates only four entries (Region 0 to Region 3). I am not able to understand the reason behind it. Why the while loop is used here and the iteration is decremented by Here, __STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt)
{
const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U;
/*while (cnt > MPU_TYPE_RALIASES) {
ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), MPU_TYPE_RALIASES*rowWordSize);
table += MPU_TYPE_RALIASES;
cnt -= MPU_TYPE_RALIASES;
}*/
ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), cnt*rowWordSize);
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @nirajgandhi,
Loading more MPU regions than Cheers, |
Beta Was this translation helpful? Give feedback.
Hey @nirajgandhi,
ARM_MPU_Load
has been implemented to load as many MPU regions as required with the least amount of CPU cycles.Depending on the amount of region aliases of the MPU (
MPU_TYPE_RALIASES
) one can load as many regions with subsequent memory accesses at once.Loading more MPU regions than
MPU_TYPE_RALIASES
one needs to split the load into junks. Hence your code won't work. It will only load the first 4 regions and the remaining 8 regions are written elsewhere into the memory. This gives basically undefined behaviour!Cheers,
Jonatan