ReactOS 0.4.15-dev-7906-g1b85a5f
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 73 of file info.c.

80{
81 PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
82 ULONG copyLength;
83 PVOID copySource;
85 union _GENERIC_INFORMATION
86 {
89 ULONG64 Ulong64;
90 NDIS_MEDIUM Medium;
91 NDIS_PNP_CAPABILITIES PmCapabilities;
92 } GenericInfo;
93
95 copySource = &GenericInfo;
96 copyLength = sizeof(ULONG);
97
98 switch (Oid)
99 {
101 copySource = (PVOID)&SupportedOidList;
102 copyLength = sizeof(SupportedOidList);
103 break;
104
106 GenericInfo.Ulong = Adapter->PacketFilter;
107 break;
108
111 GenericInfo.Ulong = (ULONG)NdisHardwareStatusReady; //FIXME
112 break;
113
116 {
117 GenericInfo.Medium = NdisMedium802_3;
118 copyLength = sizeof(NDIS_MEDIUM);
119 break;
120 }
121
127 GenericInfo.Ulong = MAXIMUM_FRAME_SIZE - sizeof(ETH_HEADER);
128 break;
129
131 copySource = Adapter->MulticastList;
132 copyLength = Adapter->MulticastListSize * IEEE_802_ADDR_LENGTH;
133 break;
134
136 GenericInfo.Ulong = MAXIMUM_MULTICAST_ADDRESSES;
137 break;
138
140 GenericInfo.Ulong = Adapter->LinkSpeedMbps * 10000;
141 break;
142
144 GenericInfo.Ulong = MAXIMUM_FRAME_SIZE;
145 break;
146
148 GenericInfo.Ulong = RECEIVE_BUFFER_SIZE;
149 break;
150
152 /* The 3 bytes of the MAC address is the vendor ID */
153 GenericInfo.Ulong = 0;
154 GenericInfo.Ulong |= (Adapter->PermanentMacAddress[0] << 16);
155 GenericInfo.Ulong |= (Adapter->PermanentMacAddress[1] << 8);
156 GenericInfo.Ulong |= (Adapter->PermanentMacAddress[2] & 0xFF);
157 break;
158
160 {
161 static UCHAR vendorDesc[] = "ReactOS Team";
162 copySource = vendorDesc;
163 copyLength = sizeof(vendorDesc);
164 break;
165 }
166
168 GenericInfo.Ulong = DRIVER_VERSION;
169 break;
170
172 {
173 copyLength = sizeof(USHORT);
174 GenericInfo.Ushort = (NDIS_MINIPORT_MAJOR_VERSION << 8) + NDIS_MINIPORT_MINOR_VERSION;
175 break;
176 }
177
179 GenericInfo.Ulong = MAXIMUM_FRAME_SIZE;
180 break;
181
183 GenericInfo.Ulong = 1;
184 break;
185
187 GenericInfo.Ulong = NDIS_MAC_OPTION_RECEIVE_SERIALIZED |
191 break;
192
194 GenericInfo.Ulong = Adapter->MediaState;
195 break;
196
198 copySource = Adapter->MulticastList[0].MacAddress;
199 copyLength = IEEE_802_ADDR_LENGTH;
200 break;
201
203 copySource = Adapter->PermanentMacAddress;
204 copyLength = IEEE_802_ADDR_LENGTH;
205 break;
206
207 case OID_GEN_XMIT_OK:
208 case OID_GEN_RCV_OK:
212 {
213 GenericInfo.Ulong64 = NICQueryStatisticCounter(Adapter, Oid);
214
215 *BytesNeeded = sizeof(ULONG64);
216 if (InformationBufferLength >= sizeof(ULONG64))
217 {
218 *BytesWritten = sizeof(ULONG64);
219 NdisMoveMemory(InformationBuffer, copySource, sizeof(ULONG64));
220 }
221 else if (InformationBufferLength >= sizeof(ULONG))
222 {
223 *BytesWritten = sizeof(ULONG);
224 NdisMoveMemory(InformationBuffer, copySource, sizeof(ULONG));
225 }
226 else
227 {
228 *BytesWritten = 0;
230 }
231 return NDIS_STATUS_SUCCESS;
232 }
233
235 {
236 copyLength = sizeof(NDIS_PNP_CAPABILITIES);
237
238 status = NICFillPowerManagementCapabilities(Adapter, &GenericInfo.PmCapabilities);
239 break;
240 }
241
242 default:
243 NDIS_DbgPrint(MIN_TRACE, ("Unknown OID 0x%x(%s)\n", Oid, Oid2Str(Oid)));
245 break;
246 }
247
249 {
250 if (copyLength > InformationBufferLength)
251 {
252 *BytesNeeded = copyLength;
253 *BytesWritten = 0;
255 }
256 else
257 {
258 NdisMoveMemory(InformationBuffer, copySource, copyLength);
259 *BytesWritten = copyLength;
260 *BytesNeeded = copyLength;
261 }
262 }
263 else
264 {
265 *BytesWritten = 0;
266 *BytesNeeded = 0;
267 }
268
269 NDIS_DbgPrint(MAX_TRACE, ("Query OID 0x%x(%s): Completed with status 0x%x (%d, %d)\n",
270 Oid, Oid2Str(Oid), status, *BytesWritten, *BytesNeeded));
271 return status;
272}
#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:53
static NDIS_STATUS NICFillPowerManagementCapabilities(_In_ PE1000_ADAPTER Adapter, _Out_ PNDIS_PNP_CAPABILITIES Capabilities)
Definition: info.c:63
#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
#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_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
struct _E1000_ADAPTER::@990 MulticastList[MAXIMUM_MULTICAST_ADDRESSES]
UCHAR PermanentMacAddress[IEEE_802_ADDR_LENGTH]
Definition: nic.h:42
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 276 of file info.c.

