81
81
#define portMPU_REGION_BASE_ADDRESS_REG ( *( ( volatile uint32_t * ) 0xe000ed9C ) )
82
82
#define portMPU_REGION_ATTRIBUTE_REG ( *( ( volatile uint32_t * ) 0xe000edA0 ) )
83
83
#define portMPU_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed94 ) )
84
- #define portEXPECTED_MPU_TYPE_VALUE ( portTOTAL_NUM_REGIONS << 8UL )
84
+ #define portEXPECTED_MPU_TYPE_VALUE ( configTOTAL_MPU_REGIONS << 8UL )
85
85
#define portMPU_ENABLE ( 0x01UL )
86
86
#define portMPU_BACKGROUND_ENABLE ( 1UL << 2UL )
87
87
#define portPRIVILEGED_EXECUTION_START_ADDRESS ( 0UL )
@@ -380,12 +380,12 @@ static void prvRestoreContextOfFirstTask( void )
380
380
" ldmia r1!, {r4-r11} \n" /* Read 4 sets of MPU registers [MPU Region # 4 - 7]. */
381
381
" stmia r2, {r4-r11} \n" /* Write 4 sets of MPU registers [MPU Region # 4 - 7]. */
382
382
" \n"
383
- #if ( portTOTAL_NUM_REGIONS == 16 )
383
+ #if ( configTOTAL_MPU_REGIONS == 16 )
384
384
" ldmia r1!, {r4-r11} \n" /* Read 4 sets of MPU registers [MPU Region # 8 - 11]. */
385
385
" stmia r2, {r4-r11} \n" /* Write 4 sets of MPU registers. [MPU Region # 8 - 11]. */
386
386
" ldmia r1!, {r4-r11} \n" /* Read 4 sets of MPU registers [MPU Region # 12 - 15]. */
387
387
" stmia r2, {r4-r11} \n" /* Write 4 sets of MPU registers. [MPU Region # 12 - 15]. */
388
- #endif /* portTOTAL_NUM_REGIONS == 16. */
388
+ #endif /* configTOTAL_MPU_REGIONS == 16. */
389
389
" \n"
390
390
" ldr r2, =0xe000ed94 \n" /* MPU_CTRL register. */
391
391
" ldr r3, [r2] \n" /* Read the value of MPU_CTRL. */
@@ -633,12 +633,12 @@ void xPortPendSVHandler( void )
633
633
" ldmia r1!, {r4-r11} \n" /* Read 4 sets of MPU registers [MPU Region # 4 - 7]. */
634
634
" stmia r2, {r4-r11} \n" /* Write 4 sets of MPU registers [MPU Region # 4 - 7]. */
635
635
" \n"
636
- #if ( portTOTAL_NUM_REGIONS == 16 )
636
+ #if ( configTOTAL_MPU_REGIONS == 16 )
637
637
" ldmia r1!, {r4-r11} \n" /* Read 4 sets of MPU registers [MPU Region # 8 - 11]. */
638
638
" stmia r2, {r4-r11} \n" /* Write 4 sets of MPU registers. [MPU Region # 8 - 11]. */
639
639
" ldmia r1!, {r4-r11} \n" /* Read 4 sets of MPU registers [MPU Region # 12 - 15]. */
640
640
" stmia r2, {r4-r11} \n" /* Write 4 sets of MPU registers. [MPU Region # 12 - 15]. */
641
- #endif /* portTOTAL_NUM_REGIONS == 16. */
641
+ #endif /* configTOTAL_MPU_REGIONS == 16. */
642
642
" \n"
643
643
" ldr r2, =0xe000ed94 \n" /* MPU_CTRL register. */
644
644
" ldr r3, [r2] \n" /* Read the value of MPU_CTRL. */
@@ -736,7 +736,7 @@ static void prvSetupMPU( void )
736
736
#endif /* if defined( __ARMCC_VERSION ) */
737
737
738
738
/* The only permitted number of regions are 8 or 16. */
739
- configASSERT ( ( portTOTAL_NUM_REGIONS == 8 ) || ( portTOTAL_NUM_REGIONS == 16 ) );
739
+ configASSERT ( ( configTOTAL_MPU_REGIONS == 8 ) || ( configTOTAL_MPU_REGIONS == 16 ) );
740
740
741
741
/* Ensure that the configTOTAL_MPU_REGIONS is configured correctly. */
742
742
configASSERT ( portMPU_TYPE_REG == portEXPECTED_MPU_TYPE_VALUE );
@@ -879,31 +879,18 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
879
879
xMPUSettings -> xRegion [ 0 ].ulRegionBaseAddress =
880
880
( ( uint32_t ) __SRAM_segment_start__ ) | /* Base address. */
881
881
( portMPU_REGION_VALID ) |
882
- ( portSTACK_REGION );
882
+ ( portSTACK_REGION ); /* Region number. */
883
883
884
884
xMPUSettings -> xRegion [ 0 ].ulRegionAttribute =
885
885
( portMPU_REGION_READ_WRITE ) |
886
886
( ( configTEX_S_C_B_SRAM & portMPU_RASR_TEX_S_C_B_MASK ) << portMPU_RASR_TEX_S_C_B_LOCATION ) |
887
887
( prvGetMPURegionSizeSetting ( ( uint32_t ) __SRAM_segment_end__ - ( uint32_t ) __SRAM_segment_start__ ) ) |
888
888
( portMPU_REGION_ENABLE );
889
889
890
- /* Re-instate the privileged only RAM region as xRegion[ 0 ] will have
891
- * just removed the privileged only parameters. */
892
- xMPUSettings -> xRegion [ 1 ].ulRegionBaseAddress =
893
- ( ( uint32_t ) __privileged_data_start__ ) | /* Base address. */
894
- ( portMPU_REGION_VALID ) |
895
- ( portSTACK_REGION + 1 );
896
-
897
- xMPUSettings -> xRegion [ 1 ].ulRegionAttribute =
898
- ( portMPU_REGION_PRIVILEGED_READ_WRITE ) |
899
- ( ( configTEX_S_C_B_SRAM & portMPU_RASR_TEX_S_C_B_MASK ) << portMPU_RASR_TEX_S_C_B_LOCATION ) |
900
- prvGetMPURegionSizeSetting ( ( uint32_t ) __privileged_data_end__ - ( uint32_t ) __privileged_data_start__ ) |
901
- ( portMPU_REGION_ENABLE );
902
-
903
- /* Invalidate all other regions. */
904
- for ( ul = 2 ; ul <= portNUM_CONFIGURABLE_REGIONS ; ul ++ )
890
+ /* Invalidate user configurable regions. */
891
+ for ( ul = 1UL ; ul <= portNUM_CONFIGURABLE_REGIONS ; ul ++ )
905
892
{
906
- xMPUSettings -> xRegion [ ul ].ulRegionBaseAddress = ( portSTACK_REGION + ul ) | portMPU_REGION_VALID ;
893
+ xMPUSettings -> xRegion [ ul ].ulRegionBaseAddress = ( ( ul - 1UL ) | portMPU_REGION_VALID ) ;
907
894
xMPUSettings -> xRegion [ ul ].ulRegionAttribute = 0UL ;
908
895
}
909
896
}
@@ -930,7 +917,7 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
930
917
931
918
lIndex = 0 ;
932
919
933
- for ( ul = 1 ; ul <= portNUM_CONFIGURABLE_REGIONS ; ul ++ )
920
+ for ( ul = 1UL ; ul <= portNUM_CONFIGURABLE_REGIONS ; ul ++ )
934
921
{
935
922
if ( ( xRegions [ lIndex ] ).ulLengthInBytes > 0UL )
936
923
{
@@ -940,7 +927,7 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
940
927
xMPUSettings -> xRegion [ ul ].ulRegionBaseAddress =
941
928
( ( uint32_t ) xRegions [ lIndex ].pvBaseAddress ) |
942
929
( portMPU_REGION_VALID ) |
943
- ( portSTACK_REGION + ul ); /* Region number. */
930
+ ( ul - 1UL ); /* Region number. */
944
931
945
932
xMPUSettings -> xRegion [ ul ].ulRegionAttribute =
946
933
( prvGetMPURegionSizeSetting ( xRegions [ lIndex ].ulLengthInBytes ) ) |
@@ -950,7 +937,7 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
950
937
else
951
938
{
952
939
/* Invalidate the region. */
953
- xMPUSettings -> xRegion [ ul ].ulRegionBaseAddress = ( portSTACK_REGION + ul ) | portMPU_REGION_VALID ;
940
+ xMPUSettings -> xRegion [ ul ].ulRegionBaseAddress = ( ( ul - 1UL ) | portMPU_REGION_VALID ) ;
954
941
xMPUSettings -> xRegion [ ul ].ulRegionAttribute = 0UL ;
955
942
}
956
943
0 commit comments