1 /* -----------------------------------------------------------------------
2 sysv.h - Copyright (c) 1998 Geoffrey Keating
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 THE AUTHOR 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 #include <powerpc/asm.h>
32 .globl ffi_prep_args_SYSV
35 /* Save the old stack pointer as AP. */
39 /* Allocate the stack space we need. */
41 /* Save registers we use. */
54 /* Save arguments over call... */
55 mr %r31,%r5 /* flags, */
56 mr %r30,%r6 /* rvalue, */
57 mr %r29,%r7 /* function address, */
58 mr %r28,%r8 /* our AP. */
61 /* Call ffi_prep_args_SYSV. */
63 bl ffi_prep_args_SYSV@local
65 /* Now do the call. */
66 /* Set up cr1 with bits 4-7 of the flags. */
68 /* Get the address to call into CTR. */
70 /* Load all those argument registers. */
71 lwz %r3,-16-(8*4)(%r28)
72 lwz %r4,-16-(7*4)(%r28)
73 lwz %r5,-16-(6*4)(%r28)
74 lwz %r6,-16-(5*4)(%r28)
77 lwz %r7,-16-(4*4)(%r28)
78 lwz %r8,-16-(3*4)(%r28)
79 lwz %r9,-16-(2*4)(%r28)
80 lwz %r10,-16-(1*4)(%r28)
84 /* Load all the FP registers. */
86 lfd %f1,-16-(8*4)-(8*8)(%r28)
87 lfd %f2,-16-(8*4)-(7*8)(%r28)
88 lfd %f3,-16-(8*4)-(6*8)(%r28)
89 lfd %f4,-16-(8*4)-(5*8)(%r28)
91 lfd %f5,-16-(8*4)-(4*8)(%r28)
92 lfd %f6,-16-(8*4)-(3*8)(%r28)
93 lfd %f7,-16-(8*4)-(2*8)(%r28)
94 lfd %f8,-16-(8*4)-(1*8)(%r28)
100 /* Now, deal with the return value. */
102 bt- 31,L(small_struct_return_value)
103 bt- 30,L(done_return_value)
104 bt- 29,L(fp_return_value)
106 bf+ 28,L(done_return_value)
108 /* Fall through... */
110 L(done_return_value):
111 /* Restore the registers we used and return. */
122 bf 28,L(float_return_value)
124 mtcrf 0x02,%r31 /* cr6 */
125 bf 27,L(done_return_value)
127 b L(done_return_value)
128 L(float_return_value):
130 b L(done_return_value)
132 L(small_struct_return_value):
133 mtcrf 0x10,%r31 /* cr3 */
134 bt- 15,L(smst_one_register)
135 mtcrf 0x08,%r31 /* cr4 */
136 bt- 16,L(smst_two_register)
137 b L(done_return_value)
139 L(smst_one_register):
140 rlwinm %r5,%r31,5+23,32-5,31 /* Extract the value to shift. */
143 b L(done_return_value)
144 L(smst_two_register):
145 rlwinm %r5,%r31,5+23,32-5,31 /* Extract the value to shift. */
156 b L(done_return_value)
161 .section ".eh_frame",EH_FRAME_FLAGS,@progbits
163 .4byte .LECIE1-.LSCIE1 /* Length of Common Information Entry */
165 .4byte 0x0 /* CIE Identifier Tag */
166 .byte 0x1 /* CIE Version */
167 #if defined _RELOCATABLE || defined __PIC__
168 .ascii "zR\0" /* CIE Augmentation */
170 .ascii "\0" /* CIE Augmentation */
172 .uleb128 0x1 /* CIE Code Alignment Factor */
173 .sleb128 -4 /* CIE Data Alignment Factor */
174 .byte 0x41 /* CIE RA Column */
175 #if defined _RELOCATABLE || defined __PIC__
176 .uleb128 0x1 /* Augmentation size */
177 .byte 0x1b /* FDE Encoding (pcrel sdata4) */
179 .byte 0xc /* DW_CFA_def_cfa */
185 .4byte .LEFDE1-.LASFDE1 /* FDE Length */
187 .4byte .LASFDE1-.Lframe1 /* FDE CIE offset */
188 #if defined _RELOCATABLE || defined __PIC__
189 .4byte .LFB1-. /* FDE initial location */
191 .4byte .LFB1 /* FDE initial location */
193 .4byte .LFE1-.LFB1 /* FDE address range */
194 #if defined _RELOCATABLE || defined __PIC__
195 .uleb128 0x0 /* Augmentation size */
197 .byte 0x4 /* DW_CFA_advance_loc4 */
199 .byte 0xd /* DW_CFA_def_cfa_register */
201 .byte 0x4 /* DW_CFA_advance_loc4 */
203 .byte 0x11 /* DW_CFA_offset_extended_sf */
206 .byte 0x9f /* DW_CFA_offset, column 0x1f */
208 .byte 0x9e /* DW_CFA_offset, column 0x1e */
210 .byte 0x9d /* DW_CFA_offset, column 0x1d */
212 .byte 0x9c /* DW_CFA_offset, column 0x1c */
214 .byte 0x4 /* DW_CFA_advance_loc4 */
216 .byte 0xd /* DW_CFA_def_cfa_register */