fix paths.
[AROS.git] / arch / m68k-amiga / c / patches.c
blob2581ba32da1695b87bc345db6ea09c3d0aa54a38
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
7 #include <aros/libcall.h>
8 #include <aros/symbolsets.h>
10 #include <proto/exec.h>
11 #include <proto/dos.h>
14 extern UBYTE copymem_040, copymeme_040;
15 extern UBYTE copymemquick_040, copymemquicke_040;
16 extern UBYTE copymem_060, copymeme_060;
17 extern UBYTE copymemquick_060, copymemquicke_060;
19 static void patch_function(UBYTE *start, UBYTE *end, void *library, WORD lvo)
21 UBYTE *mem;
22 ULONG size;
24 size = end - start;
25 mem = AllocMem(size, MEMF_PUBLIC);
26 if (!mem)
27 return;
28 CopyMem(start, mem, size);
29 CacheClearE(mem, size, CACRF_ClearI|CACRF_ClearD);
30 SetFunction(library, lvo * -LIB_VECTSIZE, mem);
33 void patches(BOOL quiet, ULONG flags)
35 if (!(flags & 1))
36 return;
37 if (SysBase->AttnFlags & AFF_68060) {
38 patch_function(&copymem_060, &copymeme_060, SysBase, 104);
39 patch_function(&copymemquick_060, &copymemquicke_060, SysBase, 105);
40 if (!quiet)
41 Printf("Replaced CopyMem() and CopyMemQuick() with 68060 optimized versions.\n");
42 } else if (SysBase->AttnFlags & AFF_68040) {
43 patch_function(&copymem_040, &copymeme_040, SysBase, 104);
44 patch_function(&copymemquick_040, &copymemquicke_040, SysBase, 105);
45 if (!quiet)
46 Printf("Replaced CopyMem() and CopyMemQuick() with 68040 optimized versions.\n");