2 ** $Id: //Department/DaVinci/BRANCHES/MT662X_593X_WIFI_DRIVER_V2_3/os/linux/include/gl_typedef.h#1 $
6 \brief Definition of basic data type(os dependent).
8 In this file we define the basic data type.
11 /*******************************************************************************
12 * Copyright (c) 2007 MediaTek Inc.
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
18 ********************************************************************************
21 /*******************************************************************************
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.
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.
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
50 ********************************************************************************
54 ** $Log: gl_typedef.h $
57 * [WCXRP00001257] [MT6620][MT5931][MT6628][Driver][Linux] Modify KAL_HZ to align ms accuracy
58 * modify KAL_HZ to (1000) for correct definition.
61 * [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
62 * portability improvement
64 * 02 15 2011 jeffrey.chang
66 * to support early suspend in android
70 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
72 * 06 06 2010 kevin.huang
73 * [WPD00003832][MT6620 5931] Create driver base
74 * [MT6620 5931] Create driver base
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
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
100 #if defined(CONFIG_HAS_EARLYSUSPEND)
101 #include <linux/earlysuspend.h>
104 /*******************************************************************************
105 * C O M P I L E R F L A G S
106 ********************************************************************************
109 /*******************************************************************************
110 * E X T E R N A L R E F E R E N C E S
111 ********************************************************************************
114 /*******************************************************************************
116 ********************************************************************************
118 /* Define HZ of timer tick for function kalGetTimeTick() */
119 #define KAL_HZ (1000)
121 /* Miscellaneous Equates */
123 #define FALSE ((BOOL) 0)
124 #define TRUE ((BOOL) 1)
128 #if defined(__cplusplus)
131 #define NULL ((void *) 0)
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);
141 /*******************************************************************************
143 ********************************************************************************
145 /* Type definition for void */
146 typedef void VOID, *PVOID, **PPVOID;
148 /* Type definition for Boolean */
149 typedef unsigned char BOOL, *PBOOL, BOOLEAN, *PBOOLEAN;
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;
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;
165 typedef unsigned long OS_SYSTIME, *POS_SYSTIME, **PPOS_SYSTIME;
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.
173 typedef union _LARGE_INTEGER {
179 } LARGE_INTEGER, *PLARGE_INTEGER;
181 typedef union _ULARGE_INTEGER {
187 } ULARGE_INTEGER, *PULARGE_INTEGER;
190 typedef INT_32 (*probe_card)(PVOID pvData);
191 typedef VOID (*remove_card)(VOID);
193 /*******************************************************************************
194 * P U B L I C D A T A
195 ********************************************************************************
198 /*******************************************************************************
199 * P R I V A T E D A T A
200 ********************************************************************************
203 /*******************************************************************************
205 ********************************************************************************
207 #define IN //volatile
208 #define OUT //volatile
210 #define __KAL_INLINE__ static __inline__
211 #define __KAL_ATTRIB_PACKED__ __attribute__((__packed__))
212 #define __KAL_ATTRIB_ALIGN_4__ __attribute__ ((aligned (4)))
216 #define BIT(n) ((UINT_32) 1UL << (n))
220 /* bits range: for example BITS(16,23) = 0xFF0000
221 * ==> (BIT(m)-1) = 0x0000FFFF ~(BIT(m)-1) => 0xFFFF0000
222 * ==> (BIT(n+1)-1) = 0x00FFFFFF
224 #define BITS(m,n) (~(BIT(m)-1) & ((BIT(n) - 1) | BIT(n)))
228 /* This macro returns the byte offset of a named field in a known structure
230 _type - structure name,
231 _field - field name of the structure */
233 #define OFFSET_OF(_type, _field) ((UINT_32)&(((_type *)0)->_field))
234 #endif /* OFFSET_OF */
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
245 #define ENTRY_OF(_addrOfField, _type, _field) \
246 ((_type *)((PINT_8)(_addrOfField) - (PINT_8)OFFSET_OF(_type, _field)))
247 #endif /* ENTRY_OF */
250 /* This macro align the input value to the DW boundary.
251 * _value - value need to check
254 #define ALIGN_4(_value) (((_value) + 3) & ~3u)
257 /* This macro check the DW alignment of the input value.
258 * _value - value of address need to check
261 #define IS_ALIGN_4(_value) (((_value) & 0x3) ? FALSE : TRUE)
262 #endif /* IS_ALIGN_4 */
264 #ifndef IS_NOT_ALIGN_4
265 #define IS_NOT_ALIGN_4(_value) (((_value) & 0x3) ? TRUE : FALSE)
266 #endif /* IS_NOT_ALIGN_4 */
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.
272 #ifndef BYTE_TO_DWORD
273 #define BYTE_TO_DWORD(_value) ((_value + 3) >> 2)
274 #endif /* BYTE_TO_DWORD */
276 /* This macro evaluate the input length in unit of Byte.
277 * _value - value in unit of DW, output is in unit of Byte.
279 #ifndef DWORD_TO_BYTE
280 #define DWORD_TO_BYTE(_value) ((_value) << 2)
281 #endif /* DWORD_TO_BYTE */
283 #if 1 // Little-Endian
284 #define CONST_NTOHS(_x) __constant_ntohs(_x)
286 #define CONST_HTONS(_x) __constant_htons(_x)
288 #define NTOHS(_x) ntohs(_x)
290 #define HTONS(_x) htons(_x)
292 #define NTOHL(_x) ntohl(_x)
294 #define HTONL(_x) htonl(_x)
298 #define CONST_NTOHS(_x)
300 #define CONST_HTONS(_x)
308 /*******************************************************************************
309 * F U N C T I O N D E C L A R A T I O N S
310 ********************************************************************************
313 /*******************************************************************************
315 ********************************************************************************
318 #endif /* _GL_TYPEDEF_H */