2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
5 Desc: CacheClearE() - Clear the caches with extended control.
9 #include <exec/types.h>
10 #include <exec/execbase.h>
11 #include <aros/libcall.h>
15 #include <proto/exec.h>
17 AROS_LH3(void, CacheClearE
,
18 AROS_LHA(APTR
, address
, A0
),
19 AROS_LHA(ULONG
, length
, D0
),
20 AROS_LHA(ULONG
, caches
, D1
),
21 struct ExecBase
*, SysBase
, 107, Exec
)
24 Although this function is not needed for BM-DMA on x86 due to
25 strong cache coherency (the CPU snoops the address lines and
26 invalidates all out-of-date cache), it is needed for some other
27 operations. For example, when updating graphics memory address
28 translation tables, changes may be invisible to the graphics
29 card/chip if not explicitly written back from the cache.
31 Drivers performing DMA operations should use
32 CachePreDMA()/CachePostDMA() instead, which maximise performance
33 on x86 by doing nothing!
38 /* A full flush has been requested */
39 if (length
== 0xFFFFFFFF)
41 Supervisor((ULONG_FUNC
)Exec_Wbinvd
);
45 /* A partial flush requested */
46 if (caches
& CACRF_ClearD
)
48 /* TODO: Detect if CPU supports clflush instruction and use it instead
49 of wbinvd to provide more optimized cache flushes */
50 Supervisor((ULONG_FUNC
)Exec_Wbinvd
);