Mercurial > pub > dyncall > dyncall
annotate dyncallback/dyncall_callback_mips_n64.S @ 315:3840e0188520
- allowing lookup of running executable's path by passing NULL to dynload's dlGetLibraryPath()
author | Tassilo Philipp |
---|---|
date | Wed, 06 Nov 2019 14:13:49 +0100 |
parents | b104c5beec8b |
children |
rev | line source |
---|---|
94 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncallback | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
138
diff
changeset
|
5 File: dyncallback/dyncall_callback_mips_n64.S |
101
1ce60358fbad
- mips related cleanup, mostly comments, cpp macro lib
cslag
parents:
94
diff
changeset
|
6 Description: Callback Thunk - Implementation for mips64 n64 |
94 | 7 License: |
8 | |
305 | 9 Copyright (c) 2016-2018 Tassilo Philipp <tphilipp@potion-studios.com> |
94 | 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 | |
122
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
25 /* input: |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
26 $t8 -> thunk |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
27 $t8+56 -> cb handler |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
28 $t8+64 -> userdata |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
29 */ |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
30 |
305 | 31 /* Frame size is 160b for hard- and 128b for soft-float, as follows: */ |
32 /* DCargs(fregs:64? + iregs:64 + regcnts:8 + sp:8) + rval:8 + ra:8 */ | |
33 #if defined(DC__ABI_HARDFLOAT) | |
34 SP_SP = 160 | |
35 #else | |
36 SP_SP = 96 | |
37 #endif | |
38 SP_LR = SP_SP-8 | |
39 SP_RVAL = SP_SP-16 | |
40 SP_ARG_SP = SP_SP-24 | |
41 SP_ARG_RC = SP_SP-32 | |
42 | |
116 | 43 .section .mdebug.abi64 |
44 .previous | |
45 .abicalls | |
46 .text | |
47 .align 2 | |
94 | 48 .globl dcCallbackThunkEntry |
116 | 49 .ent dcCallbackThunkEntry |
94 | 50 dcCallbackThunkEntry: |
122
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
51 .set noreorder |
94 | 52 |
122
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
53 /* Prolog. */ |
305 | 54 daddiu $sp, $sp, -SP_SP /* open frame */ |
55 sd $ra, SP_LR($sp) /* save link register */ | |
122
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
56 |
305 | 57 .frame $fp,SP_SP,$31 /* specify our frame: fp,size,lr; creates virt $fp */ |
138
1b0c02e827c4
mips n64 fixes for platforms using hiword of addresses
cslag
parents:
124
diff
changeset
|
58 /* code below doesn't use $fp though, as n/a with -O1 */ |
122
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
59 /* Init return value */ |
305 | 60 sd $zero, SP_RVAL($sp) |
122
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
61 |
305 | 62 /* Store reg args where our DCargs member arrays are, in local stack area */ |
122
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
63 sd $4, 0($sp) |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
64 sd $5, 8($sp) |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
65 sd $6, 16($sp) |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
66 sd $7, 24($sp) |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
67 sd $8, 32($sp) |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
68 sd $9, 40($sp) |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
69 sd $10, 48($sp) |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
70 sd $11, 56($sp) |
305 | 71 #if defined(DC__ABI_HARDFLOAT) |
122
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
72 s.d $f12, 64($sp) |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
73 s.d $f13, 72($sp) |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
74 s.d $f14, 80($sp) |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
75 s.d $f15, 88($sp) |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
76 s.d $f16, 96($sp) |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
77 s.d $f17, 104($sp) |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
78 s.d $f18, 112($sp) |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
79 s.d $f19, 120($sp) |
305 | 80 #endif |
116 | 81 |
122
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
82 /* Init DCarg's reg_counts and stackptr. */ |
305 | 83 sd $zero, SP_ARG_RC($sp) /* reg_count */ |
84 daddiu $4, $sp, SP_SP | |
85 sd $4, SP_ARG_SP($sp) /* stackptr */ | |
122
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
86 |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
87 /* Prepare callback handler call. */ |
305 | 88 move $4, $24 /* Param 0 = DCCallback*, $24/$t8 holds DCThunk* */ |
89 move $5, $sp /* Param 1 = ptr to where DCArgs* is stored */ | |
90 daddiu $6, $sp, SP_RVAL /* Param 2 = results ptr to 8b of local stack data */ | |
91 ld $7, 64($24) /* Param 3 = userdata pointer */ | |
122
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
92 |
305 | 93 ld $25, 56($24) /* store handler entry in $25/$t9, required for PIC */ |
94 jalr $25 /* jump */ | |
95 nop /* branch delay nop */ | |
122
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
96 |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
97 /* Copy result in corresponding registers $2-$3 ($v0-$v1) and $f0 */ |
305 | 98 ld $2, SP_RVAL($sp) /* note: ignoring 2nd possible retval in $3, here */ |
99 #if defined(DC__ABI_HARDFLOAT) | |
100 l.d $f0, SP_RVAL($sp) | |
101 #endif | |
122
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
102 |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
103 /* Epilog. Tear down frame and return. */ |
305 | 104 ld $ra, SP_LR($sp) /* restore return address */ |
105 daddiu $sp, $sp, SP_SP /* close frame */ | |
106 j $ra /* return */ | |
107 nop /* branch delay nop */ | |
122
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
108 |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
109 .set reorder |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
110 .end dcCallbackThunkEntry |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
111 .ident "handwritten" |
f63467916f98
- first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
116
diff
changeset
|
112 |