ReactOS 0.4.16-dev-1204-gb627a42
pcnet.h File Reference
#include <ndis.h>
#include "pci.h"
#include "pcnethw.h"
Include dependency graph for pcnet.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _ADAPTER_STATS
 
struct  _ADAPTER
 

Macros

#define NUMBER_OF_BUFFERS   0x20
 
#define LOG_NUMBER_OF_BUFFERS   5 /* log2(NUMBER_OF_BUFFERS) */
 
#define BUFFER_SIZE   0x600
 
#define MAX_MULTICAST_ADDRESSES   32
 
#define MEDIA_DETECTION_INTERVAL   5000
 
#define RESET_IN_PROGRESS   0x1
 
#define INTERRUPT_LIMIT   10
 
#define PCNET_TAG   'tNcP'
 

Typedefs

typedef struct _ADAPTER_STATS ADAPTER_STATS
 
typedef struct _ADAPTER_STATSPADAPTER_STATS
 
typedef struct _ADAPTER ADAPTER
 
typedef struct _ADAPTERPADAPTER
 

Functions

NDIS_STATUS NTAPI MiniportQueryInformation (IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, IN ULONG InformationBufferLength, OUT PULONG BytesWritten, OUT PULONG BytesNeeded)
 
NDIS_STATUS NTAPI MiniportSetInformation (IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, IN ULONG InformationBufferLength, OUT PULONG BytesRead, OUT PULONG BytesNeeded)
 
NDIS_STATUS NTAPI MiSetMulticast (PADAPTER Adapter, UCHAR *Addresses, UINT AddressCount)
 
NDIS_MEDIA_STATE NTAPI MiGetMediaState (PADAPTER Adapter)
 
UINT NTAPI MiGetMediaSpeed (PADAPTER Adapter)
 
BOOLEAN NTAPI MiGetMediaDuplex (PADAPTER Adapter)
 

Macro Definition Documentation

◆ BUFFER_SIZE

#define BUFFER_SIZE   0x600

Definition at line 154 of file pcnet.h.

◆ INTERRUPT_LIMIT

#define INTERRUPT_LIMIT   10

Definition at line 162 of file pcnet.h.

◆ LOG_NUMBER_OF_BUFFERS

#define LOG_NUMBER_OF_BUFFERS   5 /* log2(NUMBER_OF_BUFFERS) */

Definition at line 153 of file pcnet.h.

◆ MAX_MULTICAST_ADDRESSES

#define MAX_MULTICAST_ADDRESSES   32

Definition at line 155 of file pcnet.h.

◆ MEDIA_DETECTION_INTERVAL

#define MEDIA_DETECTION_INTERVAL   5000

Definition at line 156 of file pcnet.h.

◆ NUMBER_OF_BUFFERS

#define NUMBER_OF_BUFFERS   0x20

Definition at line 152 of file pcnet.h.

◆ PCNET_TAG

#define PCNET_TAG   'tNcP'

Definition at line 165 of file pcnet.h.

◆ RESET_IN_PROGRESS

#define RESET_IN_PROGRESS   0x1

Definition at line 159 of file pcnet.h.

Typedef Documentation

◆ ADAPTER

◆ ADAPTER_STATS

◆ PADAPTER

◆ PADAPTER_STATS

Function Documentation

◆ MiGetMediaDuplex()

BOOLEAN NTAPI MiGetMediaDuplex ( PADAPTER  Adapter)

Definition at line 1285 of file pcnet.c.

1286{
1287 ULONG Data;
1288
1291
1292 return (Data & BCR5_LEDOUT) != 0;
1293}
#define NdisRawReadPortUshort(Port, Data)
Definition: ndis.h:4191
#define NdisRawWritePortUshort(Port, Data)
Definition: ndis.h:4248
#define BCR5
Definition: pcnethw.h:140
#define RAP
Definition: pcnethw.h:48
#define BDP
Definition: pcnethw.h:49
#define BCR5_LEDOUT
Definition: pcnethw.h:285
ULONG_PTR PortOffset
Definition: pcnet.h:65
uint32_t ULONG
Definition: typedefs.h:59

Referenced by MiInitChip(), and MiSyncMediaDetection().

◆ MiGetMediaSpeed()

UINT NTAPI MiGetMediaSpeed ( PADAPTER  Adapter)

Definition at line 1297 of file pcnet.c.

