ReactOS 0.4.16-dev-329-g9223134
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:470
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 73 of file info.c.

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

283{
284 PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
285 ULONG genericUlong;
287
289
290 switch (Oid)
291 {
293 if (InformationBufferLength < sizeof(ULONG))
294 {
295 *BytesRead = 0;
296 *BytesNeeded = sizeof(ULONG);
298 break;
299 }
300
301 NdisMoveMemory(&genericUlong, InformationBuffer, sizeof(ULONG));
302
303 if (genericUlong &
310 {
311 *BytesRead = sizeof(ULONG);
312 *BytesNeeded = sizeof(ULONG);
314 break;
315 }
316
317 if (Adapter->PacketFilter == genericUlong)
318 {
319 break;
320 }
321
322 Adapter->PacketFilter = genericUlong;
323
324 status = NICApplyPacketFilter(Adapter);
326 {
327 NDIS_DbgPrint(MIN_TRACE, ("Failed to apply new packet filter (0x%x)\n", status));
328 break;
329 }
330
331 break;
332
334 if (InformationBufferLength < sizeof(ULONG))
335 {
336 *BytesRead = 0;
337 *BytesNeeded = sizeof(ULONG);
339 break;
340 }
341
342 NdisMoveMemory(&genericUlong, InformationBuffer, sizeof(ULONG));
343
344 if (genericUlong > MAXIMUM_FRAME_SIZE - sizeof(ETH_HEADER))
345 {
347 }
348 else
349 {
350 // Ignore this...
351 }
352
353 break;
354
356 if (InformationBufferLength % IEEE_802_ADDR_LENGTH)
357 {
358 *BytesRead = 0;
359 *BytesNeeded = InformationBufferLength + (InformationBufferLength % IEEE_802_ADDR_LENGTH);
361 break;
362 }
363
364 if (InformationBufferLength > sizeof(Adapter->MulticastList))
365 {
366 *BytesNeeded = sizeof(Adapter->MulticastList);
367 *BytesRead = 0;
369 break;
370 }
371
372 NdisMoveMemory(Adapter->MulticastList, InformationBuffer, InformationBufferLength);
373
374 Adapter->MulticastListSize = InformationBufferLength / IEEE_802_ADDR_LENGTH;
375
376 NICUpdateMulticastList(Adapter);
377 break;
378
379 default:
380 NDIS_DbgPrint(MIN_TRACE, ("Unknown OID 0x%x(%s)\n", Oid, Oid2Str(Oid)));
382 *BytesRead = 0;
383 *BytesNeeded = 0;
384 break;
385 }
386
388 {
389 *BytesRead = InformationBufferLength;
390 *BytesNeeded = 0;
391 }
392
393 return status;
394}
NDIS_STATUS NTAPI NICApplyPacketFilter(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:724
NDIS_STATUS NTAPI NICUpdateMulticastList(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:693
#define NDIS_PACKET_TYPE_PROMISCUOUS
Definition: ndis.h:668
#define NDIS_STATUS_INVALID_DATA
Definition: ndis.h:486
#define NDIS_PACKET_TYPE_MAC_FRAME
Definition: ndis.h:674
#define NDIS_STATUS_INVALID_LENGTH
Definition: ndis.h:485
#define NDIS_PACKET_TYPE_BROADCAST
Definition: ndis.h:666
#define NDIS_PACKET_TYPE_MULTICAST
Definition: ndis.h:664
#define NDIS_PACKET_TYPE_DIRECTED
Definition: ndis.h:663
#define NDIS_PACKET_TYPE_ALL_MULTICAST
Definition: ndis.h:665
#define NDIS_STATUS_MULTICAST_FULL
Definition: ndis.h:473
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870

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}
unsigned int UINT
Definition: ndis.h:50
#define NdisRawReadPortUchar(Port, Data)
Definition: ndis.h:4173
#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:2928
#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:471
#define R_MS_LINKDWN
Definition: rtlhw.h:82
#define R_MS_SPEED_10
Definition: rtlhw.h:83
#define R_MS
Definition: rtlhw.h:80