annotate dyncallback/dyncall_callback_sparc32.s @ 157:49549739228c

- sparc callback asm and args code (still some stack alignment issues, currently) - doc improvements for sparc callconv
author cslag
date Wed, 28 Dec 2016 16:48:35 -0600
parents bbefb8b8e74c
children de5ed248757f
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_sparc32.s
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 Description: Callback Thunk - Implementation for Sparc 32-bit
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
155
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 15
diff changeset
9 Copyright (c) 2007-2016 Daniel Adler <dadler@uni-goettingen.de>,
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 Tassilo Philipp <tphilipp@potion-studios.com>
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 Permission to use, copy, modify, and distribute this software for any
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 purpose with or without fee is hereby granted, provided that the above
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 copyright notice and this permission notice appear in all copies.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
24 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
25
155
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 15
diff changeset
26 /* input:
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 15
diff changeset
27 $i0 -> thunk
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 15
diff changeset
28 $i0+24 -> cb handler
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 15
diff changeset
29 $i0+28 -> userdata
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 15
diff changeset
30 */
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 15
diff changeset
31
157
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
32 .text
15
03c516772c65 - consistency in filenames that have cpp logic .s -> .S
cslag
parents: 0
diff changeset
33 .globl dcCallbackThunkEntry
157
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
34
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
35 /* Called by thunk - thunk stores pointer to DCCallback */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
36 /* in %g1, and pointer to called function in %g2 */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
37 dcCallbackThunkEntry:
157
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
38
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
39 /* Prolog. */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
40 /* Frame size of 80b comes from needing storage space for the following: */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
41 /* DCargs(sparc_req_reg_save_area:64 + argptr:4) + pad:4 + retval:8 */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
42 save %sp, -80, %sp
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
43
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
44 /* Spill register args. */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
45 st %i0, [ %fp + 68 ] /* reg arg 0 */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
46 st %i1, [ %fp + 72 ] /* reg arg 1 */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
47 st %i2, [ %fp + 76 ] /* reg arg 2 */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
48 st %i3, [ %fp + 80 ] /* reg arg 3 */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
49 st %i4, [ %fp + 84 ] /* reg arg 4 */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
50 st %i5, [ %fp + 88 ] /* reg arg 5 */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
51 add %fp, 68, %l0
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
52 st %l0, [ %sp + 64 ] /* init arg_ptr */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
53
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
54 /* Zero retval store (for data < word size). */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
55 st %g0, [ %sp + 72 ]
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
56 st %g0, [ %sp + 76 ]
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
57
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
58 /* Prepare callback handler call. */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
59 mov %g1, %o0 /* Param 0 = DCCallback*, %g1 holds ptr to thunk */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
60 add %sp, 64, %o1 /* Param 1 = DCArgs* (ptr to struct with args ptr */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
61 add %sp, 72, %o2 /* Param 2 = results ptr to 8b of local stack data */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
62 ld [ %g1 + 28 ], %o3 /* Param 3 = userdata ptr */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
63
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
64 ld [ %g1 + 24 ], %l0
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
65 call %l0
155
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 15
diff changeset
66 nop
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
67
157
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
68 /* Put retval in %i0/%i1 (to be in caller's %o0/%o1), and %f0/%f1. */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
69 ld [ %sp + 72 ], %i0
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
70 ld [ %sp + 76 ], %i1
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
71 ld [ %sp + 72 ], %f0
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
72 ld [ %sp + 76 ], %f1
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
73
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
74 /* Epilog. */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
75 restore /* unshift reg window */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
76 retl /* Return from proc. -- jmpl %i7 + 8, %g0 */
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
77 nop
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 155
diff changeset
78