Mercurial > pub > dyncall > dyncall
annotate dyncallback/dyncall_callback_sparc64.s @ 301:74948b02cfa0
- changelog
author | Tassilo Philipp |
---|---|
date | Sun, 20 May 2018 02:23:44 +0200 |
parents | 91db39538e78 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncallback | |
5 File: dyncallback/dyncall_callback_sparc64.s | |
191
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
6 Description: Callback - Implementation for Sparc 64-bit |
0 | 7 License: |
8 | |
191
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
9 Copyright (c) 2017 Tassilo Philipp <tphilipp@potion-studios.com> |
0 | 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 | |
191
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
25 /* input: |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
26 $i0 -> thunk |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
27 $i0+56 -> cb handler |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
28 $i0+64 -> userdata |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
29 */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
30 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
31 /* NOTE: %sp/%fp for v9 are offset, using them needs a "BIAS" of 2047 */ |
249
91db39538e78
- replaced `.set' directives used to set symbol values in assembly files with (seemingly) more portable `=' syntax (e.g. older versions of Sun's `as' don't handle `.set')
Tassilo Philipp
parents:
196
diff
changeset
|
32 BIAS = 2047 |
191
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
33 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
34 .text |
15
03c516772c65
- consistency in filenames that have cpp logic .s -> .S
cslag
parents:
0
diff
changeset
|
35 .globl dcCallbackThunkEntry |
191
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
36 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
37 /* Called by thunk - thunk stores pointer to DCCallback */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
38 /* in %g1, and pointer to called function in %g2 */ |
0 | 39 dcCallbackThunkEntry: |
191
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
40 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
41 /* Prolog. */ |
196 | 42 /* Frame size of 336b comes from needing storage space for the following: */ |
43 /* req_reg_save_area:128 + spill:48 + dcargs:144 + retval:8 + pad:8 */ | |
191
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
44 /* Spill area could theoretically be only 32b, b/c cbHandler function has */ |
196 | 45 /* 4 arguments, but let's be conservative. */ |
46 save %sp, -336, %sp | |
191
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
47 |
196 | 48 /* Spill register args as dcargs is based on that (in prev frame, after */ |
49 /* req_reg_save_area). */ | |
50 add %fp, BIAS + 128, %l0 | |
51 stx %i0, [ %l0 + 0 ] /* reg arg 0 */ | |
52 stx %i1, [ %l0 + 8 ] /* reg arg 1 */ | |
53 stx %i2, [ %l0 + 16 ] /* reg arg 2 */ | |
54 stx %i3, [ %l0 + 24 ] /* reg arg 3 */ | |
55 stx %i4, [ %l0 + 32 ] /* reg arg 4 */ | |
56 stx %i5, [ %l0 + 40 ] /* reg arg 5 */ | |
57 stx %l0, [ %sp + BIAS + 176 ] /* set DCArg's arg_ptr */ | |
58 st %f0, [ %sp + BIAS + 184 ] /* store fp args in DCArgs's dreg_data */ | |
59 st %f1, [ %sp + BIAS + 188 ] /* @@@ I think stx should work to store */ | |
60 st %f2, [ %sp + BIAS + 192 ] /* all 64bits, but I get "Illegal */ | |
61 st %f3, [ %sp + BIAS + 196 ] /* Operands", so using single prec. */ | |
62 st %f4, [ %sp + BIAS + 200 ] /* store (st) */ | |
63 st %f5, [ %sp + BIAS + 204 ] | |
64 st %f6, [ %sp + BIAS + 208 ] | |
65 st %f7, [ %sp + BIAS + 212 ] | |
66 st %f8, [ %sp + BIAS + 216 ] | |
67 st %f9, [ %sp + BIAS + 220 ] | |
68 st %f10, [ %sp + BIAS + 224 ] | |
69 st %f11, [ %sp + BIAS + 228 ] | |
70 st %f12, [ %sp + BIAS + 232 ] | |
71 st %f13, [ %sp + BIAS + 236 ] | |
72 st %f14, [ %sp + BIAS + 240 ] | |
73 st %f15, [ %sp + BIAS + 244 ] | |
74 st %f16, [ %sp + BIAS + 248 ] | |
75 st %f17, [ %sp + BIAS + 252 ] | |
76 st %f18, [ %sp + BIAS + 256 ] | |
77 st %f19, [ %sp + BIAS + 260 ] | |
78 st %f20, [ %sp + BIAS + 264 ] | |
79 st %f21, [ %sp + BIAS + 268 ] | |
80 st %f22, [ %sp + BIAS + 272 ] | |
81 st %f23, [ %sp + BIAS + 276 ] | |
82 st %f24, [ %sp + BIAS + 280 ] | |
83 st %f25, [ %sp + BIAS + 284 ] | |
84 st %f26, [ %sp + BIAS + 288 ] | |
85 st %f27, [ %sp + BIAS + 292 ] | |
86 st %f28, [ %sp + BIAS + 296 ] | |
87 st %f29, [ %sp + BIAS + 300 ] | |
88 st %f30, [ %sp + BIAS + 304 ] | |
89 st %f31, [ %sp + BIAS + 308 ] | |
90 stx %g0, [ %sp + BIAS + 312 ] /* init DCArg's i */ | |
191
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
91 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
92 /* Zero retval store. */ |
196 | 93 stx %g0, [ %sp + BIAS + 320 ] |
0 | 94 |
191
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
95 /* Prepare callback handler call. */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
96 mov %g1, %o0 /* Param 0 = DCCallback*, %g1 holds ptr to thunk */ |
196 | 97 add %sp, BIAS + 176, %o1 /* Param 1 = DCArgs* (ptr to struct with args ptr) */ |
98 add %sp, BIAS + 320, %o2 /* Param 2 = results ptr to 8b of local stack data */ | |
191
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
99 ldx [ %g1 + 64 ], %o3 /* Param 3 = userdata ptr */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
100 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
101 /* Fetch callback handler address (after thunk blob) and call. */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
102 ldx [ %g1 + 56 ], %l0 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
103 call %l0 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
104 nop |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
105 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
106 /* Put retval in %i0 (to be in caller's %o0), and %f0. */ |
196 | 107 ldx [ %sp + BIAS + 320 ], %i0 |
108 ldd [ %sp + BIAS + 320 ], %f0 | |
191
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
109 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
110 /* Epilog. */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
111 restore /* unshift reg window */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
112 retl /* Return from proc. -- jmpl %i7 + 8, %g0 */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
113 nop |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
114 |