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