1
/* -----------------------------------------------------------------------
2
sysv.S - Copyright (c) 2002, 2003, 2004 Kaz Kojima
4
SuperH 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>
29
#ifdef HAVE_MACHINE_ASM_H
30
#include <machine/asm.h>
32
/* XXX these lose for some platforms, I'm sure. */
34
#define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x):
37
#if defined(__HITACHI__)
38
#define STRUCT_VALUE_ADDRESS_WITH_ARG 1
40
#define STRUCT_VALUE_ADDRESS_WITH_ARG 0
52
# This assumes we are using gas.
88
mov #FFI_TYPE_STRUCT,r2
91
#if STRUCT_VALUE_ADDRESS_WITH_ARG
111
cmp/eq #FFI_TYPE_DOUBLE,r0
138
#ifdef __LITTLE_ENDIAN__
167
cmp/eq #FFI_TYPE_FLOAT,r0
187
#ifdef __LITTLE_ENDIAN__
224
cmp/eq #FFI_TYPE_INT,r0
255
#if (! STRUCT_VALUE_ADDRESS_WITH_ARG)
263
mov #FFI_TYPE_DOUBLE,r2
268
#ifdef __LITTLE_ENDIAN__
281
mov #FFI_TYPE_SINT64,r2
284
mov #FFI_TYPE_UINT64,r2
295
mov #FFI_TYPE_FLOAT,r2
313
# Remove the space we pushed for the args
341
mov #FFI_TYPE_STRUCT,r2
344
#if STRUCT_VALUE_ADDRESS_WITH_ARG
363
cmp/eq #FFI_TYPE_DOUBLE,r0
404
cmp/eq #FFI_TYPE_INT,r0
435
#if (! STRUCT_VALUE_ADDRESS_WITH_ARG)
443
mov #FFI_TYPE_DOUBLE,r2
453
mov #FFI_TYPE_SINT64,r2
456
mov #FFI_TYPE_UINT64,r2
467
mov #FFI_TYPE_FLOAT,r2
479
# Remove the space we pushed for the args
492
.size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
494
.globl ffi_closure_helper_SYSV
496
ENTRY(ffi_closure_SYSV)
511
xx bytes (on stack parameters)
512
16 bytes (register parameters)
513
4 bytes (saved frame pointer)
514
4 bytes (saved return address)
515
32 bytes (floating register parameters, SH-4 only)
534
#ifdef __LITTLE_ENDIAN__
600
.long _GLOBAL_OFFSET_TABLE_
602
.long ffi_closure_helper_SYSV@GOTOFF
605
.long ffi_closure_helper_SYSV
608
.short L_case_v - 0b /* FFI_TYPE_VOID */
609
.short L_case_i - 0b /* FFI_TYPE_INT */
611
.short L_case_f - 0b /* FFI_TYPE_FLOAT */
612
.short L_case_d - 0b /* FFI_TYPE_DOUBLE */
613
.short L_case_d - 0b /* FFI_TYPE_LONGDOUBLE */
615
.short L_case_i - 0b /* FFI_TYPE_FLOAT */
616
.short L_case_ll - 0b /* FFI_TYPE_DOUBLE */
617
.short L_case_ll - 0b /* FFI_TYPE_LONGDOUBLE */
619
.short L_case_uq - 0b /* FFI_TYPE_UINT8 */
620
.short L_case_q - 0b /* FFI_TYPE_SINT8 */
621
.short L_case_uh - 0b /* FFI_TYPE_UINT16 */
622
.short L_case_h - 0b /* FFI_TYPE_SINT16 */
623
.short L_case_i - 0b /* FFI_TYPE_UINT32 */
624
.short L_case_i - 0b /* FFI_TYPE_SINT32 */
625
.short L_case_ll - 0b /* FFI_TYPE_UINT64 */
626
.short L_case_ll - 0b /* FFI_TYPE_SINT64 */
627
.short L_case_v - 0b /* FFI_TYPE_STRUCT */
628
.short L_case_i - 0b /* FFI_TYPE_POINTER */
632
#ifdef __LITTLE_ENDIAN__
657
#ifdef __LITTLE_ENDIAN__
665
#ifdef __LITTLE_ENDIAN__
674
#ifdef __LITTLE_ENDIAN__
682
#ifdef __LITTLE_ENDIAN__
701
.ffi_closure_SYSV_end:
702
.size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV)
704
.section ".eh_frame","aw",@progbits
706
.4byte .LECIE1-.LSCIE1 /* Length of Common Information Entry */
708
.4byte 0x0 /* CIE Identifier Tag */
709
.byte 0x1 /* CIE Version */
711
.ascii "zR\0" /* CIE Augmentation */
713
.byte 0x0 /* CIE Augmentation */
715
.byte 0x1 /* uleb128 0x1; CIE Code Alignment Factor */
716
.byte 0x7c /* sleb128 -4; CIE Data Alignment Factor */
717
.byte 0x11 /* CIE RA Column */
719
.uleb128 0x1 /* Augmentation size */
720
.byte 0x10 /* FDE Encoding (pcrel) */
722
.byte 0xc /* DW_CFA_def_cfa */
723
.byte 0xf /* uleb128 0xf */
724
.byte 0x0 /* uleb128 0x0 */
728
.4byte .LEFDE1-.LASFDE1 /* FDE Length */
730
.4byte .LASFDE1-__FRAME_BEGIN__ /* FDE CIE offset */
732
.4byte .LFB1-. /* FDE initial location */
734
.4byte .LFB1 /* FDE initial location */
736
.4byte .LFE1-.LFB1 /* FDE address range */
738
.uleb128 0x0 /* Augmentation size */
740
.byte 0x4 /* DW_CFA_advance_loc4 */
742
.byte 0xe /* DW_CFA_def_cfa_offset */
743
.byte 0x4 /* uleb128 0x4 */
744
.byte 0x4 /* DW_CFA_advance_loc4 */
746
.byte 0xe /* DW_CFA_def_cfa_offset */
747
.byte 0x8 /* uleb128 0x4 */
748
.byte 0x4 /* DW_CFA_advance_loc4 */
750
.byte 0xe /* DW_CFA_def_cfa_offset */
751
.byte 0xc /* uleb128 0x4 */
752
.byte 0x4 /* DW_CFA_advance_loc4 */
754
.byte 0xe /* DW_CFA_def_cfa_offset */
755
.byte 0x10 /* uleb128 0x4 */
756
.byte 0x4 /* DW_CFA_advance_loc4 */
758
.byte 0xe /* DW_CFA_def_cfa_offset */
759
.byte 0x14 /* uleb128 0x4 */
760
.byte 0x4 /* DW_CFA_advance_loc4 */
762
.byte 0xe /* DW_CFA_def_cfa_offset */
763
.byte 0x18 /* uleb128 0x4 */
764
.byte 0x91 /* DW_CFA_offset, column 0x11 */
765
.byte 0x6 /* uleb128 0x6 */
766
.byte 0x8e /* DW_CFA_offset, column 0xe */
767
.byte 0x5 /* uleb128 0x5 */
768
.byte 0x8c /* DW_CFA_offset, column 0xc */
769
.byte 0x4 /* uleb128 0x4 */
770
.byte 0x8a /* DW_CFA_offset, column 0xa */
771
.byte 0x3 /* uleb128 0x3 */
772
.byte 0x89 /* DW_CFA_offset, column 0x9 */
773
.byte 0x2 /* uleb128 0x2 */
774
.byte 0x88 /* DW_CFA_offset, column 0x8 */
775
.byte 0x1 /* uleb128 0x1 */
776
.byte 0x4 /* DW_CFA_advance_loc4 */
778
.byte 0xd /* DW_CFA_def_cfa_register */
779
.byte 0xe /* uleb128 0xe */
784
.4byte .LEFDE3-.LASFDE3 /* FDE Length */
786
.4byte .LASFDE3-__FRAME_BEGIN__ /* FDE CIE offset */
788
.4byte .LFB2-. /* FDE initial location */
790
.4byte .LFB2 /* FDE initial location */
792
.4byte .LFE2-.LFB2 /* FDE address range */
794
.uleb128 0x0 /* Augmentation size */
796
.byte 0x4 /* DW_CFA_advance_loc4 */
798
.byte 0xe /* DW_CFA_def_cfa_offset */
799
.byte 0x4 /* uleb128 0x4 */
800
.byte 0x4 /* DW_CFA_advance_loc4 */
802
.byte 0xe /* DW_CFA_def_cfa_offset */
803
.byte 0x8 /* uleb128 0x4 */
804
.byte 0x4 /* DW_CFA_advance_loc4 */
806
.byte 0xe /* DW_CFA_def_cfa_offset */
807
.byte 0xc /* uleb128 0x4 */
808
.byte 0x4 /* DW_CFA_advance_loc4 */
810
.byte 0xe /* DW_CFA_def_cfa_offset */
811
.byte 0x10 /* uleb128 0x4 */
812
.byte 0x4 /* DW_CFA_advance_loc4 */
814
.byte 0xe /* DW_CFA_def_cfa_offset */
815
.byte 0x14 /* uleb128 0x4 */
816
.byte 0x4 /* DW_CFA_advance_loc4 */
818
.byte 0xe /* DW_CFA_def_cfa_offset */
819
.byte 0x18 /* uleb128 0x4 */
820
.byte 0x4 /* DW_CFA_advance_loc4 */
822
.byte 0xe /* DW_CFA_def_cfa_offset */
824
.byte 24+48 /* uleb128 24+48 */
826
.byte 24+16 /* uleb128 24+16 */
828
.byte 0x91 /* DW_CFA_offset, column 0x11 */
829
.byte 0x6 /* uleb128 0x6 */
830
.byte 0x8e /* DW_CFA_offset, column 0xe */
831
.byte 0x5 /* uleb128 0x5 */
832
.byte 0x8b /* DW_CFA_offset, column 0xb */
833
.byte 0x4 /* uleb128 0x4 */
834
.byte 0x8a /* DW_CFA_offset, column 0xa */
835
.byte 0x3 /* uleb128 0x3 */
836
.byte 0x89 /* DW_CFA_offset, column 0x9 */
837
.byte 0x2 /* uleb128 0x2 */
838
.byte 0x88 /* DW_CFA_offset, column 0x8 */
839
.byte 0x1 /* uleb128 0x1 */
840
.byte 0x4 /* DW_CFA_advance_loc4 */
842
.byte 0xd /* DW_CFA_def_cfa_register */
843
.byte 0xe /* uleb128 0xe */