1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
|
/*++
Copyright (c) 1990 Microsoft Corporation
Module Name:
software.h
Abstract:
This is the software definitions header file for the Ungermann Bass
Ethernet Controller.
This file contains definitions and macros used in
Author:
Sanjeev Katariya (sanjeevk) 03-05-92
Environment:
Kernel Mode Operating Systems : NT and other lesser OS's(dos)
Revision History:
Brian Lieuallen BrianLie 12/15/93
Made it a mini-port
--*/
// DEFINES
//
// Default software settings for ANY Ungermann Bass card
// supported by this driver
//
#define DEFAULT_MULTICAST_SIZE 16
#define DEFAULT_MAXIMUM_REQUESTS 4
#define DEFAULT_MAXIMUM_TRANSMITS 6
#define DEFAULT_RECEIVE_BUFFER_SIZE 512
#define DEFAULT_RECEIVE_BUFFERS 64
#define UBNEI_NDIS_MAJOR_VERSION 3
#define UBNEI_NDIS_MINOR_VERSION 0
#define UBNEI_ETHERNET_HEADER_SIZE 14
//
// Default software settings for specific Ungermann Bass cards
//
//#define DEFAULT_GPCNIU_MAXMCAST_SIZE 16
#define UBNEI_MOVE_MEM(dest,src,size) NdisMoveMemory(dest,src,size)
#define UBNEI_MOVE_SHARED_RAM_TO_MEM(dest,src,size) NdisMoveFromMappedMemory(dest,src,size)
#define UBNEI_MOVE_MEM_TO_SHARED_RAM(dest,src,size) NdisMoveToMappedMemory(dest,src,size)
#define UBNEI_MOVE_UCHAR_TO_SHARED_RAM(dest, src) NdisWriteRegisterUchar((PUCHAR)dest, (UCHAR)(src))
//#define UBNEI_MOVE_USHORT_TO_SHARED_RAM(dest, src) NdisWriteRegisterUshort((PUSHORT)dest, (USHORT)(src))
//#define UBNEI_MOVE_DWORD_TO_SHARED_RAM(dest, src) NdisWriteRegisterUlong((PULONG)dest, (ULONG)(src))
#define UBNEI_MOVE_SHARED_RAM_TO_UCHAR(dest, src) NdisReadRegisterUchar((PUCHAR)src, (PUCHAR)(dest))
#define UBNEI_MOVE_SHARED_RAM_TO_USHORT(dest, src) NdisReadRegisterUshort((PUSHORT)src, (PUSHORT)(dest))
#define UBNEI_MOVE_SHARED_RAM_TO_DWORD(dest, src) NdisReadRegisterUlong((PULONG)src, (PULONG)(dest))
#if 0
#define UBNEI_MOVE_USHORT_TO_SHARED_RAM(dest, src) { \
\
if ((ULONG)(dest) & 1) { \
DbgPrint("UBNEI: Unaligned word write to shared ram %08x\n",dest); \
DbgBreakPoint(); \
} \
NdisWriteRegisterUshort((PUSHORT)(dest), (USHORT)(src)); \
}
#define UBNEI_MOVE_DWORD_TO_SHARED_RAM(dest, src) { \
\
if ((ULONG)(dest) & 3) { \
DbgPrint("UBNEI: Unaligned dword write to shared ram %08x\n",dest); \
DbgBreakPoint(); \
} \
\
NdisWriteRegisterUlong((PULONG)(dest), (ULONG)(src)); \
}
#else
#define UBNEI_MOVE_USHORT_TO_SHARED_RAM(dest, src) NdisWriteRegisterUshort((PUSHORT)dest, (USHORT)(src))
#define UBNEI_MOVE_DWORD_TO_SHARED_RAM(dest, src) NdisWriteRegisterUlong((PULONG)dest, (ULONG)(src))
#endif
//
// Macros
//
#define MACRO_ASSERTALL() { \
ASSERT ( sizeof(CHAR) = 1 ); \
ASSERT ( sizeof(UCHAR) = 1 ); \
ASSERT ( sizeof(USHORT) = 2 ); \
ASSERT ( sizeof(UINT) = 4 ); \
ASSERT ( sizeof(ULONG) = 4 ); \
}
typedef struct _PACKET_QUEUE {
PNDIS_PACKET QIn;
PNDIS_PACKET QOut;
} PACKET_QUEUE, *PPACKET_QUEUE;
typedef struct _SYNC_CONTEXT {
struct _UBNEI_ADAPTER * pAdapter;
UCHAR CurrentMapRegister;
UCHAR NewMapRegister;
} SYNC_CONTEXT, * PSYNC_CONTEXT;
typedef struct _SEND_SYNC_CONTEXT {
struct _UBNEI_ADAPTER * pAdapter;
PVOID SendBuffer;
UINT PacketLength;
UCHAR TbdIndex;
} SEND_SYNC_CONTEXT, *PSEND_SYNC_CONTEXT;
typedef
VOID
(*NIU_GEN_REQ_DPC)(
IN NDIS_STATUS status,
IN PVOID pContext
);
typedef struct _NIUREQUEST {
PVOID pContext;
NIU_GEN_REQ_DPC pDPCFunc;
PUCHAR AddressList;
UINT ListSize;
RRBE rrbe;
} NIUREQUEST, *PNIUREQUEST;
//
// One of these structures per adapter registered.
//
typedef struct _UBNEI_ADAPTER {
SYNC_CONTEXT MapRegSync;
//
// Window mapping values used to map in various pages
//
UCHAR InitWindow_Page;
UCHAR ReceiveDataWindow_Page;
UCHAR DataWindow_Page;
UCHAR CodeWindow_Page;
//
// Ports
//
PVOID InterruptMaskPort;
PVOID MapPort;
PVOID InterruptStatusPort;
PVOID SetWindowBasePort;
//
// NDIS wrapper information.
//
NDIS_HANDLE NdisAdapterHandle; // returned from NdisRegisterAdapter
//
// NDIS Interrupt information
//
NDIS_MINIPORT_INTERRUPT NdisInterrupt;
NDIS_INTERRUPT_MODE InterruptMode;
volatile UINT uInterruptCount;
BOOLEAN InInit;
volatile BOOLEAN WaitingForDPC;
BOOLEAN DpcHasRun;
BOOLEAN WaitingForXmitInterrupt;
//
// Registry information
//
PVOID TranslatedIoBase;
UINT IoPortBaseAddr;
UINT MemBaseAddr;
UINT MaxMultiCastTableSize;
UINT MaxRequests;
UINT MaxTransmits;
UINT ReceiveBuffers;
UINT ReceiveBufSize;
UINT AdapterType;
BOOLEAN Diagnostics;
CHAR IrqLevel;
ULONG WindowSize;
ULONG WindowMask;
ULONG NotWindowMask;
UCHAR StationAddress[ETH_LENGTH_OF_ADDRESS]; // filled in at init time
UCHAR PermanentAddress[ETH_LENGTH_OF_ADDRESS]; // filled in at init time
//
// Statistics used by Set/QueryInformation.
//
UINT TransmitBufferSpace;
UINT ReceiveBufferSpace;
UINT TransmitBlockSize;
UINT ReceiveBlockSize;
ULONG FramesXmitGood; // Good Frames Transmitted
ULONG FramesRcvGood; // Good Frames Received
ULONG FramesXmitBad; // Bad Frames Transmitted
ULONG FramesXmitOneCollision; // Frames Transmitted with one collision
ULONG FramesXmitManyCollisions; // Frames Transmitted with > 1 collision
ULONG FrameAlignmentErrors; // FAE errors counted
ULONG CrcErrors; // CRC errors counted
ULONG MissedPackets; // missed packet counted
//
// Look Ahead information.
//
ULONG MaxLookAhead;
//
// Adapter specific Infomation
//
USHORT PacketFilter;
//
// Timer functions/objects
//
UINT WakeUpState;
//
// Memory mapped pointers
//
PVOID pCardRam;
PHIGHNIUDATA pDataWindow;
PNIU_CONTROL_AREA pNIU_Control;
//
// NIU general requests
//
USHORT NIU_Requests_Pending;
USHORT NIU_Request_Head,NIU_Request_Tail,NIU_Next_Request;
NIUREQUEST NiuRequest[DEFAULT_MAXIMUM_REQUESTS];
//
// Recieve stuff
//
PRBD pIndicatedRBD;
UINT PacketLen;
PUCHAR FirstCardBuffer;
//
// Init stuff
//
} UBNEI_ADAPTER, * PUBNEI_ADAPTER;
//
// NIU general request
//
#define NIU_Cmd_Set_Multicast 8
#define NIU_Cmd_Set_Filter 7
#define NIU_Cmd_Open 4
#define NIU_Cmd_Close 5
#define NIU_Cmd_Reset 6
#define NIU_SET_MULTICAST_LIST(_pAdapter,CallBack,_List,_Size) \
NIU_General_Request3( \
CallBack, \
(PVOID)_pAdapter, \
8, \
_Size, \
_List)
#define NIU_SET_FILTER(_pAdapter,CallBack,Filter) \
NIU_General_Request3( \
CallBack, \
(PVOID)_pAdapter, \
7, \
Filter, \
NULL)
#define NIU_OPEN_ADAPTER(_pAdapter,CallBack) \
NIU_General_Request3( \
CallBack, \
(PVOID)_pAdapter, \
4, \
0, \
NULL)
#define NIU_CLOSE_ADAPTER(_pAdapter,CallBack) \
NIU_General_Request3( \
CallBack, \
(PVOID)_pAdapter, \
5, \
0, \
NULL)
#define NIU_RESET_ADAPTER(_pAdapter,CallBack) \
NIU_General_Request3( \
CallBack, \
(PVOID)_pAdapter, \
6, \
0, \
NULL) \
#define NIU_SET_STATION_ADDRESS(_pAdapter,CallBack,Address)\
NIU_General_Request3( \
CallBack, \
(PVOID)_pAdapter, \
3, \
0, \
Address) \
#define INTERRUPT_ENABLED 0x02
#define INTERRUPT_DISABLED 0x00
#define RESET_SET 0x01
#define RESET_CLEAR 0x00
|