root / cache-utils.h @ d29275f1
History | View | Annotate | Download (1.1 kB)
1 | 902b3d5c | malc | #ifndef QEMU_CACHE_UTILS_H
|
---|---|---|---|
2 | 902b3d5c | malc | #define QEMU_CACHE_UTILS_H
|
3 | 902b3d5c | malc | |
4 | e58ffeb3 | malc | #if defined(_ARCH_PPC)
|
5 | 902b3d5c | malc | struct qemu_cache_conf {
|
6 | 902b3d5c | malc | unsigned long dcache_bsize; |
7 | 902b3d5c | malc | unsigned long icache_bsize; |
8 | 902b3d5c | malc | }; |
9 | 902b3d5c | malc | |
10 | 902b3d5c | malc | extern struct qemu_cache_conf qemu_cache_conf; |
11 | 902b3d5c | malc | |
12 | 902b3d5c | malc | extern void qemu_cache_utils_init(char **envp); |
13 | 902b3d5c | malc | |
14 | 902b3d5c | malc | /* mildly adjusted code from tcg-dyngen.c */
|
15 | 902b3d5c | malc | static inline void flush_icache_range(unsigned long start, unsigned long stop) |
16 | 902b3d5c | malc | { |
17 | 902b3d5c | malc | unsigned long p, start1, stop1; |
18 | 902b3d5c | malc | unsigned long dsize = qemu_cache_conf.dcache_bsize; |
19 | 902b3d5c | malc | unsigned long isize = qemu_cache_conf.icache_bsize; |
20 | 902b3d5c | malc | |
21 | 902b3d5c | malc | start1 = start & ~(dsize - 1);
|
22 | 902b3d5c | malc | stop1 = (stop + dsize - 1) & ~(dsize - 1); |
23 | 902b3d5c | malc | for (p = start1; p < stop1; p += dsize) {
|
24 | 902b3d5c | malc | asm volatile ("dcbst 0,%0" : : "r"(p) : "memory"); |
25 | 902b3d5c | malc | } |
26 | 902b3d5c | malc | asm volatile ("sync" : : : "memory"); |
27 | 902b3d5c | malc | |
28 | 902b3d5c | malc | start &= start & ~(isize - 1);
|
29 | 902b3d5c | malc | stop1 = (stop + isize - 1) & ~(isize - 1); |
30 | 902b3d5c | malc | for (p = start1; p < stop1; p += isize) {
|
31 | 902b3d5c | malc | asm volatile ("icbi 0,%0" : : "r"(p) : "memory"); |
32 | 902b3d5c | malc | } |
33 | 902b3d5c | malc | asm volatile ("sync" : : : "memory"); |
34 | 902b3d5c | malc | asm volatile ("isync" : : : "memory"); |
35 | 902b3d5c | malc | } |
36 | 902b3d5c | malc | |
37 | 902b3d5c | malc | #else
|
38 | 902b3d5c | malc | #define qemu_cache_utils_init(envp) do { (void) (envp); } while (0) |
39 | 902b3d5c | malc | #endif
|
40 | 902b3d5c | malc | |
41 | 902b3d5c | malc | #endif /* QEMU_CACHE_UTILS_H */ |