FreeRTOS: Make the default stack alignment 16 for Xtensa

This commit is contained in:
Omar Chebib 2022-11-11 15:00:42 +08:00
parent 7ae5ec946d
commit b2ddedb941
3 changed files with 8 additions and 2 deletions

View File

@ -95,7 +95,7 @@
#include "portmacro.h"
#include "port_systick.h"
_Static_assert(portBYTE_ALIGNMENT == 16, "portBYTE_ALIGNMENT must be set to 16");
/* ---------------------------------------------------- Variables ------------------------------------------------------
*
@ -248,6 +248,8 @@ StackType_t *pxPortInitialiseStack(StackType_t *pxTopOfStack, TaskFunction_t pxC
frame->gp = (UBaseType_t)&__global_pointer$;
frame->tp = (UBaseType_t)threadptr;
configASSERT(((uint32_t) frame & portBYTE_ALIGNMENT_MASK) == 0);
//TODO: IDF-2393
return (StackType_t *)frame;
}

View File

@ -106,7 +106,7 @@ typedef uint32_t TickType_t;
#define portCRITICAL_NESTING_IN_TCB 0
#define portSTACK_GROWTH ( -1 )
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
#define portBYTE_ALIGNMENT 4
#define portBYTE_ALIGNMENT 16 // Xtensa Windowed ABI requires the stack pointer to always be 16-byte aligned. See "isa_rm.pdf 8.1.1 Windowed Register Usage and Stack Layout"
#define portNOP() XT_NOP()

View File

@ -66,6 +66,8 @@
#include "task.h" /* Required for TaskHandle_t, tskNO_AFFINITY, and vTaskStartScheduler */
#include "port_systick.h"
_Static_assert(portBYTE_ALIGNMENT == 16, "portBYTE_ALIGNMENT must be set to 16");
_Static_assert(tskNO_AFFINITY == CONFIG_FREERTOS_NO_AFFINITY, "incorrect tskNO_AFFINITY value");
@ -241,6 +243,8 @@ StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t px
p[2] = (((uint32_t) p) + 12 + XCHAL_TOTAL_SA_ALIGN - 1) & -XCHAL_TOTAL_SA_ALIGN;
#endif /* XCHAL_CP_NUM */
configASSERT(((uint32_t) sp & portBYTE_ALIGNMENT_MASK) == 0);
return sp;
}