expression_with_stack_xtensa_asm.S 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include <freertos/xtensa_context.h>
  15. .extern esp_clear_watchpoint
  16. .text
  17. /**
  18. * extern void switch_stack_enter(portSTACK_TYPE *stack, portSTACK_TYPE *backup_stack);
  19. */
  20. .globl esp_switch_stack_enter
  21. .type esp_switch_stack_enter,@function
  22. .align 4
  23. esp_switch_stack_enter:
  24. #ifndef __XTENSA_CALL0_ABI__
  25. entry sp, 0x10
  26. mov a4, a1
  27. s32i a4, a3, 0 /* on a3 there is a safe place to save the current stack */
  28. l32i a4, a2, 0 /* obtains the user allocated stack buffer */
  29. mov a1, a4 /* sp register now contains caller specified stack */
  30. retw
  31. #else
  32. #error "this code is written for Window ABI"
  33. #endif
  34. /**
  35. * extern void switch_stack_exit(portSTACK_TYPE *backup_stack);
  36. */
  37. .globl esp_switch_stack_exit
  38. .type esp_switch_stack_exit,@function
  39. .align 4
  40. esp_switch_stack_exit:
  41. #ifndef __XTENSA_CALL0_ABI__
  42. entry sp, 0x10
  43. l32i a4, a2, 0 /* recover the original task stack */
  44. mov a1, a4 /* put it on sp register again */
  45. retw
  46. #else
  47. #error "this code is written for Window ABI"
  48. #endif