ReactOS  0.4.15-dev-5097-g328cc41
nic.h
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Intel PRO/1000 Driver
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: Hardware specific functions
5  * COPYRIGHT: 2013 Cameron Gutman (cameron.gutman@reactos.org)
6  * 2018 Mark Jansen (mark.jansen@reactos.org)
7  * 2019 Victor Perevertkin (victor.perevertkin@reactos.org)
8  */
9 
10 #ifndef _E1000_PCH_
11 #define _E1000_PCH_
12 
13 #include <ndis.h>
14 
15 #include "e1000hw.h"
16 
17 #define E1000_TAG '001e'
18 
19 #define MAXIMUM_FRAME_SIZE 1522
20 #define RECEIVE_BUFFER_SIZE 2048
21 
22 #define DRIVER_VERSION 1
23 
24 #define DEFAULT_INTERRUPT_MASK (E1000_IMS_LSC | E1000_IMS_TXDW | E1000_IMS_TXQE | E1000_IMS_RXDMT0 | E1000_IMS_RXT0 | E1000_IMS_TXD_LOW)
25 
26 
27 typedef struct _E1000_ADAPTER
28 {
29  /* NIC Memory */
30  volatile PUCHAR IoBase;
33 
34  // NDIS_SPIN_LOCK AdapterLock;
35 
41 
43 
44  struct {
48 
52 
53  /* Io Port */
56  volatile PUCHAR IoPort;
57 
58  /* Interrupt */
63 
66 
68 
71 
72 
73  /* Transmit */
76 
78 
82 
83 
84  /* Receive */
87 
92 
94 
95 
96 BOOLEAN
97 NTAPI
99  IN PE1000_ADAPTER Adapter);
100 
102 NTAPI
104  IN PE1000_ADAPTER Adapter,
106 
108 NTAPI
110  IN PE1000_ADAPTER Adapter);
111 
113 NTAPI
115  IN PE1000_ADAPTER Adapter);
116 
118 NTAPI
120  IN PE1000_ADAPTER Adapter);
121 
123 NTAPI
125  IN PE1000_ADAPTER Adapter);
126 
128 NTAPI
129 NICPowerOn(
130  IN PE1000_ADAPTER Adapter);
131 
133 NTAPI
135  IN PE1000_ADAPTER Adapter);
136 
138 NTAPI
140  IN PE1000_ADAPTER Adapter);
141 
143 NTAPI
145  IN PE1000_ADAPTER Adapter);
146 
148 NTAPI
150  IN PE1000_ADAPTER Adapter,
151  OUT PUCHAR MacAddress);
152 
154 NTAPI
156  IN PE1000_ADAPTER Adapter);
157 
159 NTAPI
161  IN PE1000_ADAPTER Adapter);
162 
163 VOID
164 NTAPI
166  IN PE1000_ADAPTER Adapter);
167 
169 NTAPI
171  _In_ NDIS_HANDLE MiniportAdapterContext,
173  _In_ UINT Flags);
174 
176 NTAPI
178  IN NDIS_HANDLE MiniportAdapterContext,
179  IN NDIS_OID Oid,
180  IN PVOID InformationBuffer,
181  IN ULONG InformationBufferLength,
183  OUT PULONG BytesNeeded);
184 
186 NTAPI
188  IN NDIS_HANDLE MiniportAdapterContext,
189  IN NDIS_OID Oid,
190  IN PVOID InformationBuffer,
191  IN ULONG InformationBufferLength,
193  OUT PULONG BytesNeeded);
194 
195 VOID
196 NTAPI
198  OUT PBOOLEAN InterruptRecognized,
199  OUT PBOOLEAN QueueMiniportHandleInterrupt,
200  IN NDIS_HANDLE MiniportAdapterContext);
201 
202 VOID
203 NTAPI
205  IN NDIS_HANDLE MiniportAdapterContext);
206 
208 VOID
210  _In_ PE1000_ADAPTER Adapter,
213 {
214  NdisReadRegisterUlong((PULONG)(Adapter->IoBase + Address), Value);
215 }
216 
218 VOID
220  _In_ PE1000_ADAPTER Adapter,
222  _In_ ULONG Value)
223 {
224  NdisWriteRegisterUlong((PULONG)(Adapter->IoBase + Address), Value);
225 }
226 
228 VOID
230  _In_ PE1000_ADAPTER Adapter,
232  _In_ ULONG Value)
233 {
234  volatile ULONG Dummy;
235 
236  NdisRawWritePortUlong((PULONG)(Adapter->IoPort), Address);
237  NdisReadRegisterUlong(Adapter->IoBase + E1000_REG_STATUS, &Dummy);
238  NdisRawWritePortUlong((PULONG)(Adapter->IoPort + 4), Value);
239 }
240 
242 VOID
244  _In_ PE1000_ADAPTER Adapter)
245 {
246  E1000WriteUlong(Adapter, E1000_REG_IMS, Adapter->InterruptMask /*| 0x1F6DC*/);
247 }
248 
250 VOID
252  _In_ PE1000_ADAPTER Adapter)
253 {
254  E1000WriteUlong(Adapter, E1000_REG_IMC, ~0);
255 }
256 
257 #endif /* _E1000_PCH_ */
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:949
ULONG MulticastListSize
Definition: nic.h:47
#define NdisWriteRegisterUlong(Register, Data)
Definition: ndis.h:4294
#define IN
Definition: typedefs.h:39
#define MAXIMUM_MULTICAST_ADDRESSES
Definition: e1000hw.h:23
enum _E1000_RCVBUF_SIZE E1000_RCVBUF_SIZE
NDIS_STATUS NTAPI NICRegisterInterrupts(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:392
_Interlocked_ volatile LONG InterruptPending
Definition: nic.h:70
NDIS_STATUS NTAPI NICInitializeAdapterResources(IN PE1000_ADAPTER Adapter, IN PNDIS_RESOURCE_LIST ResourceList)
Definition: hardware.c:241
#define E1000_REG_STATUS
Definition: e1000hw.h:115
NDIS_STATUS NTAPI NICSoftReset(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:531
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
ULONG IoPortLength
Definition: nic.h:55
NDIS_PHYSICAL_ADDRESS ReceiveBufferPa
Definition: nic.h:90
NDIS_HANDLE AdapterHandle
Definition: nic.h:36
#define _Out_
Definition: ms_sal.h:345
USHORT SubsystemVendorID
Definition: nic.h:40
FORCEINLINE VOID NICDisableInterrupts(_In_ PE1000_ADAPTER Adapter)
Definition: nic.h:251
PE1000_RECEIVE_DESCRIPTOR ReceiveDescriptors
Definition: nic.h:85
VOID NTAPI MiniportISR(OUT PBOOLEAN InterruptRecognized, OUT PBOOLEAN QueueMiniportHandleInterrupt, IN NDIS_HANDLE MiniportAdapterContext)
Definition: interrupt.c:16
volatile PUCHAR IoPort
Definition: nic.h:56
FORCEINLINE VOID E1000WriteUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:219
volatile PUCHAR ReceiveBuffer
Definition: nic.h:89
unsigned char * PUCHAR
Definition: retypes.h:3
struct _E1000_ADAPTER * PE1000_ADAPTER
FORCEINLINE VOID E1000WriteIoUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:229
NDIS_PHYSICAL_ADDRESS ReceiveDescriptorsPa
Definition: nic.h:86
ULONG NDIS_OID
Definition: ntddndis.h:230
USHORT VendorID
Definition: nic.h:37
BOOLEAN InterruptShared
Definition: nic.h:61
#define E1000_REG_IMC
Definition: e1000hw.h:123
USHORT SubsystemID
Definition: nic.h:39
#define NUM_TRANSMIT_DESCRIPTORS
Definition: e1000hw.h:108
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:304
NDIS_STATUS NTAPI MiniportSend(_In_ NDIS_HANDLE MiniportAdapterContext, _In_ PNDIS_PACKET Packet, _In_ UINT Flags)
Definition: send.c:49
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:859
NDIS_MINIPORT_INTERRUPT Interrupt
Definition: nic.h:64
int NDIS_STATUS
Definition: ntddndis.h:475
BOOLEAN NTAPI NICRecognizeHardware(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:214
BOOLEAN InterruptRegistered
Definition: nic.h:65
ULONG PacketFilter
Definition: nic.h:51
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
long LONG
Definition: pedump.c:60
ULONG InterruptLevel
Definition: nic.h:60
unsigned char BOOLEAN
static WCHAR Address[46]
Definition: ping.c:68
#define _In_
Definition: ms_sal.h:308
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
NDIS_PHYSICAL_ADDRESS TransmitDescriptorsPa
Definition: nic.h:75
VOID NTAPI MiniportHandleInterrupt(IN NDIS_HANDLE MiniportAdapterContext)
Definition: interrupt.c:46
ULONG MediaState
Definition: nic.h:50
ULONG IoLength
Definition: nic.h:32
#define E1000_REG_IMS
Definition: e1000hw.h:122
struct _E1000_ADAPTER::@966 MulticastList[MAXIMUM_MULTICAST_ADDRESSES]
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: info.c:73
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
UCHAR MacAddress[IEEE_802_ADDR_LENGTH]
Definition: nic.h:45
NDIS_STATUS NTAPI NICReleaseIoResources(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:433
ULONG LinkSpeedMbps
Definition: nic.h:49
NDIS_STATUS NTAPI NICAllocateIoResources(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:309
#define IEEE_802_ADDR_LENGTH
Definition: e1000hw.h:11
VOID NTAPI NICUpdateLinkStatus(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:738
ULONG LastTxDesc
Definition: nic.h:80
BOOLEAN TxFull
Definition: nic.h:81
ULONG InterruptVector
Definition: nic.h:59
UCHAR PermanentMacAddress[IEEE_802_ADDR_LENGTH]
Definition: nic.h:42
FORCEINLINE VOID NICApplyInterruptMask(_In_ PE1000_ADAPTER Adapter)
Definition: nic.h:243
PE1000_TRANSMIT_DESCRIPTOR TransmitDescriptors
Definition: nic.h:74
NDIS_STATUS NTAPI NICEnableTxRx(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:574
unsigned char UCHAR
Definition: xmlstorage.h:181
char * PBOOLEAN
Definition: retypes.h:11
ULONG CurrentTxDesc
Definition: nic.h:79
ULONG ReceiveBufferEntrySize
Definition: nic.h:91
NDIS_PHYSICAL_ADDRESS IoAddress
Definition: nic.h:31
struct _E1000_ADAPTER E1000_ADAPTER
PNDIS_PACKET TransmitPackets[NUM_TRANSMIT_DESCRIPTORS]
Definition: nic.h:77
NDIS_STATUS NTAPI NICDisableTxRx(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:641
NDIS_STATUS NTAPI NICPowerOn(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:509
FORCEINLINE VOID E1000ReadUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _Out_ PULONG Value)
Definition: nic.h:209
unsigned short USHORT
Definition: pedump.c:61
#define FORCEINLINE
Definition: wdftypes.h:67
unsigned int * PULONG
Definition: retypes.h:1
unsigned int UINT
Definition: ndis.h:50
#define NdisReadRegisterUlong(Register, Data)
Definition: ndis.h:4267
ULONG InterruptFlags
Definition: nic.h:62
#define OUT
Definition: typedefs.h:40
unsigned int ULONG
Definition: retypes.h:1
USHORT DeviceID
Definition: nic.h:38
LONG InterruptMask
Definition: nic.h:67
ULONG IoPortAddress
Definition: nic.h:54
volatile PUCHAR IoBase
Definition: nic.h:30
#define _Interlocked_
NDIS_STATUS NTAPI NICGetPermanentMacAddress(IN PE1000_ADAPTER Adapter, OUT PUCHAR MacAddress)
Definition: hardware.c:661
E1000_RCVBUF_SIZE ReceiveBufferType
Definition: nic.h:88
NDIS_STATUS NTAPI NICUpdateMulticastList(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:691
NDIS_STATUS NTAPI NICUnregisterInterrupts(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:417
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: info.c:276
NDIS_STATUS NTAPI NICApplyPacketFilter(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:722
#define NdisRawWritePortUlong(Port, Data)
Definition: ndis.h:4239