2019-11-27 16:52:27 +00:00
|
|
|
#include <esp_expression_with_stack.h>
|
|
|
|
#include <freertos/xtensa_rtos.h>
|
|
|
|
#include <freertos/xtensa_context.h>
|
|
|
|
|
|
|
|
StackType_t * esp_switch_stack_setup(StackType_t *stack, size_t stack_size)
|
|
|
|
{
|
|
|
|
int watchpoint_place = (((int)stack + 31) & ~31);
|
|
|
|
StackType_t *top_of_stack = (StackType_t *)&stack[0] +
|
2019-12-20 16:23:47 +00:00
|
|
|
((stack_size * sizeof(StackType_t)) / sizeof(StackType_t));
|
2019-11-27 16:52:27 +00:00
|
|
|
|
|
|
|
//Align stack to a 16byte boundary, as required by CPU specific:
|
2019-12-04 14:25:02 +00:00
|
|
|
top_of_stack = (StackType_t *)(((UBaseType_t)(top_of_stack - 31) -
|
2019-11-27 16:52:27 +00:00
|
|
|
ALIGNUP(0x10, sizeof(XtSolFrame) )) &
|
|
|
|
~0xf);
|
|
|
|
|
|
|
|
//Fake stack frame to do not break the backtrace
|
|
|
|
XtSolFrame *frame = (XtSolFrame *)top_of_stack;
|
|
|
|
frame->a0 = 0;
|
|
|
|
frame->a1 = (UBaseType_t)top_of_stack;
|
|
|
|
|
|
|
|
esp_set_watchpoint(2, (char*)watchpoint_place, 32, ESP_WATCHPOINT_STORE);
|
|
|
|
return top_of_stack;
|
|
|
|
}
|