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 // NDIS_SPIN_LOCK AdapterLock; 30 31 NDIS_HANDLE AdapterHandle; 32 USHORT VendorID; 33 USHORT DeviceID; 34 USHORT SubsystemID; 35 USHORT SubsystemVendorID; 36 37 UCHAR PermanentMacAddress[IEEE_802_ADDR_LENGTH]; 38 struct { 39 UCHAR MacAddress[IEEE_802_ADDR_LENGTH]; 40 } MulticastList[MAXIMUM_MULTICAST_ADDRESSES]; 41 42 ULONG LinkSpeedMbps; 43 ULONG MediaState; 44 ULONG PacketFilter; 45 46 /* Io Port */ 47 ULONG IoPortAddress; 48 ULONG IoPortLength; 49 volatile PUCHAR IoPort; 50 51 /* NIC Memory */ 52 NDIS_PHYSICAL_ADDRESS IoAddress; 53 ULONG IoLength; 54 volatile PUCHAR IoBase; 55 56 /* Interrupt */ 57 ULONG InterruptVector; 58 ULONG InterruptLevel; 59 BOOLEAN InterruptShared; 60 ULONG InterruptFlags; 61 62 NDIS_MINIPORT_INTERRUPT Interrupt; 63 BOOLEAN InterruptRegistered; 64 65 LONG InterruptMask; 66 LONG InterruptPending; 67 68 69 /* Transmit */ 70 PE1000_TRANSMIT_DESCRIPTOR TransmitDescriptors; 71 NDIS_PHYSICAL_ADDRESS TransmitDescriptorsPa; 72 73 PNDIS_PACKET TransmitPackets[NUM_TRANSMIT_DESCRIPTORS]; 74 75 ULONG CurrentTxDesc; 76 ULONG LastTxDesc; 77 BOOLEAN TxFull; 78 79 80 /* Receive */ 81 PE1000_RECEIVE_DESCRIPTOR ReceiveDescriptors; 82 NDIS_PHYSICAL_ADDRESS ReceiveDescriptorsPa; 83 84 E1000_RCVBUF_SIZE ReceiveBufferType; 85 volatile PUCHAR ReceiveBuffer; 86 NDIS_PHYSICAL_ADDRESS ReceiveBufferPa; 87 ULONG ReceiveBufferEntrySize; 88 89 } E1000_ADAPTER, *PE1000_ADAPTER; 90 91 92 BOOLEAN 93 NTAPI 94 NICRecognizeHardware( 95 IN PE1000_ADAPTER Adapter); 96 97 NDIS_STATUS 98 NTAPI 99 NICInitializeAdapterResources( 100 IN PE1000_ADAPTER Adapter, 101 IN PNDIS_RESOURCE_LIST ResourceList); 102 103 NDIS_STATUS 104 NTAPI 105 NICAllocateIoResources( 106 IN PE1000_ADAPTER Adapter); 107 108 NDIS_STATUS 109 NTAPI 110 NICRegisterInterrupts( 111 IN PE1000_ADAPTER Adapter); 112 113 NDIS_STATUS 114 NTAPI 115 NICUnregisterInterrupts( 116 IN PE1000_ADAPTER Adapter); 117 118 NDIS_STATUS 119 NTAPI 120 NICReleaseIoResources( 121 IN PE1000_ADAPTER Adapter); 122 123 NDIS_STATUS 124 NTAPI 125 NICPowerOn( 126 IN PE1000_ADAPTER Adapter); 127 128 NDIS_STATUS 129 NTAPI 130 NICSoftReset( 131 IN PE1000_ADAPTER Adapter); 132 133 NDIS_STATUS 134 NTAPI 135 NICEnableTxRx( 136 IN PE1000_ADAPTER Adapter); 137 138 NDIS_STATUS 139 NTAPI 140 NICDisableTxRx( 141 IN PE1000_ADAPTER Adapter); 142 143 NDIS_STATUS 144 NTAPI 145 NICGetPermanentMacAddress( 146 IN PE1000_ADAPTER Adapter, 147 OUT PUCHAR MacAddress); 148 149 NDIS_STATUS 150 NTAPI 151 NICUpdateMulticastList( 152 IN PE1000_ADAPTER Adapter); 153 154 NDIS_STATUS 155 NTAPI 156 NICApplyPacketFilter( 157 IN PE1000_ADAPTER Adapter); 158 159 NDIS_STATUS 160 NTAPI 161 NICApplyInterruptMask( 162 IN PE1000_ADAPTER Adapter); 163 164 NDIS_STATUS 165 NTAPI 166 NICDisableInterrupts( 167 IN PE1000_ADAPTER Adapter); 168 169 ULONG 170 NTAPI 171 NICInterruptRecognized( 172 IN PE1000_ADAPTER Adapter, 173 OUT PBOOLEAN InterruptRecognized); 174 175 VOID 176 NTAPI 177 NICUpdateLinkStatus( 178 IN PE1000_ADAPTER Adapter); 179 180 NDIS_STATUS 181 NTAPI 182 NICTransmitPacket( 183 IN PE1000_ADAPTER Adapter, 184 IN PHYSICAL_ADDRESS PhysicalAddress, 185 IN ULONG Length); 186 187 NDIS_STATUS 188 NTAPI 189 MiniportSetInformation( 190 IN NDIS_HANDLE MiniportAdapterContext, 191 IN NDIS_OID Oid, 192 IN PVOID InformationBuffer, 193 IN ULONG InformationBufferLength, 194 OUT PULONG BytesRead, 195 OUT PULONG BytesNeeded); 196 197 NDIS_STATUS 198 NTAPI 199 MiniportQueryInformation( 200 IN NDIS_HANDLE MiniportAdapterContext, 201 IN NDIS_OID Oid, 202 IN PVOID InformationBuffer, 203 IN ULONG InformationBufferLength, 204 OUT PULONG BytesWritten, 205 OUT PULONG BytesNeeded); 206 207 VOID 208 NTAPI 209 MiniportISR( 210 OUT PBOOLEAN InterruptRecognized, 211 OUT PBOOLEAN QueueMiniportHandleInterrupt, 212 IN NDIS_HANDLE MiniportAdapterContext); 213 214 VOID 215 NTAPI 216 MiniportHandleInterrupt( 217 IN NDIS_HANDLE MiniportAdapterContext); 218 219 220 VOID 221 NTAPI 222 E1000ReadUlong( 223 IN PE1000_ADAPTER Adapter, 224 IN ULONG Address, 225 OUT PULONG Value); 226 227 VOID 228 NTAPI 229 E1000WriteUlong( 230 IN PE1000_ADAPTER Adapter, 231 IN ULONG Address, 232 IN ULONG Value); 233 234 #endif /* _E1000_PCH_ */ 235