2013-05-08 21:45:39 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
|
2014-12-19 06:59:46 +00:00
|
|
|
*
|
2013-05-08 21:45:39 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
#ifndef __BASIC_TYPES_H__
|
|
|
|
#define __BASIC_TYPES_H__
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#include <drv_conf.h>
|
|
|
|
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
#define SUCCESS 0
|
|
|
|
#define FAIL (-1)
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifndef TRUE
|
|
|
|
#define _TRUE 1
|
|
|
|
#else
|
2014-12-19 06:59:46 +00:00
|
|
|
#define _TRUE TRUE
|
2014-12-11 21:15:04 +00:00
|
|
|
#endif
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
#ifndef FALSE
|
2014-12-11 21:15:04 +00:00
|
|
|
#define _FALSE 0
|
|
|
|
#else
|
2014-12-19 06:59:46 +00:00
|
|
|
#define _FALSE FALSE
|
2014-12-11 21:15:04 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#define IN
|
|
|
|
#define OUT
|
|
|
|
#define VOID void
|
|
|
|
#define NDIS_OID uint
|
|
|
|
#define NDIS_STATUS uint
|
|
|
|
|
|
|
|
typedef signed int sint;
|
|
|
|
|
|
|
|
#ifndef PVOID
|
|
|
|
typedef void * PVOID;
|
|
|
|
//#define PVOID (void *)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define UCHAR u8
|
|
|
|
#define USHORT u16
|
|
|
|
#define UINT u32
|
2014-12-19 06:59:46 +00:00
|
|
|
#define ULONG u32
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
typedef void (*proc_t)(void*);
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
typedef __kernel_size_t SIZE_T;
|
2014-12-11 21:15:04 +00:00
|
|
|
typedef __kernel_ssize_t SSIZE_T;
|
|
|
|
#define FIELD_OFFSET(s,field) ((SSIZE_T)&((s*)(0))->field)
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#define MEM_ALIGNMENT_OFFSET (sizeof (SIZE_T))
|
|
|
|
#define MEM_ALIGNMENT_PADDING (sizeof(SIZE_T) - 1)
|
|
|
|
|
|
|
|
#define SIZE_PTR SIZE_T
|
|
|
|
#define SSIZE_PTR SSIZE_T
|
|
|
|
|
|
|
|
//port from fw by thomas
|
|
|
|
// TODO: Belows are Sync from SD7-Driver. It is necessary to check correctness
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Call endian free function when
|
|
|
|
* 1. Read/write packet content.
|
|
|
|
* 2. Before write integer to IO.
|
|
|
|
* 3. After read integer from IO.
|
|
|
|
*/
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
//
|
|
|
|
// Byte Swapping routine.
|
|
|
|
//
|
2014-12-19 06:59:46 +00:00
|
|
|
#define EF1Byte
|
|
|
|
#define EF2Byte le16_to_cpu
|
2014-12-11 21:15:04 +00:00
|
|
|
#define EF4Byte le32_to_cpu
|
|
|
|
|
|
|
|
//
|
|
|
|
// Read LE format data from memory
|
|
|
|
//
|
|
|
|
#define ReadEF1Byte(_ptr) EF1Byte(*((u8 *)(_ptr)))
|
|
|
|
#define ReadEF2Byte(_ptr) EF2Byte(*((u16 *)(_ptr)))
|
|
|
|
#define ReadEF4Byte(_ptr) EF4Byte(*((u32 *)(_ptr)))
|
|
|
|
|
|
|
|
//
|
|
|
|
// Write LE data to memory
|
|
|
|
//
|
|
|
|
#define WriteEF1Byte(_ptr, _val) (*((u8 *)(_ptr)))=EF1Byte(_val)
|
|
|
|
#define WriteEF2Byte(_ptr, _val) (*((u16 *)(_ptr)))=EF2Byte(_val)
|
2014-12-19 06:59:46 +00:00
|
|
|
#define WriteEF4Byte(_ptr, _val) (*((u32 *)(_ptr)))=EF4Byte(_val)
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Example:
|
|
|
|
// BIT_LEN_MASK_32(0) => 0x00000000
|
|
|
|
// BIT_LEN_MASK_32(1) => 0x00000001
|
|
|
|
// BIT_LEN_MASK_32(2) => 0x00000003
|
|
|
|
// BIT_LEN_MASK_32(32) => 0xFFFFFFFF
|
|
|
|
//
|
|
|
|
#define BIT_LEN_MASK_32(__BitLen) \
|
|
|
|
(0xFFFFFFFF >> (32 - (__BitLen)))
|
|
|
|
//
|
|
|
|
// Example:
|
|
|
|
// BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003
|
|
|
|
// BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000
|
|
|
|
//
|
|
|
|
#define BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) \
|
2014-12-19 06:59:46 +00:00
|
|
|
(BIT_LEN_MASK_32(__BitLen) << (__BitOffset))
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Description:
|
|
|
|
// Return 4-byte value in host byte ordering from
|
|
|
|
// 4-byte pointer in litten-endian system.
|
|
|
|
//
|
|
|
|
#define LE_P4BYTE_TO_HOST_4BYTE(__pStart) \
|
|
|
|
(EF4Byte(*((u32 *)(__pStart))))
|
|
|
|
|
|
|
|
//
|
|
|
|
// Description:
|
|
|
|
// Translate subfield (continuous bits in little-endian) of 4-byte value in litten byte to
|
|
|
|
// 4-byte value in host byte ordering.
|
|
|
|
//
|
|
|
|
#define LE_BITS_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
|
|
|
|
( \
|
|
|
|
( LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset) ) \
|
|
|
|
& \
|
|
|
|
BIT_LEN_MASK_32(__BitLen) \
|
|
|
|
)
|
|
|
|
|
|
|
|
//
|
|
|
|
// Description:
|
2014-12-19 06:59:46 +00:00
|
|
|
// Mask subfield (continuous bits in little-endian) of 4-byte value in litten byte oredering
|
2014-12-11 21:15:04 +00:00
|
|
|
// and return the result in 4-byte value in host byte ordering.
|
|
|
|
//
|
|
|
|
#define LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
|
2013-05-08 21:45:39 +00:00
|
|
|
( \
|
2014-12-11 21:15:04 +00:00
|
|
|
LE_P4BYTE_TO_HOST_4BYTE(__pStart) \
|
|
|
|
& \
|
|
|
|
( ~BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) ) \
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Description:
|
2014-12-19 06:59:46 +00:00
|
|
|
// Set subfield of little-endian 4-byte value to specified value.
|
2014-12-11 21:15:04 +00:00
|
|
|
//
|
|
|
|
#define SET_BITS_TO_LE_4BYTE(__pStart, __BitOffset, __BitLen, __Value) \
|
|
|
|
*((u32 *)(__pStart)) = \
|
|
|
|
EF4Byte( \
|
|
|
|
LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
|
|
|
|
| \
|
|
|
|
( (((u32)__Value) & BIT_LEN_MASK_32(__BitLen)) << (__BitOffset) ) \
|
|
|
|
);
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#define BIT_LEN_MASK_16(__BitLen) \
|
|
|
|
(0xFFFF >> (16 - (__BitLen)))
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#define BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) \
|
|
|
|
(BIT_LEN_MASK_16(__BitLen) << (__BitOffset))
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#define LE_P2BYTE_TO_HOST_2BYTE(__pStart) \
|
|
|
|
(EF2Byte(*((u16 *)(__pStart))))
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#define LE_BITS_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
|
2013-05-08 21:45:39 +00:00
|
|
|
( \
|
2014-12-11 21:15:04 +00:00
|
|
|
( LE_P2BYTE_TO_HOST_2BYTE(__pStart) >> (__BitOffset) ) \
|
|
|
|
& \
|
|
|
|
BIT_LEN_MASK_16(__BitLen) \
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#define LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
|
2013-05-08 21:45:39 +00:00
|
|
|
( \
|
2014-12-11 21:15:04 +00:00
|
|
|
LE_P2BYTE_TO_HOST_2BYTE(__pStart) \
|
|
|
|
& \
|
|
|
|
( ~BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) ) \
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#define SET_BITS_TO_LE_2BYTE(__pStart, __BitOffset, __BitLen, __Value) \
|
|
|
|
*((u16 *)(__pStart)) = \
|
|
|
|
EF2Byte( \
|
|
|
|
LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
|
|
|
|
| \
|
|
|
|
( (((u16)__Value) & BIT_LEN_MASK_16(__BitLen)) << (__BitOffset) ) \
|
|
|
|
);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#define BIT_LEN_MASK_8(__BitLen) \
|
|
|
|
(0xFF >> (8 - (__BitLen)))
|
|
|
|
|
|
|
|
#define BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) \
|
|
|
|
(BIT_LEN_MASK_8(__BitLen) << (__BitOffset))
|
|
|
|
|
|
|
|
#define LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
|
|
|
|
(EF1Byte(*((u8 *)(__pStart))))
|
|
|
|
|
|
|
|
#define LE_BITS_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
|
2013-05-08 21:45:39 +00:00
|
|
|
( \
|
2014-12-11 21:15:04 +00:00
|
|
|
( LE_P1BYTE_TO_HOST_1BYTE(__pStart) >> (__BitOffset) ) \
|
|
|
|
& \
|
|
|
|
BIT_LEN_MASK_8(__BitLen) \
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
#define LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
|
2013-05-08 21:45:39 +00:00
|
|
|
( \
|
2014-12-11 21:15:04 +00:00
|
|
|
LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
|
|
|
|
& \
|
|
|
|
( ~BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) ) \
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
#define SET_BITS_TO_LE_1BYTE(__pStart, __BitOffset, __BitLen, __Value) \
|
|
|
|
*((u8 *)(__pStart)) = \
|
|
|
|
EF1Byte( \
|
|
|
|
LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
|
|
|
|
| \
|
|
|
|
( (((u8)__Value) & BIT_LEN_MASK_8(__BitLen)) << (__BitOffset) ) \
|
|
|
|
);
|
|
|
|
|
|
|
|
//pclint
|
|
|
|
#define LE_BITS_CLEARED_TO_1BYTE_8BIT(__pStart, __BitOffset, __BitLen) \
|
2013-05-08 21:45:39 +00:00
|
|
|
( \
|
2014-12-11 21:15:04 +00:00
|
|
|
LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
//pclint
|
|
|
|
#define SET_BITS_TO_LE_1BYTE_8BIT(__pStart, __BitOffset, __BitLen, __Value) \
|
|
|
|
{ \
|
|
|
|
*((pu1Byte)(__pStart)) = \
|
|
|
|
EF1Byte( \
|
|
|
|
LE_BITS_CLEARED_TO_1BYTE_8BIT(__pStart, __BitOffset, __BitLen) \
|
|
|
|
| \
|
|
|
|
((u1Byte)__Value) \
|
|
|
|
); \
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the N-bytes aligment offset from the current length
|
|
|
|
#define N_BYTE_ALIGMENT(__Value, __Aligment) ((__Aligment == 1) ? (__Value) : (((__Value + __Aligment - 1) / __Aligment) * __Aligment))
|
2013-08-14 02:01:38 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
typedef unsigned char BOOLEAN,*PBOOLEAN;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#endif //__BASIC_TYPES_H__
|