1 /* -----------------------------------------------------------------------
2 sysv.h - Copyright (c) 2003 Jakub Jelinek <jakub@redhat.com>
4 PowerPC64 Assembly glue.
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>
32 .hidden ffi_call_LINUX64, .ffi_call_LINUX64
33 .globl ffi_call_LINUX64, .ffi_call_LINUX64
37 .quad .ffi_call_LINUX64,.TOC.@tocbase,0
38 .size ffi_call_LINUX64,24
39 .type .ffi_call_LINUX64,@function
50 mr %r28, %r1 /* our AP. */
53 mr %r31, %r5 /* flags, */
54 mr %r30, %r6 /* rvalue, */
55 mr %r29, %r7 /* function address. */
58 /* Call ffi_prep_args64. */
66 /* Now do the call. */
67 /* Set up cr1 with bits 4-7 of the flags. */
70 /* Get the address to call into CTR. */
72 /* Load all those argument registers. */
73 ld %r3, -32-(8*8)(%r28)
74 ld %r4, -32-(7*8)(%r28)
75 ld %r5, -32-(6*8)(%r28)
76 ld %r6, -32-(5*8)(%r28)
78 ld %r7, -32-(4*8)(%r28)
79 ld %r8, -32-(3*8)(%r28)
80 ld %r9, -32-(2*8)(%r28)
81 ld %r10, -32-(1*8)(%r28)
84 /* Load all the FP registers. */
86 lfd %f1, -32-(21*8)(%r28)
87 lfd %f2, -32-(20*8)(%r28)
88 lfd %f3, -32-(19*8)(%r28)
89 lfd %f4, -32-(18*8)(%r28)
90 lfd %f5, -32-(17*8)(%r28)
91 lfd %f6, -32-(16*8)(%r28)
92 lfd %f7, -32-(15*8)(%r28)
93 lfd %f8, -32-(14*8)(%r28)
94 lfd %f9, -32-(13*8)(%r28)
95 lfd %f10, -32-(12*8)(%r28)
96 lfd %f11, -32-(11*8)(%r28)
97 lfd %f12, -32-(10*8)(%r28)
98 lfd %f13, -32-(9*8)(%r28)
104 /* This must follow the call immediately, the unwinder
105 uses this to find out if r2 has been saved or not. */
108 /* Now, deal with the return value. */
110 bt- 30, .Ldone_return_value
111 bt- 29, .Lfp_return_value
113 /* Fall through... */
116 /* Restore the registers we used and return. */
127 bf 28, .Lfloat_return_value
129 mtcrf 0x02, %r31 /* cr6 */
130 bf 27, .Ldone_return_value
132 b .Ldone_return_value
133 .Lfloat_return_value:
135 b .Ldone_return_value
138 .byte 0,12,0,1,128,4,0,0
139 .size .ffi_call_LINUX64,.-.ffi_call_LINUX64
141 .section .eh_frame,EH_FRAME_FLAGS,@progbits
143 .4byte .LECIE1-.LSCIE1 # Length of Common Information Entry
145 .4byte 0x0 # CIE Identifier Tag
146 .byte 0x1 # CIE Version
147 .ascii "zR\0" # CIE Augmentation
148 .uleb128 0x1 # CIE Code Alignment Factor
149 .sleb128 -8 # CIE Data Alignment Factor
150 .byte 0x41 # CIE RA Column
151 .uleb128 0x1 # Augmentation size
152 .byte 0x14 # FDE Encoding (pcrel udata8)
153 .byte 0xc # DW_CFA_def_cfa
159 .4byte .LEFDE1-.LASFDE1 # FDE Length
161 .4byte .LASFDE1-.Lframe1 # FDE CIE offset
162 .8byte .LFB1-. # FDE initial location
163 .8byte .LFE1-.LFB1 # FDE address range
164 .uleb128 0x0 # Augmentation size
165 .byte 0x2 # DW_CFA_advance_loc1
167 .byte 0xd # DW_CFA_def_cfa_register
169 .byte 0x11 # DW_CFA_offset_extended_sf
172 .byte 0x9f # DW_CFA_offset, column 0x1f
174 .byte 0x9e # DW_CFA_offset, column 0x1e
176 .byte 0x9d # DW_CFA_offset, column 0x1d
178 .byte 0x9c # DW_CFA_offset, column 0x1c