ReactOS 0.4.16-dev-109-gf4cb10f
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
27typedef 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
99 IN PE1000_ADAPTER Adapter);
100
102NTAPI
104 IN PE1000_ADAPTER Adapter,
106
108NTAPI
110 IN PE1000_ADAPTER Adapter);
111
113NTAPI
115 IN PE1000_ADAPTER Adapter);
116
118NTAPI
120 IN PE1000_ADAPTER Adapter);
121
123NTAPI
125 IN PE1000_ADAPTER Adapter);
126
128NTAPI
130 IN PE1000_ADAPTER Adapter);
131
133NTAPI
135 IN PE1000_ADAPTER Adapter);
136
138NTAPI
140 IN PE1000_ADAPTER Adapter);
141
143NTAPI
145 IN PE1000_ADAPTER Adapter);
146
148NTAPI
150 IN PE1000_ADAPTER Adapter,
151 OUT PUCHAR MacAddress);
152
154NTAPI
156 IN PE1000_ADAPTER Adapter);
157
159NTAPI
161 IN PE1000_ADAPTER Adapter);
162
163VOID
164NTAPI
166 IN PE1000_ADAPTER Adapter);
167
169NTAPI
171 _In_ NDIS_HANDLE MiniportAdapterContext,
173 _In_ UINT Flags);
174
176NTAPI
178 IN NDIS_HANDLE MiniportAdapterContext,
179 IN NDIS_OID Oid,
180 IN PVOID InformationBuffer,
181 IN ULONG InformationBufferLength,
183 OUT PULONG BytesNeeded);
184
186NTAPI
188 IN NDIS_HANDLE MiniportAdapterContext,
189 IN NDIS_OID Oid,
190 IN PVOID InformationBuffer,
191 IN ULONG InformationBufferLength,
193 OUT PULONG BytesNeeded);
194
195VOID
196NTAPI
198 OUT PBOOLEAN InterruptRecognized,
199 OUT PBOOLEAN QueueMiniportHandleInterrupt,
200 IN NDIS_HANDLE MiniportAdapterContext);
201
202VOID
203NTAPI
205 IN NDIS_HANDLE MiniportAdapterContext);
206
208VOID
210 _In_ PE1000_ADAPTER Adapter,
213{
214 NdisReadRegisterUlong((PULONG)(Adapter->IoBase + Address), Value);
215}
216
218VOID
220 _In_ PE1000_ADAPTER Adapter,
223{
224 NdisWriteRegisterUlong((PULONG)(Adapter->IoBase + Address), Value);
225}
226
228VOID
230 _In_ PE1000_ADAPTER Adapter,
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
242VOID
244 _In_ PE1000_ADAPTER Adapter)
245{
246 E1000WriteUlong(Adapter, E1000_REG_IMS, Adapter->InterruptMask /*| 0x1F6DC*/);
247}
248
250VOID
252 _In_ PE1000_ADAPTER Adapter)
253{
254 E1000WriteUlong(Adapter, E1000_REG_IMC, ~0);
255}
256
257#endif /* _E1000_PCH_ */
#define NICDisableInterrupts(Adapter)
Definition: 8390.h:159
unsigned char BOOLEAN
#define _Interlocked_
NDIS_STATUS NTAPI NICRegisterInterrupts(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:392
NDIS_STATUS NTAPI NICPowerOn(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:509
NDIS_STATUS NTAPI NICEnableTxRx(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:574
NDIS_STATUS NTAPI NICSoftReset(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:531
BOOLEAN NTAPI NICRecognizeHardware(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:214
NDIS_STATUS NTAPI NICGetPermanentMacAddress(IN PE1000_ADAPTER Adapter, OUT PUCHAR MacAddress)
Definition: hardware.c:661
struct _E1000_ADAPTER E1000_ADAPTER
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
struct _E1000_ADAPTER * PE1000_ADAPTER
VOID NTAPI MiniportISR(OUT PBOOLEAN InterruptRecognized, OUT PBOOLEAN QueueMiniportHandleInterrupt, IN NDIS_HANDLE MiniportAdapterContext)
Definition: interrupt.c:16
NDIS_STATUS NTAPI NICAllocateIoResources(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:309
NDIS_STATUS NTAPI NICApplyPacketFilter(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:724
VOID NTAPI NICUpdateLinkStatus(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:740
VOID NTAPI MiniportHandleInterrupt(IN NDIS_HANDLE MiniportAdapterContext)
Definition: interrupt.c:46
NDIS_STATUS NTAPI NICReleaseIoResources(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:433
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
FORCEINLINE VOID E1000WriteIoUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:229
NDIS_STATUS NTAPI NICDisableTxRx(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:641
NDIS_STATUS NTAPI NICUpdateMulticastList(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:693
FORCEINLINE VOID E1000ReadUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _Out_ PULONG Value)
Definition: nic.h:209
NDIS_STATUS NTAPI MiniportSend(_In_ NDIS_HANDLE MiniportAdapterContext, _In_ PNDIS_PACKET Packet, _In_ UINT Flags)
Definition: send.c:49
FORCEINLINE VOID NICApplyInterruptMask(_In_ PE1000_ADAPTER Adapter)
Definition: nic.h:243
NDIS_STATUS NTAPI NICUnregisterInterrupts(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:417
NDIS_STATUS NTAPI NICInitializeAdapterResources(IN PE1000_ADAPTER Adapter, IN PNDIS_RESOURCE_LIST ResourceList)
Definition: hardware.c:241
FORCEINLINE VOID E1000WriteUlong(_In_ PE1000_ADAPTER Adapter, _In_ ULONG Address, _In_ ULONG Value)
Definition: nic.h:219
#define E1000_REG_IMS
Definition: e1000hw.h:122
#define E1000_REG_IMC
Definition: e1000hw.h:123
#define MAXIMUM_MULTICAST_ADDRESSES
Definition: e1000hw.h:23
#define E1000_REG_STATUS
Definition: e1000hw.h:115
#define IEEE_802_ADDR_LENGTH
Definition: e1000hw.h:11
#define NUM_TRANSMIT_DESCRIPTORS
Definition: e1000hw.h:108
enum _E1000_RCVBUF_SIZE E1000_RCVBUF_SIZE
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1549
unsigned int UINT
Definition: ndis.h:50
#define NdisReadRegisterUlong(Register, Data)
Definition: ndis.h:4267
#define NdisRawWritePortUlong(Port, Data)
Definition: ndis.h:4239
#define NdisWriteRegisterUlong(Register, Data)
Definition: ndis.h:4294
int NDIS_STATUS
Definition: ntddndis.h:475
ULONG NDIS_OID
Definition: ntddndis.h:230
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
static WCHAR Address[46]
Definition: ping.c:68
ULONG LinkSpeedMbps
Definition: nic.h:49
BOOLEAN InterruptShared
Definition: nic.h:61
PE1000_RECEIVE_DESCRIPTOR ReceiveDescriptors
Definition: nic.h:85
ULONG IoPortAddress
Definition: nic.h:54
ULONG LastTxDesc
Definition: nic.h:80
NDIS_PHYSICAL_ADDRESS IoAddress
Definition: nic.h:31
ULONG InterruptFlags
Definition: nic.h:62
LONG InterruptMask
Definition: nic.h:67
struct _E1000_ADAPTER::@999 MulticastList[MAXIMUM_MULTICAST_ADDRESSES]
NDIS_MINIPORT_INTERRUPT Interrupt
Definition: nic.h:64
ULONG PacketFilter
Definition: nic.h:51
BOOLEAN TxFull
Definition: nic.h:81
ULONG InterruptLevel
Definition: nic.h:60
volatile PUCHAR IoPort
Definition: nic.h:56
ULONG ReceiveBufferEntrySize
Definition: nic.h:91
PE1000_TRANSMIT_DESCRIPTOR TransmitDescriptors
Definition: nic.h:74
ULONG InterruptVector
Definition: nic.h:59
NDIS_PHYSICAL_ADDRESS ReceiveBufferPa
Definition: nic.h:90
ULONG MediaState
Definition: nic.h:50
E1000_RCVBUF_SIZE ReceiveBufferType
Definition: nic.h:88
PNDIS_PACKET TransmitPackets[NUM_TRANSMIT_DESCRIPTORS]
Definition: nic.h:77
USHORT SubsystemID
Definition: nic.h:39
ULONG MulticastListSize
Definition: nic.h:47
UCHAR PermanentMacAddress[IEEE_802_ADDR_LENGTH]
Definition: nic.h:42
volatile PUCHAR IoBase
Definition: nic.h:30
USHORT DeviceID
Definition: nic.h:38
ULONG IoLength
Definition: nic.h:32
BOOLEAN InterruptRegistered
Definition: nic.h:65
NDIS_HANDLE AdapterHandle
Definition: nic.h:36
USHORT SubsystemVendorID
Definition: nic.h:40
ULONG IoPortLength
Definition: nic.h:55
NDIS_PHYSICAL_ADDRESS TransmitDescriptorsPa
Definition: nic.h:75
_Interlocked_ volatile LONG InterruptPending
Definition: nic.h:70
volatile PUCHAR ReceiveBuffer
Definition: nic.h:89
NDIS_PHYSICAL_ADDRESS ReceiveDescriptorsPa
Definition: nic.h:86
UCHAR MacAddress[IEEE_802_ADDR_LENGTH]
Definition: nic.h:45
ULONG CurrentTxDesc
Definition: nic.h:79
USHORT VendorID
Definition: nic.h:37
uint32_t * PULONG
Definition: typedefs.h:59
unsigned char * PBOOLEAN
Definition: typedefs.h:53
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_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
_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
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
#define FORCEINLINE
Definition: wdftypes.h:67
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
unsigned char UCHAR
Definition: xmlstorage.h:181