ReactOS  0.4.14-dev-317-g96040ec
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)
 
NDIS_STATUS NTAPI NICApplyInterruptMask (IN PE1000_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICDisableInterrupts (IN PE1000_ADAPTER Adapter)
 
ULONG NTAPI NICInterruptRecognized (IN PE1000_ADAPTER Adapter, OUT PBOOLEAN InterruptRecognized)
 
VOID NTAPI NICUpdateLinkStatus (IN PE1000_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICTransmitPacket (IN PE1000_ADAPTER Adapter, IN PHYSICAL_ADDRESS PhysicalAddress, IN ULONG Length)
 
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)
 
VOID NTAPI E1000ReadUlong (IN PE1000_ADAPTER Adapter, IN ULONG Address, OUT PULONG Value)
 
VOID NTAPI E1000WriteUlong (IN PE1000_ADAPTER Adapter, IN ULONG Address, IN ULONG Value)
 

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()

VOID NTAPI E1000ReadUlong ( IN PE1000_ADAPTER  Adapter,
IN ULONG  Address,
OUT PULONG  Value 
)

Definition at line 70 of file hardware.c.

71 {
72  NdisReadRegisterUlong((PULONG)(Adapter->IoBase + Address), Value);
73 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
static WCHAR Address[46]
Definition: ping.c:68
unsigned int * PULONG
Definition: retypes.h:1
#define NdisReadRegisterUlong(Register, Data)
Definition: ndis.h:4267

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

◆ E1000WriteUlong()

VOID NTAPI E1000WriteUlong ( IN PE1000_ADAPTER  Adapter,
IN ULONG  Address,
IN ULONG  Value 
)

Definition at line 65 of file hardware.c.

66 {
67  NdisWriteRegisterUlong((PULONG)(Adapter->IoBase + Address), Value);
68 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#define NdisWriteRegisterUlong(Register, Data)
Definition: ndis.h:4294
static WCHAR Address[46]
Definition: ping.c:68
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 40 of file interrupt.c.

42 {
43  ULONG InterruptPending;
44  PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
45  volatile PE1000_TRANSMIT_DESCRIPTOR TransmitDescriptor;
46 
47  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
48 
49  InterruptPending = InterlockedExchange(&Adapter->InterruptPending, 0);
50 
51 
52  /* Link State Changed */
53  if (InterruptPending & E1000_IMS_LSC)
54  {
55  ULONG Status;
56 
57  InterruptPending &= ~E1000_IMS_LSC;
58  NDIS_DbgPrint(MAX_TRACE, ("Link status changed!.\n"));
59 
60  NICUpdateLinkStatus(Adapter);
61 
63 
66  }
67 
68  /* Handling receive interrupts */
69  if (InterruptPending & (E1000_IMS_RXDMT0 | E1000_IMS_RXT0))
70  {
71  volatile PE1000_RECEIVE_DESCRIPTOR ReceiveDescriptor;
72  PETH_HEADER EthHeader;
73  ULONG BufferOffset;
74  BOOLEAN bGotAny = FALSE;
75  ULONG RxDescHead, RxDescTail, CurrRxDesc;
76 
77  /* Clear out these interrupts */
78  InterruptPending &= ~(E1000_IMS_RXDMT0 | E1000_IMS_RXT0);
79 
80  E1000ReadUlong(Adapter, E1000_REG_RDH, &RxDescHead);
81  E1000ReadUlong(Adapter, E1000_REG_RDT, &RxDescTail);
82 
83  while (((RxDescTail + 1) % NUM_RECEIVE_DESCRIPTORS) != RxDescHead)
84  {
85  CurrRxDesc = (RxDescTail + 1) % NUM_RECEIVE_DESCRIPTORS;
86  BufferOffset = CurrRxDesc * Adapter->ReceiveBufferEntrySize;
87  ReceiveDescriptor = Adapter->ReceiveDescriptors + CurrRxDesc;
88 
89  /* Check if the hardware have released this descriptor (DD - Descriptor Done) */
90  if (!(ReceiveDescriptor->Status & E1000_RDESC_STATUS_DD))
91  {
92  /* No need to check descriptors after the first unfinished one */
93  break;
94  }
95 
96  /* Ignoring these flags for now */
97  ReceiveDescriptor->Status &= ~(E1000_RDESC_STATUS_IXSM | E1000_RDESC_STATUS_PIF);
98 
99  if (ReceiveDescriptor->Status != (E1000_RDESC_STATUS_EOP | E1000_RDESC_STATUS_DD))
100  {
101  NDIS_DbgPrint(MIN_TRACE, ("Unrecognized ReceiveDescriptor status flag: %u\n", ReceiveDescriptor->Status));
102  }
103 
104  if (ReceiveDescriptor->Length != 0 && ReceiveDescriptor->Address != 0)
105  {
106  EthHeader = (PETH_HEADER)(Adapter->ReceiveBuffer + BufferOffset);
107 
109  NULL,
110  (PCHAR)EthHeader,
111  sizeof(ETH_HEADER),
112  (PCHAR)(EthHeader + 1),
113  ReceiveDescriptor->Length - sizeof(ETH_HEADER),
114  ReceiveDescriptor->Length - sizeof(ETH_HEADER));
115 
116  bGotAny = TRUE;
117  }
118  else
119  {
120  NDIS_DbgPrint(MIN_TRACE, ("Got a NULL descriptor"));
121  }
122 
123  /* Give the descriptor back */
124  ReceiveDescriptor->Status = 0;
125 
126  RxDescTail = CurrRxDesc;
127  }
128 
129  if (bGotAny)
130  {
131  /* Write back new tail value */
132  E1000WriteUlong(Adapter, E1000_REG_RDT, RxDescTail);
133 
134  NDIS_DbgPrint(MAX_TRACE, ("Rx done (RDH: %u, RDT: %u)\n", RxDescHead, RxDescTail));
135 
137  }
138  }
139 
140  /* Handling transmit interrupts */
141  if (InterruptPending & (E1000_IMS_TXD_LOW | E1000_IMS_TXDW | E1000_IMS_TXQE))
142  {
143  PNDIS_PACKET AckPackets[40] = {0};
144  ULONG NumPackets = 0, i;
145 
146  /* Clear out these interrupts */
147  InterruptPending &= ~(E1000_IMS_TXD_LOW | E1000_IMS_TXDW | E1000_IMS_TXQE);
148 
149  while ((Adapter->TxFull || Adapter->LastTxDesc != Adapter->CurrentTxDesc) && NumPackets < ARRAYSIZE(AckPackets))
150  {
151  TransmitDescriptor = Adapter->TransmitDescriptors + Adapter->LastTxDesc;
152 
153  if (TransmitDescriptor->Status & E1000_TDESC_STATUS_DD)
154  {
155  if (Adapter->TransmitPackets[Adapter->LastTxDesc])
156  {
157  AckPackets[NumPackets++] = Adapter->TransmitPackets[Adapter->LastTxDesc];
158  Adapter->TransmitPackets[Adapter->LastTxDesc] = NULL;
159  TransmitDescriptor->Status = 0;
160  }
161 
162  Adapter->LastTxDesc = (Adapter->LastTxDesc + 1) % NUM_TRANSMIT_DESCRIPTORS;
163  Adapter->TxFull = FALSE;
164  }
165  else
166  {
167  break;
168  }
169  }
170 
171  if (NumPackets)
172  {
173  NDIS_DbgPrint(MAX_TRACE, ("Tx: (TDH: %u, TDT: %u)\n", Adapter->CurrentTxDesc, Adapter->LastTxDesc));
174  NDIS_DbgPrint(MAX_TRACE, ("Tx Done: %u packets to ack\n", NumPackets));
175 
176  for (i = 0; i < NumPackets; ++i)
177  {
178  NdisMSendComplete(Adapter->AdapterHandle, AckPackets[i], NDIS_STATUS_SUCCESS);
179  }
180  }
181  }
182 
183  ASSERT(InterruptPending == 0);
184 }
#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
#define TRUE
Definition: types.h:120
VOID NTAPI E1000ReadUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, OUT PULONG Value)
Definition: hardware.c:70
NDIS_HANDLE AdapterHandle
Definition: nic.h:31
PE1000_RECEIVE_DESCRIPTOR ReceiveDescriptors
Definition: nic.h:81
volatile PUCHAR ReceiveBuffer
Definition: nic.h:85
#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
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 E1000_REG_RDT
Definition: e1000hw.h:133
Definition: lan.h:33
#define E1000_RDESC_STATUS_EOP
Definition: e1000hw.h:61
LONG InterruptPending
Definition: nic.h:66
#define E1000_RDESC_STATUS_DD
Definition: e1000hw.h:62
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI NICUpdateLinkStatus(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:808
#define E1000_RDESC_STATUS_IXSM
Definition: e1000hw.h:60
VOID EXPORT NdisMIndicateStatusComplete(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:1580
ULONG MediaState
Definition: nic.h:43
#define NDIS_STATUS_MEDIA_CONNECT
Definition: ndis.h:361
#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:76
BOOLEAN TxFull
Definition: nic.h:77
#define NdisMEthIndicateReceive(MiniportAdapterHandle, MiniportReceiveContext, HeaderBuffer, HeaderBufferSize, LookaheadBuffer, LookaheadBufferSize, PacketSize)
Definition: ndis.h:5458
PE1000_TRANSMIT_DESCRIPTOR TransmitDescriptors
Definition: nic.h:70
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define E1000_RDESC_STATUS_PIF
Definition: e1000hw.h:59
ULONG CurrentTxDesc
Definition: nic.h:75
ULONG ReceiveBufferEntrySize
Definition: nic.h:87
PNDIS_PACKET TransmitPackets[NUM_TRANSMIT_DESCRIPTORS]
Definition: nic.h:73
#define InterlockedExchange
Definition: armddk.h:54
Status
Definition: gdiplustypes.h:24
#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
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
unsigned int ULONG
Definition: retypes.h:1
#define MIN_TRACE
Definition: debug.h:14
VOID NTAPI E1000WriteUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, IN ULONG Value)
Definition: hardware.c:65
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  Value = NICInterruptRecognized(Adapter, InterruptRecognized);
26 
27  if (!(*InterruptRecognized))
28  {
29  /* This is not ours. */
30  *QueueMiniportHandleInterrupt = FALSE;
31  return;
32  }
33 
34  /* Mark the events pending service */
35  *QueueMiniportHandleInterrupt = TRUE;
36 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#define TRUE
Definition: types.h:120
struct _E1000_ADAPTER * PE1000_ADAPTER
ULONG NTAPI NICInterruptRecognized(IN PE1000_ADAPTER Adapter, OUT PBOOLEAN InterruptRecognized)
Definition: hardware.c:790
LONG InterruptPending
Definition: nic.h:66
#define InterlockedOr
Definition: interlocked.h:224
unsigned int ULONG
Definition: retypes.h:1

◆ 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

◆ NICAllocateIoResources()

NDIS_STATUS NTAPI NICAllocateIoResources ( IN PE1000_ADAPTER  Adapter)

Definition at line 340 of file hardware.c.

342 {
345  UINT n;
346 
347  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
348 
349  Status = NdisMRegisterIoPortRange((PVOID*)&Adapter->IoPort,
350  Adapter->AdapterHandle,
351  Adapter->IoPortAddress,
352  Adapter->IoPortLength);
354  {
355  NDIS_DbgPrint(MIN_TRACE, ("Unable to register IO port range (0x%x)\n", Status));
356  return NDIS_STATUS_RESOURCES;
357  }
358 
359  Status = NdisMMapIoSpace((PVOID*)&Adapter->IoBase,
360  Adapter->AdapterHandle,
361  Adapter->IoAddress,
362  Adapter->IoLength);
363 
364 
365  NdisMAllocateSharedMemory(Adapter->AdapterHandle,
367  FALSE,
368  (PVOID*)&Adapter->TransmitDescriptors,
369  &Adapter->TransmitDescriptorsPa);
370  if (Adapter->TransmitDescriptors == NULL)
371  {
372  NDIS_DbgPrint(MIN_TRACE, ("Unable to allocate transmit descriptors\n"));
373  return NDIS_STATUS_RESOURCES;
374  }
375 
376  for (n = 0; n < NUM_TRANSMIT_DESCRIPTORS; ++n)
377  {
378  PE1000_TRANSMIT_DESCRIPTOR Descriptor = Adapter->TransmitDescriptors + n;
379  Descriptor->Address = 0;
380  Descriptor->Length = 0;
381  }
382 
383  NdisMAllocateSharedMemory(Adapter->AdapterHandle,
385  FALSE,
386  (PVOID*)&Adapter->ReceiveDescriptors,
387  &Adapter->ReceiveDescriptorsPa);
388  if (Adapter->ReceiveDescriptors == NULL)
389  {
390  NDIS_DbgPrint(MIN_TRACE, ("Unable to allocate receive descriptors\n"));
391  return NDIS_STATUS_RESOURCES;
392  }
393 
394  AllocationSize = RcvBufAllocationSize(Adapter->ReceiveBufferType);
395  ASSERT(Adapter->ReceiveBufferEntrySize == 0 || Adapter->ReceiveBufferEntrySize == AllocationSize);
396  Adapter->ReceiveBufferEntrySize = AllocationSize;
397 
398  NdisMAllocateSharedMemory(Adapter->AdapterHandle,
399  Adapter->ReceiveBufferEntrySize * NUM_RECEIVE_DESCRIPTORS,
400  FALSE,
401  (PVOID*)&Adapter->ReceiveBuffer,
402  &Adapter->ReceiveBufferPa);
403 
404  if (Adapter->ReceiveBuffer == NULL)
405  {
406  NDIS_DbgPrint(MIN_TRACE, ("Unable to allocate receive buffer\n"));
407  return NDIS_STATUS_RESOURCES;
408  }
409 
410  for (n = 0; n < NUM_RECEIVE_DESCRIPTORS; ++n)
411  {
412  PE1000_RECEIVE_DESCRIPTOR Descriptor = Adapter->ReceiveDescriptors + n;
413 
415  Descriptor->Address = Adapter->ReceiveBufferPa.QuadPart + n * Adapter->ReceiveBufferEntrySize;
416  }
417 
418  return NDIS_STATUS_SUCCESS;
419 }
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
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
static ULONG RcvBufAllocationSize(E1000_RCVBUF_SIZE BufSize)
Definition: hardware.c:112
Status
Definition: gdiplustypes.h:24
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
Definition: fatprocs.h:310
#define MAX_TRACE
Definition: debug.h:16
unsigned int UINT
Definition: ndis.h:50
#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:261
#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
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

Referenced by MiniportInitialize().

◆ NICApplyInterruptMask()

NDIS_STATUS NTAPI NICApplyInterruptMask ( IN PE1000_ADAPTER  Adapter)

Definition at line 768 of file hardware.c.

770 {
771  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
772 
773  E1000WriteUlong(Adapter, E1000_REG_IMS, Adapter->InterruptMask /*| 0x1F6DC*/);
774  return NDIS_STATUS_SUCCESS;
775 }
#define E1000_REG_IMS
Definition: e1000hw.h:122
#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 NTAPI E1000WriteUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, IN ULONG Value)
Definition: hardware.c:65

Referenced by MiniportInitialize().

◆ NICApplyPacketFilter()

NDIS_STATUS NTAPI NICApplyPacketFilter ( IN PE1000_ADAPTER  Adapter)

Definition at line 752 of file hardware.c.

754 {
755  ULONG FilterMask;
756 
757  E1000ReadUlong(Adapter, E1000_REG_RCTL, &FilterMask);
758 
759  FilterMask &= ~E1000_RCTL_FILTER_BITS;
760  FilterMask |= PacketFilterToMask(Adapter->PacketFilter);
761  E1000WriteUlong(Adapter, E1000_REG_RCTL, FilterMask);
762 
763  return NDIS_STATUS_SUCCESS;
764 }
static ULONG PacketFilterToMask(ULONG PacketFilter)
Definition: hardware.c:82
VOID NTAPI E1000ReadUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, OUT PULONG Value)
Definition: hardware.c:70
#define E1000_REG_RCTL
Definition: e1000hw.h:125
#define E1000_RCTL_FILTER_BITS
Definition: e1000hw.h:207
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI E1000WriteUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, IN ULONG Value)
Definition: hardware.c:65

