mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-12 00:57:44 -04:00
Add support for dynamically allocated stack
If xTaskCreate API is used to create a task, the task's stack is allocated using pvPortMalloc. This places the task's stack in the privileged data section (as all the heap memory is now placed in the privileged data section). We had a separate MPU region to grant a task access to its stack - If the stack is in the privileged data section, this results in overlapping MPU regions as privileged data section is already protected using a separate MPU region. ARMv8-M does not allow overlapping MPU regions and this results in a fault. This commit ensures to not use a separate MPU region to protect the task's stack if it lies within the privileged data section. A side effect of this is that xTaskCreate API cannot be used to create an unprivileged task as the task's stack will be in the privileged data section and the task won't have access to it. xTaskCreateRestricted and xTaskCreateRestrictedStatic API should be used to create unprivileged tasks. Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
parent
94a64e1a90
commit
bba322a72b
25 changed files with 331 additions and 106 deletions
|
@ -1035,6 +1035,16 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
{
|
||||
uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber;
|
||||
int32_t lIndex = 0;
|
||||
#if defined( __ARMCC_VERSION )
|
||||
/* Declaration when these variable are defined in code instead of being
|
||||
* exported from linker scripts. */
|
||||
extern uint32_t * __privileged_sram_start__;
|
||||
extern uint32_t * __privileged_sram_end__;
|
||||
#else
|
||||
/* Declaration when these variable are exported from linker scripts. */
|
||||
extern uint32_t __privileged_sram_start__[];
|
||||
extern uint32_t __privileged_sram_end__[];
|
||||
#endif /* defined( __ARMCC_VERSION ) */
|
||||
|
||||
/* Setup MAIR0. */
|
||||
xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK );
|
||||
|
@ -1046,9 +1056,23 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
* the stack region has already been configured. */
|
||||
if( ulStackDepth > 0 )
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionStartAddress = ( uint32_t ) pxBottomOfStack;
|
||||
ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1;
|
||||
|
||||
/* If the stack is within the privileged SRAM, do not protect it
|
||||
* using a separate MPU region. This is needed because privileged
|
||||
* SRAM is already protected using an MPU region and ARMv8-M does
|
||||
* not allow overlapping MPU regions. */
|
||||
if( ulRegionStartAddress >= ( uint32_t ) __privileged_sram_start__ &&
|
||||
ulRegionEndAddress <= ( uint32_t ) __privileged_sram_end__ )
|
||||
{
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = 0;
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress &= portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK;
|
||||
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) |
|
||||
|
@ -1060,6 +1084,7 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
( portMPU_RLAR_ATTR_INDEX0 ) |
|
||||
( portMPU_RLAR_REGION_ENABLE );
|
||||
}
|
||||
}
|
||||
|
||||
/* User supplied configurable regions. */
|
||||
for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ )
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef unsigned long UBaseType_t;
|
|||
#define portARCH_NAME "Cortex-M23"
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portBYTE_ALIGNMENT 32
|
||||
#define portNOP()
|
||||
#define portINLINE __inline
|
||||
#ifndef portFORCE_INLINE
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef unsigned long UBaseType_t;
|
|||
#define portARCH_NAME "Cortex-M23"
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portBYTE_ALIGNMENT 32
|
||||
#define portNOP()
|
||||
#define portINLINE __inline
|
||||
#ifndef portFORCE_INLINE
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef unsigned long UBaseType_t;
|
|||
#define portARCH_NAME "Cortex-M33"
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portBYTE_ALIGNMENT 32
|
||||
#define portNOP()
|
||||
#define portINLINE __inline
|
||||
#ifndef portFORCE_INLINE
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef unsigned long UBaseType_t;
|
|||
#define portARCH_NAME "Cortex-M33"
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portBYTE_ALIGNMENT 32
|
||||
#define portNOP()
|
||||
#define portINLINE __inline
|
||||
#ifndef portFORCE_INLINE
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef unsigned long UBaseType_t;
|
|||
#define portARCH_NAME "Cortex-M23"
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portBYTE_ALIGNMENT 32
|
||||
#define portNOP()
|
||||
#define portINLINE __inline
|
||||
#ifndef portFORCE_INLINE
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef unsigned long UBaseType_t;
|
|||
#define portARCH_NAME "Cortex-M23"
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portBYTE_ALIGNMENT 32
|
||||
#define portNOP()
|
||||
#define portINLINE __inline
|
||||
#ifndef portFORCE_INLINE
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef unsigned long UBaseType_t;
|
|||
#define portARCH_NAME "Cortex-M33"
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portBYTE_ALIGNMENT 32
|
||||
#define portNOP()
|
||||
#define portINLINE __inline
|
||||
#ifndef portFORCE_INLINE
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef unsigned long UBaseType_t;
|
|||
#define portARCH_NAME "Cortex-M33"
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portBYTE_ALIGNMENT 32
|
||||
#define portNOP()
|
||||
#define portINLINE __inline
|
||||
#ifndef portFORCE_INLINE
|
||||
|
|
|
@ -1035,6 +1035,16 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
{
|
||||
uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber;
|
||||
int32_t lIndex = 0;
|
||||
#if defined( __ARMCC_VERSION )
|
||||
/* Declaration when these variable are defined in code instead of being
|
||||
* exported from linker scripts. */
|
||||
extern uint32_t * __privileged_sram_start__;
|
||||
extern uint32_t * __privileged_sram_end__;
|
||||
#else
|
||||
/* Declaration when these variable are exported from linker scripts. */
|
||||
extern uint32_t __privileged_sram_start__[];
|
||||
extern uint32_t __privileged_sram_end__[];
|
||||
#endif /* defined( __ARMCC_VERSION ) */
|
||||
|
||||
/* Setup MAIR0. */
|
||||
xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK );
|
||||
|
@ -1046,9 +1056,23 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
* the stack region has already been configured. */
|
||||
if( ulStackDepth > 0 )
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionStartAddress = ( uint32_t ) pxBottomOfStack;
|
||||
ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1;
|
||||
|
||||
/* If the stack is within the privileged SRAM, do not protect it
|
||||
* using a separate MPU region. This is needed because privileged
|
||||
* SRAM is already protected using an MPU region and ARMv8-M does
|
||||
* not allow overlapping MPU regions. */
|
||||
if( ulRegionStartAddress >= ( uint32_t ) __privileged_sram_start__ &&
|
||||
ulRegionEndAddress <= ( uint32_t ) __privileged_sram_end__ )
|
||||
{
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = 0;
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress &= portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK;
|
||||
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) |
|
||||
|
@ -1060,6 +1084,7 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
( portMPU_RLAR_ATTR_INDEX0 ) |
|
||||
( portMPU_RLAR_REGION_ENABLE );
|
||||
}
|
||||
}
|
||||
|
||||
/* User supplied configurable regions. */
|
||||
for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ )
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef unsigned long UBaseType_t;
|
|||
#define portARCH_NAME "Cortex-M23"
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portBYTE_ALIGNMENT 32
|
||||
#define portNOP()
|
||||
#define portINLINE __inline
|
||||
#ifndef portFORCE_INLINE
|
||||
|
|
|
@ -1035,6 +1035,16 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
{
|
||||
uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber;
|
||||
int32_t lIndex = 0;
|
||||
#if defined( __ARMCC_VERSION )
|
||||
/* Declaration when these variable are defined in code instead of being
|
||||
* exported from linker scripts. */
|
||||
extern uint32_t * __privileged_sram_start__;
|
||||
extern uint32_t * __privileged_sram_end__;
|
||||
#else
|
||||
/* Declaration when these variable are exported from linker scripts. */
|
||||
extern uint32_t __privileged_sram_start__[];
|
||||
extern uint32_t __privileged_sram_end__[];
|
||||
#endif /* defined( __ARMCC_VERSION ) */
|
||||
|
||||
/* Setup MAIR0. */
|
||||
xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK );
|
||||
|
@ -1046,9 +1056,23 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
* the stack region has already been configured. */
|
||||
if( ulStackDepth > 0 )
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionStartAddress = ( uint32_t ) pxBottomOfStack;
|
||||
ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1;
|
||||
|
||||
/* If the stack is within the privileged SRAM, do not protect it
|
||||
* using a separate MPU region. This is needed because privileged
|
||||
* SRAM is already protected using an MPU region and ARMv8-M does
|
||||
* not allow overlapping MPU regions. */
|
||||
if( ulRegionStartAddress >= ( uint32_t ) __privileged_sram_start__ &&
|
||||
ulRegionEndAddress <= ( uint32_t ) __privileged_sram_end__ )
|
||||
{
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = 0;
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress &= portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK;
|
||||
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) |
|
||||
|
@ -1060,6 +1084,7 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
( portMPU_RLAR_ATTR_INDEX0 ) |
|
||||
( portMPU_RLAR_REGION_ENABLE );
|
||||
}
|
||||
}
|
||||
|
||||
/* User supplied configurable regions. */
|
||||
for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ )
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef unsigned long UBaseType_t;
|
|||
#define portARCH_NAME "Cortex-M23"
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portBYTE_ALIGNMENT 32
|
||||
#define portNOP()
|
||||
#define portINLINE __inline
|
||||
#ifndef portFORCE_INLINE
|
||||
|
|
|
@ -1035,6 +1035,16 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
{
|
||||
uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber;
|
||||
int32_t lIndex = 0;
|
||||
#if defined( __ARMCC_VERSION )
|
||||
/* Declaration when these variable are defined in code instead of being
|
||||
* exported from linker scripts. */
|
||||
extern uint32_t * __privileged_sram_start__;
|
||||
extern uint32_t * __privileged_sram_end__;
|
||||
#else
|
||||
/* Declaration when these variable are exported from linker scripts. */
|
||||
extern uint32_t __privileged_sram_start__[];
|
||||
extern uint32_t __privileged_sram_end__[];
|
||||
#endif /* defined( __ARMCC_VERSION ) */
|
||||
|
||||
/* Setup MAIR0. */
|
||||
xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK );
|
||||
|
@ -1046,9 +1056,23 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
* the stack region has already been configured. */
|
||||
if( ulStackDepth > 0 )
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionStartAddress = ( uint32_t ) pxBottomOfStack;
|
||||
ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1;
|
||||
|
||||
/* If the stack is within the privileged SRAM, do not protect it
|
||||
* using a separate MPU region. This is needed because privileged
|
||||
* SRAM is already protected using an MPU region and ARMv8-M does
|
||||
* not allow overlapping MPU regions. */
|
||||
if( ulRegionStartAddress >= ( uint32_t ) __privileged_sram_start__ &&
|
||||
ulRegionEndAddress <= ( uint32_t ) __privileged_sram_end__ )
|
||||
{
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = 0;
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress &= portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK;
|
||||
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) |
|
||||
|
@ -1060,6 +1084,7 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
( portMPU_RLAR_ATTR_INDEX0 ) |
|
||||
( portMPU_RLAR_REGION_ENABLE );
|
||||
}
|
||||
}
|
||||
|
||||
/* User supplied configurable regions. */
|
||||
for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ )
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef unsigned long UBaseType_t;
|
|||
#define portARCH_NAME "Cortex-M33"
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portBYTE_ALIGNMENT 32
|
||||
#define portNOP()
|
||||
#define portINLINE __inline
|
||||
#ifndef portFORCE_INLINE
|
||||
|
|
|
@ -1035,6 +1035,16 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
{
|
||||
uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber;
|
||||
int32_t lIndex = 0;
|
||||
#if defined( __ARMCC_VERSION )
|
||||
/* Declaration when these variable are defined in code instead of being
|
||||
* exported from linker scripts. */
|
||||
extern uint32_t * __privileged_sram_start__;
|
||||
extern uint32_t * __privileged_sram_end__;
|
||||
#else
|
||||
/* Declaration when these variable are exported from linker scripts. */
|
||||
extern uint32_t __privileged_sram_start__[];
|
||||
extern uint32_t __privileged_sram_end__[];
|
||||
#endif /* defined( __ARMCC_VERSION ) */
|
||||
|
||||
/* Setup MAIR0. */
|
||||
xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK );
|
||||
|
@ -1046,9 +1056,23 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
* the stack region has already been configured. */
|
||||
if( ulStackDepth > 0 )
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionStartAddress = ( uint32_t ) pxBottomOfStack;
|
||||
ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1;
|
||||
|
||||
/* If the stack is within the privileged SRAM, do not protect it
|
||||
* using a separate MPU region. This is needed because privileged
|
||||
* SRAM is already protected using an MPU region and ARMv8-M does
|
||||
* not allow overlapping MPU regions. */
|
||||
if( ulRegionStartAddress >= ( uint32_t ) __privileged_sram_start__ &&
|
||||
ulRegionEndAddress <= ( uint32_t ) __privileged_sram_end__ )
|
||||
{
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = 0;
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress &= portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK;
|
||||
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) |
|
||||
|
@ -1060,6 +1084,7 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
( portMPU_RLAR_ATTR_INDEX0 ) |
|
||||
( portMPU_RLAR_REGION_ENABLE );
|
||||
}
|
||||
}
|
||||
|
||||
/* User supplied configurable regions. */
|
||||
for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ )
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef unsigned long UBaseType_t;
|
|||
#define portARCH_NAME "Cortex-M33"
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portBYTE_ALIGNMENT 32
|
||||
#define portNOP()
|
||||
#define portINLINE __inline
|
||||
#ifndef portFORCE_INLINE
|
||||
|
|
|
@ -1035,6 +1035,16 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
{
|
||||
uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber;
|
||||
int32_t lIndex = 0;
|
||||
#if defined( __ARMCC_VERSION )
|
||||
/* Declaration when these variable are defined in code instead of being
|
||||
* exported from linker scripts. */
|
||||
extern uint32_t * __privileged_sram_start__;
|
||||
extern uint32_t * __privileged_sram_end__;
|
||||
#else
|
||||
/* Declaration when these variable are exported from linker scripts. */
|
||||
extern uint32_t __privileged_sram_start__[];
|
||||
extern uint32_t __privileged_sram_end__[];
|
||||
#endif /* defined( __ARMCC_VERSION ) */
|
||||
|
||||
/* Setup MAIR0. */
|
||||
xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK );
|
||||
|
@ -1046,9 +1056,23 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
* the stack region has already been configured. */
|
||||
if( ulStackDepth > 0 )
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionStartAddress = ( uint32_t ) pxBottomOfStack;
|
||||
ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1;
|
||||
|
||||
/* If the stack is within the privileged SRAM, do not protect it
|
||||
* using a separate MPU region. This is needed because privileged
|
||||
* SRAM is already protected using an MPU region and ARMv8-M does
|
||||
* not allow overlapping MPU regions. */
|
||||
if( ulRegionStartAddress >= ( uint32_t ) __privileged_sram_start__ &&
|
||||
ulRegionEndAddress <= ( uint32_t ) __privileged_sram_end__ )
|
||||
{
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = 0;
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress &= portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK;
|
||||
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) |
|
||||
|
@ -1060,6 +1084,7 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
( portMPU_RLAR_ATTR_INDEX0 ) |
|
||||
( portMPU_RLAR_REGION_ENABLE );
|
||||
}
|
||||
}
|
||||
|
||||
/* User supplied configurable regions. */
|
||||
for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ )
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef unsigned long UBaseType_t;
|
|||
#define portARCH_NAME "Cortex-M23"
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portBYTE_ALIGNMENT 32
|
||||
#define portNOP()
|
||||
#define portINLINE __inline
|
||||
#ifndef portFORCE_INLINE
|
||||
|
|
|
@ -1035,6 +1035,16 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
{
|
||||
uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber;
|
||||
int32_t lIndex = 0;
|
||||
#if defined( __ARMCC_VERSION )
|
||||
/* Declaration when these variable are defined in code instead of being
|
||||
* exported from linker scripts. */
|
||||
extern uint32_t * __privileged_sram_start__;
|
||||
extern uint32_t * __privileged_sram_end__;
|
||||
#else
|
||||
/* Declaration when these variable are exported from linker scripts. */
|
||||
extern uint32_t __privileged_sram_start__[];
|
||||
extern uint32_t __privileged_sram_end__[];
|
||||
#endif /* defined( __ARMCC_VERSION ) */
|
||||
|
||||
/* Setup MAIR0. */
|
||||
xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK );
|
||||
|
@ -1046,9 +1056,23 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
* the stack region has already been configured. */
|
||||
if( ulStackDepth > 0 )
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionStartAddress = ( uint32_t ) pxBottomOfStack;
|
||||
ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1;
|
||||
|
||||
/* If the stack is within the privileged SRAM, do not protect it
|
||||
* using a separate MPU region. This is needed because privileged
|
||||
* SRAM is already protected using an MPU region and ARMv8-M does
|
||||
* not allow overlapping MPU regions. */
|
||||
if( ulRegionStartAddress >= ( uint32_t ) __privileged_sram_start__ &&
|
||||
ulRegionEndAddress <= ( uint32_t ) __privileged_sram_end__ )
|
||||
{
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = 0;
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress &= portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK;
|
||||
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) |
|
||||
|
@ -1060,6 +1084,7 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
( portMPU_RLAR_ATTR_INDEX0 ) |
|
||||
( portMPU_RLAR_REGION_ENABLE );
|
||||
}
|
||||
}
|
||||
|
||||
/* User supplied configurable regions. */
|
||||
for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ )
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef unsigned long UBaseType_t;
|
|||
#define portARCH_NAME "Cortex-M23"
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portBYTE_ALIGNMENT 32
|
||||
#define portNOP()
|
||||
#define portINLINE __inline
|
||||
#ifndef portFORCE_INLINE
|
||||
|
|
|
@ -1035,6 +1035,16 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
{
|
||||
uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber;
|
||||
int32_t lIndex = 0;
|
||||
#if defined( __ARMCC_VERSION )
|
||||
/* Declaration when these variable are defined in code instead of being
|
||||
* exported from linker scripts. */
|
||||
extern uint32_t * __privileged_sram_start__;
|
||||
extern uint32_t * __privileged_sram_end__;
|
||||
#else
|
||||
/* Declaration when these variable are exported from linker scripts. */
|
||||
extern uint32_t __privileged_sram_start__[];
|
||||
extern uint32_t __privileged_sram_end__[];
|
||||
#endif /* defined( __ARMCC_VERSION ) */
|
||||
|
||||
/* Setup MAIR0. */
|
||||
xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK );
|
||||
|
@ -1046,9 +1056,23 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
* the stack region has already been configured. */
|
||||
if( ulStackDepth > 0 )
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionStartAddress = ( uint32_t ) pxBottomOfStack;
|
||||
ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1;
|
||||
|
||||
/* If the stack is within the privileged SRAM, do not protect it
|
||||
* using a separate MPU region. This is needed because privileged
|
||||
* SRAM is already protected using an MPU region and ARMv8-M does
|
||||
* not allow overlapping MPU regions. */
|
||||
if( ulRegionStartAddress >= ( uint32_t ) __privileged_sram_start__ &&
|
||||
ulRegionEndAddress <= ( uint32_t ) __privileged_sram_end__ )
|
||||
{
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = 0;
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress &= portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK;
|
||||
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) |
|
||||
|
@ -1060,6 +1084,7 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
( portMPU_RLAR_ATTR_INDEX0 ) |
|
||||
( portMPU_RLAR_REGION_ENABLE );
|
||||
}
|
||||
}
|
||||
|
||||
/* User supplied configurable regions. */
|
||||
for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ )
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef unsigned long UBaseType_t;
|
|||
#define portARCH_NAME "Cortex-M33"
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portBYTE_ALIGNMENT 32
|
||||
#define portNOP()
|
||||
#define portINLINE __inline
|
||||
#ifndef portFORCE_INLINE
|
||||
|
|
|
@ -1035,6 +1035,16 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
{
|
||||
uint32_t ulRegionStartAddress, ulRegionEndAddress, ulRegionNumber;
|
||||
int32_t lIndex = 0;
|
||||
#if defined( __ARMCC_VERSION )
|
||||
/* Declaration when these variable are defined in code instead of being
|
||||
* exported from linker scripts. */
|
||||
extern uint32_t * __privileged_sram_start__;
|
||||
extern uint32_t * __privileged_sram_end__;
|
||||
#else
|
||||
/* Declaration when these variable are exported from linker scripts. */
|
||||
extern uint32_t __privileged_sram_start__[];
|
||||
extern uint32_t __privileged_sram_end__[];
|
||||
#endif /* defined( __ARMCC_VERSION ) */
|
||||
|
||||
/* Setup MAIR0. */
|
||||
xMPUSettings->ulMAIR0 = ( ( portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE << portMPU_MAIR_ATTR0_POS ) & portMPU_MAIR_ATTR0_MASK );
|
||||
|
@ -1046,9 +1056,23 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
* the stack region has already been configured. */
|
||||
if( ulStackDepth > 0 )
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress = ( ( uint32_t ) pxBottomOfStack ) & portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionStartAddress = ( uint32_t ) pxBottomOfStack;
|
||||
ulRegionEndAddress = ( uint32_t ) pxBottomOfStack + ( ulStackDepth * ( uint32_t ) sizeof( StackType_t ) ) - 1;
|
||||
|
||||
/* If the stack is within the privileged SRAM, do not protect it
|
||||
* using a separate MPU region. This is needed because privileged
|
||||
* SRAM is already protected using an MPU region and ARMv8-M does
|
||||
* not allow overlapping MPU regions. */
|
||||
if( ulRegionStartAddress >= ( uint32_t ) __privileged_sram_start__ &&
|
||||
ulRegionEndAddress <= ( uint32_t ) __privileged_sram_end__ )
|
||||
{
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = 0;
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRLAR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Define the region that allows access to the stack. */
|
||||
ulRegionStartAddress &= portMPU_RBAR_ADDRESS_MASK;
|
||||
ulRegionEndAddress &= portMPU_RLAR_ADDRESS_MASK;
|
||||
|
||||
xMPUSettings->xRegionsSettings[ 0 ].ulRBAR = ( ulRegionStartAddress ) |
|
||||
|
@ -1060,6 +1084,7 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
|
|||
( portMPU_RLAR_ATTR_INDEX0 ) |
|
||||
( portMPU_RLAR_REGION_ENABLE );
|
||||
}
|
||||
}
|
||||
|
||||
/* User supplied configurable regions. */
|
||||
for( ulRegionNumber = 1; ulRegionNumber <= portNUM_CONFIGURABLE_REGIONS; ulRegionNumber++ )
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef unsigned long UBaseType_t;
|
|||
#define portARCH_NAME "Cortex-M33"
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portBYTE_ALIGNMENT 32
|
||||
#define portNOP()
|
||||
#define portINLINE __inline
|
||||
#ifndef portFORCE_INLINE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue