2ba600ae538bed664f753dcbb21f52a431c6f8dd
[AROS.git] / arch / m68k-all / exec / cachepostdma.c
blob2ba600ae538bed664f753dcbb21f52a431c6f8dd
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: CachePostDMA() - Do what is necessary for DMA.
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <exec/types.h>
11 #include <exec/execbase.h>
12 #include <aros/libcall.h>
14 extern void AROS_SLIB_ENTRY(CachePostDMA_00,Exec,128)(void);
15 extern void AROS_SLIB_ENTRY(CachePostDMA_30,Exec,128)(void);
16 extern void AROS_SLIB_ENTRY(CachePostDMA_40,Exec,128)(void);
17 /*****************************************************************************
19 NAME */
20 #include <proto/exec.h>
22 AROS_LH3(void, CachePostDMA,
24 /* SYNOPSIS */
25 AROS_LHA(APTR, address, A0),
26 AROS_LHA(ULONG *, length, A1),
27 AROS_LHA(ULONG, flags, D0),
29 /* LOCATION */
30 struct ExecBase *, SysBase, 128, Exec)
32 /* FUNCTION
33 Do everything necessary to make CPU caches aware that a DMA has
34 happened.
36 INPUTS
37 address - Virtual address of memory affected by the DMA
38 *length - Number of bytes affected
39 flags - DMA_NoModify - Indicate that the memory did not change.
40 DMA_ReadFromRAM - Indicate that the DMA goes from RAM
41 to the device. Set this bit in
42 both calls.
44 RESULT
46 NOTES
47 DMA must follow a call to CachePostDMA() and must be followed
48 by a call to CachePostDMA().
50 EXAMPLE
52 BUGS
54 SEE ALSO
55 CachePostDMA()
57 INTERNALS
59 ******************************************************************************/
61 AROS_LIBFUNC_INIT
62 void (*func)(void);
64 /* When called the first time, this patches up the
65 * Exec syscall table to directly point to the right routine.
67 Disable();
68 if (SysBase->AttnFlags & AFF_68040) {
69 /* 68040 support */
70 func = AROS_SLIB_ENTRY(CachePostDMA_40, Exec, 128);
71 } else if (SysBase->AttnFlags & AFF_68030) {
72 /* 68030 support */
73 func = AROS_SLIB_ENTRY(CachePostDMA_30, Exec, 128);
74 } else {
75 /* Everybody else (68000, 68010) */
76 func = AROS_SLIB_ENTRY(CachePostDMA_00, Exec, 128);
79 SetFunction((struct Library *)SysBase, -LIB_VECTSIZE * 128, func);
80 Enable();
82 /* Call 'myself', which is now pointing to the correct routine */
83 return CachePostDMA(address, length, flags);
85 AROS_LIBFUNC_EXIT
86 } /* CachePostDMA */