2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Create the jumptable for a shared library or a device.
9 #include <exec/execbase.h>
10 #include <aros/asmcall.h>
11 #include <aros/libcall.h>
12 #include <proto/exec.h>
14 #include "exec_debug.h"
16 AROS_LD3(void, CacheClearE
,
17 AROS_LHA(APTR
, address
, A0
),
18 AROS_LHA(ULONG
, length
, D0
),
19 AROS_LHA(ULONG
, caches
, D1
),
20 struct ExecBase
*, SysBase
, 107, Exec
);
22 /*****************************************************************************
26 AROS_LH3(ULONG
, MakeFunctions
,
29 AROS_LHA(APTR
, target
, A0
),
30 AROS_LHA(CONST_APTR
, functionArray
, A1
),
31 AROS_LHA(CONST_APTR
, funcDispBase
, A2
),
34 struct ExecBase
*, SysBase
, 15, Exec
)
37 Creates the jumptable for a shared library and flushes the processor's
38 instruction cache. Does not checksum the library.
41 target - The highest byte +1 of the jumptable. Typically
42 this is the library's base address.
43 functionArray - Pointer to either an array of function pointers or
44 an array of WORD displacements to a given location
45 in memory. A value of -1 terminates the array in both
47 funcDispBase - The base location for WORD displacements or NULL
48 for function pointers.
51 Size of the jumptable.
63 ******************************************************************************/
69 DCREATELIBRARY("MakeFunctions(0x%p, 0x%p, 0x%p)", target
, functionArray
, funcDispBase
);
73 if (funcDispBase
!=NULL
)
75 /* If FuncDispBase is non-NULL it's an array of relative offsets */
76 WORD
*fp
=(WORD
*)functionArray
;
78 /* -1 terminates the array */
81 /* Decrement vector pointer by one and install vector */
82 __AROS_INITVEC(target
,n
);
84 __AROS_SETVECADDR(target
,n
,(void *)funcDispBase
+*fp
);
86 /* Use next array entry */
93 /* If FuncDispBase is NULL it's an array of function pointers */
94 void **fp
=(void **)functionArray
;
96 /* -1 terminates the array */
97 while(*fp
!=(void *)-1)
99 /* Decrement vector pointer by one and install vector */
100 __AROS_INITVEC(target
,n
);
102 __AROS_SETVECADDR(target
,n
,*fp
);
104 /* Use next array entry */
110 lastvec
= __AROS_GETJUMPVEC(target
,n
);
111 n
= (IPTR
)target
-(IPTR
)lastvec
;
113 #ifdef __AROS_USE_FULLJMP
114 /* Clear instruction cache for the whole jumptable. We need to do it only if
115 the jumptable actually contains executable code. __AROS_USE_FULLJMP must
116 be defined in cpu.h in this case.
118 Note that we call this function directly because MakeFunctions() is also
119 used for building ExecBase itself. */
120 if (SysBase
->LibNode
.lib_Node
.ln_Type
!= NT_LIBRARY
) {
121 AROS_CALL3NR(void, AROS_SLIB_ENTRY(CacheClearE
, Exec
, 107),
122 AROS_UFCA(APTR
, lastvec
, A0
),
123 AROS_UFCA(ULONG
, n
, D0
),
124 AROS_UFCA(ULONG
, CACRF_ClearI
|CACRF_ClearD
, D1
),
125 struct ExecBase
*, SysBase
);
127 /* call CacheClearE() indirectly if SysBase is already valid.
128 * CacheClearE may have been SetFunction()'d for specific CPU type.
130 CacheClearE(lastvec
, n
, CACRF_ClearI
|CACRF_ClearD
);
134 /* Return size of jumptable */
135 DCREATELIBRARY("Created %lu vectors", n
);
139 } /* MakeFunctions */