expression_with_stack_xtensa_asm.S 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 xtensa_shared_stack
  16. .extern xtensa_shared_stack_callback
  17. .extern xtensa_shared_stack_function_done
  18. .extern xtensa_shared_stack_env
  19. .extern longjmp
  20. .text
  21. /* extern void esp_shared_stack_invoke_function(void) */
  22. .globl esp_shared_stack_invoke_function
  23. .type esp_shared_stack_invoke_function,@function
  24. .align 4
  25. esp_shared_stack_invoke_function:
  26. #ifndef __XTENSA_CALL0_ABI__
  27. movi a0, 0 /* must not rotate the window here, */
  28. /* the state of execution for shared stack */
  29. /* functions will be completely destroyed at end */
  30. movi a6, xtensa_shared_stack
  31. l32i sp, a6, 0 /* load shared stack pointer */
  32. movi a12, xtensa_shared_stack_callback
  33. l32i a12, a12, 0
  34. callx4 a12 /* call user function */
  35. movi a6, xtensa_shared_stack_function_done
  36. movi a7, 1
  37. s32i a7, a6, 0 /* hint the function was finished */
  38. movi a6, xtensa_shared_stack_env
  39. movi a7, 0
  40. movi a12, longjmp
  41. callx4 a12 /* jump to last clean state previously saved */
  42. ret
  43. #else
  44. #error "this code is written for Window ABI"
  45. #endif