1c96e56d03ef0fbc5d61489753de715add60bfc4
[AROS.git] / arch / m68k-all / exec / cacheclearu.c
blob1c96e56d03ef0fbc5d61489753de715add60bfc4
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: CacheClearU - Simple way of clearing the caches.
6 Lang: english
7 */
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 /*****************************************************************************
19 NAME */
20 #include <proto/exec.h>
22 AROS_LH0(void, CacheClearU,
24 /* LOCATION */
25 struct ExecBase *, SysBase, 106, Exec)
27 /* FUNCTION
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:
35 DMA
36 Code relocation to run at a different address
37 Building jump tables
38 Loading code from disk
40 INPUTS
42 RESULT
43 The caches will be flushed.
45 NOTES
46 It is possible that on some systems the entire cache will be
47 even if this was not the specific request.
49 EXAMPLE
51 BUGS
53 SEE ALSO
54 CacheClearE(), CacheControl(), CachePreDMA(), CachePostDMA()
56 INTERNALS
57 Although it is not necessary, but it could be more efficient if
58 this function was replaced by a function in $(KERNEL).
60 ******************************************************************************/
62 AROS_LIBFUNC_INIT
63 void (*func)(void);
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.
70 return;
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()
78 Disable();
79 if (SysBase->AttnFlags & AFF_68060) {
80 /* 68060 support */
81 func = AROS_SLIB_ENTRY(CacheClearU_60, Exec, 106);
82 } else if (SysBase->AttnFlags & AFF_68040) {
83 /* 68040 support */
84 func = AROS_SLIB_ENTRY(CacheClearU_40, Exec, 106);
85 } else if (SysBase->AttnFlags & AFF_68020) {
86 /* 68020 support */
87 func = AROS_SLIB_ENTRY(CacheClearU_20, Exec, 106);
88 } else {
89 /* Everybody else (68000, 68010) */
90 func = AROS_SLIB_ENTRY(CacheClearU_00, Exec, 106);
92 func();
93 SetFunction((struct Library *)SysBase, -LIB_VECTSIZE * 106, func);
94 Enable();
96 AROS_LIBFUNC_EXIT
97 } /* CacheClearU */