1298{
1299 ULONG Data;
1300
1303
1304 return Data & BCR6_LEDOUT ? 100 : 10;
1305}
#define BCR6
Definition: pcnethw.h:141
#define BCR6_LEDOUT
Definition: pcnethw.h:301

Referenced by MiInitChip(), and MiSyncMediaDetection().

◆ MiGetMediaState()

NDIS_MEDIA_STATE NTAPI MiGetMediaState ( PADAPTER  Adapter)

Definition at line 1309 of file pcnet.c.

1318{
1319 ULONG Data;
1323}
@ NdisMediaStateConnected
Definition: ntddndis.h:470
@ NdisMediaStateDisconnected
Definition: ntddndis.h:471
#define BCR4_LEDOUT
Definition: pcnethw.h:269
#define BCR4
Definition: pcnethw.h:139

Referenced by MiInitChip(), and MiSyncMediaDetection().

◆ MiniportQueryInformation()

NDIS_STATUS NTAPI MiniportQueryInformation ( IN NDIS_HANDLE  MiniportAdapterContext,
IN NDIS_OID  Oid,
IN PVOID  InformationBuffer,
IN ULONG  InformationBufferLength,
OUT PULONG  BytesWritten,
OUT PULONG  BytesNeeded 
)

Definition at line 74 of file info.c.

