1 /*******************************************************************************
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  *
21  * Copyright 2014 QLogic Corporation
22  * The contents of this file are subject to the terms of the
23  * QLogic End User License (the "License").
24  * You may not use this file except in compliance with the License.
25  *
26  * You can obtain a copy of the License at
27  * http://www.qlogic.com/Resources/Documents/DriverDownloadHelp/
28  * QLogic_End_User_Software_License.txt
29  * See the License for the specific language governing permissions
30  * and limitations under the License.
31  *
32  ****************************************************************************/
33 #ifndef __bcmtype_h__
34 #define __bcmtype_h__
35 
36 #if defined(UEFI) && defined (EVEREST_DIAG)
37 #include <machine/endian.h>
38 #endif
39 
40 #ifndef IN
41 #define IN
42 #endif /* IN */
43 
44 #ifndef OUT
45 #define OUT
46 #endif /* OUT */
47 
48 #ifndef INOUT
49 #define INOUT
50 #endif /* INOUT */
51 
52 #ifndef OPTIONAL
53 #define OPTIONAL
54 #endif /* OPTIONAL */
55 
56 #if defined(__LINUX) || defined (USER_LINUX)
57 
58 #ifdef __LINUX
59 
60 #ifdef __BIG_ENDIAN
61 #ifndef BIG_ENDIAN
62 #define BIG_ENDIAN
63 #endif
64 #else /* __LITTLE_ENDIAN */
65 #ifndef LITTLE_ENDIAN
66 #define LITTLE_ENDIAN
67 #endif
68 #endif
69 
70 /*
71  * define underscore-t types
72  */
73 typedef u64 u64_t;
74 typedef u32 u32_t;
75 typedef u16 u16_t;
76 typedef u8  u8_t;
77 
78 typedef s64 s64_t;
79 typedef s32 s32_t;
80 typedef s16 s16_t;
81 typedef s8  s8_t;
82 
83 typedef unsigned long int_ptr_t;
84 
85 #else /* USER_LINUX */
86 
87 #if __BYTE_ORDER == __LITTLE_ENDIAN
88 #undef BIG_ENDIAN
89 #undef __BIG_ENDIAN
90 #else
91 #undef LITTLE_ENDIAN
92 #undef __LITTLE_ENDIAN
93 #endif
94 
95 /*
96  * define underscore-t types
97  */
98 typedef u_int64_t u64_t;
99 typedef u_int32_t u32_t;
100 typedef u_int16_t u16_t;
101 typedef u_int8_t  u8_t;
102 
103 typedef int64_t s64_t;
104 typedef int32_t s32_t;
105 typedef int16_t s16_t;
106 typedef int8_t  s8_t;
107 
108 typedef u_int64_t u64;
109 typedef u_int32_t u32;
110 typedef u_int16_t u16;
111 typedef u_int8_t  u8;
112 
113 typedef int64_t s64;
114 typedef int32_t s32;
115 typedef int16_t s16;
116 typedef int8_t  s8;
117 
118 typedef unsigned long int_ptr_t;
119 
120 /* Define upper case types */
121 
122 typedef u64_t 	U64;
123 typedef u32_t 	U32;
124 typedef u16_t 	U16;
125 typedef u8_t  	U8;
126 
127 typedef s64_t	S64;
128 typedef s32_t	S32;
129 typedef s16_t	S16;
130 typedef s8_t	S8;
131 
132 #endif
133 
134 
135 
136 #else
137 /*
138  * define the data model
139  */
140 #if !defined(LP64) && !defined(P64) && !defined(LLP64)
141   /* VC 32-bit compiler 5.0 or later */
142   #if (defined(_MSC_VER) && (_MSC_VER > 800)) || defined(TARGET_WINDOWS)
143     #define P64
144   #elif defined(__sun)
145     /* Solaris */
146     #define LP64
147   #elif defined(_HPUX_SOURCE)
148     /* HP/UX */
149     #define LP64
150   #elif defined(__FreeBSD__)
151     /* FreeBSD */
152     #define LP64
153   #elif defined(LINUX)
154     /* Linux */
155     #define LP64
156   #elif defined(__bsdi__)
157     /* BSDI */
158     #define LP64
159   #elif defined(_IRIX)
160     /* IRIX */
161     #define LP64
162   #elif defined(UNIXWARE)
163     /* UnixWare */
164     #define LP64
165   #endif /* UNIXWARE */
166 #endif /* !LP64 && !P64 && !LLP64 */
167 
168 /*
169  * define sized type
170  */
171 #if defined(P64) || defined(LLP64)
172   /* P64 */
173   typedef unsigned __int64    U64;
174   typedef unsigned int        U32;
175   typedef unsigned short      U16;
176   typedef unsigned char       U8;
177   typedef signed __int64      S64;
178   typedef signed int          S32;
179   typedef signed short        S16;
180   typedef signed char         S8;
181 
182   #if defined(IA64)  || defined(AMD64)
183         typedef U64  int_ptr_t;
184   #else
185     #ifndef UEFI64
186         typedef unsigned long       int_ptr_t;
187     #endif
188   #endif
189 #elif defined(LP64)
190   /* LP64: Sun, HP and etc */
191   typedef unsigned long long  U64;
192   typedef unsigned int        U32;
193   typedef unsigned short      U16;
194   typedef unsigned char       U8;
195   typedef signed long long    S64;
196   typedef signed int          S32;
197   typedef signed short        S16;
198   typedef signed char         S8;
199   typedef unsigned long       int_ptr_t;
200 #elif defined(__WATCOMC__)
201   typedef unsigned __int64    U64;
202   typedef unsigned long       U32;
203   typedef unsigned short      U16;
204   typedef unsigned char       U8;
205   typedef signed __int64      S64;
206   typedef signed long         S32;
207   typedef signed short        S16;
208   typedef signed char         S8;
209   typedef unsigned long       int_ptr_t;
210 #else
211   /* assume others: 16-bit */
212   typedef unsigned char       U64[8];
213   typedef unsigned long       U32;
214   typedef unsigned short      U16;
215   typedef unsigned char       U8;
216   typedef signed char         S64[8];
217   typedef signed long         S32;
218   typedef signed short        S16;
219   typedef signed char         S8;
220   typedef unsigned long       int_ptr_t;
221 #endif /*  */
222 
223 
224 
225 /*
226  * define lower case types
227  */
228 typedef U64 u64_t;
229 typedef U32 u32_t;
230 typedef U16 u16_t;
231 typedef U8  u8_t;
232 
233 typedef S64 s64_t;
234 typedef S32 s32_t;
235 typedef S16 s16_t;
236 typedef S8  s8_t;
237 
238 #ifndef LINUX
239 typedef U64 u64;
240 typedef U32 u32;
241 typedef U16 u16;
242 typedef U8  u8;
243 
244 typedef S64 s64;
245 typedef S32 s32;
246 typedef S16 s16;
247 typedef S8  s8;
248 #endif
249 
250 #endif
251 
252 #ifdef UEFI
253 #if BYTE_ORDER == LITTLE_ENDIAN
254 #undef BIG_ENDIAN
255 #endif
256 #ifdef UEFI64
257 typedef u64_t  int_ptr_t;
258 #endif
259 #endif
260 
261 #ifdef LITTLE_ENDIAN
262 #ifndef __LITTLE_ENDIAN
263 #define __LITTLE_ENDIAN LITTLE_ENDIAN
264 #endif /* __LITTLE_ENDIAN */
265 #endif /* LITTLE_ENDIAN */
266 
267 #ifdef BIG_ENDIAN
268 #ifndef __BIG_ENDIAN
269 #define  __BIG_ENDIAN  BIG_ENDIAN
270 #endif /* __BIG_ENDIAN */
271 #endif /* BIG_ENDIAN */
272 
273 #ifdef __FreeBSD__
274 #if _BYTE_ORDER == _LITTLE_ENDIAN
275 #undef BIG_ENDIAN
276 #undef __BIG_ENDIAN
277 #else
278 #undef LITTLE_ENDIAN
279 #undef __LITTLE_ENDIAN
280 #endif
281 #endif /* __FreeBSD__ */
282 
283 /* Signed subtraction macros with no sign extending.  */
284 #define S64_SUB(_a, _b)     ((s64_t) ((s64_t) (_a) - (s64_t) (_b)))
285 #define u64_SUB(_a, _b)     ((u64_t) ((s64_t) (_a) - (s64_t) (_b)))
286 #define S32_SUB(_a, _b)     ((s32_t) ((s32_t) (_a) - (s32_t) (_b)))
287 #define uS32_SUB(_a, _b)    ((u32_t) ((s32_t) (_a) - (s32_t) (_b)))
288 #define S16_SUB(_a, _b)     ((s16_t) ((s16_t) (_a) - (s16_t) (_b)))
289 #define u16_SUB(_a, _b)     ((u16_t) ((s16_t) (_a) - (s16_t) (_b)))
290 #define PTR_SUB(_a, _b)     ((u8_t *) (_a) - (u8_t *) (_b))
291 
292 #if (!defined LINUX ) && (!defined MFW)
293 #define __builtin_offsetof(path1_nvm_image_t, f) (u32_t)((int_ptr_t)(&(((path1_nvm_image_t *)0)->f)))
294 #endif
295 
296 #endif/* __bcmtype_h__ */
297 
298