From 9091db4e889c6d6f922ef46663109d11e0d12ecd Mon Sep 17 00:00:00 2001 From: richardbarry Date: Mon, 16 Apr 2012 18:23:32 +0000 Subject: [PATCH] Change the stack alignment when a task first starts in the CM4F GCC, Tasking and Keil ports. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1735 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Source/portable/GCC/ARM_CM4F/port.c | 4 ++-- Source/portable/GCC/ARM_CM4F/portmacro.h | 5 +++++ Source/portable/RVDS/ARM_CM4F/port.c | 4 ++-- Source/portable/RVDS/ARM_CM4F/portmacro.h | 4 ++++ Source/portable/Tasking/ARM_CM4F/port.c | 4 ++-- Source/portable/Tasking/ARM_CM4F/portmacro.h | 5 +++++ 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Source/portable/GCC/ARM_CM4F/port.c b/Source/portable/GCC/ARM_CM4F/port.c index 3a6427cae..3b713cb3f 100644 --- a/Source/portable/GCC/ARM_CM4F/port.c +++ b/Source/portable/GCC/ARM_CM4F/port.c @@ -126,7 +126,7 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts, and to ensure alignment. */ - pxTopOfStack -= 2; + pxTopOfStack--; *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ pxTopOfStack--; @@ -138,7 +138,7 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxTopOfStack -= 5; /* R12, R3, R2 and R1. */ *pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */ - /* A save method is being used that requiers each task to maintain its + /* A save method is being used that requires each task to maintain its own exec return value. */ pxTopOfStack--; *pxTopOfStack = portINITIAL_EXEC_RETURN; diff --git a/Source/portable/GCC/ARM_CM4F/portmacro.h b/Source/portable/GCC/ARM_CM4F/portmacro.h index 6b53008fa..9279cf5b1 100644 --- a/Source/portable/GCC/ARM_CM4F/portmacro.h +++ b/Source/portable/GCC/ARM_CM4F/portmacro.h @@ -140,6 +140,11 @@ extern void vPortExitCritical( void ); #define portENABLE_INTERRUPTS() portCLEAR_INTERRUPT_MASK() #define portENTER_CRITICAL() vPortEnterCritical() #define portEXIT_CRITICAL() vPortExitCritical() + +/* There are an uneven number of items on the initial stack, so +portALIGNMENT_ASSERT_pxCurrentTCB() will trigger false positive asserts. */ +#define portALIGNMENT_ASSERT_pxCurrentTCB ( void ) + /*-----------------------------------------------------------*/ /* Task function macros as described on the FreeRTOS.org WEB site. */ diff --git a/Source/portable/RVDS/ARM_CM4F/port.c b/Source/portable/RVDS/ARM_CM4F/port.c index 6e70e1801..35c19313b 100644 --- a/Source/portable/RVDS/ARM_CM4F/port.c +++ b/Source/portable/RVDS/ARM_CM4F/port.c @@ -121,7 +121,7 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts, and to ensure alignment. */ - pxTopOfStack -= 2; + pxTopOfStack--; *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ pxTopOfStack--; @@ -133,7 +133,7 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxTopOfStack -= 5; /* R12, R3, R2 and R1. */ *pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */ - /* A save method is being used that requiers each task to maintain its + /* A save method is being used that requires each task to maintain its own exec return value. */ pxTopOfStack--; *pxTopOfStack = portINITIAL_EXEC_RETURN; diff --git a/Source/portable/RVDS/ARM_CM4F/portmacro.h b/Source/portable/RVDS/ARM_CM4F/portmacro.h index 7b598fd44..8d42c6334 100644 --- a/Source/portable/RVDS/ARM_CM4F/portmacro.h +++ b/Source/portable/RVDS/ARM_CM4F/portmacro.h @@ -117,6 +117,10 @@ extern void vPortExitCritical( void ); #define portSET_INTERRUPT_MASK_FROM_ISR() 0;vPortSetInterruptMask() #define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask();(void)x +/* There are an uneven number of items on the initial stack, so +portALIGNMENT_ASSERT_pxCurrentTCB() will trigger false positive asserts. */ +#define portALIGNMENT_ASSERT_pxCurrentTCB ( void ) + /*-----------------------------------------------------------*/ /* Task function macros as described on the FreeRTOS.org WEB site. */ diff --git a/Source/portable/Tasking/ARM_CM4F/port.c b/Source/portable/Tasking/ARM_CM4F/port.c index 2e34b8737..d7db5c5b8 100644 --- a/Source/portable/Tasking/ARM_CM4F/port.c +++ b/Source/portable/Tasking/ARM_CM4F/port.c @@ -119,7 +119,7 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts, and to ensure alignment. */ - pxTopOfStack -= 2; + pxTopOfStack--; *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ pxTopOfStack--; @@ -131,7 +131,7 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxTopOfStack -= 5; /* R12, R3, R2 and R1. */ *pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */ - /* A save method is being used that requiers each task to maintain its + /* A save method is being used that requires each task to maintain its own exec return value. */ pxTopOfStack--; *pxTopOfStack = portINITIAL_EXEC_RETURN; diff --git a/Source/portable/Tasking/ARM_CM4F/portmacro.h b/Source/portable/Tasking/ARM_CM4F/portmacro.h index 2f671fba1..025bc8d36 100644 --- a/Source/portable/Tasking/ARM_CM4F/portmacro.h +++ b/Source/portable/Tasking/ARM_CM4F/portmacro.h @@ -128,6 +128,11 @@ extern void vPortExitCritical( void ); #define portENABLE_INTERRUPTS() portCLEAR_INTERRUPT_MASK() #define portENTER_CRITICAL() vPortEnterCritical() #define portEXIT_CRITICAL() vPortExitCritical() + +/* There are an uneven number of items on the initial stack, so +portALIGNMENT_ASSERT_pxCurrentTCB() will trigger false positive asserts. */ +#define portALIGNMENT_ASSERT_pxCurrentTCB ( void ) + /*-----------------------------------------------------------*/ /* Task function macros as described on the FreeRTOS.org WEB site. */ -- 2.39.5