Referenced by MiniportSetInformation().

◆ NICDisableInterrupts()

NDIS_STATUS NTAPI NICDisableInterrupts ( IN PE1000_ADAPTER  Adapter)

Definition at line 779 of file hardware.c.

781 {
782  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
783 
784  E1000WriteUlong(Adapter, E1000_REG_IMC, ~0);
785  return NDIS_STATUS_SUCCESS;
786 }
#define E1000_REG_IMC
Definition: e1000hw.h:123
#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 NTAPI E1000WriteUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, IN ULONG Value)
Definition: hardware.c:65

Referenced by NICSoftReset().

◆ NICDisableTxRx()

NDIS_STATUS NTAPI NICDisableTxRx ( IN PE1000_ADAPTER  Adapter)

Definition at line 672 of file hardware.c.

674 {
675  ULONG Value;
676 
677  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
678 
679  E1000ReadUlong(Adapter, E1000_REG_TCTL, &Value);
680  Value &= ~E1000_TCTL_EN;
682 
683  E1000ReadUlong(Adapter, E1000_REG_RCTL, &Value);
684  Value &= ~E1000_RCTL_EN;
686 
687  return NDIS_STATUS_SUCCESS;
688 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
VOID NTAPI E1000ReadUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, OUT PULONG Value)
Definition: hardware.c:70
#define E1000_TCTL_EN
Definition: e1000hw.h:211
#define E1000_REG_RCTL
Definition: e1000hw.h:125
#define E1000_REG_TCTL
Definition: e1000hw.h:126
#define E1000_RCTL_EN
Definition: e1000hw.h:197
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI E1000WriteUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, IN ULONG Value)
Definition: hardware.c:65

