]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/portable/MPLAB/PIC32MZ/port.c
Ensure the PIC32 interrupt stack is 8 byte aligned for all values of configISR_STACK_...
[freertos] / FreeRTOS / Source / portable / MPLAB / PIC32MZ / port.c
index b573b16d3d2b566dec73f1ad51b56c473f6b247c..69ab7bed6567ff54f30ddb6d9dfcc50e36719dc5 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.\r
+    FreeRTOS V9.0.1 - Copyright (C) 2017 Real Time Engineers Ltd.\r
     All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
  * Implementation of functions defined in portable.h for the PIC32MZ port.\r
   *----------------------------------------------------------*/\r
 \r
+/* Microchip specific headers. */\r
 #include <xc.h>\r
 \r
+/* Standard headers. */\r
+#include <string.h>\r
+\r
 /* Scheduler include files. */\r
 #include "FreeRTOS.h"\r
 #include "task.h"\r
@@ -189,11 +193,13 @@ volatile UBaseType_t uxInterruptNesting = 0x01;
 UBaseType_t uxSavedTaskStackPointer = 0;\r
 \r
 /* The stack used by interrupt service routines that cause a context switch. */\r
-StackType_t xISRStack[ configISR_STACK_SIZE ] = { 0 };\r
+__attribute__ ((aligned(8))) StackType_t xISRStack[ configISR_STACK_SIZE ] = { 0 };\r
 \r
 /* The top of stack value ensures there is enough space to store 6 registers on\r
-the callers stack, as some functions seem to want to do this. */\r
-const StackType_t * const xISRStackTop = &( xISRStack[ configISR_STACK_SIZE - 7 ] );\r
+the callers stack, as some functions seem to want to do this.  8 byte alignment\r
+is required to allow double word floating point stack pushes generated by the\r
+compiler. */\r
+const StackType_t * const xISRStackTop = &( xISRStack[ ( configISR_STACK_SIZE & ~portBYTE_ALIGNMENT_MASK ) - 8 ] );\r
 \r
 /* Saved as part of the task context. Set to pdFALSE if the task does not\r
  require an FPU context. */\r