expression_with_stack_xtensa.c 941 B

1234567891011121314151617181920212223
  1. #include <esp_expression_with_stack.h>
  2. #include <freertos/xtensa_rtos.h>
  3. #include <freertos/xtensa_context.h>
  4. StackType_t * esp_switch_stack_setup(StackType_t *stack, size_t stack_size)
  5. {
  6. int watchpoint_place = (((int)stack + 31) & ~31);
  7. StackType_t *top_of_stack = (StackType_t *)&stack[0] +
  8. ((stack_size * sizeof(StackType_t)) / sizeof(StackType_t));
  9. //Align stack to a 16byte boundary, as required by CPU specific:
  10. top_of_stack = (StackType_t *)(((UBaseType_t)(top_of_stack - 31) -
  11. ALIGNUP(0x10, sizeof(XtSolFrame) )) &
  12. ~0xf);
  13. //Fake stack frame to do not break the backtrace
  14. XtSolFrame *frame = (XtSolFrame *)top_of_stack;
  15. frame->a0 = 0;
  16. frame->a1 = (UBaseType_t)top_of_stack;
  17. esp_set_watchpoint(2, (char*)watchpoint_place, 32, ESP_WATCHPOINT_STORE);
  18. return top_of_stack;
  19. }