]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/vendor-ti-am57x.git/blob - sgx_km/eurasia_km/include4/img_defs.h
sgx_km: Build SGX KM from source
[android/vendor-ti-am57x.git] / sgx_km / eurasia_km / include4 / img_defs.h
1 /*************************************************************************/ /*!
2 @Title          Common header containing type definitions for portability
3 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @Description    Contains variable and structure definitions. Any platform
5                 specific types should be defined in this file.
6 @License        Dual MIT/GPLv2
8 The contents of this file are subject to the MIT license as set out below.
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
32 This License is also included in this distribution in the file called
33 "MIT-COPYING".
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /**************************************************************************/
43 #if !defined (__IMG_DEFS_H__)
44 #define __IMG_DEFS_H__
46 #include "img_types.h"
48 typedef         enum    img_tag_TriStateSwitch
49 {
50         IMG_ON          =       0x00,
51         IMG_OFF,
52         IMG_IGNORE
54 } img_TriStateSwitch, * img_pTriStateSwitch;
56 #define         IMG_SUCCESS                             0
58 #define         IMG_NO_REG                              1
60 #if defined (NO_INLINE_FUNCS)
61         #define INLINE
62         #define FORCE_INLINE
63 #else
64 #if defined (__cplusplus)
65         #define INLINE                                  inline
66         #define FORCE_INLINE                    inline
67 #else
68 #if     !defined(INLINE)
69         #define INLINE                                  __inline
70 #endif
71         #define FORCE_INLINE                    static __inline
72 #endif
73 #endif
76 /* Use this in any file, or use attributes under GCC - see below */
77 #ifndef PVR_UNREFERENCED_PARAMETER
78 #define PVR_UNREFERENCED_PARAMETER(param) (param) = (param)
79 #endif
81 /* The best way to supress unused parameter warnings using GCC is to use a
82  * variable attribute.  Place the unref__ between the type and name of an
83  * unused parameter in a function parameter list, eg `int unref__ var'. This
84  * should only be used in GCC build environments, for example, in files that
85  * compile only on Linux. Other files should use UNREFERENCED_PARAMETER */
86 #ifdef __GNUC__
87 #define unref__ __attribute__ ((unused))
88 #else
89 #define unref__
90 #endif
92 /*
93         Wide character definitions
94 */
95 #ifndef _TCHAR_DEFINED
96 #if defined(UNICODE)
97 typedef unsigned short          TCHAR, *PTCHAR, *PTSTR;
98 #else   /* #if defined(UNICODE) */
99 typedef char                            TCHAR, *PTCHAR, *PTSTR;
100 #endif  /* #if defined(UNICODE) */
101 #define _TCHAR_DEFINED
102 #endif /* #ifndef _TCHAR_DEFINED */
105                         #if defined(__linux__) || defined(__QNXNTO__) || defined(__METAG)
107                                 #define IMG_CALLCONV
108                                 #define IMG_INTERNAL    __attribute__((visibility("hidden")))
109                                 #define IMG_EXPORT              __attribute__((visibility("default")))
110                                 #define IMG_IMPORT
111                                 #define IMG_RESTRICT    __restrict__
112                         #if defined(USE_64BIT_COMPAT)
113                                 #define IMG_COMPAT __attribute__ ((packed))
114                         #else
115                                 #define IMG_COMPAT
116                         #endif
118                         #else
119                                         #error("define an OS")
120                         #endif
122 // Use default definition if not overridden
123 #ifndef IMG_ABORT
124         #define IMG_ABORT()     abort()
125 #endif
127 #ifndef IMG_MALLOC
128         #define IMG_MALLOC(A)           malloc  (A)
129 #endif
131 #ifndef IMG_FREE
132         #define IMG_FREE(A)                     free    (A)
133 #endif
135 #define IMG_CONST const
137 #if defined(__GNUC__)
138 #define IMG_FORMAT_PRINTF(x,y)          __attribute__((format(printf,x,y)))
139 #else
140 #define IMG_FORMAT_PRINTF(x,y)
141 #endif
143 /*
144  * Cleanup request defines
145   */
146 #define  CLEANUP_WITH_POLL              IMG_FALSE
147 #define  FORCE_CLEANUP                  IMG_TRUE
149 #if defined (_WIN64)
150 #define IMG_UNDEF       (~0ULL)
151 #else
152 #define IMG_UNDEF       (~0UL)
153 #endif
155 /*
156    Do the right thing when using printf to output cpu addresses,
157    depending on architecture.
158  */
159 #if defined (_WIN64)
160     #define UINTPTR_FMT "%016llX"
161 #else
162     #if defined (__x86_64__)
163         #define UINTPTR_FMT "%016lX"
164     #else
165         #define UINTPTR_FMT "%08lX"
166     #endif
167 #endif
169 /* 
170    Similarly for DEV_ and SYS_ PHYSADDRs, but this is dependent on 32/36-bit MMU
171    capability, in addition to host architecture.
172  */
173 #if IMG_ADDRSPACE_PHYSADDR_BITS == 32
174         #if defined(IMG_UINT32_IS_ULONG)
175                 #define CPUPADDR_FMT "%08lX"
176                 #define DEVPADDR_FMT "%08lX"
177                 #define SYSPADDR_FMT "%08lX"
178         #else
179                 #define CPUPADDR_FMT "%08X"
180                 #define DEVPADDR_FMT "%08X"
181                 #define SYSPADDR_FMT "%08X"
182         #endif
183 #else
184         #if defined(__x86_64__)
185                         #define CPUPADDR_FMT "%016lX"
186                         #define DEVPADDR_FMT "%016lX"
187                         #define SYSPADDR_FMT "%016lX"
188         #else
190                         #define CPUPADDR_FMT "%016llX"
191                         #define DEVPADDR_FMT "%016llX"
192                         #define SYSPADDR_FMT "%016llX"
193         #endif
194 #endif
196 /*
197    Define a printf format macro for the length property of the format-specifier
198    for size_t, that allows avoidance of C99 dependency on compilers that don't
199    support this, while still ensuring that whatever the size of size_t (eg 32, 
200    64 bit Linux builds, or Win32/64 builds), a size_t (or IMG_SIZE_T) can be
201    passed to printf-type functions without a cast.
202 */
203 #if defined LINUX
204         /* Use C99 format specifier where possible */
205         #define SIZE_T_FMT_LEN "z"
206 #elif  defined _WIN64
207         #define SIZE_T_FMT_LEN "I"
208 #else
209         #define SIZE_T_FMT_LEN "l" /* May need to be updated as required, for other OSs */
210 #endif
213 #if defined (__x86_64__)
214         #define IMG_UINT64_FMT "l"
215 #else
216         #define IMG_UINT64_FMT "ll" /* May need to be updated as required, for other OSs */
217 #endif
219 /*
220         Some versions of MSVC don't have snprintf, vsnprintf in their CRTs.
221         Remap to the deprecated unix compatibility versions.
222 */
224 #endif /* #if !defined (__IMG_DEFS_H__) */
225 /*****************************************************************************
226  End of file (IMG_DEFS.H)
227 *****************************************************************************/