I am doing some benchmarking and I need to clear the cache before each test. I have this example here:
Caches and Self-Modifying Code
However, I just want to clean the whole cache. Is there an easy way to do that? I do not need to know the start and end address of the functions. I just want some simple code
Thanks.
Ahh, sorry - I had misunderstood your question. No, you can't directly clean/invalidate the caches from User mode. If you're are running under an OS, you will have to make a call to the OS to have it do it for you.
Which OS are you using?
I am using the Linux Kernel 3.7 on a Altera Cyclone V board.
Are you able to say if this is enough to clean the whole cache? Using the example in the OP
uint32_t * code = mmap(
NULL,
32768, // 32kb -- Whole Cache.
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS,
-1,
0);
Hi there,
I know that this is an old post, but I have a related question.
I should clean and invalidate the L2 cache on Cortex A9. Can I use your function? Instead of 32768 I will use 512000, the size of L2 cache.
It works?