test_context_save_clobber.S 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* Helper function for the test case in test_context_save_clobber.c */
  2. #if defined(__XTENSA__)
  3. #include "xtensa/config/core-isa.h"
  4. #if defined(XCHAL_HAVE_WINDOWED)
  5. .data
  6. recursion_count:
  7. .word 0
  8. .text
  9. .global test_context_save_clober_func
  10. .type test_context_save_clober_func,@function
  11. .align 4
  12. /* This function recursively calls itself via call4, making sure each frame
  13. * uses only 4 registers. For this reason, recursion count can not be
  14. * a function argument (it would have to be in a6) and is placed into .data
  15. * section above.
  16. */
  17. test_context_save_clober_func:
  18. entry a1, 16
  19. /* load recursion count from memory */
  20. movi a3, recursion_count
  21. l32i a2, a3, 0
  22. /* if it is zero, initialize it to 16 (=64 physical registers / 4 registers per call) */
  23. bnez a2, 1f
  24. movi a2, 16
  25. 1:
  26. /* decrement the counter and write it back */
  27. addi a2, a2, -1
  28. s32i a2, a3, 0
  29. /* counter not zero? do a recursive call */
  30. beqz a2, wait
  31. call4 test_context_save_clober_func
  32. j end
  33. wait:
  34. /* Counter has reached zero, and we have 16 frames on the stack.
  35. * Delay for a few seconds, expecting in interrupt to happen.
  36. */
  37. movi a3, 100000000
  38. 1:
  39. addi a3, a3, -1
  40. bnez a3, 1b
  41. end:
  42. retw
  43. #endif // XCHAL_HAVE_WINDOWED
  44. #endif // __XTENSA__