From: rtel Date: Sun, 9 Apr 2017 20:13:48 +0000 (+0000) Subject: Ensure the PIC32 interrupt stack is 8 byte aligned for all values of configISR_STACK_... X-Git-Tag: V10.0.0~22 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a03adc4e5a6bd0ece2b5e6d3796649b381a347e4;p=freertos Ensure the PIC32 interrupt stack is 8 byte aligned for all values of configISR_STACK_SIZE. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2497 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MX/port.c b/FreeRTOS/Source/portable/MPLAB/PIC32MX/port.c index 8a3b4fceb..913df4048 100644 --- a/FreeRTOS/Source/portable/MPLAB/PIC32MX/port.c +++ b/FreeRTOS/Source/portable/MPLAB/PIC32MX/port.c @@ -188,11 +188,11 @@ volatile UBaseType_t uxInterruptNesting = 0x01; UBaseType_t uxSavedTaskStackPointer = 0; /* The stack used by interrupt service routines that cause a context switch. */ -StackType_t xISRStack[ configISR_STACK_SIZE ] = { 0 }; +__attribute__ ((aligned(8))) StackType_t xISRStack[ configISR_STACK_SIZE ] = { 0 }; /* The top of stack value ensures there is enough space to store 6 registers on the callers stack, as some functions seem to want to do this. */ -const StackType_t * const xISRStackTop = &( xISRStack[ configISR_STACK_SIZE - 7 ] ); +const StackType_t * const xISRStackTop = &( xISRStack[ ( configISR_STACK_SIZE & ~portBYTE_ALIGNMENT_MASK ) - 8 ] ); /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MX/portmacro.h b/FreeRTOS/Source/portable/MPLAB/PIC32MX/portmacro.h index 994601b4c..801ed8731 100644 --- a/FreeRTOS/Source/portable/MPLAB/PIC32MX/portmacro.h +++ b/FreeRTOS/Source/portable/MPLAB/PIC32MX/portmacro.h @@ -198,7 +198,7 @@ extern void vPortClearInterruptMaskFromISR( UBaseType_t ); /*-----------------------------------------------------------*/ - #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - _clz( ( uxReadyPriorities ) ) ) + #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - _clz( ( uxReadyPriorities ) ) ) #endif /* taskRECORD_READY_PRIORITY */ diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MZ/port.c b/FreeRTOS/Source/portable/MPLAB/PIC32MZ/port.c index b573b16d3..69ab7bed6 100644 --- a/FreeRTOS/Source/portable/MPLAB/PIC32MZ/port.c +++ b/FreeRTOS/Source/portable/MPLAB/PIC32MZ/port.c @@ -1,5 +1,5 @@ /* - FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. + FreeRTOS V9.0.1 - Copyright (C) 2017 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. @@ -71,8 +71,12 @@ * Implementation of functions defined in portable.h for the PIC32MZ port. *----------------------------------------------------------*/ +/* Microchip specific headers. */ #include +/* Standard headers. */ +#include + /* Scheduler include files. */ #include "FreeRTOS.h" #include "task.h" @@ -189,11 +193,13 @@ volatile UBaseType_t uxInterruptNesting = 0x01; UBaseType_t uxSavedTaskStackPointer = 0; /* The stack used by interrupt service routines that cause a context switch. */ -StackType_t xISRStack[ configISR_STACK_SIZE ] = { 0 }; +__attribute__ ((aligned(8))) StackType_t xISRStack[ configISR_STACK_SIZE ] = { 0 }; /* The top of stack value ensures there is enough space to store 6 registers on -the callers stack, as some functions seem to want to do this. */ -const StackType_t * const xISRStackTop = &( xISRStack[ configISR_STACK_SIZE - 7 ] ); +the callers stack, as some functions seem to want to do this. 8 byte alignment +is required to allow double word floating point stack pushes generated by the +compiler. */ +const StackType_t * const xISRStackTop = &( xISRStack[ ( configISR_STACK_SIZE & ~portBYTE_ALIGNMENT_MASK ) - 8 ] ); /* Saved as part of the task context. Set to pdFALSE if the task does not require an FPU context. */ diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MZ/portmacro.h b/FreeRTOS/Source/portable/MPLAB/PIC32MZ/portmacro.h index bb317f886..26e79b196 100644 --- a/FreeRTOS/Source/portable/MPLAB/PIC32MZ/portmacro.h +++ b/FreeRTOS/Source/portable/MPLAB/PIC32MZ/portmacro.h @@ -209,7 +209,7 @@ extern void vPortClearInterruptMaskFromISR( UBaseType_t ); /*-----------------------------------------------------------*/ - #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - _clz( ( uxReadyPriorities ) ) ) + #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - _clz( ( uxReadyPriorities ) ) ) #endif /* taskRECORD_READY_PRIORITY */