1 #ifndef QEMU_CACHE_UTILS_H
2 #define QEMU_CACHE_UTILS_H
4 #include "config-host.h"
6 #if defined HOST_PPC || defined HOST_PPC64
7 struct qemu_cache_conf
{
8 unsigned long dcache_bsize
;
9 unsigned long icache_bsize
;
12 extern struct qemu_cache_conf qemu_cache_conf
;
14 extern void qemu_cache_utils_init(char **envp
);
16 /* mildly adjusted code from tcg-dyngen.c */
17 static inline void flush_icache_range(unsigned long start
, unsigned long stop
)
19 unsigned long p
, start1
, stop1
;
20 unsigned long dsize
= qemu_cache_conf
.dcache_bsize
;
21 unsigned long isize
= qemu_cache_conf
.icache_bsize
;
23 start1
= start
& ~(dsize
- 1);
24 stop1
= (stop
+ dsize
- 1) & ~(dsize
- 1);
25 for (p
= start1
; p
< stop1
; p
+= dsize
) {
26 asm volatile ("dcbst 0,%0" : : "r"(p
) : "memory");
28 asm volatile ("sync" : : : "memory");
30 start
&= start
& ~(isize
- 1);
31 stop1
= (stop
+ isize
- 1) & ~(isize
- 1);
32 for (p
= start1
; p
< stop1
; p
+= isize
) {
33 asm volatile ("icbi 0,%0" : : "r"(p
) : "memory");
35 asm volatile ("sync" : : : "memory");
36 asm volatile ("isync" : : : "memory");
40 #define qemu_cache_utils_init(envp) do { (void) (envp); } while (0)
43 #endif /* QEMU_CACHE_UTILS_H */