2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
6 /*****************************************************************************
10 AROS_LH3(APTR, CachePreDMA,
13 AROS_LHA(APTR, address, A0),
14 AROS_LHA(ULONG *, length, A1),
15 AROS_LHA(ULONG, flags, D0),
18 struct ExecBase *, SysBase, 127, Exec)
21 Do everything necessary to make CPU caches aware that a DMA will happen.
22 Virtual memory systems will make it possible that your memory is not at
23 one block and not at the address you thought. This function gives you
24 all the information you need to split the DMA request up and to convert
25 virtual to physical addresses.
28 address - Virtual address of memory affected by the DMA
29 *length - Number of bytes affected
30 flags - DMA_Continue - This is a call to continue a request that
32 DMA_ReadFromRAM - Indicate that the DMA goes from RAM
33 to the device. Set this bit in bot calls.
36 The physical address in memory.
37 *length contains the number of contiguous bytes in physical memory.
40 DMA must follow a call to CachePreDMA() and must be followed
41 by a call to CachePostDMA().
54 ******************************************************************************/
57 XDEF AROS_SLIB_ENTRY(CachePreDMA,Exec,127) ; for 68000/10/20/30
58 XDEF AROS_SLIB_ENTRY(CachePreDMA_40,Exec,127) ; for 68040+
61 #include "aros/m68k/asm.h"
64 #define DMAB_Continue 1 /* Continuation flag for CachePreDMA */
65 #define DMAB_NoModify 2 /* Set if DMA does not update memory */
66 #define DMAB_ReadFromRAM 3 /* Set if DMA goes *FROM* RAM to device */
70 .globl AROS_SLIB_ENTRY(CachePreDMA_00,Exec,127)
71 .type AROS_SLIB_ENTRY(CachePreDMA_00,Exec,127),@function
72 AROS_SLIB_ENTRY(CachePreDMA_00,Exec,127):
78 move.l %a0,%d0 /* return input address */
83 .globl AROS_SLIB_ENTRY(CachePreDMA_40,Exec,127)
84 .type AROS_SLIB_ENTRY(CachePreDMA_40,Exec,127),@function
85 AROS_SLIB_ENTRY(CachePreDMA_40,Exec,127):
91 movem.l %a0/%a3/%a5,-(%sp)
93 btst #DMAB_Continue,%d0
95 btst #DMAB_ReadFromRAM,%d0
103 * Not cache line aligned.
105 * Details can be read here:
106 * http://groups.google.com/group/comp.sys.amiga.hardware/browse_thread/thread/6e5caefab6a68a1e/16f93d291b0b1440?hl=en&ie=UTF-8
108 * We assume MMU is already configured.
111 move.l %a6@(eb_KernelBase),%a3
112 move.l %a3@(kb_PlatformData),%a3
113 tst.l MMU_Level_A(%a3)
117 lea cacheprepostset,%a5
121 jsr -0x27C(%a6) /* CacheClearU() */
125 jsr -0x282(%a6) /* CacheClearE() */
128 movem.l (%sp)+,%a0/%a3/%a5
132 .globl cacheprepostset
135 // d1 = copyback mode. on=1 off=0
137 movem.l %a0/%a2,-(%sp)
145 movem.l (%sp)+,%a0/%a2
149 movem.l %d0-%d3/%a0-%a1,-(%sp)
153 beq.s 1f // cache line aligned -> nothing to do
157 beq.s 1f // end == start
164 /* adjust page descriptor cache flags */
168 bne.s 1f // bit 6 set = noncacheable
169 bclr #5,%d0 // disable copyback
172 bset #5,%d0 // enable copyback
176 1: movem.l (%sp)+,%d0-%d3/%a0-%a1
179 /* Fetch page descriptor address. No error checks. */
181 move.l MMU_Level_A(%a3),%a1
184 move.l 0(%a1,%d0.w*4),%d0
188 move.l 0(%a1,%d0.w*4),%d0
192 lea 0(%a1,%d0.w*4),%a0
197 movem.l %d0-%d1/%a0-%a1,-(%sp)
204 movem.l (%sp)+,%d0-%d1/%a0-%a1
208 movem.l %d0-%d1/%a0-%a1,-(%sp)
216 movem.l (%sp)+,%d0-%d1/%a0-%a1
220 .string "PreDMA(%p,%x,%x)\n"
222 .string "CB(%08x,%08x[%08x],%d)\n"