|
43 | 43 | * value is for all interrupts to be enabled. */ |
44 | 44 | #define portINITIAL_SR ( 0UL ) |
45 | 45 |
|
46 | | -/* Dimensions the array into which the floating point context is saved. |
47 | | - * Allocate enough space for FPR0 to FPR15, FPUL and FPSCR, each of which is 4 |
48 | | - * bytes big. If this number is changed then the 72 in portasm.src also needs |
49 | | - * changing. */ |
50 | | -#define portFLOP_REGISTERS_TO_STORE ( 18 ) |
51 | | -#define portFLOP_STORAGE_SIZE ( portFLOP_REGISTERS_TO_STORE * 4 ) |
52 | | - |
53 | 46 | #if ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) |
54 | 47 | #error configSUPPORT_DYNAMIC_ALLOCATION must be 1 to use this port. |
55 | 48 | #endif |
@@ -245,26 +238,35 @@ BaseType_t xPortUsesFloatingPoint( TaskHandle_t xTask ) |
245 | 238 | xTask = ( TaskHandle_t ) pxCurrentTCB; |
246 | 239 | } |
247 | 240 |
|
248 | | - /* Allocate a buffer large enough to hold all the flop registers. */ |
249 | | - pulFlopBuffer = ( uint32_t * ) pvPortMalloc( portFLOP_STORAGE_SIZE ); |
250 | | - |
251 | | - if( pulFlopBuffer != NULL ) |
| 241 | + /* The task tag already owns the FPU buffer for this port. Do not replace |
| 242 | + * it, or the original allocation would become unreachable. */ |
| 243 | + if( xTaskGetApplicationTaskTag( xTask ) != NULL ) |
252 | 244 | { |
253 | | - /* Start with the registers in a benign state. */ |
254 | | - memset( ( void * ) pulFlopBuffer, 0x00, portFLOP_STORAGE_SIZE ); |
255 | | - |
256 | | - /* The first thing to get saved in the buffer is the FPSCR value - |
257 | | - * initialise this to the current FPSCR value. */ |
258 | | - *pulFlopBuffer = get_fpscr(); |
259 | | - |
260 | | - /* Use the task tag to point to the flop buffer. Pass pointer to just |
261 | | - * above the buffer because the flop save routine uses a pre-decrement. */ |
262 | | - vTaskSetApplicationTaskTag( xTask, ( void * ) ( pulFlopBuffer + portFLOP_REGISTERS_TO_STORE ) ); |
263 | 245 | xReturn = pdPASS; |
264 | 246 | } |
265 | 247 | else |
266 | 248 | { |
267 | | - xReturn = pdFAIL; |
| 249 | + /* Allocate a buffer large enough to hold all the flop registers. */ |
| 250 | + pulFlopBuffer = ( uint32_t * ) pvPortMalloc( portFLOP_STORAGE_SIZE ); |
| 251 | + |
| 252 | + if( pulFlopBuffer != NULL ) |
| 253 | + { |
| 254 | + /* Start with the registers in a benign state. */ |
| 255 | + memset( ( void * ) pulFlopBuffer, 0x00, portFLOP_STORAGE_SIZE ); |
| 256 | + |
| 257 | + /* The first thing to get saved in the buffer is the FPSCR value - |
| 258 | + * initialise this to the current FPSCR value. */ |
| 259 | + *pulFlopBuffer = get_fpscr(); |
| 260 | + |
| 261 | + /* Use the task tag to point to the flop buffer. Pass pointer to just |
| 262 | + * above the buffer because the flop save routine uses a pre-decrement. */ |
| 263 | + vTaskSetApplicationTaskTag( xTask, ( void * ) ( pulFlopBuffer + portFLOP_REGISTERS_TO_STORE ) ); |
| 264 | + xReturn = pdPASS; |
| 265 | + } |
| 266 | + else |
| 267 | + { |
| 268 | + xReturn = pdFAIL; |
| 269 | + } |
268 | 270 | } |
269 | 271 |
|
270 | 272 | return xReturn; |
|
0 commit comments