dcf498a61356252b0afc3a9ea1fb9fcb1be37d5a
[AROS.git] / arch / m68k-all / exec / cachecleare.c
blobdcf498a61356252b0afc3a9ea1fb9fcb1be37d5a
1 /*
2 Copyright © 1995-2001, 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 extern void AROS_SLIB_ENTRY(CacheClearE_00,Exec,107)(void);
14 extern void AROS_SLIB_ENTRY(CacheClearE_20,Exec,107)(void);
15 extern void AROS_SLIB_ENTRY(CacheClearE_4060,Exec,107)(void);
17 /*****************************************************************************
19 NAME */
20 #include <proto/exec.h>
22 AROS_LH3(void, CacheClearE,
24 /* SYNOPSIS */
25 AROS_LHA(APTR, address, A0),
26 AROS_LHA(ULONG, length, D0),
27 AROS_LHA(ULONG, caches, D1),
29 /* LOCATION */
30 struct ExecBase *, SysBase, 107, Exec)
32 /* FUNCTION
33 Flush the contents of the CPU instruction or data caches. If some
34 of the cache contains dirty data, push it to memory first.
36 For most systems DMA will not effect processor caches. If *any*
37 external (non-processor) event changes system memory, you MUST
38 clear the cache. For example:
40 DMA
41 Code relocation to run at a different address
42 Building jump tables
43 Loading code from disk
45 INPUTS
46 address - Address to start the operation. This address may be
47 rounded DOWN due to hardware granularity.
48 length - Length of the memory to flush. This will be rounded
49 up, of $FFFFFFFF to indicate that all addresses
50 should be cleared.
51 caches - Bit flags to indicate which caches should be cleared
53 CACRF_ClearI - Clear the instruction cache
54 CACRF_ClearD - Clear the data cache
56 All other bits are reserved.
58 RESULT
59 The caches will be flushed.
61 NOTES
62 It is possible that on some systems the entire cache will be
63 even if this was not the specific request.
65 EXAMPLE
67 BUGS
69 SEE ALSO
70 CacheClearU(), CacheControl()
72 INTERNALS
73 This is a rather CPU dependant function.
75 ******************************************************************************/
77 AROS_LIBFUNC_INIT
79 void (*func)();
81 if (SysBase->LibNode.lib_OpenCnt == 0)
82 return;
84 Disable();
85 if (SysBase->AttnFlags & AFF_68060) {
86 /* 68060 support */
87 func = AROS_SLIB_ENTRY(CacheClearE_4060, Exec, 107);
88 } else if (SysBase->AttnFlags & AFF_68040) {
89 /* 68040 support */
90 func = AROS_SLIB_ENTRY(CacheClearE_4060, Exec, 107);
91 } else if (SysBase->AttnFlags & AFF_68020) {
92 /* 68020 support */
93 func = AROS_SLIB_ENTRY(CacheClearE_20, Exec, 107);
94 } else {
95 /* Everybody else (68000, 68010) */
96 func = AROS_SLIB_ENTRY(CacheClearE_00, Exec, 107);
98 AROS_UFC3NR(void, func,
99 AROS_UFCA(APTR, address, A0),
100 AROS_UFCA(ULONG, length, D0),
101 AROS_UFCA(ULONG, caches, D1));
102 SetFunction((struct Library *)SysBase, -LIB_VECTSIZE * 107, func);
103 Enable();
105 AROS_LIBFUNC_EXIT
106 } /* CacheClearE */