1 /* -----------------------------------------------------------------------
2 osf.S - Copyright (c) 1998, 2001, 2007, 2008, 2011 Red Hat
4 Alpha/OSF 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>
34 /* ffi_call_osf (void *args, unsigned long bytes, unsigned flags,
35 void *raddr, void (*fnaddr)(void));
37 Bit o trickiness here -- ARGS+BYTES is the base of the stack frame
38 for this function. This has been allocated by ffi_call. We also
39 deallocate some of the stack that has been alloca'd. */
44 FFI_HIDDEN(ffi_call_osf)
47 .frame $15, 32, $26, 0
62 # Load up all of the (potential) argument registers.
76 # Deallocate the register argument area.
82 # If the return value pointer is NULL, assume no return value.
89 # Store the return value out in the proper type.
90 cmpeq $18, FFI_TYPE_INT, $1
92 cmpeq $18, FFI_TYPE_FLOAT, $2
94 cmpeq $18, FFI_TYPE_DOUBLE, $3
126 /* ffi_closure_osf(...)
128 Receives the closure argument in $1. */
131 .globl ffi_closure_osf
133 FFI_HIDDEN(ffi_closure_osf)
136 .frame $30, 16*8, $26, 0
137 .mask 0x4000000, -16*8
146 # Store all of the potential argument registers in va_list format.
160 # Call ffi_closure_osf_inner to do the bulk of the work.
164 jsr $26, ffi_closure_osf_inner
168 # Load up the return value in the proper type.
173 jmp $31, ($1), $load_32
267 .gprel32 $load_none # FFI_TYPE_VOID
268 .gprel32 $load_32 # FFI_TYPE_INT
269 .gprel32 $load_float # FFI_TYPE_FLOAT
270 .gprel32 $load_double # FFI_TYPE_DOUBLE
271 .gprel32 $load_none # FFI_TYPE_LONGDOUBLE
272 .gprel32 $load_u8 # FFI_TYPE_UINT8
273 .gprel32 $load_s8 # FFI_TYPE_SINT8
274 .gprel32 $load_u16 # FFI_TYPE_UINT16
275 .gprel32 $load_s16 # FFI_TYPE_SINT16
276 .gprel32 $load_32 # FFI_TYPE_UINT32
277 .gprel32 $load_32 # FFI_TYPE_SINT32
278 .gprel32 $load_64 # FFI_TYPE_UINT64
279 .gprel32 $load_64 # FFI_TYPE_SINT64
280 .gprel32 $load_none # FFI_TYPE_STRUCT
281 .gprel32 $load_64 # FFI_TYPE_POINTER
283 /* Assert that the table above is in sync with ffi.h. */
285 #if FFI_TYPE_FLOAT != 2 \
286 || FFI_TYPE_DOUBLE != 3 \
287 || FFI_TYPE_UINT8 != 5 \
288 || FFI_TYPE_SINT8 != 6 \
289 || FFI_TYPE_UINT16 != 7 \
290 || FFI_TYPE_SINT16 != 8 \
291 || FFI_TYPE_UINT32 != 9 \
292 || FFI_TYPE_SINT32 != 10 \
293 || FFI_TYPE_UINT64 != 11 \
294 || FFI_TYPE_SINT64 != 12 \
295 || FFI_TYPE_STRUCT != 13 \
296 || FFI_TYPE_POINTER != 14 \
297 || FFI_TYPE_LAST != 14
298 #error "osf.S out of sync with ffi.h"
302 # define UA_SI .4byte
303 # define FDE_ENCODING 0x1b /* pcrel sdata4 */
304 # define FDE_ENCODE(X) .4byte X-.
305 # define FDE_ARANGE(X) .4byte X
306 #elif defined __osf__
307 # define UA_SI .align 0; .long
308 # define FDE_ENCODING 0x50 /* aligned absolute */
309 # define FDE_ENCODE(X) .align 3; .quad X
310 # define FDE_ARANGE(X) .align 0; .quad X
314 .section .eh_frame,EH_FRAME_FLAGS,@progbits
315 #elif defined __osf__
318 .globl _GLOBAL__F_ffi_call_osf
319 _GLOBAL__F_ffi_call_osf:
322 UA_SI $LECIE1-$LSCIE1 # Length of Common Information Entry
324 UA_SI 0x0 # CIE Identifier Tag
325 .byte 0x1 # CIE Version
326 .ascii "zR\0" # CIE Augmentation
327 .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor
328 .byte 0x78 # sleb128 -8; CIE Data Alignment Factor
329 .byte 26 # CIE RA Column
330 .byte 0x1 # uleb128 0x1; Augmentation size
331 .byte FDE_ENCODING # FDE Encoding
332 .byte 0xc # DW_CFA_def_cfa
333 .byte 30 # uleb128 column 30
334 .byte 0 # uleb128 offset 0
338 UA_SI $LEFDE1-$LASFDE1 # FDE Length
340 UA_SI $LASFDE1-__FRAME_BEGIN__ # FDE CIE offset
341 FDE_ENCODE($LFB1) # FDE initial location
342 FDE_ARANGE($LFE1-$LFB1) # FDE address range
343 .byte 0x0 # uleb128 0x0; Augmentation size
345 .byte 0x4 # DW_CFA_advance_loc4
347 .byte 0x9a # DW_CFA_offset, column 26
348 .byte 4 # uleb128 4*-8
349 .byte 0x8f # DW_CFA_offset, column 15
350 .byte 0x3 # uleb128 3*-8
351 .byte 0xc # DW_CFA_def_cfa
352 .byte 15 # uleb128 column 15
353 .byte 32 # uleb128 offset 32
355 .byte 0x4 # DW_CFA_advance_loc4
357 .byte 0xda # DW_CFA_restore, column 26
362 UA_SI $LEFDE3-$LASFDE3 # FDE Length
364 UA_SI $LASFDE3-__FRAME_BEGIN__ # FDE CIE offset
365 FDE_ENCODE($LFB2) # FDE initial location
366 FDE_ARANGE($LFE2-$LFB2) # FDE address range
367 .byte 0x0 # uleb128 0x0; Augmentation size
369 .byte 0x4 # DW_CFA_advance_loc4
371 .byte 0xe # DW_CFA_def_cfa_offset
372 .byte 0x80,0x1 # uleb128 128
374 .byte 0x4 # DW_CFA_advance_loc4
376 .byte 0x9a # DW_CFA_offset, column 26
377 .byte 16 # uleb128 offset 16*-8
382 .long 0 # End of Table
385 #if defined __ELF__ && defined __linux__
386 .section .note.GNU-stack,"",@progbits