summaryrefslogtreecommitdiffstats
path: root/source/sync.c
blob: f22827e475089f2f0450dca7ff89e14308622cf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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");
}