81{
82 PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
83 ULONG copyLength;
84 PVOID copySource;
86 union _GENERIC_INFORMATION
87 {
90 ULONG64 Ulong64;
91 NDIS_MEDIUM Medium;
92 NDIS_PNP_CAPABILITIES PmCapabilities;
93 } GenericInfo;
94
96 copySource = &GenericInfo;
97 copyLength = sizeof(ULONG);
98
99 switch (Oid)
100 {
102 copySource = (PVOID)&SupportedOidList;
103 copyLength = sizeof(SupportedOidList);
104 break;
105
107 GenericInfo.Ulong = Adapter->PacketFilter;
108 break;
109
112 GenericInfo.Ulong = (ULONG)NdisHardwareStatusReady; //FIXME
113 break;
114
117 {
118 GenericInfo.Medium = NdisMedium802_3;
119 copyLength = sizeof(NDIS_MEDIUM);
120 break;
121 }
122
128 GenericInfo.Ulong = MAXIMUM_FRAME_SIZE - sizeof(ETH_HEADER);
129 break;
130
132 copySource = Adapter->MulticastList;
133 copyLength = Adapter->MulticastListSize * IEEE_802_ADDR_LENGTH;
134 break;
135
137 GenericInfo.Ulong = MAXIMUM_MULTICAST_ADDRESSES;
138 break;
139
141 GenericInfo.Ulong = Adapter->LinkSpeedMbps * 10000;
142 break;
143
145 GenericInfo.Ulong = MAXIMUM_FRAME_SIZE;
146 break;
147
149 GenericInfo.Ulong = RECEIVE_BUFFER_SIZE;
150 break;
151
153 /* The 3 bytes of the MAC address is the vendor ID */
154 GenericInfo.Ulong = 0;
155 GenericInfo.Ulong |= (Adapter->PermanentMacAddress[0] << 16);
156 GenericInfo.Ulong |= (Adapter->PermanentMacAddress[1] << 8);
157 GenericInfo.Ulong |= (Adapter->PermanentMacAddress[2] & 0xFF);
158 break;
159
161 {
162 static UCHAR vendorDesc[] = "ReactOS Team";
163 copySource = vendorDesc;
164 copyLength = sizeof(vendorDesc);
165 break;
166 }
167
169 GenericInfo.Ulong = DRIVER_VERSION;
170 break;
171
173 {
174 copyLength = sizeof(USHORT);
175 GenericInfo.Ushort = (NDIS_MINIPORT_MAJOR_VERSION << 8) + NDIS_MINIPORT_MINOR_VERSION;
176 break;
177 }
178
180 GenericInfo.Ulong = MAXIMUM_FRAME_SIZE;
181 break;
182
184 GenericInfo.Ulong = 1;
185 break;
186
188 GenericInfo.Ulong = NDIS_MAC_OPTION_RECEIVE_SERIALIZED |
192 break;
193
195 GenericInfo.Ulong = Adapter->MediaState;
196 break;
197
199 copySource = Adapter->MulticastList[0].MacAddress;
200 copyLength = IEEE_802_ADDR_LENGTH;
201 break;
202
204 copySource = Adapter->PermanentMacAddress;
205 copyLength = IEEE_802_ADDR_LENGTH;
206 break;
207
208 case OID_GEN_XMIT_OK:
209 case OID_GEN_RCV_OK:
213 {
214 GenericInfo.Ulong64 = NICQueryStatisticCounter(Adapter, Oid);
215
216 *BytesNeeded = sizeof(ULONG64);
217 if (InformationBufferLength >= sizeof(ULONG64))
218 {
219 *BytesWritten = sizeof(ULONG64);
220 NdisMoveMemory(InformationBuffer, copySource, sizeof(ULONG64));
221 }
222 else if (InformationBufferLength >= sizeof(ULONG))
223 {
224 *BytesWritten = sizeof(ULONG);
225 NdisMoveMemory(InformationBuffer, copySource, sizeof(ULONG));
226 }
227 else
228 {
229 *BytesWritten = 0;
231 }
232 return NDIS_STATUS_SUCCESS;
233 }
234
236 {
237 copyLength = sizeof(NDIS_PNP_CAPABILITIES);
238
239 status = NICFillPowerManagementCapabilities(Adapter, &GenericInfo.PmCapabilities);
240 break;
241 }
242
244 {
245 GenericInfo.Ulong = NdisPhysicalMedium802_3;
246 break;
247 }
248
249 default:
250 NDIS_DbgPrint(MIN_TRACE, ("Unknown OID 0x%x(%s)\n", Oid, Oid2Str(Oid)));
252 break;
253 }
254
256 {
257 if (copyLength > InformationBufferLength)
258 {
259 *BytesNeeded = copyLength;
260 *BytesWritten = 0;
262 }
263 else
264 {
265 NdisMoveMemory(InformationBuffer, copySource, copyLength);
266 *BytesWritten = copyLength;
267 *BytesNeeded = copyLength;
268 }
269 }
270 else
271 {
272 *BytesWritten = 0;
273 *BytesNeeded = 0;
274 }
275
276 NDIS_DbgPrint(MAX_TRACE, ("Query OID 0x%x(%s): Completed with status 0x%x (%d, %d)\n",
277 Oid, Oid2Str(Oid), status, *BytesWritten, *BytesNeeded));
278 return status;
279}
#define MIN_TRACE
Definition: debug.h:14
#define MAX_TRACE
Definition: debug.h:16
const char * Oid2Str(IN NDIS_OID Oid)
Definition: debug.c:12
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
static NDIS_OID SupportedOidList[]
Definition: info.c:13
static ULONG64 NICQueryStatisticCounter(_In_ PE1000_ADAPTER Adapter, _In_ NDIS_OID Oid)
Definition: info.c:54
static NDIS_STATUS NICFillPowerManagementCapabilities(_In_ PE1000_ADAPTER Adapter, _Out_ PNDIS_PNP_CAPABILITIES Capabilities)
Definition: info.c:64
#define MAXIMUM_FRAME_SIZE
Definition: nic.h:19
struct _E1000_ADAPTER * PE1000_ADAPTER
#define RECEIVE_BUFFER_SIZE
Definition: nic.h:20
#define DRIVER_VERSION
Definition: nic.h:22
#define MAXIMUM_MULTICAST_ADDRESSES
Definition: e1000hw.h:23
#define IEEE_802_ADDR_LENGTH
Definition: e1000hw.h:11
unsigned __int64 ULONG64
Definition: imports.h:198
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
#define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND
Definition: ndis.h:684
#define NDIS_MAC_OPTION_RECEIVE_SERIALIZED
Definition: ndis.h:683
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define NDIS_STATUS_BUFFER_TOO_SHORT
Definition: ndis.h:487
#define NDIS_MAC_OPTION_NO_LOOPBACK
Definition: ndis.h:685
#define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA
Definition: ndis.h:682
#define NdisMoveMemory(Destination, Source, Length)
Definition: ndis.h:3896
enum _NDIS_MEDIUM NDIS_MEDIUM
#define OID_GEN_TRANSMIT_BLOCK_SIZE
Definition: ntddndis.h:242
#define OID_GEN_XMIT_OK
Definition: ntddndis.h:267
#define OID_GEN_MAXIMUM_TOTAL_SIZE
Definition: ntddndis.h:249
#define OID_GEN_XMIT_ERROR
Definition: ntddndis.h:269
#define OID_GEN_VENDOR_DRIVER_VERSION
Definition: ntddndis.h:254
@ NdisPhysicalMedium802_3
Definition: ntddndis.h:221
#define OID_802_3_PERMANENT_ADDRESS
Definition: ntddndis.h:302
#define OID_GEN_LINK_SPEED
Definition: ntddndis.h:239
#define OID_GEN_VENDOR_ID
Definition: ntddndis.h:244
#define OID_GEN_CURRENT_PACKET_FILTER
Definition: ntddndis.h:246
#define OID_GEN_RCV_NO_BUFFER
Definition: ntddndis.h:271
#define OID_GEN_PHYSICAL_MEDIUM
Definition: ntddndis.h:264
#define OID_GEN_RECEIVE_BUFFER_SPACE
Definition: ntddndis.h:241
#define OID_802_3_MAXIMUM_LIST_SIZE
Definition: ntddndis.h:305
#define OID_GEN_DRIVER_VERSION
Definition: ntddndis.h:248
#define OID_802_3_CURRENT_ADDRESS
Definition: ntddndis.h:303
#define OID_802_3_MULTICAST_LIST
Definition: ntddndis.h:304
struct _NDIS_PNP_CAPABILITIES NDIS_PNP_CAPABILITIES
#define OID_GEN_TRANSMIT_BUFFER_SPACE
Definition: ntddndis.h:240
#define OID_GEN_MEDIA_SUPPORTED
Definition: ntddndis.h:235
@ NdisMedium802_3
Definition: ntddndis.h:188
#define OID_GEN_MAXIMUM_FRAME_SIZE
Definition: ntddndis.h:238
#define OID_GEN_MEDIA_IN_USE
Definition: ntddndis.h:236
#define OID_GEN_MEDIA_CONNECT_STATUS
Definition: ntddndis.h:252
#define OID_GEN_RCV_OK
Definition: ntddndis.h:268
#define OID_GEN_MAXIMUM_LOOKAHEAD
Definition: ntddndis.h:237
int NDIS_STATUS
Definition: ntddndis.h:475
#define OID_GEN_RCV_ERROR
Definition: ntddndis.h:270
@ NdisHardwareStatusReady
Definition: ntddndis.h:450
#define OID_PNP_CAPABILITIES
Definition: ntddndis.h:360
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:247
#define OID_GEN_MAC_OPTIONS
Definition: ntddndis.h:251
#define OID_GEN_VENDOR_DESCRIPTION
Definition: ntddndis.h:245
#define OID_GEN_SUPPORTED_LIST
Definition: ntddndis.h:233
#define OID_GEN_RECEIVE_BLOCK_SIZE
Definition: ntddndis.h:243
#define OID_GEN_MAXIMUM_SEND_PACKETS
Definition: ntddndis.h:253
#define OID_GEN_HARDWARE_STATUS
Definition: ntddndis.h:234
unsigned short USHORT
Definition: pedump.c:61
Definition: lan.h:33
ULONG LinkSpeedMbps
Definition: nic.h:49
ULONG PacketFilter
Definition: nic.h:51
ULONG MediaState
Definition: nic.h:50
ULONG MulticastListSize
Definition: nic.h:47
UCHAR PermanentMacAddress[IEEE_802_ADDR_LENGTH]
Definition: nic.h:42
struct _E1000_ADAPTER::@1037 MulticastList[MAXIMUM_MULTICAST_ADDRESSES]
Definition: ps.c:97
void * PVOID
Definition: typedefs.h:50
unsigned short Ushort
Definition: utypes.h:44
unsigned long Ulong
Definition: utypes.h:42
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ MiniportSetInformation()

