1 /*************************************************************************/ /*!
2 @Title Global types for use by IMG APIs
3 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @Description Defines type aliases for use by IMG APIs.
5 @License Dual MIT/GPLv2
7 The contents of this file are subject to the MIT license as set out below.
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
19 Alternatively, the contents of this file may be used under the terms of
20 the GNU General Public License Version 2 ("GPL") in which case the provisions
21 of GPL are applicable instead of those above.
23 If you wish to allow use of your version of this file only under the terms of
24 GPL, and not to allow others to use your version of this file under the terms
25 of the MIT license, indicate your decision by deleting the provisions above
26 and replace them with the notice and other provisions required by GPL as set
27 out in the file called "GPL-COPYING" included in this distribution. If you do
28 not delete the provisions above, a recipient may use your version of this file
29 under the terms of either the MIT license or GPL.
31 This License is also included in this distribution in the file called
32 "MIT-COPYING".
34 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
35 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
38 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /**************************************************************************/
43 #ifndef __IMG_TYPES_H__
44 #define __IMG_TYPES_H__
46 /* define all address space bit depths: */
47 /* CPU virtual address space defaults to 32bits */
48 #if !defined(IMG_ADDRSPACE_CPUVADDR_BITS)
49 #define IMG_ADDRSPACE_CPUVADDR_BITS 32
50 #endif
52 /* Physical address space defaults to 32bits */
53 #if !defined(IMG_ADDRSPACE_PHYSADDR_BITS)
54 #define IMG_ADDRSPACE_PHYSADDR_BITS 32
55 #endif
57 typedef unsigned int IMG_UINT, *IMG_PUINT;
58 typedef signed int IMG_INT, *IMG_PINT;
60 typedef unsigned char IMG_UINT8, *IMG_PUINT8;
61 typedef unsigned char IMG_BYTE, *IMG_PBYTE;
62 typedef signed char IMG_INT8, *IMG_PINT8;
63 typedef char IMG_CHAR, *IMG_PCHAR;
65 typedef unsigned short IMG_UINT16, *IMG_PUINT16;
66 typedef signed short IMG_INT16, *IMG_PINT16;
67 #if !defined(IMG_UINT32_IS_ULONG)
68 typedef unsigned int IMG_UINT32, *IMG_PUINT32;
69 typedef signed int IMG_INT32, *IMG_PINT32;
70 #else
71 typedef unsigned long IMG_UINT32, *IMG_PUINT32;
72 typedef signed long IMG_INT32, *IMG_PINT32;
73 #endif
74 #if !defined(IMG_UINT32_MAX)
75 #define IMG_UINT32_MAX 0xFFFFFFFFUL
76 #endif
78 #if defined(USE_CODE)
80 typedef unsigned __int64 IMG_UINT64, *IMG_PUINT64;
81 typedef __int64 IMG_INT64, *IMG_PINT64;
83 #else
84 #if ((defined(LINUX) || defined(__METAG)) || defined(__QNXNTO__))
85 typedef unsigned long long IMG_UINT64, *IMG_PUINT64;
86 typedef long long IMG_INT64, *IMG_PINT64;
87 #else
88 #error("define an OS")
89 #endif
90 #endif
92 #if !(defined(LINUX) && defined (__KERNEL__))
93 /* Linux kernel mode does not use floating point */
94 typedef float IMG_FLOAT, *IMG_PFLOAT;
95 typedef double IMG_DOUBLE, *IMG_PDOUBLE;
96 #endif
98 typedef enum tag_img_bool
99 {
100 IMG_FALSE = 0,
101 IMG_TRUE = 1,
102 IMG_FORCE_ALIGN = 0x7FFFFFFF
103 } IMG_BOOL, *IMG_PBOOL;
105 typedef void IMG_VOID, *IMG_PVOID;
107 typedef IMG_INT32 IMG_RESULT;
109 #if defined(_WIN64)
110 typedef unsigned __int64 IMG_UINTPTR_T;
111 typedef signed __int64 IMG_PTRDIFF_T;
112 typedef IMG_UINT64 IMG_SIZE_T;
113 #else
114 typedef unsigned int IMG_UINTPTR_T;
115 typedef IMG_UINT32 IMG_SIZE_T;
116 #endif
118 typedef IMG_PVOID IMG_HANDLE;
120 typedef void** IMG_HVOID, * IMG_PHVOID;
122 #define IMG_NULL 0
124 /* services/stream ID */
125 typedef IMG_UINT32 IMG_SID;
127 typedef IMG_UINT32 IMG_EVENTSID;
129 /*
130 * Address types.
131 * All types used to refer to a block of memory are wrapped in structures
132 * to enforce some degree of type safety, i.e. a IMG_DEV_VIRTADDR cannot
133 * be assigned to a variable of type IMG_DEV_PHYADDR because they are not the
134 * same thing.
135 *
136 * There is an assumption that the system contains at most one non-cpu mmu,
137 * and a memory block is only mapped by the MMU once.
138 *
139 * Different devices could have offset views of the physical address space.
140 *
141 */
144 /*
145 *
146 * +------------+ +------------+ +------------+ +------------+
147 * | CPU | | DEV | | DEV | | DEV |
148 * +------------+ +------------+ +------------+ +------------+
149 * | | | |
150 * | PVOID |IMG_DEV_VIRTADDR |IMG_DEV_VIRTADDR |
151 * | \-------------------/ |
152 * | | |
153 * +------------+ +------------+ |
154 * | MMU | | MMU | |
155 * +------------+ +------------+ |
156 * | | |
157 * | | |
158 * | | |
159 * +--------+ +---------+ +--------+
160 * | Offset | | (Offset)| | Offset |
161 * +--------+ +---------+ +--------+
162 * | | IMG_DEV_PHYADDR |
163 * | | |
164 * | | IMG_DEV_PHYADDR |
165 * +---------------------------------------------------------------------+
166 * | System Address bus |
167 * +---------------------------------------------------------------------+
168 *
169 */
171 typedef IMG_PVOID IMG_CPU_VIRTADDR;
173 /* device virtual address */
174 typedef struct _IMG_DEV_VIRTADDR
175 {
176 /* device virtual addresses are 32bit for now */
177 IMG_UINT32 uiAddr;
178 #define IMG_CAST_TO_DEVVADDR_UINT(var) (IMG_UINT32)(var)
180 } IMG_DEV_VIRTADDR;
182 typedef IMG_UINT32 IMG_DEVMEM_SIZE_T;
184 /* cpu physical address */
185 typedef struct _IMG_CPU_PHYADDR
186 {
187 /* variable sized type (32,64) */
188 IMG_UINTPTR_T uiAddr;
189 } IMG_CPU_PHYADDR;
191 /* device physical address */
192 typedef struct _IMG_DEV_PHYADDR
193 {
194 #if IMG_ADDRSPACE_PHYSADDR_BITS == 32
195 /* variable sized type (32,64) */
196 IMG_UINTPTR_T uiAddr;
197 #else
198 IMG_UINT32 uiAddr;
199 IMG_UINT32 uiHighAddr;
200 #endif
201 } IMG_DEV_PHYADDR;
203 /* system physical address */
204 typedef struct _IMG_SYS_PHYADDR
205 {
206 /* variable sized type (32,64) */
207 IMG_UINTPTR_T uiAddr;
208 } IMG_SYS_PHYADDR;
210 #include "img_defs.h"
212 #endif /* __IMG_TYPES_H__ */
213 /******************************************************************************
214 End of file (img_types.h)
215 ******************************************************************************/