summaryrefslogtreecommitdiff
path: root/FreeRTOS/Source/portable/RVDS
diff options
context:
space:
mode:
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2016-06-27 13:13:05 +0000
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2016-06-27 13:13:05 +0000
commit48c3a814441783b709b3584ba250c15926f472a3 (patch)
tree62810c8e6dd7e63fab3c5b5a80ae926c7e6d34d0 /FreeRTOS/Source/portable/RVDS
parent4f73e0b4480bcbec3e4f8e7c80bb47657346f2ed (diff)
downloadfreertos-48c3a814441783b709b3584ba250c15926f472a3.tar.gz
Improvements to the Cortex-M ports:
- Clear the SysTick current value register before starting the SysTick (only required if something uses SysTick before starting the scheduler). - Ensure atomic operations are thread safe by executing clrex in the context switch. git-svn-id: http://svn.code.sf.net/p/freertos/code/trunk@2465 1d2547de-c912-0410-9cb9-b8ca96c0e9e2
Diffstat (limited to 'FreeRTOS/Source/portable/RVDS')
-rw-r--r--FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c9
-rw-r--r--FreeRTOS/Source/portable/RVDS/ARM_CM3/port.c5
-rw-r--r--FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c9
-rw-r--r--FreeRTOS/Source/portable/RVDS/ARM_CM4_MPU/port.c20
-rw-r--r--FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/port.c7
5 files changed, 40 insertions, 10 deletions
diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c b/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c
index 6fc1e94b6..1de444935 100644
--- a/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c
+++ b/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c
@@ -76,8 +76,9 @@
#include "task.h"
/* Constants required to manipulate the NVIC. */
-#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t *) 0xe000e010 )
-#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t *) 0xe000e014 )
+#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t * ) 0xe000e010 )
+#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t * ) 0xe000e014 )
+#define portNVIC_SYSTICK_CURRENT_VALUE ( ( volatile uint32_t * ) 0xe000e018 )
#define portNVIC_INT_CTRL ( ( volatile uint32_t *) 0xe000ed04 )
#define portNVIC_SYSPRI2 ( ( volatile uint32_t *) 0xe000ed20 )
#define portNVIC_SYSTICK_CLK 0x00000004
@@ -341,6 +342,10 @@ uint32_t ulPreviousMask;
*/
void prvSetupTimerInterrupt( void )
{
+ /* Stop and reset the SysTick. */
+ *(portNVIC_SYSTICK_CTRL) = 0UL;
+ *(portNVIC_SYSTICK_CURRENT_VALUE) = 0UL;
+
/* Configure SysTick to interrupt at the requested rate. */
*(portNVIC_SYSTICK_LOAD) = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;
*(portNVIC_SYSTICK_CTRL) = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE;
diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM3/port.c b/FreeRTOS/Source/portable/RVDS/ARM_CM3/port.c
index 61d85967d..8ce6d098d 100644
--- a/FreeRTOS/Source/portable/RVDS/ARM_CM3/port.c
+++ b/FreeRTOS/Source/portable/RVDS/ARM_CM3/port.c
@@ -407,6 +407,7 @@ __asm void xPortPendSVHandler( void )
stmdb r0!, {r4-r11} /* Save the remaining registers. */
str r0, [r2] /* Save the new top of stack into the first member of the TCB. */
+ clrex /* Ensure thread safety of atomic operations. */
stmdb sp!, {r3, r14}
mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
@@ -621,6 +622,10 @@ void xPortSysTickHandler( void )
}
#endif /* configUSE_TICKLESS_IDLE */
+ /* Stop and clear the SysTick. */
+ portNVIC_SYSTICK_CTRL_REG = 0UL;
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;
+
/* Configure SysTick to interrupt at the requested rate. */
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;
portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );
diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c b/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c
index 1dc1b5b00..aaf9efd21 100644
--- a/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c
+++ b/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c
@@ -479,6 +479,9 @@ __asm void xPortPendSVHandler( void )
/* Save the new top of stack into the first member of the TCB. */
str r0, [r2]
+ /* Ensure thread safety of atomic operations. */
+ clrex
+
stmdb sp!, {r3}
mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
msr basepri, r0
@@ -696,7 +699,7 @@ void xPortSysTickHandler( void )
* Setup the SysTick timer to generate the tick interrupts at the required
* frequency.
*/
-#if configOVERRIDE_DEFAULT_TICK_CONFIGURATION == 0
+#if( configOVERRIDE_DEFAULT_TICK_CONFIGURATION == 0 )
void vPortSetupTimerInterrupt( void )
{
@@ -709,6 +712,10 @@ void xPortSysTickHandler( void )
}
#endif /* configUSE_TICKLESS_IDLE */
+ /* Stop and clear the SysTick. */
+ portNVIC_SYSTICK_CTRL_REG = 0UL;
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;
+
/* Configure SysTick to interrupt at the requested rate. */
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;
portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );
diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM4_MPU/port.c b/FreeRTOS/Source/portable/RVDS/ARM_CM4_MPU/port.c
index bbe2a96a8..0623859e8 100644
--- a/FreeRTOS/Source/portable/RVDS/ARM_CM4_MPU/port.c
+++ b/FreeRTOS/Source/portable/RVDS/ARM_CM4_MPU/port.c
@@ -91,6 +91,7 @@ task.h is included from an application file. */
/* Constants required to access and manipulate the NVIC. */
#define portNVIC_SYSTICK_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000e010 ) )
#define portNVIC_SYSTICK_LOAD_REG ( * ( ( volatile uint32_t * ) 0xe000e014 ) )
+#define portNVIC_SYSTICK_CURRENT_VALUE_REG ( * ( ( volatile uint32_t * ) 0xe000e018 ) )
#define portNVIC_SYSPRI2_REG ( * ( ( volatile uint32_t * ) 0xe000ed20 ) )
#define portNVIC_SYSPRI1_REG ( * ( ( volatile uint32_t * ) 0xe000ed1c ) )
#define portNVIC_SYS_CTRL_STATE_REG ( * ( ( volatile uint32_t * ) 0xe000ed24 ) )
@@ -206,7 +207,7 @@ static void vPortEnableVFP( void );
* Utility function.
*/
static uint32_t prvPortGetIPSR( void );
-
+
/*
* Used by the portASSERT_IF_INTERRUPT_PRIORITY_INVALID() macro to ensure
* FreeRTOS API functions are not called from interrupts that have been assigned
@@ -297,7 +298,7 @@ uint32_t ulReg;
__asm void vPortSVCHandler( void )
{
extern prvSVCHandler
-
+
PRESERVE8
/* Assumes psp was in use. */
@@ -424,7 +425,7 @@ BaseType_t xPortStartScheduler( void )
__asm void prvStartFirstTask( void )
{
PRESERVE8
-
+
ldr r0, =0xE000ED08 /* Use the NVIC offset register to locate the stack. */
ldr r0, [r0]
ldr r0, [r0]
@@ -491,6 +492,7 @@ __asm void xPortPendSVHandler( void )
mrs r1, control
stmdb r0!, {r1, r4-r11, r14} /* Save the remaining registers. */
str r0, [r2] /* Save the new top of stack into the first member of the TCB. */
+ clrex /* Ensure thread safety of atomic operations. */
stmdb sp!, {r3}
mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
@@ -544,6 +546,10 @@ uint32_t ulDummy;
*/
static void prvSetupTimerInterrupt( void )
{
+ /* Reset the SysTick. */
+ portNVIC_SYSTICK_CTRL_REG = 0UL;
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;
+
/* Configure SysTick to interrupt at the requested rate. */
portNVIC_SYSTICK_LOAD_REG = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE;
@@ -553,18 +559,18 @@ static void prvSetupTimerInterrupt( void )
__asm void vPortSwitchToUserMode( void )
{
PRESERVE8
-
+
mrs r0, control
orr r0, #1
msr control, r0
bx r14
}
/*-----------------------------------------------------------*/
-
+
__asm void vPortEnableVFP( void )
{
PRESERVE8
-
+
ldr.w r0, =0xE000ED88 /* The FPU enable bits are in the CPACR. */
ldr r1, [r0]
@@ -682,7 +688,7 @@ extern uint32_t __SRAM_segment_end__;
extern uint32_t __privileged_data_start__;
extern uint32_t __privileged_data_end__;
-
+
int32_t lIndex;
uint32_t ul;
diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/port.c b/FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/port.c
index ef34402f6..9f0dc3330 100644
--- a/FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/port.c
+++ b/FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/port.c
@@ -463,6 +463,9 @@ __asm void xPortPendSVHandler( void )
/* Save the new top of stack into the first member of the TCB. */
str r0, [r2]
+ /* Ensure thread safety of atomic operations. */
+ clrex
+
stmdb sp!, {r3}
mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
cpsid i
@@ -695,6 +698,10 @@ void xPortSysTickHandler( void )
}
#endif /* configUSE_TICKLESS_IDLE */
+ /* Stop and clear the SysTick. */
+ portNVIC_SYSTICK_CTRL_REG = 0UL;
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;
+
/* Configure SysTick to interrupt at the requested rate. */
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;
portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );