Statistics
| Branch: | Revision:

root / cache-utils.h @ 395f153d

History | View | Annotate | Download (1.2 kB)

1
#ifndef QEMU_CACHE_UTILS_H
2
#define QEMU_CACHE_UTILS_H
3

    
4
#include "config-host.h"
5

    
6
#if defined HOST_PPC || defined HOST_PPC64
7
struct qemu_cache_conf {
8
    unsigned long dcache_bsize;
9
    unsigned long icache_bsize;
10
};
11

    
12
extern struct qemu_cache_conf qemu_cache_conf;
13

    
14
extern void qemu_cache_utils_init(char **envp);
15

    
16
/* mildly adjusted code from tcg-dyngen.c */
17
static inline void flush_icache_range(unsigned long start, unsigned long stop)
18
{
19
    unsigned long p, start1, stop1;
20
    unsigned long dsize = qemu_cache_conf.dcache_bsize;
21
    unsigned long isize = qemu_cache_conf.icache_bsize;
22

    
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");
27
    }
28
    asm volatile ("sync" : : : "memory");
29

    
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");
34
    }
35
    asm volatile ("sync" : : : "memory");
36
    asm volatile ("isync" : : : "memory");
37
}
38

    
39
#else
40
#define qemu_cache_utils_init(envp) do { (void) (envp); } while (0)
41
#endif
42

    
43
#endif /* QEMU_CACHE_UTILS_H */