Mercurial > pub > dyncall > dyncall
comparison dyncallback/dyncall_callback_sparc64.s @ 191:2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
author | Tassilo Philipp |
---|---|
date | Fri, 17 Mar 2017 03:27:36 +0100 |
parents | 03c516772c65 |
children | 95cf20c0d1de |
comparison
equal
deleted
inserted
replaced
190:06ee88ce4962 | 191:2f7a7f3472cb |
---|---|
1 /* | 1 /* |
2 | 2 |
3 Package: dyncall | 3 Package: dyncall |
4 Library: dyncallback | 4 Library: dyncallback |
5 File: dyncallback/dyncall_callback_sparc64.s | 5 File: dyncallback/dyncall_callback_sparc64.s |
6 Description: Callback Thunk - Implementation for Sparc 64-bit | 6 Description: Callback - Implementation for Sparc 64-bit |
7 License: | 7 License: |
8 | 8 |
9 Copyright (c) 2007-2011 Daniel Adler <dadler@uni-goettingen.de>, | 9 Copyright (c) 2017 Tassilo Philipp <tphilipp@potion-studios.com> |
10 Tassilo Philipp <tphilipp@potion-studios.com> | |
11 | 10 |
12 Permission to use, copy, modify, and distribute this software for any | 11 Permission to use, copy, modify, and distribute this software for any |
13 purpose with or without fee is hereby granted, provided that the above | 12 purpose with or without fee is hereby granted, provided that the above |
14 copyright notice and this permission notice appear in all copies. | 13 copyright notice and this permission notice appear in all copies. |
15 | 14 |
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 21 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
23 | 22 |
24 */ | 23 */ |
25 | 24 |
25 /* input: | |
26 $i0 -> thunk | |
27 $i0+56 -> cb handler | |
28 $i0+64 -> userdata | |
29 */ | |
30 | |
31 /* NOTE: %sp/%fp for v9 are offset, using them needs a "BIAS" of 2047 */ | |
32 .set BIAS, 2047 | |
33 | |
34 .text | |
26 .globl dcCallbackThunkEntry | 35 .globl dcCallbackThunkEntry |
36 | |
37 /* Called by thunk - thunk stores pointer to DCCallback */ | |
38 /* in %g1, and pointer to called function in %g2 */ | |
27 dcCallbackThunkEntry: | 39 dcCallbackThunkEntry: |
28 jmpl %i7 + 8, %g0 /* Return from proc. */ | |
29 nop | |
30 | 40 |
41 /* Prolog. */ | |
42 /* Frame size of 208b comes from needing storage space for the following: */ | |
43 /* DCargs(sparc_req_reg_save_area:128 + spill:64 + argptr:8) + retval:8 */ | |
44 /* Spill area could theoretically be only 32b, b/c cbHandler function has */ | |
45 /* 4 arguments, and retval doesn't need stack, but let's be conservative. */ | |
46 save %sp, -208, %sp | |
47 | |
48 /* Spill register args. */ | |
49 add %fp, BIAS + 136, %l0 | |
50 stx %i0, [ %l0 + 0 ] /* reg arg 0 */ | |
51 stx %i1, [ %l0 + 8 ] /* reg arg 1 */ | |
52 stx %i2, [ %l0 + 16 ] /* reg arg 2 */ | |
53 stx %i3, [ %l0 + 24 ] /* reg arg 3 */ | |
54 stx %i4, [ %l0 + 32 ] /* reg arg 4 */ | |
55 stx %i5, [ %l0 + 40 ] /* reg arg 5 */ | |
56 stx %l0, [ %sp + BIAS + 192 ] /* init arg_ptr */ | |
57 | |
58 /* Zero retval store. */ | |
59 stx %g0, [ %sp + BIAS + 200 ] | |
60 | |
61 /* Prepare callback handler call. */ | |
62 mov %g1, %o0 /* Param 0 = DCCallback*, %g1 holds ptr to thunk */ | |
63 add %sp, BIAS + 192, %o1 /* Param 1 = DCArgs* (ptr to struct with args ptr) */ | |
64 add %sp, BIAS + 200, %o2 /* Param 2 = results ptr to 8b of local stack data */ | |
65 ldx [ %g1 + 64 ], %o3 /* Param 3 = userdata ptr */ | |
66 | |
67 /* Fetch callback handler address (after thunk blob) and call. */ | |
68 ldx [ %g1 + 56 ], %l0 | |
69 call %l0 | |
70 nop | |
71 | |
72 /* Put retval in %i0 (to be in caller's %o0), and %f0. */ | |
73 ldx [ %sp + BIAS + 200 ], %i0 | |
74 ldd [ %sp + BIAS + 200 ], %f0 | |
75 | |
76 /* Epilog. */ | |
77 restore /* unshift reg window */ | |
78 retl /* Return from proc. -- jmpl %i7 + 8, %g0 */ | |
79 nop | |
80 |