diff options
Diffstat (limited to 'source/sync.c')
-rw-r--r-- | source/sync.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/sync.c b/source/sync.c new file mode 100644 index 0000000..f22827e --- /dev/null +++ b/source/sync.c @@ -0,0 +1,18 @@ +#include <stdint.h> + +//Originally written by Segher, but I changed the function enough to be "mine" +void sync_before_exec(const void *p, uint32_t len) +{ + uint32_t x, y; + + x = (uint32_t)p & ~0x1f; + y = ((uint32_t)p + len + 0x1f) & ~0x1f; + + while(x < y) + { + asm("dcbst 0,%0 ; sync ; icbi 0,%0" : : "b"(x)); + x += 32; + } + + asm("sync ; isync"); +} |