34e62cba9b0777802ebb2e03a8b7f39be27dfd43
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / mt5931_kk / drv_wlan / os / linux / include / gl_typedef.h
1 /*
2 ** $Id: //Department/DaVinci/BRANCHES/MT662X_593X_WIFI_DRIVER_V2_3/os/linux/include/gl_typedef.h#1 $
3 */
4
5 /*! \file   gl_typedef.h
6     \brief  Definition of basic data type(os dependent).
7
8     In this file we define the basic data type.
9 */
10
11 /*******************************************************************************
12 * Copyright (c) 2007 MediaTek Inc.
13 *
14 * All rights reserved. Copying, compilation, modification, distribution
15 * or any other use whatsoever of this material is strictly prohibited
16 * except in accordance with a Software License Agreement with
17 * MediaTek Inc.
18 ********************************************************************************
19 */
20
21 /*******************************************************************************
22 * LEGAL DISCLAIMER
23 *
24 * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND
25 * AGREES THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK
26 * SOFTWARE") RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE
27 * PROVIDED TO BUYER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY
28 * DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
29 * LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
30 * PARTICULAR PURPOSE OR NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE
31 * ANY WARRANTY WHATSOEVER WITH RESPECT TO THE SOFTWARE OF ANY THIRD PARTY
32 * WHICH MAY BE USED BY, INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK
33 * SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY
34 * WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE
35 * FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S SPECIFICATION OR TO
36 * CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
37 *
38 * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
39 * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL
40 * BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT
41 * ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY
42 * BUYER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
43 *
44 * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
45 * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT
46 * OF LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING
47 * THEREOF AND RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN
48 * FRANCISCO, CA, UNDER THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE
49 * (ICC).
50 ********************************************************************************
51 */
52
53 /*
54 ** $Log: gl_typedef.h $
55  *
56  * 06 22 2012 cp.wu
57  * [WCXRP00001257] [MT6620][MT5931][MT6628][Driver][Linux] Modify KAL_HZ to align ms accuracy
58  * modify KAL_HZ to (1000) for correct definition.
59  *
60  * 03 21 2011 cp.wu
61  * [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
62  * portability improvement
63  *
64  * 02 15 2011 jeffrey.chang
65  * NULL
66  * to support early suspend in android
67  *
68  * 07 08 2010 cp.wu
69  * 
70  * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
71  *
72  * 06 06 2010 kevin.huang
73  * [WPD00003832][MT6620 5931] Create driver base 
74  * [MT6620 5931] Create driver base
75  *
76  * 03 24 2010 jeffrey.chang
77  * [WPD00003826]Initial import for Linux port 
78  * initial import for Linux port
79 **  \main\maintrunk.MT5921\6 2009-08-18 22:57:14 GMT mtk01090
80 **  Add Linux SDIO (with mmc core) support.
81 **  Add Linux 2.6.21, 2.6.25, 2.6.26.
82 **  Fix compile warning in Linux.
83 **  \main\maintrunk.MT5921\5 2008-09-22 23:19:30 GMT mtk01461
84 **  Update comment for code review
85 **  \main\maintrunk.MT5921\4 2008-09-05 17:25:16 GMT mtk01461
86 **  Update Driver for Code Review
87 **  \main\maintrunk.MT5921\3 2007-11-09 11:00:50 GMT mtk01425
88 **  1. Use macro to unify network-to-host and host-to-network related functions
89 ** Revision 1.3  2007/06/27 02:18:51  MTK01461
90 ** Update SCAN_FSM, Initial(Can Load Module), Proc(Can do Reg R/W), TX API
91 **
92 ** Revision 1.2  2007/06/25 06:16:24  MTK01461
93 ** Update illustrations, gl_init.c, gl_kal.c, gl_kal.h, gl_os.h and RX API
94 **
95 */
96
97 #ifndef _GL_TYPEDEF_H
98 #define _GL_TYPEDEF_H
99
100 #if defined(CONFIG_HAS_EARLYSUSPEND)
101 #include <linux/earlysuspend.h>
102 #endif
103
104 /*******************************************************************************
105 *                         C O M P I L E R   F L A G S
106 ********************************************************************************
107 */
108
109 /*******************************************************************************
110 *                    E X T E R N A L   R E F E R E N C E S
111 ********************************************************************************
112 */
113
114 /*******************************************************************************
115 *                              C O N S T A N T S
116 ********************************************************************************
117 */
118 /* Define HZ of timer tick for function kalGetTimeTick() */
119 #define KAL_HZ                  (1000)
120
121 /* Miscellaneous Equates */
122 #ifndef FALSE
123     #define FALSE               ((BOOL) 0)
124     #define TRUE                ((BOOL) 1)
125 #endif /* FALSE */
126
127 #ifndef NULL
128     #if defined(__cplusplus)
129         #define NULL            0
130     #else
131         #define NULL            ((void *) 0)
132     #endif
133 #endif
134
135 #if defined(CONFIG_HAS_EARLYSUSPEND)
136 typedef void (*early_suspend_callback)(struct early_suspend *h);
137 typedef void (*late_resume_callback) (struct early_suspend *h);
138 #endif
139
140
141 /*******************************************************************************
142 *                             D A T A   T Y P E S
143 ********************************************************************************
144 */
145 /* Type definition for void */
146 typedef void                    VOID, *PVOID, **PPVOID;
147
148 /* Type definition for Boolean */
149 typedef unsigned char           BOOL, *PBOOL, BOOLEAN, *PBOOLEAN;
150
151 /* Type definition for signed integers */
152 typedef signed char             CHAR, *PCHAR, **PPCHAR;
153 typedef signed char             INT_8, *PINT_8, **PPINT_8;
154 typedef signed short            INT_16, *PINT_16, **PPINT_16;
155 typedef signed long             INT_32, *PINT_32, **PPINT_32;
156 typedef signed long long        INT_64, *PINT_64, **PPINT_64;
157
158 /* Type definition for unsigned integers */
159 typedef unsigned char           UCHAR, *PUCHAR, **PPUCHAR;
160 typedef unsigned char           UINT_8, *PUINT_8, **PPUINT_8, *P_UINT_8;
161 typedef unsigned short          UINT_16, *PUINT_16, **PPUINT_16;
162 typedef unsigned long           ULONG, UINT_32, *PUINT_32, **PPUINT_32;
163 typedef unsigned long long      UINT_64, *PUINT_64, **PPUINT_64;
164
165 typedef unsigned long           OS_SYSTIME, *POS_SYSTIME, **PPOS_SYSTIME;
166
167
168 /* Type definition of large integer (64bits) union to be comptaible with
169  * Windows definition, so we won't apply our own coding style to these data types.
170  * NOTE: LARGE_INTEGER must NOT be floating variable.
171  * <TODO>: Check for big-endian compatibility.
172  */
173 typedef union _LARGE_INTEGER {
174     struct {
175         UINT_32  LowPart;
176         INT_32   HighPart;
177     } u;
178     INT_64       QuadPart;
179 } LARGE_INTEGER, *PLARGE_INTEGER;
180
181 typedef union _ULARGE_INTEGER {
182     struct {
183         UINT_32  LowPart;
184         UINT_32  HighPart;
185     } u;
186     UINT_64      QuadPart;
187 } ULARGE_INTEGER, *PULARGE_INTEGER;
188
189
190 typedef INT_32 (*probe_card)(PVOID pvData);
191 typedef VOID (*remove_card)(VOID);
192
193 /*******************************************************************************
194 *                            P U B L I C   D A T A
195 ********************************************************************************
196 */
197
198 /*******************************************************************************
199 *                           P R I V A T E   D A T A
200 ********************************************************************************
201 */
202
203 /*******************************************************************************
204 *                                 M A C R O S
205 ********************************************************************************
206 */
207 #define IN  //volatile
208 #define OUT //volatile
209
210 #define __KAL_INLINE__                  static __inline__
211 #define __KAL_ATTRIB_PACKED__           __attribute__((__packed__))
212 #define __KAL_ATTRIB_ALIGN_4__          __attribute__ ((aligned (4)))
213
214
215 #ifndef BIT
216 #define BIT(n)                          ((UINT_32) 1UL << (n))
217 #endif /* BIT */
218
219 #ifndef BITS
220 /* bits range: for example BITS(16,23) = 0xFF0000
221  *   ==>  (BIT(m)-1)   = 0x0000FFFF     ~(BIT(m)-1)   => 0xFFFF0000
222  *   ==>  (BIT(n+1)-1) = 0x00FFFFFF
223  */
224 #define BITS(m,n)                       (~(BIT(m)-1) & ((BIT(n) - 1) | BIT(n)))
225 #endif /* BIT */
226
227
228 /* This macro returns the byte offset of a named field in a known structure
229    type.
230    _type - structure name,
231    _field - field name of the structure */
232 #ifndef OFFSET_OF
233     #define OFFSET_OF(_type, _field)    ((UINT_32)&(((_type *)0)->_field))
234 #endif /* OFFSET_OF */
235
236
237 /* This macro returns the base address of an instance of a structure
238  * given the type of the structure and the address of a field within the
239  * containing structure.
240  * _addrOfField - address of current field of the structure,
241  * _type - structure name,
242  * _field - field name of the structure
243  */
244 #ifndef ENTRY_OF
245     #define ENTRY_OF(_addrOfField, _type, _field) \
246         ((_type *)((PINT_8)(_addrOfField) - (PINT_8)OFFSET_OF(_type, _field)))
247 #endif /* ENTRY_OF */
248
249
250 /* This macro align the input value to the DW boundary.
251  * _value - value need to check
252  */
253 #ifndef ALIGN_4
254     #define ALIGN_4(_value)             (((_value) + 3) & ~3u)
255 #endif /* ALIGN_4 */
256
257 /* This macro check the DW alignment of the input value.
258  * _value - value of address need to check
259  */
260 #ifndef IS_ALIGN_4
261     #define IS_ALIGN_4(_value)          (((_value) & 0x3) ? FALSE : TRUE)
262 #endif /* IS_ALIGN_4 */
263
264 #ifndef IS_NOT_ALIGN_4
265     #define IS_NOT_ALIGN_4(_value)      (((_value) & 0x3) ? TRUE : FALSE)
266 #endif /* IS_NOT_ALIGN_4 */
267
268
269 /* This macro evaluate the input length in unit of Double Word(4 Bytes).
270  * _value - value in unit of Byte, output will round up to DW boundary.
271  */
272 #ifndef BYTE_TO_DWORD
273     #define BYTE_TO_DWORD(_value)       ((_value + 3) >> 2)
274 #endif /* BYTE_TO_DWORD */
275
276 /* This macro evaluate the input length in unit of Byte.
277  * _value - value in unit of DW, output is in unit of Byte.
278  */
279 #ifndef DWORD_TO_BYTE
280     #define DWORD_TO_BYTE(_value)       ((_value) << 2)
281 #endif /* DWORD_TO_BYTE */
282
283 #if 1 // Little-Endian
284     #define CONST_NTOHS(_x)     __constant_ntohs(_x)
285
286     #define CONST_HTONS(_x)     __constant_htons(_x)
287
288     #define NTOHS(_x)           ntohs(_x)
289
290     #define HTONS(_x)           htons(_x)
291
292     #define NTOHL(_x)           ntohl(_x)
293
294     #define HTONL(_x)           htonl(_x)
295
296 #else // Big-Endian
297
298     #define CONST_NTOHS(_x)
299
300     #define CONST_HTONS(_x)
301
302     #define NTOHS(_x)
303
304     #define HTONS(_x)
305
306 #endif
307
308 /*******************************************************************************
309 *                  F U N C T I O N   D E C L A R A T I O N S
310 ********************************************************************************
311 */
312
313 /*******************************************************************************
314 *                              F U N C T I O N S
315 ********************************************************************************
316 */
317
318 #endif /* _GL_TYPEDEF_H */
319