283{
284 PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
285 ULONG genericUlong;
287
289
290 switch (Oid)
291 {
293 if (InformationBufferLength < sizeof(ULONG))
294 {
295 *BytesRead = 0;
296 *BytesNeeded = sizeof(ULONG);
298 break;
299 }
300
301 NdisMoveMemory(&genericUlong, InformationBuffer, sizeof(ULONG));
302
303 if (genericUlong &
310 {
311 *BytesRead = sizeof(ULONG);
312 *BytesNeeded = sizeof(ULONG);
314 break;
315 }
316
317 if (Adapter->PacketFilter == genericUlong)
318 {
319 break;
320 }
321
322 Adapter->PacketFilter = genericUlong;
323
324 status = NICApplyPacketFilter(Adapter);
326 {
327 NDIS_DbgPrint(MIN_TRACE, ("Failed to apply new packet filter (0x%x)\n", status));
328 break;
329 }
330
331 break;
332
334 if (InformationBufferLength < sizeof(ULONG))
335 {
336 *BytesRead = 0;
337 *BytesNeeded = sizeof(ULONG);
339 break;
340 }
341
342 NdisMoveMemory(&genericUlong, InformationBuffer, sizeof(ULONG));
343
344 if (genericUlong > MAXIMUM_FRAME_SIZE - sizeof(ETH_HEADER))
345 {
347 }
348 else
349 {
350 // Ignore this...
351 }
352
353 break;
354
356 if (InformationBufferLength % IEEE_802_ADDR_LENGTH)
357 {
358 *BytesRead = 0;
359 *BytesNeeded = InformationBufferLength + (InformationBufferLength % IEEE_802_ADDR_LENGTH);
361 break;
362 }
363
364 if (InformationBufferLength > sizeof(Adapter->MulticastList))
365 {
366 *BytesNeeded = sizeof(Adapter->MulticastList);
367 *BytesRead = 0;
369 break;
370 }
371
372 NdisMoveMemory(Adapter->MulticastList, InformationBuffer, InformationBufferLength);
373
374 Adapter->MulticastListSize = InformationBufferLength / IEEE_802_ADDR_LENGTH;
375
376 NICUpdateMulticastList(Adapter);
377 break;
378
379 default:
380 NDIS_DbgPrint(MIN_TRACE, ("Unknown OID 0x%x(%s)\n", Oid, Oid2Str(Oid)));
382 *BytesRead = 0;
383 *BytesNeeded = 0;
384 break;
385 }
386
388 {
389 *BytesRead = InformationBufferLength;
390 *BytesNeeded = 0;
391 }
392
393 return status;
394}
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().