diff options
author | malc <malc@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-12-10 19:18:40 +0000 |
---|---|---|
committer | malc <malc@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-12-10 19:18:40 +0000 |
commit | 902b3d5c392bb6f48ef340ad8ecc3311705d2800 (patch) | |
tree | cad585902aebf14be473f75fe5bf9c09b4e1b7a1 /cache-utils.h | |
parent | 4fbfcd6d53cffc5cde141df7afa9045a4987b5cd (diff) | |
download | qemu-902b3d5c392bb6f48ef340ad8ecc3311705d2800.tar.gz qemu-902b3d5c392bb6f48ef340ad8ecc3311705d2800.tar.bz2 qemu-902b3d5c392bb6f48ef340ad8ecc3311705d2800.zip |
Introduce and use cache-utils.[ch]
Thanks to Segher Boessenkool and Holis Blanchard.
AIX and Darwin cache inquiry:
http://gcc.gnu.org/ml/gcc-patches/2007-08/msg00388.html
Auxiliary vectors:
http://manugarg.googlepages.com/aboutelfauxiliaryvectors
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5973 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'cache-utils.h')
-rw-r--r-- | cache-utils.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/cache-utils.h b/cache-utils.h new file mode 100644 index 0000000000..0598b96eba --- /dev/null +++ b/cache-utils.h @@ -0,0 +1,41 @@ +#ifndef QEMU_CACHE_UTILS_H +#define QEMU_CACHE_UTILS_H + +#ifdef __powerpc__ +struct qemu_cache_conf { + unsigned long dcache_bsize; + unsigned long icache_bsize; +}; + +extern struct qemu_cache_conf qemu_cache_conf; + +extern void qemu_cache_utils_init(char **envp); + +/* mildly adjusted code from tcg-dyngen.c */ +static inline void flush_icache_range(unsigned long start, unsigned long stop) +{ + unsigned long p, start1, stop1; + unsigned long dsize = qemu_cache_conf.dcache_bsize; + unsigned long isize = qemu_cache_conf.icache_bsize; + + start1 = start & ~(dsize - 1); + stop1 = (stop + dsize - 1) & ~(dsize - 1); + for (p = start1; p < stop1; p += dsize) { + asm volatile ("dcbst 0,%0" : : "r"(p) : "memory"); + } + asm volatile ("sync" : : : "memory"); + + start &= start & ~(isize - 1); + stop1 = (stop + isize - 1) & ~(isize - 1); + for (p = start1; p < stop1; p += isize) { + asm volatile ("icbi 0,%0" : : "r"(p) : "memory"); + } + asm volatile ("sync" : : : "memory"); + asm volatile ("isync" : : : "memory"); +} + +#else +#define qemu_cache_utils_init(envp) do { (void) (envp); } while (0) +#endif + +#endif /* QEMU_CACHE_UTILS_H */ |