annotate dyncallback/dyncall_callback_sparc64.s @ 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')
author Tassilo Philipp
date Sat, 13 May 2017 23:02:17 +0200
parents 95cf20c0d1de
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 /*
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
3 Package: dyncall
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4 Library: dyncallback
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 License:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11 Permission to use, copy, modify, and distribute this software for any
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 purpose with or without fee is hereby granted, provided that the above
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 copyright notice and this permission notice appear in all copies.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
42 /* Frame size of 336b comes from needing storage space for the following: */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
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
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
45 /* 4 arguments, but let's be conservative. */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
46 save %sp, -336, %sp
191
2f7a7f3472cb - first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents: 15
diff changeset
47
196
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
48 /* Spill register args as dcargs is based on that (in prev frame, after */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
49 /* req_reg_save_area). */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
50 add %fp, BIAS + 128, %l0
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
51 stx %i0, [ %l0 + 0 ] /* reg arg 0 */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
52 stx %i1, [ %l0 + 8 ] /* reg arg 1 */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
53 stx %i2, [ %l0 + 16 ] /* reg arg 2 */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
54 stx %i3, [ %l0 + 24 ] /* reg arg 3 */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
55 stx %i4, [ %l0 + 32 ] /* reg arg 4 */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
56 stx %i5, [ %l0 + 40 ] /* reg arg 5 */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
57 stx %l0, [ %sp + BIAS + 176 ] /* set DCArg's arg_ptr */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
58 st %f0, [ %sp + BIAS + 184 ] /* store fp args in DCArgs's dreg_data */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
59 st %f1, [ %sp + BIAS + 188 ] /* @@@ I think stx should work to store */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
60 st %f2, [ %sp + BIAS + 192 ] /* all 64bits, but I get "Illegal */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
61 st %f3, [ %sp + BIAS + 196 ] /* Operands", so using single prec. */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
62 st %f4, [ %sp + BIAS + 200 ] /* store (st) */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
63 st %f5, [ %sp + BIAS + 204 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
64 st %f6, [ %sp + BIAS + 208 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
65 st %f7, [ %sp + BIAS + 212 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
66 st %f8, [ %sp + BIAS + 216 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
67 st %f9, [ %sp + BIAS + 220 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
68 st %f10, [ %sp + BIAS + 224 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
69 st %f11, [ %sp + BIAS + 228 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
70 st %f12, [ %sp + BIAS + 232 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
71 st %f13, [ %sp + BIAS + 236 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
72 st %f14, [ %sp + BIAS + 240 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
73 st %f15, [ %sp + BIAS + 244 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
74 st %f16, [ %sp + BIAS + 248 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
75 st %f17, [ %sp + BIAS + 252 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
76 st %f18, [ %sp + BIAS + 256 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
77 st %f19, [ %sp + BIAS + 260 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
78 st %f20, [ %sp + BIAS + 264 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
79 st %f21, [ %sp + BIAS + 268 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
80 st %f22, [ %sp + BIAS + 272 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
81 st %f23, [ %sp + BIAS + 276 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
82 st %f24, [ %sp + BIAS + 280 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
83 st %f25, [ %sp + BIAS + 284 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
84 st %f26, [ %sp + BIAS + 288 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
85 st %f27, [ %sp + BIAS + 292 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
86 st %f28, [ %sp + BIAS + 296 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
87 st %f29, [ %sp + BIAS + 300 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
88 st %f30, [ %sp + BIAS + 304 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
89 st %f31, [ %sp + BIAS + 308 ]
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
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
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
93 stx %g0, [ %sp + BIAS + 320 ]
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
97 add %sp, BIAS + 176, %o1 /* Param 1 = DCArgs* (ptr to struct with args ptr) */
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
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
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
107 ldx [ %sp + BIAS + 320 ], %i0
95cf20c0d1de - sparc64 callbacks:
Tassilo Philipp
parents: 191
diff changeset
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