This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Clean Whole Cache on Cortex-A9

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.

Parents
  • > The ARMv7-A/R Architecture gives an example sequence for cleaning the entire data and unified cache, using set/way operations


    Hmm - this isn't guaranteed to work portably. On a single-core system you'll get away with it, but the set/way maintenance operations are not guaranteed to be SMP-safe. The only "architecturally sound" means to clean/clean-invalidate the cache in an SMP system once it is up and running is use the "by VA" operations.


    *EDIT* Also note that by default the data memory allocations returned to an application in Linux is marked "XN" in the MMU (eXecute Never) - the data pages are not executable. IIRC you'll need to make some special memory allocation calls with the kernel to get some executable memory.


    HTH,

    Pete

Reply
  • > The ARMv7-A/R Architecture gives an example sequence for cleaning the entire data and unified cache, using set/way operations


    Hmm - this isn't guaranteed to work portably. On a single-core system you'll get away with it, but the set/way maintenance operations are not guaranteed to be SMP-safe. The only "architecturally sound" means to clean/clean-invalidate the cache in an SMP system once it is up and running is use the "by VA" operations.


    *EDIT* Also note that by default the data memory allocations returned to an application in Linux is marked "XN" in the MMU (eXecute Never) - the data pages are not executable. IIRC you'll need to make some special memory allocation calls with the kernel to get some executable memory.


    HTH,

    Pete

Children