only bring in as many sdl things as are strictly necessary
[tangerine.git] / arch / ppc-sam440 / exec / cachecleare.c
blob318c9256f11a2e1e23c0fea53196f7937967816c
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 /*****************************************************************************
15 NAME */
16 #include <proto/exec.h>
18 AROS_LH3(void, CacheClearE,
20 /* SYNOPSIS */
21 AROS_LHA(APTR, address, A0),
22 AROS_LHA(ULONG, length, D0),
23 AROS_LHA(ULONG, caches, D1),
25 /* LOCATION */
26 struct ExecBase *, SysBase, 107, Exec)
28 /* FUNCTION
29 Flush the contents of the CPU instruction or data caches. If some
30 of the cache contains dirty data, push it to memory first.
32 For most systems DMA will not effect processor caches. If *any*
33 external (non-processor) event changes system memory, you MUST
34 clear the cache. For example:
36 DMA
37 Code relocation to run at a different address
38 Building jump tables
39 Loading code from disk
41 INPUTS
42 address - Address to start the operation. This address may be
43 rounded DOWN due to hardware granularity.
44 length - Length of the memory to flush. This will be rounded
45 up, of $FFFFFFFF to indicate that all addresses
46 should be cleared.
47 caches - Bit flags to indicate which caches should be cleared
49 CACRF_ClearI - Clear the instruction cache
50 CACRF_ClearD - Clear the data cache
52 All other bits are reserved.
54 RESULT
55 The caches will be flushed.
57 NOTES
58 It is possible that on some systems the entire cache will be
59 even if this was not the specific request.
61 EXAMPLE
63 BUGS
65 SEE ALSO
66 CacheClearU(), CacheControl()
68 INTERNALS
69 This is a rather CPU dependant function. You should replace it
70 in your $(KERNEL).
72 ******************************************************************************/
74 AROS_LIBFUNC_INIT
76 char *start = (char*)((IPTR)address & 0xffffffe0);
77 char *end = (char*)(((IPTR)address + length + 31) & 0xffffffe0);
78 char *ptr;
80 /* Flush data caches and mark cacke lines invalid */
81 if (caches & CACRF_ClearD)
83 for (ptr = start; ptr < end; ptr +=32)
85 asm volatile("dcbf 0,%0"::"r"(ptr));
87 asm volatile("sync");
90 if (caches & CACRF_InvalidateD)
92 register APTR addr asm ("r4") = address;
93 register ULONG len asm ("r5") = length;
94 asm volatile("li %%r3,%0; sc"::"i"(8 /*SC_INVALIDATED*/),"r"(addr),"r"(len):"memory","r3");
97 if (caches & CACRF_ClearI) /* Clear ICache with DCache together */
99 for (ptr = start; ptr < end; ptr +=32)
101 asm volatile("icbi 0,%0"::"r"(ptr));
104 asm volatile("sync; isync; ");
107 AROS_LIBFUNC_EXIT
108 } /* CacheClearE */