This is an automated email from the ASF dual-hosted git repository.

kasjer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 18dff21a49b2e385ce9f0aba839630c0e2084779
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Wed Oct 14 14:05:58 2026 +0200

    cmsis-core: Allow variable address in MPU_ARM_V7_REGION
    
    MPU_ARM_V7_REGION() combined region address with VALID bit using
    bitwise or. Address of variable is not a compile time constant for
    bitwise operation, so region could only be defined for fixed numeric
    address and not for memory allocated by linker.
    
    Region base address is aligned to region size (at least 32 bytes),
    so VALID bit can be added instead, which is allowed in static
    initializer for address of variable.
    
    Assisted-by: Claude:claude-opus-5-5
    Signed-off-by: Jerzy Kasenberg <[email protected]>
---
 hw/cmsis-core/include/arm_mpu.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/hw/cmsis-core/include/arm_mpu.h b/hw/cmsis-core/include/arm_mpu.h
index e8d506198..5c6069c04 100644
--- a/hw/cmsis-core/include/arm_mpu.h
+++ b/hw/cmsis-core/include/arm_mpu.h
@@ -28,9 +28,14 @@
 
 LINK_TABLE(ARM_MPU_Region_t, mpu_regions);
 
+/*
+ * Region base address is aligned to region size (at least 32 bytes) so
+ * VALID bit can be added.  Using + instead of | allows address of variable
+ * to be used, it is not compile time constant for bitwise operation.
+ */
 #define MPU_ARM_V7_REGION(name, address, rasr)                                \
     LINK_TABLE_ELEMENT(mpu_regions, name) = {                                 \
-        .RBAR = address | MPU_RBAR_VALID_Msk,                                 \
+        .RBAR = (uint32_t)(address) + MPU_RBAR_VALID_Msk,                     \
         .RASR = rasr,                                                         \
     };
 

Reply via email to