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_64BITS   = 1 << (31-28),
38 
39   /* This goes in cr6 */
40   FLAG_RETURNS_128BITS  = 1 << (31-27),
41 
42   FLAG_COMPAT		= 1 << (31- 8), /* Not used by assembly */
43 
44   /* These go in cr1 */
45   FLAG_ARG_NEEDS_COPY   = 1 << (31- 7), /* Used by sysv code */
46   FLAG_ARG_NEEDS_PSAVE  = FLAG_ARG_NEEDS_COPY, /* Used by linux64 code */
47   FLAG_FP_ARGUMENTS     = 1 << (31- 6), /* cr1.eq; specified by ABI */
48   FLAG_4_GPR_ARGUMENTS  = 1 << (31- 5),
49   FLAG_RETVAL_REFERENCE = 1 << (31- 4)
50 };
51 
52 typedef union
53 {
54   float f;
55   double d;
56 } ffi_dblfl;
57 
58 void FFI_HIDDEN ffi_closure_SYSV (void);
59 void FFI_HIDDEN ffi_call_SYSV(extended_cif *, unsigned, unsigned, unsigned *,
60 			      void (*)(void));
61 
62 void FFI_HIDDEN ffi_prep_types_sysv (ffi_abi);
63 ffi_status FFI_HIDDEN ffi_prep_cif_sysv (ffi_cif *);
64 int FFI_HIDDEN ffi_closure_helper_SYSV (ffi_closure *, void *, unsigned long *,
65 					ffi_dblfl *, unsigned long *);
66 
67 void FFI_HIDDEN ffi_call_LINUX64(extended_cif *, unsigned long, unsigned long,
68 				 unsigned long *, void (*)(void));
69 void FFI_HIDDEN ffi_closure_LINUX64 (void);
70 
71 void FFI_HIDDEN ffi_prep_types_linux64 (ffi_abi);
72 ffi_status FFI_HIDDEN ffi_prep_cif_linux64 (ffi_cif *);
73 ffi_status FFI_HIDDEN ffi_prep_cif_linux64_var (ffi_cif *, unsigned int,
74 						unsigned int);
75 void FFI_HIDDEN ffi_prep_args64 (extended_cif *, unsigned long *const);
76 int FFI_HIDDEN ffi_closure_helper_LINUX64 (ffi_closure *, void *,
77 					   unsigned long *, ffi_dblfl *);
78