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,
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 DEALINGS IN THE SOFTWARE.
25 ----------------------------------------------------------------------- */
28 #include <fficonfig.h>
42 # This assumes we are using gas.
44 .type ffi_call_SYSV,%function
47 stm %r6,%r15,24(%r15) # Save registers
49 basr %r13,0 # Set up base register
51 lr %r11,%r15 # Set up frame pointer
54 ahi %r15,-96-48 # Allocate stack
55 lr %r8,%r6 # Save ecif.rvalue
57 ic %r9,.Ltable-.Lbase(%r13,%r5) # Load epilog address
58 l %r7,96(%r11) # Load function address
59 st %r11,0(%r15) # Set up back chain
60 ahi %r11,-48 # Register save area
63 la %r2,96(%r15) # Save area
64 # r3 already holds &ecif
65 basr %r14,%r4 # Call ffi_prep_args
67 lm %r2,%r6,0(%r11) # Load arguments
70 la %r14,0(%r13,%r9) # Set return address
71 br %r7 # ... and call function
73 .LretNone: # Return void
75 lm %r6,%r15,48+24(%r11)
80 ste %f0,0(%r8) # Return float
81 lm %r6,%r15,48+24(%r11)
86 std %f0,0(%r8) # Return double
87 lm %r6,%r15,48+24(%r11)
92 st %r2,0(%r8) # Return int
93 lm %r6,%r15,48+24(%r11)
98 stm %r2,%r3,0(%r8) # Return long long
99 lm %r6,%r15,48+24(%r11)
103 .byte .LretNone-.Lbase # FFI390_RET_VOID
104 .byte .LretNone-.Lbase # FFI390_RET_STRUCT
105 .byte .LretFloat-.Lbase # FFI390_RET_FLOAT
106 .byte .LretDouble-.Lbase # FFI390_RET_DOUBLE
107 .byte .LretInt32-.Lbase # FFI390_RET_INT32
108 .byte .LretInt64-.Lbase # FFI390_RET_INT64
112 .size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
115 .globl ffi_closure_SYSV
116 .type ffi_closure_SYSV,%function
119 stm %r12,%r15,48(%r15) # Save registers
121 basr %r13,0 # Set up base register
123 stm %r2,%r6,8(%r15) # Save arguments
126 lr %r1,%r15 # Set up stack frame
129 l %r12,.Lchelper-.Lcbase(%r13) # Get helper function
132 la %r4,64(%r1) # FPRs
133 la %r5,96(%r1) # Overflow
134 st %r1,0(%r15) # Set up back chain
136 bas %r14,0(%r12,%r13) # Call helper
139 ld %f0,96+64(%r15) # Load return registers
140 lm %r2,%r3,96+8(%r15)
141 lm %r12,%r15,96+48(%r15)
146 .long ffi_closure_helper_SYSV-.Lcbase
150 .ffi_closure_SYSV_end:
151 .size ffi_closure_SYSV,.ffi_closure_SYSV_end-ffi_closure_SYSV
154 .section .eh_frame,EH_FRAME_FLAGS,@progbits
156 .4byte .LECIE1-.LSCIE1 # Length of Common Information Entry
158 .4byte 0x0 # CIE Identifier Tag
159 .byte 0x1 # CIE Version
160 .ascii "zR\0" # CIE Augmentation
161 .uleb128 0x1 # CIE Code Alignment Factor
162 .sleb128 -4 # CIE Data Alignment Factor
163 .byte 0xe # CIE RA Column
164 .uleb128 0x1 # Augmentation size
165 .byte 0x1b # FDE Encoding (pcrel sdata4)
166 .byte 0xc # DW_CFA_def_cfa
172 .4byte .LEFDE1-.LASFDE1 # FDE Length
174 .4byte .LASFDE1-.Lframe1 # FDE CIE offset
175 .4byte .LFB1-. # FDE initial location
176 .4byte .LFE1-.LFB1 # FDE address range
177 .uleb128 0x0 # Augmentation size
178 .byte 0x4 # DW_CFA_advance_loc4
180 .byte 0x8f # DW_CFA_offset, column 0xf
182 .byte 0x8e # DW_CFA_offset, column 0xe
184 .byte 0x8d # DW_CFA_offset, column 0xd
186 .byte 0x8c # DW_CFA_offset, column 0xc
188 .byte 0x8b # DW_CFA_offset, column 0xb
190 .byte 0x8a # DW_CFA_offset, column 0xa
192 .byte 0x89 # DW_CFA_offset, column 0x9
194 .byte 0x88 # DW_CFA_offset, column 0x8
196 .byte 0x87 # DW_CFA_offset, column 0x7
198 .byte 0x86 # DW_CFA_offset, column 0x6
200 .byte 0x4 # DW_CFA_advance_loc4
202 .byte 0xd # DW_CFA_def_cfa_register
204 .byte 0x4 # DW_CFA_advance_loc4
206 .byte 0xe # DW_CFA_def_cfa_offset
211 .4byte .LEFDE2-.LASFDE2 # FDE Length
213 .4byte .LASFDE2-.Lframe1 # FDE CIE offset
214 .4byte .LFB2-. # FDE initial location
215 .4byte .LFE2-.LFB2 # FDE address range
216 .uleb128 0x0 # Augmentation size
217 .byte 0x4 # DW_CFA_advance_loc4
219 .byte 0x8f # DW_CFA_offset, column 0xf
221 .byte 0x8e # DW_CFA_offset, column 0xe
223 .byte 0x8d # DW_CFA_offset, column 0xd
225 .byte 0x8c # DW_CFA_offset, column 0xc
227 .byte 0x4 # DW_CFA_advance_loc4
228 .4byte .LCFI11-.LCFI10
229 .byte 0xe # DW_CFA_def_cfa_offset
245 # This assumes we are using gas.
247 .type ffi_call_SYSV,%function
250 stmg %r6,%r15,48(%r15) # Save registers
252 larl %r13,.Lbase # Set up base register
253 lgr %r11,%r15 # Set up frame pointer
256 aghi %r15,-160-80 # Allocate stack
257 lgr %r8,%r6 # Save ecif.rvalue
258 llgc %r9,.Ltable-.Lbase(%r13,%r5) # Load epilog address
259 lg %r7,160(%r11) # Load function address
260 stg %r11,0(%r15) # Set up back chain
261 aghi %r11,-80 # Register save area
264 la %r2,160(%r15) # Save area
265 # r3 already holds &ecif
266 basr %r14,%r4 # Call ffi_prep_args
268 lmg %r2,%r6,0(%r11) # Load arguments
273 la %r14,0(%r13,%r9) # Set return address
274 br %r7 # ... and call function
277 .LretNone: # Return void
279 lmg %r6,%r15,80+48(%r11)
284 ste %f0,0(%r8) # Return float
285 lmg %r6,%r15,80+48(%r11)
290 std %f0,0(%r8) # Return double
291 lmg %r6,%r15,80+48(%r11)
296 st %r2,0(%r8) # Return int
297 lmg %r6,%r15,80+48(%r11)
302 stg %r2,0(%r8) # Return long
303 lmg %r6,%r15,80+48(%r11)
307 .byte .LretNone-.Lbase # FFI390_RET_VOID
308 .byte .LretNone-.Lbase # FFI390_RET_STRUCT
309 .byte .LretFloat-.Lbase # FFI390_RET_FLOAT
310 .byte .LretDouble-.Lbase # FFI390_RET_DOUBLE
311 .byte .LretInt32-.Lbase # FFI390_RET_INT32
312 .byte .LretInt64-.Lbase # FFI390_RET_INT64
316 .size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
319 .globl ffi_closure_SYSV
320 .type ffi_closure_SYSV,%function
323 stmg %r14,%r15,112(%r15) # Save registers
325 stmg %r2,%r6,16(%r15) # Save arguments
330 lgr %r1,%r15 # Set up stack frame
333 lgr %r2,%r0 # Closure
334 la %r3,16(%r1) # GPRs
335 la %r4,128(%r1) # FPRs
336 la %r5,160(%r1) # Overflow
337 stg %r1,0(%r15) # Set up back chain
339 brasl %r14,ffi_closure_helper_SYSV # Call helper
341 lg %r14,160+112(%r15)
342 ld %f0,160+128(%r15) # Load return registers
348 .ffi_closure_SYSV_end:
349 .size ffi_closure_SYSV,.ffi_closure_SYSV_end-ffi_closure_SYSV
353 .section .eh_frame,EH_FRAME_FLAGS,@progbits
355 .4byte .LECIE1-.LSCIE1 # Length of Common Information Entry
357 .4byte 0x0 # CIE Identifier Tag
358 .byte 0x1 # CIE Version
359 .ascii "zR\0" # CIE Augmentation
360 .uleb128 0x1 # CIE Code Alignment Factor
361 .sleb128 -8 # CIE Data Alignment Factor
362 .byte 0xe # CIE RA Column
363 .uleb128 0x1 # Augmentation size
364 .byte 0x1b # FDE Encoding (pcrel sdata4)
365 .byte 0xc # DW_CFA_def_cfa
371 .4byte .LEFDE1-.LASFDE1 # FDE Length
373 .4byte .LASFDE1-.Lframe1 # FDE CIE offset
374 .4byte .LFB1-. # FDE initial location
375 .4byte .LFE1-.LFB1 # FDE address range
376 .uleb128 0x0 # Augmentation size
377 .byte 0x4 # DW_CFA_advance_loc4
379 .byte 0x8f # DW_CFA_offset, column 0xf
381 .byte 0x8e # DW_CFA_offset, column 0xe
383 .byte 0x8d # DW_CFA_offset, column 0xd
385 .byte 0x8c # DW_CFA_offset, column 0xc
387 .byte 0x8b # DW_CFA_offset, column 0xb
389 .byte 0x8a # DW_CFA_offset, column 0xa
391 .byte 0x89 # DW_CFA_offset, column 0x9
393 .byte 0x88 # DW_CFA_offset, column 0x8
395 .byte 0x87 # DW_CFA_offset, column 0x7
397 .byte 0x86 # DW_CFA_offset, column 0x6
399 .byte 0x4 # DW_CFA_advance_loc4
401 .byte 0xd # DW_CFA_def_cfa_register
403 .byte 0x4 # DW_CFA_advance_loc4
405 .byte 0xe # DW_CFA_def_cfa_offset
410 .4byte .LEFDE2-.LASFDE2 # FDE Length
412 .4byte .LASFDE2-.Lframe1 # FDE CIE offset
413 .4byte .LFB2-. # FDE initial location
414 .4byte .LFE2-.LFB2 # FDE address range
415 .uleb128 0x0 # Augmentation size
416 .byte 0x4 # DW_CFA_advance_loc4
418 .byte 0x8f # DW_CFA_offset, column 0xf
420 .byte 0x8e # DW_CFA_offset, column 0xe
422 .byte 0x4 # DW_CFA_advance_loc4
423 .4byte .LCFI11-.LCFI10
424 .byte 0xe # DW_CFA_def_cfa_offset
431 #if defined __ELF__ && defined __linux__
432 .section .note.GNU-stack,"",@progbits