- Limit the number of interrupts that are handled per call to MiniportHandleInterrup...
[reactos.git] / reactos / drivers / network / dd / ne2000 / include / ne2000.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Novell Eagle 2000 driver
4 * FILE: include/ne2000.h
5 * PURPOSE: NE2000 driver definitions
6 */
7 #ifndef __NE2000_H
8 #define __NE2000_H
9
10 #define NDIS_MINIPORT_DRIVER 1
11 #define NDIS_LEGACY_MINIPORT 1
12 #define NDIS51_MINIPORT 1
13 #include <ndis.h>
14 #include <8390.h>
15 #include <debug.h>
16
17 /* Define NOCARD to test NDIS without a card */
18 //#define NOCARD
19
20 /* NE2000 sepcific constants */
21 #define NIC_DATA 0x10 /* Data register */
22 #define NIC_RESET 0x1F /* Reset register */
23
24
25 /* Global constants */
26
27 #define DRIVER_NDIS_MAJOR_VERSION 3
28 #define DRIVER_NDIS_MINOR_VERSION 0
29
30 #define DRIVER_DEFAULT_IO_BASE_ADDRESS 0x280 /* bochs default */
31 #define DRIVER_DEFAULT_INTERRUPT_NUMBER 9 /* bochs default */
32 #define DRIVER_DEFAULT_INTERRUPT_SHARED FALSE
33 #define DRIVER_DEFAULT_INTERRUPT_MODE NdisInterruptLatched
34
35 #define DRIVER_MAX_MULTICAST_LIST_SIZE 8
36
37 #define DRIVER_VENDOR_DESCRIPTION "Novell Eagle 2000 Adapter."
38 #define DRIVER_VENDOR_DRIVER_VERSION 0x0100 /* 1.0 */
39
40 #define DRIVER_FRAME_SIZE 1514 /* Size of an ethernet frame */
41 #define DRIVER_HEADER_SIZE 14 /* Size of an ethernet header */
42 #define DRIVER_LENGTH_OF_ADDRESS 6 /* Size of an ethernet address */
43
44 /* Maximum lookahead buffer size */
45 #define DRIVER_MAXIMUM_LOOKAHEAD (252 - DRIVER_HEADER_SIZE)
46
47 /* Size of a block in a buffer ring */
48 #define DRIVER_BLOCK_SIZE 256
49
50
51 /* Default number of transmit buffers */
52 #define DRIVER_DEFAULT_TX_BUFFER_COUNT 12
53 #define BUFFERS_PER_TX_BUF 1
54
55 /* Interrupt Mask Register value */
56 #define DRIVER_INTERRUPT_MASK IMR_ALLE - IMR_RDCE
57
58 /* Maximum number of interrupts handled per call to MiniportHandleInterrupt */
59 #define INTERRUPT_LIMIT 10
60
61 /* Global structures */
62
63 typedef struct _MINIPORT_RESERVED
64 {
65 PNDIS_PACKET Next;
66 } MINIPORT_RESERVED, *PMINIPORT_RESERVED;
67
68 #define RESERVED(Packet) ((PMINIPORT_RESERVED)((Packet)->MiniportReserved))
69
70 typedef UCHAR DRIVER_HARDWARE_ADDRESS[DRIVER_LENGTH_OF_ADDRESS];
71
72 /* Information about an adapter */
73 typedef struct _NIC_ADAPTER
74 {
75 /* Entry on global adapter list */
76 LIST_ENTRY ListEntry;
77 /* Adapter handle */
78 NDIS_HANDLE MiniportAdapterHandle;
79 /* NDIS interrupt object */
80 NDIS_MINIPORT_INTERRUPT Interrupt;
81
82 /* I/O base address and interrupt number of adapter */
83 ULONG IoBaseAddress;
84 ULONG InterruptLevel;
85 ULONG InterruptVector;
86 BOOLEAN InterruptShared;
87 KINTERRUPT_MODE InterruptMode;
88
89 /* Mapped address of the I/O base port */
90 PUCHAR IOBase;
91
92 /* TRUE if the NIC can transfer in word mode */
93 BOOLEAN WordMode;
94
95 /* Base address and size of the onboard memory window */
96 PUCHAR RamBase;
97 UINT RamSize;
98
99 /* Station Address PROM (SAPROM) */
100 UCHAR SAPROM[16];
101
102 /* Onboard ethernet address from the manufacturer */
103 DRIVER_HARDWARE_ADDRESS PermanentAddress;
104
105 /* Ethernet address currently in use */
106 DRIVER_HARDWARE_ADDRESS StationAddress;
107
108 /* Maximum number of multicast addresses this adapter supports */
109 ULONG MaxMulticastListSize;
110
111 /* List of multicast addresses in use */
112 DRIVER_HARDWARE_ADDRESS Addresses[DRIVER_MAX_MULTICAST_LIST_SIZE];
113
114 /* Current multicast address mask */
115 UCHAR MulticastAddressMask[8];
116
117 /* Masked interrupts (IMR value) */
118 ULONG InterruptMask;
119
120 /* Interrupts that have occurred */
121 UCHAR InterruptStatus;
122
123 /* Current packet filter */
124 ULONG PacketFilter;
125
126 /* Lookahead buffer */
127 UINT LookaheadSize;
128 UCHAR Lookahead[DRIVER_MAXIMUM_LOOKAHEAD + DRIVER_HEADER_SIZE];
129
130 /* Receive buffer ring */
131 UINT PageStart;
132 UINT PageStop;
133 UINT CurrentPage;
134 UINT NextPacket;
135
136 /* TRUE if there was a buffer overflow */
137 BOOLEAN BufferOverflow;
138
139 /* TRUE if an error occurred during reception of a packet */
140 BOOLEAN ReceiveError;
141
142 /* TRUE if an error occurred during transmission of a packet */
143 BOOLEAN TransmitError;
144
145 /* TRUE if a transmit interrupt is pending */
146 BOOLEAN TransmitPending;
147
148 /* Received packet header */
149 PACKET_HEADER PacketHeader;
150
151 /* Offset in onboard RAM of received packet */
152 ULONG PacketOffset;
153
154 /* TRUE if receive indications are done and should be completed */
155 BOOLEAN DoneIndicating;
156
157 /* Transmit buffers */
158 UINT TXStart; /* Start block of transmit buffer ring */
159 UINT TXCount; /* Number of blocks in transmit buffer ring */
160 UINT TXFree; /* Number of free transmit buffers */
161 UINT TXNext; /* Next buffer to use */
162 /* Length of packet. 0 means buffer is unused */
163 UINT TXSize[DRIVER_DEFAULT_TX_BUFFER_COUNT];
164 INT TXCurrent; /* Current buffer beeing transmitted. -1 means none */
165
166 /* Head of transmit queue */
167 PNDIS_PACKET TXQueueHead;
168 /* Tail of transmit queue */
169 PNDIS_PACKET TXQueueTail;
170
171 /* Statistics */
172 ULONG FrameAlignmentErrors;
173 ULONG CrcErrors;
174 ULONG MissedPackets;
175
176 /* Flags used for driver cleanup */
177 BOOLEAN IOPortRangeRegistered;
178 BOOLEAN InterruptRegistered;
179 BOOLEAN ShutdownHandlerRegistered;
180 } NIC_ADAPTER, *PNIC_ADAPTER;
181
182 /* Global driver information */
183 typedef struct _DRIVER_INFORMATION
184 {
185 NDIS_HANDLE NdisWrapperHandle; /* Returned from NdisInitializeWrapper */
186 NDIS_HANDLE NdisMacHandle; /* Returned from NdisRegisterMac */
187 LIST_ENTRY AdapterListHead; /* Adapters this driver control */
188 } DRIVER_INFORMATION, *PDRIVER_INFORMATION;
189
190
191
192 /* Global variable */
193
194 extern DRIVER_INFORMATION DriverInfo;
195 extern NDIS_PHYSICAL_ADDRESS HighestAcceptableMax;
196
197
198
199 /* Prototypes */
200
201 BOOLEAN NICCheck(
202 PNIC_ADAPTER Adapter);
203
204 NDIS_STATUS NICInitialize(
205 PNIC_ADAPTER Adapter);
206
207 NDIS_STATUS NICSetup(
208 PNIC_ADAPTER Adapter);
209
210 NDIS_STATUS NICStart(
211 PNIC_ADAPTER Adapter);
212
213 NDIS_STATUS NICStop(
214 PNIC_ADAPTER Adapter);
215
216 NDIS_STATUS NICReset(
217 PNIC_ADAPTER Adapter);
218
219 VOID NICUpdateCounters(
220 PNIC_ADAPTER Adapter);
221
222 VOID NICReadDataAlign(
223 PNIC_ADAPTER Adapter,
224 PUSHORT Target,
225 ULONG Source,
226 USHORT Length);
227
228 VOID NICWriteDataAlign(
229 PNIC_ADAPTER Adapter,
230 ULONG Target,
231 PUSHORT Source,
232 USHORT Length);
233
234 VOID NICReadData(
235 PNIC_ADAPTER Adapter,
236 PUCHAR Target,
237 ULONG Source,
238 USHORT Length);
239
240 VOID NICWriteData(
241 PNIC_ADAPTER Adapter,
242 ULONG Target,
243 PUCHAR Source,
244 USHORT Length);
245
246 VOID NICTransmit(
247 PNIC_ADAPTER Adapter);
248
249 #endif /* __NE2000_H */
250
251 /* EOF */