Mercurial > pub > dyncall > dyncall
annotate dyncallback/dyncall_callback_sparc64.s @ 194:41d6945f5858
- sparc doc improvements (esp. for sparc64)
author | Tassilo Philipp |
---|---|
date | Sat, 18 Mar 2017 19:08:45 +0100 |
parents | 2f7a7f3472cb |
children | 95cf20c0d1de |
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 */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
32 .set BIAS, 2047 |
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. */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
42 /* Frame size of 208b comes from needing storage space for the following: */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
43 /* DCargs(sparc_req_reg_save_area:128 + spill:64 + argptr:8) + retval:8 */ |
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 */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
45 /* 4 arguments, and retval doesn't need stack, but let's be conservative. */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
46 save %sp, -208, %sp |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
47 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
48 /* Spill register args. */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
49 add %fp, BIAS + 136, %l0 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
50 stx %i0, [ %l0 + 0 ] /* reg arg 0 */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
51 stx %i1, [ %l0 + 8 ] /* reg arg 1 */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
52 stx %i2, [ %l0 + 16 ] /* reg arg 2 */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
53 stx %i3, [ %l0 + 24 ] /* reg arg 3 */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
54 stx %i4, [ %l0 + 32 ] /* reg arg 4 */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
55 stx %i5, [ %l0 + 40 ] /* reg arg 5 */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
56 stx %l0, [ %sp + BIAS + 192 ] /* init arg_ptr */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
57 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
58 /* Zero retval store. */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
59 stx %g0, [ %sp + BIAS + 200 ] |
0 | 60 |
191
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
61 /* Prepare callback handler call. */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
62 mov %g1, %o0 /* Param 0 = DCCallback*, %g1 holds ptr to thunk */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
63 add %sp, BIAS + 192, %o1 /* Param 1 = DCArgs* (ptr to struct with args ptr) */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
64 add %sp, BIAS + 200, %o2 /* Param 2 = results ptr to 8b of local stack data */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
65 ldx [ %g1 + 64 ], %o3 /* Param 3 = userdata ptr */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
66 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
67 /* 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
|
68 ldx [ %g1 + 56 ], %l0 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
69 call %l0 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
70 nop |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
71 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
72 /* Put retval in %i0 (to be in caller's %o0), and %f0. */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
73 ldx [ %sp + BIAS + 200 ], %i0 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
74 ldd [ %sp + BIAS + 200 ], %f0 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
75 |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
76 /* Epilog. */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
77 restore /* unshift reg window */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
78 retl /* Return from proc. -- jmpl %i7 + 8, %g0 */ |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
79 nop |
2f7a7f3472cb
- first draft at sparc64 callbacks (floats not working, yet)
Tassilo Philipp
parents:
15
diff
changeset
|
80 |