mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 20:41:14 +00:00
FreeRTOS: Make the default stack alignment 16 for Xtensa
This commit is contained in:
@@ -44,6 +44,8 @@
|
||||
#include "esp_gdbstub.h"
|
||||
#endif // CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME
|
||||
|
||||
_Static_assert(portBYTE_ALIGNMENT == 16, "portBYTE_ALIGNMENT must be set to 16");
|
||||
|
||||
/* ---------------------------------------------------- Variables ------------------------------------------------------
|
||||
*
|
||||
* ------------------------------------------------------------------------------------------------------------------ */
|
||||
@@ -703,13 +705,17 @@ StackType_t *pxPortInitialiseStack(StackType_t *pxTopOfStack, TaskFunction_t pxC
|
||||
*/
|
||||
|
||||
UBaseType_t uxStackPointer = (UBaseType_t)pxTopOfStack;
|
||||
configASSERT((uxStackPointer & portBYTE_ALIGNMENT_MASK) == 0);
|
||||
|
||||
// Initialize GCC TLS area
|
||||
uint32_t threadptr_reg_init;
|
||||
uxStackPointer = uxInitialiseStackTLS(uxStackPointer, &threadptr_reg_init);
|
||||
configASSERT((uxStackPointer & portBYTE_ALIGNMENT_MASK) == 0);
|
||||
|
||||
// Initialize the starting interrupt stack frame
|
||||
uxStackPointer = uxInitialiseStackFrame(uxStackPointer, pxCode, pvParameters, threadptr_reg_init);
|
||||
configASSERT((uxStackPointer & portBYTE_ALIGNMENT_MASK) == 0);
|
||||
|
||||
// Return the task's current stack pointer address which should point to the starting interrupt stack frame
|
||||
return (StackType_t *)uxStackPointer;
|
||||
//TODO: IDF-2393
|
||||
|
@@ -72,7 +72,7 @@ typedef uint32_t TickType_t;
|
||||
#define portCRITICAL_NESTING_IN_TCB 1
|
||||
#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() //Todo: Check if XT_NOP exists
|
||||
|
||||
/* ---------------------------------------------- Forward Declarations -------------------------------------------------
|
||||
|
@@ -50,6 +50,8 @@
|
||||
#include "hal/systimer_ll.h"
|
||||
#endif // CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER
|
||||
|
||||
_Static_assert(portBYTE_ALIGNMENT == 16, "portBYTE_ALIGNMENT must be set to 16");
|
||||
|
||||
/*
|
||||
OS state variables
|
||||
*/
|
||||
@@ -884,18 +886,23 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
|
||||
*/
|
||||
|
||||
UBaseType_t uxStackPointer = (UBaseType_t)pxTopOfStack;
|
||||
configASSERT((uxStackPointer & portBYTE_ALIGNMENT_MASK) == 0);
|
||||
|
||||
#if XCHAL_CP_NUM > 0
|
||||
// Initialize the coprocessor save area
|
||||
uxStackPointer = uxInitialiseStackCPSA(uxStackPointer);
|
||||
configASSERT((uxStackPointer & portBYTE_ALIGNMENT_MASK) == 0);
|
||||
#endif /* XCHAL_CP_NUM > 0 */
|
||||
|
||||
// Initialize the GCC TLS area
|
||||
uint32_t threadptr_reg_init;
|
||||
uxStackPointer = uxInitialiseStackTLS(uxStackPointer, &threadptr_reg_init);
|
||||
configASSERT((uxStackPointer & portBYTE_ALIGNMENT_MASK) == 0);
|
||||
|
||||
// Initialize the starting interrupt stack frame
|
||||
uxStackPointer = uxInitialiseStackFrame(uxStackPointer, pxCode, pvParameters, threadptr_reg_init);
|
||||
configASSERT((uxStackPointer & portBYTE_ALIGNMENT_MASK) == 0);
|
||||
|
||||
// Return the task's current stack pointer address which should point to the starting interrupt stack frame
|
||||
return (StackType_t *)uxStackPointer;
|
||||
}
|
||||
|
Reference in New Issue
Block a user