From 4a729218baef8e1e6b84a512c3dbfdbc1224b752 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Sat, 3 Oct 2009 19:56:09 +0000 Subject: [PATCH] Reinstate privileged only RAM region when a task is running that does not otherwise make use of the MPU. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@890 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Source/portable/GCC/ARM_CM3_MPU/port.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Source/portable/GCC/ARM_CM3_MPU/port.c b/Source/portable/GCC/ARM_CM3_MPU/port.c index 92d541337..48fa7d858 100644 --- a/Source/portable/GCC/ARM_CM3_MPU/port.c +++ b/Source/portable/GCC/ARM_CM3_MPU/port.c @@ -502,12 +502,14 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMOR { extern unsigned long __SRAM_segment_start__[]; extern unsigned long __SRAM_segment_end__[]; +extern unsigned long __privileged_data_start__[]; +extern unsigned long __privileged_data_end__[]; long lIndex; unsigned long ul; if( xRegions == NULL ) { - /* No MPU regions are specified to allow access to all RAM. */ + /* No MPU regions are specified so allow access to all RAM. */ xMPUSettings->xRegion[ 0 ].ulRegionBaseAddress = ( ( unsigned long ) __SRAM_segment_start__ ) | /* Base address. */ ( portMPU_REGION_VALID ) | @@ -519,9 +521,22 @@ unsigned long ul; ( prvGetMPURegionSizeSetting( ( unsigned long ) __SRAM_segment_end__ - ( unsigned long ) __SRAM_segment_start__ ) ) | ( portMPU_REGION_ENABLE ); + /* Re-instate the privileged only RAM region as xRegion[ 0 ] will have + just removed the privileged only parameters. */ + xMPUSettings->xRegion[ 1 ].ulRegionBaseAddress = + ( ( unsigned long ) __privileged_data_start__ ) | /* Base address. */ + ( portMPU_REGION_VALID ) | + ( portSTACK_REGION + 1 ); + + xMPUSettings->xRegion[ 1 ].ulRegionAttribute = + ( portMPU_REGION_PRIVILEGED_READ_WRITE ) | + ( portMPU_REGION_CACHEABLE_BUFFERABLE ) | + prvGetMPURegionSizeSetting( ( unsigned long ) __privileged_data_end__ - ( unsigned long ) __privileged_data_start__ ) | + ( portMPU_REGION_ENABLE ); + /* Invalidate all other regions. */ - for( ul = 1; ul <= portNUM_CONFIGURABLE_REGIONS; ul++ ) - { + for( ul = 2; ul <= portNUM_CONFIGURABLE_REGIONS; ul++ ) + { xMPUSettings->xRegion[ ul ].ulRegionBaseAddress = ( portSTACK_REGION + ul ) | portMPU_REGION_VALID; xMPUSettings->xRegion[ ul ].ulRegionAttribute = 0UL; } -- 2.39.5