From c21c352f11468a82b4d93ad0ce1f6479fefb51a6 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Tue, 30 Jun 2009 16:32:36 +0000 Subject: [PATCH] Add proper 8 byte alignment support. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@788 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Source/include/portable.h | 4 ++++ Source/portable/MemMang/heap_1.c | 19 +++++-------------- Source/portable/MemMang/heap_2.c | 8 ++++++-- Source/tasks.c | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Source/include/portable.h b/Source/include/portable.h index dca1e9f6f..7498491d8 100644 --- a/Source/include/portable.h +++ b/Source/include/portable.h @@ -220,6 +220,10 @@ #include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h" #endif +#ifdef GCC_PPC440 + #include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h" +#endif + #ifdef _16FX_SOFTUNE #include "..\..\Source\portable\Softune\MB96340\portmacro.h" #endif diff --git a/Source/portable/MemMang/heap_1.c b/Source/portable/MemMang/heap_1.c index 126609b3f..7dff39e50 100644 --- a/Source/portable/MemMang/heap_1.c +++ b/Source/portable/MemMang/heap_1.c @@ -49,19 +49,6 @@ licensing and training services. */ -/* - -Changes between V2.5.1 and V2.5.1 - - + The memory pool has been defined within a struct to ensure correct memory - alignment on 32bit systems. - -Changes between V2.6.1 and V3.0.0 - - + An overflow check has been added to ensure the next free byte variable - does not wrap around. -*/ - /* * The simplest possible implementation of pvPortMalloc(). Note that this @@ -100,7 +87,11 @@ Changes between V2.6.1 and V3.0.0 alignment without using any non-portable code. */ static union xRTOS_HEAP { - volatile unsigned portLONG ulDummy; + #if portBYTE_ALIGNMENT == 8 + volatile portDOUBLE dDummy; + #else + volatile unsigned portLONG ulDummy; + #endif unsigned portCHAR ucHeap[ configTOTAL_HEAP_SIZE ]; } xHeap; diff --git a/Source/portable/MemMang/heap_2.c b/Source/portable/MemMang/heap_2.c index 1dfd66529..4cd92b064 100644 --- a/Source/portable/MemMang/heap_2.c +++ b/Source/portable/MemMang/heap_2.c @@ -88,7 +88,11 @@ alignment without using any non-portable code. */ static union xRTOS_HEAP { - volatile unsigned portLONG ulDummy; + #if portBYTE_ALIGNMENT == 8 + volatile portDOUBLE dDummy; + #else + volatile unsigned portLONG ulDummy; + #endif unsigned portCHAR ucHeap[ configTOTAL_HEAP_SIZE ]; } xHeap; @@ -101,7 +105,7 @@ typedef struct A_BLOCK_LINK } xBlockLink; -static const unsigned portSHORT heapSTRUCT_SIZE = ( sizeof( xBlockLink ) + ( sizeof( xBlockLink ) % portBYTE_ALIGNMENT ) ); +static const unsigned portSHORT heapSTRUCT_SIZE = ( sizeof( xBlockLink ) + portBYTE_ALIGNMENT - ( sizeof( xBlockLink ) % portBYTE_ALIGNMENT ) ); #define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( heapSTRUCT_SIZE * 2 ) ) /* Create a couple of list links to mark the start and end of the list. */ diff --git a/Source/tasks.c b/Source/tasks.c index ec6d36057..37beb15cf 100644 --- a/Source/tasks.c +++ b/Source/tasks.c @@ -391,7 +391,7 @@ tskTCB * pxNewTCB; required by the port. */ #if portSTACK_GROWTH < 0 { - pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 ); + pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 ) - ( ( usStackDepth - 1 ) % portBYTE_ALIGNMENT ); } #else { -- 2.39.2