summaryrefslogtreecommitdiff
path: root/emu/Linux/segflush-power.c
blob: 07f9a3cbcb810e3fcddf99ab8ae325de57e5182a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 * from geoff collyer's port
 * invalidate instruction cache and write back data cache from a to a+n-1,
 * at least.
 */
void
segflush(void *a, ulong n)
{
    ulong *p;

    // cache blocks are often eight words (32 bytes) long, sometimes 16 bytes.
    // need to determine it dynamically?
    for (p = (ulong *)((ulong)a & ~3UL); (char *)p < (char *)a + n; p++)
        __asm__("dcbst	0,%0\n\t"	// not dcbf, which writes back, then invalidates
            "icbi	0,%0\n\t"
            : // no output
            : "ar" (p)
            );
     __asm__("sync\n\t"
            : // no output
            :
            );
   __asm__("isync\n\t"
            : // no output
            :
            );
}