ReactOS 0.4.16-dev-1946-g52006dd
nic.h File Reference
#include <ndis.h>
#include "rtlhw.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  _RTL_ADAPTER
 

Macros

#define ADAPTER_TAG   'Altr'
 
#define RESOURCE_LIST_TAG   'Rltr'
 
#define MAX_RESET_ATTEMPTS   25
 
#define RECEIVE_BUFFER_SIZE   (32768)
 
#define FULL_RECEIVE_BUFFER_SIZE   (32768 + 16 + 2048)
 
#define RECV_CRC_LENGTH   4
 
#define MINIMUM_FRAME_SIZE   60
 
#define MAXIMUM_FRAME_SIZE   1514
 
#define DRIVER_VERSION   1
 
#define RC_VAL   (0x800B780)
 
#define TC_VAL   (0x700)
 

Typedefs

typedef struct _RTL_ADAPTER RTL_ADAPTER
 
typedef struct _RTL_ADAPTERPRTL_ADAPTER
 

Functions

NDIS_STATUS NTAPI NICPowerOn (IN PRTL_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICSoftReset (IN PRTL_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICRegisterReceiveBuffer (IN PRTL_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICRemoveReceiveBuffer (IN PRTL_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICEnableTxRx (IN PRTL_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICGetPermanentMacAddress (IN PRTL_ADAPTER Adapter, OUT PUCHAR MacAddress)
 
NDIS_STATUS NTAPI NICApplyPacketFilter (IN PRTL_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICApplyInterruptMask (IN PRTL_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICDisableInterrupts (IN PRTL_ADAPTER Adapter)
 
USHORT NTAPI NICInterruptRecognized (IN PRTL_ADAPTER Adapter, OUT PBOOLEAN InterruptRecognized)
 
VOID NTAPI NICAcknowledgeInterrupts (IN PRTL_ADAPTER Adapter)
 
VOID NTAPI NICUpdateLinkStatus (IN PRTL_ADAPTER Adapter)
 
NDIS_STATUS NTAPI NICTransmitPacket (IN PRTL_ADAPTER Adapter, IN UCHAR TxDesc, IN ULONG 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)
 

Macro Definition Documentation

◆ ADAPTER_TAG

#define ADAPTER_TAG   'Altr'

Definition at line 15 of file nic.h.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1

Definition at line 28 of file nic.h.

◆ FULL_RECEIVE_BUFFER_SIZE

#define FULL_RECEIVE_BUFFER_SIZE   (32768 + 16 + 2048)

Definition at line 22 of file nic.h.

◆ MAX_RESET_ATTEMPTS

#define MAX_RESET_ATTEMPTS   25

Definition at line 18 of file nic.h.

◆ MAXIMUM_FRAME_SIZE

#define MAXIMUM_FRAME_SIZE   1514

Definition at line 26 of file nic.h.

◆ MINIMUM_FRAME_SIZE

#define MINIMUM_FRAME_SIZE   60

Definition at line 25 of file nic.h.

◆ RC_VAL

#define RC_VAL   (0x800B780)

Definition at line 31 of file nic.h.

◆ RECEIVE_BUFFER_SIZE

#define RECEIVE_BUFFER_SIZE   (32768)

Definition at line 19 of file nic.h.

◆ RECV_CRC_LENGTH

#define RECV_CRC_LENGTH   4

Definition at line 23 of file nic.h.

◆ RESOURCE_LIST_TAG

#define RESOURCE_LIST_TAG   'Rltr'

Definition at line 16 of file nic.h.

◆ TC_VAL

#define TC_VAL   (0x700)

Definition at line 34 of file nic.h.

Typedef Documentation

◆ PRTL_ADAPTER

◆ RTL_ADAPTER

Function Documentation

◆ 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 {
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
135NextReceiveDescriptor:
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 {
192 }
193 }
194 }
195
196 ASSERT(InterruptPending == 0);
197}
unsigned char BOOLEAN
#define MIN_TRACE
Definition: debug.h:14
#define MAX_TRACE
Definition: debug.h:16
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
struct _ETH_HEADER * PETH_HEADER
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
VOID NTAPI NICUpdateLinkStatus(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:740
struct _E1000_ADAPTER * PE1000_ADAPTER
FORCEINLINE VOID E1000ReadUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _Out_ PULONG Value)
Definition: nic.h:209
FORCEINLINE VOID E1000WriteUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:219
#define E1000_IMS_RXDMT0
Definition: e1000hw.h:185
#define E1000_RDESC_STATUS_PIF
Definition: e1000hw.h:59
#define E1000_RDESC_STATUS_IXSM
Definition: e1000hw.h:60
#define E1000_IMS_TXQE
Definition: e1000hw.h:183
#define E1000_IMS_LSC
Definition: e1000hw.h:184
#define E1000_RDESC_STATUS_DD
Definition: e1000hw.h:62
#define E1000_IMS_TXD_LOW
Definition: e1000hw.h:187
#define E1000_IMS_TXDW
Definition: e1000hw.h:182
#define E1000_REG_RDH
Definition: e1000hw.h:132
#define E1000_TDESC_STATUS_DD
Definition: e1000hw.h:84
#define NUM_RECEIVE_DESCRIPTORS
Definition: e1000hw.h:109
#define E1000_RDESC_STATUS_EOP
Definition: e1000hw.h:61
#define NUM_TRANSMIT_DESCRIPTORS
Definition: e1000hw.h:108
#define E1000_IMS_RXT0
Definition: e1000hw.h:186
#define E1000_REG_RDT
Definition: e1000hw.h:133
Status
Definition: gdiplustypes.h:25
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
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
#define ASSERT(a)
Definition: mode.c:44
#define NDIS_STATUS_MEDIA_CONNECT
Definition: ndis.h:361
#define NdisMEthIndicateReceiveComplete(MiniportAdapterHandle)
Definition: ndis.h:5482
#define NdisMIndicateStatusComplete(MiniportAdapterHandle)
Definition: ndis.h:5580
#define NdisMEthIndicateReceive(MiniportAdapterHandle, MiniportReceiveContext, HeaderBuffer, HeaderBufferSize, LookaheadBuffer, LookaheadBufferSize, PacketSize)
Definition: ndis.h:5458
#define NDIS_STATUS_MEDIA_DISCONNECT
Definition: ndis.h:362
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define NdisMSendComplete(MiniportAdapterHandle, Packet, Status)
Definition: ndis.h:5689
#define NdisMIndicateStatus(MiniportAdapterHandle, GeneralStatus, StatusBuffer, StatusBufferSize)
Definition: ndis.h:5570
@ NdisMediaStateConnected
Definition: ntddndis.h:491
Definition: lan.h:33
PE1000_RECEIVE_DESCRIPTOR ReceiveDescriptors
Definition: nic.h:85
ULONG LastTxDesc
Definition: nic.h:80
ULONG PacketFilter
Definition: nic.h:51
BOOLEAN TxFull
Definition: nic.h:81
ULONG ReceiveBufferEntrySize
Definition: nic.h:91
PE1000_TRANSMIT_DESCRIPTOR TransmitDescriptors
Definition: nic.h:74
ULONG MediaState
Definition: nic.h:50
PNDIS_PACKET TransmitPackets[NUM_TRANSMIT_DESCRIPTORS]
Definition: nic.h:77
NDIS_HANDLE AdapterHandle
Definition: nic.h:36
_Interlocked_ volatile LONG InterruptPending
Definition: nic.h:70
volatile PUCHAR ReceiveBuffer
Definition: nic.h:89
ULONG CurrentTxDesc
Definition: nic.h:79
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51

Referenced by DriverEntry().

◆ MiniportISR()

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

Definition at line 16 of file interrupt.c.

20{
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}
#define E1000_REG_ICR
Definition: e1000hw.h:119
long _InterlockedOr(_Interlocked_operand_ long volatile *_Value, long _Mask)
LONG InterruptMask
Definition: nic.h:67
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by DriverEntry().

◆ MiniportQueryInformation()

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

Definition at line 74 of file info.c.

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

Referenced by DriverEntry().

◆ MiniportSetInformation()

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

Definition at line 283 of file info.c.

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

Referenced by DriverEntry().

◆ NICAcknowledgeInterrupts()

VOID NTAPI NICAcknowledgeInterrupts ( IN PRTL_ADAPTER  Adapter)

Definition at line 167 of file hardware.c.

170{
171 NdisRawWritePortUshort(Adapter->IoBase + R_IS, Adapter->InterruptPending);
172}
#define NdisRawWritePortUshort(Port, Data)
Definition: ndis.h:4248
#define R_IS
Definition: rtlhw.h:54

Referenced by MiniportISR().

◆ NICApplyInterruptMask()

NDIS_STATUS NTAPI NICApplyInterruptMask ( IN PRTL_ADAPTER  Adapter)

Definition at line 131 of file hardware.c.

134{
135 NdisRawWritePortUshort(Adapter->IoBase + R_IM, Adapter->InterruptMask);
136 return NDIS_STATUS_SUCCESS;
137}
#define R_IM
Definition: rtlhw.h:53

◆ NICApplyPacketFilter()

NDIS_STATUS NTAPI NICApplyPacketFilter ( IN PRTL_ADAPTER  Adapter)

Definition at line 190 of file hardware.c.

193{
194 ULONG filterMask;
195
196 filterMask = RC_VAL;
197
198 if (Adapter->PacketFilter & NDIS_PACKET_TYPE_DIRECTED)
199 {
200 filterMask |= B_RC_APM;
201 }
202
203 if (Adapter->PacketFilter & NDIS_PACKET_TYPE_MULTICAST)
204 {
205 filterMask |= B_RC_AM;
206 }
207
208 if (Adapter->PacketFilter & NDIS_PACKET_TYPE_BROADCAST)
209 {
210 filterMask |= B_RC_AB;
211 }
212
213 if (Adapter->PacketFilter & NDIS_PACKET_TYPE_PROMISCUOUS)
214 {
215 filterMask |= B_RC_AAP;
216 }
217
218 NdisRawWritePortUlong(Adapter->IoBase + R_RC, filterMask);
219
220 return NDIS_STATUS_SUCCESS;
221}
#define NdisRawWritePortUlong(Port, Data)
Definition: ndis.h:4239
#define RC_VAL
Definition: nic.h:31
#define B_RC_APM
Definition: rtlhw.h:69
#define B_RC_AAP
Definition: rtlhw.h:68
#define R_RC
Definition: rtlhw.h:67
#define B_RC_AM
Definition: rtlhw.h:70
#define B_RC_AB
Definition: rtlhw.h:71

◆ NICDisableInterrupts()

NDIS_STATUS NTAPI NICDisableInterrupts ( IN PRTL_ADAPTER  Adapter)

Definition at line 141 of file hardware.c.

144{
145 NdisRawWritePortUshort(Adapter->IoBase + R_IM, 0);
146 return NDIS_STATUS_SUCCESS;
147}

◆ NICEnableTxRx()

NDIS_STATUS NTAPI NICEnableTxRx ( IN PRTL_ADAPTER  Adapter)

Definition at line 98 of file hardware.c.

101{
102 NdisRawWritePortUchar(Adapter->IoBase + R_CMD, B_CMD_TXE | B_CMD_RXE);
103
104 //
105 // TX and RX must be enabled before setting these
106 //
107 NdisRawWritePortUlong(Adapter->IoBase + R_RC, RC_VAL);
108 NdisRawWritePortUlong(Adapter->IoBase + R_TC, TC_VAL);
109 return NDIS_STATUS_SUCCESS;
110}
#define NdisRawWritePortUchar(Port, Data)
Definition: ndis.h:4230
#define TC_VAL
Definition: nic.h:34
#define B_CMD_TXE
Definition: rtlhw.h:47
#define B_CMD_RXE
Definition: rtlhw.h:48
#define R_TC
Definition: rtlhw.h:55
#define R_CMD
Definition: rtlhw.h:45

◆ NICGetPermanentMacAddress()

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

Definition at line 114 of file hardware.c.

118{
119 UINT i;
120
121 for (i = 0; i < IEEE_802_ADDR_LENGTH; i++)
122 {
123 NdisRawReadPortUchar(Adapter->IoBase + R_MAC + i, &MacAddress[i]);
124 }
125
126 return NDIS_STATUS_SUCCESS;
127}
#define NdisRawReadPortUchar(Port, Data)
Definition: ndis.h:4173
unsigned int UINT
Definition: ndis.h:50
#define R_MAC
Definition: rtlhw.h:17

◆ NICInterruptRecognized()

USHORT NTAPI NICInterruptRecognized ( IN PRTL_ADAPTER  Adapter,
OUT PBOOLEAN  InterruptRecognized 
)

Definition at line 151 of file hardware.c.

155{
156 USHORT interruptStatus;
157
158 NdisRawReadPortUshort(Adapter->IoBase + R_IS, &interruptStatus);
159
160 *InterruptRecognized = (interruptStatus & Adapter->InterruptMask) != 0;
161
162 return (interruptStatus & Adapter->InterruptMask);
163}
#define NdisRawReadPortUshort(Port, Data)
Definition: ndis.h:4191

Referenced by MiniportISR().

◆ NICPowerOn()

NDIS_STATUS NTAPI NICPowerOn ( IN PRTL_ADAPTER  Adapter)

Definition at line 29 of file hardware.c.

32{
33 //
34 // Send 0x00 to the CONFIG_1 register (0x52) to set the LWAKE + LWPTN to active high.
35 // This should essentially *power on* the device.
36 // -- OSDev Wiki
37 //
38 NdisRawWritePortUchar(Adapter->IoBase + R_CFG1, 0x00);
40}
#define R_CFG1
Definition: rtlhw.h:78

◆ NICRegisterReceiveBuffer()

NDIS_STATUS NTAPI NICRegisterReceiveBuffer ( IN PRTL_ADAPTER  Adapter)

Definition at line 75 of file hardware.c.

78{
79 ASSERT(NdisGetPhysicalAddressHigh(Adapter->ReceiveBufferPa) == 0);
80
81 NdisRawWritePortUlong(Adapter->IoBase + R_RXSA, Adapter->ReceiveBufferPa.LowPart);
82
84}
#define NdisGetPhysicalAddressHigh(PhysicalAddress)
Definition: ndis.h:3830
#define R_RXSA
Definition: rtlhw.h:34

Referenced by MiniportInitialize().

◆ NICRemoveReceiveBuffer()

NDIS_STATUS NTAPI NICRemoveReceiveBuffer ( IN PRTL_ADAPTER  Adapter)

Definition at line 88 of file hardware.c.

91{
92 NdisRawWritePortUlong(Adapter->IoBase + R_RXSA, 0);
94}

Referenced by MiniportHalt().

◆ NICSoftReset()

NDIS_STATUS NTAPI NICSoftReset ( IN PRTL_ADAPTER  Adapter)

Definition at line 44 of file hardware.c.

47{
48 UCHAR commandReg;
49 UINT resetAttempts;
50
51 //
52 // Sending 0x10 to the Command register (0x37) will send the RTL8139 into a software reset.
53 // Once that byte is sent, the RST bit must be checked to make sure that the chip has finished the reset.
54 // If the RST bit is high (1), then the reset is still in operation.
55 // -- OSDev Wiki
56 NdisRawWritePortUchar(Adapter->IoBase + R_CMD, B_CMD_RST);
57
58 for (resetAttempts = 0; resetAttempts < MAX_RESET_ATTEMPTS; resetAttempts++)
59 {
60 NdisRawReadPortUchar(Adapter->IoBase + R_CMD, &commandReg);
61
62 if (!(commandReg & B_CMD_RST))
63 {
65 }
66
67 NdisMSleep(100);
68 }
69
71}
#define MAX_RESET_ATTEMPTS
Definition: e1000hw.h:15
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465
VOID EXPORT NdisMSleep(IN ULONG MicrosecondsToSleep)
Definition: miniport.c:2933
#define B_CMD_RST
Definition: rtlhw.h:49

◆ NICTransmitPacket()

NDIS_STATUS NTAPI NICTransmitPacket ( IN PRTL_ADAPTER  Adapter,
IN UCHAR  TxDesc,
IN ULONG  PhysicalAddress,
IN ULONG  Length 
)

Definition at line 225 of file hardware.c.

231{
232 NdisRawWritePortUlong(Adapter->IoBase + R_TXSAD0 + (TxDesc * sizeof(ULONG)), PhysicalAddress);
233 NdisRawWritePortUlong(Adapter->IoBase + R_TXSTS0 + (TxDesc * sizeof(ULONG)), Length);
234 return NDIS_STATUS_SUCCESS;
235}
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define R_TXSAD0
Definition: rtlhw.h:30
#define R_TXSTS0
Definition: rtlhw.h:26
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098

◆ NICUpdateLinkStatus()

VOID NTAPI NICUpdateLinkStatus ( IN PRTL_ADAPTER  Adapter)

Definition at line 176 of file hardware.c.

179{
180 UCHAR mediaState;
181
182 NdisRawReadPortUchar(Adapter->IoBase + R_MS, &mediaState);
183 Adapter->MediaState = (mediaState & R_MS_LINKDWN) ? NdisMediaStateDisconnected :
185 Adapter->LinkSpeedMbps = (mediaState & R_MS_SPEED_10) ? 10 : 100;
186}
@ NdisMediaStateDisconnected
Definition: ntddndis.h:492
#define R_MS_LINKDWN
Definition: rtlhw.h:82
#define R_MS_SPEED_10
Definition: rtlhw.h:83
#define R_MS
Definition: rtlhw.h:80