ReactOS  0.4.14-dev-845-g8381e29
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 
1290  NdisRawReadPortUshort(Adapter->PortOffset + BDP, &Data);
1291 
1292  return (Data & BCR5_LEDOUT) != 0;
1293 }
#define RAP
Definition: pcnethw.h:48
#define NdisRawReadPortUshort(Port, Data)
Definition: ndis.h:4191
ULONG_PTR PortOffset
Definition: pcnet.h:65
#define NdisRawWritePortUshort(Port, Data)
Definition: ndis.h:4248
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
#define BCR5
Definition: pcnethw.h:140
#define BCR5_LEDOUT
Definition: pcnethw.h:285
unsigned int ULONG
Definition: retypes.h:1
#define BDP
Definition: pcnethw.h:49

Referenced by MiInitChip(), and MiSyncMediaDetection().

◆ MiGetMediaSpeed()

UINT NTAPI MiGetMediaSpeed ( PADAPTER  Adapter)

Definition at line 1297 of file pcnet.c.

1298 {
1299  ULONG Data;
1300 
1302  NdisRawReadPortUshort(Adapter->PortOffset + BDP, &Data);
1303 
1304  return Data & BCR6_LEDOUT ? 100 : 10;
1305 }
#define BCR6
Definition: pcnethw.h:141
#define RAP
Definition: pcnethw.h:48
#define NdisRawReadPortUshort(Port, Data)
Definition: ndis.h:4191
ULONG_PTR PortOffset
Definition: pcnet.h:65
#define BCR6_LEDOUT
Definition: pcnethw.h:301
#define NdisRawWritePortUshort(Port, Data)
Definition: ndis.h:4248
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
unsigned int ULONG
Definition: retypes.h:1
#define BDP
Definition: pcnethw.h:49

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;
1321  NdisRawReadPortUshort(Adapter->PortOffset + BDP, &Data);
1323 }
#define RAP
Definition: pcnethw.h:48
#define NdisRawReadPortUshort(Port, Data)
Definition: ndis.h:4191
ULONG_PTR PortOffset
Definition: pcnet.h:65
#define BCR4
Definition: pcnethw.h:139
#define NdisRawWritePortUshort(Port, Data)
Definition: ndis.h:4248
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
unsigned int ULONG
Definition: retypes.h:1
#define BDP
Definition: pcnethw.h:49
#define BCR4_LEDOUT
Definition: pcnethw.h:269

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 51 of file info.c.

