1 /* -----------------------------------------------------------------------
2 sysv.S - Copyright (c) 2000 Software AG
4 S390 Foreign Function Interface
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 ``Software''), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice shall be included
15 in all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 OTHER DEALINGS IN THE SOFTWARE.
24 ----------------------------------------------------------------------- */
28 #ifdef HAVE_MACHINE_ASM_H
29 #include <machine/asm.h>
41 # This assumes we are using gas.
43 .type ffi_call_SYSV,%function
49 l %r7,96(%r15) # Get A(fn)
51 ahi %r15,-128 # Make room for my args
53 st %r0,0(%r15) # Set backchain
54 lr %r11,%r15 # Establish my stack register
56 sr %r15,%r4 # Make room for fn args
57 ahi %r15,-96 # Make room for new frame
58 lr %r10,%r15 # Establish stack build area
59 ahi %r15,-96 # Stack for next call
61 stm %r2,%r7,96(%r11) # Save args on my stack
63 #------------------------------------------------------------------
64 # move first 3 parameters in registers
65 #------------------------------------------------------------------
66 lr %r9,%r2 # r9: &ffi_prep_args
67 lr %r2,%r10 # Parm 1: &stack Parm 2: &ecif
68 basr %r14,%r9 # call ffi_prep_args
70 #------------------------------------------------------------------
71 # load first 5 parameter registers
72 #------------------------------------------------------------------
75 #------------------------------------------------------------------
76 # load fp parameter registers
77 #------------------------------------------------------------------
81 #------------------------------------------------------------------
83 #------------------------------------------------------------------
84 lr %r15,%r10 # Set new stack
85 l %r9,116(%r11) # Get &fn
86 basr %r14,%r9 # Call function
88 #------------------------------------------------------------------
90 # r2: Return value (r3: Return value + 4 for long long)
91 #------------------------------------------------------------------
93 #------------------------------------------------------------------
94 # If the return value pointer is NULL, assume no return value.
95 #------------------------------------------------------------------
99 l %r5,108(%r11) # Get return type
100 #------------------------------------------------------------------
102 #------------------------------------------------------------------
110 #------------------------------------------------------------------
111 # return LONG LONG (signed/unsigned)
112 #------------------------------------------------------------------
113 chi %r5,FFI_TYPE_UINT64
116 chi %r5,FFI_TYPE_SINT64
124 #------------------------------------------------------------------
126 #------------------------------------------------------------------
127 chi %r5,FFI_TYPE_FLOAT
134 #------------------------------------------------------------------
135 # return DOUBLE or LONGDOUBLE
136 #------------------------------------------------------------------
137 chi %r5,FFI_TYPE_DOUBLE
145 #------------------------------------------------------------------
146 # Structure - rvalue already set as sent as 1st parm to routine
147 #------------------------------------------------------------------
148 chi %r5,FFI_TYPE_STRUCT
152 #------------------------------------------------------------------
154 #------------------------------------------------------------------
166 .size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
169 .section .eh_frame,"aw",@progbits
171 .4byte .LECIE1-.LSCIE1 # Length of Common Information Entry
173 .4byte 0x0 # CIE Identifier Tag
174 .byte 0x1 # CIE Version
175 .ascii "\0" # CIE Augmentation
176 .uleb128 0x1 # CIE Code Alignment Factor
177 .sleb128 -4 # CIE Data Alignment Factor
178 .byte 0xe # CIE RA Column
179 .byte 0xc # DW_CFA_def_cfa
185 .4byte .LEFDE1-.LASFDE1 # FDE Length
187 .4byte .LASFDE1-.Lframe1 # FDE CIE offset
188 .4byte .LFB1 # FDE initial location
189 .4byte .LFE1-.LFB1 # FDE address range
190 .uleb128 0x0 # Augmentation size
191 .byte 0x4 # DW_CFA_advance_loc4
193 .byte 0x8f # DW_CFA_offset, column 0xf
195 .byte 0x8e # DW_CFA_offset, column 0xe
197 .byte 0x8d # DW_CFA_offset, column 0xd
199 .byte 0x8c # DW_CFA_offset, column 0xc
201 .byte 0x8b # DW_CFA_offset, column 0xb
203 .byte 0x8a # DW_CFA_offset, column 0xa
205 .byte 0x89 # DW_CFA_offset, column 0x9
207 .byte 0x88 # DW_CFA_offset, column 0x8
209 .byte 0x87 # DW_CFA_offset, column 0x7
211 .byte 0x86 # DW_CFA_offset, column 0x6
213 .byte 0x4 # DW_CFA_advance_loc4
215 .byte 0xe # DW_CFA_def_cfa_offset
217 .byte 0x4 # DW_CFA_advance_loc4
219 .byte 0xd # DW_CFA_def_cfa_register