Referenced by MiniportHalt().

◆ NICEnableTxRx()

NDIS_STATUS NTAPI NICEnableTxRx ( IN PE1000_ADAPTER  Adapter)

Definition at line 605 of file hardware.c.

607 {
608  ULONG Value;
609 
610  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
611  NDIS_DbgPrint(MID_TRACE, ("Setting up transmit.\n"));
612 
613  /* Make sure the thing is disabled first. */
614  E1000WriteUlong(Adapter, E1000_REG_TCTL, 0);
615 
616  /* Transmit descriptor ring buffer */
617  E1000WriteUlong(Adapter, E1000_REG_TDBAH, Adapter->TransmitDescriptorsPa.HighPart);
618  E1000WriteUlong(Adapter, E1000_REG_TDBAL, Adapter->TransmitDescriptorsPa.LowPart);
619 
620  /* Transmit descriptor buffer size */
622 
623  /* Transmit descriptor tail / head */
624  E1000WriteUlong(Adapter, E1000_REG_TDH, 0);
625  E1000WriteUlong(Adapter, E1000_REG_TDT, 0);
626  Adapter->CurrentTxDesc = 0;
627 
628  /* Set up interrupt timers */
629  E1000WriteUlong(Adapter, E1000_REG_TADV, 96); // value is in 1.024 of usec
630  E1000WriteUlong(Adapter, E1000_REG_TIDV, 16);
631 
633 
635 
636  NDIS_DbgPrint(MID_TRACE, ("Setting up receive.\n"));
637 
638  /* Make sure the thing is disabled first. */
639  E1000WriteUlong(Adapter, E1000_REG_RCTL, 0);
640 
641  /* Receive descriptor ring buffer */
642  E1000WriteUlong(Adapter, E1000_REG_RDBAH, Adapter->ReceiveDescriptorsPa.HighPart);
643  E1000WriteUlong(Adapter, E1000_REG_RDBAL, Adapter->ReceiveDescriptorsPa.LowPart);
644 
645  /* Receive descriptor buffer size */
647 
648  /* Receive descriptor tail / head */
649  E1000WriteUlong(Adapter, E1000_REG_RDH, 0);
651 
652  /* Set up interrupt timers */
653  E1000WriteUlong(Adapter, E1000_REG_RADV, 96);
654  E1000WriteUlong(Adapter, E1000_REG_RDTR, 16);
655 
656  /* Some defaults */
658 
659  /* Receive buffer size */
660  Value |= RcvBufRegisterMask(Adapter->ReceiveBufferType);
661 
662  /* Add our current packet filter */
663  Value |= PacketFilterToMask(Adapter->PacketFilter);
664 
666 
667  return NDIS_STATUS_SUCCESS;
668 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
static ULONG PacketFilterToMask(ULONG PacketFilter)
Definition: hardware.c:82
#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
#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
#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:128
#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
VOID NTAPI E1000WriteUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, IN ULONG Value)
Definition: hardware.c:65
#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 692 of file hardware.c.

