port-work; won't compile or even work
[ppcskel.git] / sync.c
1 /*
2         BootMii - a Free Software replacement for the Nintendo/BroadOn bootloader.
3         Requires mini.
4
5 Copyright (C) 2008              Segher Boessenkool <segher@kernel.crashing.org>
6
7 # This code is licensed to you under the terms of the GNU GPL, version 2;
8 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
9 */
10
11 #include "bootmii_ppc.h"
12
13 void sync_before_read(void *p, u32 len)
14 {
15         u32 a, b;
16
17         a = (u32)p & ~0x1f;
18         b = ((u32)p + len + 0x1f) & ~0x1f;
19
20         for ( ; a < b; a += 32)
21                 asm("dcbi 0,%0" : : "b"(a));
22
23         asm("sync ; isync");
24 }
25
26 void sync_after_write(const void *p, u32 len)
27 {
28         u32 a, b;
29
30         a = (u32)p & ~0x1f;
31         b = ((u32)p + len + 0x1f) & ~0x1f;
32
33         for ( ; a < b; a += 32)
34                 asm("dcbst 0,%0" : : "b"(a));
35
36         asm("sync ; isync");
37 }
38
39 void sync_before_exec(const void *p, u32 len)
40 {
41         u32 a, b;
42
43         a = (u32)p & ~0x1f;
44         b = ((u32)p + len + 0x1f) & ~0x1f;
45
46         for ( ; a < b; a += 32)
47                 asm("dcbst 0,%0 ; sync ; icbi 0,%0" : : "b"(a));
48
49         asm("sync ; isync");
50 }
51