File tree Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -176,7 +176,7 @@ void _xt_user_exit( void );
176176 #endif
177177
178178 /* Create interrupt stack frame aligned to 16 byte boundary */
179- sp = ( StackType_t * ) ( ( ( UBaseType_t ) ( pxTopOfStack + 1 ) - XT_CP_SIZE - XT_STK_FRMSZ ) & ~0xf );
179+ sp = ( StackType_t * ) ( ( ( UBaseType_t ) pxTopOfStack - XT_CP_SIZE - XT_STK_FRMSZ ) & ~0xf );
180180
181181 /* Clear the entire frame (do not use memset() because we don't depend on C library) */
182182 for ( tp = sp ; tp <= pxTopOfStack ; ++ tp )
@@ -229,6 +229,7 @@ void _xt_user_exit( void );
229229 * //p = (uint32_t *) xMPUSettings->coproc_area;
230230 */
231231 p = ( uint32_t * ) ( ( ( uint32_t ) pxTopOfStack - XT_CP_SIZE ) & ~0xf );
232+ configASSERT ( ( uint32_t ) p >= frame -> a1 );
232233 p [ 0 ] = 0 ;
233234 p [ 1 ] = 0 ;
234235 p [ 2 ] = ( ( ( uint32_t ) p ) + 12 + XCHAL_TOTAL_SA_ALIGN - 1 ) & - XCHAL_TOTAL_SA_ALIGN ;
@@ -319,7 +320,9 @@ void vPortYieldOtherCore( BaseType_t coreid )
319320 uint32_t usStackDepth )
320321 {
321322 #if XCHAL_CP_NUM > 0
322- xMPUSettings -> coproc_area = ( StackType_t * ) ( ( ( ( uint32_t ) ( pxBottomOfStack + usStackDepth - 1 ) ) - XT_CP_SIZE ) & ~0xf );
323+ xMPUSettings -> coproc_area = ( StackType_t * ) ( ( uint32_t ) ( pxBottomOfStack + usStackDepth - 1 ));
324+ xMPUSettings -> coproc_area = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) xMPUSettings -> coproc_area ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );
325+ xMPUSettings -> coproc_area = ( StackType_t * ) ( ( ( uint32_t ) xMPUSettings -> coproc_area - XT_CP_SIZE ) & ~0xf );
323326
324327
325328 /* NOTE: we cannot initialize the coprocessor save area here because FreeRTOS is going to
Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ void _xt_user_exit( void );
157157 #endif
158158
159159 /* Create interrupt stack frame aligned to 16 byte boundary */
160- sp = ( StackType_t * ) ( ( ( UBaseType_t ) ( pxTopOfStack + 1 ) - XT_CP_SIZE - XT_STK_FRMSZ ) & ~0xf );
160+ sp = ( StackType_t * ) ( ( ( UBaseType_t ) pxTopOfStack - XT_CP_SIZE - XT_STK_FRMSZ ) & ~0xf );
161161
162162 /* Clear the entire frame (do not use memset() because we don't depend on C library) */
163163 for ( tp = sp ; tp <= pxTopOfStack ; ++ tp )
@@ -196,6 +196,7 @@ void _xt_user_exit( void );
196196 * //p = (uint32_t *) xMPUSettings->coproc_area;
197197 */
198198 p = ( uint32_t * ) ( ( ( uint32_t ) pxTopOfStack - XT_CP_SIZE ) & ~0xf );
199+ configASSERT ( ( uint32_t ) p >= frame -> a1 );
199200 p [ 0 ] = 0 ;
200201 p [ 1 ] = 0 ;
201202 p [ 2 ] = ( ( ( uint32_t ) p ) + 12 + XCHAL_TOTAL_SA_ALIGN - 1 ) & - XCHAL_TOTAL_SA_ALIGN ;
@@ -286,9 +287,11 @@ void vPortYieldOtherCore( BaseType_t coreid )
286287 uint32_t usStackDepth )
287288 {
288289 #if XCHAL_CP_NUM > 0
289- xMPUSettings -> coproc_area = ( StackType_t * ) ( ( ( ( uint32_t ) ( pxBottomOfStack + usStackDepth - 1 ) ) - XT_CP_SIZE ) & ~0xf );
290-
290+ xMPUSettings -> coproc_area = ( StackType_t * ) ( ( uint32_t ) ( pxBottomOfStack + usStackDepth - 1 ));
291+ xMPUSettings -> coproc_area = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) xMPUSettings -> coproc_area ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );
292+ xMPUSettings -> coproc_area = ( StackType_t * ) ( ( ( uint32_t ) xMPUSettings -> coproc_area - XT_CP_SIZE ) & ~0xf );
291293
294+
292295 /* NOTE: we cannot initialize the coprocessor save area here because FreeRTOS is going to
293296 * clear the stack area after we return. This is done in pxPortInitialiseStack().
294297 */
Original file line number Diff line number Diff line change @@ -220,7 +220,7 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
220220 #if XCHAL_CP_NUM > 0
221221 xMPUSettings -> coproc_area = ( StackType_t * ) ( ( uint32_t ) ( pxBottomOfStack + ulStackDepth - 1 ));
222222 xMPUSettings -> coproc_area = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) xMPUSettings -> coproc_area ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );
223- xMPUSettings -> coproc_area = ( Stacktype_t * ) ( ( ( uint32_t ) xMPUSettings -> coproc_area - XT_CP_SIZE ) & ~0xf );
223+ xMPUSettings -> coproc_area = ( StackType_t * ) ( ( ( uint32_t ) xMPUSettings -> coproc_area - XT_CP_SIZE ) & ~0xf );
224224
225225 /* NOTE: we cannot initialize the coprocessor save area here because FreeRTOS is going to
226226 * clear the stack area after we return. This is done in pxPortInitialiseStack().
You can’t perform that action at this time.
0 commit comments