58 {
59  PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
60  ULONG genericUlong;
61  ULONG copyLength;
62  PVOID copySource;
64 
66  copySource = &genericUlong;
67  copyLength = sizeof(ULONG);
68 
69  switch (Oid)
70  {
72  copySource = (PVOID)&SupportedOidList;
73  copyLength = sizeof(SupportedOidList);
74  break;
75 
77  genericUlong = Adapter->PacketFilter;
78  break;
79 
82  genericUlong = (ULONG)NdisHardwareStatusReady; //FIXME
83  break;
84 
87  {
88  static const NDIS_MEDIUM medium = NdisMedium802_3;
89  copySource = (PVOID)&medium;
90  copyLength = sizeof(medium);
91  break;
92  }
93 
99  genericUlong = MAXIMUM_FRAME_SIZE - sizeof(ETH_HEADER);
100  break;
101 
103  genericUlong = MAXIMUM_MULTICAST_ADDRESSES;
104  break;
105 
106  case OID_GEN_LINK_SPEED:
107  genericUlong = Adapter->LinkSpeedMbps * 10000;
108  break;
109 
111  genericUlong = MAXIMUM_FRAME_SIZE;
112  break;
113 
115  genericUlong = RECEIVE_BUFFER_SIZE;
116  break;
117 
118  case OID_GEN_VENDOR_ID:
119  /* The 3 bytes of the MAC address is the vendor ID */
120  genericUlong = 0;
121  genericUlong |= (Adapter->PermanentMacAddress[0] << 16);
122  genericUlong |= (Adapter->PermanentMacAddress[1] << 8);
123  genericUlong |= (Adapter->PermanentMacAddress[2] & 0xFF);
124  break;
125 
127  {
128  static UCHAR vendorDesc[] = "ReactOS Team";
129  copySource = vendorDesc;
130  copyLength = sizeof(vendorDesc);
131  break;
132  }
133 
135  genericUlong = DRIVER_VERSION;
136  break;
137 
139  {
140  static const USHORT driverVersion =
141  (NDIS_MINIPORT_MAJOR_VERSION << 8) + NDIS_MINIPORT_MINOR_VERSION;
142  copySource = (PVOID)&driverVersion;
143  copyLength = sizeof(driverVersion);
144  break;
145  }
146 
148  genericUlong = MAXIMUM_FRAME_SIZE;
149  break;
150 
152  genericUlong = 1;
153  break;
154 
155  case OID_GEN_MAC_OPTIONS:
156  genericUlong = NDIS_MAC_OPTION_RECEIVE_SERIALIZED |
160  break;
161 
163  genericUlong = Adapter->MediaState;
164  break;
165 
166 
168  copySource = Adapter->MulticastList[0].MacAddress;
169  copyLength = IEEE_802_ADDR_LENGTH;
170  break;
171 
173  copySource = Adapter->PermanentMacAddress;
174  copyLength = IEEE_802_ADDR_LENGTH;
175  break;
176 
177  case OID_GEN_XMIT_OK:
178  genericUlong = 0;
179  break;
180  case OID_GEN_RCV_OK:
181  genericUlong = 0;
182  break;
183  case OID_GEN_XMIT_ERROR:
184  genericUlong = 0;
185  break;
186  case OID_GEN_RCV_ERROR:
187  genericUlong = 0;
188  break;
190  genericUlong = 0;
191  break;
192 
193  default:
194  NDIS_DbgPrint(MIN_TRACE, ("Unknown OID 0x%x(%s)\n", Oid, Oid2Str(Oid)));
196  break;
197  }
198 
200  {
201  if (copyLength > InformationBufferLength)
202  {
203  *BytesNeeded = copyLength;
204  *BytesWritten = 0;
206  }
207  else
208  {
209  NdisMoveMemory(InformationBuffer, copySource, copyLength);
210  *BytesWritten = copyLength;
211  *BytesNeeded = copyLength;
212  }
213  }
214  else
215  {
216  *BytesWritten = 0;
217  *BytesNeeded = 0;
218  }
219 
220  /* XMIT_ERROR and RCV_ERROR are really noisy, so do not log those. */
221  if (Oid != OID_GEN_XMIT_ERROR && Oid != OID_GEN_RCV_ERROR)
222  {
223  NDIS_DbgPrint(MAX_TRACE, ("Query OID 0x%x(%s): Completed with status 0x%x (%d, %d)\n",
224  Oid, Oid2Str(Oid), status, *BytesWritten, *BytesNeeded));
225  }
226 
227  return status;
228 }
#define MAXIMUM_MULTICAST_ADDRESSES
Definition: e1000hw.h:23
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
static ULONG
Definition: info.c:26
#define OID_GEN_VENDOR_DRIVER_VERSION
Definition: ntddndis.h:254
enum _NDIS_MEDIUM NDIS_MEDIUM
#define DRIVER_VERSION
Definition: nic.h:22
#define OID_GEN_RECEIVE_BUFFER_SPACE
Definition: ntddndis.h:241
struct _E1000_ADAPTER * PE1000_ADAPTER
static ULONG SupportedOidList[]
Definition: info.c:13
#define OID_GEN_MAC_OPTIONS
Definition: ntddndis.h:251
#define OID_GEN_RCV_ERROR
Definition: ntddndis.h:270
#define OID_GEN_CURRENT_PACKET_FILTER
Definition: ntddndis.h:246
#define OID_GEN_HARDWARE_STATUS
Definition: ntddndis.h:234
#define OID_GEN_MEDIA_IN_USE
Definition: ntddndis.h:236
#define NDIS_MAC_OPTION_NO_LOOPBACK
Definition: ndis.h:685
int NDIS_STATUS
Definition: ntddndis.h:471
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
#define OID_802_3_MAXIMUM_LIST_SIZE
Definition: ntddndis.h:305
ULONG PacketFilter
Definition: nic.h:44
#define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND
Definition: ndis.h:684
#define OID_GEN_MEDIA_CONNECT_STATUS
Definition: ntddndis.h:252
#define OID_GEN_TRANSMIT_BUFFER_SPACE
Definition: ntddndis.h:240
#define OID_GEN_MAXIMUM_LOOKAHEAD
Definition: ntddndis.h:237
#define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA
Definition: ndis.h:682
#define OID_GEN_RCV_OK
Definition: ntddndis.h:268
#define NDIS_STATUS_INVALID_LENGTH
Definition: ndis.h:485
#define OID_GEN_SUPPORTED_LIST
Definition: ntddndis.h:233
#define OID_GEN_VENDOR_ID
Definition: ntddndis.h:244
#define NDIS_MAC_OPTION_RECEIVE_SERIALIZED
Definition: ndis.h:683
ULONG MediaState
Definition: nic.h:43
#define OID_GEN_VENDOR_DESCRIPTION
Definition: ntddndis.h:245
#define OID_GEN_XMIT_OK
Definition: ntddndis.h:267
#define OID_GEN_MAXIMUM_FRAME_SIZE
Definition: ntddndis.h:238
struct _ETH_HEADER ETH_HEADER
#define OID_GEN_MAXIMUM_TOTAL_SIZE
Definition: ntddndis.h:249
ULONG LinkSpeedMbps
Definition: nic.h:42
#define IEEE_802_ADDR_LENGTH
Definition: e1000hw.h:11
UCHAR PermanentMacAddress[IEEE_802_ADDR_LENGTH]
Definition: nic.h:37
struct _E1000_ADAPTER::@989 MulticastList[MAXIMUM_MULTICAST_ADDRESSES]
const char * Oid2Str(IN NDIS_OID Oid)
Definition: debug.c:12
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
unsigned char UCHAR
Definition: xmlstorage.h:181
static PVOID
Definition: info.c:26
#define OID_GEN_LINK_SPEED
Definition: ntddndis.h:239
#define OID_GEN_MAXIMUM_SEND_PACKETS
Definition: ntddndis.h:253
#define MAX_TRACE
Definition: debug.h:16
#define OID_GEN_MEDIA_SUPPORTED
Definition: ntddndis.h:235
unsigned short USHORT
Definition: pedump.c:61
#define OID_GEN_XMIT_ERROR
Definition: ntddndis.h:269
#define OID_GEN_TRANSMIT_BLOCK_SIZE
Definition: ntddndis.h:242
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define RECEIVE_BUFFER_SIZE
Definition: nic.h:20
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define OID_GEN_RECEIVE_BLOCK_SIZE
Definition: ntddndis.h:243
unsigned int ULONG
Definition: retypes.h:1
#define MIN_TRACE
Definition: debug.h:14
#define OID_802_3_PERMANENT_ADDRESS
Definition: ntddndis.h:302
#define OID_802_3_CURRENT_ADDRESS
Definition: ntddndis.h:303
#define MAXIMUM_FRAME_SIZE
Definition: nic.h:19
#define NdisMoveMemory(Destination, Source, Length)
Definition: ndis.h:3896
static SERVICE_STATUS status
Definition: service.c:31
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:247
#define OID_GEN_DRIVER_VERSION
Definition: ntddndis.h:248
#define OID_GEN_RCV_NO_BUFFER
Definition: ntddndis.h:271
Definition: ps.c:97

