2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Create the jumptable for a shared library or a device.
8 #include <exec/execbase.h>
9 #include <aros/libcall.h>
10 #include <proto/exec.h>
12 /*****************************************************************************
16 AROS_LH3(ULONG
, MakeFunctions
,
19 AROS_LHA(APTR
, target
, A0
),
20 AROS_LHA(APTR
, functionArray
, A1
),
21 AROS_LHA(APTR
, funcDispBase
, A2
),
24 struct ExecBase
*, SysBase
, 15, Exec
)
27 Creates the jumptable for a shared library and flushes the processor's
28 instruction cache. Does not checksum the library.
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
37 funcDispBase - The base location for WORD displacements or NULL
38 for function pointers.
41 Size of the jumptable.
53 ******************************************************************************/
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 */
69 /* Decrement vector pointer by one and install vector */
70 __AROS_INITVEC(target
,n
);
72 __AROS_SETVECADDR(target
,n
,funcDispBase
+*fp
);
74 /* Use next array entry */
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
);
90 __AROS_SETVECADDR(target
,n
,*fp
);
92 /* Use next array entry */
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 */
107 } /* MakeFunctions */