695 {
696  USHORT AddrWord;
697  UINT n;
698 
699  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
700 
701  /* Should we read from RAL/RAH first? */
702  for (n = 0; n < (IEEE_802_ADDR_LENGTH / 2); ++n)
703  {
704  if (!E1000ReadEeprom(Adapter, (UCHAR)n, &AddrWord))
705  return NDIS_STATUS_FAILURE;
706  Adapter->PermanentMacAddress[n * 2 + 0] = AddrWord & 0xff;
707  Adapter->PermanentMacAddress[n * 2 + 1] = (AddrWord >> 8) & 0xff;
708  }
709 
710  NDIS_DbgPrint(MIN_TRACE, ("MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
711  Adapter->PermanentMacAddress[0],
712  Adapter->PermanentMacAddress[1],
713  Adapter->PermanentMacAddress[2],
714  Adapter->PermanentMacAddress[3],
715  Adapter->PermanentMacAddress[4],
716  Adapter->PermanentMacAddress[5]));
717  return NDIS_STATUS_SUCCESS;
718 }
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:193
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 272 of file hardware.c.

275 {
276  UINT n;
277  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
278 
279  for (n = 0; n < ResourceList->Count; n++)
280  {
281  PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor = ResourceList->PartialDescriptors + n;
282 
283  switch (ResourceDescriptor->Type)
284  {
285  case CmResourceTypePort:
286  ASSERT(Adapter->IoPortAddress == 0);
287  ASSERT(ResourceDescriptor->u.Port.Start.HighPart == 0);
288 
289  Adapter->IoPortAddress = ResourceDescriptor->u.Port.Start.LowPart;
290  Adapter->IoPortLength = ResourceDescriptor->u.Port.Length;
291 
292  NDIS_DbgPrint(MID_TRACE, ("I/O port range is %p to %p\n",
293  Adapter->IoPortAddress,
294  Adapter->IoPortAddress + Adapter->IoPortLength));
295  break;
297  ASSERT(Adapter->InterruptVector == 0);
298  ASSERT(Adapter->InterruptLevel == 0);
299 
300  Adapter->InterruptVector = ResourceDescriptor->u.Interrupt.Vector;
301  Adapter->InterruptLevel = ResourceDescriptor->u.Interrupt.Level;
302  Adapter->InterruptShared = (ResourceDescriptor->ShareDisposition == CmResourceShareShared);
303  Adapter->InterruptFlags = ResourceDescriptor->Flags;
304 
305  NDIS_DbgPrint(MID_TRACE, ("IRQ vector is %d\n", Adapter->InterruptVector));
306  break;
308  /* Internal registers and memories (including PHY) */
309  if (ResourceDescriptor->u.Memory.Length == (128 * 1024))
310  {
311  ASSERT(Adapter->IoAddress.LowPart == 0);
312  ASSERT(ResourceDescriptor->u.Port.Start.HighPart == 0);
313 
314 
315  Adapter->IoAddress.QuadPart = ResourceDescriptor->u.Memory.Start.QuadPart;
316  Adapter->IoLength = ResourceDescriptor->u.Memory.Length;
317  NDIS_DbgPrint(MID_TRACE, ("Memory range is %I64x to %I64x\n",
318  Adapter->IoAddress.QuadPart,
319  Adapter->IoAddress.QuadPart + Adapter->IoLength));
320  }
321  break;
322 
323  default:
324  NDIS_DbgPrint(MIN_TRACE, ("Unrecognized resource type: 0x%x\n", ResourceDescriptor->Type));
325  break;
326  }
327  }
328 
329  if (Adapter->IoAddress.QuadPart == 0 || Adapter->IoPortAddress == 0 || Adapter->InterruptVector == 0)
330  {
331  NDIS_DbgPrint(MIN_TRACE, ("Adapter didn't receive enough resources\n"));
332  return NDIS_STATUS_RESOURCES;
333  }
334 
335  return NDIS_STATUS_SUCCESS;
336 }
#define MID_TRACE
Definition: debug.h:15
GLdouble n
Definition: glext.h:7729
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@378 u
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
#define CmResourceTypePort
Definition: hwresource.cpp:123
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@378::@380 Port
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@378::@383 Memory
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@378::@381 Interrupt
#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
#define CmResourceTypeMemory
Definition: hwresource.cpp:125

