1 /*************************************************************************/ /*!
3 @Title Global types for use by IMG APIs
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Defines type aliases for use by IMG APIs.
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
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 */ /**************************************************************************/
44 #ifndef __IMG_TYPES_H__
45 #define __IMG_TYPES_H__
46 #if defined (__cplusplus)
49 /* number of bits in the units returned by sizeof */
50 #define IMG_CHAR_BIT 8
52 /* define all address space bit depths: */
53 /* CPU virtual address space defaults to 32bits */
54 #if !defined(IMG_ADDRSPACE_CPUVADDR_BITS)
55 #define IMG_ADDRSPACE_CPUVADDR_BITS 32
58 typedef unsigned int IMG_UINT, *IMG_PUINT;
59 typedef signed int IMG_INT, *IMG_PINT;
61 typedef unsigned char IMG_UINT8, *IMG_PUINT8;
62 typedef unsigned char IMG_BYTE, *IMG_PBYTE;
63 typedef signed char IMG_INT8, *IMG_PINT8;
64 typedef char IMG_CHAR, *IMG_PCHAR;
65 typedef IMG_CHAR const *IMG_PCCHAR;
67 typedef unsigned short IMG_UINT16, *IMG_PUINT16;
68 typedef signed short IMG_INT16, *IMG_PINT16;
69 typedef unsigned int IMG_UINT32, *IMG_PUINT32;
70 typedef signed int IMG_INT32, *IMG_PINT32;
71 #if !defined(IMG_UINT32_MAX)
72 #define IMG_UINT32_MAX 0xFFFFFFFFUL
74 #if !defined(IMG_UINT16_MAX)
75 #define IMG_UINT16_MAX 0xFFFFU
78 typedef IMG_UINT16 const* IMG_PCUINT16;
79 typedef IMG_INT16 const* IMG_PCINT16;
80 typedef IMG_UINT32 const* IMG_PCUINT32;
81 typedef IMG_INT32 const* IMG_PCINT32;
85 typedef unsigned __int64 IMG_UINT64, *IMG_PUINT64;
86 typedef __int64 IMG_INT64, *IMG_PINT64;
87 #define IMG_INT64_C(c) c ## LL
88 #define IMG_UINT64_C(c) c ## ULL
90 #define strtoll _strtoi64
94 #if defined(LINUX) || defined(__METAG) || defined(__QNXNTO__)
95 typedef unsigned long long IMG_UINT64, *IMG_PUINT64;
96 typedef long long IMG_INT64, *IMG_PINT64;
97 #define IMG_INT64_C(c) c ## LL
98 #define IMG_UINT64_C(c) c ## ULL
100 #error("define an OS")
103 #if !defined(IMG_UINT64_MAX)
104 #define IMG_UINT64_MAX 0xFFFFFFFFFFFFFFFFULL
107 #if !(defined(LINUX) && defined (__KERNEL__))
108 /* Linux kernel mode does not use floating point */
109 typedef float IMG_FLOAT, *IMG_PFLOAT;
110 typedef double IMG_DOUBLE, *IMG_PDOUBLE;
112 typedef union _IMG_UINT32_FLOAT_
120 typedef int IMG_SECURE_TYPE;
122 typedef enum tag_img_bool
126 IMG_FORCE_ALIGN = 0x7FFFFFFF
127 } IMG_BOOL, *IMG_PBOOL;
128 typedef IMG_BOOL const* IMG_PCBOOL;
130 typedef void IMG_VOID, *IMG_PVOID;
131 typedef IMG_VOID const* IMG_PCVOID;
133 /* Figure out which headers to include to get uintptr_t. */
134 #if !defined(_MSC_VER) && !defined(__KERNEL__)
135 /* MSVC before VS2010 doesn't have <stdint.h>, but it has uintptr_t in
139 #if defined(__QNXNTO__)
142 #if defined(LINUX) && defined (__KERNEL__)
143 #include <linux/types.h>
147 typedef uintptr_t IMG_UINTPTR_T;
148 typedef size_t IMG_SIZE_T;
150 #define IMG_SIZE_T_MAX ((IMG_SIZE_T) -1)
152 #if defined(_MSC_VER)
153 #define IMG_SIZE_FMTSPEC "%Iu"
154 #define IMG_SIZE_FMTSPECX "%Ix"
156 #define IMG_SIZE_FMTSPEC "%zu"
157 #define IMG_SIZE_FMTSPECX "%zx"
160 typedef IMG_PVOID IMG_HANDLE;
162 #define IMG_NULL NULL
164 /* services/stream ID */
165 typedef IMG_UINT64 IMG_SID;
168 typedef IMG_UINT32 IMG_PID;
173 * All types used to refer to a block of memory are wrapped in structures
174 * to enforce some degree of type safety, i.e. a IMG_DEV_VIRTADDR cannot
175 * be assigned to a variable of type IMG_DEV_PHYADDR because they are not the
178 * There is an assumption that the system contains at most one non-cpu mmu,
179 * and a memory block is only mapped by the MMU once.
181 * Different devices could have offset views of the physical address space.
188 * +------------+ +------------+ +------------+ +------------+
189 * | CPU | | DEV | | DEV | | DEV |
190 * +------------+ +------------+ +------------+ +------------+
192 * | PVOID |IMG_DEV_VIRTADDR |IMG_DEV_VIRTADDR |
193 * | \-------------------/ |
195 * +------------+ +------------+ |
197 * +------------+ +------------+ |
201 * +--------+ +---------+ +--------+
202 * | Offset | | (Offset)| | Offset |
203 * +--------+ +---------+ +--------+
204 * | | IMG_DEV_PHYADDR |
206 * | | IMG_DEV_PHYADDR |
207 * +---------------------------------------------------------------------+
208 * | System Address bus |
209 * +---------------------------------------------------------------------+
213 typedef IMG_PVOID IMG_CPU_VIRTADDR;
215 /* device virtual address */
216 typedef struct _IMG_DEV_VIRTADDR
219 #define IMG_CAST_TO_DEVVADDR_UINT(var) (IMG_UINT64)(var)
223 typedef IMG_UINT64 IMG_DEVMEM_SIZE_T;
224 typedef IMG_UINT64 IMG_DEVMEM_ALIGN_T;
225 typedef IMG_UINT64 IMG_DEVMEM_OFFSET_T;
226 typedef IMG_UINT32 IMG_DEVMEM_LOG2ALIGN_T;
228 #define IMG_DEV_VIRTADDR_FMTSPEC "0x%010llX"
229 #define IMG_DEVMEM_SIZE_FMTSPEC "0x%010llX"
230 #define IMG_DEVMEM_ALIGN_FMTSPEC "0x%010llX"
231 #define IMG_DEVMEM_OFFSET_FMTSPEC "0x%010llX"
233 /* cpu physical address */
234 typedef struct _IMG_CPU_PHYADDR
236 #if defined(UNDER_WDDM)
237 IMG_UINTPTR_T uiAddr;
238 #define IMG_CAST_TO_CPUPHYADDR_UINT(var) (IMG_UINTPTR_T)(var)
241 #define IMG_CAST_TO_CPUPHYADDR_UINT(var) (IMG_UINT64)(var)
245 /* device physical address */
246 typedef struct _IMG_DEV_PHYADDR
251 /* system physical address */
252 typedef struct _IMG_SYS_PHYADDR
254 #if defined(UNDER_WDDM)
255 IMG_UINTPTR_T uiAddr;
264 typedef struct _IMG_RECT_
272 typedef struct _IMG_RECT_16_
280 #if defined (__cplusplus)
284 #include "img_defs.h"
286 #endif /* __IMG_TYPES_H__ */
287 /******************************************************************************
288 End of file (img_types.h)
289 ******************************************************************************/