summaryrefslogtreecommitdiff
path: root/include/qemu/cache-utils.h
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-12-17 18:20:00 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2012-12-19 08:32:39 +0100
commit1de7afc984b49af164e2619e6850b9732b173b34 (patch)
tree60cd16f527440fcfcdb81d9bea1af5d9147604c4 /include/qemu/cache-utils.h
parent14cccb618508a0aa70eb9ccf366703a019a45ff0 (diff)
downloadqemu-1de7afc984b49af164e2619e6850b9732b173b34.tar.gz
misc: move include files to include/qemu/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/qemu/cache-utils.h')
-rw-r--r--include/qemu/cache-utils.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/include/qemu/cache-utils.h b/include/qemu/cache-utils.h
new file mode 100644
index 0000000000..2c57f78fc1
--- /dev/null
+++ b/include/qemu/cache-utils.h
@@ -0,0 +1,44 @@
+#ifndef QEMU_CACHE_UTILS_H
+#define QEMU_CACHE_UTILS_H
+
+#if defined(_ARCH_PPC)
+
+#include <stdint.h> /* uintptr_t */
+
+struct qemu_cache_conf {
+ unsigned long dcache_bsize;
+ unsigned long icache_bsize;
+};
+
+extern struct qemu_cache_conf qemu_cache_conf;
+
+void qemu_cache_utils_init(char **envp);
+
+/* mildly adjusted code from tcg-dyngen.c */
+static inline void flush_icache_range(uintptr_t start, uintptr_t 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 */