Referenced by MiniportInitialize().

◆ NICInterruptRecognized()

ULONG NTAPI NICInterruptRecognized ( IN PE1000_ADAPTER  Adapter,
OUT PBOOLEAN  InterruptRecognized 
)

Definition at line 790 of file hardware.c.

793 {
794  ULONG Value;
795 
796  /* Reading the interrupt acknowledges them */
797  E1000ReadUlong(Adapter, E1000_REG_ICR, &Value);
798 
799  *InterruptRecognized = (Value & Adapter->InterruptMask) != 0;
800 
801  NDIS_DbgPrint(MAX_TRACE, ("NICInterruptRecognized(0x%x, 0x%x).\n", Value, *InterruptRecognized));
802 
803  return (Value & Adapter->InterruptMask);
804 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
VOID NTAPI E1000ReadUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, OUT PULONG Value)
Definition: hardware.c:70
#define E1000_REG_ICR
Definition: e1000hw.h:119
#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 MiniportISR().

◆ NICPowerOn()

NDIS_STATUS NTAPI NICPowerOn ( IN PE1000_ADAPTER  Adapter)

Definition at line 540 of file hardware.c.

542 {
544  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
545 
546  Status = NICSoftReset(Adapter);
548  {
549  return Status;
550  }
551 
552  if (!E1000ValidateNvmChecksum(Adapter))
553  {
555  }
556 
557  return NDIS_STATUS_SUCCESS;
558 }
NDIS_STATUS NTAPI NICSoftReset(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:562
int NDIS_STATUS
Definition: ntddndis.h:471
#define NDIS_STATUS_INVALID_DATA
Definition: ndis.h:486
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
Status
Definition: gdiplustypes.h:24
#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:218

Referenced by MiniportInitialize().

◆ NICRecognizeHardware()

BOOLEAN NTAPI NICRecognizeHardware ( IN PE1000_ADAPTER  Adapter)

Definition at line 245 of file hardware.c.

247 {
248  UINT n;
249  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
250 
251  if (Adapter->VendorID != HW_VENDOR_INTEL)
252  {
253  NDIS_DbgPrint(MIN_TRACE, ("Unknown vendor: 0x%x\n", Adapter->VendorID));
254  return FALSE;
255  }
256 
257  for (n = 0; n < ARRAYSIZE(SupportedDevices); ++n)
258  {
259  if (SupportedDevices[n] == Adapter->DeviceID)
260  {
261  return TRUE;
262  }
263  }
264 
265  NDIS_DbgPrint(MIN_TRACE, ("Unknown device: 0x%x\n", Adapter->DeviceID));
266 
267  return FALSE;
268 }
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 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 423 of file hardware.c.

425 {
427  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
428 
429  Status = NdisMRegisterInterrupt(&Adapter->Interrupt,
430  Adapter->AdapterHandle,
431  Adapter->InterruptVector,
432  Adapter->InterruptLevel,
433  TRUE, // We always want ISR calls
434  Adapter->InterruptShared,
435  (Adapter->InterruptFlags & CM_RESOURCE_INTERRUPT_LATCHED) ?
437 
439  {
440  Adapter->InterruptRegistered = TRUE;
441  }
442 
443  return Status;
444 }
#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
#define NdisInterruptLatched
Definition: ndis.h:921
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
Status
Definition: gdiplustypes.h:24
#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 464 of file hardware.c.

466 {
467  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
468 
469  if (Adapter->ReceiveDescriptors != 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_RDH, 0);
475  E1000WriteUlong(Adapter, E1000_REG_RDT, 0);
476  }
477 
478  NdisMFreeSharedMemory(Adapter->AdapterHandle,
480  FALSE,
481  Adapter->ReceiveDescriptors,
482  Adapter->ReceiveDescriptorsPa);
483 
484  Adapter->ReceiveDescriptors = NULL;
485  }
486 
487  if (Adapter->ReceiveBuffer != NULL)
488  {
489  NdisMFreeSharedMemory(Adapter->AdapterHandle,
490  Adapter->ReceiveBufferEntrySize * NUM_RECEIVE_DESCRIPTORS,
491  FALSE,
492  Adapter->ReceiveBuffer,
493  Adapter->ReceiveBufferPa);
494 
495  Adapter->ReceiveBuffer = NULL;
496  Adapter->ReceiveBufferEntrySize = 0;
497  }
498 
499 
500  if (Adapter->TransmitDescriptors != NULL)
501  {
502  /* Disassociate our shared buffer before freeing it to avoid NIC-induced memory corruption */
503  if (Adapter->IoBase)
504  {
505  E1000WriteUlong(Adapter, E1000_REG_TDH, 0);
506  E1000WriteUlong(Adapter, E1000_REG_TDT, 0);
507  }
508 
509  NdisMFreeSharedMemory(Adapter->AdapterHandle,
511  FALSE,
512  Adapter->TransmitDescriptors,
513  Adapter->TransmitDescriptorsPa);
514 
515  Adapter->TransmitDescriptors = NULL;
516  }
517 
518 
519 
520  if (Adapter->IoPort)
521  {
522  NdisMDeregisterIoPortRange(Adapter->AdapterHandle,
523  Adapter->IoPortAddress,
524  Adapter->IoPortLength,
525  Adapter->IoPort);
526  }
527 
528  if (Adapter->IoBase)
529  {
530  NdisMUnmapIoSpace(Adapter->AdapterHandle, Adapter->IoBase, Adapter->IoLength);
531  }
532 
533 
534  return NDIS_STATUS_SUCCESS;
535 }
#define E1000_REG_RDH
Definition: e1000hw.h:132
#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
smooth NULL
Definition: ftsmooth.c:416
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define E1000_REG_TDT
Definition: e1000hw.h:141
#define MAX_TRACE
Definition: debug.h:16
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
VOID NTAPI E1000WriteUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, IN ULONG Value)
Definition: hardware.c:65

