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
|
/****************************************************************************
** COPYRIGHT (C) 1994-1997 INTEL CORPORATION **
** DEVELOPED FOR MICROSOFT BY INTEL CORP., HILLSBORO, OREGON **
** HTTP://WWW.INTEL.COM/ **
** THIS FILE IS PART OF THE INTEL ETHEREXPRESS PRO/100B(TM) AND **
** ETHEREXPRESS PRO/100+(TM) NDIS 5.0 MINIPORT SAMPLE DRIVER **
****************************************************************************/
/****************************************************************************
Module Name:
macros.h (inlinef.h)
This driver runs on the following hardware:
- 82558 based PCI 10/100Mb ethernet adapters
(aka Intel EtherExpress(TM) PRO Adapters)
Environment:
Kernel Mode - Or whatever is the equivalent on WinNT
*****************************************************************************/
__inline BOOLEAN
WaitScb(
IN PFDO_DATA FdoData
);
//-----------------------------------------------------------------------------
// Procedure: D100IssueScbCommand
//
// Description: This general routine will issue a command to the D100.
//
// Arguments:
// FdoData - ptr to FdoData object instance.
// ScbCommand - The command that is to be issued
// WaitForSCB - A boolean value indicating whether or not a wait for SCB
// must be done before the command is issued to the chip
//
// Returns:
// TRUE if the command was issued to the chip successfully
// FALSE if the command was not issued to the chip
//-----------------------------------------------------------------------------
__inline NTSTATUS
D100IssueScbCommand(
IN PFDO_DATA FdoData,
IN UCHAR ScbCommandLow,
IN BOOLEAN WaitForScb
)
{
if(WaitForScb == TRUE)
{
if(!WaitScb(FdoData))
{
return(STATUS_DEVICE_DATA_ERROR);
}
}
FdoData->CSRAddress->ScbCommandLow = ScbCommandLow;
return(STATUS_SUCCESS);
}
__inline NTSTATUS
MP_GET_STATUS_FROM_FLAGS(
IN PFDO_DATA FdoData
)
{
NTSTATUS Status = STATUS_UNSUCCESSFUL;
if(MP_TEST_FLAG(FdoData, fMP_ADAPTER_RESET_IN_PROGRESS))
{
Status = STATUS_DEVICE_NOT_READY;
}
else if(MP_TEST_FLAG(FdoData, fMP_ADAPTER_HARDWARE_ERROR))
{
Status = STATUS_DEVICE_OFF_LINE;
}
else if(MP_TEST_FLAG(FdoData, fMP_ADAPTER_NO_CABLE))
{
Status = STATUS_DEVICE_NOT_CONNECTED;
}
return Status;
}
__inline VOID
NICDisableInterrupt(
IN PFDO_DATA FdoData
)
{
FdoData->CSRAddress->ScbCommandHigh = SCB_INT_MASK;
}
EVT_WDF_INTERRUPT_SYNCHRONIZE NICEnableInterrupt;
__inline BOOLEAN NICEnableInterrupt(
IN WDFINTERRUPT WdfInterrupt,
IN WDFCONTEXT Context
)
{
PFDO_DATA FdoData = (PFDO_DATA)Context;
UNREFERENCED_PARAMETER(WdfInterrupt);
FdoData->CSRAddress->ScbCommandHigh = 0;
return TRUE;
}
__inline
BOOLEAN
IsPoMgmtSupported(
IN PFDO_DATA FdoData
)
{
if (FdoData->RevsionID >= E100_82559_A_STEP
/*&& FdoData->RevsionID <= E100_82559_C_STEP*/)
{
return TRUE;
}
else
{
return FALSE;
}
}
__inline
USHORT
NICReadPortUShort (
IN USHORT * x
)
{
return READ_PORT_USHORT (x);
}
__inline
VOID
NICWritePortUShort (
IN USHORT * x,
IN USHORT y
)
{
WRITE_PORT_USHORT (x,y);
}
__inline
USHORT
NICReadRegisterUShort (
IN USHORT * x
)
{
return READ_REGISTER_USHORT (x);
}
__inline
VOID
NICWriteRegisterUShort (
IN USHORT * x,
IN USHORT y
)
{
WRITE_REGISTER_USHORT (x,y);
}
// routines.c
BOOLEAN
MdiRead(
IN PFDO_DATA Adapter,
IN ULONG RegAddress,
IN ULONG PhyAddress,
IN BOOLEAN Recoverable,
IN OUT PUSHORT DataValue
);
VOID
MdiWrite(
IN PFDO_DATA FdoData,
IN ULONG RegAddress,
IN ULONG PhyAddress,
IN USHORT DataValue
);
NTSTATUS
D100IssueScbCommand(
IN PFDO_DATA FdoData,
IN UCHAR ScbCommandLow,
IN BOOLEAN WaitForScb
);
MEDIA_STATE
GetMediaState(
IN PFDO_DATA Adapter
);
NTSTATUS
D100SubmitCommandBlockAndWait(
IN PFDO_DATA Adapter
);
VOID
NICIssueFullReset(
PFDO_DATA Adapter
);
VOID
NICIssueSelectiveReset(
PFDO_DATA Adapter
);
VOID
DumpStatsCounters(
IN PFDO_DATA Adapter
);
// physet.c
VOID
ResetPhy(
IN PFDO_DATA FdoData
);
NTSTATUS
PhyDetect(
IN PFDO_DATA FdoData
);
NTSTATUS
ScanAndSetupPhy(
IN PFDO_DATA FdoData
);
VOID
SelectPhy(
IN PFDO_DATA FdoData,
IN UINT SelectPhyAddress,
IN BOOLEAN WaitAutoNeg
);
NTSTATUS
SetupPhy(
IN PFDO_DATA FdoData
);
VOID
FindPhySpeedAndDpx(
IN PFDO_DATA FdoData,
IN UINT PhyId
);
// eeprom.c
USHORT
GetEEpromAddressSize(
IN USHORT Size
);
USHORT
GetEEpromSize(
IN PFDO_DATA FdoData,
IN PUCHAR CSRBaseIoAddress
);
USHORT
ReadEEprom(
IN PFDO_DATA FdoData,
IN PUCHAR CSRBaseIoAddress,
IN USHORT Reg,
IN USHORT AddressSize
);
VOID
ShiftOutBits(
IN PFDO_DATA FdoData,
IN USHORT data,
IN USHORT count,
IN PUCHAR CSRBaseIoAddress
);
USHORT
ShiftInBits(
IN PFDO_DATA FdoData,
IN PUCHAR CSRBaseIoAddress
);
VOID
RaiseClock(
IN PFDO_DATA FdoData,
IN OUT USHORT *x,
IN PUCHAR CSRBaseIoAddress
);
VOID
LowerClock(
IN PFDO_DATA FdoData,
IN OUT USHORT *x,
IN PUCHAR CSRBaseIoAddress
);
VOID
EEpromCleanup(
IN PFDO_DATA FdoData,
IN PUCHAR CSRBaseIoAddress
);
|