expression_with_stack_xtensa_asm.S 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. movi a6, 2
  44. movi a4, esp_clear_watchpoint
  45. callx4 a4 /* clear the watchpoint before releasing stack */
  46. l32i a4, a2, 0 /* recover the original task stack */
  47. mov a1, a4 /* put it on sp register again */
  48. retw
  49. #else
  50. #error "this code is written for Window ABI"
  51. #endif