Referenced by MiniportHalt().

◆ NICSoftReset()

NDIS_STATUS NTAPI NICSoftReset ( IN PE1000_ADAPTER  Adapter)

Definition at line 562 of file hardware.c.

564 {
565  ULONG Value, ResetAttempts;
566  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
567 
568  NICDisableInterrupts(Adapter);
569  E1000WriteUlong(Adapter, E1000_REG_RCTL, 0);
570  E1000WriteUlong(Adapter, E1000_REG_TCTL, 0);
571  E1000ReadUlong(Adapter, E1000_REG_CTRL, &Value);
572  /* Write this using IO port, some devices cannot ack this otherwise */
574 
575 
576  for (ResetAttempts = 0; ResetAttempts < MAX_RESET_ATTEMPTS; ResetAttempts++)
577  {
578  /* Wait 1us after reset (according to manual) */
580  E1000ReadUlong(Adapter, E1000_REG_CTRL, &Value);
581 
582  if (!(Value & E1000_CTRL_RST))
583  {
584  NDIS_DbgPrint(MAX_TRACE, ("Device is back (%u)\n", ResetAttempts));
585 
586  NICDisableInterrupts(Adapter);
587  /* Clear out interrupts (the register is cleared upon read) */
588  E1000ReadUlong(Adapter, E1000_REG_ICR, &Value);
589 
590  E1000ReadUlong(Adapter, E1000_REG_CTRL, &Value);
594 
595  return NDIS_STATUS_SUCCESS;
596  }
597  }
598 
599  NDIS_DbgPrint(MIN_TRACE, ("Device did not recover\n"));
600  return NDIS_STATUS_FAILURE;
601 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
VOID NTAPI E1000ReadUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, OUT PULONG Value)
Definition: hardware.c:70
#define E1000_CTRL_RST
Definition: e1000hw.h:154
#define E1000_REG_RCTL
Definition: e1000hw.h:125
#define E1000_CTRL_VME
Definition: e1000hw.h:155
#define E1000_CTRL_ASDE
Definition: e1000hw.h:152
static VOID E1000WriteIoUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, IN ULONG Value)
Definition: hardware.c:75
#define E1000_REG_CTRL
Definition: e1000hw.h:114
#define E1000_REG_TCTL
Definition: e1000hw.h:126
#define E1000_REG_ICR
Definition: e1000hw.h:119
#define E1000_CTRL_SLU
Definition: e1000hw.h:153
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define MAX_TRACE
Definition: debug.h:16
#define MAX_RESET_ATTEMPTS
Definition: e1000hw.h:15
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
NDIS_STATUS NTAPI NICDisableInterrupts(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:779
unsigned int ULONG
Definition: retypes.h:1
#define MIN_TRACE
Definition: debug.h:14
VOID NTAPI E1000WriteUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, IN ULONG Value)
Definition: hardware.c:65
#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().

