2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
5 Desc: CacheClearE() - Clear the caches with extended control.
9 #include <aros/config.h>
10 #include <exec/types.h>
11 #include <exec/execbase.h>
12 #include <aros/libcall.h>
14 #include "kernel_syscall.h"
16 #include <proto/exec.h>
18 /* See rom/exec/cachecleare.c for documentation */
20 AROS_LH3(void, CacheClearE
,
21 AROS_LHA(APTR
, address
, A0
),
22 AROS_LHA(ULONG
, length
, D0
),
23 AROS_LHA(ULONG
, caches
, D1
),
24 struct ExecBase
*, SysBase
, 107, Exec
)
28 char *start
= (char*)((IPTR
)address
& 0xffffffe0);
29 char *end
= (char*)(((IPTR
)address
+ length
+ 31) & 0xffffffe0);
32 /* Flush data caches and mark cache lines invalid */
33 if (caches
& CACRF_ClearD
)
35 for (ptr
= start
; ptr
< end
; ptr
+=32)
37 asm volatile("dcbf 0,%0"::"r"(ptr
));
42 #if (AROS_FLAVOUR & AROS_FLAVOUR_STANDALONE)
43 if (caches
& CACRF_InvalidateD
)
45 register APTR addr
asm ("r4") = address
;
46 register ULONG len
asm ("r5") = length
;
47 asm volatile("li %%r3,%0; sc"::"i"(SC_INVALIDATED
),"r"(addr
),"r"(len
):"memory","r3");
51 if (caches
& CACRF_ClearI
) /* Clear ICache with DCache together */
53 for (ptr
= start
; ptr
< end
; ptr
+=32)
55 asm volatile("icbi 0,%0"::"r"(ptr
));
58 asm volatile("sync; isync; ");