Post by m***@yahoo.comDoes anybody know how can I invalidate content of the cache in user
space = user process/thread? Thanks.
There are semi-architected instructions called dcb* and icb* that deal
with cache lines. E.g., here's how I ensure that the I-cache does not
constain stale lines:
#include <stddef.h>
#include <sys/types.h>
/* the name is from an AIX (4.3) call (thanks to Dan Prener
<***@watson.ibm.com> for this information) */
void _sync_cache_range(caddr_t addr, size_t size)
{
size_t cache_block_size=32;
caddr_t p=(caddr_t)(((long)addr)&-cache_block_size);
/* this works for a single-processor PPC 604e, but may have
portability problems for other machines; the ultimate solution is
a system call, because the architecture is pretty shoddy in this
area */
for (; p < (addr+size); p+=cache_block_size)
asm("dcbst 0,%0\n sync\n icbi 0,%0"::"r"(p));
asm("sync\n isync"); /* PPC 604e needs the additional sync
according to Tim Olson */
}
The sync between the dcbst and the icbi ensures that the I-cache is
not reloaded from memory before the D-cache has stored its data to
memory. For larger blocks, it is faster to do all the dcbsts, then
one sync, then all the icbis.
Despite the comment about the non-portabilty, this seems to work on
all PPCs I have tried.
- anton
--
M. Anton Ertl Some things have to be seen to be believed
***@mips.complang.tuwien.ac.at Most things have to be believed to be seen
http://www.complang.tuwien.ac.at/anton/home.html