test_fastbus_asm.S 992 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "sdkconfig.h"
  2. #if CONFIG_IDF_TARGET_ESP32
  3. /*
  4. This little bit of code is executed in-place by one CPU, but copied to a different memory region
  5. by the other CPU. Make sure it stays position-independent.
  6. */
  7. .text
  8. .align 4
  9. .global test_fastbus_cp
  10. .type test_fastbus_cp,@function
  11. //Args:
  12. //a2 - fifo addr
  13. //a3 - buf addr
  14. //a4 - len
  15. //a5 - ptr to int to use
  16. test_fastbus_cp:
  17. entry a1,64
  18. back:
  19. beqi a4, 0, out //check if loop done
  20. s32i a4, a5, 0 //store value, for shits and/or giggles
  21. memw //make sure write happens
  22. l32i a4, a5, 0 //load value again, to thwart any prediction in the pipeline
  23. bbsi a4, 0, pred //Random jump to check predictive reads. Both branches should do the same.
  24. l32i a6, a2, 0 //read from fifo 1
  25. j predout
  26. pred:
  27. l32i a6, a2, 0 //read from fifo 2
  28. predout:
  29. s8i a6, a3, 0 //store result
  30. addi a3, a3, 1 //inc ptr
  31. addi a4, a4, -1 //next
  32. j back //loop again
  33. out:
  34. retw //and we are done
  35. #endif // CONFIG_IDF_TARGET_ESP32