1 /***************************************************************************\
3 |* Copyright 2001-2004 NVIDIA Corporation. All Rights Reserved. *|
5 |* THE INFORMATION CONTAINED HEREIN IS PROPRIETARY AND CONFIDENTIAL *|
6 |* TO NVIDIA, CORPORATION. USE, REPRODUCTION OR DISCLOSURE TO ANY *|
7 |* THIRD PARTY IS SUBJECT TO WRITTEN PRE-APPROVAL BY NVIDIA, CORP. *|
9 |* THE INFORMATION CONTAINED HEREIN IS PROVIDED "AS IS" WITHOUT *|
10 |* EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING ALL IMPLIED *|
11 |* WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A *|
12 |* PARTICULAR PURPOSE. *|
14 \***************************************************************************/
26 This file contains the base type definitions used by the networking driver.
31 SNo. Date Author Description
32 1. 2/7/2000 AJha Created
64 // Don't use as these are going to be deleted soon. Use NV_ instead
69 typedef unsigned char UCHAR;
70 typedef UCHAR * PUCHAR;
71 typedef unsigned short USHORT;
72 typedef USHORT * PUSHORT;
74 typedef unsigned int ULONG;
76 typedef unsigned long ULONG;
78 typedef ULONG * PULONG;
84 typedef unsigned int UINT;
85 typedef unsigned int *PUINT;
92 typedef NV_VOID *PNV_VOID;
94 typedef unsigned long NV_BOOLEAN, *PNV_BOOLEAN;
96 typedef unsigned char NV_UINT8, *PNV_UINT8;
97 typedef unsigned short NV_UINT16, *PNV_UINT16;
99 typedef unsigned int NV_UINT32, *PNV_UINT32;
101 typedef unsigned long NV_UINT32, *PNV_UINT32;
104 typedef signed char NV_SINT8, *PNV_SINT8;
105 typedef signed short NV_SINT16, *PNV_SINT16;
106 typedef signed long NV_SINT32, *PNV_SINT32;
111 typedef unsigned long long NV_UINT64, *PNV_UINT64;
112 typedef signed long long NV_SINT64, *PNV_SINT64;
115 #if _MSC_VER >= 1200 // MSVC 6.0 onwards
116 typedef unsigned __int64 NV_UINT64, *PNV_UINT64;
117 typedef signed __int64 NV_SINT64, *PNV_SINT64;
119 typedef unsigned long NV_UINT64, *PNV_UINT64;
120 typedef signed long NV_SINT64, *PNV_SINT64;
126 typedef unsigned int NV_UINT;
127 typedef signed int NV_INT;
132 typedef unsigned long long NV_UINT;
133 typedef signed long long NV_INT;
137 typedef unsigned __int64 NV_UINT;
138 typedef signed __int64 NV_INT;
145 // Floating point definitions
147 typedef float NV_REAL32; // 4-byte floating point
148 typedef double NV_REAL64; // 8-byte floating point
155 #define NV_BIT(bitpos) (1 << (bitpos))
158 // Sets the specified bit position (0..31).
159 // Parameter bits can be 1 byte to 4 bytes, but the caller needs to make sure bitpos fits into it.
163 #define NV_BIT_SET(bits, bitpos) ((bits) |= (NV_BIT(bitpos)))
166 // Clears the specified bit position (0..31)
167 // Parameter bits can be 1 byte to 4 bytes, but the caller needs to make sure bitpos fits into it.
169 // NV_BIT_CLEAR(x, 1)
171 #define NV_BIT_CLEAR(bits, bitpos) ((bits) &= (~NV_BIT(bitpos)))
174 // Gets the bit at the specified bit position (0..31)
175 // Parameter bits can be 1 byte to 4 bytes, but the caller needs to make sure bitpos fits into it.
176 // Result is either 1 or 0.
180 #define NV_BIT_GET(bits, bitpos) (((bits) >> (bitpos)) & 0x0001)
184 // Gets the value from a 32 bit ULONG at specified bit position.
185 // Parameter bits needs to be 4 bytes long.
186 // Ex. ul32 = 0xFEDCBA98
187 // ulVal = NV_BIT_GETVALUE(ul32, 3, 0) : Gets value from Bit position 3 to 0
188 // Result : ulVal = 8
189 #define NV_BIT_GETVALUE(ulOrigValue, bitposHi, bitposLow) (((ulOrigValue) >> (bitposLow)) & (~(0xFFFFFFFF << ((bitposHi) - (bitposLow) +1))))
192 // Set a value in a 32 bit ULONG at a specific bit position.
193 // Parameter bits needs to be 4 bytes long.
194 // Ex. ul32 = 0xFEDCBA98
195 // NV_BIT_SETVALUE(ul32, 0xF, 3, 0) : Sets value at Bit position 3 to 0
196 // Result : ul32 becomes 0xFEDCBA9F
197 #define NV_BIT_SETVALUE(ulOrigValue, ulWindowValue, bitposHi, bitposLow) \
198 ((ulOrigValue) = ((((ulOrigValue) & (~ ((0xFFFFFFFF >> (31 - (bitposHi))) & (0xFFFFFFFF << (bitposLow))))) | ((ulWindowValue) << (bitposLow)))))
201 #define NV_BYTE(ulus, bytepos) ((ulus >> (8 * (bytepos))) & 0xFF)
204 #define SWAP_U16(us) ((((us) & 0x00FF) << 8) | \
205 (((us) & 0xFF00) >> 8))
207 #define SWAP_U32(ul) ((((ul) & 0x000000FF) << 24) | \
208 (((ul) & 0x0000FF00) << 8) | \
209 (((ul) & 0x00FF0000) >> 8) | \
210 (((ul) & 0xFF000000) >> 24))
212 #define NV_FIELD_OFFSET(TYPE, FIELD) ((NV_UINT32)((NV_UINT64)&((TYPE *)0)->FIELD))
214 #define ADDRESS_OFFSET(structure, member) ((NV_UINT32) ((NV_UINT8 *) &(structure).member \
215 - (NV_UINT8 *) &(structure)))
218 #define NV_MIN(a, b) ((a < b) ? a : b)
219 #define NV_MAX(a, b) ((a > b) ? a : b)
222 #define PNV_VOID_TO_NV_UINT64(x) ((NV_UINT64)(x))
223 #define PNV_VOID_TO_NV_UINT32(x) ((NV_UINT32)(NV_UINT64)(x))
224 #define NV_UINT64_TO_PNV_VOID(x) ((PNV_VOID)(x))
225 #define NV_UINT32_TO_PNV_VOID(x) ((PNV_VOID)(NV_UINT64)(x))
227 #define PNV_VOID_TO_NV_UINT64(x) ((NV_UINT64)(NV_UINT32)(x))
228 #define PNV_VOID_TO_NV_UINT32(x) ((NV_UINT32)(x))
229 #define NV_UINT64_TO_PNV_VOID(x) ((PNV_VOID)(NV_UINT32)(x))
230 #define NV_UINT32_TO_PNV_VOID(x) ((PNV_VOID)(x))
233 #define NV_MAKE_TAG32(s) (((NV_UINT32)((s)[3]) << 24) | ((NV_UINT32)((s)[2]) << 16) | \
234 ((NV_UINT32)((s)[1]) << 8) | ((NV_UINT32)((s)[0])))
236 #define NV_MAKE_TAG64(s) (((NV_UINT64)((s)[7]) << 56) | ((NV_UINT64)((s)[6]) << 48) | \
237 ((NV_UINT64)((s)[5]) << 40) | ((NV_UINT64)((s)[4]) << 32) | \
238 ((NV_UINT64)((s)[3]) << 24) | ((NV_UINT64)((s)[2]) << 16) | \
239 ((NV_UINT64)((s)[1]) << 8) | ((NV_UINT64)((s)[0])))
241 typedef union _NVLARGE_INTEGER {
244 // NO UNNAMED UNIONS ALLOWED !@
258 } NVLARGE_INTEGER, *PNVLARGE_INTEGER;
262 typedef unsigned short NV_WCHAR;
264 typedef unsigned long NV_WCHAR;
267 typedef NV_WCHAR *PNV_WSTR;
270 #if !defined(NV_API_CALL)
271 #if defined (__i386__)
272 #define NV_API_CALL __attribute__ ((regparm(0)))
281 #endif // _BASETYPE_H_