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 ----------------------------------------------------------------------- */
27 #include <fficonfig.h>
41 # This assumes we are using gas.
43 .type ffi_call_SYSV,%function
46 stm %r6,%r15,24(%r15) # Save registers
48 basr %r13,0 # Set up base register
50 lr %r11,%r15 # Set up frame pointer
53 ahi %r15,-96-48 # Allocate stack
54 lr %r8,%r6 # Save ecif.rvalue
56 ic %r9,.Ltable-.Lbase(%r13,%r5) # Load epilog address
57 l %r7,96(%r11) # Load function address
58 st %r11,0(%r15) # Set up back chain
59 ahi %r11,-48 # Register save area
62 la %r2,96(%r15) # Save area
63 # r3 already holds &ecif
64 basr %r14,%r4 # Call ffi_prep_args
66 lm %r2,%r6,0(%r11) # Load arguments
69 la %r14,0(%r13,%r9) # Set return address
70 br %r7 # ... and call function
72 .LretNone: # Return void
74 lm %r6,%r15,48+24(%r11)
79 ste %f0,0(%r8) # Return float
80 lm %r6,%r15,48+24(%r11)
85 std %f0,0(%r8) # Return double
86 lm %r6,%r15,48+24(%r11)
91 st %r2,0(%r8) # Return int
92 lm %r6,%r15,48+24(%r11)
97 stm %r2,%r3,0(%r8) # Return long long
98 lm %r6,%r15,48+24(%r11)
102 .byte .LretNone-.Lbase # FFI390_RET_VOID
103 .byte .LretNone-.Lbase # FFI390_RET_STRUCT
104 .byte .LretFloat-.Lbase # FFI390_RET_FLOAT
105 .byte .LretDouble-.Lbase # FFI390_RET_DOUBLE
106 .byte .LretInt32-.Lbase # FFI390_RET_INT32
107 .byte .LretInt64-.Lbase # FFI390_RET_INT64
111 .size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
114 .globl ffi_closure_SYSV
115 .type ffi_closure_SYSV,%function
118 stm %r12,%r15,48(%r15) # Save registers
120 basr %r13,0 # Set up base register
122 stm %r2,%r6,8(%r15) # Save arguments
125 lr %r1,%r15 # Set up stack frame
128 l %r12,.Lchelper-.Lcbase(%r13) # Get helper function
131 la %r4,64(%r1) # FPRs
132 la %r5,96(%r1) # Overflow
133 st %r1,0(%r15) # Set up back chain
135 bas %r14,0(%r12,%r13) # Call helper
138 ld %f0,96+64(%r15) # Load return registers
139 lm %r2,%r3,96+8(%r15)
140 lm %r12,%r15,96+48(%r15)
145 .long ffi_closure_helper_SYSV-.Lcbase
149 .ffi_closure_SYSV_end:
150 .size ffi_closure_SYSV,.ffi_closure_SYSV_end-ffi_closure_SYSV
153 .section .eh_frame,EH_FRAME_FLAGS,@progbits
155 .4byte .LECIE1-.LSCIE1 # Length of Common Information Entry
157 .4byte 0x0 # CIE Identifier Tag
158 .byte 0x1 # CIE Version
159 .ascii "zR\0" # CIE Augmentation
160 .uleb128 0x1 # CIE Code Alignment Factor
161 .sleb128 -4 # CIE Data Alignment Factor
162 .byte 0xe # CIE RA Column
163 .uleb128 0x1 # Augmentation size
164 .byte 0x1b # FDE Encoding (pcrel sdata4)
165 .byte 0xc # DW_CFA_def_cfa
171 .4byte .LEFDE1-.LASFDE1 # FDE Length
173 .4byte .LASFDE1-.Lframe1 # FDE CIE offset
174 .4byte .LFB1-. # FDE initial location
175 .4byte .LFE1-.LFB1 # FDE address range
176 .uleb128 0x0 # Augmentation size
177 .byte 0x4 # DW_CFA_advance_loc4
179 .byte 0x8f # DW_CFA_offset, column 0xf
181 .byte 0x8e # DW_CFA_offset, column 0xe
183 .byte 0x8d # DW_CFA_offset, column 0xd
185 .byte 0x8c # DW_CFA_offset, column 0xc
187 .byte 0x8b # DW_CFA_offset, column 0xb
189 .byte 0x8a # DW_CFA_offset, column 0xa
191 .byte 0x89 # DW_CFA_offset, column 0x9
193 .byte 0x88 # DW_CFA_offset, column 0x8
195 .byte 0x87 # DW_CFA_offset, column 0x7
197 .byte 0x86 # DW_CFA_offset, column 0x6
199 .byte 0x4 # DW_CFA_advance_loc4
201 .byte 0xd # DW_CFA_def_cfa_register
203 .byte 0x4 # DW_CFA_advance_loc4
205 .byte 0xe # DW_CFA_def_cfa_offset
210 .4byte .LEFDE2-.LASFDE2 # FDE Length
212 .4byte .LASFDE2-.Lframe1 # FDE CIE offset
213 .4byte .LFB2-. # FDE initial location
214 .4byte .LFE2-.LFB2 # FDE address range
215 .uleb128 0x0 # Augmentation size
216 .byte 0x4 # DW_CFA_advance_loc4
218 .byte 0x8f # DW_CFA_offset, column 0xf
220 .byte 0x8e # DW_CFA_offset, column 0xe
222 .byte 0x8d # DW_CFA_offset, column 0xd
224 .byte 0x8c # DW_CFA_offset, column 0xc
226 .byte 0x4 # DW_CFA_advance_loc4
227 .4byte .LCFI11-.LCFI10
228 .byte 0xe # DW_CFA_def_cfa_offset
244 # This assumes we are using gas.
246 .type ffi_call_SYSV,%function
249 stmg %r6,%r15,48(%r15) # Save registers
251 larl %r13,.Lbase # Set up base register
252 lgr %r11,%r15 # Set up frame pointer
255 aghi %r15,-160-80 # Allocate stack
256 lgr %r8,%r6 # Save ecif.rvalue
257 llgc %r9,.Ltable-.Lbase(%r13,%r5) # Load epilog address
258 lg %r7,160(%r11) # Load function address
259 stg %r11,0(%r15) # Set up back chain
260 aghi %r11,-80 # Register save area
263 la %r2,160(%r15) # Save area
264 # r3 already holds &ecif
265 basr %r14,%r4 # Call ffi_prep_args
267 lmg %r2,%r6,0(%r11) # Load arguments
272 la %r14,0(%r13,%r9) # Set return address
273 br %r7 # ... and call function
276 .LretNone: # Return void
278 lmg %r6,%r15,80+48(%r11)
283 ste %f0,0(%r8) # Return float
284 lmg %r6,%r15,80+48(%r11)
289 std %f0,0(%r8) # Return double
290 lmg %r6,%r15,80+48(%r11)
295 st %r2,0(%r8) # Return int
296 lmg %r6,%r15,80+48(%r11)
301 stg %r2,0(%r8) # Return long
302 lmg %r6,%r15,80+48(%r11)
306 .byte .LretNone-.Lbase # FFI390_RET_VOID
307 .byte .LretNone-.Lbase # FFI390_RET_STRUCT
308 .byte .LretFloat-.Lbase # FFI390_RET_FLOAT
309 .byte .LretDouble-.Lbase # FFI390_RET_DOUBLE
310 .byte .LretInt32-.Lbase # FFI390_RET_INT32
311 .byte .LretInt64-.Lbase # FFI390_RET_INT64
315 .size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
318 .globl ffi_closure_SYSV
319 .type ffi_closure_SYSV,%function
322 stmg %r14,%r15,112(%r15) # Save registers
324 stmg %r2,%r6,16(%r15) # Save arguments
329 lgr %r1,%r15 # Set up stack frame
332 lgr %r2,%r0 # Closure
333 la %r3,16(%r1) # GPRs
334 la %r4,128(%r1) # FPRs
335 la %r5,160(%r1) # Overflow
336 stg %r1,0(%r15) # Set up back chain
338 brasl %r14,ffi_closure_helper_SYSV # Call helper
340 lg %r14,160+112(%r15)
341 ld %f0,160+128(%r15) # Load return registers
347 .ffi_closure_SYSV_end:
348 .size ffi_closure_SYSV,.ffi_closure_SYSV_end-ffi_closure_SYSV
352 .section .eh_frame,EH_FRAME_FLAGS,@progbits
354 .4byte .LECIE1-.LSCIE1 # Length of Common Information Entry
356 .4byte 0x0 # CIE Identifier Tag
357 .byte 0x1 # CIE Version
358 .ascii "zR\0" # CIE Augmentation
359 .uleb128 0x1 # CIE Code Alignment Factor
360 .sleb128 -8 # CIE Data Alignment Factor
361 .byte 0xe # CIE RA Column
362 .uleb128 0x1 # Augmentation size
363 .byte 0x1b # FDE Encoding (pcrel sdata4)
364 .byte 0xc # DW_CFA_def_cfa
370 .4byte .LEFDE1-.LASFDE1 # FDE Length
372 .4byte .LASFDE1-.Lframe1 # FDE CIE offset
373 .4byte .LFB1-. # FDE initial location
374 .4byte .LFE1-.LFB1 # FDE address range
375 .uleb128 0x0 # Augmentation size
376 .byte 0x4 # DW_CFA_advance_loc4
378 .byte 0x8f # DW_CFA_offset, column 0xf
380 .byte 0x8e # DW_CFA_offset, column 0xe
382 .byte 0x8d # DW_CFA_offset, column 0xd
384 .byte 0x8c # DW_CFA_offset, column 0xc
386 .byte 0x8b # DW_CFA_offset, column 0xb
388 .byte 0x8a # DW_CFA_offset, column 0xa
390 .byte 0x89 # DW_CFA_offset, column 0x9
392 .byte 0x88 # DW_CFA_offset, column 0x8
394 .byte 0x87 # DW_CFA_offset, column 0x7
396 .byte 0x86 # DW_CFA_offset, column 0x6
398 .byte 0x4 # DW_CFA_advance_loc4
400 .byte 0xd # DW_CFA_def_cfa_register
402 .byte 0x4 # DW_CFA_advance_loc4
404 .byte 0xe # DW_CFA_def_cfa_offset
409 .4byte .LEFDE2-.LASFDE2 # FDE Length
411 .4byte .LASFDE2-.Lframe1 # FDE CIE offset
412 .4byte .LFB2-. # FDE initial location
413 .4byte .LFE2-.LFB2 # FDE address range
414 .uleb128 0x0 # Augmentation size
415 .byte 0x4 # DW_CFA_advance_loc4
417 .byte 0x8f # DW_CFA_offset, column 0xf
419 .byte 0x8e # DW_CFA_offset, column 0xe
421 .byte 0x4 # DW_CFA_advance_loc4
422 .4byte .LCFI11-.LCFI10
423 .byte 0xe # DW_CFA_def_cfa_offset