2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: CacheClearU - Simple way of clearing the caches.
9 #include <exec/types.h>
10 #include <exec/execbase.h>
11 #include <aros/libcall.h>
13 extern void AROS_SLIB_ENTRY(CacheClearU_00
,Exec
,106)(void);
14 extern void AROS_SLIB_ENTRY(CacheClearU_20
,Exec
,106)(void);
15 extern void AROS_SLIB_ENTRY(CacheClearU_40
,Exec
,106)(void);
16 extern void AROS_SLIB_ENTRY(CacheClearU_60
,Exec
,106)(void);
17 /*****************************************************************************
20 #include <proto/exec.h>
22 AROS_LH0(void, CacheClearU
,
25 struct ExecBase
*, SysBase
, 106, Exec
)
28 Flush the entire contents of the CPU instruction and data caches.
29 If some of the cache contains dirty data, push it to memory first.
31 For most systems DMA will not effect processor caches. If *any*
32 external (non-processor) event changes system memory, you MUST
33 clear the cache. For example:
36 Code relocation to run at a different address
38 Loading code from disk
43 The caches will be flushed.
46 It is possible that on some systems the entire cache will be
47 even if this was not the specific request.
54 CacheClearE(), CacheControl(), CachePreDMA(), CachePostDMA()
57 Although it is not necessary, but it could be more efficient if
58 this function was replaced by a function in $(KERNEL).
60 ******************************************************************************/
65 if (SysBase
->LibNode
.lib_OpenCnt
== 0)
66 /* We were called from PrepareExecBase. AttnFlags isn't set yet.
67 * Do nothing or we would always install 68000 routine.
68 * No harm done, caches are disabled at this point.
72 /* When called the first time, this patches up the
73 * Exec syscall table to directly point to the right routine.
74 * NOTE: We may have been originally called from SetFunction()
75 * We must clear caches before calling SetFunction()
79 if (SysBase
->AttnFlags
& AFF_68060
) {
81 func
= AROS_SLIB_ENTRY(CacheClearU_60
, Exec
, 106);
82 } else if (SysBase
->AttnFlags
& AFF_68040
) {
84 func
= AROS_SLIB_ENTRY(CacheClearU_40
, Exec
, 106);
85 } else if (SysBase
->AttnFlags
& AFF_68020
) {
87 func
= AROS_SLIB_ENTRY(CacheClearU_20
, Exec
, 106);
89 /* Everybody else (68000, 68010) */
90 func
= AROS_SLIB_ENTRY(CacheClearU_00
, Exec
, 106);
93 SetFunction((struct Library
*)SysBase
, -LIB_VECTSIZE
* 106, func
);