◆ 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 232 of file info.c.

239 {
240  PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
241  ULONG genericUlong;
243 
245 
246  switch (Oid)
247  {
249  if (InformationBufferLength < sizeof(ULONG))
250  {
251  *BytesRead = 0;
252  *BytesNeeded = sizeof(ULONG);
254  break;
255  }
256 
257  NdisMoveMemory(&genericUlong, InformationBuffer, sizeof(ULONG));
258 
259  if (genericUlong &
266  {
267  *BytesRead = sizeof(ULONG);
268  *BytesNeeded = sizeof(ULONG);
270  break;
271  }
272 
273  Adapter->PacketFilter = genericUlong;
274 
275  status = NICApplyPacketFilter(Adapter);
277  {
278  NDIS_DbgPrint(MIN_TRACE, ("Failed to apply new packet filter (0x%x)\n", status));
279  break;
280  }
281 
282  break;
283 
285  if (InformationBufferLength < sizeof(ULONG))
286  {
287  *BytesRead = 0;
288  *BytesNeeded = sizeof(ULONG);
290  break;
291  }
292 
293  NdisMoveMemory(&genericUlong, InformationBuffer, sizeof(ULONG));
294 
295  if (genericUlong > MAXIMUM_FRAME_SIZE - sizeof(ETH_HEADER))
296  {
298  }
299  else
300  {
301  // Ignore this...
302  }
303 
304  break;
305 
307  if (InformationBufferLength % IEEE_802_ADDR_LENGTH)
308  {
309  *BytesRead = 0;
310  *BytesNeeded = InformationBufferLength + (InformationBufferLength % IEEE_802_ADDR_LENGTH);
312  break;
313  }
314 
315  if (InformationBufferLength / 6 > MAXIMUM_MULTICAST_ADDRESSES)
316  {
318  *BytesRead = 0;
320  break;
321  }
322 
323  NdisMoveMemory(Adapter->MulticastList, InformationBuffer, InformationBufferLength);
324  NICUpdateMulticastList(Adapter);
325  break;
326 
327  default:
328  NDIS_DbgPrint(MIN_TRACE, ("Unknown OID 0x%x(%s)\n", Oid, Oid2Str(Oid)));
330  *BytesRead = 0;
331  *BytesNeeded = 0;
332  break;
333  }
334 
336  {
337  *BytesRead = InformationBufferLength;
338  *BytesNeeded = 0;
339  }
340 
341  return status;
342 }
#define MAXIMUM_MULTICAST_ADDRESSES
Definition: e1000hw.h:23
static ULONG
Definition: info.c:26
NDIS_STATUS NTAPI NICApplyPacketFilter(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:752
struct _E1000_ADAPTER * PE1000_ADAPTER
#define OID_GEN_CURRENT_PACKET_FILTER
Definition: ntddndis.h:246
int NDIS_STATUS
Definition: ntddndis.h:471
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
ULONG PacketFilter
Definition: nic.h:44
Definition: lan.h:33
#define NDIS_PACKET_TYPE_SOURCE_ROUTING
Definition: ndis.h:667
#define NDIS_STATUS_INVALID_LENGTH
Definition: ndis.h:485
#define NDIS_PACKET_TYPE_GROUP
Definition: ndis.h:671
#define NDIS_STATUS_INVALID_DATA
Definition: ndis.h:486
#define IEEE_802_ADDR_LENGTH
Definition: e1000hw.h:11
#define NDIS_PACKET_TYPE_FUNCTIONAL
Definition: ndis.h:673
struct _E1000_ADAPTER::@989 MulticastList[MAXIMUM_MULTICAST_ADDRESSES]
const char * Oid2Str(IN NDIS_OID Oid)
Definition: debug.c:12
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define NDIS_PACKET_TYPE_SMT
Definition: ndis.h:669
#define OID_802_3_MULTICAST_LIST
Definition: ntddndis.h:304
#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL
Definition: ndis.h:672
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
NDIS_STATUS NTAPI NICUpdateMulticastList(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:722
unsigned int ULONG
Definition: retypes.h:1
#define MIN_TRACE
Definition: debug.h:14
#define MAXIMUM_FRAME_SIZE
Definition: nic.h:19
#define NDIS_PACKET_TYPE_ALL_LOCAL
Definition: ndis.h:670
#define NdisMoveMemory(Destination, Source, Length)
Definition: ndis.h:3896
static SERVICE_STATUS status
Definition: service.c:31
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:247
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
Definition: ps.c:97

◆ 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 }
static ULONG NTAPI MiEthernetCrc(UCHAR *Address)
Definition: pcnet.c:1235
static const UCHAR Index[8]
Definition: usbohci.c:18
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
PINITIALIZATION_BLOCK InitializationBlockVirt
Definition: pcnet.h:81
unsigned int UINT
Definition: ndis.h:50
#define NdisZeroMemory(Destination, Length)
Definition: ndis.h:3926
unsigned int ULONG
Definition: retypes.h:1

Referenced by MiniportSetInformation().