◆ NICTransmitPacket()

NDIS_STATUS NTAPI NICTransmitPacket ( IN PE1000_ADAPTER  Adapter,
IN PHYSICAL_ADDRESS  PhysicalAddress,
IN ULONG  Length 
)

Definition at line 825 of file hardware.c.

829 {
830  volatile PE1000_TRANSMIT_DESCRIPTOR TransmitDescriptor;
831 
832  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
833 
834  TransmitDescriptor = Adapter->TransmitDescriptors + Adapter->CurrentTxDesc;
835  TransmitDescriptor->Address = PhysicalAddress.QuadPart;
836  TransmitDescriptor->Length = Length;
837  TransmitDescriptor->ChecksumOffset = 0;
839  TransmitDescriptor->Status = 0;
840  TransmitDescriptor->ChecksumStartField = 0;
841  TransmitDescriptor->Special = 0;
842 
843  Adapter->CurrentTxDesc = (Adapter->CurrentTxDesc + 1) % NUM_TRANSMIT_DESCRIPTORS;
844 
845  E1000WriteUlong(Adapter, E1000_REG_TDT, Adapter->CurrentTxDesc);
846 
847  if (Adapter->CurrentTxDesc == Adapter->LastTxDesc)
848  {
849  NDIS_DbgPrint(MID_TRACE, ("All TX descriptors are full now\n"));
850  Adapter->TxFull = TRUE;
851  }
852 
853  return NDIS_STATUS_SUCCESS;
854 }
#define TRUE
Definition: types.h:120
#define MID_TRACE
Definition: debug.h:15
#define E1000_TDESC_CMD_IDE
Definition: e1000hw.h:79
#define E1000_TDESC_CMD_RS
Definition: e1000hw.h:80
#define NUM_TRANSMIT_DESCRIPTORS
Definition: e1000hw.h:108
#define E1000_TDESC_CMD_EOP
Definition: e1000hw.h:82
#define E1000_TDESC_CMD_IFCS
Definition: e1000hw.h:81
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1061
#define E1000_REG_TDT
Definition: e1000hw.h:141
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
VOID NTAPI E1000WriteUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, IN ULONG Value)
Definition: hardware.c:65
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by MiniportSend().

