move VMWare SVGA driver to generic location
[AROS.git] / rom / exec / makefunctions.c
blob077df0385a78e3de2a3dcce467088d2096a4a331
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Create the jumptable for a shared library or a device.
6 Lang: english
7 */
8 #include <exec/execbase.h>
9 #include <aros/libcall.h>
10 #include <proto/exec.h>
12 /*****************************************************************************
14 NAME */
16 AROS_LH3(ULONG, MakeFunctions,
18 /* SYNOPSIS */
19 AROS_LHA(APTR, target, A0),
20 AROS_LHA(APTR, functionArray, A1),
21 AROS_LHA(APTR, funcDispBase, A2),
23 /* LOCATION */
24 struct ExecBase *, SysBase, 15, Exec)
26 /* FUNCTION
27 Creates the jumptable for a shared library and flushes the processor's
28 instruction cache. Does not checksum the library.
30 INPUTS
31 target - The highest byte +1 of the jumptable. Typically
32 this is the library's base address.
33 functionArray - Pointer to either an array of function pointers or
34 an array of WORD displacements to a given location
35 in memory. A value of -1 terminates the array in both
36 cases.
37 funcDispBase - The base location for WORD displacements or NULL
38 for function pointers.
40 RESULT
41 Size of the jumptable.
43 NOTES
45 EXAMPLE
47 BUGS
49 SEE ALSO
51 INTERNALS
53 ******************************************************************************/
55 AROS_LIBFUNC_INIT
56 long n;
57 APTR lastvec;
59 n = 1;
61 if (funcDispBase!=NULL)
63 /* If FuncDispBase is non-NULL it's an array of relative offsets */
64 WORD *fp=(WORD *)functionArray;
66 /* -1 terminates the array */
67 while(*fp!=-1)
69 /* Decrement vector pointer by one and install vector */
70 __AROS_INITVEC(target,n);
71 if (*fp)
72 __AROS_SETVECADDR(target,n,funcDispBase+*fp);
74 /* Use next array entry */
75 fp++;
76 n++;
79 else
81 /* If FuncDispBase is NULL it's an array of function pointers */
82 void **fp=(void **)functionArray;
84 /* -1 terminates the array */
85 while(*fp!=(void *)-1)
87 /* Decrement vector pointer by one and install vector */
88 __AROS_INITVEC(target,n);
89 if (*fp)
90 __AROS_SETVECADDR(target,n,*fp);
92 /* Use next array entry */
93 fp++;
94 n++;
98 lastvec = __AROS_GETJUMPVEC(target,n);
99 n = (IPTR)target-(IPTR)lastvec;
101 /* Clear instruction cache for the whole jumptable */
102 CacheClearE(lastvec, n, CACRF_ClearI|CACRF_ClearD);
104 /* Return size of jumptable */
105 return n;
106 AROS_LIBFUNC_EXIT
107 } /* MakeFunctions */