rbdc 0.8.7 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/{bindings → dyncall-bindings}/ruby/rbdc/extconf.rb +1 -1
- data/{bindings → dyncall-bindings}/ruby/rbdc/rbdc.c +3 -1
- data/dyncall/AUTHORS +2 -0
- data/dyncall/BUGS +1 -0
- data/dyncall/CMakeLists.txt +10 -2
- data/dyncall/ChangeLog +46 -11
- data/dyncall/LICENSE +4 -1
- data/dyncall/Makefile.embedded +7 -3
- data/dyncall/README +23 -14
- data/dyncall/ToDo +27 -28
- data/dyncall/autovar/autovar_ABI.h +3 -2
- data/dyncall/autovar/autovar_ARCH.h +13 -10
- data/dyncall/autovar/autovar_CC.h +3 -2
- data/dyncall/autovar/autovar_OS.h +3 -2
- data/dyncall/autovar/autovar_OSFAMILY.h +3 -2
- data/dyncall/buildsys/scripts/batch-build-linux.sh +6 -2
- data/dyncall/buildsys/scripts/batch-build-minix.sh +2 -0
- data/dyncall/buildsys/scripts/batch-build-psp.sh +4 -1
- data/dyncall/buildsys/scripts/elf-to-psp-eboot.sh +19 -0
- data/dyncall/buildsys/scripts/setenv-cross-ios.sh +0 -0
- data/dyncall/buildsys/scripts/setenv-sdk-ios.sh +0 -0
- data/dyncall/configure +83 -30
- data/dyncall/dyncall/dyncall.3 +16 -4
- data/dyncall/dyncall/dyncall.h +9 -1
- data/dyncall/dyncall/dyncall_alloc.h +2 -1
- data/dyncall/dyncall/dyncall_api.c +2 -1
- data/dyncall/dyncall/dyncall_call.S +9 -2
- data/dyncall/dyncall/dyncall_call_arm32_arm.S +2 -1
- data/dyncall/dyncall/dyncall_call_arm32_arm.h +8 -2
- data/dyncall/dyncall/dyncall_call_arm32_arm_armhf.S +11 -19
- data/dyncall/dyncall/dyncall_call_arm32_arm_armhf.h +15 -2
- data/dyncall/dyncall/dyncall_call_arm32_thumb.h +8 -6
- data/dyncall/dyncall/dyncall_call_arm32_thumb_armhf.S +10 -18
- data/dyncall/dyncall/dyncall_call_arm32_thumb_gas.s +0 -16
- data/dyncall/dyncall/dyncall_call_arm64.S +226 -0
- data/dyncall/dyncall/dyncall_call_arm64.h +45 -0
- data/dyncall/dyncall/dyncall_call_mips.h +2 -1
- data/dyncall/dyncall/dyncall_call_mips_eabi.h +2 -1
- data/dyncall/dyncall/dyncall_call_mips_gas.S +2 -1
- data/dyncall/dyncall/dyncall_call_mips_n32.h +2 -1
- data/dyncall/dyncall/dyncall_call_mips_n64.h +2 -1
- data/dyncall/dyncall/dyncall_call_mips_o32.h +2 -1
- data/dyncall/dyncall/dyncall_call_ppc32.S +27 -2
- data/dyncall/dyncall/dyncall_call_ppc32.h +2 -2
- data/dyncall/dyncall/dyncall_call_ppc64.S +210 -0
- data/dyncall/dyncall/dyncall_call_ppc64.h +55 -0
- data/dyncall/dyncall/dyncall_call_sparc.S +2 -1
- data/dyncall/dyncall/dyncall_call_sparc.h +2 -1
- data/dyncall/dyncall/dyncall_call_sparc64.S +2 -1
- data/dyncall/dyncall/dyncall_call_sparc64.h +2 -1
- data/dyncall/dyncall/dyncall_call_sparc_v9.S +25 -23
- data/dyncall/dyncall/dyncall_call_sparc_v9.h +2 -1
- data/dyncall/dyncall/dyncall_call_x64-att.S +2 -1
- data/dyncall/dyncall/dyncall_call_x64.S +2 -1
- data/dyncall/dyncall/dyncall_call_x64.h +2 -1
- data/dyncall/dyncall/dyncall_call_x86.S +2 -1
- data/dyncall/dyncall/dyncall_call_x86.h +2 -1
- data/dyncall/dyncall/dyncall_callf.c +56 -66
- data/dyncall/dyncall/dyncall_callf.h +5 -1
- data/dyncall/dyncall/dyncall_callvm.c +11 -2
- data/dyncall/dyncall/dyncall_callvm.h +2 -1
- data/dyncall/dyncall/dyncall_callvm_arm32_arm.c +2 -1
- data/dyncall/dyncall/dyncall_callvm_arm32_arm.h +2 -1
- data/dyncall/dyncall/dyncall_callvm_arm32_arm_armhf.c +60 -30
- data/dyncall/dyncall/dyncall_callvm_arm32_arm_armhf.h +3 -2
- data/dyncall/dyncall/dyncall_callvm_arm32_thumb.c +2 -24
- data/dyncall/dyncall/dyncall_callvm_arm32_thumb.h +2 -1
- data/dyncall/dyncall/dyncall_callvm_arm64.c +165 -0
- data/dyncall/dyncall/dyncall_callvm_arm64.h +51 -0
- data/dyncall/dyncall/dyncall_callvm_arm64_apple.c +272 -0
- data/dyncall/dyncall/dyncall_callvm_base.c +2 -1
- data/dyncall/dyncall/dyncall_callvm_mips.c +2 -1
- data/dyncall/dyncall/dyncall_callvm_mips.h +2 -1
- data/dyncall/dyncall/dyncall_callvm_mips_eabi.c +2 -1
- data/dyncall/dyncall/dyncall_callvm_mips_eabi.h +2 -1
- data/dyncall/dyncall/dyncall_callvm_mips_n32.c +2 -1
- data/dyncall/dyncall/dyncall_callvm_mips_n64.c +2 -1
- data/dyncall/dyncall/dyncall_callvm_mips_n64.h +2 -1
- data/dyncall/dyncall/dyncall_callvm_mips_o32.c +2 -1
- data/dyncall/dyncall/dyncall_callvm_mips_o32.h +2 -1
- data/dyncall/dyncall/dyncall_callvm_ppc32.c +45 -2
- data/dyncall/dyncall/dyncall_callvm_ppc32.h +2 -1
- data/dyncall/dyncall/dyncall_callvm_ppc64.c +351 -0
- data/dyncall/dyncall/dyncall_callvm_ppc64.h +60 -0
- data/dyncall/dyncall/dyncall_callvm_sparc.c +2 -1
- data/dyncall/dyncall/dyncall_callvm_sparc.h +2 -1
- data/dyncall/dyncall/dyncall_callvm_sparc64.c +2 -2
- data/dyncall/dyncall/dyncall_callvm_sparc64.h +2 -1
- data/dyncall/dyncall/dyncall_callvm_sparc_v9.c +3 -3
- data/dyncall/dyncall/dyncall_callvm_sparc_v9.h +2 -1
- data/dyncall/dyncall/dyncall_callvm_x64.c +2 -1
- data/dyncall/dyncall/dyncall_callvm_x64.h +2 -1
- data/dyncall/dyncall/dyncall_callvm_x86.c +2 -1
- data/dyncall/dyncall/dyncall_callvm_x86.h +2 -1
- data/dyncall/dyncall/dyncall_config.h +2 -1
- data/dyncall/dyncall/dyncall_macros.h +46 -9
- data/dyncall/dyncall/dyncall_signature.h +2 -1
- data/dyncall/dyncall/dyncall_struct.c +2 -1
- data/dyncall/dyncall/dyncall_struct.h +2 -1
- data/dyncall/dyncall/dyncall_types.h +2 -1
- data/dyncall/dyncall/dyncall_utils.h +2 -1
- data/dyncall/dyncall/dyncall_value.h +19 -1
- data/dyncall/dyncall/dyncall_vector.c +2 -1
- data/dyncall/dyncall/dyncall_vector.h +3 -1
- data/dyncall/dyncall/gen-masm.sh +0 -0
- data/dyncall/dyncallback/Makefile.generic +1 -1
- data/dyncall/dyncallback/dyncall_alloc_wx.c +2 -1
- data/dyncall/dyncallback/dyncall_alloc_wx.h +2 -1
- data/dyncall/dyncallback/dyncall_alloc_wx_malloc.c +2 -1
- data/dyncall/dyncallback/dyncall_alloc_wx_mmap.c +2 -1
- data/dyncall/dyncallback/dyncall_alloc_wx_win32.c +2 -1
- data/dyncall/dyncallback/dyncall_args.c +22 -10
- data/dyncall/dyncallback/dyncall_args.h +2 -1
- data/dyncall/dyncallback/dyncall_args_arm32_arm.c +35 -4
- data/dyncall/dyncallback/dyncall_args_arm32_arm.h +7 -1
- data/dyncall/dyncallback/dyncall_args_arm32_thumb.c +2 -1
- data/dyncall/dyncallback/dyncall_args_arm32_thumb.h +2 -1
- data/dyncall/dyncallback/dyncall_args_arm64.c +77 -0
- data/dyncall/dyncallback/dyncall_args_arm64_apple.c +160 -0
- data/dyncall/dyncallback/dyncall_args_mips.c +3 -2
- data/dyncall/dyncallback/dyncall_args_mips.h +3 -2
- data/dyncall/dyncallback/dyncall_args_ppc32.c +2 -1
- data/dyncall/dyncallback/dyncall_args_ppc32.h +9 -7
- data/dyncall/dyncallback/dyncall_args_ppc32_sysv.c +95 -0
- data/dyncall/dyncallback/dyncall_args_ppc64.c +71 -0
- data/dyncall/dyncallback/dyncall_args_ppc64.h +40 -0
- data/dyncall/dyncallback/dyncall_args_sparc32.c +2 -1
- data/dyncall/dyncallback/dyncall_args_sparc32.h +2 -1
- data/dyncall/dyncallback/dyncall_args_sparc64.c +2 -1
- data/dyncall/dyncallback/dyncall_args_sparc64.h +2 -1
- data/dyncall/dyncallback/dyncall_args_x64.c +2 -1
- data/dyncall/dyncallback/dyncall_args_x64.h +2 -1
- data/dyncall/dyncallback/dyncall_args_x86.c +2 -1
- data/dyncall/dyncallback/dyncall_args_x86.h +2 -1
- data/dyncall/dyncallback/dyncall_callback.c +7 -2
- data/dyncall/dyncallback/dyncall_callback.h +3 -1
- data/dyncall/dyncallback/dyncall_callback_arch.S +14 -6
- data/dyncall/dyncallback/dyncall_callback_arm32_arm.c +2 -1
- data/dyncall/dyncallback/dyncall_callback_arm32_arm.h +2 -1
- data/dyncall/dyncallback/dyncall_callback_arm32_arm_apple.s +1 -1
- data/dyncall/dyncallback/{dyncall_callback_arm32_arm_gas.s → dyncall_callback_arm32_arm_gas.S} +17 -7
- data/dyncall/dyncallback/dyncall_callback_arm32_thumb.c +2 -1
- data/dyncall/dyncallback/dyncall_callback_arm32_thumb.h +2 -1
- data/dyncall/dyncallback/{dyncall_callback_arm32_thumb_apple.s → dyncall_callback_arm32_thumb_apple.S} +2 -2
- data/dyncall/dyncallback/{dyncall_callback_arm32_thumb_gas.s → dyncall_callback_arm32_thumb_gas.S} +2 -2
- data/dyncall/dyncallback/dyncall_callback_arm64.S +111 -0
- data/dyncall/dyncallback/dyncall_callback_arm64.c +71 -0
- data/dyncall/dyncallback/dyncall_callback_mips.c +3 -2
- data/dyncall/dyncallback/dyncall_callback_mips.h +3 -2
- data/dyncall/dyncallback/dyncall_callback_ppc32.S +115 -4
- data/dyncall/dyncallback/dyncall_callback_ppc32.c +3 -2
- data/dyncall/dyncallback/dyncall_callback_ppc32.h +6 -6
- data/dyncall/dyncallback/dyncall_callback_ppc32_apple.s +6 -5
- data/dyncall/dyncallback/dyncall_callback_ppc64.S +170 -0
- data/dyncall/dyncallback/dyncall_callback_ppc64.c +60 -0
- data/dyncall/dyncallback/dyncall_callback_ppc64.h +56 -0
- data/dyncall/dyncallback/dyncall_callback_sparc32.c +2 -1
- data/dyncall/dyncallback/dyncall_callback_sparc32.h +2 -1
- data/dyncall/dyncallback/dyncall_callback_sparc32.s +1 -1
- data/dyncall/dyncallback/dyncall_callback_sparc64.c +2 -1
- data/dyncall/dyncallback/dyncall_callback_sparc64.s +1 -1
- data/dyncall/dyncallback/dyncall_callback_x64.S +5 -12
- data/dyncall/dyncallback/dyncall_callback_x64.c +2 -1
- data/dyncall/dyncallback/dyncall_callback_x64.h +2 -1
- data/dyncall/dyncallback/dyncall_callback_x64_masm.asm +0 -7
- data/dyncall/dyncallback/dyncall_callback_x86.S +5 -12
- data/dyncall/dyncallback/dyncall_callback_x86.c +2 -1
- data/dyncall/dyncallback/dyncall_callback_x86.h +2 -1
- data/dyncall/dyncallback/dyncall_callback_x86_masm.asm +2 -11
- data/dyncall/dyncallback/dyncall_thunk.c +11 -3
- data/dyncall/dyncallback/dyncall_thunk.h +8 -2
- data/dyncall/dyncallback/dyncall_thunk_arm32_arm.c +7 -7
- data/dyncall/dyncallback/dyncall_thunk_arm32_arm.h +2 -1
- data/dyncall/dyncallback/dyncall_thunk_arm32_thumb.c +2 -1
- data/dyncall/dyncallback/dyncall_thunk_arm32_thumb.h +2 -1
- data/dyncall/dyncallback/dyncall_thunk_arm64.c +64 -0
- data/dyncall/dyncallback/dyncall_thunk_arm64.h +42 -0
- data/dyncall/dyncallback/dyncall_thunk_mips.c +49 -17
- data/dyncall/dyncallback/dyncall_thunk_mips.h +3 -2
- data/dyncall/dyncallback/dyncall_thunk_ppc32.c +3 -2
- data/dyncall/dyncallback/dyncall_thunk_ppc32.h +7 -7
- data/dyncall/dyncallback/dyncall_thunk_ppc32_sysv.c +50 -0
- data/dyncall/dyncallback/dyncall_thunk_ppc64.c +87 -0
- data/dyncall/dyncallback/dyncall_thunk_ppc64.h +55 -0
- data/dyncall/dyncallback/dyncall_thunk_sparc32.c +2 -1
- data/dyncall/dyncallback/dyncall_thunk_sparc32.h +2 -1
- data/dyncall/dyncallback/dyncall_thunk_sparc64.c +2 -1
- data/dyncall/dyncallback/dyncall_thunk_sparc64.h +2 -1
- data/dyncall/dyncallback/dyncall_thunk_x64.c +2 -1
- data/dyncall/dyncallback/dyncall_thunk_x64.h +2 -1
- data/dyncall/dyncallback/dyncall_thunk_x86.c +2 -1
- data/dyncall/dyncallback/dyncall_thunk_x86.h +2 -1
- data/dyncall/dyncallback/dyncallback.3 +3 -3
- data/dyncall/dyncallback/gen-masm.sh +0 -0
- data/dyncall/dynload/dynload.c +2 -1
- data/dyncall/dynload/dynload.h +2 -1
- data/dyncall/dynload/dynload_alloc.h +2 -1
- data/dyncall/dynload/dynload_darwin.c +2 -1
- data/dyncall/dynload/dynload_syms.c +2 -1
- data/dyncall/dynload/dynload_syms_elf.c +2 -1
- data/dyncall/dynload/dynload_syms_mach-o.c +3 -2
- data/dyncall/dynload/dynload_syms_pe.c +2 -1
- data/dyncall/dynload/dynload_unix.c +2 -1
- data/dyncall/dynload/dynload_windows.c +2 -1
- data/dyncall/portasm/gen-masm.sh +0 -0
- data/dyncall/portasm/portasm-arm.S +3 -2
- data/dyncall/portasm/portasm-ppc.S +2 -1
- data/dyncall/portasm/portasm-ppc64.S +119 -0
- data/dyncall/portasm/portasm-x64-att.S +2 -1
- data/dyncall/portasm/portasm-x86.S +2 -1
- metadata +39 -18
- data/dyncall/dyncallback/dyncall_callback_x64_apple.s +0 -122
- data/dyncall/dyncallback/dyncall_callback_x64_gas.s +0 -119
- data/dyncall/dyncallback/dyncall_callback_x64_gas_w64.s +0 -102
@@ -6,8 +6,8 @@
|
|
6
6
|
Description: Callback - Header for MIPS
|
7
7
|
License:
|
8
8
|
|
9
|
-
Copyright (c) 2013 Daniel Adler <dadler@uni-goettingen.de>,
|
10
|
-
|
9
|
+
Copyright (c) 2013-2015 Daniel Adler <dadler@uni-goettingen.de>,
|
10
|
+
Tassilo Philipp <tphilipp@potion-studios.com>
|
11
11
|
|
12
12
|
Permission to use, copy, modify, and distribute this software for any
|
13
13
|
purpose with or without fee is hereby granted, provided that the above
|
@@ -23,6 +23,7 @@
|
|
23
23
|
|
24
24
|
*/
|
25
25
|
|
26
|
+
|
26
27
|
#ifndef DYNCALL_CALLBACK_MIPS_H
|
27
28
|
#define DYNCALL_CALLBACK_MIPS_H
|
28
29
|
|
@@ -3,11 +3,10 @@
|
|
3
3
|
Package: dyncall
|
4
4
|
Library: dyncallback
|
5
5
|
File: dyncallback/dyncall_callback_ppc32.S
|
6
|
-
Description: Callback Thunk
|
6
|
+
Description: Callback Thunk Entry for PowerPC 32-bit System V Big-Endian ABI
|
7
7
|
License:
|
8
8
|
|
9
|
-
Copyright (c)
|
10
|
-
Tassilo Philipp <tphilipp@potion-studios.com>
|
9
|
+
Copyright (c) 2015 Daniel Adler <dadler@uni-goettingen.de>
|
11
10
|
|
12
11
|
Permission to use, copy, modify, and distribute this software for any
|
13
12
|
purpose with or without fee is hereby granted, provided that the above
|
@@ -23,11 +22,123 @@
|
|
23
22
|
|
24
23
|
*/
|
25
24
|
|
25
|
+
|
26
26
|
#include "../portasm/portasm-ppc.S"
|
27
|
+
|
27
28
|
.machine ppc
|
28
29
|
.text
|
29
30
|
.align 2
|
31
|
+
|
32
|
+
/* Struct DCCallback */
|
33
|
+
|
34
|
+
DCB_THUNK = 0
|
35
|
+
DCB_HANDLER = 24
|
36
|
+
DCB_CLEANUP = 28
|
37
|
+
DCB_USERDATA = 32
|
38
|
+
|
39
|
+
/* Struct DCArgs */
|
40
|
+
|
41
|
+
ARGS_IREGS = 0
|
42
|
+
ARGS_FREGS = ARGS_IREGS + 4*8
|
43
|
+
ARGS_SP = ARGS_FREGS + 8*13
|
44
|
+
ARGS_ICNT = ARGS_SP + 4
|
45
|
+
ARGS_FCNT = ARGS_ICNT + 4
|
46
|
+
ARGS_SIZE = ARGS_FCNT + 4
|
47
|
+
|
48
|
+
/* Struct DCValue */
|
49
|
+
|
50
|
+
RESULT_SIZE = 8
|
51
|
+
|
52
|
+
/* Stack Offsets: */
|
53
|
+
|
54
|
+
SP_PREV = 0
|
55
|
+
SP_LR = (SP_PREV + 4)
|
56
|
+
SP_PAR = SP_LR + 4
|
57
|
+
PAR_SZ = 0
|
58
|
+
SP_ARGS = SP_PAR + PAR_SZ
|
59
|
+
SP_IREGS = SP_ARGS + ARGS_IREGS
|
60
|
+
SP_FREGS = SP_ARGS + ARGS_FREGS
|
61
|
+
SP_SP = SP_ARGS + ARGS_SP
|
62
|
+
SP_ICNT = SP_ARGS + ARGS_ICNT
|
63
|
+
SP_FCNT = SP_ARGS + ARGS_FCNT
|
64
|
+
SP_RESULT = SP_ARGS + ARGS_SIZE
|
65
|
+
SP_SIZE = SP_RESULT + RESULT_SIZE
|
66
|
+
|
67
|
+
#define ALIGN(M,X) ( M+(X-1) & (-X) )
|
68
|
+
|
69
|
+
FRAMESIZE = ALIGN(SP_SIZE,16)
|
70
|
+
|
30
71
|
GLOBAL_C(dcCallbackThunkEntry)
|
31
72
|
ENTRY_C(dcCallbackThunkEntry)
|
32
|
-
blr /* return */
|
33
73
|
|
74
|
+
/* --------------------------------------------------------------------------
|
75
|
+
|
76
|
+
Input:
|
77
|
+
r1 Stack Pointer
|
78
|
+
r3-r10 Integer Arguments
|
79
|
+
f1-f8 Floating-point Arguments
|
80
|
+
r11 Thunk Pointer
|
81
|
+
|
82
|
+
*/
|
83
|
+
|
84
|
+
/* prolog */
|
85
|
+
|
86
|
+
mflr r0
|
87
|
+
stw r0, SP_LR(r1) /* store return address */
|
88
|
+
addi r12, r1, SP_PAR /* temporary r12: parameter area on callers stack frame */
|
89
|
+
stwu r1, -FRAMESIZE(r1)
|
90
|
+
|
91
|
+
stw r3, SP_IREGS + 0*4(r1) /* spill 8 integer parameter registers */
|
92
|
+
stw r4, SP_IREGS + 1*4(r1)
|
93
|
+
stw r5, SP_IREGS + 2*4(r1)
|
94
|
+
stw r6, SP_IREGS + 3*4(r1)
|
95
|
+
stw r7, SP_IREGS + 4*4(r1)
|
96
|
+
stw r8, SP_IREGS + 5*4(r1)
|
97
|
+
stw r9, SP_IREGS + 6*4(r1)
|
98
|
+
stw r10,SP_IREGS + 7*4(r1)
|
99
|
+
|
100
|
+
stfd f1, SP_FREGS + 0*8(r1) /* spill 8 (of 13) float parameter registers */
|
101
|
+
stfd f2, SP_FREGS + 1*8(r1)
|
102
|
+
stfd f3, SP_FREGS + 2*8(r1)
|
103
|
+
stfd f4, SP_FREGS + 3*8(r1)
|
104
|
+
stfd f5, SP_FREGS + 4*8(r1)
|
105
|
+
stfd f6, SP_FREGS + 5*8(r1)
|
106
|
+
stfd f7, SP_FREGS + 6*8(r1)
|
107
|
+
stfd f8, SP_FREGS + 7*8(r1)
|
108
|
+
|
109
|
+
stw r12, SP_SP(r1) /* init stack pointer */
|
110
|
+
xor r0, r0, r0 /* init register counters */
|
111
|
+
stw r0, SP_ICNT(r1)
|
112
|
+
stw r0, SP_FCNT(r1)
|
113
|
+
stw r0, SP_RESULT(r1) /* init result object */
|
114
|
+
stw r0, SP_RESULT + 4(r1)
|
115
|
+
/* invoke callback handler */
|
116
|
+
mr r3, r11 /* arg 1: DCCallback* pcb (r11 is thunk pointer) */
|
117
|
+
addi r4, r1, SP_ARGS /* arg 2: DCArgs* args */
|
118
|
+
addi r5, r1, SP_RESULT /* arg 3: DCValue* result */
|
119
|
+
lwz r6, DCB_USERDATA(r11) /* arg 4: void* userdata */
|
120
|
+
|
121
|
+
/* branch-and-link to DCCallback.handler */
|
122
|
+
lwz r12, DCB_HANDLER(r11)
|
123
|
+
mtctr r12
|
124
|
+
bctrl
|
125
|
+
/* check result type */
|
126
|
+
cmpi cr0, r3, 'f
|
127
|
+
beq .f32
|
128
|
+
cmpi cr0, r3, 'd
|
129
|
+
beq .f64
|
130
|
+
.i64:
|
131
|
+
lwz r3, SP_RESULT (r1)
|
132
|
+
lwz r4, SP_RESULT + 4 (r1)
|
133
|
+
.end:
|
134
|
+
lwz r1, SP_PREV(r1) /* restore stack pointer */
|
135
|
+
lwz r0, SP_LR(r1) /* load link register with return address */
|
136
|
+
mtlr r0
|
137
|
+
blr /* branch back to link register */
|
138
|
+
.f32:
|
139
|
+
lfs f1, SP_RESULT(r1)
|
140
|
+
b .end
|
141
|
+
.f64:
|
142
|
+
lfd f1, SP_RESULT(r1)
|
143
|
+
b .end
|
144
|
+
|
@@ -3,10 +3,10 @@
|
|
3
3
|
Package: dyncall
|
4
4
|
Library: dyncallback
|
5
5
|
File: dyncallback/dyncall_callback_ppc32.c
|
6
|
-
Description: Callback - Implementation Header for ppc32
|
6
|
+
Description: Callback - Implementation Header for ppc32
|
7
7
|
License:
|
8
8
|
|
9
|
-
Copyright (c) 2007-
|
9
|
+
Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
|
10
10
|
Tassilo Philipp <tphilipp@potion-studios.com>
|
11
11
|
|
12
12
|
Permission to use, copy, modify, and distribute this software for any
|
@@ -23,6 +23,7 @@
|
|
23
23
|
|
24
24
|
*/
|
25
25
|
|
26
|
+
|
26
27
|
#include "dyncall_callback.h"
|
27
28
|
#include "dyncall_callback_ppc32.h"
|
28
29
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
Description: Callback - Header for ppc32
|
7
7
|
License:
|
8
8
|
|
9
|
-
Copyright (c) 2007-
|
9
|
+
Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
|
10
10
|
Tassilo Philipp <tphilipp@potion-studios.com>
|
11
11
|
|
12
12
|
Permission to use, copy, modify, and distribute this software for any
|
@@ -33,11 +33,11 @@
|
|
33
33
|
|
34
34
|
struct DCCallback
|
35
35
|
{
|
36
|
-
DCThunk thunk; /* offset 0, size
|
37
|
-
DCCallbackHandler* handler; /* offset
|
38
|
-
size_t stack_cleanup; /* offset
|
39
|
-
void* userdata; /* offset
|
40
|
-
};
|
36
|
+
DCThunk thunk; /* offset 0, size 24 */
|
37
|
+
DCCallbackHandler* handler; /* offset 24, size 4 */
|
38
|
+
size_t stack_cleanup; /* offset 28, size 4 */
|
39
|
+
void* userdata; /* offset 32, size 4 */
|
40
|
+
}; /* total size 36 */
|
41
41
|
|
42
42
|
#endif /* DYNCALL_CALLBACK_PPC32_H */
|
43
43
|
|
@@ -3,10 +3,10 @@
|
|
3
3
|
Package: dyncall
|
4
4
|
Library: dyncallback
|
5
5
|
File: dyncallback/dyncall_callback_ppc32_apple.s
|
6
|
-
Description: Callback Thunk -
|
6
|
+
Description: Callback Thunk - PowerPC 32-bit System V ABI
|
7
7
|
License:
|
8
8
|
|
9
|
-
Copyright (c) 2007-
|
9
|
+
Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
|
10
10
|
Tassilo Philipp <tphilipp@potion-studios.com>
|
11
11
|
|
12
12
|
Permission to use, copy, modify, and distribute this software for any
|
@@ -27,12 +27,13 @@
|
|
27
27
|
.text
|
28
28
|
.align 2
|
29
29
|
|
30
|
-
/* Callback Thunk Entry code for Apple Mac OS X
|
30
|
+
/* Callback Thunk Entry code for PowerPC 32-bit Darwin/Apple Mac OS X. */
|
31
|
+
|
31
32
|
|
32
33
|
/* Stack Frame Layout:
|
33
34
|
|
34
|
-
|
35
|
-
56 DCArgs (32+104+4+8 =
|
35
|
+
204 DCValue ( )
|
36
|
+
56 DCArgs (32+104+4+8 = 148)
|
36
37
|
24 Parameter area ( 4*8 = 32 )
|
37
38
|
0 Linkage area ( 24 )
|
38
39
|
|
@@ -0,0 +1,170 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Package: dyncall
|
4
|
+
Library: dyncallback
|
5
|
+
File: dyncallback/dyncall_callback_ppc64.S
|
6
|
+
Description: Callback Thunk - Implementation for PowerPC 64-bit
|
7
|
+
License:
|
8
|
+
|
9
|
+
Copyright (c) 2014-2015 Masanori Mitsugi <mitsugi@linux.vnet.ibm.com>
|
10
|
+
|
11
|
+
Permission to use, copy, modify, and distribute this software for any
|
12
|
+
purpose with or without fee is hereby granted, provided that the above
|
13
|
+
copyright notice and this permission notice appear in all copies.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
16
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
17
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
18
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
19
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
20
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
21
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
22
|
+
|
23
|
+
*/
|
24
|
+
|
25
|
+
#include "../portasm/portasm-ppc64.S"
|
26
|
+
|
27
|
+
.text
|
28
|
+
.align 2
|
29
|
+
|
30
|
+
/* struct DCCallback */
|
31
|
+
|
32
|
+
#if DC__ABI_PPC64_ELF_V != 2
|
33
|
+
DCB_THUNK = 0 /* v1 */
|
34
|
+
DCB_HANDLER = 64
|
35
|
+
DCB_STACKCLEAN = 72
|
36
|
+
DCB_USERDATA = 80
|
37
|
+
#else
|
38
|
+
DCB_THUNK = 0 /* v2 */
|
39
|
+
DCB_HANDLER = 48
|
40
|
+
DCB_STACKCLEAN = 56
|
41
|
+
DCB_USERDATA = 64
|
42
|
+
#endif
|
43
|
+
|
44
|
+
/* struct DCArgs */
|
45
|
+
|
46
|
+
ARGS_IREGS = 0
|
47
|
+
ARGS_FREGS = ARGS_IREGS + 8*8
|
48
|
+
ARGS_SP = ARGS_FREGS + 8*13
|
49
|
+
ARGS_ICNT = ARGS_SP + 8
|
50
|
+
ARGS_FCNT = ARGS_ICNT + 4
|
51
|
+
ARGS_SIZE = ARGS_FCNT + 4
|
52
|
+
|
53
|
+
/* struct DCValue */
|
54
|
+
|
55
|
+
RESULT_SIZE = 8
|
56
|
+
|
57
|
+
/* Stack Offsets */
|
58
|
+
|
59
|
+
SP_PREV = 0
|
60
|
+
SP_CR = SP_PREV + 8
|
61
|
+
SP_LR = SP_CR + 8
|
62
|
+
#if DC__ABI_PPC64_ELF_V != 2
|
63
|
+
SP_TOC = 40
|
64
|
+
SP_PAR = 48
|
65
|
+
PAR_SZ = 64
|
66
|
+
#else
|
67
|
+
SP_TOC = 24
|
68
|
+
SP_PAR = 32
|
69
|
+
PAR_SZ = 0
|
70
|
+
#endif
|
71
|
+
SP_ARGS = SP_PAR + PAR_SZ
|
72
|
+
SP_IREGS = SP_ARGS + ARGS_IREGS
|
73
|
+
SP_FREGS = SP_ARGS + ARGS_FREGS
|
74
|
+
SP_SP = SP_ARGS + ARGS_SP
|
75
|
+
SP_ICNT = SP_ARGS + ARGS_ICNT
|
76
|
+
SP_FCNT = SP_ARGS + ARGS_FCNT
|
77
|
+
SP_RESULT = SP_ARGS + ARGS_SIZE
|
78
|
+
SP_LOCAL = SP_RESULT + RESULT_SIZE /* additional locals (reg 30/31) */
|
79
|
+
SP_SIZE = SP_LOCAL + 2*8
|
80
|
+
|
81
|
+
#define ALIGN(M,X) ( M+(X-1) & (-X) )
|
82
|
+
|
83
|
+
FRAMESIZE = ALIGN(SP_SIZE,16)
|
84
|
+
|
85
|
+
GLOBAL_C(dcCallbackThunkEntry)
|
86
|
+
ENTRY_C(dcCallbackThunkEntry)
|
87
|
+
|
88
|
+
/* --------------------------------------------------------------------------
|
89
|
+
|
90
|
+
Input:
|
91
|
+
r1 Stack Pointer
|
92
|
+
r3-r10 Integer Arguments
|
93
|
+
f1-f8 Floating-point Arguments
|
94
|
+
r11 Thunk Pointer
|
95
|
+
|
96
|
+
*/
|
97
|
+
|
98
|
+
mflr r0
|
99
|
+
std r0, SP_LR(r1) /* store return address */
|
100
|
+
std r31, -8(r1) /* store preserved registers (r31) */
|
101
|
+
addi r12, r1, SP_PAR /* temporary r12 = parameter area on callers stack frame */
|
102
|
+
stdu r1, -FRAMESIZE(r1) /* save callers stack pointer and make new stack frame. */
|
103
|
+
|
104
|
+
std r3, SP_IREGS + 0*8(r1) /* spill 8 integer parameter registers */
|
105
|
+
std r4, SP_IREGS + 1*8(r1)
|
106
|
+
std r5, SP_IREGS + 2*8(r1)
|
107
|
+
std r6, SP_IREGS + 3*8(r1)
|
108
|
+
std r7, SP_IREGS + 4*8(r1)
|
109
|
+
std r8, SP_IREGS + 5*8(r1)
|
110
|
+
std r9, SP_IREGS + 6*8(r1)
|
111
|
+
std r10,SP_IREGS + 7*8(r1)
|
112
|
+
stfd f1, SP_FREGS + 0*8(r1) /* spill 13 float parameter registers */
|
113
|
+
stfd f2, SP_FREGS + 1*8(r1)
|
114
|
+
stfd f3, SP_FREGS + 2*8(r1)
|
115
|
+
stfd f4, SP_FREGS + 3*8(r1)
|
116
|
+
stfd f5, SP_FREGS + 4*8(r1)
|
117
|
+
stfd f6, SP_FREGS + 5*8(r1)
|
118
|
+
stfd f7, SP_FREGS + 6*8(r1)
|
119
|
+
stfd f8, SP_FREGS + 7*8(r1)
|
120
|
+
stfd f9, SP_FREGS + 8*8(r1)
|
121
|
+
stfd f10,SP_FREGS + 9*8(r1)
|
122
|
+
stfd f11,SP_FREGS +10*8(r1)
|
123
|
+
stfd f12,SP_FREGS +11*8(r1)
|
124
|
+
stfd f13,SP_FREGS +12*8(r1)
|
125
|
+
/* initialize struct DCCallback */
|
126
|
+
std r12,SP_SP(r1) /* init stack pointer */
|
127
|
+
xor r0, r0, r0 /* init register counters */
|
128
|
+
std r0, SP_ICNT(r1)
|
129
|
+
std r0, SP_FCNT(r1)
|
130
|
+
std r0, SP_RESULT(r1) /* init result object */
|
131
|
+
/* invoke callback handler */
|
132
|
+
mr r3, r11 /* arg 1: DCCallback* pcb (r11 is thunk pointer) */
|
133
|
+
addi r4, r1, SP_ARGS /* arg 2: DCArgs* args */
|
134
|
+
addi r5, r1, SP_RESULT /* arg 3: DCValue* result */
|
135
|
+
ld r6, DCB_USERDATA(r11) /* arg 4: void* userdata */
|
136
|
+
|
137
|
+
/* branch-and-link to DCCallback.handler */
|
138
|
+
ld r12, DCB_HANDLER(r11)
|
139
|
+
std r2, SP_TOC(r1)
|
140
|
+
#if DC__ABI_PPC64_ELF_V != 2
|
141
|
+
ld r2, 8(r12)
|
142
|
+
ld r0, 0(r12)
|
143
|
+
mtctr r0
|
144
|
+
#else
|
145
|
+
mtctr r12
|
146
|
+
#endif
|
147
|
+
bctrl
|
148
|
+
|
149
|
+
/* check result type */
|
150
|
+
cmpi cr0, r3, 'f
|
151
|
+
beq .f32
|
152
|
+
cmpi cr0, r3, 'd
|
153
|
+
beq .f64
|
154
|
+
.i64:
|
155
|
+
ld r3, SP_RESULT(r1)
|
156
|
+
b .end
|
157
|
+
.end:
|
158
|
+
|
159
|
+
ld r2, SP_TOC(r1)
|
160
|
+
ld r1, SP_PREV(r1) /* restore stack pointer */
|
161
|
+
ld r31, -8(r1) /* restore preserved registers */
|
162
|
+
ld r0, SP_LR(r1) /* load link register with return address */
|
163
|
+
mtlr r0
|
164
|
+
blr /* branch back to link register */
|
165
|
+
.f32:
|
166
|
+
lfs f1, SP_RESULT(r1)
|
167
|
+
b .end
|
168
|
+
.f64:
|
169
|
+
lfd f1, SP_RESULT(r1)
|
170
|
+
b .end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Package: dyncall
|
4
|
+
Library: dyncallback
|
5
|
+
File: dyncallback/dyncall_callback_ppc64.c
|
6
|
+
Description: Callback - Implementation Header for ppc64
|
7
|
+
License:
|
8
|
+
|
9
|
+
Copyright (c) 2014-2015 Masanori Mitsugi <mitsugi@linux.vnet.ibm.com>
|
10
|
+
|
11
|
+
Permission to use, copy, modify, and distribute this software for any
|
12
|
+
purpose with or without fee is hereby granted, provided that the above
|
13
|
+
copyright notice and this permission notice appear in all copies.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
16
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
17
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
18
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
19
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
20
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
21
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
22
|
+
|
23
|
+
*/
|
24
|
+
|
25
|
+
|
26
|
+
#include "dyncall_callback.h"
|
27
|
+
#include "dyncall_callback_ppc64.h"
|
28
|
+
|
29
|
+
void dcbInitCallback(DCCallback* pcb, const char* signature, DCCallbackHandler* handler, void* userdata)
|
30
|
+
{
|
31
|
+
const char* ptr;
|
32
|
+
char ch;
|
33
|
+
|
34
|
+
pcb->handler = handler;
|
35
|
+
pcb->userdata = userdata;
|
36
|
+
}
|
37
|
+
|
38
|
+
extern void dcCallbackThunkEntry();
|
39
|
+
|
40
|
+
DCCallback* dcbNewCallback(const char* signature, DCCallbackHandler* handler, void* userdata)
|
41
|
+
{
|
42
|
+
DCCallback* pcb;
|
43
|
+
int err = dcAllocWX(sizeof(DCCallback), (void**) &pcb);
|
44
|
+
if (err != 0) return 0;
|
45
|
+
|
46
|
+
dcbInitThunk(&pcb->thunk, dcCallbackThunkEntry);
|
47
|
+
dcbInitCallback(pcb, signature, handler, userdata);
|
48
|
+
|
49
|
+
return pcb;
|
50
|
+
}
|
51
|
+
|
52
|
+
void dcbFreeCallback(DCCallback* pcb)
|
53
|
+
{
|
54
|
+
dcFreeWX(pcb, sizeof(DCCallback));
|
55
|
+
}
|
56
|
+
|
57
|
+
void* dcbGetUserData(DCCallback* pcb)
|
58
|
+
{
|
59
|
+
return pcb->userdata;
|
60
|
+
}
|