b17e33ae2d6da9077f49a3b707ab14accc142643
[AROS.git] / arch / ppc-chrp / exec / cachepredma.c
blobb17e33ae2d6da9077f49a3b707ab14accc142643
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: CachePreDMA() - Do what is necessary for DMA.
6 Lang: english
7 */
9 #define DEBUG 0
11 #include <aros/debug.h>
12 #include <exec/types.h>
13 #include <aros/libcall.h>
15 #include "exec_intern.h"
17 /*****************************************************************************
19 NAME */
20 #include <proto/exec.h>
21 #include <proto/kernel.h>
23 AROS_LH3(APTR, CachePreDMA,
25 /* SYNOPSIS */
26 AROS_LHA(APTR, address, A0),
27 AROS_LHA(ULONG *, length, A1),
28 AROS_LHA(ULONG, flags, D0),
30 /* LOCATION */
31 struct ExecBase *, SysBase, 127, Exec)
33 /* FUNCTION
34 Do everything necessary to make CPU caches aware that a DMA
35 will happen. Virtual memory systems will make it possible
36 that your memory is not at one block and not at the address
37 you thought. This function gives you all the information
38 you need to split the DMA request up and to convert virtual
39 to physical addresses.
41 INPUTS
42 address - Virtual address of memory affected by the DMA
43 *length - Number of bytes affected
44 flags - DMA_Continue - This is a call to continue a
45 request that was broken up.
46 DMA_ReadFromRAM - Indicate that the DMA goes from
47 RAM to the device. Set this bit
48 in both calls.
50 RESULT
51 The physical address in memory.
52 *length contains the number of contiguous bytes in physical
53 memory.
55 NOTES
56 DMA must follow a call to CachePreDMA() and must be followed
57 by a call to CachePostDMA().
59 EXAMPLE
61 BUGS
63 SEE ALSO
64 CachePostDMA()
66 INTERNALS
68 ******************************************************************************/
70 AROS_LIBFUNC_INIT
72 void *addr = KrnVirtualToPhysical(address);
74 /* At PreDMA stage only data caches need to be flushed */
75 //if (flags & DMA_ReadFromRAM)
77 CacheClearE(address, *length, CACRF_ClearD);
79 return addr;
81 AROS_LIBFUNC_EXIT
82 } /* CachePreDMA() */