◆ NICUnregisterInterrupts()

NDIS_STATUS NTAPI NICUnregisterInterrupts ( IN PE1000_ADAPTER  Adapter)

Definition at line 448 of file hardware.c.

450 {
451  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
452 
453  if (Adapter->InterruptRegistered)
454  {
455  NdisMDeregisterInterrupt(&Adapter->Interrupt);
456  Adapter->InterruptRegistered = FALSE;
457  }
458 
459  return NDIS_STATUS_SUCCESS;
460 }
#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 808 of file hardware.c.

810 {
811  ULONG DeviceStatus;
812  SIZE_T SpeedIndex;
813  static ULONG SpeedValues[] = { 10, 100, 1000, 1000 };
814 
815  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
816 
817  E1000ReadUlong(Adapter, E1000_REG_STATUS, &DeviceStatus);
818  Adapter->MediaState = (DeviceStatus & E1000_STATUS_LU) ? NdisMediaStateConnected : NdisMediaStateDisconnected;
819  SpeedIndex = (DeviceStatus & E1000_STATUS_SPEEDMASK) >> E1000_STATUS_SPEEDSHIFT;
820  Adapter->LinkSpeedMbps = SpeedValues[SpeedIndex];
821 }
#define E1000_STATUS_SPEEDSHIFT
Definition: e1000hw.h:161
VOID NTAPI E1000ReadUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, OUT PULONG Value)
Definition: hardware.c:70
#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:78
#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 722 of file hardware.c.

724 {
725  UINT n;
726  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
727 
728  for (n = 0; n < MAXIMUM_MULTICAST_ADDRESSES; ++n)
729  {
730  ULONG Ral = *(ULONG *)Adapter->MulticastList[n].MacAddress;
731  ULONG Rah = *(USHORT *)&Adapter->MulticastList[n].MacAddress[4];
732 
733  if (Rah || Ral)
734  {
735  Rah |= E1000_RAH_AV;
736 
737  E1000WriteUlong(Adapter, E1000_REG_RAL + (8*n), Ral);
738  E1000WriteUlong(Adapter, E1000_REG_RAH + (8*n), Rah);
739  }
740  else
741  {
742  E1000WriteUlong(Adapter, E1000_REG_RAH + (8*n), 0);
743  E1000WriteUlong(Adapter, E1000_REG_RAL + (8*n), 0);
744  }
745  }
746 
747  return NDIS_STATUS_SUCCESS;
748 }
#define MAXIMUM_MULTICAST_ADDRESSES
Definition: e1000hw.h:23
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
VOID NTAPI E1000WriteUlong(IN PE1000_ADAPTER Adapter, IN ULONG Address, IN ULONG Value)
Definition: hardware.c:65
#define E1000_REG_RAL
Definition: e1000hw.h:146

Referenced by MiniportInitialize(), and MiniportSetInformation().