2008-12-10 20:18:40 +01:00
|
|
|
#ifndef QEMU_CACHE_UTILS_H
|
|
|
|
#define QEMU_CACHE_UTILS_H
|
|
|
|
|
2009-01-14 19:39:49 +01:00
|
|
|
#if defined(_ARCH_PPC)
|
2012-03-05 21:15:19 +01:00
|
|
|
|
|
|
|
#include <stdint.h> /* uintptr_t */
|
|
|
|
|
2008-12-10 20:18:40 +01:00
|
|
|
struct qemu_cache_conf {
|
|
|
|
unsigned long dcache_bsize;
|
|
|
|
unsigned long icache_bsize;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct qemu_cache_conf qemu_cache_conf;
|
|
|
|
|
2011-01-23 17:21:20 +01:00
|
|
|
void qemu_cache_utils_init(char **envp);
|
2008-12-10 20:18:40 +01:00
|
|
|
|
|
|
|
/* mildly adjusted code from tcg-dyngen.c */
|
2012-03-02 23:30:06 +01:00
|
|
|
static inline void flush_icache_range(uintptr_t start, uintptr_t stop)
|
2008-12-10 20:18:40 +01:00
|
|
|
{
|
|
|
|
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 */
|