| 1 |
/* ----------------------------------------------------------------------- |
| 2 |
ffi_powerpc.h - Copyright (C) 2013 IBM |
| 3 |
Copyright (C) 2011 Anthony Green |
| 4 |
Copyright (C) 2011 Kyle Moffett |
| 5 |
Copyright (C) 2008 Red Hat, Inc |
| 6 |
Copyright (C) 2007, 2008 Free Software Foundation, Inc |
| 7 |
Copyright (c) 1998 Geoffrey Keating |
| 8 |
|
| 9 |
PowerPC Foreign Function Interface |
| 10 |
|
| 11 |
Permission is hereby granted, free of charge, to any person obtaining |
| 12 |
a copy of this software and associated documentation files (the |
| 13 |
``Software''), to deal in the Software without restriction, including |
| 14 |
without limitation the rights to use, copy, modify, merge, publish, |
| 15 |
distribute, sublicense, and/or sell copies of the Software, and to |
| 16 |
permit persons to whom the Software is furnished to do so, subject to |
| 17 |
the following conditions: |
| 18 |
|
| 19 |
The above copyright notice and this permission notice shall be included |
| 20 |
in all copies or substantial portions of the Software. |
| 21 |
|
| 22 |
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 23 |
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 24 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 25 |
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 26 |
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 27 |
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 28 |
OTHER DEALINGS IN THE SOFTWARE. |
| 29 |
----------------------------------------------------------------------- */ |
| 30 |
|
| 31 |
enum { |
| 32 |
/* The assembly depends on these exact flags. */ |
| 33 |
/* These go in cr7 */ |
| 34 |
FLAG_RETURNS_SMST = 1 << (31-31), /* Used for FFI_SYSV small structs. */ |
| 35 |
FLAG_RETURNS_NOTHING = 1 << (31-30), |
| 36 |
FLAG_RETURNS_FP = 1 << (31-29), |
| 37 |
FLAG_RETURNS_VEC = 1 << (31-28), |
| 38 |
|
| 39 |
/* These go in cr6 */ |
| 40 |
FLAG_RETURNS_64BITS = 1 << (31-27), |
| 41 |
FLAG_RETURNS_128BITS = 1 << (31-26), |
| 42 |
|
| 43 |
FLAG_COMPAT = 1 << (31- 8), /* Not used by assembly */ |
| 44 |
|
| 45 |
/* These go in cr1 */ |
| 46 |
FLAG_ARG_NEEDS_COPY = 1 << (31- 7), /* Used by sysv code */ |
| 47 |
FLAG_ARG_NEEDS_PSAVE = FLAG_ARG_NEEDS_COPY, /* Used by linux64 code */ |
| 48 |
FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */ |
| 49 |
FLAG_4_GPR_ARGUMENTS = 1 << (31- 5), |
| 50 |
FLAG_RETVAL_REFERENCE = 1 << (31- 4), |
| 51 |
FLAG_VEC_ARGUMENTS = 1 << (31- 3), |
| 52 |
}; |
| 53 |
|
| 54 |
typedef union |
| 55 |
{ |
| 56 |
float f; |
| 57 |
double d; |
| 58 |
} ffi_dblfl; |
| 59 |
|
| 60 |
#if defined(__FLOAT128_TYPE__) && defined(__HAVE_FLOAT128) |
| 61 |
typedef _Float128 float128; |
| 62 |
#elif defined(__FLOAT128__) |
| 63 |
typedef __float128 float128; |
| 64 |
#else |
| 65 |
typedef char float128[16] __attribute__((aligned(16))); |
| 66 |
#endif |
| 67 |
|
| 68 |
void FFI_HIDDEN ffi_closure_SYSV (void); |
| 69 |
void FFI_HIDDEN ffi_go_closure_sysv (void); |
| 70 |
void FFI_HIDDEN ffi_call_SYSV(extended_cif *, void (*)(void), void *, |
| 71 |
unsigned, void *, int); |
| 72 |
|
| 73 |
void FFI_HIDDEN ffi_prep_types_sysv (ffi_abi); |
| 74 |
ffi_status FFI_HIDDEN ffi_prep_cif_sysv (ffi_cif *); |
| 75 |
ffi_status FFI_HIDDEN ffi_prep_closure_loc_sysv (ffi_closure *, |
| 76 |
ffi_cif *, |
| 77 |
void (*) (ffi_cif *, void *, |
| 78 |
void **, void *), |
| 79 |
void *, void *); |
| 80 |
int FFI_HIDDEN ffi_closure_helper_SYSV (ffi_cif *, |
| 81 |
void (*) (ffi_cif *, void *, |
| 82 |
void **, void *), |
| 83 |
void *, void *, unsigned long *, |
| 84 |
ffi_dblfl *, unsigned long *); |
| 85 |
|
| 86 |
void FFI_HIDDEN ffi_call_LINUX64(extended_cif *, void (*) (void), void *, |
| 87 |
unsigned long, void *, long); |
| 88 |
void FFI_HIDDEN ffi_closure_LINUX64 (void); |
| 89 |
void FFI_HIDDEN ffi_go_closure_linux64 (void); |
| 90 |
|
| 91 |
void FFI_HIDDEN ffi_prep_types_linux64 (ffi_abi); |
| 92 |
ffi_status FFI_HIDDEN ffi_prep_cif_linux64 (ffi_cif *); |
| 93 |
ffi_status FFI_HIDDEN ffi_prep_cif_linux64_var (ffi_cif *, unsigned int, |
| 94 |
unsigned int); |
| 95 |
void FFI_HIDDEN ffi_prep_args64 (extended_cif *, unsigned long *const); |
| 96 |
ffi_status FFI_HIDDEN ffi_prep_closure_loc_linux64 (ffi_closure *, ffi_cif *, |
| 97 |
void (*) (ffi_cif *, void *, |
| 98 |
void **, void *), |
| 99 |
void *, void *); |
| 100 |
int FFI_HIDDEN ffi_closure_helper_LINUX64 (ffi_cif *, |
| 101 |
void (*) (ffi_cif *, void *, |
| 102 |
void **, void *), |
| 103 |
void *, void *, |
| 104 |
unsigned long *, ffi_dblfl *, |
| 105 |
float128 *); |