NDIS_STATUS NTAPI MiniportSetInformation ( IN NDIS_HANDLE  MiniportAdapterContext,
IN NDIS_OID  Oid,
IN PVOID  InformationBuffer,
IN ULONG  InformationBufferLength,
OUT PULONG  BytesRead,
OUT PULONG  BytesNeeded 
)

Definition at line 283 of file info.c.

290{
291 PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
292 ULONG genericUlong;
294
296
297 switch (Oid)
298 {
300 if (InformationBufferLength < sizeof(ULONG))
301 {
302 *BytesRead = 0;
303 *BytesNeeded = sizeof(ULONG);
305 break;
306 }
307
308 NdisMoveMemory(&genericUlong, InformationBuffer, sizeof(ULONG));
309
310 if (genericUlong &
317 {
318 *BytesRead = sizeof(ULONG);
319 *BytesNeeded = sizeof(ULONG);
321 break;
322 }
323
324 if (Adapter->PacketFilter == genericUlong)
325 {
326 break;
327 }
328
329 Adapter->PacketFilter = genericUlong;
330
331 status = NICApplyPacketFilter(Adapter);
333 {
334 NDIS_DbgPrint(MIN_TRACE, ("Failed to apply new packet filter (0x%x)\n", status));
335 break;
336 }
337
338 break;
339
341 if (InformationBufferLength < sizeof(ULONG))
342 {
343 *BytesRead = 0;
344 *BytesNeeded = sizeof(ULONG);
346 break;
347 }
348
349 NdisMoveMemory(&genericUlong, InformationBuffer, sizeof(ULONG));
350
351 if (genericUlong > MAXIMUM_FRAME_SIZE - sizeof(ETH_HEADER))
352 {
354 }
355 else
356 {
357 // Ignore this...
358 }
359
360 break;
361
363 if (InformationBufferLength % IEEE_802_ADDR_LENGTH)
364 {
365 *BytesRead = 0;
366 *BytesNeeded = InformationBufferLength + (InformationBufferLength % IEEE_802_ADDR_LENGTH);
368 break;
369 }
370
371 if (InformationBufferLength > sizeof(Adapter->MulticastList))
372 {
373 *BytesNeeded = sizeof(Adapter->MulticastList);
374 *BytesRead = 0;
376 break;
377 }
378
379 NdisMoveMemory(Adapter->MulticastList, InformationBuffer, InformationBufferLength);
380
381 Adapter->MulticastListSize = InformationBufferLength / IEEE_802_ADDR_LENGTH;
382
383 NICUpdateMulticastList(Adapter);
384 break;
385
386 default:
387 NDIS_DbgPrint(MIN_TRACE, ("Unknown OID 0x%x(%s)\n", Oid, Oid2Str(Oid)));
389 *BytesRead = 0;
390 *BytesNeeded = 0;
391 break;
392 }
393
395 {
396 *BytesRead = InformationBufferLength;
397 *BytesNeeded = 0;
398 }
399
400 return status;
401}
NDIS_STATUS NTAPI NICApplyPacketFilter(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:724
NDIS_STATUS NTAPI NICUpdateMulticastList(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:693
#define NDIS_PACKET_TYPE_PROMISCUOUS
Definition: ndis.h:668
#define NDIS_STATUS_INVALID_DATA
Definition: ndis.h:486
#define NDIS_PACKET_TYPE_MAC_FRAME
Definition: ndis.h:674
#define NDIS_STATUS_INVALID_LENGTH
Definition: ndis.h:485
#define NDIS_PACKET_TYPE_BROADCAST
Definition: ndis.h:666
#define NDIS_PACKET_TYPE_MULTICAST
Definition: ndis.h:664
#define NDIS_PACKET_TYPE_DIRECTED
Definition: ndis.h:663
#define NDIS_PACKET_TYPE_ALL_MULTICAST
Definition: ndis.h:665
#define NDIS_STATUS_MULTICAST_FULL
Definition: ndis.h:473
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870

◆ MiSetMulticast()

NDIS_STATUS NTAPI MiSetMulticast ( PADAPTER  Adapter,
UCHAR Addresses,
UINT  AddressCount 
)

Definition at line 1262 of file pcnet.c.

1266{
1267 UINT Index;
1268 ULONG CrcIndex;
1269
1271 for (Index = 0; Index < AddressCount; Index++)
1272 {
1273 CrcIndex = MiEthernetCrc(Addresses) >> 26;
1274 Adapter->InitializationBlockVirt->LADR[CrcIndex >> 3] |= 1 << (CrcIndex & 15);
1275 Addresses += 6;
1276 }
1277
1278 /* FIXME: The specification mentions we need to reload the init block here. */
1279
1280 return NDIS_STATUS_SUCCESS;
1281}
#define NdisZeroMemory(Destination, Length)
Definition: ndis.h:3926
unsigned int UINT
Definition: ndis.h:50
static ULONG NTAPI MiEthernetCrc(UCHAR *Address)
Definition: pcnet.c:1235
PINITIALIZATION_BLOCK InitializationBlockVirt
Definition: pcnet.h:81
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by MiniportSetInformation().