1
/* -----------------------------------------------------------------------
2
sysv.S - Copyright (c) 2009 Bradley Smith <brad@brad-smith.co.uk>
4
AVR32 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 NONINFRINGEMENT.
20
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
--------------------------------------------------------------------- */
27
#include <fficonfig.h>
35
* sp+0: cif->rstruct_flag
41
.type ffi_call_SYSV, @function
47
/* Make room for all of the new args. */
49
/* Pad to make way for potential skipped registers */
52
/* Call ffi_prep_args(stack, &ecif). */
58
/* Save new argument size */
61
/* Move first 5 parameters in registers. */
64
/* call (fn) (...). */
68
/* Remove the space we pushed for the args. */
71
/* Load r1 with the rstruct flag. */
74
/* Load r9 with the return type code. */
77
/* Load r8 with the return value pointer. */
80
/* If the return value pointer is NULL, assume no return value. */
84
/* Check if return type is actually a struct */
89
cp.w r9, FFI_TYPE_UINT8
93
cp.w r9, FFI_TYPE_UINT16
98
cp.w r9, FFI_TYPE_UINT32
100
cp.w r9, FFI_TYPE_UINT16
102
cp.w r9, FFI_TYPE_UINT8
106
cp.w r9, FFI_TYPE_UINT64
109
/* Didn't match anything */
133
.size ffi_call_SYSV, . - ffi_call_SYSV
137
* r11: __rstruct_flag
141
.globl ffi_closure_SYSV
142
.type ffi_closure_SYSV, @function
153
/* Check if return type is actually a struct */
158
cp.w r12, FFI_TYPE_UINT8
162
cp.w r12, FFI_TYPE_UINT16
167
cp.w r12, FFI_TYPE_UINT32
169
cp.w r12, FFI_TYPE_UINT16
171
cp.w r12, FFI_TYPE_UINT8
175
cp.w r12, FFI_TYPE_UINT64
178
/* Didn't match anything */
204
.size ffi_closure_SYSV, . - ffi_closure_SYSV
206
#if defined __ELF__ && defined __linux__
207
.section .note.GNU-stack,"",@progbits