revert between 56095 -> 55830 in arch
[AROS.git] / arch / i386-pc / exec / cachecleare.c
blob0697e94333787d14487d66065e4faf3da499d918
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: CacheClearE() - Clear the caches with extended control.
6 Lang: english
7 */
9 #include <exec/types.h>
10 #include <exec/execbase.h>
11 #include <aros/libcall.h>
13 void Exec_Wbinvd();
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)
23 INTERNALS
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!
36 AROS_LIBFUNC_INIT
38 /* A full flush has been requested */
39 if (length == 0xFFFFFFFF)
41 Supervisor((ULONG_FUNC)Exec_Wbinvd);
42 return;
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);
53 AROS_LIBFUNC_EXIT
54 } /* CacheClearE */