ReactOS  0.4.15-dev-3733-g974a0f0
nic.h File Reference
#include <ndis.h>
#include "e1000hw.h"
Include dependency graph for nic.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _E1000_ADAPTER
 

Macros

#define E1000_TAG   '001e'
 
#define MAXIMUM_FRAME_SIZE   1522
 
#define RECEIVE_BUFFER_SIZE   2048
 
#define DRIVER_VERSION   1
 
#define DEFAULT_INTERRUPT_MASK   (E1000_IMS_LSC | E1000_IMS_TXDW | E1000_IMS_TXQE | E1000_IMS_RXDMT0 | E1000_IMS_RXT0 | E1000_IMS_TXD_LOW)
 

Typedefs

typedef struct _E1000_ADAPTER E1000_ADAPTER
 
typedef struct _E1000_ADAPTERPE1000_ADAPTER
 

Functions

BOOLEAN NTAPI NICRecognizeHardware (IN PE1000_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICInitializeAdapterResources (IN PE1000_ADAPTER Adapter, IN PNDIS_RESOURCE_LIST ResourceList)
 
NDIS_STATUS NTAPI NICAllocateIoResources (IN PE1000_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICRegisterInterrupts (IN PE1000_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICUnregisterInterrupts (IN PE1000_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICReleaseIoResources (IN PE1000_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICPowerOn (IN PE1000_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICSoftReset (IN PE1000_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICEnableTxRx (IN PE1000_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICDisableTxRx (IN PE1000_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICGetPermanentMacAddress (IN PE1000_ADAPTER Adapter, OUT PUCHAR MacAddress)
 
NDIS_STATUS NTAPI NICUpdateMulticastList (IN PE1000_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICApplyPacketFilter (IN PE1000_ADAPTER Adapter)
 
VOID NTAPI NICUpdateLinkStatus (IN PE1000_ADAPTER Adapter)
 
NDIS_STATUS NTAPI MiniportSend (_In_ NDIS_HANDLE MiniportAdapterContext, _In_ PNDIS_PACKET Packet, _In_ UINT Flags)
 
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 MiniportQueryInformation (IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, IN ULONG InformationBufferLength, OUT PULONG BytesWritten, OUT PULONG BytesNeeded)
 
VOID NTAPI MiniportISR (OUT PBOOLEAN InterruptRecognized, OUT PBOOLEAN QueueMiniportHandleInterrupt, IN NDIS_HANDLE MiniportAdapterContext)
 
VOID NTAPI MiniportHandleInterrupt (IN NDIS_HANDLE MiniportAdapterContext)
 
FORCEINLINE VOID E1000ReadUlong (_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _Out_ PULONG Value)
 
FORCEINLINE VOID E1000WriteUlong (_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
 
FORCEINLINE VOID E1000WriteIoUlong (_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
 
FORCEINLINE VOID NICApplyInterruptMask (_In_ PE1000_ADAPTER Adapter)
 
FORCEINLINE VOID NICDisableInterrupts (_In_ PE1000_ADAPTER Adapter)
 

Macro Definition Documentation

◆ DEFAULT_INTERRUPT_MASK

Definition at line 24 of file nic.h.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1

Definition at line 22 of file nic.h.

◆ E1000_TAG

#define E1000_TAG   '001e'

Definition at line 17 of file nic.h.

◆ MAXIMUM_FRAME_SIZE

#define MAXIMUM_FRAME_SIZE   1522

Definition at line 19 of file nic.h.

◆ RECEIVE_BUFFER_SIZE

#define RECEIVE_BUFFER_SIZE   2048

Definition at line 20 of file nic.h.

Typedef Documentation

◆ E1000_ADAPTER

◆ PE1000_ADAPTER

Function Documentation

◆ E1000ReadUlong()

FORCEINLINE VOID E1000ReadUlong ( _In_ PE1000_ADAPTER  Adapter,
_In_ ULONG  Address,
_Out_ PULONG  Value 
)

Definition at line 209 of file nic.h.

213 {
214  NdisReadRegisterUlong((PULONG)(Adapter->IoBase + Address), Value);
215 }
static WCHAR Address[46]
Definition: ping.c:68
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
unsigned int * PULONG
Definition: retypes.h:1
#define NdisReadRegisterUlong(Register, Data)
Definition: ndis.h:4267

Referenced by E1000ReadEeprom(), MiniportHandleInterrupt(), MiniportISR(), NICApplyPacketFilter(), NICDisableTxRx(), NICSoftReset(), and NICUpdateLinkStatus().

◆ E1000WriteIoUlong()

FORCEINLINE VOID E1000WriteIoUlong ( _In_ PE1000_ADAPTER  Adapter,
_In_ ULONG  Address,
_In_ ULONG  Value 
)

Definition at line 229 of file nic.h.

233 {
234  volatile ULONG Dummy;
235 
236  NdisRawWritePortUlong((PULONG)(Adapter->IoPort), Address);
237  NdisReadRegisterUlong(Adapter->IoBase + E1000_REG_STATUS, &Dummy);
238  NdisRawWritePortUlong((PULONG)(Adapter->IoPort + 4), Value);
239 }
#define E1000_REG_STATUS
Definition: e1000hw.h:115
static WCHAR Address[46]
Definition: ping.c:68
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
unsigned int * PULONG
Definition: retypes.h:1
#define NdisReadRegisterUlong(Register, Data)
Definition: ndis.h:4267
unsigned int ULONG
Definition: retypes.h:1
#define NdisRawWritePortUlong(Port, Data)
Definition: ndis.h:4239

Referenced by NICSoftReset().

◆ E1000WriteUlong()

FORCEINLINE VOID E1000WriteUlong ( _In_ PE1000_ADAPTER  Adapter,
_In_ ULONG  Address,
_In_ ULONG  Value 
)

Definition at line 219 of file nic.h.

223 {
224  NdisWriteRegisterUlong((PULONG)(Adapter->IoBase + Address), Value);
225 }
#define NdisWriteRegisterUlong(Register, Data)
Definition: ndis.h:4294
static WCHAR Address[46]
Definition: ping.c:68
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
unsigned int * PULONG
Definition: retypes.h:1

Referenced by E1000ReadEeprom(), MiniportHandleInterrupt(), NICApplyInterruptMask(), NICApplyPacketFilter(), NICDisableInterrupts(), NICDisableTxRx(), NICEnableTxRx(), NICReleaseIoResources(), NICSoftReset(), NICTransmitPacket(), and NICUpdateMulticastList().

◆ MiniportHandleInterrupt()

VOID NTAPI MiniportHandleInterrupt ( IN NDIS_HANDLE  MiniportAdapterContext)

Definition at line 46 of file interrupt.c.

48 {
49  ULONG InterruptPending;
50  PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
51  volatile PE1000_TRANSMIT_DESCRIPTOR TransmitDescriptor;
52 
53  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
54 
55  InterruptPending = _InterlockedExchange(&Adapter->InterruptPending, 0);
56 
57 
58  /* Link State Changed */
59  if (InterruptPending & E1000_IMS_LSC)
60  {
61  ULONG Status;
62 
63  InterruptPending &= ~E1000_IMS_LSC;
64  NDIS_DbgPrint(MAX_TRACE, ("Link status changed!.\n"));
65 
66  NICUpdateLinkStatus(Adapter);
67 
69 
72  }
73 
74  /* Handling receive interrupts */
75  if (InterruptPending & (E1000_IMS_RXDMT0 | E1000_IMS_RXT0))
76  {
77  volatile PE1000_RECEIVE_DESCRIPTOR ReceiveDescriptor;
78  PETH_HEADER EthHeader;
79  ULONG BufferOffset;
80  BOOLEAN bGotAny = FALSE;
81  ULONG RxDescHead, RxDescTail, CurrRxDesc;
82 
83  /* Clear out these interrupts */
84  InterruptPending &= ~(E1000_IMS_RXDMT0 | E1000_IMS_RXT0);
85 
86  E1000ReadUlong(Adapter, E1000_REG_RDH, &RxDescHead);
87  E1000ReadUlong(Adapter, E1000_REG_RDT, &RxDescTail);
88 
89  while (((RxDescTail + 1) % NUM_RECEIVE_DESCRIPTORS) != RxDescHead)
90  {
91  CurrRxDesc = (RxDescTail + 1) % NUM_RECEIVE_DESCRIPTORS;
92  BufferOffset = CurrRxDesc * Adapter->ReceiveBufferEntrySize;
93  ReceiveDescriptor = Adapter->ReceiveDescriptors + CurrRxDesc;
94 
95  /* Check if the hardware have released this descriptor (DD - Descriptor Done) */
96  if (!(ReceiveDescriptor->Status & E1000_RDESC_STATUS_DD))
97  {
98  /* No need to check descriptors after the first unfinished one */
99  break;
100  }
101 
102  /* Ignoring these flags for now */
103  ReceiveDescriptor->Status &= ~(E1000_RDESC_STATUS_IXSM | E1000_RDESC_STATUS_PIF);
104 
105  if (ReceiveDescriptor->Status != (E1000_RDESC_STATUS_EOP | E1000_RDESC_STATUS_DD))
106  {
107  NDIS_DbgPrint(MIN_TRACE, ("Unrecognized ReceiveDescriptor status flag: %u\n", ReceiveDescriptor->Status));
108  }
109 
110  /* Make sure the receive indications are enabled */
111  if (!Adapter->PacketFilter)
112  {
113  goto NextReceiveDescriptor;
114  }
115 
116  if (ReceiveDescriptor->Length != 0 && ReceiveDescriptor->Address != 0)
117  {
118  EthHeader = (PETH_HEADER)(Adapter->ReceiveBuffer + BufferOffset);
119 
121  NULL,
122  (PCHAR)EthHeader,
123  sizeof(ETH_HEADER),
124  (PCHAR)(EthHeader + 1),
125  ReceiveDescriptor->Length - sizeof(ETH_HEADER),
126  ReceiveDescriptor->Length - sizeof(ETH_HEADER));
127 
128  bGotAny = TRUE;
129  }
130  else
131  {
132  NDIS_DbgPrint(MIN_TRACE, ("Got a NULL descriptor"));
133  }
134 
135 NextReceiveDescriptor:
136  /* Give the descriptor back */
137  ReceiveDescriptor->Status = 0;
138 
139  RxDescTail = CurrRxDesc;
140  }
141 
142  if (bGotAny)
143  {
144  /* Write back new tail value */
145  E1000WriteUlong(Adapter, E1000_REG_RDT, RxDescTail);
146 
147  NDIS_DbgPrint(MAX_TRACE, ("Rx done (RDH: %u, RDT: %u)\n", RxDescHead, RxDescTail));
148 
150  }
151  }
152 
153  /* Handling transmit interrupts */
154  if (InterruptPending & (E1000_IMS_TXD_LOW | E1000_IMS_TXDW | E1000_IMS_TXQE))
155  {
156  PNDIS_PACKET AckPackets[40] = {0};
157  ULONG NumPackets = 0, i;
158 
159  /* Clear out these interrupts */
160  InterruptPending &= ~(E1000_IMS_TXD_LOW | E1000_IMS_TXDW | E1000_IMS_TXQE);
161 
162  while ((Adapter->TxFull || Adapter->LastTxDesc != Adapter->CurrentTxDesc) && NumPackets < ARRAYSIZE(AckPackets))
163  {
164  TransmitDescriptor = Adapter->TransmitDescriptors + Adapter->LastTxDesc;
165 
166  if (TransmitDescriptor->Status & E1000_TDESC_STATUS_DD)
167  {
168  if (Adapter->TransmitPackets[Adapter->LastTxDesc])
169  {
170  AckPackets[NumPackets++] = Adapter->TransmitPackets[Adapter->LastTxDesc];
171  Adapter->TransmitPackets[Adapter->LastTxDesc] = NULL;
172  TransmitDescriptor->Status = 0;
173  }
174 
175  Adapter->LastTxDesc = (Adapter->LastTxDesc + 1) % NUM_TRANSMIT_DESCRIPTORS;
176  Adapter->TxFull = FALSE;
177  }
178  else
179  {
180  break;
181  }
182  }
183 
184  if (NumPackets)
185  {
186  NDIS_DbgPrint(MAX_TRACE, ("Tx: (TDH: %u, TDT: %u)\n", Adapter->CurrentTxDesc, Adapter->LastTxDesc));
187  NDIS_DbgPrint(MAX_TRACE, ("Tx Done: %u packets to ack\n", NumPackets));
188 
189  for (i = 0; i < NumPackets; ++i)
190  {
191  NdisMSendComplete(Adapter->AdapterHandle, AckPackets[i], NDIS_STATUS_SUCCESS);
192  }
193  }
194  }
195 
196  ASSERT(InterruptPending == 0);
197 }
#define E1000_IMS_RXT0
Definition: e1000hw.h:186
signed char * PCHAR
Definition: retypes.h:7
VOID EXPORT NdisMSendComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status)
Definition: miniport.c:2809
#define E1000_REG_RDH
Definition: e1000hw.h:132
_Interlocked_ volatile LONG InterruptPending
Definition: nic.h:70
NDIS_HANDLE AdapterHandle
Definition: nic.h:36
PE1000_RECEIVE_DESCRIPTOR ReceiveDescriptors
Definition: nic.h:85
#define TRUE
Definition: types.h:120
FORCEINLINE VOID E1000WriteUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:219
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
volatile PUCHAR ReceiveBuffer
Definition: nic.h:89
#define NUM_RECEIVE_DESCRIPTORS
Definition: e1000hw.h:109
#define NdisMEthIndicateReceiveComplete(MiniportAdapterHandle)
Definition: ndis.h:5482
struct _E1000_ADAPTER * PE1000_ADAPTER
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define NUM_TRANSMIT_DESCRIPTORS
Definition: e1000hw.h:108
#define E1000_IMS_TXQE
Definition: e1000hw.h:183
#define E1000_REG_RDT
Definition: e1000hw.h:133
ULONG PacketFilter
Definition: nic.h:51
#define FALSE
Definition: types.h:117
Definition: lan.h:33
#define E1000_RDESC_STATUS_EOP
Definition: e1000hw.h:61
#define E1000_RDESC_STATUS_DD
Definition: e1000hw.h:62
unsigned char BOOLEAN
VOID NTAPI NICUpdateLinkStatus(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:738
#define E1000_RDESC_STATUS_IXSM
Definition: e1000hw.h:60
VOID EXPORT NdisMIndicateStatusComplete(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:1580
Status
Definition: gdiplustypes.h:24
ULONG MediaState
Definition: nic.h:50
#define NDIS_STATUS_MEDIA_CONNECT
Definition: ndis.h:361
#define ASSERT(a)
Definition: mode.c:44
#define E1000_IMS_LSC
Definition: e1000hw.h:184
#define E1000_IMS_RXDMT0
Definition: e1000hw.h:185
struct _ETH_HEADER * PETH_HEADER
ULONG LastTxDesc
Definition: nic.h:80
BOOLEAN TxFull
Definition: nic.h:81
#define NdisMEthIndicateReceive(MiniportAdapterHandle, MiniportReceiveContext, HeaderBuffer, HeaderBufferSize, LookaheadBuffer, LookaheadBufferSize, PacketSize)
Definition: ndis.h:5458
PE1000_TRANSMIT_DESCRIPTOR TransmitDescriptors
Definition: nic.h:74
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define E1000_RDESC_STATUS_PIF
Definition: e1000hw.h:59
ULONG CurrentTxDesc
Definition: nic.h:79
ULONG ReceiveBufferEntrySize
Definition: nic.h:91
PNDIS_PACKET TransmitPackets[NUM_TRANSMIT_DESCRIPTORS]
Definition: nic.h:77
#define E1000_IMS_TXDW
Definition: e1000hw.h:182
#define E1000_TDESC_STATUS_DD
Definition: e1000hw.h:84
#define E1000_IMS_TXD_LOW
Definition: e1000hw.h:187
FORCEINLINE VOID E1000ReadUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _Out_ PULONG Value)
Definition: nic.h:209
#define MAX_TRACE
Definition: debug.h:16
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
unsigned int ULONG
Definition: retypes.h:1
#define MIN_TRACE
Definition: debug.h:14
VOID EXPORT NdisMIndicateStatus(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS GeneralStatus, IN PVOID StatusBuffer, IN UINT StatusBufferSize)
Definition: miniport.c:1565
#define NDIS_STATUS_MEDIA_DISCONNECT
Definition: ndis.h:362

◆ MiniportISR()

VOID NTAPI MiniportISR ( OUT PBOOLEAN  InterruptRecognized,
OUT PBOOLEAN  QueueMiniportHandleInterrupt,
IN NDIS_HANDLE  MiniportAdapterContext 
)

Definition at line 16 of file interrupt.c.

20 {
21  ULONG Value;
22  PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
23 
24  /* Reading the interrupt acknowledges them */
26 
27  Value &= Adapter->InterruptMask;
29 
30  if (Value)
31  {
32  *InterruptRecognized = TRUE;
33  /* Mark the events pending service */
34  *QueueMiniportHandleInterrupt = TRUE;
35  }
36  else
37  {
38  /* This is not ours. */
39  *InterruptRecognized = FALSE;
40  *QueueMiniportHandleInterrupt = FALSE;
41  }
42 }
_Interlocked_ volatile LONG InterruptPending
Definition: nic.h:70
#define TRUE
Definition: types.h:120
struct _E1000_ADAPTER * PE1000_ADAPTER
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
#define E1000_REG_ICR
Definition: e1000hw.h:119
FORCEINLINE VOID E1000ReadUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _Out_ PULONG Value)
Definition: nic.h:209
unsigned int ULONG
Definition: retypes.h:1
LONG InterruptMask
Definition: nic.h:67
long _InterlockedOr(_Interlocked_operand_ long volatile *_Value, long _Mask)

◆ 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  {
87  USHORT Ushort;
88  ULONG Ulong;
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 
139  case OID_GEN_LINK_SPEED:
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 
151  case OID_GEN_VENDOR_ID:
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 
186  case OID_GEN_MAC_OPTIONS:
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:
209  case OID_GEN_XMIT_ERROR:
210  case OID_GEN_RCV_ERROR:
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 }
_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:949
ULONG MulticastListSize
Definition: nic.h:47
#define MAXIMUM_MULTICAST_ADDRESSES
Definition: e1000hw.h:23
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
#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_PNP_CAPABILITIES
Definition: ntddndis.h:360
#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:51
#define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND
Definition: ndis.h:684
#define NDIS_STATUS_BUFFER_TOO_SHORT
Definition: ndis.h:487
#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 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:50
static NDIS_OID SupportedOidList[]
Definition: info.c:13
#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:49
#define IEEE_802_ADDR_LENGTH
Definition: e1000hw.h:11
UCHAR PermanentMacAddress[IEEE_802_ADDR_LENGTH]
Definition: nic.h:42
struct _E1000_ADAPTER::@962 MulticastList[MAXIMUM_MULTICAST_ADDRESSES]
const char * Oid2Str(IN NDIS_OID Oid)
Definition: debug.c:12
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
unsigned __int64 ULONG64
Definition: imports.h:198
unsigned char UCHAR
Definition: xmlstorage.h:181
static PVOID
Definition: info.c:26
#define OID_GEN_LINK_SPEED
Definition: ntddndis.h:239
#define OID_802_3_MULTICAST_LIST
Definition: ntddndis.h:304
static NDIS_STATUS NICFillPowerManagementCapabilities(_In_ PE1000_ADAPTER Adapter, _Out_ PNDIS_PNP_CAPABILITIES Capabilities)
Definition: info.c:63
#define OID_GEN_MAXIMUM_SEND_PACKETS
Definition: ntddndis.h:253
#define MAX_TRACE
Definition: debug.h:16
unsigned short Ushort
Definition: utypes.h:44
#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
struct _NDIS_PNP_CAPABILITIES NDIS_PNP_CAPABILITIES
#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
unsigned long Ulong
Definition: utypes.h:42
#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
static ULONG64 NICQueryStatisticCounter(_In_ PE1000_ADAPTER Adapter, _In_ NDIS_OID Oid)
Definition: info.c:53
#define OID_GEN_RCV_NO_BUFFER
Definition: ntddndis.h:271
Definition: ps.c:97

◆ MiniportSend()

NDIS_STATUS NTAPI MiniportSend ( _In_ NDIS_HANDLE  MiniportAdapterContext,
_In_ PNDIS_PACKET  Packet,
_In_ UINT  Flags 
)

Definition at line 49 of file send.c.

53 {
54  PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
55  PSCATTER_GATHER_LIST sgList;
56  ULONG TransmitLength;
57  PHYSICAL_ADDRESS TransmitBuffer;
59 
61 
62  ASSERT(sgList != NULL);
63  ASSERT(sgList->NumberOfElements == 1);
64  ASSERT((sgList->Elements[0].Address.LowPart & 3) == 0);
65  ASSERT(sgList->Elements[0].Length <= MAXIMUM_FRAME_SIZE);
66 
67  if (Adapter->TxFull)
68  {
69  NDIS_DbgPrint(MIN_TRACE, ("All TX descriptors are full\n"));
70  return NDIS_STATUS_RESOURCES;
71  }
72 
73  TransmitLength = sgList->Elements[0].Length;
74  TransmitBuffer = sgList->Elements[0].Address;
75  Adapter->TransmitPackets[Adapter->CurrentTxDesc] = Packet;
76 
77  Status = NICTransmitPacket(Adapter, TransmitBuffer, TransmitLength);
79  {
80  NDIS_DbgPrint(MIN_TRACE, ("Transmit packet failed\n"));
81  return Status;
82  }
83 
84  return NDIS_STATUS_PENDING;
85 }
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
struct _E1000_ADAPTER * PE1000_ADAPTER
int NDIS_STATUS
Definition: ntddndis.h:471
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
BOOLEAN TxFull
Definition: nic.h:81
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
ULONG CurrentTxDesc
Definition: nic.h:79
PNDIS_PACKET TransmitPackets[NUM_TRANSMIT_DESCRIPTORS]
Definition: nic.h:77
#define NULL
Definition: types.h:112
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
struct _SCATTER_GATHER_LIST * PSCATTER_GATHER_LIST
Definition: iotypes.h:2204
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
unsigned int ULONG
Definition: retypes.h:1
#define MIN_TRACE
Definition: debug.h:14
static NDIS_STATUS NICTransmitPacket(_In_ PE1000_ADAPTER Adapter, _In_ PHYSICAL_ADDRESS PhysicalAddress, _In_ ULONG Length)
Definition: send.c:15
#define MAXIMUM_FRAME_SIZE
Definition: nic.h:19
#define NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, InfoType)
Definition: ndis.h:1351

◆ 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 }
ULONG MulticastListSize
Definition: nic.h:47
static ULONG
Definition: info.c:26
NDIS_STATUS NTAPI NICApplyPacketFilter(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:722
struct _E1000_ADAPTER * PE1000_ADAPTER
#define OID_GEN_CURRENT_PACKET_FILTER
Definition: ntddndis.h:246
_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:859
int NDIS_STATUS
Definition: ntddndis.h:471
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
ULONG PacketFilter
Definition: nic.h:51
Definition: lan.h:33
#define NDIS_STATUS_INVALID_LENGTH
Definition: ndis.h:485
#define NDIS_STATUS_INVALID_DATA
Definition: ndis.h:486
#define NDIS_STATUS_MULTICAST_FULL
Definition: ndis.h:473
#define NDIS_PACKET_TYPE_ALL_MULTICAST
Definition: ndis.h:665
#define IEEE_802_ADDR_LENGTH
Definition: e1000hw.h:11
struct _E1000_ADAPTER::@962 MulticastList[MAXIMUM_MULTICAST_ADDRESSES]
#define NDIS_PACKET_TYPE_MULTICAST
Definition: ndis.h:664
const char * Oid2Str(IN NDIS_OID Oid)
Definition: debug.c:12
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define OID_802_3_MULTICAST_LIST
Definition: ntddndis.h:304
#define NDIS_PACKET_TYPE_PROMISCUOUS
Definition: ndis.h:668
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
NDIS_STATUS NTAPI NICUpdateMulticastList(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:691
unsigned int ULONG
Definition: retypes.h:1
#define MIN_TRACE
Definition: debug.h:14
#define NDIS_PACKET_TYPE_MAC_FRAME
Definition: ndis.h:674
#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 NDIS_PACKET_TYPE_DIRECTED
Definition: ndis.h:663
#define NDIS_PACKET_TYPE_BROADCAST
Definition: ndis.h:666
Definition: ps.c:97

◆ NICAllocateIoResources()

NDIS_STATUS NTAPI NICAllocateIoResources ( IN PE1000_ADAPTER  Adapter)

Definition at line 309 of file hardware.c.

311 {
314  UINT n;
315 
316  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
317 
318  Status = NdisMRegisterIoPortRange((PVOID*)&Adapter->IoPort,
319  Adapter->AdapterHandle,
320  Adapter->IoPortAddress,
321  Adapter->IoPortLength);
323  {
324  NDIS_DbgPrint(MIN_TRACE, ("Unable to register IO port range (0x%x)\n", Status));
325  return NDIS_STATUS_RESOURCES;
326  }
327 
328  Status = NdisMMapIoSpace((PVOID*)&Adapter->IoBase,
329  Adapter->AdapterHandle,
330  Adapter->IoAddress,
331  Adapter->IoLength);
332 
333 
334  NdisMAllocateSharedMemory(Adapter->AdapterHandle,
336  FALSE,
337  (PVOID*)&Adapter->TransmitDescriptors,
338  &Adapter->TransmitDescriptorsPa);
339  if (Adapter->TransmitDescriptors == NULL)
340  {
341  NDIS_DbgPrint(MIN_TRACE, ("Unable to allocate transmit descriptors\n"));
342  return NDIS_STATUS_RESOURCES;
343  }
344 
345  for (n = 0; n < NUM_TRANSMIT_DESCRIPTORS; ++n)
346  {
347  PE1000_TRANSMIT_DESCRIPTOR Descriptor = Adapter->TransmitDescriptors + n;
348  Descriptor->Address = 0;
349  Descriptor->Length = 0;
350  }
351 
352  NdisMAllocateSharedMemory(Adapter->AdapterHandle,
354  FALSE,
355  (PVOID*)&Adapter->ReceiveDescriptors,
356  &Adapter->ReceiveDescriptorsPa);
357  if (Adapter->ReceiveDescriptors == NULL)
358  {
359  NDIS_DbgPrint(MIN_TRACE, ("Unable to allocate receive descriptors\n"));
360  return NDIS_STATUS_RESOURCES;
361  }
362 
363  AllocationSize = RcvBufAllocationSize(Adapter->ReceiveBufferType);
364  ASSERT(Adapter->ReceiveBufferEntrySize == 0 || Adapter->ReceiveBufferEntrySize == AllocationSize);
365  Adapter->ReceiveBufferEntrySize = AllocationSize;
366 
367  NdisMAllocateSharedMemory(Adapter->AdapterHandle,
368  Adapter->ReceiveBufferEntrySize * NUM_RECEIVE_DESCRIPTORS,
369  FALSE,
370  (PVOID*)&Adapter->ReceiveBuffer,
371  &Adapter->ReceiveBufferPa);
372 
373  if (Adapter->ReceiveBuffer == NULL)
374  {
375  NDIS_DbgPrint(MIN_TRACE, ("Unable to allocate receive buffer\n"));
376  return NDIS_STATUS_RESOURCES;
377  }
378 
379  for (n = 0; n < NUM_RECEIVE_DESCRIPTORS; ++n)
380  {
381  PE1000_RECEIVE_DESCRIPTOR Descriptor = Adapter->ReceiveDescriptors + n;
382 
384  Descriptor->Address = Adapter->ReceiveBufferPa.QuadPart + n * Adapter->ReceiveBufferEntrySize;
385  }
386 
387  return NDIS_STATUS_SUCCESS;
388 }
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
VOID EXPORT NdisMAllocateSharedMemory(IN NDIS_HANDLE MiniportAdapterHandle, IN ULONG Length, IN BOOLEAN Cached, OUT PVOID *VirtualAddress, OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress)
Definition: memory.c:148
#define NUM_RECEIVE_DESCRIPTORS
Definition: e1000hw.h:109
NDIS_STATUS EXPORT NdisMRegisterIoPortRange(OUT PVOID *PortOffset, IN NDIS_HANDLE MiniportAdapterHandle, IN UINT InitialPort, IN UINT NumberOfPorts)
Definition: io.c:1018
GLdouble n
Definition: glext.h:7729
#define NUM_TRANSMIT_DESCRIPTORS
Definition: e1000hw.h:108
int NDIS_STATUS
Definition: ntddndis.h:471
#define FALSE
Definition: types.h:117
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
static ULONG RcvBufAllocationSize(E1000_RCVBUF_SIZE BufSize)
Definition: hardware.c:86
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
Definition: fatprocs.h:319
#define MAX_TRACE
Definition: debug.h:16
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define MIN_TRACE
Definition: debug.h:14
NDIS_STATUS EXPORT NdisMMapIoSpace(OUT PVOID *VirtualAddress, IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_PHYSICAL_ADDRESS PhysicalAddress, IN UINT Length)
Definition: io.c:774

Referenced by MiniportInitialize().

◆ NICApplyInterruptMask()

FORCEINLINE VOID NICApplyInterruptMask ( _In_ PE1000_ADAPTER  Adapter)

Definition at line 243 of file nic.h.

245 {
246  E1000WriteUlong(Adapter, E1000_REG_IMS, Adapter->InterruptMask /*| 0x1F6DC*/);
247 }
FORCEINLINE VOID E1000WriteUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:219
#define E1000_REG_IMS
Definition: e1000hw.h:122

Referenced by MiniportInitialize().

◆ NICApplyPacketFilter()

NDIS_STATUS NTAPI NICApplyPacketFilter ( IN PE1000_ADAPTER  Adapter)

Definition at line 722 of file hardware.c.

724 {
725  ULONG FilterMask;
726 
727  E1000ReadUlong(Adapter, E1000_REG_RCTL, &FilterMask);
728 
729  FilterMask &= ~E1000_RCTL_FILTER_BITS;
730  FilterMask |= PacketFilterToMask(Adapter->PacketFilter);
731  E1000WriteUlong(Adapter, E1000_REG_RCTL, FilterMask);
732 
733  return NDIS_STATUS_SUCCESS;
734 }
static ULONG PacketFilterToMask(ULONG PacketFilter)
Definition: hardware.c:56
#define E1000_REG_RCTL
Definition: e1000hw.h:125
FORCEINLINE VOID E1000WriteUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:219
#define E1000_RCTL_FILTER_BITS
Definition: e1000hw.h:207
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
FORCEINLINE VOID E1000ReadUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _Out_ PULONG Value)
Definition: nic.h:209
unsigned int ULONG
Definition: retypes.h:1

Referenced by MiniportSetInformation().

◆ NICDisableInterrupts()

FORCEINLINE VOID NICDisableInterrupts ( _In_ PE1000_ADAPTER  Adapter)

Definition at line 251 of file nic.h.

253 {
254  E1000WriteUlong(Adapter, E1000_REG_IMC, ~0);
255 }
FORCEINLINE VOID E1000WriteUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:219
#define E1000_REG_IMC
Definition: e1000hw.h:123

◆ NICDisableTxRx()

NDIS_STATUS NTAPI NICDisableTxRx ( IN PE1000_ADAPTER  Adapter)

Definition at line 641 of file hardware.c.

643 {
644  ULONG Value;
645 
646  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
647 
648  E1000ReadUlong(Adapter, E1000_REG_TCTL, &Value);
649  Value &= ~E1000_TCTL_EN;
651 
652  E1000ReadUlong(Adapter, E1000_REG_RCTL, &Value);
653  Value &= ~E1000_RCTL_EN;
655 
656  return NDIS_STATUS_SUCCESS;
657 }
#define E1000_TCTL_EN
Definition: e1000hw.h:211
#define E1000_REG_RCTL
Definition: e1000hw.h:125
FORCEINLINE VOID E1000WriteUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:219
#define E1000_REG_TCTL
Definition: e1000hw.h:126
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
#define E1000_RCTL_EN
Definition: e1000hw.h:197
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
FORCEINLINE VOID E1000ReadUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _Out_ PULONG Value)
Definition: nic.h:209
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
unsigned int ULONG
Definition: retypes.h:1

Referenced by MiniportHalt().

◆ NICEnableTxRx()

NDIS_STATUS NTAPI NICEnableTxRx ( IN PE1000_ADAPTER  Adapter)

Definition at line 574 of file hardware.c.

576 {
577  ULONG Value;
578 
579  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
580  NDIS_DbgPrint(MID_TRACE, ("Setting up transmit.\n"));
581 
582  /* Make sure the thing is disabled first. */
583  E1000WriteUlong(Adapter, E1000_REG_TCTL, 0);
584 
585  /* Transmit descriptor ring buffer */
586  E1000WriteUlong(Adapter, E1000_REG_TDBAH, Adapter->TransmitDescriptorsPa.HighPart);
587  E1000WriteUlong(Adapter, E1000_REG_TDBAL, Adapter->TransmitDescriptorsPa.LowPart);
588 
589  /* Transmit descriptor buffer size */
591 
592  /* Transmit descriptor tail / head */
593  E1000WriteUlong(Adapter, E1000_REG_TDH, 0);
594  E1000WriteUlong(Adapter, E1000_REG_TDT, 0);
595  Adapter->CurrentTxDesc = 0;
596 
597  /* Set up interrupt timers */
598  E1000WriteUlong(Adapter, E1000_REG_TADV, 96); // value is in 1.024 of usec
599  E1000WriteUlong(Adapter, E1000_REG_TIDV, 16);
600 
602 
604 
605  NDIS_DbgPrint(MID_TRACE, ("Setting up receive.\n"));
606 
607  /* Make sure the thing is disabled first. */
608  E1000WriteUlong(Adapter, E1000_REG_RCTL, 0);
609 
610  /* Receive descriptor ring buffer */
611  E1000WriteUlong(Adapter, E1000_REG_RDBAH, Adapter->ReceiveDescriptorsPa.HighPart);
612  E1000WriteUlong(Adapter, E1000_REG_RDBAL, Adapter->ReceiveDescriptorsPa.LowPart);
613 
614  /* Receive descriptor buffer size */
616 
617  /* Receive descriptor tail / head */
618  E1000WriteUlong(Adapter, E1000_REG_RDH, 0);
620 
621  /* Set up interrupt timers */
622  E1000WriteUlong(Adapter, E1000_REG_RADV, 96);
623  E1000WriteUlong(Adapter, E1000_REG_RDTR, 16);
624 
625  /* Some defaults */
627 
628  /* Receive buffer size */
629  Value |= RcvBufRegisterMask(Adapter->ReceiveBufferType);
630 
631  /* Add our current packet filter */
632  Value |= PacketFilterToMask(Adapter->PacketFilter);
633 
635 
636  return NDIS_STATUS_SUCCESS;
637 }
static ULONG PacketFilterToMask(ULONG PacketFilter)
Definition: hardware.c:56
#define E1000_REG_RDH
Definition: e1000hw.h:132
#define MID_TRACE
Definition: debug.h:15
#define E1000_TCTL_EN
Definition: e1000hw.h:211
#define E1000_REG_RCTL
Definition: e1000hw.h:125
FORCEINLINE VOID E1000WriteUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:219
#define NUM_RECEIVE_DESCRIPTORS
Definition: e1000hw.h:109
#define E1000_REG_TDH
Definition: e1000hw.h:140
#define NUM_TRANSMIT_DESCRIPTORS
Definition: e1000hw.h:108
#define E1000_REG_RDT
Definition: e1000hw.h:133
#define E1000_REG_TCTL
Definition: e1000hw.h:126
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
#define E1000_REG_TADV
Definition: e1000hw.h:143
#define E1000_REG_TDBAH
Definition: e1000hw.h:138
#define E1000_TCTL_PSP
Definition: e1000hw.h:212
#define E1000_REG_RDBAH
Definition: e1000hw.h:130
#define E1000_RCTL_EN
Definition: e1000hw.h:197
#define E1000_REG_TDLEN
Definition: e1000hw.h:139
#define E1000_REG_TDBAL
Definition: e1000hw.h:137
#define E1000_REG_TIPG
Definition: e1000hw.h:127
#define E1000_RCTL_SECRC
Definition: e1000hw.h:205
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
static ULONG RcvBufRegisterMask(E1000_RCVBUF_SIZE BufSize)
Definition: hardware.c:102
#define E1000_TIPG_IPGR1_DEF
Definition: e1000hw.h:216
#define E1000_REG_RDBAL
Definition: e1000hw.h:129
#define E1000_REG_RDLEN
Definition: e1000hw.h:131
#define E1000_REG_TDT
Definition: e1000hw.h:141
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define E1000_TIPG_IPGR2_DEF
Definition: e1000hw.h:217
unsigned int ULONG
Definition: retypes.h:1
#define E1000_REG_TIDV
Definition: e1000hw.h:142
#define E1000_REG_RDTR
Definition: e1000hw.h:134
#define E1000_TIPG_IPGT_DEF
Definition: e1000hw.h:215
#define E1000_REG_RADV
Definition: e1000hw.h:135

Referenced by MiniportInitialize().

◆ NICGetPermanentMacAddress()

NDIS_STATUS NTAPI NICGetPermanentMacAddress ( IN PE1000_ADAPTER  Adapter,
OUT PUCHAR  MacAddress 
)

Definition at line 661 of file hardware.c.

664 {
665  USHORT AddrWord;
666  UINT n;
667 
668  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
669 
670  /* Should we read from RAL/RAH first? */
671  for (n = 0; n < (IEEE_802_ADDR_LENGTH / 2); ++n)
672  {
673  if (!E1000ReadEeprom(Adapter, (UCHAR)n, &AddrWord))
674  return NDIS_STATUS_FAILURE;
675  Adapter->PermanentMacAddress[n * 2 + 0] = AddrWord & 0xff;
676  Adapter->PermanentMacAddress[n * 2 + 1] = (AddrWord >> 8) & 0xff;
677  }
678 
679  NDIS_DbgPrint(MIN_TRACE, ("MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
680  Adapter->PermanentMacAddress[0],
681  Adapter->PermanentMacAddress[1],
682  Adapter->PermanentMacAddress[2],
683  Adapter->PermanentMacAddress[3],
684  Adapter->PermanentMacAddress[4],
685  Adapter->PermanentMacAddress[5]));
686  return NDIS_STATUS_SUCCESS;
687 }
GLdouble n
Definition: glext.h:7729
#define IEEE_802_ADDR_LENGTH
Definition: e1000hw.h:11
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
unsigned char UCHAR
Definition: xmlstorage.h:181
#define MAX_TRACE
Definition: debug.h:16
unsigned short USHORT
Definition: pedump.c:61
static BOOLEAN E1000ReadEeprom(IN PE1000_ADAPTER Adapter, IN UCHAR Address, USHORT *Result)
Definition: hardware.c:162
unsigned int UINT
Definition: ndis.h:50
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define MIN_TRACE
Definition: debug.h:14
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465

Referenced by MiniportInitialize().

◆ NICInitializeAdapterResources()

NDIS_STATUS NTAPI NICInitializeAdapterResources ( IN PE1000_ADAPTER  Adapter,
IN PNDIS_RESOURCE_LIST  ResourceList 
)

Definition at line 241 of file hardware.c.

244 {
245  UINT n;
246  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
247 
248  for (n = 0; n < ResourceList->Count; n++)
249  {
250  PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor = ResourceList->PartialDescriptors + n;
251 
252  switch (ResourceDescriptor->Type)
253  {
254  case CmResourceTypePort:
255  ASSERT(Adapter->IoPortAddress == 0);
256  ASSERT(ResourceDescriptor->u.Port.Start.HighPart == 0);
257 
258  Adapter->IoPortAddress = ResourceDescriptor->u.Port.Start.LowPart;
259  Adapter->IoPortLength = ResourceDescriptor->u.Port.Length;
260 
261  NDIS_DbgPrint(MID_TRACE, ("I/O port range is %p to %p\n",
262  Adapter->IoPortAddress,
263  Adapter->IoPortAddress + Adapter->IoPortLength));
264  break;
266  ASSERT(Adapter->InterruptVector == 0);
267  ASSERT(Adapter->InterruptLevel == 0);
268 
269  Adapter->InterruptVector = ResourceDescriptor->u.Interrupt.Vector;
270  Adapter->InterruptLevel = ResourceDescriptor->u.Interrupt.Level;
271  Adapter->InterruptShared = (ResourceDescriptor->ShareDisposition == CmResourceShareShared);
272  Adapter->InterruptFlags = ResourceDescriptor->Flags;
273 
274  NDIS_DbgPrint(MID_TRACE, ("IRQ vector is %d\n", Adapter->InterruptVector));
275  break;
277  /* Internal registers and memories (including PHY) */
278  if (ResourceDescriptor->u.Memory.Length == (128 * 1024))
279  {
280  ASSERT(Adapter->IoAddress.LowPart == 0);
281  ASSERT(ResourceDescriptor->u.Port.Start.HighPart == 0);
282 
283 
284  Adapter->IoAddress.QuadPart = ResourceDescriptor->u.Memory.Start.QuadPart;
285  Adapter->IoLength = ResourceDescriptor->u.Memory.Length;
286  NDIS_DbgPrint(MID_TRACE, ("Memory range is %I64x to %I64x\n",
287  Adapter->IoAddress.QuadPart,
288  Adapter->IoAddress.QuadPart + Adapter->IoLength));
289  }
290  break;
291 
292  default:
293  NDIS_DbgPrint(MIN_TRACE, ("Unrecognized resource type: 0x%x\n", ResourceDescriptor->Type));
294  break;
295  }
296  }
297 
298  if (Adapter->IoAddress.QuadPart == 0 || Adapter->IoPortAddress == 0 || Adapter->InterruptVector == 0)
299  {
300  NDIS_DbgPrint(MIN_TRACE, ("Adapter didn't receive enough resources\n"));
301  return NDIS_STATUS_RESOURCES;
302  }
303 
304  return NDIS_STATUS_SUCCESS;
305 }
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@377::@380 Interrupt
#define MID_TRACE
Definition: debug.h:15
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@377::@382 Memory
GLdouble n
Definition: glext.h:7729
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:304
#define CmResourceTypePort
Definition: hwresource.cpp:123
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@377 u
#define ASSERT(a)
Definition: mode.c:44
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define MAX_TRACE
Definition: debug.h:16
unsigned int UINT
Definition: ndis.h:50
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
#define MIN_TRACE
Definition: debug.h:14
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@377::@379 Port
#define CmResourceTypeMemory
Definition: hwresource.cpp:125

Referenced by MiniportInitialize().

◆ NICPowerOn()

NDIS_STATUS NTAPI NICPowerOn ( IN PE1000_ADAPTER  Adapter)

Definition at line 509 of file hardware.c.

511 {
513  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
514 
515  Status = NICSoftReset(Adapter);
517  {
518  return Status;
519  }
520 
521  if (!E1000ValidateNvmChecksum(Adapter))
522  {
524  }
525 
526  return NDIS_STATUS_SUCCESS;
527 }
NDIS_STATUS NTAPI NICSoftReset(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:531
int NDIS_STATUS
Definition: ntddndis.h:471
#define NDIS_STATUS_INVALID_DATA
Definition: ndis.h:486
Status
Definition: gdiplustypes.h:24
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
BOOLEAN E1000ValidateNvmChecksum(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:187

Referenced by MiniportInitialize().

◆ NICRecognizeHardware()

BOOLEAN NTAPI NICRecognizeHardware ( IN PE1000_ADAPTER  Adapter)

Definition at line 214 of file hardware.c.

216 {
217  UINT n;
218  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
219 
220  if (Adapter->VendorID != HW_VENDOR_INTEL)
221  {
222  NDIS_DbgPrint(MIN_TRACE, ("Unknown vendor: 0x%x\n", Adapter->VendorID));
223  return FALSE;
224  }
225 
226  for (n = 0; n < ARRAYSIZE(SupportedDevices); ++n)
227  {
228  if (SupportedDevices[n] == Adapter->DeviceID)
229  {
230  return TRUE;
231  }
232  }
233 
234  NDIS_DbgPrint(MIN_TRACE, ("Unknown device: 0x%x\n", Adapter->DeviceID));
235 
236  return FALSE;
237 }
static USHORT SupportedDevices[]
Definition: hardware.c:14
#define TRUE
Definition: types.h:120
GLdouble n
Definition: glext.h:7729
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define FALSE
Definition: types.h:117
#define MAX_TRACE
Definition: debug.h:16
unsigned int UINT
Definition: ndis.h:50
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define MIN_TRACE
Definition: debug.h:14

Referenced by MiniportInitialize().

◆ NICRegisterInterrupts()

NDIS_STATUS NTAPI NICRegisterInterrupts ( IN PE1000_ADAPTER  Adapter)

Definition at line 392 of file hardware.c.

394 {
396  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
397 
398  Status = NdisMRegisterInterrupt(&Adapter->Interrupt,
399  Adapter->AdapterHandle,
400  Adapter->InterruptVector,
401  Adapter->InterruptLevel,
402  TRUE, // We always want ISR calls
403  Adapter->InterruptShared,
404  (Adapter->InterruptFlags & CM_RESOURCE_INTERRUPT_LATCHED) ?
406 
408  {
409  Adapter->InterruptRegistered = TRUE;
410  }
411 
412  return Status;
413 }
#define NdisInterruptLevelSensitive
Definition: ndis.h:920
#define TRUE
Definition: types.h:120
int NDIS_STATUS
Definition: ntddndis.h:471
NDIS_STATUS EXPORT NdisMRegisterInterrupt(OUT PNDIS_MINIPORT_INTERRUPT Interrupt, IN NDIS_HANDLE MiniportAdapterHandle, IN UINT InterruptVector, IN UINT InterruptLevel, IN BOOLEAN RequestIsr, IN BOOLEAN SharedInterrupt, IN NDIS_INTERRUPT_MODE InterruptMode)
Definition: io.c:941
Status
Definition: gdiplustypes.h:24
#define NdisInterruptLatched
Definition: ndis.h:921
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144

Referenced by MiniportInitialize().

◆ NICReleaseIoResources()

NDIS_STATUS NTAPI NICReleaseIoResources ( IN PE1000_ADAPTER  Adapter)

Definition at line 433 of file hardware.c.

435 {
436  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
437 
438  if (Adapter->ReceiveDescriptors != NULL)
439  {
440  /* Disassociate our shared buffer before freeing it to avoid NIC-induced memory corruption */
441  if (Adapter->IoBase)
442  {
443  E1000WriteUlong(Adapter, E1000_REG_RDH, 0);
444  E1000WriteUlong(Adapter, E1000_REG_RDT, 0);
445  }
446 
447  NdisMFreeSharedMemory(Adapter->AdapterHandle,
449  FALSE,
450  Adapter->ReceiveDescriptors,
451  Adapter->ReceiveDescriptorsPa);
452 
453  Adapter->ReceiveDescriptors = NULL;
454  }
455 
456  if (Adapter->ReceiveBuffer != NULL)
457  {
458  NdisMFreeSharedMemory(Adapter->AdapterHandle,
459  Adapter->ReceiveBufferEntrySize * NUM_RECEIVE_DESCRIPTORS,
460  FALSE,
461  Adapter->ReceiveBuffer,
462  Adapter->ReceiveBufferPa);
463 
464  Adapter->ReceiveBuffer = NULL;
465  Adapter->ReceiveBufferEntrySize = 0;
466  }
467 
468 
469  if (Adapter->TransmitDescriptors != NULL)
470  {
471  /* Disassociate our shared buffer before freeing it to avoid NIC-induced memory corruption */
472  if (Adapter->IoBase)
473  {
474  E1000WriteUlong(Adapter, E1000_REG_TDH, 0);
475  E1000WriteUlong(Adapter, E1000_REG_TDT, 0);
476  }
477 
478  NdisMFreeSharedMemory(Adapter->AdapterHandle,
480  FALSE,
481  Adapter->TransmitDescriptors,
482  Adapter->TransmitDescriptorsPa);
483 
484  Adapter->TransmitDescriptors = NULL;
485  }
486 
487 
488 
489  if (Adapter->IoPort)
490  {
491  NdisMDeregisterIoPortRange(Adapter->AdapterHandle,
492  Adapter->IoPortAddress,
493  Adapter->IoPortLength,
494  Adapter->IoPort);
495  }
496 
497  if (Adapter->IoBase)
498  {
499  NdisMUnmapIoSpace(Adapter->AdapterHandle, Adapter->IoBase, Adapter->IoLength);
500  }
501 
502 
503  return NDIS_STATUS_SUCCESS;
504 }
#define E1000_REG_RDH
Definition: e1000hw.h:132
FORCEINLINE VOID E1000WriteUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:219
#define NUM_RECEIVE_DESCRIPTORS
Definition: e1000hw.h:109
#define E1000_REG_TDH
Definition: e1000hw.h:140
VOID EXPORT NdisMUnmapIoSpace(IN NDIS_HANDLE MiniportAdapterHandle, IN PVOID VirtualAddress, IN UINT Length)
Definition: io.c:1139
#define NUM_TRANSMIT_DESCRIPTORS
Definition: e1000hw.h:108
VOID EXPORT NdisMFreeSharedMemory(IN NDIS_HANDLE MiniportAdapterHandle, IN ULONG Length, IN BOOLEAN Cached, IN PVOID VirtualAddress, IN NDIS_PHYSICAL_ADDRESS PhysicalAddress)
Definition: memory.c:215
#define E1000_REG_RDT
Definition: e1000hw.h:133
#define FALSE
Definition: types.h:117
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define E1000_REG_TDT
Definition: e1000hw.h:141
#define MAX_TRACE
Definition: debug.h:16
#define NULL
Definition: types.h:112
VOID EXPORT NdisMDeregisterIoPortRange(IN NDIS_HANDLE MiniportAdapterHandle, IN UINT InitialPort, IN UINT NumberOfPorts, IN PVOID PortOffset)
Definition: io.c:1093
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40

Referenced by MiniportHalt().

◆ NICSoftReset()

NDIS_STATUS NTAPI NICSoftReset ( IN PE1000_ADAPTER  Adapter)

Definition at line 531 of file hardware.c.

533 {
534  ULONG Value, ResetAttempts;
535  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
536 
537  NICDisableInterrupts(Adapter);
538  E1000WriteUlong(Adapter, E1000_REG_RCTL, 0);
539  E1000WriteUlong(Adapter, E1000_REG_TCTL, 0);
540  E1000ReadUlong(Adapter, E1000_REG_CTRL, &Value);
541  /* Write this using IO port, some devices cannot ack this otherwise */
543 
544 
545  for (ResetAttempts = 0; ResetAttempts < MAX_RESET_ATTEMPTS; ResetAttempts++)
546  {
547  /* Wait 1us after reset (according to manual) */
549  E1000ReadUlong(Adapter, E1000_REG_CTRL, &Value);
550 
551  if (!(Value & E1000_CTRL_RST))
552  {
553  NDIS_DbgPrint(MAX_TRACE, ("Device is back (%u)\n", ResetAttempts));
554 
555  NICDisableInterrupts(Adapter);
556  /* Clear out interrupts (the register is cleared upon read) */
557  E1000ReadUlong(Adapter, E1000_REG_ICR, &Value);
558 
559  E1000ReadUlong(Adapter, E1000_REG_CTRL, &Value);
563 
564  return NDIS_STATUS_SUCCESS;
565  }
566  }
567 
568  NDIS_DbgPrint(MIN_TRACE, ("Device did not recover\n"));
569  return NDIS_STATUS_FAILURE;
570 }
#define E1000_CTRL_RST
Definition: e1000hw.h:154
#define E1000_REG_RCTL
Definition: e1000hw.h:125
FORCEINLINE VOID E1000WriteUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:219
#define E1000_CTRL_VME
Definition: e1000hw.h:155
FORCEINLINE VOID E1000WriteIoUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:229
NDIS_STATUS NTAPI NICDisableInterrupts(IN PRTL_ADAPTER Adapter)
Definition: hardware.c:141
#define E1000_CTRL_ASDE
Definition: e1000hw.h:152
#define E1000_REG_CTRL
Definition: e1000hw.h:114
#define E1000_REG_TCTL
Definition: e1000hw.h:126
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
#define E1000_REG_ICR
Definition: e1000hw.h:119
#define E1000_CTRL_SLU
Definition: e1000hw.h:153
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
FORCEINLINE VOID E1000ReadUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _Out_ PULONG Value)
Definition: nic.h:209
#define MAX_TRACE
Definition: debug.h:16
#define MAX_RESET_ATTEMPTS
Definition: e1000hw.h:15
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
unsigned int ULONG
Definition: retypes.h:1
#define MIN_TRACE
Definition: debug.h:14
#define NdisStallExecution
Definition: ndis.h:4453
#define E1000_CTRL_LRST
Definition: e1000hw.h:151
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465

Referenced by MiniportInitialize(), and NICPowerOn().

◆ NICUnregisterInterrupts()

NDIS_STATUS NTAPI NICUnregisterInterrupts ( IN PE1000_ADAPTER  Adapter)

Definition at line 417 of file hardware.c.

419 {
420  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
421 
422  if (Adapter->InterruptRegistered)
423  {
424  NdisMDeregisterInterrupt(&Adapter->Interrupt);
425  Adapter->InterruptRegistered = FALSE;
426  }
427 
428  return NDIS_STATUS_SUCCESS;
429 }
#define FALSE
Definition: types.h:117
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
VOID EXPORT NdisMDeregisterInterrupt(IN PNDIS_MINIPORT_INTERRUPT Interrupt)
Definition: io.c:700

Referenced by MiniportHalt().

◆ NICUpdateLinkStatus()

VOID NTAPI NICUpdateLinkStatus ( IN PE1000_ADAPTER  Adapter)

Definition at line 738 of file hardware.c.

740 {
741  ULONG DeviceStatus;
742  SIZE_T SpeedIndex;
743  static ULONG SpeedValues[] = { 10, 100, 1000, 1000 };
744 
745  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
746 
747  E1000ReadUlong(Adapter, E1000_REG_STATUS, &DeviceStatus);
748  Adapter->MediaState = (DeviceStatus & E1000_STATUS_LU) ? NdisMediaStateConnected : NdisMediaStateDisconnected;
749  SpeedIndex = (DeviceStatus & E1000_STATUS_SPEEDMASK) >> E1000_STATUS_SPEEDSHIFT;
750  Adapter->LinkSpeedMbps = SpeedValues[SpeedIndex];
751 }
#define E1000_STATUS_SPEEDSHIFT
Definition: e1000hw.h:161
#define E1000_REG_STATUS
Definition: e1000hw.h:115
#define E1000_STATUS_SPEEDMASK
Definition: e1000hw.h:162
#define E1000_STATUS_LU
Definition: e1000hw.h:160
ULONG_PTR SIZE_T
Definition: typedefs.h:80
FORCEINLINE VOID E1000ReadUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _Out_ PULONG Value)
Definition: nic.h:209
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
unsigned int ULONG
Definition: retypes.h:1

Referenced by MiniportHandleInterrupt(), MiniportInitialize(), and MiniportISR().

◆ NICUpdateMulticastList()

NDIS_STATUS NTAPI NICUpdateMulticastList ( IN PE1000_ADAPTER  Adapter)

Definition at line 691 of file hardware.c.

693 {
694  UINT n;
695  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
696 
697  // FIXME: Use 'Adapter->MulticastListSize'? Check the datasheet
698  for (n = 0; n < MAXIMUM_MULTICAST_ADDRESSES; ++n)
699  {
700  ULONG Ral = *(ULONG *)Adapter->MulticastList[n].MacAddress;
701  ULONG Rah = *(USHORT *)&Adapter->MulticastList[n].MacAddress[4];
702 
703  if (Rah || Ral)
704  {
705  Rah |= E1000_RAH_AV;
706 
707  E1000WriteUlong(Adapter, E1000_REG_RAL + (8*n), Ral);
708  E1000WriteUlong(Adapter, E1000_REG_RAH + (8*n), Rah);
709  }
710  else
711  {
712  E1000WriteUlong(Adapter, E1000_REG_RAH + (8*n), 0);
713  E1000WriteUlong(Adapter, E1000_REG_RAL + (8*n), 0);
714  }
715  }
716 
717  return NDIS_STATUS_SUCCESS;
718 }
#define MAXIMUM_MULTICAST_ADDRESSES
Definition: e1000hw.h:23
FORCEINLINE VOID E1000WriteUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:219
GLdouble n
Definition: glext.h:7729
#define E1000_REG_RAH
Definition: e1000hw.h:147
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define E1000_RAH_AV
Definition: e1000hw.h:221
#define MAX_TRACE
Definition: debug.h:16
unsigned short USHORT
Definition: pedump.c:61
unsigned int UINT
Definition: ndis.h:50
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
unsigned int ULONG
Definition: retypes.h:1
#define E1000_REG_RAL
Definition: e1000hw.h:146

Referenced by MiniportInitialize(), and MiniportSetInformation().